MantisBT - VCMI
View Issue Details
0000152VCMIMechanics - Battlespublic2009-10-13 11:172014-05-30 17:41
Boulie 
Tow 
normalfeaturealways
closedfixed 
0.74 
0.9 
0000152: Range penalty not implemented (or else damage calculation is wrong)
Either range penalty is not implemented or the dmg calculation is wrong.

See screenshots:

first VCMI - 14 liches attack with damage 148 (5 medusas perished)

second H3 - 14 liches attack with dmg 70 (2 medusas perished), two times less then in VCMI.
No tags attached.
related to 0001130closed Warmonger If the 1st hex of a wide creature is within full shooting range, no penalty should be applied to its 2nd hex 
jpg bug dmg calculation.jpg (257,869) 2009-10-13 11:17
https://bugs.vcmi.eu/file_download.php?file_id=25&type=bug
jpg

jpg bug dmg calculation org.jpg (108,923) 2009-10-13 11:17
https://bugs.vcmi.eu/file_download.php?file_id=26&type=bug
jpg

jpg penalty.jpg (669,489) 2010-06-08 14:05
https://bugs.vcmi.eu/file_download.php?file_id=411&type=bug
jpg

jpg shot range.jpg (153,765) 2010-06-11 12:59
https://bugs.vcmi.eu/file_download.php?file_id=422&type=bug
jpg

jpg siege_03 with fort but no castle.jpg (250,872) 2010-07-27 07:16
https://bugs.vcmi.eu/file_download.php?file_id=483&type=bug
jpg

jpg range penalty differences.jpg (122,138) 2010-08-06 14:01
https://bugs.vcmi.eu/file_download.php?file_id=568&type=bug
jpg

? _test_SoD_map_by Boulie.h3m (7,786) 2010-08-06 14:01
https://bugs.vcmi.eu/file_download.php?file_id=569&type=bug
Issue History
2009-10-13 11:17BoulieNew Issue
2009-10-13 11:17BoulieFile Added: bug dmg calculation.jpg
2009-10-13 11:17BoulieFile Added: bug dmg calculation org.jpg
2009-10-13 11:25BoulieNote Added: 0000099
2009-10-13 11:25BoulieNote Deleted: 0000099
2009-10-13 11:26BoulieNote Added: 0000100
2009-10-13 11:26BoulieNote Edited: 0000100bug_revision_view_page.php?bugnote_id=100#r199
2009-10-13 15:14ZamolxisNote Added: 0000101
2009-10-13 15:33BoulieNote Edited: 0000100bug_revision_view_page.php?bugnote_id=100#r200
2009-10-13 17:35ZamolxisSeveritymajor => feature
2009-10-13 17:35ZamolxisSummaryBug not proper damage calculation => Range penalty not implemented (or else damage calculation is wrong)
2009-10-13 17:35ZamolxisDescription Updatedbug_revision_view_page.php?rev_id=202#r202
2009-10-13 17:36ZamolxisNote Edited: 0000101bug_revision_view_page.php?bugnote_id=101#r204
2010-06-08 14:04BoulieNote Added: 0000947
2010-06-08 14:05BoulieFile Added: penalty.jpg
2010-06-08 19:25ZamolxisNote Added: 0000948
2010-06-11 12:59BoulieNote Added: 0000953
2010-06-11 12:59BoulieFile Added: shot range.jpg
2010-07-15 17:53Tow dragonNote Added: 0001133
2010-07-15 17:53Tow dragonStatusassigned => resolved
2010-07-15 17:53Tow dragonFixed in Version => 0.89
2010-07-15 17:53Tow dragonResolutionopen => fixed
2010-07-27 07:16BoulieNote Added: 0001186
2010-07-27 07:16BoulieFile Added: siege_03 with fort but no castle.jpg
2010-07-27 13:00anonymousStatusresolved => feedback
2010-07-27 13:00anonymousResolutionfixed => reopened
2010-07-27 13:02TowNote Added: 0001195
2010-07-27 13:02TowNote Edited: 0001195bug_revision_view_page.php?bugnote_id=1195#r1001
2010-07-28 12:34Tow dragonNote Added: 0001215
2010-07-28 12:34Tow dragonStatusfeedback => resolved
2010-07-28 12:34Tow dragonResolutionreopened => fixed
2010-07-29 13:47BoulieNote Added: 0001237
2010-08-06 14:01BoulieNote Added: 0001298
2010-08-06 14:01BoulieStatusresolved => feedback
2010-08-06 14:01BoulieResolutionfixed => reopened
2010-08-06 14:01BoulieFile Added: range penalty differences.jpg
2010-08-06 14:01BoulieFile Added: _test_SoD_map_by Boulie.h3m
2010-08-06 14:16BoulieNote Edited: 0001298bug_revision_view_page.php?bugnote_id=1298#r1115
2010-08-06 14:17BoulieNote Edited: 0001298bug_revision_view_page.php?bugnote_id=1298#r1116
2010-08-06 17:32WarmongerNote Added: 0001299
2010-08-06 17:33WarmongerNote Edited: 0001299bug_revision_view_page.php?bugnote_id=1299#r1118
2010-08-06 17:34WarmongerNote Edited: 0001299bug_revision_view_page.php?bugnote_id=1299#r1119
2010-08-06 17:34WarmongerNote Edited: 0001299bug_revision_view_page.php?bugnote_id=1299#r1120
2010-08-06 22:27BoulieNote Added: 0001300
2010-08-06 22:27BoulieStatusfeedback => assigned
2012-02-27 12:23WarmongerAssigned ToTow dragon => Warmonger
2012-08-28 12:32TowNote Added: 0002942
2012-08-28 12:32TowStatusassigned => resolved
2012-08-28 12:32TowFixed in Version0.82 => 0.9
2012-08-28 12:32TowResolutionreopened => fixed
2012-08-28 12:32TowAssigned ToWarmonger => Tow
2012-10-01 13:12ZamolxisIssue cloned: 0001130
2012-10-01 13:12ZamolxisRelationship addedrelated to 0001130
2014-05-30 17:41beegeeStatusresolved => closed

Notes
(0000100)
Boulie   
2009-10-13 11:26   
(edited on: 2009-10-13 15:33)
chcialem edytowac ze to tyczy archery penalty ale nie wiem jak

EDIT:
@Zamolxis-> Yes, I wanted to edit my added bug to write it refer to archery penalty but I can't or I do not know how can I do it.

(0000101)
Zamolxis   
2009-10-13 15:14   
(edited on: 2009-10-13 17:36)
As I think you already guessed correctly in the note above, range penalty is indeed not implemented yet (AFAIK).

EDIT: Report description & severity updated.

(0000947)
Boulie   
2010-06-08 14:04   
So if now we have implemented ranged penalty I need to write few difference between OH3 and VCMI.
1. Range should have 10 hexes not like it is now 8 hexes, damage penalty should start from 11th hex.
2. If we have 2-hex unit to which we aim and her closer hex is in range, there should be no damage penalty on both hexes (10th and 11th) - no broken arrow. Now on further hex is broken arrow, but dmg is shown and dealt ok.
Added new screenshot

PS> Nice that dmg calculation seems to be ok, now.
(0000948)
Zamolxis   
2010-06-08 19:25   
Thanks Boulie for the above. I did have a strong feeling the no-penalty range is smaller in VCMI, but I didn't know the actual OH3 values.
(0000953)
Boulie   
2010-06-11 12:59   
One more think I didn't noticed before. Range is not a vertical line but radius.
Added one more screenshot.
(0001133)
Tow dragon   
2010-07-15 17:53   
Distance penalty has been implemented in 0.81, additionally I've corrected the formula for distance in rev 1658. Please reopen if it's still wrong, I haven't checked it in-game, but the formula seems to be correct.
(0001186)
Boulie   
2010-07-27 07:16   
Still wrong. If radius is implemented so the distance is 15 hexes.
Also point 2 from comment 947 isn't implemented.
Added one more screen.
PS> same was in 081b and now is in 081c
(0001195)
Tow   
2010-07-27 13:02   
@Boulie
If something that was marked as fixed still doesn't work, please reopen the issue (eg by changing status to feedback). Then we'll be easily able to see that something is wrong.

(0001215)
Tow dragon   
2010-07-28 12:34   
hopefully (again) resolved in rev 1699. Here is the code for determining the penalty:

si8 BattleInfo::hasDistancePenalty( int stackID, int destHex )
{
    const CStack * stack = getStack(stackID);

    struct HLP
    {
        static bool lowerAnalyze(const CStack * stack, int hex)
        {
            int xDst = std::abs(hex % BFIELD_WIDTH - stack->position % BFIELD_WIDTH),
                yDst = std::abs(hex / BFIELD_WIDTH - stack->position / BFIELD_WIDTH);
            int distance = std::max(xDst, yDst) + std::min(xDst, yDst) - (yDst + 1)/2;

            //I hope it's approximately correct
            return distance > 10 && !stack->hasBonusOfType(Bonus::NO_DISTANCE_PENALTY);
        }
    };
    const CStack * dstStack = getStackT(destHex, false);

    if (dstStack->doubleWide())
        return HLP::lowerAnalyze(stack, destHex) && HLP::lowerAnalyze(stack, dstStack->occupiedHex());
    else
        return HLP::lowerAnalyze(stack, destHex);
    
}

I'm not sure about it but I'd like to avoid writing BFS.
(0001237)
Boulie   
2010-07-29 13:47   
Nice ;) Tomorrow I'm starting learning C++ so I try before final version of VCMI (1.0 ) understand the code you attached ;)
and what is BFS?

this one is the most inspiring
"int distance = std::max(xDst, yDst) + std::min(xDst, yDst) - (yDst + 1)/2;"
(0001298)
Boulie   
2010-08-06 14:01   
(edited on: 2010-08-06 14:17)
OK! I felt that something wrong is with this formula.
        {
            int xDst = std::abs(hex % BFIELD_WIDTH - stack->position % BFIELD_WIDTH),
                yDst = std::abs(hex / BFIELD_WIDTH - stack->position / BFIELD_WIDTH);
            int distance = std::max(xDst, yDst) + std::min(xDst, yDst) - (yDst + 1)/2;
}
Fast learning C++ by doing a lot of tests in VCMI (I think it took me more than 2 hours;) and I have the results.
See attached screenshot .
It is nearly ok but it depends from the row in which shooting stack is.
On the screenshot you have marked which row is wrong for red or blue player.
Also there is example for one of the Blue player's Cyclops. (with exclamation marks). Note that there is 11-hexes radius. In straight line (stack are in the same row) it is ok (broken arrow) but for one rows up and down it is full arrow. Next row is broken, next row is full.but in every row arrow should be broken.
I've added the test map with this creatures. You can try it. Run it in MP and attack Christian (red) vs Sir Mullich (blue).
PS.
Also aiming in the 2 hex stack is wrong. If first hex(head) is 10th (so there is full arrow) also on the 11th hex should full arrow.

I hope it is more less clear - it was hard for me to explain it in English. ;)
If you don't follow my bad English I can write it in Polish.

(0001299)
Warmonger   
2010-08-06 17:32   
(edited on: 2010-08-06 17:34)
Why don't you just use formula from creature movement? If a target is 10 tiles away, it's position will be in range of flying creature with speed 10.

(0001300)
Boulie   
2010-08-06 22:27   
Yes Wormonger! You are right! I will use it but I don't know this formula, yet ;)
Ofc a little joke.
@Tow - do it! ;)
(0002942)
Tow   
2012-08-28 12:32   
Should be finally fixed in r2853.
I found a new formula and double checked it.