hedgewars/GSHandlers.inc
changeset 4044 de7170e51cc6
parent 4038 8972dd38bbad
child 4045 e3a2a39a8277
--- a/hedgewars/GSHandlers.inc	Sat Oct 30 22:53:23 2010 -0400
+++ b/hedgewars/GSHandlers.inc	Sat Oct 30 23:50:49 2010 -0400
@@ -4107,13 +4107,12 @@
 begin
     AllInactive := false;
     hh := PHedgehog(Gear^.Hedgehog);
-    DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy -
+    DrawCentered(hwRound(hh^.Gear^.X) + WorldDx, hwRound(hh^.Gear^.Y) + WorldDy -
             cHHRadius - 14 - hh^.HealthTagTex^.h, hh^.HealthTagTex);
     (*DrawCircle(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Radius, 1.5, 0, 0, $FF,
             $FF);*)
 
-    doStepHedgehogMoving(hh^.Gear);
-    hh^.Gear^.Y := Gear^.Y;
+    if hh^.Gear^.Damage <> 0 then doStepHedgehogMoving(hh^.Gear);
 
     if ((Gear^.Message and gmUp) <> 0) then 
         begin
@@ -4121,22 +4120,25 @@
         end 
     else if (GameTicks and $1FF) <> 0 then exit;
 
-    if Gear^.Power < 45 then begin
+    if Gear^.Power < 45 then 
+        begin
         inc(Gear^.Power);
-        Gear^.Y := Gear^.Y - _1;
-    end;
-
-    graves := GearsNear(hh^.Gear^.X, hh^.Gear^.Y + int2hwFloat(Gear^.Power),
+        if not TestCollisionYwithGear(hh^.Gear, -1) then hh^.Gear^.Y := hh^.Gear^.Y - _1;
+        end;
+
+    graves := GearsNear(Gear^.X, Gear^.Y + int2hwFloat(Gear^.Power),
                     gtGrave, Gear^.Radius);
 
-    if Length(graves) = 0 then begin
+    if Length(graves) = 0 then 
+        begin
         StopSound(Gear^.SoundChannel);
         Gear^.Timer := 250;
         Gear^.doStep := @doStepIdle;
         exit;
-    end;
-
-    if ((Gear^.Message and gmAttack) <> 0) and (hh^.Gear^.Health > 0) then begin
+        end;
+
+    if ((Gear^.Message and gmAttack) <> 0) and (hh^.Gear^.Health > 0) then 
+        begin
         i := getRandom(Length(graves));
         dec(hh^.Gear^.Health);
         if (hh^.Gear^.Health = 0) and (hh^.Gear^.Damage = 0) then
@@ -4149,10 +4151,13 @@
                 inc(graves[i]^.Health);
             end;
         end; -}
-    end else begin
+        end 
+    else 
+        begin
         // now really resurrect the hogs with the hp saved in the graves
         for i:= 0 to High(graves) do
-            if graves[i]^.Health > 0 then begin
+            if graves[i]^.Health > 0 then
+                begin
                 resgear := AddGear(hwRound(graves[i]^.X), hwRound(graves[i]^.Y),
                         gtHedgehog, gstWait, _0, _0, 0);
                 resgear^.Hedgehog := graves[i]^.Hedgehog;
@@ -4169,36 +4174,38 @@
                         LoadImage(Pathz[ptHats] + '/Reserved/Zombie', ifNone),
                         True)
                     end
-            end;
-
-        hh^.Gear^.dY := _0;
+                end;
+
+        doStepHedgehogMoving(hh^.Gear);
         StopSound(Gear^.SoundChannel);
         Gear^.Timer := 250;
         Gear^.doStep := @doStepIdle;
-    end;
+        end
     //if hh^.Gear^.Health = 0 then doStepHedgehogFree(hh^.Gear);
 end;
 
 procedure doStepResurrector(Gear: PGear);
 var
     graves: TPGearArray;
-    hh: PHedgehog;
     i: LongInt;
 begin
     AllInactive := false;
-    hh := PHedgehog(Gear^.Hedgehog);
-    graves := GearsNear(hh^.Gear^.X, hh^.Gear^.Y, gtGrave, Gear^.Radius);
-
-    if Length(graves) > 0 then begin
-        for i:= 0 to High(graves) do begin
+    graves := GearsNear(Gear^.X, Gear^.Y, gtGrave, Gear^.Radius);
+
+    if Length(graves) > 0 then
+        begin
+        for i:= 0 to High(graves) do
+            begin
             PHedgehog(graves[i]^.Hedgehog)^.Gear := nil;
             graves[i]^.Health := 0;
-        end;
+            end;
         Gear^.doStep := @doStepResurrectorWork;
-    end else begin
+        end 
+    else 
+        begin
         StopSound(Gear^.SoundChannel);
         Gear^.Timer := 250;
         Gear^.doStep := @doStepIdle;
-    end;
+        end
 end;