- Mine checks whether a hedgehog is near less frequently
authorunc0rr
Fri, 09 Sep 2005 21:45:31 +0000
changeset 14 81f125629b25
parent 13 7a5db822fd3f
child 15 6200cca92480
- Mine checks whether a hedgehog is near less frequently - Case with ammo (not fully implemented)
hedgewars/Data/Graphics/Case.png
hedgewars/GSHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
Binary file hedgewars/Data/Graphics/Case.png has changed
--- a/hedgewars/GSHandlers.inc	Wed Sep 07 18:51:53 2005 +0000
+++ b/hedgewars/GSHandlers.inc	Fri Sep 09 21:45:31 2005 +0000
@@ -586,8 +586,13 @@
    end;
 if ((Gear.State and gsttmpFlag) <> 0) then
    if ((Gear.State and gstAttacking) = 0) then
-      if isGearNear(Gear, gtHedgehog, 46, 32) then Gear.State:= Gear.State or gstAttacking else
-      else // gstAttacking <> 0
+      begin
+      if (Gear.Tag = 0) then
+         begin
+         Gear.Tag:= 10;
+         if isGearNear(Gear, gtHedgehog, 46, 32) then Gear.State:= Gear.State or gstAttacking
+         end else dec(Gear.Tag)
+      end else // gstAttacking <> 0
       begin
       AllInactive:= false;
       if (Gear.Timer and $1FF) = 0 then PlaySound(sndMineTick);
@@ -601,3 +606,41 @@
       end else // gsttmpFlag = 0
    if TurnTimeLeft = 0 then Gear.State:= Gear.State or gsttmpFlag;
 end;
+
+procedure doStepCase(Gear: PGear);
+begin
+if (Gear.dY <> 0) or (not TestCollisionY(Gear, 1)) then
+   begin
+   AllInactive:= false;
+   Gear.dY:= Gear.dY + cGravity;
+   Gear.Y:= Gear.Y + Gear.dY;
+   if (Gear.dY < 0) and TestCollisionY(Gear, -1) then Gear.dY:= 0 else
+   if (Gear.dY >= 0) and TestCollisionY(Gear, 1) then
+      begin
+      Gear.dY:= - Gear.dY * Gear.Elasticity;
+      if Gear.dY > - 0.001 then Gear.dY:= 0
+         else if Gear.dY < - 0.03 then PlaySound(sndGraveImpact);
+      end;
+   CheckGearDrowning(Gear);
+   end;
+
+if (Gear.CollIndex = High(Longword)) and (Gear.dY = 0) then AddGearCR(Gear)
+   else if (Gear.CollIndex < High(Longword)) and (Gear.dY <> 0) then DeleteCR(Gear);
+
+if (Gear.Tag = 0) then
+   begin
+   Gear.Tag:= 10;
+   if isGearNear(Gear, gtHedgehog, 25, 25) then
+      begin
+      ;//give ammo to hedgehog
+      DeleteGear(Gear);
+      SetAllToActive;
+      end;
+   end else dec(Gear.Tag);
+
+if Gear.Damage > 0 then
+   begin
+   DeleteGear(Gear);
+   doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound)
+   end
+end;
--- a/hedgewars/uConsts.pas	Wed Sep 07 18:51:53 2005 +0000
+++ b/hedgewars/uConsts.pas	Fri Sep 09 21:45:31 2005 +0000
@@ -44,10 +44,10 @@
      TSprite    = (sprWater, sprCloud, sprBomb, sprBigDigit, sprFrame,
                    sprLag, sprArrow, sprGrenade, sprTargetP, sprUFO,
                    sprSmokeTrace, sprRopeHook, sprExplosion50, sprMineOff,
-                   sprMineOn);
+                   sprMineOn, sprCase);
      TGearType  = (gtCloud, gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag,
                    gtGrave, gtUFO, gtShotgunShot, gtActionTimer, gtPickHammer, gtRope,
-                   gtSmokeTrace, gtExplosion, gtMine);
+                   gtSmokeTrace, gtExplosion, gtMine, gtCase);
      TSound     = (sndGrenadeImpact, sndExplosion, sndThrowPowerUp, sndThrowRelease, sndSplash,
                    sndShotgunReload, sndShotgunFire, sndGraveImpact, sndMineTick);
      TAmmoType  = (amGrenade, amBazooka, amUFO, amShotgun, amPickHammer, amSkip, amRope,
@@ -226,7 +226,8 @@
                                          (FileName:  'RopeHook.png'; Path: ptGraphics; Width:  32; Height: 32),// sprRopeHook
                                          (FileName:    'Expl50.png'; Path: ptGraphics; Width:  64; Height: 64),// sprExplosion50
                                          (FileName:   'MineOff.png'; Path: ptGraphics; Width:  16; Height: 16),// sprMineOff
-                                         (FileName:    'MineOn.png'; Path: ptGraphics; Width:  16; Height: 16) // sprMineOn
+                                         (FileName:    'MineOn.png'; Path: ptGraphics; Width:  16; Height: 16),// sprMineOn
+                                         (FileName:      'Case.png'; Path: ptGraphics; Width:  32; Height: 32) // sprCase
                                          );
       Soundz: array[TSound] of record
                                        FileName: String[31];
--- a/hedgewars/uGears.pas	Wed Sep 07 18:51:53 2005 +0000
+++ b/hedgewars/uGears.pas	Fri Sep 09 21:45:31 2005 +0000
@@ -107,7 +107,8 @@
                                                                doStepRope,
                                                                doStepSmokeTrace,
                                                                doStepExplosion,
-                                                               doStepMine
+                                                               doStepMine,
+                                                               doStepCase
                                                                );
 
 function AddGear(X, Y: integer; Kind: TGearType; State: Cardinal; const dX: real=0.0; dY: real=0.0; Timer: LongWord=0): PGear;
@@ -194,6 +195,11 @@
                 Result.Friction:= 0.995;
                 Result.Timer:= 3000;
                 end;
+        gtCase: begin
+                Result.HalfWidth:= 10;
+                Result.HalfHeight:= 10;
+                Result.Elasticity:= 0.6
+                end;
      end;
 if GearsList = nil then GearsList:= Result
                    else begin
@@ -445,6 +451,7 @@
             gtMine: if ((Gear.State and gstAttacking) = 0)or((Gear.Timer and $3FF) < 420)
                        then DrawSprite(sprMineOff , Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, trunc(Gear.DirAngle), Surface)
                        else DrawSprite(sprMineOn  , Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, trunc(Gear.DirAngle), Surface);
+            gtCase: DrawSprite(sprCase, Round(Gear.X) - 12 + WorldDx, Round(Gear.Y) - 12 + WorldDy, 0, Surface);
               end;
       Gear:= Gear.NextGear
       end;
@@ -470,11 +477,17 @@
 begin
 for i:= 0 to cCloudsNumber do AddGear( - cScreenWidth + i * ((cScreenWidth * 2 + 2304) div cCloudsNumber), -128, gtCloud, random(4), (0.5-random)*0.01);
 AddGear(0, 0, gtActionTimer, gtsStartGame, 0, 0, 2000).Health:= 3;
-for i:= 0 to 3 do
+for i:= 0 to 2 do
     begin
     GetHHPoint(x, y);
     AddGear(X, Y + 9, gtMine, 0);
     end;
+
+for i:= 0 to 0 do
+    begin
+    GetHHPoint(x, y);
+    AddGear(X, Y, gtCase, 0)
+    end;
 end;
 
 procedure doMakeExplosion(X, Y, Radius: integer; Mask: LongWord);
@@ -497,7 +510,8 @@
          dmg:= dmg shr 1;
          case Gear.Kind of
               gtHedgehog,
-                  gtMine: begin
+                  gtMine,
+                  gtCase: begin
                           inc(Gear.Damage, dmg);
                           Gear.dX:= Gear.dX + dmg / 200 * sign(Gear.X - X);
                           Gear.dY:= Gear.dY + dmg / 200 * sign(Gear.Y - Y);