Prevent gaining more health than hedgehog actually has
authornemo
Fri, 15 May 2009 00:51:37 +0000
changeset 2057 cf0d84479251
parent 2056 ed8c83f1e4b0
child 2058 5c2b52755141
Prevent gaining more health than hedgehog actually has
hedgewars/uGears.pas
--- a/hedgewars/uGears.pas	Fri May 15 00:38:49 2009 +0000
+++ b/hedgewars/uGears.pas	Fri May 15 00:51:37 2009 +0000
@@ -665,11 +665,10 @@
 var s: shortstring;
     vampDmg: Longword;
 begin
-	inc(Gear^.Damage, Damage);
 	if Gear^.Kind = gtHedgehog then
     begin
 	AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), Damage, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color);
-    Damage:= min(Damage, Gear^.Health);
+    Damage:= min(Damage, max(0,Gear^.Health-Gear^.Damage));
     if (Gear <> CurrentHedgehog^.Gear) and (CurrentHedgehog^.Gear <> nil) and (Damage >= 1) then
         begin
         if cVampiric then
@@ -704,6 +703,7 @@
            end;
         end;
     end;
+	inc(Gear^.Damage, Damage);
 end;
 
 procedure SetAllToActive;