Hammer changes/fixes: honor extra-damage (Issue 975), round up damage, do correct damage when being spammed in infinite-attack mode
authorsheepluva
Sun, 09 Aug 2015 00:19:33 +0200
changeset 11039 cd4b0851b060
parent 11038 5a9dde74127e
child 11040 3ab93d702fb1
Hammer changes/fixes: honor extra-damage (issue #975), round up damage, do correct damage when being spammed in infinite-attack mode
ChangeLog.txt
hedgewars/uGearsHandlersMess.pas
--- a/ChangeLog.txt	Fri Aug 07 07:30:14 2015 -0400
+++ b/ChangeLog.txt	Sun Aug 09 00:19:33 2015 +0200
@@ -9,10 +9,12 @@
  + Divided teams options will now just be ignored when more/less than 2 teams, instead of displaying a fatal error
  + Added 6 TechRacer maps to TechMaps
  + Added 3 SpeedShoppa Challenges: Shoppa Love, Ropes and Crates, The Customer is King
+ + Hammer damage is now rounded up. This means it can be used to execute hedgehogs with only 1 hp.
  + Improved "Art" theme.
  * Generated bridges/girders are now connected better to the land mass
  * Fixed rubberband sprite
  * The game will now fallback to default voicepack if a team's voicepack is not locally installed. (Instead of rendering team voiceless)
+ * Hammer now does more damage when the Extra-Damage utility is used
  * Many other bug fixes
 
 0.9.20 -> 0.9.21:
--- a/hedgewars/uGearsHandlersMess.pas	Fri Aug 07 07:30:14 2015 -0400
+++ b/hedgewars/uGearsHandlersMess.pas	Sun Aug 09 00:19:33 2015 +0200
@@ -5206,7 +5206,7 @@
 procedure doStepHammer(Gear: PGear);
 var HHGear, tmp, tmp2: PGear;
          t: PGearArray;
-         i: LongInt;
+ i, dmg, d: LongInt;
 begin
 HHGear:= Gear^.Hedgehog^.Gear;
 HHGear^.State:= HHGear^.State or gstNoDamage;
@@ -5227,7 +5227,25 @@
             begin
             //tmp^.State:= tmp^.State or gstFlatened;
             if (tmp^.Kind <> gtHedgehog) or (tmp^.Hedgehog^.Effects[heInvulnerable] = 0) then
-                ApplyDamage(tmp, CurrentHedgehog, tmp^.Health div 3, dsUnknown);
+                begin
+                // do 1/2 current hp worth of damage if extra damage is enabled (1/3 damage if not)
+                if cDamageModifier > _1 then
+                    d:= 2
+                else
+                    d:= 3;
+                // base damage on remaining health
+                dmg:= (tmp^.Health - tmp^.Damage);
+                if dmg > 0 then
+                    begin
+                    // always round up
+                    if dmg mod d > 0 then
+                        dmg:= dmg div d + 1
+                    else
+                        dmg:= dmg div d;
+
+                    ApplyDamage(tmp, CurrentHedgehog, dmg, dsUnknown);
+                    end;
+            end;
             //DrawTunnel(tmp^.X, tmp^.Y - _1, _0, _0_5, cHHRadius * 6, cHHRadius * 3);
             tmp2:= AddGear(hwRound(tmp^.X), hwRound(tmp^.Y), gtHammerHit, 0, _0, _0, 0);
             tmp2^.LinkedGear:= tmp;