MantisBT - VCMI
View Issue Details
0000948VCMIGUI - Battlespublic2012-05-04 09:382014-05-30 17:41
ench0 
Warmonger 
normalfeatureN/A
closedfixed 
 
0.89 
0000948: Add enemy unit movement shadow (like in King's Bounty - The Legend )
In the new King's Bounty (KB - The lgened and KB - Armored Princess) games there is a very neat feature, which I think would be great to add to VCMI.

In the battle, when you place the mouse over an enemy unit it turns off your current unit movement shadow and displays a shadow for the enemy unit (i.e. tells you how far this enemy unit would move in its turn).

A variant (perhaps slight improvement) of this feature would be to display a movement shadow for the the enemy unit without hiding your current unit's movement shadow. Perhaps display enemy's shadow with a slightly different color (reddish?). This way you could easily see how far you can move your unit without it being reachable by the enemy unit.
I will see if I can add a KB screen shot here to illustrate this featrue request
No tags attached.
related to 0000966closed Ivan Crash occurs at the end of the battle. 
? kb-enemy-movmt-shdw-256.bmp (397,870) 2012-05-07 16:54
https://bugs.vcmi.eu/file_download.php?file_id=921&type=bug
bmp

patch show-enemy-move-shadow.01.patch (1,328) 2012-05-14 13:01
https://bugs.vcmi.eu/file_download.php?file_id=923&type=bug
? CCELLSH2.bmp (3,572) 2012-05-28 08:25
https://bugs.vcmi.eu/file_download.php?file_id=949&type=bug
bmp

patch colorize-enemy-move-shadow.01.patch (2,053) 2012-05-28 08:25
https://bugs.vcmi.eu/file_download.php?file_id=950&type=bug
patch colorize-enemy-move-shadow.02.patch (969) 2012-05-28 09:04
https://bugs.vcmi.eu/file_download.php?file_id=951&type=bug
Issue History
2012-05-04 09:38ench0New Issue
2012-05-04 13:53majaczekNote Added: 0002401
2012-05-04 13:53majaczekNote Edited: 0002401bug_revision_view_page.php?bugnote_id=2401#r1568
2012-05-07 16:54ench0File Added: kb-enemy-movmt-shdw-256.bmp
2012-05-07 16:59ench0Note Added: 0002407
2012-05-14 13:01ench0File Added: show-enemy-move-shadow.01.patch
2012-05-14 13:07ench0Note Added: 0002423
2012-05-14 13:08ench0Note Added: 0002424
2012-05-14 13:08ench0Statusnew => feedback
2012-05-14 13:51ench0Note Edited: 0002424bug_revision_view_page.php?rev_id=1583
2012-05-14 13:51ench0Note Deleted: 0002424
2012-05-14 16:51IvanNote Added: 0002428
2012-05-14 17:11IvanNote Edited: 0002428bug_revision_view_page.php?bugnote_id=2428#r1585
2012-05-14 17:13IvanNote Edited: 0002428bug_revision_view_page.php?bugnote_id=2428#r1586
2012-05-14 21:45IvanNote Edited: 0002428bug_revision_view_page.php?bugnote_id=2428#r1587
2012-05-17 16:36ench0Note Added: 0002475
2012-05-17 16:36ench0Statusfeedback => new
2012-05-17 16:52IvanNote Added: 0002476
2012-05-22 08:28WarmongerAssigned To => Warmonger
2012-05-22 08:28WarmongerStatusnew => assigned
2012-05-22 10:16WarmongerNote Added: 0002518
2012-05-22 10:16WarmongerStatusassigned => resolved
2012-05-22 10:16WarmongerFixed in Version => 0.89
2012-05-22 10:16WarmongerResolutionopen => fixed
2012-05-23 13:33ench0Note Added: 0002529
2012-05-24 15:20IvanRelationship addedrelated to 0000966
2012-05-28 08:24ench0Note Added: 0002579
2012-05-28 08:24ench0Statusresolved => feedback
2012-05-28 08:24ench0Resolutionfixed => reopened
2012-05-28 08:25ench0File Added: CCELLSH2.bmp
2012-05-28 08:25ench0File Added: colorize-enemy-move-shadow.01.patch
2012-05-28 08:33ench0Note Edited: 0002579bug_revision_view_page.php?bugnote_id=2579#r1674
2012-05-28 08:34ench0Note Added: 0002580
2012-05-28 08:34ench0Statusfeedback => assigned
2012-05-28 08:35ench0Note Edited: 0002579bug_revision_view_page.php?bugnote_id=2579#r1675
2012-05-28 08:45IvanNote Added: 0002581
2012-05-28 09:04ench0File Added: colorize-enemy-move-shadow.02.patch
2012-05-28 09:11ench0Note Added: 0002582
2012-05-28 22:49TowNote Added: 0002584
2012-06-01 17:23TowNote Added: 0002598
2012-06-01 17:23TowStatusassigned => resolved
2012-06-01 17:23TowResolutionreopened => fixed
2012-06-15 12:01ench0Note Added: 0002691
2014-05-30 17:41beegeeStatusresolved => closed

Notes
(0002401)
majaczek   
2012-05-04 13:53   
I insist to include this feature. Similair feature is also in H5 I believe. Shading the hexes is just for not having to count them, and I many times in H3 had to count hexes to know to be out of meele fighter range.

(0002407)
ench0   
2012-05-07 16:59   
I added a screenshot. Here's the explanation:
- The currently active unit are my Red Snakes (100). This is indicated by the greenish runic-like aura underneath them.
- My mouse pointer is over the enemy Ghosts (2). Don't mind the ugly mouse pointer, I added it manually for illustration purposes, coz the screenshot does not capture the mouse. As u can see moving the mouse over the enemy units hides the movement shadow of my Snakes and displays a shadow for the ghosts, showing how far the ghosts would move when their turn comes.
(0002423)
ench0   
2012-05-14 13:07   
I added a patch which displays a movement shadow when mouse is hovered over a stack. I started a couple battles and it seems to be working as supposed to.

It works WITHOUT hiding the shadow of the active stack so the two may be present on the map at the same (and may even be overlapping). IMO it looks fine for a first-cut of the feature, but adding a couple of different shadow BMPs for the enemy units and for the friendly units would make it look better...

...btw if anyone could point me to where these BMPs are located they could save me some debugging time :) I mean this line in client/BattleInterface/CBattleInterface.cpp:
  cellShade = BitmapHandler::loadBitmap("CCELLSHD.BMP");
(0002428)
Ivan   
2012-05-14 16:51   
(edited on: 2012-05-14 21:45)
You mean location of bmp files on disk?
Bitmap handler loads them from VCMI/Data/H3Bitmap.lod
You can use MMArchive to extract them: http://wogarchive.ru/file.php?id=119 [^] (Only for Windows, but works in wine)

Some thoughts about patch:
- It should check for if movement shadow enabled in options

- To change transparency without any additional images:
cellShade->format->palette->colors[4].unused = 128;
128 - default, 255 - transparent, 0 - opaque

!!!
- There is crash at the end of battle.
!!!

I'll leave patch to somebody else (Warmonger?) but I like this feature.

(0002475)
ench0   
2012-05-17 16:36   
1. When I tested the patch the game did NOT crash at the end of the battle.
2. On the next day (and on another machine) it DID crash at the end of the battle.
3. Today (tag 2686) vcmi crashes as soon as I try to start a scenario...

Unfortunately I do not remember what I first tested with, I think it was at 2661 or 2663.

There may very well be some problem with my code but I need to be able to start a scenario and enter a battle to debug :) I will be looking into this in the next few days and as soon as there is a working release will try to verify whether my patch is causing any problems at the end of the battle...
(0002476)
Ivan   
2012-05-17 16:52   
Hmm... 2686 works fine for me. Can you post stacktrace of crash?
Or at least try with rev. 2684:
svn update -r 2864
(0002518)
Warmonger   
2012-05-22 10:16   
Implemented patch in r2704. Thanks!
(0002529)
ench0   
2012-05-23 13:33   
I finally managed to find some time to look into this today and I saw that Wamonger has taken my patch in as-is, so I guess it was not the cause of the problem? Or at least is not easily reproducible... It certainly is not happening for me today in Revision:2707.
(0002579)
ench0   
2012-05-28 08:24   
(edited on: 2012-05-28 08:35)
Adding a patch and a BMP hex image to color enemy shadow a bit differently...

The BMP uses color 2 (0-based) from the original palette, hence the name CCELLSH2.BMP. I thought it may be important to preserve the 8.3 filename format...

The patch displays the enemy shadow in a slightly lighter shade than the current unit's shadow. Thus it is easier to see where the two shadows intersect and which is your unit vs. the other unit.

This is not the ideal solution, e.g. it would be much cooler to color the enemy shadow with some reddish color (you know - enemy... red...). However I have nott not looked yet into how exactly the CSDL_Ext::blit8bppAlphaTo24bpp function does its magic so I am not sure how exactly to make it display a red semi-transparent shade...

Nevertheless this is an improvement of my original impl. so please let's take it in for the time being, if there's no objections regarding the code.

(0002580)
ench0   
2012-05-28 08:34   
oh and I need to add a check for what Ivan said:

>>It should check for if movement shadow enabled in options

So I will add one more patch here for this as well.
(0002581)
Ivan   
2012-05-28 08:45   
Red (or any other non-gray) may not work. Red can be difficult to see for example on lava or fire fields, green won't work on grass or magic plains.

>> I am not sure how exactly to make it display a red semi-transparent shade...
I am not sure how to do this at all. Check CSDL_Ext::alphaTransform - it will change first 8 colors into semi-transparent colors
(0002582)
ench0   
2012-05-28 09:11   
Thanks for the tip Ivan, I look there.

Before doing this I also took a (very quick) look at the CDSL_Ext functions, saw that it is somewhat complex, decided that it's not something I can do in 30 minutes on a Monday morning and instead made the quick fix above :) (using color 2 from the palette). I'll look at this in more detail as soon as I have a little more free time...

In the mean time:
- the uploaded file colorize-enemy-move-shadow.02.patch is an incremental patch to only display the enemy movement shadow when movement and cursor shadows are enabled in the battle interface...
(0002584)
Tow   
2012-05-28 22:49   
> I am not sure how to do this at all. Check CSDL_Ext::alphaTransform - it will change first 8 colors into semi-transparent colors

Alpha transform just replaces first 8 colors in palette with transparent (or shady) black. You can't have transparent non-black colors with it.


However if you save 8bpp picture with transparent colors in palette (and not using the first, reserved colors), then it should "just work" with or without any transforms, if blitted with blit8bppAlphaTo24bpp.
(0002598)
Tow   
2012-06-01 17:23   
Second patch committed in r2738.
(0002691)
ench0   
2012-06-15 12:01   
Um, Tow... part-2 of this feature didn't actually make into the trunk.. sorry may have been my mistake due to not knowing the proper way of submitting patches or maybe I didn't explain it properly..

To get this in, both patch files (colorize-enemy-move-shadow.01.patch and colorize-enemy-move-shadow.02.patch) need to be applied, incrementally. Atm, it seems that only patch 02 has been applied.

And also the BMP file also needs to be added somehow to the resources - something which I also was not sure at all how you do it so I left it for someone more knowledgeable to decide how to go about this. On my machine I just added it to h3bitmap.lod with MMArchive but this is probably not the proper way..

I will wait a few days to see if anyone comments here and then will change status to unresolved again, to draw attention...