roman-murashov / hedgewars

Automatically exported from code.google.com/p/hedgewars
GNU General Public License v2.0
0 stars 0 forks source link

Hammer does not make extra damage when extra damage is enabled #975

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Play a game with hammers and extra damage available, leave hog health at 100
2. Hit any hog with the hammer
3. Now enable extra damage and hit any other 100 health hog with the hammer

What is the expected output? What do you see instead?
Expectation: The first hog suffers 33 damage (100 * (1/3) = 33 (rounded))
The second hog suffers more damage than the first one.

Actual result: The first hog suffers 33 damage, but the second hog suffers 33 
damage, too. The extra damage simply has no effect on hammers. At all.

My suggestion is to change this.
Here is my proposed "fix" (???):

If extra damage is enabled, instead of dealing one third of the hedgehog's 
health, deal one half of the hedgehog's health.
That's because hammer takes away 1/3 of target's health normally, the extra 
damage factor is 1.5, and
(1/3) * 1.5 = 1/2.

Also, when calculating the damage for a hog, use the “round half up” rule, 
that is, if half of the hedgehog's health is not a whole number (i.e. 10.5), 
then round up if the first decimal "after" the comma is 5 or higher (i.e. from 
10.5 to 11). Notably, this also means the hammer (with extra damage) will kill 
hedgehogs with 1 health (1/2 = 0.5, gets rounded to 1), but it will not kill 1 
health hedgehogs without extra damage (1/3 = ca. 0.33333, rounded this is 0; 
this is also exactly how Hedgewars currently behaves).

Under my initial example, this change would mean that the first hedgehog 
suffers 33 damage (unchanged behaviour) and the second hedgehog suffers 50 
damage (100 * (1/2) = 50) (NEW behaviour).

What version of the product are you using? On what operating system?
0.9.21.

Original issue reported on code.google.com by almikes@aol.com on 8 Aug 2015 at 8:48

GoogleCodeExporter commented 8 years ago
About rounding:

Sheepluva said it is odd that the hammer (without extra damage) does not kill a 
hog with 1 health.
I said this would be an exception to the rule and inconsistent since HW seems 
to apply the "round half up" rule so far when calculating the damage.

So I suggest to maybe apply another rounding rule: "always round up" (meaning 
if the number is not a whole number, round up to the next whole number, so 0.3 
→ 1, 0.5 → 1, 0.7 → 1, but 1 stays 1)

So 1 HP, 1 * (1/3) = ~0.333, rounded up to 1, meaning the hog is killed.
2 HP, 2 * (1/3) = ~0.667, rounded up to 1, 1 damage, and so on.

Original comment by almikes@aol.com on 8 Aug 2015 at 9:45

GoogleCodeExporter commented 8 years ago
fixed in rcd4b0851b060d6b3b8f14a02129167cb12f2bd37

Original comment by sheepyluva on 8 Aug 2015 at 10:39