remove redundant abs, and some incorrect 1+ to damage
authornemo
Tue, 07 May 2013 15:43:34 -0400
changeset 8966 5ab59d79bc9a
parent 8965 b4f10ff6ea90
child 8967 4e71a1facd8b
remove redundant abs, and some incorrect 1+ to damage
hedgewars/uAIMisc.pas
hedgewars/uGearsUtils.pas
--- a/hedgewars/uAIMisc.pas	Tue May 07 23:37:03 2013 +0400
+++ b/hedgewars/uAIMisc.pas	Tue May 07 15:43:34 2013 -0400
@@ -386,8 +386,8 @@
                 begin
                 if (Kind = gtHedgehog) and (0.4 < dY) then
                     begin
-                    dmg := 1 + trunc((abs(dY) - 0.4) * 70);
-                    if dmg >= 1 then exit(dmg)
+                    dmg := 1 + trunc((dY - 0.4) * 70);
+                    exit(dmg)
                     end
                 else 
                     begin
@@ -399,12 +399,12 @@
                                 ((abs(odX) > 0.15) or ((abs(odY) > 0.15) and 
                                 (abs(odX) > 0.02))) and (dxdy > 0.35)))) then
                         begin
-                        dmg := 1 + trunc(dxdy * 25);
+                        dmg := trunc(dxdy * 25);
                         exit(dmg)
                         end
                     else if (Kind = gtExplosives) and not((abs(odX) > 0.15) or ((abs(odY) > 0.15) and (abs(odX) > 0.02))) and (dY > 0.2) then
                         begin
-                        dmg := 1 + trunc(dy * 70);
+                        dmg := trunc(dy * 70);
                         exit(dmg)
                         end
                     end;
@@ -438,9 +438,8 @@
                 begin
                 if (Kind = gtHedgehog) and (0.4 < dY) then
                     begin
-                    dmg := 1 + trunc((abs(dY) - 0.4) * 70);
-                    if dmg >= 1 then
-                        exit(dmg);
+                    dmg := trunc((dY - 0.4) * 70);
+                    exit(dmg);
                     end
                 else 
                     begin
@@ -452,12 +451,12 @@
                                 ((abs(odX) > 0.15) or ((abs(odY) > 0.15) and 
                                 (abs(odX) > 0.02))) and (dxdy > 0.35)))) then
                         begin
-                        dmg := 1 + trunc(dxdy * 25);
+                        dmg := trunc(dxdy * 25);
                         exit(dmg)
                         end
                     else if (Kind = gtExplosives) and not((abs(odX) > 0.15) or ((abs(odY) > 0.15) and (abs(odX) > 0.02))) and (dY > 0.2) then
                         begin
-                        dmg := 1 + trunc(dy * 70);
+                        dmg := trunc(dy * 70);
                         exit(dmg)
                         end
                     end;
--- a/hedgewars/uGearsUtils.pas	Tue May 07 23:37:03 2013 +0400
+++ b/hedgewars/uGearsUtils.pas	Tue May 07 15:43:34 2013 -0400
@@ -291,7 +291,7 @@
 begin
     if _0_4 < Gear^.dY then
         begin
-        dmg := ModifyDamage(1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70), Gear);
+        dmg := ModifyDamage(1 + hwRound((Gear^.dY - _0_4) * 70), Gear);
         PlaySound(sndBump);
         if dmg < 1 then
             exit;