ihhub / fheroes2

fheroes2 is a recreation of Heroes of Might and Magic II game engine.
https://ihhub.github.io/fheroes2/
GNU General Public License v2.0
2.69k stars 375 forks source link

Combat, Necromancy, number of skeletons raised is not rounded up correctly #6871

Closed LeHerosInconnu closed 1 year ago

LeHerosInconnu commented 1 year ago

Preliminary checks

Platform

Windows

Describe the bug

In fheroes2, the number of skeletons raised is not rounded up correctly.

In fheroes2:

In the example, for 10% of 21 decimated peasants (2.1), 2 skeletons are raised instead of 3 (standard and instant combat): Necromancy standard combat 003 Necromancy standard combat 004 Necromancy instant combat 001 Necromancy instant combat 002

In the example, for 10% of 22 decimated peasants (2.2), 2 skeletons are raised instead of 3 (standard and instant combat): Necromancy standard combat 005 Necromancy standard combat 006 Necromancy instant combat 003 Necromancy instant combat 004

In the example, for 10% of 23 decimated peasants (2.3) and then up to 30 decimated peasants, 3 skeletons are raised (standard and instant combat), so from there to 30, it is correct: Necromancy standard combat 007 Necromancy standard combat 008 Necromancy instant combat 005 Necromancy instant combat 006

Save file

Here is the test scenario file: 0 9924d.zip

Additional info

No response

Mr-Bajs commented 1 year ago

It it a bug though? I tried the basic necromancy in the original game, and it seams to always to round down, never up. 21 peasants gave 2 skeletons, 29 gave 2 skeletons, 30 gave 3.

oleg-derevenetz commented 1 year ago

@Mr-Bajs yeah, I also remember that number of skeletons is rounded down. This should be additionally checked.

LeHerosInconnu commented 1 year ago

Hello @Mr-Bajs and @oleg-derevenetz,

It it a bug though? I tried the basic necromancy in the original game, and it seams to always to round down, never up. 21 peasants gave 2 skeletons, 29 gave 2 skeletons, 30 gave 3.

@Mr-Bajs yeah, I also remember that number of skeletons is rounded down. This should be additionally checked.

This is rounded down in the original game. It was made rounded up in fheroes2, because in the original game the necromancy always gives at least 1 skeleton (10% of 1 peasant (0.1) raises 1 skeleton) while in fheroes2 it was given 0 skeleton (10% of 1 peasant (0.1) raises 0 skeleton).

Related closed issue: https://github.com/ihhub/fheroes2/issues/1496.

oleg-derevenetz commented 1 year ago

@LeHerosInconnu

This is rounded down in the original game. It was made rounded up in fheroes2, because in the original game the necromancy always gives at least 1 skeleton (10% of 1 peasant (0.1) raises 1 skeleton) while in fheroes2 it was given 0 skeleton (10% of 1 peasant (0.1) raises 0 skeleton).

But that's not the case. In fheroes2 there also will be 1 skeleton even from 1 peasant. Just checked this in the Battle Only mode.

LeHerosInconnu commented 1 year ago

@oleg-derevenetz.

@LeHerosInconnu

This is rounded down in the original game. It was made rounded up in fheroes2, because in the original game the necromancy always gives at least 1 skeleton (10% of 1 peasant (0.1) raises 1 skeleton) while in fheroes2 it was given 0 skeleton (10% of 1 peasant (0.1) raises 0 skeleton).

But that's not the case. In fheroes2 there also will be 1 skeleton even from 1 peasant. Just checked this in the Battle Only mode.

Yes, the problem has been solved and the issue closed. :)

undef21 commented 1 year ago

@Mr-Bajs yeah, I also remember that number of skeletons is rounded down.

@oleg-derevenetz, in this case raising of 3 skeletons from 23 units is incorrect, right?

oleg-derevenetz commented 1 year ago

@LeHerosInconnu

Yes, the problem has been solved and the issue closed. :)

So currently this logic behave (mostly) just like in the OG, right? The only exception is 3 skeletons from 23 peasants, which is incorrect.

oleg-derevenetz commented 1 year ago

@undef21

in this case raising of 3 skeletons from 23 units is incorrect, right?

Yes, this case seems incorrect.

Mr-Bajs commented 1 year ago

@Mr-Bajs yeah, I also remember that number of skeletons is rounded down.

@oleg-derevenetz, in this case raising of 3 skeletons from 23 units is incorrect, right?

Yes incorrect.

OG: 23 peasants gives 2 skeletons Fheroes2 1.0.2: 23 peasants gives 3 skeletons, which is incorrect. It should give 2 skeletons not 3. So something is wrong.

undef21 commented 1 year ago

@oleg-derevenetz could you look at this place?

Is a correct formula just raiseCount = enemyTroopsKilled * necromancyPercent / 100?

LeHerosInconnu commented 1 year ago

@oleg-derevenetz.

@LeHerosInconnu

Yes, the problem has been solved and the issue closed. :)

So currently this logic behave (mostly) just like in the OG, right? The only exception is 3 skeletons from 23 peasants, which is incorrect.

I assumed that it was simpler to round up as this would take all cases into account, without needing a special case to have at least one skeleton raised, but this does not seem to be the case.

It is the same from 23 to 29. Everything must be 3 skeletons from 21 to 29 creatures decimated (rounded up), or everything must be 2 skeletons from 21 to 29 creatures decimated (rounded down).

oleg-derevenetz commented 1 year ago

@undef21

Is a correct formula just raiseCount = enemyTroopsKilled * necromancyPercent / 100?

I'm not sure about the correct formula. Need to make some inquiries.

oleg-derevenetz commented 1 year ago

Is a correct formula just raiseCount = enemyTroopsKilled * necromancyPercent / 100?

Yes, it seems so. In HoMM3 the efficiency of Necromancy depends on the health of dead stacks, while in HoMM2 it seems to depend only on the number of killed units (although I haven't found the exact formula anywhere).