Check for collision with surfaces above when levitating hog, use more typical drawing syntax for the resurrector wep, restore typical indentation
authornemo
Sat, 30 Oct 2010 23:50:49 -0400
changeset 4044 de7170e51cc6
parent 4043 4bf039d637df
child 4045 e3a2a39a8277
Check for collision with surfaces above when levitating hog, use more typical drawing syntax for the resurrector wep, restore typical indentation
hedgewars/GSHandlers.inc
hedgewars/GearDrawing.inc
--- 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;
 
--- a/hedgewars/GearDrawing.inc	Sat Oct 30 22:53:23 2010 -0400
+++ b/hedgewars/GearDrawing.inc	Sat Oct 30 23:50:49 2010 -0400
@@ -278,15 +278,8 @@
                 defaultPos:= false
                 end;
             gtResurrector: begin
-                DrawRotated(sprHandResurrector, hwRound(Gear^.X) + WorldDx,
-                        hwRound(Gear^.Y) + WorldDy, 0, 0); 
-                DrawRotated(sprCross, hwRound(CurAmmoGear^.X) + WorldDx,
-                        hwRound(CurAmmoGear^.Y) + WorldDy + (CurAmmoGear^.Power), 0, 0);
-                defaultPos := false;
-                Tint($f5, $db, $35, max($00, floor($C0 * abs(1 - (GameTicks mod 6000) / 3000))));
-                DrawTexture(sx - 108, sy - 108 + (CurAmmoGear^.Power),
-                        SpritesData[sprVampiric].Texture, 4.5);
-                Tint($FF, $FF, $FF, $FF);
+                DrawRotated(sprHandResurrector, sx, sy, 0, 0); 
+                defaultPos:= false
                 end;
             gtKamikaze: begin
                 if CurAmmoGear^.Pos = 0 then
@@ -865,6 +858,12 @@
                     DrawRotatedTextureF(SpritesData[sprSmokeWhite].texture, 3, 0, 0, x, y, 0, 1, 22, 22, (RealTicks shr 36 + Gear^.UID * 100) mod 360);
                     Tint($FF, $FF, $FF, $FF)
                     end;
+     gtResurrector: begin
+                    DrawRotated(sprCross, x, y, 0, 0);
+                    Tint($f5, $db, $35, max($00, floor($C0 * abs(1 - (GameTicks mod 6000) / 3000))));
+                    DrawTexture(x - 108, y - 108, SpritesData[sprVampiric].Texture, 4.5);
+                    Tint($FF, $FF, $FF, $FF);
+                    end;
          end;
       if Gear^.RenderTimer and (Gear^.Tex <> nil) then DrawCentered(x + 8, y + 8, Gear^.Tex);
       Gear:= Gear^.NextGear