Messing around w/ Freezer icegun
authornemo
Sun, 24 Feb 2013 21:44:40 -0500
branchicegun
changeset 8560 134a098235fa
parent 8557 18330b24b92c
child 8563 4d9d8287e601
Messing around w/ Freezer
hedgewars/GSHandlers.inc
hedgewars/uGearsHedgehog.pas
hedgewars/uGearsRender.pas
hedgewars/uGearsUtils.pas
hedgewars/uRender.pas
hedgewars/uTeams.pas
hedgewars/uVariables.pas
share/hedgewars/Data/Graphics/Hedgehog.png
share/hedgewars/Data/Graphics/Hedgehog/amIceGun.png
share/hedgewars/Data/Graphics/icetexture.png
--- a/hedgewars/GSHandlers.inc	Sun Feb 24 21:40:06 2013 +0200
+++ b/hedgewars/GSHandlers.inc	Sun Feb 24 21:44:40 2013 -0500
@@ -2382,7 +2382,7 @@
 
         repeat
             CurrentTeam^.CurrHedgehog := Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber);
-        until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^.Damage = 0);
+        until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^.Damage = 0) and (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen]=0);
 
         SwitchCurrentHedgehog(@CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]);
         AmmoMenuInvalidated:= true; 
@@ -5130,7 +5130,8 @@
     pictureX := x mod iceSurface^.w;
     pictureY := y mod iceSurface^.h;
     icePixels := iceSurface^.pixels;
-    LandPixels[y, x] := icePixels^[pictureX + pictureY * iceSurface^.w];
+    LandPixels[y, x]:= addBgColor(LandPixels[y, x], icePixels^[pictureX + pictureY * iceSurface^.w]);
+
     Land[y, x] := land[y, x] or lfIce;
 end;
 
@@ -5155,6 +5156,7 @@
                 if isLanscapeEdge(weight) then 
                 begin
                     LandPixels[j, i] := $FFB2AF8A;                    
+                    if Land[j, i] > 255 then Land[j, i] := Land[j, i] or lfIce;
                 end;                
             end;
         end;
@@ -5176,7 +5178,7 @@
     hogs: PGearArrayS;
 begin
     HHGear := Gear^.Hedgehog^.Gear;
-    if (Gear^.Health = 0) or (HHGear = nil) or (HHGear^.Damage <> 0) then
+    if (Gear^.Message and gmAttack <> 0) or (Gear^.Health = 0) or (HHGear = nil) or (HHGear^.Damage <> 0) then
         begin
         DeleteGear(Gear);
         AfterAttack;
@@ -5235,7 +5237,7 @@
                 end;
 
 // freeze nearby hogs
-                hogs := GearsNear(int2hwFloat(Target.X), int2hwFloat(Target.Y), gtHedgehog, Gear^.Radius);
+                hogs := GearsNear(int2hwFloat(Target.X), int2hwFloat(Target.Y), gtHedgehog, Gear^.Radius*2);
                 if hogs.size > 0 then
                     for i:= 0 to hogs.size - 1 do
                     begin
@@ -5243,7 +5245,9 @@
                         begin
                             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;
+                                hogs.ar^[i]^.Hedgehog^.Effects[heFrozen] := hogs.ar^[i]^.Hedgehog^.Effects[heFrozen] + 1
+                            else if hogs.ar^[i]^.Hedgehog^.Effects[heFrozen] = 256 then
+                                hogs.ar^[i]^.Hedgehog^.Effects[heFrozen]:= 100000;
                         end;                        
                     end;
                 inc(Pos)
--- a/hedgewars/uGearsHedgehog.pas	Sun Feb 24 21:40:06 2013 +0200
+++ b/hedgewars/uGearsHedgehog.pas	Sun Feb 24 21:44:40 2013 -0500
@@ -695,6 +695,7 @@
 var PrevdX: LongInt;
     CurWeapon: PAmmo;
 begin
+if Gear^.Hedgehog^.Effects[heFrozen] > 0 then exit;
 CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^);
 if ((Gear^.State and (gstAttacking or gstMoving)) = 0) then
     begin
--- a/hedgewars/uGearsRender.pas	Sun Feb 24 21:40:06 2013 +0200
+++ b/hedgewars/uGearsRender.pas	Sun Feb 24 21:44:40 2013 -0500
@@ -241,6 +241,29 @@
     defaultPos:= true;
     HatVisible:= false;
 
+    if HH^.Effects[heFrozen] > 0 then
+        if HH^.Effects[heFrozen] < 256 then
+            begin
+            DrawHedgehog(sx, sy,
+                    sign,
+                    0,
+                    0,
+                    0);
+            defaultPos:= false;
+            HatVisible:= true
+            end
+        else 
+            begin
+            DrawHedgehog(sx, sy,
+                    sign,
+                    2,
+                    4,
+                    0);
+            defaultPos:= false;
+            HatVisible:= false;
+            exit
+            end;
+
 
     if HH^.Effects[hePoisoned] <> 0 then
         begin
@@ -921,16 +944,17 @@
         DrawSprite(sprInvulnerable, sx - 24, sy - 24, 0);
         end;
 
-    if HH^.Effects[heFrozen] <> 0 then
+    if HH^.Effects[heFrozen] = HH^.Effects[heFrozen] and $FF then
         begin
-       /// Tint($00, $FF, $40, $40);
-        iceOffset := trunc(HH^.Effects[heFrozen] / 256 * 64);
+       /// Tint($00, $FF, $40, $40);  (HH^.Effects[heFrozen] and $FF)
+        iceOffset:= trunc(HH^.Effects[heFrozen] / 256 * 64);
         Tint($FF, $FF, $FF, $FF);        
-        r.x := 0;
-        r.y := 64 - iceOffset;
+        r.x := 128;
+        r.y := 128 - iceOffset;
         r.w := 64;
         r.h := iceOffset;
-        DrawTextureFromRect(sx-32, sy-iceoffset+32, @r, SpritesData[sprFrozenHog].texture);
+        //DrawTextureFromRect(sx-32, sy-iceoffset+32, @r, SpritesData[sprFrozenHog].texture);
+        DrawTextureFromRectDir(sx-18, sy+48-iceoffset, r.w, r.h, @r, HHTexture, sign);
 
         Tint($FF, $FF, $FF, $FF);
         end;
--- a/hedgewars/uGearsUtils.pas	Sun Feb 24 21:40:06 2013 +0200
+++ b/hedgewars/uGearsUtils.pas	Sun Feb 24 21:44:40 2013 -0500
@@ -182,6 +182,7 @@
 i:= _1;
 if (CurrentHedgehog <> nil) and CurrentHedgehog^.King then
     i:= _1_5;
+if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Effects[heFrozen] > 0) then i:=i*_0_2;
 if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.King) then
     ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent * _0_5)
 else
--- a/hedgewars/uRender.pas	Sun Feb 24 21:40:06 2013 +0200
+++ b/hedgewars/uRender.pas	Sun Feb 24 21:44:40 2013 -0500
@@ -26,15 +26,16 @@
 
 procedure DrawSprite            (Sprite: TSprite; X, Y, Frame: LongInt);
 procedure DrawSprite            (Sprite: TSprite; X, Y, FrameX, FrameY: LongInt);
-procedure DrawSpriteFromRect    (Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt);
+procedure DrawSpriteFromRect    (Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); inline;
 procedure DrawSpriteClipped     (Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt);
 procedure DrawSpriteRotated     (Sprite: TSprite; X, Y, Dir: LongInt; Angle: real);
 procedure DrawSpriteRotatedF    (Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real);
 
 procedure DrawTexture           (X, Y: LongInt; Texture: PTexture); inline;
 procedure DrawTexture           (X, Y: LongInt; Texture: PTexture; Scale: GLfloat);
-procedure DrawTextureFromRect   (X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
-procedure DrawTextureFromRect   (X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
+procedure DrawTextureFromRect   (X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline;
+procedure DrawTextureFromRect   (X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline;
+procedure DrawTextureFromRectDir(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture; Dir: LongInt);
 procedure DrawTextureCentered   (X, Top: LongInt; Source: PTexture);
 procedure DrawTextureF          (Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt);
 procedure DrawTextureRotated    (Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real);
@@ -63,19 +64,23 @@
 
 var LastTint: LongWord = 0;
 
-procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt);
+procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); inline;
 begin
 r.y:= r.y + Height * Position;
 r.h:= Height;
 DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture)
 end;
 
-procedure DrawTextureFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
+procedure DrawTextureFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline;
 begin
-DrawTextureFromRect(X, Y, r^.w, r^.h, r, SourceTexture)
+DrawTextureFromRectDir(X, Y, r^.w, r^.h, r, SourceTexture, 1)
+end;
+procedure DrawTextureFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline;
+begin
+DrawTextureFromRectDir(X, Y, W, H, r, SourceTexture, 1)
 end;
 
-procedure DrawTextureFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
+procedure DrawTextureFromRectDir(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture; Dir: LongInt);
 var rr: TSDL_Rect;
     _l, _r, _t, _b: real;
     VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
@@ -101,14 +106,28 @@
 
 glBindTexture(GL_TEXTURE_2D, SourceTexture^.id);
 
-VertexBuffer[0].X:= X;
-VertexBuffer[0].Y:= Y;
-VertexBuffer[1].X:= rr.w + X;
-VertexBuffer[1].Y:= Y;
-VertexBuffer[2].X:= rr.w + X;
-VertexBuffer[2].Y:= rr.h + Y;
-VertexBuffer[3].X:= X;
-VertexBuffer[3].Y:= rr.h + Y;
+if Dir < 0 then
+    begin
+    VertexBuffer[0].X:= X + rr.w/2;
+    VertexBuffer[0].Y:= Y;
+    VertexBuffer[1].X:= X - rr.w/2;
+    VertexBuffer[1].Y:= Y;
+    VertexBuffer[2].X:= X - rr.w/2;
+    VertexBuffer[2].Y:= rr.h + Y;
+    VertexBuffer[3].X:= X + rr.w/2;
+    VertexBuffer[3].Y:= rr.h + Y;
+    end
+else
+    begin
+    VertexBuffer[0].X:= X;
+    VertexBuffer[0].Y:= Y;
+    VertexBuffer[1].X:= rr.w + X;
+    VertexBuffer[1].Y:= Y;
+    VertexBuffer[2].X:= rr.w + X;
+    VertexBuffer[2].Y:= rr.h + Y;
+    VertexBuffer[3].X:= X;
+    VertexBuffer[3].Y:= rr.h + Y;
+    end;
 
 TextureBuffer[0].X:= _l;
 TextureBuffer[0].Y:= _t;
--- a/hedgewars/uTeams.pas	Sun Feb 24 21:40:06 2013 +0200
+++ b/hedgewars/uTeams.pas	Sun Feb 24 21:44:40 2013 -0500
@@ -188,7 +188,7 @@
                 PrevHH:= CurrHedgehog mod HedgehogsNumber; // prevent infinite loop when CurrHedgehog = 7, but HedgehogsNumber < 8 (team is destroyed before its first turn)
                 repeat
                     CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber;
-                until (Hedgehogs[CurrHedgehog].Gear <> nil) or (CurrHedgehog = PrevHH)
+                until ((Hedgehogs[CurrHedgehog].Gear <> nil) and (Hedgehogs[CurrHedgehog].Effects[heFrozen] = 0)) or (CurrHedgehog = PrevHH)
                 end
         until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) or (PrevTeam = CurrTeam) or ((CurrTeam = TagTeamIndex) and ((GameFlags and gfTagTeam) <> 0));
         end
--- a/hedgewars/uVariables.pas	Sun Feb 24 21:40:06 2013 +0200
+++ b/hedgewars/uVariables.pas	Sun Feb 24 21:44:40 2013 -0500
@@ -667,7 +667,7 @@
             (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: 32; Height: 32; imageWidth: 32; imageHeight: 32; 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
             );
Binary file share/hedgewars/Data/Graphics/Hedgehog.png has changed
Binary file share/hedgewars/Data/Graphics/Hedgehog/amIceGun.png has changed
Binary file share/hedgewars/Data/Graphics/icetexture.png has changed