First implementation of the Cake weapon
authorunc0rr
Fri, 25 Jul 2008 13:52:35 +0000
changeset 1089 24e9e1ca0394
parent 1088 9702e17146e6
child 1090 c4ff49d0fe9b
First implementation of the Cake weapon
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uAIAmmoTests.pas
hedgewars/uConsts.pas
hedgewars/uGears.pas
hedgewars/uLocale.pas
share/hedgewars/Data/Locale/bg.txt
share/hedgewars/Data/Locale/de.txt
share/hedgewars/Data/Locale/en.txt
share/hedgewars/Data/Locale/fr.txt
share/hedgewars/Data/Locale/it.txt
share/hedgewars/Data/Locale/pl.txt
share/hedgewars/Data/Locale/ru.txt
share/hedgewars/Data/Locale/sk.txt
--- a/hedgewars/GSHandlers.inc	Fri Jul 25 10:56:05 2008 +0000
+++ b/hedgewars/GSHandlers.inc	Fri Jul 25 13:52:35 2008 +0000
@@ -1481,8 +1481,82 @@
 Gear^.doStep:= @doStepKamikazeIdle
 end;
 
-procedure doStepSpider(Gear: PGear);
+procedure doStepCakeWork(Gear: PGear);
+const dirs: array[0..3] of TPoint = ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0));
+var xx, yy, xxn, yyn: LongInt;
+	da: LongInt;
+
+	procedure PrevAngle;
+	begin
+	Gear^.Angle:= (Gear^.Angle + 4 - dA) mod 4
+	end;
+	
+	procedure NextAngle;
+	begin
+	Gear^.Angle:= (Gear^.Angle + 4 + dA) mod 4
+	end;
+	
 begin
-AfterAttack;
-DeleteGear(Gear);
+inc(Gear^.Tag);
+if Gear^.Tag < 5 then exit;
+
+
+dA:= hwSign(Gear^.dX);
+xx:= dirs[Gear^.Angle].x;
+yy:= dirs[Gear^.Angle].y;
+xxn:= dirs[(Gear^.Angle + 4 + dA) mod 4].x;
+yyn:= dirs[(Gear^.Angle + 4 + dA) mod 4].y;
+
+
+if (xx = 0) then
+	if TestCollisionYwithGear(Gear, yy) then
+		PrevAngle
+	else begin
+		Gear^.Tag:= 0;
+		Gear^.Y:= Gear^.Y + int2hwFloat(yy);
+		if not TestCollisionXwithGear(Gear, xxn) then NextAngle
+		end;
+
+if (yy = 0) then
+	if TestCollisionXwithGear(Gear, xx) then
+		PrevAngle
+	else begin
+		Gear^.Tag:= 0;
+		Gear^.X:= Gear^.X + int2hwFloat(xx);
+		if not TestCollisionYwithGear(Gear, yyn) then NextAngle
+		end;
+
+dec(Gear^.Health);
+if Gear^.Health = 0 then
+	begin
+	doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound);
+	AfterAttack;
+	DeleteGear(Gear)
+	end
 end;
+
+procedure doStepCakeFall(Gear: PGear);
+begin
+AllInactive:= false;
+
+Gear^.dY:= Gear^.dY + cGravity;
+if TestCollisionYwithGear(Gear, 1) then
+	Gear^.doStep:= @doStepCakeWork
+else
+	begin
+	Gear^.Y:= Gear^.Y + Gear^.dY;
+	if CheckGearDrowning(Gear) then AfterAttack
+	end
+end;
+
+procedure doStepCake(Gear: PGear);
+var HHGear: PGear;
+begin
+AllInactive:= false;
+
+HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
+DeleteCI(HHGear);
+
+Gear^.doStep:= @doStepCakeFall
+end;
+
--- a/hedgewars/HHHandlers.inc	Fri Jul 25 10:56:05 2008 +0000
+++ b/hedgewars/HHHandlers.inc	Fri Jul 25 13:52:35 2008 +0000
@@ -159,7 +159,7 @@
                        amSwitch: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtSwitcher, 0, _0, _0, 0);
                        amMortar: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtMortar,  0, xx*cMaxPower/cPowerDivisor, yy*cMaxPower/cPowerDivisor, 0);
                        amKamikaze: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtKamikaze, 0, xx * _0_5, yy * _0_5, 0);
-                         amSpider: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtSpider, 0, xx, _0, 0);
+                         amCake: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtCake, 0, xx, _0, 0);
                   end;
 
         uStats.AmmoUsed(Ammo^[CurSlot, CurAmmo].AmmoType);
--- a/hedgewars/uAIAmmoTests.pas	Fri Jul 25 10:56:05 2008 +0000
+++ b/hedgewars/uAIAmmoTests.pas	Fri Jul 25 13:52:35 2008 +0000
@@ -68,7 +68,7 @@
                   (proc: nil;              flags: 0), // amSwitch
                   (proc: @TestMortar;      flags: 0), // amMortar
                   (proc: nil;              flags: 0), // amKamikaze
-                  (proc: nil;              flags: 0)  // amSpider
+                  (proc: nil;              flags: 0)  // amCake
                   );
 
 const BadTurn = Low(LongInt) div 4;
--- a/hedgewars/uConsts.pas	Fri Jul 25 10:56:05 2008 +0000
+++ b/hedgewars/uConsts.pas	Fri Jul 25 13:52:35 2008 +0000
@@ -55,7 +55,7 @@
                    gtFirePunch, gtATStartGame, gtATSmoothWindCh, gtATFinishGame,
                    gtParachute, gtAirAttack, gtAirBomb, gtBlowTorch, gtGirder,
                    gtTeleport, gtSmallDamage, gtSwitcher, gtTarget, gtMortar,
-                   gtWhip, gtKamikaze, gtSpider);
+                   gtWhip, gtKamikaze, gtCake);
 
      TVisualGearType = (vgtFlake, vgtCloud, vgtExplPart, vgtExplPart2, vgtFire);
 
@@ -72,7 +72,7 @@
      TAmmoType  = (amGrenade, amClusterBomb, amBazooka, amUFO, amShotgun, amPickHammer,
                    amSkip, amRope, amMine, amDEagle, amDynamite, amFirePunch, amWhip,
                    amBaseballBat, amParachute, amAirAttack, amMineStrike, amBlowTorch,
-                   amGirder, amTeleport, amSwitch, amMortar, amKamikaze, amSpider);
+                   amGirder, amTeleport, amSwitch, amMortar, amKamikaze, amCake);
 
      THWFont    = (fnt16, fntBig, fntSmall);
 
@@ -940,7 +940,7 @@
                                    SkipTurns: 0;
                                    PosCount: 1;
                                    PosSprite: sprWater),
-                                  (NameId: sidSpider;
+                                  (NameId: sidCake;
                                    NameTex: nil;
                                    Probability: 100;
                                    NumberInCase: 1;
@@ -951,7 +951,7 @@
                                           NumPerTurn: 0;
                                           Timer: 0;
                                           Pos: 0;
-                                          AmmoType: amSpider);
+                                          AmmoType: amCake);
                                    Slot: 4;
                                    TimeAfterTurn: 0;
                                    minAngle: 0;
--- a/hedgewars/uGears.pas	Fri Jul 25 10:56:05 2008 +0000
+++ b/hedgewars/uGears.pas	Fri Jul 25 13:52:35 2008 +0000
@@ -138,7 +138,7 @@
                                                                @doStepMortar,
                                                                @doStepWhip,
                                                                @doStepKamikaze,
-                                                               @doStepSpider
+                                                               @doStepCake
                                                                );
 
 procedure InsertGearToList(Gear: PGear);
@@ -313,6 +313,11 @@
                 Result^.Health:= 2048;
                 Result^.Radius:= 20
                 end;
+        gtCake: begin
+                Result^.Health:= 3072;
+                Result^.Radius:= 5;
+                if hwSign(dX) > 0 then Result^.Angle:= 1 else Result^.Angle:= 3
+                end;
      end;
 InsertGearToList(Result);
 AddGear:= Result
@@ -1029,6 +1034,7 @@
         gtSwitcher: DrawSprite(sprSwitch, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 56 + WorldDy, (GameTicks shr 6) mod 12);
           gtTarget: DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0);
           gtMortar: DrawRotated(sprMortar, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
+          gtCake: DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0);
               end;
       Gear:= Gear^.NextGear
       end;
--- a/hedgewars/uLocale.pas	Fri Jul 25 10:56:05 2008 +0000
+++ b/hedgewars/uLocale.pas	Fri Jul 25 13:52:35 2008 +0000
@@ -23,7 +23,7 @@
                    sidDynamite, sidBaseballBat, sidFirePunch, sidSeconds,
                    sidParachute, sidAirAttack, sidMineStrike, sidBlowTorch,
                    sidGirder, sidTeleport, sidSwitch, sidMortar, sidWhip,
-                   sidKamikaze, sidSpider);
+                   sidKamikaze, sidCake);
 
      TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused,
                   sidConfirm, sidSuddenDeath);
--- a/share/hedgewars/Data/Locale/bg.txt	Fri Jul 25 10:56:05 2008 +0000
+++ b/share/hedgewars/Data/Locale/bg.txt	Fri Jul 25 13:52:35 2008 +0000
@@ -24,7 +24,7 @@
 00:21=Миномет
 00:22=Бич
 00:23=Камикадзе
-00:24=Spider
+00:24=Cake
 
 01:00=Бой!
 01:01=Равен рунд
--- a/share/hedgewars/Data/Locale/de.txt	Fri Jul 25 10:56:05 2008 +0000
+++ b/share/hedgewars/Data/Locale/de.txt	Fri Jul 25 13:52:35 2008 +0000
@@ -24,7 +24,7 @@
 00:21=Mörser
 00:22=Stoßen
 00:23=Kamikaze
-00:24=Spider
+00:24=Cake
 
 01:00=Auf in die Schlacht!
 01:01=Unentschieden
--- a/share/hedgewars/Data/Locale/en.txt	Fri Jul 25 10:56:05 2008 +0000
+++ b/share/hedgewars/Data/Locale/en.txt	Fri Jul 25 13:52:35 2008 +0000
@@ -24,7 +24,7 @@
 00:21=Mortar
 00:22=Whip
 00:23=Kamikaze
-00:24=Spider
+00:24=Cake
 
 01:00=Let's fight!
 01:01=Round draw
--- a/share/hedgewars/Data/Locale/fr.txt	Fri Jul 25 10:56:05 2008 +0000
+++ b/share/hedgewars/Data/Locale/fr.txt	Fri Jul 25 13:52:35 2008 +0000
@@ -24,7 +24,7 @@
 00:21=Mortier
 00:22=Fouet
 00:23=Kamikaze
-00:24=Spider
+00:24=Cake
 
 01:00=C'est parti!
 01:01=Round ex aequo
--- a/share/hedgewars/Data/Locale/it.txt	Fri Jul 25 10:56:05 2008 +0000
+++ b/share/hedgewars/Data/Locale/it.txt	Fri Jul 25 13:52:35 2008 +0000
@@ -24,7 +24,7 @@
 00:21=Granata a grappolo
 00:22=Frusta
 00:23=Attacco Kamikaze
-00:24=Spider
+00:24=Cake
 
 01:00=Combattiamo!
 01:01=Round in parità
--- a/share/hedgewars/Data/Locale/pl.txt	Fri Jul 25 10:56:05 2008 +0000
+++ b/share/hedgewars/Data/Locale/pl.txt	Fri Jul 25 13:52:35 2008 +0000
@@ -24,7 +24,7 @@
 00:21=Moździerz
 00:22=Bicz
 00:23=Kamikaze
-00:24=Spider
+00:24=Cake
 
 01:00=Walczmy!
 01:01=Remis
--- a/share/hedgewars/Data/Locale/ru.txt	Fri Jul 25 10:56:05 2008 +0000
+++ b/share/hedgewars/Data/Locale/ru.txt	Fri Jul 25 13:52:35 2008 +0000
@@ -24,7 +24,7 @@
 00:21=Миномёт
 00:22=Кнут
 00:23=Камикадзе
-00:24=Паук
+00:24=Торт
 
 01:00=Вперёд к победе!
 01:01=Ничья
--- a/share/hedgewars/Data/Locale/sk.txt	Fri Jul 25 10:56:05 2008 +0000
+++ b/share/hedgewars/Data/Locale/sk.txt	Fri Jul 25 13:52:35 2008 +0000
@@ -24,7 +24,7 @@
 00:21=Mínomet
 00:22=Bič
 00:23=Kamikadze
-00:24=Spider
+00:24=Cake
 
 01:00=Do boja!
 01:01=Remíza