hedgewars/GSHandlers.inc
changeset 5977 0b1bfdd95310
parent 5972 add1cae1add6
child 5995 647d52370ce9
child 6002 7f790689205c
--- a/hedgewars/GSHandlers.inc	Wed Sep 21 02:05:42 2011 +0200
+++ b/hedgewars/GSHandlers.inc	Tue Sep 20 20:52:04 2011 -0400
@@ -118,7 +118,7 @@
     Message := Message and not gmAttack;
     end;
 HH^.GearHidden:= HH^.Gear;
-HH^.Gear:= nil;
+HH^.Gear:= nil
 end;
 
 procedure RestoreHog(HH: PHedgehog);
@@ -5097,7 +5097,6 @@
 var HH: PHedgehog;
     i,j,cnt: LongWord;
 begin
-
 HH:= Gear^.Hedgehog;
 if Gear^.Pos = 2 then
     begin
@@ -5108,7 +5107,9 @@
             begin
             AfterAttack;
             if Gear = CurAmmoGear then CurAmmoGear := nil;
-            HideHog(HH)
+            if (HH^.Gear^.Damage = 0) and  (HH^.Gear^.Health > 0) and 
+            ((Gear^.State and (gstMoving or gstHHDeath or gstHHGone)) = 0) then
+                HideHog(HH)
             end
         //else if (HH^.Gear <> nil) and (HH^.Gear^.State and gstInvisible <> 0) then
         else if (HH^.GearHidden <> nil) then// and (HH^.Gear^.State and gstInvisible <> 0) then
@@ -5126,8 +5127,10 @@
 if (Gear^.Pos = 1) and (GameTicks and $1F = 0) and (Gear^.Power < 255) then 
     begin
     inc(Gear^.Power);
-    if (Gear^.Power = 172) and (Gear^.Hedgehog^.Gear <> nil) then
-        with Gear^.Hedgehog^.Gear^ do
+    if (Gear^.Power = 172) and (HH^.Gear <> nil) and 
+       (HH^.Gear^.Damage = 0) and (HH^.Gear^.Health > 0) and
+       ((HH^.Gear^.State and (gstMoving or gstHHDeath or gstHHGone)) = 0) then
+        with HH^.Gear^ do
             begin
 	        State:= State or gstAnimation;
 	        Tag:= 2;
@@ -5191,13 +5194,14 @@
     3. Hog is a king
 *)
     HH:= Gear^.Hedgehog;
+    if HH^.Gear <> nil then 
     if (HH^.Gear = nil) or (HH^.King) or (SuddenDeathDmg) then
         begin
-	if HH^.Gear <> nil then 
-	    begin
-	    HH^.Gear^.Message := HH^.Gear^.Message and not gmAttack;
-	    HH^.Gear^.State:= HH^.Gear^.State and not gstAttacking;
-	    end;
+        if HH^.Gear <> nil then 
+            begin
+            HH^.Gear^.Message := HH^.Gear^.Message and not gmAttack;
+            HH^.Gear^.State:= HH^.Gear^.State and not gstAttacking;
+            end;
         PlaySound(sndDenied);
         DeleteGear(gear);
         exit
@@ -5211,14 +5215,14 @@
                 HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.Damage) then inc(cnt);
     if cnt < 2 then
         begin
-	if HH^.Gear <> nil then 
-	    begin
-	    HH^.Gear^.Message := HH^.Gear^.Message and not gmAttack;
-	    HH^.Gear^.State:= HH^.Gear^.State and not gstAttacking;
-	    end;
-        PlaySound(sndDenied);
-        DeleteGear(gear);
-        exit
+        if HH^.Gear <> nil then 
+            begin
+            HH^.Gear^.Message := HH^.Gear^.Message and not gmAttack;
+            HH^.Gear^.State:= HH^.Gear^.State and not gstAttacking;
+            end;
+            PlaySound(sndDenied);
+            DeleteGear(gear);
+            exit
         end;
     Gear^.SoundChannel := LoopSound(sndTardis);
     Gear^.doStep:= @doStepTardisWarp