Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
authornemo
Thu, 03 May 2012 00:20:58 -0400
changeset 7010 10a0a31804f3
parent 7007 0ccdff4ae8e9
child 7012 8ca19b467e2f
Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
hedgewars/GSHandlers.inc
hedgewars/uGears.pas
hedgewars/uGearsHedgehog.pas
hedgewars/uGearsList.pas
hedgewars/uGearsRender.pas
hedgewars/uGearsUtils.pas
hedgewars/uScript.pas
hedgewars/uTeams.pas
hedgewars/uTypes.pas
--- a/hedgewars/GSHandlers.inc	Wed May 02 19:16:12 2012 -0400
+++ b/hedgewars/GSHandlers.inc	Thu May 03 00:20:58 2012 -0400
@@ -5089,7 +5089,7 @@
                 DeleteGear(graves[i]);
                 RenderHealth(resgear^.Hedgehog^);
                 RecountTeamHealth(resgear^.Hedgehog^.Team);
-                resgear^.Hedgehog^.Effects[heResurrected]:= true;
+                resgear^.Hedgehog^.Effects[heResurrected]:= 1;
                 // only make hat-less hedgehogs look like zombies, preserve existing hats
                 
                 if resgear^.Hedgehog^.Hat = 'NoHat' then
@@ -5420,15 +5420,64 @@
 
 (*
 WIP. The ice gun will have the following effects.  It has been proposed by sheepluva that it take the appearance of a large freezer
-spewing ice cubes.  The cubes will probably be visual gears only, although if they were gear particles, it could allow for impacting targets in a spray.
+spewing ice cubes.  The cubes will be visual gears only.  The scatter from them and the impact snow dust should help hide imprecisions in things like the GearsNear effect.
 For now we assume a "ray" like a deagle projected out from the gun.
 All these effects assume the ray's angle is not changed and that the target type was unchanged over a number of ticks.  This is a simplifying assumption for "gun was applying freezing effect to the same target".  
   * When fired at water a layer of ice textured land is added above the water.
-  * When fired at non-ice land (land and $FF00 and not lfIce) the land is overlaid with a thin layer of ice textured land near that point. For attractiveness, a slope would probably be needed.
+  * When fired at non-ice land (land and $FF00 and not lfIce) the land is overlaid with a thin layer of ice textured land around that point (say, 1 or 2px into land, 1px above). For attractiveness, a slope would probably be needed.
   * When fired at a hog (land and $00FF <> 0), while the hog is targetted, the hog's state is set to frozen.  As long as the gun is on the hog, a frozen hog sprite creeps up from the feet to the head.  If the effect is interrupted before reaching the top, the freezing state is cleared.
 A frozen hog will animate differently.  To be decided, but possibly in a similar fashion to a grave when it comes to explosions.  The hog might (possibly) not be damaged by explosions.  This might make freezing potentially useful for friendlies in a bad position.  It might be better to allow damage though.
 A frozen hog stays frozen for a certain number of turns. Each turn the frozen overlay becomes fainter, until it fades and the hog animates normally again.
 *)
 procedure doStepIceGun(Gear: PGear);
+var 
+    HHGear, iter: PGear;
+    ndX, ndY: hwFloat;
+    gX, gY: LongInt;
 begin
+    with Gear^ do
+        begin
+        HHGear := Hedgehog^.Gear;
+        HedgehogChAngle(HHGear);
+        ndX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX);
+        ndY:= -AngleCos(HHGear^.Angle);
+        if (ndX <> dX) or (ndY <> dY) then
+            begin
+            Pos:= 0;
+            Target.X:= NoPointX;
+            LastDamage:= nil;
+            X:= HHGear^.X;
+            Y:= HHGear^.Y;
+// unfreeze all semifrozen hogs
+            iter := GearsList;
+            while iter <> nil do
+                begin
+                if (iter^.Kind = gtHedgehog) and 
+                   (iter^.Hedgehog^.Effects[heFrozen] < 0) then 
+                    iter^.Hedgehog^.Effects[heFrozen]:= 0;
+                iter:= iter^.NextGear;
+                end;
+            end
+        else
+            begin
+            gX:= hwRound(X);
+            gY:= hwRound(Y);
+            X:= X + dX;
+            Y:= Y + dY;
+            if Target.X <> NoPointX then
+                inc(Pos)
+            else if (gY > cWaterLine) or 
+                    (((gX and LAND_WIDTH_MASK = 0) and (gY and LAND_HEIGHT_MASK = 0))
+                        and ((Land[gY, gX] and $FF00 and not lfIce <> 0) or
+                             (Land[gY, gX] and $00FF <> 0))) then
+                begin
+                Target.X:= gX;
+                Target.Y:= gY;
+                if Land[gY, gX] and $00FF <> 0 then // locate and tag hogs
+                    begin
+                //GearsNear(X, Y, gtHedgehog, Radius);
+                    end;
+                end
+        end
+    end;
 end;
--- a/hedgewars/uGears.pas	Wed May 02 19:16:12 2012 -0400
+++ b/hedgewars/uGears.pas	Thu May 03 00:20:58 2012 -0400
@@ -110,7 +110,7 @@
                 dec(Gear^.Health, dmg);
 
             if (Gear^.Hedgehog^.Team = CurrentTeam) and (Gear^.Damage <> Gear^.Karma)
-            and (not Gear^.Hedgehog^.King) and (not Gear^.Hedgehog^.Effects[hePoisoned]) and (not SuddenDeathDmg) then
+            and (not Gear^.Hedgehog^.King) and (Gear^.Hedgehog^.Effects[hePoisoned] = 0) and (not SuddenDeathDmg) then
                 Gear^.State:= Gear^.State or gstLoser;
 
             spawnHealthTagForHH(Gear, dmg);
@@ -141,7 +141,7 @@
         if Gear^.Kind = gtHedgehog then
             begin
             tmp:= 0;
-            if Gear^.Hedgehog^.Effects[hePoisoned] then
+            if Gear^.Hedgehog^.Effects[hePoisoned] <> 0 then
                 begin
                 inc(tmp, ModifyDamage(5, Gear));
                 if (GameFlags and gfResetHealth) <> 0 then
--- a/hedgewars/uGearsHedgehog.pas	Wed May 02 19:16:12 2012 -0400
+++ b/hedgewars/uGearsHedgehog.pas	Thu May 03 00:20:58 2012 -0400
@@ -356,6 +356,7 @@
                                  //amMelonStrike: AddGear(CurWeapon^.Pos, 0, gtAirAttack, 4, _0, _0, 0);
                     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);
              end;
              
              case CurAmmoType of
@@ -379,7 +380,8 @@
                       amJetpack, amBirdy,
                  amFlamethrower, amLandGun,
                   amResurrector, amStructure,
-                       amTardis, amPiano: CurAmmoGear:= newGear;
+                       amTardis, amPiano,
+                       amIceGun: CurAmmoGear:= newGear;
              end;
              
             if ((CurAmmoType = amMine) or (CurAmmoType = amSMine)) and (GameFlags and gfInfAttack <> 0) then
@@ -611,7 +613,7 @@
                     end;
      posCaseHealth: begin
                     inc(HH^.Health, Gear^.Health);
-                    HH^.Hedgehog^.Effects[hePoisoned] := false;
+                    HH^.Hedgehog^.Effects[hePoisoned] := 0;
                     str(Gear^.Health, s);
                     s:= '+' + s;
                     AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo);
@@ -1157,8 +1159,8 @@
 
         if (Gear^.State and gstHHGone) = 0 then
             begin
-            Gear^.Hedgehog^.Effects[hePoisoned] := false;
-            if Gear^.Hedgehog^.Effects[heResurrectable] then
+            Gear^.Hedgehog^.Effects[hePoisoned] := 0;
+            if Gear^.Hedgehog^.Effects[heResurrectable] <> 0 then
                 begin
                 ResurrectHedgehog(Gear);
                 end
--- a/hedgewars/uGearsList.pas	Wed May 02 19:16:12 2012 -0400
+++ b/hedgewars/uGearsList.pas	Thu May 03 00:20:58 2012 -0400
@@ -148,7 +148,7 @@
                 gear^.Z:= cHHZ;
                 if (GameFlags and gfAISurvival) <> 0 then
                     if gear^.Hedgehog^.BotLevel > 0 then
-                        gear^.Hedgehog^.Effects[heResurrectable] := true;
+                        gear^.Hedgehog^.Effects[heResurrectable] := 0;
                 end;
        gtShell: begin
                 gear^.Radius:= 4;
@@ -541,8 +541,8 @@
 
         inc(KilledHHs);
         RecountTeamHealth(team);
-        if (CurrentHedgehog <> nil) and CurrentHedgehog^.Effects[heResurrectable] and
-        (not Gear^.Hedgehog^.Effects[heResurrectable]) then
+        if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Effects[heResurrectable] <> 0)  and
+        (Gear^.Hedgehog^.Effects[heResurrectable] = 0) then
             with CurrentHedgehog^ do 
                 begin
                 inc(Team^.stats.AIKills);
--- a/hedgewars/uGearsRender.pas	Wed May 02 19:16:12 2012 -0400
+++ b/hedgewars/uGearsRender.pas	Thu May 03 00:20:58 2012 -0400
@@ -232,7 +232,7 @@
     HatVisible:= false;
 
 
-    if HH^.Effects[hePoisoned] then
+    if HH^.Effects[hePoisoned] <> 0 then
         begin
         Tint($00, $FF, $40, $40);
         DrawTextureRotatedF(SpritesData[sprSmokeWhite].texture, 2, 0, 0, sx, sy, 0, 1, 22, 22, (RealTicks shr 36) mod 360);
@@ -877,12 +877,12 @@
             end
         end;
 
-    if HH^.Effects[hePoisoned] then
+    if HH^.Effects[hePoisoned] <> 0 then
         begin
         Tint($00, $FF, $40, $80);
         DrawTextureRotatedF(SpritesData[sprSmokeWhite].texture, 1.5, 0, 0, sx, sy, 0, 1, 22, 22, 360 - (RealTicks shr 37) mod 360);
         end;
-    if HH^.Effects[heResurrected] then
+    if HH^.Effects[heResurrected] <> 0 then
         begin
         Tint($f5, $db, $35, $20);
         DrawSprite(sprVampiric, sx - 24, sy - 24, 0);
@@ -914,8 +914,10 @@
     if Gear^.Target.X <> NoPointX then
         if Gear^.AmmoType = amBee then
             DrawSpriteRotatedF(sprTargetBee, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360)
-        else
-            DrawSpriteRotatedF(sprTargetP, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360);
+	else if Gear^.AmmoType = amIceGun then
+	    DrawSprite(sprSnowDust, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, (RealTicks shr 3) mod 360)
+    else
+        DrawSpriteRotatedF(sprTargetP, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360);
 
     case Gear^.Kind of
           gtGrenade: DrawSpriteRotated(sprBomb, x, y, 0, Gear^.DirAngle);
--- a/hedgewars/uGearsUtils.pas	Wed May 02 19:16:12 2012 -0400
+++ b/hedgewars/uGearsUtils.pas	Thu May 03 00:20:58 2012 -0400
@@ -132,7 +132,7 @@
                                 if Gear^.Kind <> gtFlame then FollowGear:= Gear
                                 end;
                             if ((Mask and EXPLPoisoned) <> 0) and (Gear^.Kind = gtHedgehog) and (not Gear^.Invulnerable) then
-                                Gear^.Hedgehog^.Effects[hePoisoned] := true;
+                                Gear^.Hedgehog^.Effects[hePoisoned] := 1;
                             end;
 
                         end;
@@ -371,7 +371,7 @@
                 and (Gear^.Kind <> gtDEagleShot) and (Gear^.Kind <> gtSineGunShot) then
                     if Gear^.Kind = gtHedgehog then
                         begin
-                        if Gear^.Hedgehog^.Effects[heResurrectable] then
+                        if Gear^.Hedgehog^.Effects[heResurrectable] <> 0 then
                             ResurrectHedgehog(Gear)
                         else
                             begin
@@ -449,8 +449,8 @@
     gear^.dY := _0;
     gear^.Damage := 0;
     gear^.Health := gear^.Hedgehog^.InitialHealth;
-    gear^.Hedgehog^.Effects[hePoisoned] := false;
-    if not CurrentHedgehog^.Effects[heResurrectable] then
+    gear^.Hedgehog^.Effects[hePoisoned] := 0;
+    if CurrentHedgehog^.Effects[heResurrectable] = 0 then
         with CurrentHedgehog^ do 
             begin
             inc(Team^.stats.AIKills);
@@ -593,7 +593,7 @@
     begin
     OutError('Can''t find place for Gear', false);
     if Gear^.Kind = gtHedgehog then
-        Gear^.Hedgehog^.Effects[heResurrectable] := false;
+        Gear^.Hedgehog^.Effects[heResurrectable] := 0;
     DeleteGear(Gear);
     Gear:= nil
     end
--- a/hedgewars/uScript.pas	Wed May 02 19:16:12 2012 -0400
+++ b/hedgewars/uScript.pas	Thu May 03 00:20:58 2012 -0400
@@ -1103,7 +1103,7 @@
     else begin
         gear := GearByUID(lua_tointeger(L, 1));
         if (gear <> nil) and (gear^.Hedgehog <> nil) then
-            gear^.Hedgehog^.Effects[THogEffect(lua_tointeger(L, 2))]:= lua_toboolean(L, 3);
+            gear^.Hedgehog^.Effects[THogEffect(lua_tointeger(L, 2))]:= lua_tointeger(L, 3);
     end;
     lc_seteffect := 0;
 end;
@@ -1118,9 +1118,9 @@
         begin
         gear:= GearByUID(lua_tointeger(L, 1));
         if (gear <> nil) and (gear^.Hedgehog <> nil) then
-            lua_pushboolean(L, gear^.Hedgehog^.Effects[THogEffect(lua_tointeger(L, 2))])
+            lua_pushinteger(L, gear^.Hedgehog^.Effects[THogEffect(lua_tointeger(L, 2))])
         else
-            lua_pushboolean(L, false)
+            lua_pushinteger(L, 0)
         end;
     lc_geteffect:= 1
 end;
--- a/hedgewars/uTeams.pas	Wed May 02 19:16:12 2012 -0400
+++ b/hedgewars/uTeams.pas	Thu May 03 00:20:58 2012 -0400
@@ -384,7 +384,7 @@
             begin
             Hedgehogs[0].King:= true;
             Hedgehogs[0].Hat:= 'crown';
-            Hedgehogs[0].Effects[hePoisoned] := false;
+            Hedgehogs[0].Effects[hePoisoned] := 0;
             h:= Hedgehogs[0].Gear^.Health;
             Hedgehogs[0].Gear^.Health:= hwRound(int2hwFloat(th)*_0_375);
             if Hedgehogs[0].Gear^.Health > h then
--- a/hedgewars/uTypes.pas	Wed May 02 19:16:12 2012 -0400
+++ b/hedgewars/uTypes.pas	Thu May 03 00:20:58 2012 -0400
@@ -209,7 +209,7 @@
             PrevTexture, NextTexture: PTexture;
             end;
 
-    THogEffect = (heInvulnerable, heResurrectable, hePoisoned, heResurrected);
+    THogEffect = (heInvulnerable, heResurrectable, hePoisoned, heResurrected, heFrozen);
 
     TScreenFade = (sfNone, sfInit, sfToBlack, sfFromBlack, sfToWhite, sfFromWhite);
 
@@ -347,7 +347,7 @@
             King: boolean;  // Flag for a bunch of hedgehog attributes
             Unplaced: boolean;  // Flag for hog placing mode
             Timer: Longword;
-            Effects: array[THogEffect] of boolean;
+            Effects: array[THogEffect] of LongInt;
             end;
 
     TTeam = record