Add freezing hogs with icegun icegun
authorUrbertar@gmail.com
Sun, 24 Feb 2013 21:40:06 +0200
branchicegun
changeset 8557 18330b24b92c
parent 8554 84a279d0556c
child 8560 134a098235fa
Add freezing hogs with icegun
hedgewars/GSHandlers.inc
hedgewars/uGearsHedgehog.pas
hedgewars/uGearsRender.pas
hedgewars/uTypes.pas
hedgewars/uVariables.pas
share/hedgewars/Data/Graphics/Hedgehog/amFrozenHog.png
--- a/hedgewars/GSHandlers.inc	Sat Feb 23 19:34:02 2013 +0200
+++ b/hedgewars/GSHandlers.inc	Sun Feb 24 21:40:06 2013 +0200
@@ -5061,6 +5061,8 @@
 
 
 procedure updateTarget(Gear:PGear; newX, newY:HWFloat);
+    var
+    iter:PGear;    
 begin
   with Gear^ do
   begin
@@ -5071,15 +5073,15 @@
     LastDamage:= nil;
     X:= Hedgehog^.Gear^.X;
     Y:= Hedgehog^.Gear^.Y;
-    (* unfreeze all semifrozen hogs - make this generic hog cleanup
+    //unfreeze all semifrozen hogs - make this generic hog cleanup
     iter := GearsList;
     while iter <> nil do
         begin
         if (iter^.Kind = gtHedgehog) and 
-        (iter^.Hedgehog^.Effects[heFrozen] < 0) then 
+        (iter^.Hedgehog^.Effects[heFrozen] and $FF = 0) then 
         iter^.Hedgehog^.Effects[heFrozen]:= 0;
         iter:= iter^.NextGear
-        end *)
+        end 
   end;
 end;
 
@@ -5233,13 +5235,15 @@
                 end;
 
 // freeze nearby hogs
-                hogs := GearsNear(Gear^.X, Gear^.Y, gtHedgehog, Gear^.Radius);
+                hogs := GearsNear(int2hwFloat(Target.X), int2hwFloat(Target.Y), gtHedgehog, Gear^.Radius);
                 if hogs.size > 0 then
                     for i:= 0 to hogs.size - 1 do
                     begin
                         if hogs.ar^[i] <> HHGear then
                         begin
-                        //if Gear^.Hedgehog^.Effects[heFrozen]:= 0;
+                            if GameTicks mod 10 = 0 then 
+                            if hogs.ar^[i]^.Hedgehog^.Effects[heFrozen] < 256 then
+                                hogs.ar^[i]^.Hedgehog^.Effects[heFrozen] := hogs.ar^[i]^.Hedgehog^.Effects[heFrozen] + 1;
                         end;                        
                     end;
                 inc(Pos)
@@ -5253,14 +5257,14 @@
                 X:= HHGear^.X;
                 Y:= HHGear^.Y
             end;
-            if (gX > max(LAND_WIDTH,4096)*2) or
+            {if (gX > max(LAND_WIDTH,4096)*2) or
                     (gX < -max(LAND_WIDTH,4096)) or
                     (gY < -max(LAND_HEIGHT,4096)) or
                     (gY > max(LAND_HEIGHT,4096)+512) then
             begin
                 X:= HHGear^.X;
                 Y:= HHGear^.Y
-            end
+            end}
         end
     end;
 end;
--- a/hedgewars/uGearsHedgehog.pas	Sat Feb 23 19:34:02 2013 +0200
+++ b/hedgewars/uGearsHedgehog.pas	Sun Feb 24 21:40:06 2013 +0200
@@ -374,7 +374,10 @@
                                  end;
                     //amStructure: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtStructure, gstWait, SignAs(_0_02, dX), _0, 3000);
                        amTardis: newGear:= AddGear(hwRound(X), hwRound(Y), gtTardis, 0, _0, _0, 5000);
-                       amIceGun: newGear:= AddGear(hwRound(X), hwRound(Y), gtIceGun, 0, _0, _0, 0);
+                       amIceGun: begin
+                       newGear:= AddGear(hwRound(X), hwRound(Y), gtIceGun, 0, _0, _0, 0);
+                       newGear^.radius := 8;
+                       end;
             end;
             if altUse and (newGear <> nil) then
                begin
--- a/hedgewars/uGearsRender.pas	Sat Feb 23 19:34:02 2013 +0200
+++ b/hedgewars/uGearsRender.pas	Sun Feb 24 21:40:06 2013 +0200
@@ -211,6 +211,8 @@
     defaultPos, HatVisible: boolean;
     HH: PHedgehog;
     CurWeapon: PAmmo;
+    iceOffset:Longint;
+    r:TSDL_Rect;
 begin
     HH:= Gear^.Hedgehog;
     if HH^.Unplaced then
@@ -247,6 +249,7 @@
         Tint($FF, $FF, $FF, $FF)
         end;
 
+
     if ((Gear^.State and gstWinner) <> 0) and
     ((CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtPickHammer)) then
         begin
@@ -917,6 +920,22 @@
         Tint($FF, $FF, $FF, max($40, round($FF * abs(1 - ((RealTicks div 2 + Gear^.uid * 491) mod 1500) / 750))));
         DrawSprite(sprInvulnerable, sx - 24, sy - 24, 0);
         end;
+
+    if HH^.Effects[heFrozen] <> 0 then
+        begin
+       /// Tint($00, $FF, $40, $40);
+        iceOffset := trunc(HH^.Effects[heFrozen] / 256 * 64);
+        Tint($FF, $FF, $FF, $FF);        
+        r.x := 0;
+        r.y := 64 - iceOffset;
+        r.w := 64;
+        r.h := iceOffset;
+        DrawTextureFromRect(sx-32, sy-iceoffset+32, @r, SpritesData[sprFrozenHog].texture);
+
+        Tint($FF, $FF, $FF, $FF);
+        end;
+
+
     if cVampiric and
     (CurrentHedgehog^.Gear <> nil) and
     (CurrentHedgehog^.Gear = Gear) then
--- a/hedgewars/uTypes.pas	Sat Feb 23 19:34:02 2013 +0200
+++ b/hedgewars/uTypes.pas	Sun Feb 24 21:40:06 2013 +0200
@@ -86,7 +86,7 @@
             sprHandResurrector, sprCross, sprAirDrill, sprNapalmBomb,
             sprBulletHit, sprSnowball, sprHandSnowball, sprSnow,
             sprSDFlake, sprSDWater, sprSDCloud, sprSDSplash, sprSDDroplet, sprTardis,
-            sprSlider, sprBotlevels, sprHandKnife, sprKnife, sprStar, sprIceTexture, sprIceGun
+            sprSlider, sprBotlevels, sprHandKnife, sprKnife, sprStar, sprIceTexture, sprIceGun, sprFrozenHog
             );
 
     // Gears that interact with other Gears and/or Land
--- a/hedgewars/uVariables.pas	Sat Feb 23 19:34:02 2013 +0200
+++ b/hedgewars/uVariables.pas	Sun Feb 24 21:40:06 2013 +0200
@@ -667,7 +667,9 @@
             (FileName:  'icetexture'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
             Width: 32; Height: 32; imageWidth: 32; imageHeight: 32; saveSurf: true; priority: tpLow; getDimensions: false; getImageDimensions: true), // sprIceTexture
             (FileName:  'amIceGun'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
-            Width: 64; Height: 64; imageWidth: 64; imageHeight: 64; saveSurf: false; priority: tpLow; getDimensions: false; getImageDimensions: false) // sprIceGun
+            Width: 64; Height: 64; imageWidth: 64; imageHeight: 64; saveSurf: false; priority: tpLow; getDimensions: false; getImageDimensions: false), // sprIceGun
+            (FileName:  'amFrozenHog'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
+            Width: 64; Height: 64; imageWidth: 64; imageHeight: 64; saveSurf: false; priority: tpLow; getDimensions: false; getImageDimensions: false) // sprFrozenHog
             );
 
 const
Binary file share/hedgewars/Data/Graphics/Hedgehog/amFrozenHog.png has changed