Cluster bomb
authorunc0rr
Wed, 12 Jul 2006 15:39:58 +0000
changeset 78 66bb79dd248d
parent 77 51eb4c197ec3
child 79 29b477319854
Cluster bomb
hedgewars/Data/Graphics/ClBomb.png
hedgewars/Data/Graphics/ClParticle.png
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uAIAmmoTests.pas
hedgewars/uConsts.pas
hedgewars/uGears.pas
Binary file hedgewars/Data/Graphics/ClBomb.png has changed
Binary file hedgewars/Data/Graphics/ClParticle.png has changed
--- a/hedgewars/GSHandlers.inc	Tue Jul 11 21:23:00 2006 +0000
+++ b/hedgewars/GSHandlers.inc	Wed Jul 12 15:39:58 2006 +0000
@@ -126,13 +126,21 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepBomb(Gear: PGear);
+var i: integer;
 begin
 AllInactive:= false;
 doStepFallingGear(Gear);
 dec(Gear.Timer);
 if Gear.Timer = 0 then
    begin
-   doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
+   case Gear.Kind of
+        gtAmmo_Bomb: doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
+      gtClusterBomb: begin
+                     doMakeExplosion(round(Gear.X), round(Gear.Y), 30, EXPLAutoSound);
+                     for i:= 0 to 4 do
+                         AddGear(round(Gear.X), round(Gear.Y), gtCluster, 0, (getrandom - 0.5)*0.2, (getrandom - 2) * 0.2);
+                     end
+        end;
    DeleteGear(Gear);
    exit
    end;
@@ -140,6 +148,20 @@
 if (Gear.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then PlaySound(sndGrenadeImpact)
 end;
 
+procedure doStepCluster(Gear: PGear);
+begin
+AllInactive:= false;
+doStepFallingGear(Gear);
+if (Gear.State and gstCollision) <> 0 then
+   begin
+   doMakeExplosion(round(Gear.X), round(Gear.Y), 20, EXPLAutoSound);
+   DeleteGear(Gear);
+   exit
+   end;
+if (GameTicks and $1F) = 0 then
+   AddGear(round(Gear.X), round(Gear.Y), gtSmokeTrace, 0)
+end;
+
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepGrenade(Gear: PGear);
 begin
--- a/hedgewars/HHHandlers.inc	Tue Jul 11 21:23:00 2006 +0000
+++ b/hedgewars/HHHandlers.inc	Wed Jul 12 15:39:58 2006 +0000
@@ -58,21 +58,22 @@
         xx:= Sign(dX)*Sin(Angle*pi/cMaxAngle);
         yy:= -Cos(Angle*pi/cMaxAngle);
              case Ammo[CurSlot, CurAmmo].AmmoType of
+                      amGrenade: FollowGear:= AddGear(round(X), round(Y), gtAmmo_Bomb,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo[CurSlot, CurAmmo].Timer);
+                  amClusterBomb: FollowGear:= AddGear(round(X), round(Y), gtClusterBomb,  0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo[CurSlot, CurAmmo].Timer);
                       amBazooka: FollowGear:= AddGear(round(X), round(Y), gtAmmo_Grenade, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor);
-                      amGrenade: FollowGear:= AddGear(round(X), round(Y), gtAmmo_Bomb,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo[CurSlot, CurAmmo].Timer);
                           amUFO: FollowGear:= AddGear(round(X), round(Y), gtUFO,          0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor);
                       amShotgun: begin
                                  PlaySound(sndShotgunReload);
                                  CurAmmoGear:= AddGear(round(X), round(Y), gtShotgunShot,  0, xx * 0.5, yy * 0.5);
                                  end;
+                   amPickHammer: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y) + cHHRadius, gtPickHammer, 0);
+                         amSkip: TurnTimeLeft:= 0;
+                         amRope: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y), gtRope, 0, xx, yy);
+                         amMine: AddGear(round(X) + Sign(dX) * 7, round(Y), gtMine, 0, Sign(dX) * 0.02, 0, 3000);
                        amDEagle: begin
                                  FollowGear:= AddGear(round(X), round(Y), gtDEagleShot,   0, xx * 0.5, yy * 0.5);
                                  end;
-                         amSkip: TurnTimeLeft:= 0;
-                   amPickHammer: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y) + cHHRadius, gtPickHammer, 0);
-                         amRope: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y), gtRope, 0, xx, yy);
-                         amMine: AddGear(round(X) + Sign(dX) * 7, round(Y), gtMine, 0, Sign(dX) * 0.02, 0, 3000);
-                     amDynamite: AddGear(round(X) + Sign(dX) * 7, round(Y), gtDynamite, 0, Sign(dX) * 0.035, 0, 5000); 
+                     amDynamite: AddGear(round(X) + Sign(dX) * 7, round(Y), gtDynamite, 0, Sign(dX) * 0.035, 0, 5000);
                   end;
         Power:= 0;
         if CurAmmoGear <> nil then
--- a/hedgewars/uAIAmmoTests.pas	Tue Jul 11 21:23:00 2006 +0000
+++ b/hedgewars/uAIAmmoTests.pas	Wed Jul 12 15:39:58 2006 +0000
@@ -44,6 +44,7 @@
 const AmmoTests: array[TAmmoType] of TAmmoTestProc =
                  (
 {amGrenade}       TestGrenade,
+{amClusterBomb}   nil,
 {amBazooka}       TestBazooka,
 {amUFO}           nil,
 {amShotgun}       TestShotgun,
--- a/hedgewars/uConsts.pas	Tue Jul 11 21:23:00 2006 +0000
+++ b/hedgewars/uConsts.pas	Wed Jul 12 15:39:58 2006 +0000
@@ -44,15 +44,16 @@
      TSprite    = (sprWater, sprCloud, sprBomb, sprBigDigit, sprFrame,
                    sprLag, sprArrow, sprGrenade, sprTargetP, sprUFO,
                    sprSmokeTrace, sprRopeHook, sprExplosion50, sprMineOff,
-                   sprMineOn, sprCase, sprFAid, sprDynamite, sprPower);
+                   sprMineOn, sprCase, sprFAid, sprDynamite, sprPower,
+                   sprClusterBomb, sprClusterParticle);
      TGearType  = (gtCloud, gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag,
                    gtGrave, gtUFO, gtShotgunShot, gtActionTimer, gtPickHammer, gtRope,
                    gtSmokeTrace, gtExplosion, gtMine, gtCase, gtDEagleShot, gtDynamite,
-                   gtTeamHealthSorter);
+                   gtTeamHealthSorter, gtClusterBomb, gtCluster);
      TGearsType = set of TGearType;
      TSound     = (sndGrenadeImpact, sndExplosion, sndThrowPowerUp, sndThrowRelease, sndSplash,
                    sndShotgunReload, sndShotgunFire, sndGraveImpact, sndMineTick);
-     TAmmoType  = (amGrenade, amBazooka, amUFO, amShotgun, amPickHammer, amSkip, amRope,
+     TAmmoType  = (amGrenade, amClusterBomb, amBazooka, amUFO, amShotgun, amPickHammer, amSkip, amRope,
                    amMine, amDEagle, amDynamite);
      THWFont    = (fnt16, fntBig);
      THHFont    = record
@@ -246,7 +247,9 @@
                      (FileName:      'Case'; Path: ptGraphics; Width:  32; Height: 32; hasAlpha: false),// sprCase
                      (FileName:  'FirstAid'; Path: ptGraphics; Width:  48; Height: 48; hasAlpha: false),// sprFAid
                      (FileName:  'dynamite'; Path: ptGraphics; Width:  32; Height: 32; hasAlpha: false),// sprDynamite
-                     (FileName:     'Power'; Path: ptGraphics; Width:  32; Height: 32; hasAlpha:  true) // sprPower
+                     (FileName:     'Power'; Path: ptGraphics; Width:  32; Height: 32; hasAlpha:  true),// sprPower
+                     (FileName:    'ClBomb'; Path: ptGraphics; Width:  16; Height: 16; hasAlpha: false),// sprClusterBomb
+                     (FileName:'ClParticle'; Path: ptGraphics; Width:  16; Height: 16; hasAlpha: false) // sprClusterParticle
                      );
       Soundz: array[TSound] of record
                                        FileName: String[31];
@@ -278,6 +281,14 @@
                                           AmmoType: amGrenade);
                                    Slot: 1;
                                    TimeAfterTurn: 3000),
+                                  (Name: 'Cluster Bomb';
+                                   Ammo: (Propz: ammoprop_Timerable or ammoprop_Power;
+                                          Count: 5;
+                                          NumPerTurn: 0;
+                                          Timer: 3000;
+                                          AmmoType: amClusterBomb);
+                                   Slot: 1;
+                                   TimeAfterTurn: 3000),
                                   (Name: 'Bazooka';
                                    Ammo: (Propz: ammoprop_Power;
                                           Count: AMMO_INFINITE;
--- a/hedgewars/uGears.pas	Tue Jul 11 21:23:00 2006 +0000
+++ b/hedgewars/uGears.pas	Wed Jul 12 15:39:58 2006 +0000
@@ -116,7 +116,9 @@
                                                                doStepCase,
                                                                doStepDEagleShot,
                                                                doStepDynamite,
-                                                               doStepTeamHealthSorter
+                                                               doStepTeamHealthSorter,
+                                                               doStepBomb,
+                                                               doStepCluster
                                                                );
 
 function AddGear(X, Y: integer; Kind: TGearType; State: Cardinal; const dX: real=0.0; dY: real=0.0; Timer: LongWord=0): PGear;
@@ -210,6 +212,12 @@
                 Result.Friction:= 0.03;
                 Result.Timer:= 5000;
                 end;
+ gtClusterBomb: begin
+                Result.Radius:= 4;
+                Result.Elasticity:= 0.6;
+                Result.Friction:= 0.995;
+                Result.Timer:= Timer
+                end;
      end;
 if GearsList = nil then GearsList:= Result
                    else begin
@@ -499,6 +507,8 @@
                          posCaseAmmo  : DrawSprite(sprCase, Round(Gear.X) - 16 + WorldDx, Round(Gear.Y) - 16 + WorldDy, 0, Surface);
                          posCaseHealth: DrawSprite(sprFAid, Round(Gear.X) - 24 + WorldDx, Round(Gear.Y) - 24 + WorldDy, (GameTicks shr 6) mod 13, Surface);
                          end;
+     gtClusterBomb: DrawSprite(sprClusterBomb, Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, trunc(Gear.DirAngle), Surface);
+         gtCluster: DrawSprite(sprClusterParticle, Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, 0, Surface);
               end;
       Gear:= Gear.NextGear
       end;