- Health tags over drowned hedgehogs
authorunc0rr
Thu, 23 Nov 2006 20:10:42 +0000
changeset 263 36379e6abcdd
parent 262 b4bc05237c06
child 264 1c50fe872a64
- Health tags over drowned hedgehogs - Air Attack weapon
hedgewars/CCHandlers.inc
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uAIAmmoTests.pas
hedgewars/uConsts.pas
hedgewars/uGears.pas
hedgewars/uLocale.pas
share/hedgewars/Data/Graphics/AirBomb.png
share/hedgewars/Data/Graphics/CMakeLists.txt
share/hedgewars/Data/Locale/en.txt
share/hedgewars/Data/Locale/ru.txt
--- a/hedgewars/CCHandlers.inc	Thu Nov 23 19:48:39 2006 +0000
+++ b/hedgewars/CCHandlers.inc	Thu Nov 23 20:10:42 2006 +0000
@@ -326,7 +326,8 @@
    bSelected:= true;
    exit
    end;
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
+with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^,
+     CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
      if (State and gstHHChooseTarget) <> 0 then
         begin
         isCursorVisible:= false;
@@ -338,6 +339,8 @@
            SendIPCXY('p', TargetPoint.X, TargetPoint.Y);
            end;
         State:= State and not gstHHChooseTarget;
+        if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then
+           Message:= Message or gm_Attack;
         end else if CurrentTeam.ExtDriven then OutError('got /put while not being in choose target mode', false)
 end;
 
--- a/hedgewars/GSHandlers.inc	Thu Nov 23 19:48:39 2006 +0000
+++ b/hedgewars/GSHandlers.inc	Thu Nov 23 20:10:42 2006 +0000
@@ -171,18 +171,27 @@
 Gear.Y:= Gear.Y - 0.07;
 if Gear.Timer = 0 then
    begin
-   PHedgehog(Gear.Hedgehog).Gear.Active:= true;
+   PHedgehog(Gear.Hedgehog).Gear.Active:= true; // to let current hh die
    DeleteGear(Gear)
    end
 end;
 
+procedure doStepHealthTagWorkUnderWater(Gear: PGear);
+begin
+AllInactive:= false;
+Gear.Y:= Gear.Y - 0.07;
+if Gear.Y <= cWaterLine + 10 then
+   DeleteGear(Gear)
+end;
+
 procedure doStepHealthTag(Gear: PGear);
 var s: shortstring;
 begin
 AllInactive:= false;
 str(Gear.State, s);
 Gear.Surf:= RenderString(s, PHedgehog(Gear.Hedgehog).Team.Color, fnt16);
-Gear.doStep:= doStepHealthTagWork
+if Gear.Y < cWaterLine then Gear.doStep:= doStepHealthTagWork
+                       else Gear.doStep:= doStepHealthTagWorkUnderWater
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -876,6 +885,8 @@
 DrawTunnel(HHGear.X - cHHRadius, HHGear.Y + 1, 0.5, 0.0, cHHRadius * 4, 5);
 end;
 
+////////////////////////////////////////////////////////////////////////////////
+
 procedure doStepParachute(Gear: PGear);
 var HHGear: PGear;
 begin
@@ -909,7 +920,52 @@
 else if (Gear.Message and gm_Down) <> 0 then HHGear.Y:= HHGear.Y + cGravity * 40;
 
 HHGear.Y:= HHGear.Y + cGravity * 100;
+end;
 
+////////////////////////////////////////////////////////////////////////////////
+const cAirPlaneSpeed = 0.8;
+      cBombsDistance = 30;
+      cBombsSpeed = 0.1;
+
+procedure doStepAirAttackWork(Gear: PGear);
+begin
+AllInactive:= false;
+Gear.X:= Gear.X + cAirPlaneSpeed;
+if (Gear.Health > 0)and(Gear.X >= Gear.dX)and(Gear.X < Gear.dX + cAirPlaneSpeed) then
+   begin
+   dec(Gear.Health);
+   AddGear(round(Gear.X), round(Gear.Y), gtAirBomb, 0, cBombsSpeed, 0.0);
+   Gear.dX:= Gear.dX + cBombsDistance
+   end;
+if Gear.X > 2560 then DeleteGear(Gear)
+end;
+
+procedure doStepAirAttack(Gear: PGear);
+begin
+AllInactive:= false;
+Gear.X:= -512;
+Gear.Y:= -128;
+Gear.dX:= TargetPoint.X -
+          cBombsDistance * 5 / 2 - 
+          cBombsSpeed * sqrt(2 * (TargetPoint.Y - Gear.Y) / cGravity);
+Gear.Health:= 6;
+Gear.doStep:= doStepAirAttackWork
+end;
+
+////////////////////////////////////////////////////////////////////////////////
+
+procedure doStepAirBomb(Gear: PGear);
+begin
+AllInactive:= false;
+doStepFallingGear(Gear);
+if (Gear.State and gstCollision) <> 0 then
+   begin
+   doMakeExplosion(round(Gear.X), round(Gear.Y), 35, EXPLAutoSound);
+   DeleteGear(Gear);
+   exit
+   end;
+if (GameTicks and $3F) = 0 then
+   AddGear(round(Gear.X), round(Gear.Y), gtSmokeTrace, 0)
 end;
 
 
--- a/hedgewars/HHHandlers.inc	Thu Nov 23 19:48:39 2006 +0000
+++ b/hedgewars/HHHandlers.inc	Thu Nov 23 20:10:42 2006 +0000
@@ -67,7 +67,8 @@
                      amDynamite: AddGear(round(X) + hwSign(dX) * 7, round(Y), gtDynamite, 0, hwSign(dX) * 0.035, 0, 5000);
                   amBaseballBat: AddGear(round(X) + hwSign(dX) * 10, round(Y), gtShover, 0, xx * 0.5, yy * 0.5).Radius:= 20;
                     amFirePunch: CurAmmoGear:= AddGear(round(X) + hwSign(dX) * 10, round(Y), gtFirePunch, 0);
-                    amParachute: CurAmmoGear:= AddGear(round(X), round(Y), gtParachute, 0)
+                    amParachute: CurAmmoGear:= AddGear(round(X), round(Y), gtParachute, 0);
+                    amAirAttack: AddGear(0, 0, gtAirAttack, 0, 0, 0);
                   end;
         Power:= 0;
         if CurAmmoGear <> nil then
--- a/hedgewars/uAIAmmoTests.pas	Thu Nov 23 19:48:39 2006 +0000
+++ b/hedgewars/uAIAmmoTests.pas	Thu Nov 23 20:10:42 2006 +0000
@@ -43,7 +43,8 @@
 {amDynamite}      nil,
 {amFirePunch}     TestFirePunch,
 {amBaseballBat}   TestBaseballBat,
-{amParachute}     nil
+{amParachute}     nil,
+{amAirAttack}     nil
                   );
 
 const BadTurn = Low(integer);
--- a/hedgewars/uConsts.pas	Thu Nov 23 19:48:39 2006 +0000
+++ b/hedgewars/uConsts.pas	Thu Nov 23 20:10:42 2006 +0000
@@ -33,19 +33,19 @@
                    sprMineOn, sprCase, sprFAid, sprDynamite, sprPower,
                    sprClusterBomb, sprClusterParticle, sprFlame, sprHorizont,
                    sprSky, sprAMBorders, sprAMSlot, sprAMSlotName, sprAMAmmos,
-                   sprAMSlotKeys, sprAMSelection, sprFinger);
+                   sprAMSlotKeys, sprAMSelection, sprFinger, sprAirBomb);
      TGearType  = (gtCloud, gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag,
                    gtGrave, gtUFO, gtShotgunShot, gtPickHammer, gtRope,
                    gtSmokeTrace, gtExplosion, gtMine, gtCase, gtDEagleShot, gtDynamite,
                    gtTeamHealthSorter, gtClusterBomb, gtCluster, gtShover, gtFlame,
                    gtFirePunch, gtATStartGame, gtATSmoothWindCh, gtATFinishGame,
-                   gtParachute);
+                   gtParachute, gtAirAttack, gtAirBomb);
      TGearsType = set of TGearType;
      TSound     = (sndGrenadeImpact, sndExplosion, sndThrowPowerUp, sndThrowRelease, sndSplash,
                    sndShotgunReload, sndShotgunFire, sndGraveImpact, sndMineTick);
      TAmmoType  = (amGrenade, amClusterBomb, amBazooka, amUFO, amShotgun, amPickHammer,
                    amSkip, amRope, amMine, amDEagle, amDynamite, amFirePunch,
-                   amBaseballBat, amParachute);
+                   amBaseballBat, amParachute, amAirAttack);
      THWFont    = (fnt16, fntBig);
      TCapGroup  = (capgrpGameState, capgrpAmmoinfo, capgrpNetSay, capgrpVolume);
      THHFont    = record
@@ -77,7 +77,7 @@
       msgGettingConfig     = 'Getting game config...';
 
 const
-      cNetProtoVersion = 1;
+      cNetProtoVersion = 2;
 
       MAXNAMELEN = 32;
 
@@ -134,7 +134,7 @@
       gm_HJump  = $00000080;
       gm_Destroy= $00000100;
 
-      cMaxSlotIndex       = 7;
+      cMaxSlotIndex       = 8;
       cMaxSlotAmmoIndex   = 1;
 
       ammoprop_Timerable    = $00000001;
@@ -144,6 +144,7 @@
       ammoprop_AttackInFall = $00000010;
       ammoprop_AttackInJump = $00000020;
       ammoprop_NoCrosshair  = $00000040;
+      ammoprop_AttackingPut = $00000080;
       AMMO_INFINITE = High(LongWord);
 
       EXPLAllDamageInRadius = $00000001;
@@ -249,7 +250,8 @@
                      (FileName:     'Ammos'; Path: ptAmmoMenu; Width:  32; Height: 32; hasAlpha: false),// sprAMAmmos
                      (FileName:  'SlotKeys'; Path: ptAmmoMenu; Width:  32; Height: 32; hasAlpha: false),// sprAMSlotKeys
                      (FileName: 'Selection'; Path: ptAmmoMenu; Width:  32; Height: 32; hasAlpha: false),// sprAMSelection
-                     (FileName:    'Finger'; Path: ptGraphics; Width:  32; Height: 48; hasAlpha: false) // sprFinger
+                     (FileName:    'Finger'; Path: ptGraphics; Width:  32; Height: 48; hasAlpha: false),// sprFinger
+                     (FileName:   'AirBomb'; Path: ptGraphics; Width:  32; Height: 32; hasAlpha: false) // sprAirBomb
                      );
       Soundz: array[TSound] of record
                                        FileName: String[31];
@@ -274,7 +276,8 @@
                                   TimeAfterTurn: Longword;
                                   end = (
                                   (NameId: sidGrenade;
-                                   Ammo: (Propz: ammoprop_Timerable or ammoprop_Power;
+                                   Ammo: (Propz: ammoprop_Timerable or
+                                                 ammoprop_Power;
                                           Count: AMMO_INFINITE;
                                           NumPerTurn: 0;
                                           Timer: 3000;
@@ -282,7 +285,8 @@
                                    Slot: 1;
                                    TimeAfterTurn: 3000),
                                   (NameId: sidClusterBomb;
-                                   Ammo: (Propz: ammoprop_Timerable or ammoprop_Power;
+                                   Ammo: (Propz: ammoprop_Timerable or
+                                                 ammoprop_Power;
                                           Count: 5;
                                           NumPerTurn: 0;
                                           Timer: 3000;
@@ -298,7 +302,8 @@
                                    Slot: 0;
                                    TimeAfterTurn: 3000),
                                   (NameId: sidUFO;
-                                   Ammo: (Propz: ammoprop_Power or ammoprop_NeedTarget;
+                                   Ammo: (Propz: ammoprop_Power or
+                                                 ammoprop_NeedTarget;
                                           Count: 2;
                                           NumPerTurn: 0;
                                           Timer: 0;
@@ -314,12 +319,15 @@
                                    Slot: 2;
                                    TimeAfterTurn: 3000),
                                   (NameId: sidPickHammer;
-                                   Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_AttackInFall or ammoprop_AttackInJump;
+                                   Ammo: (Propz: ammoprop_ForwMsgs or
+                                                 ammoprop_AttackInFall or
+                                                 ammoprop_AttackInJump or
+                                                 ammoprop_NoCrosshair;
                                           Count: 2;
                                           NumPerTurn: 0;
                                           Timer: 0;
                                           AmmoType: amPickHammer);
-                                   Slot: 5;
+                                   Slot: 6;
                                    TimeAfterTurn: 0),
                                   (NameId: sidSkip;
                                    Ammo: (Propz: 0;
@@ -327,15 +335,17 @@
                                           NumPerTurn: 0;
                                           Timer: 0;
                                           AmmoType: amSkip);
-                                   Slot: 7;
+                                   Slot: 8;
                                    TimeAfterTurn: 0),
                                   (NameId: sidRope;
-                                   Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_AttackInFall or ammoprop_AttackInJump;
+                                   Ammo: (Propz: ammoprop_ForwMsgs or
+                                                 ammoprop_AttackInFall or
+                                                 ammoprop_AttackInJump;
                                           Count: 5;
                                           NumPerTurn: 0;
                                           Timer: 0;
                                           AmmoType: amRope);
-                                   Slot: 6;
+                                   Slot: 7;
                                    TimeAfterTurn: 0),
                                   (NameId: sidMine;
                                    Ammo: (Propz: ammoprop_NoCrosshair;
@@ -354,7 +364,9 @@
                                    Slot: 2;
                                    TimeAfterTurn: 3000),
                                    (NameId: sidDynamite;
-                                    Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_AttackInJump or ammoprop_AttackInFall;
+                                    Ammo: (Propz: ammoprop_NoCrosshair or
+                                                  ammoprop_AttackInJump or
+                                                  ammoprop_AttackInFall;
                                            Count: 1;
                                            NumPerTurn: 0;
                                            Timer: 0;
@@ -362,7 +374,10 @@
                                     Slot: 4;
                                     TimeAfterTurn: 5000),
                                    (NameId: sidFirePunch;
-                                    Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_ForwMsgs or ammoprop_AttackInJump or ammoprop_AttackInFall;
+                                    Ammo: (Propz: ammoprop_NoCrosshair or
+                                                  ammoprop_ForwMsgs or
+                                                  ammoprop_AttackInJump or
+                                                  ammoprop_AttackInFall;
                                            Count: AMMO_INFINITE;
                                            NumPerTurn: 0;
                                            Timer: 0;
@@ -378,12 +393,24 @@
                                     Slot: 3;
                                     TimeAfterTurn: 5000),
                                   (NameId: sidParachute;
-                                   Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_AttackInJump or ammoprop_AttackInFall;
+                                   Ammo: (Propz: ammoprop_ForwMsgs or
+                                                 ammoprop_AttackInJump or
+                                                 ammoprop_AttackInFall;
                                           Count: 2;
                                           NumPerTurn: 0;
                                           Timer: 0;
                                           AmmoType: amParachute);
-                                   Slot: 6;
+                                   Slot: 7;
+                                   TimeAfterTurn: 0),
+                                  (NameId: sidAirAttack;
+                                   Ammo: (Propz: ammoprop_NoCrosshair or
+                                                 ammoprop_NeedTarget or
+                                                 ammoprop_AttackingPut;
+                                          Count: 3;
+                                          NumPerTurn: 0;
+                                          Timer: 0;
+                                          AmmoType: amAirAttack);
+                                   Slot: 5;
                                    TimeAfterTurn: 0));
 
 implementation
--- a/hedgewars/uGears.pas	Thu Nov 23 19:48:39 2006 +0000
+++ b/hedgewars/uGears.pas	Thu Nov 23 20:10:42 2006 +0000
@@ -112,7 +112,9 @@
                                                                doStepActionTimer,
                                                                doStepActionTimer,
                                                                doStepActionTimer,
-                                                               doStepParachute
+                                                               doStepParachute,
+                                                               doStepAirAttack,
+                                                               doStepAirBomb
                                                                );
 
 function AddGear(X, Y: integer; Kind: TGearType; State: Longword; const dX: Double=0.0; dY: Double=0.0; Timer: LongWord=0): PGear;
@@ -221,6 +223,9 @@
                 Result.Radius:= 15;
                 Result.Tag:= Y
                 end;
+    gtAirBomb: begin
+               Result.Radius:= 3;
+               end;
      end;
 if GearsList = nil then GearsList:= Result
                    else begin
@@ -244,10 +249,12 @@
       exit
       end else
       begin
+      if Gear.Y >= cWaterLine then
+         AddGear(Round(Gear.X), Round(Gear.Y), gtHealthTag, max(Gear.Damage, Gear.Health)).Hedgehog:= Gear.Hedgehog;
       team:= PHedgehog(Gear.Hedgehog).Team;
-      PHedgehog(Gear.Hedgehog).Gear:= nil;
       if CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear = Gear then
          FreeActionsList; // to avoid ThinkThread on drawned gear
+      PHedgehog(Gear.Hedgehog).Gear:= nil;
       RecountTeamHealth(team);
       end;
 {$IFDEF DEBUGFILE}AddFileLog('DeleteGear: handle = '+inttostr(integer(Gear)));{$ENDIF}
@@ -517,6 +524,7 @@
      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);
            gtFlame: DrawSprite(sprFlame, Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy,(GameTicks div 128 + Gear.Angle) mod 8, Surface);
+         gtAirBomb: DrawSprite(sprAirBomb , Round(Gear.X) - 16 + WorldDx, Round(Gear.Y) - 16 + WorldDy, DxDy2Angle32(Gear.dY, Gear.dX), Surface);
               end;
       Gear:= Gear.NextGear
       end;
--- a/hedgewars/uLocale.pas	Thu Nov 23 19:48:39 2006 +0000
+++ b/hedgewars/uLocale.pas	Thu Nov 23 20:10:42 2006 +0000
@@ -21,7 +21,7 @@
 type TAmmoStrId = (sidGrenade, sidClusterBomb, sidBazooka, sidUFO, sidShotgun,
                    sidPickHammer, sidSkip, sidRope, sidMine, sidDEagle,
                    sidDynamite, sidBaseballBat, sidFirePunch, sidSeconds,
-                   sidParachute);
+                   sidParachute, sidAirAttack);
      TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume);
 var trammo: array[TAmmoStrId] of string;
     trmsg: array[TMsgStrId] of string;
Binary file share/hedgewars/Data/Graphics/AirBomb.png has changed
--- a/share/hedgewars/Data/Graphics/CMakeLists.txt	Thu Nov 23 19:48:39 2006 +0000
+++ b/share/hedgewars/Data/Graphics/CMakeLists.txt	Thu Nov 23 20:10:42 2006 +0000
@@ -1,6 +1,7 @@
 add_subdirectory(Graves)
 add_subdirectory(AmmoMenu)
 install(FILES
+	AirBomb.png
 	Arrow.png
 	BigDigits.png
 	BlueWater.png
--- a/share/hedgewars/Data/Locale/en.txt	Thu Nov 23 19:48:39 2006 +0000
+++ b/share/hedgewars/Data/Locale/en.txt	Thu Nov 23 20:10:42 2006 +0000
@@ -15,6 +15,7 @@
 00:12=Fire Punch
 00:13=sec
 00:14=Parachute
+00:15=Air Attack
 
 01:00=Let's fight!
 01:01=Round draw
--- a/share/hedgewars/Data/Locale/ru.txt	Thu Nov 23 19:48:39 2006 +0000
+++ b/share/hedgewars/Data/Locale/ru.txt	Thu Nov 23 20:10:42 2006 +0000
@@ -15,6 +15,7 @@
 00:12=Огненный удар
 00:13=сек
 00:14=Парашют
+00:15=Воздушная атака
 
 01:00=Вперёд к победе!
 01:01=Ничья