Kamikaze weapon
authorunc0rr
Mon, 09 Jun 2008 20:34:45 +0000
changeset 984 dd5f16f69926
parent 983 d21ad13cd17d
child 985 345e22f92757
Kamikaze weapon
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uChat.pas
hedgewars/uConsts.pas
hedgewars/uGears.pas
--- a/hedgewars/GSHandlers.inc	Mon Jun 09 15:26:52 2008 +0000
+++ b/hedgewars/GSHandlers.inc	Mon Jun 09 20:34:45 2008 +0000
@@ -1383,3 +1383,79 @@
 if (GameTicks and $3F) = 0 then
 	AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0)
 end;
+
+////////////////////////////////////////////////////////////////////////////////
+procedure doStepKamikazeWork(Gear: PGear);
+const upd: Longword = 0;
+var i, x, y: LongWord;
+    oX, oY: hwFloat;
+    HHGear: PGear;
+begin
+AllInactive:= false;
+
+HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
+HHGear^.State:= HHGear^.State or gstNoDamage;
+DeleteCI(HHGear);
+
+i:= 2;
+oX:= Gear^.X;
+oY:= Gear^.Y;
+repeat
+	Gear^.X:= Gear^.X + HHGear^.dX;
+	Gear^.Y:= Gear^.Y + HHGear^.dY;
+	HHGear^.X:= Gear^.X;
+	HHGear^.Y:= Gear^.Y;
+
+	inc(Gear^.Damage, 2);
+
+	if TestCollisionXwithGear(HHGear, hwSign(Gear^.dX))
+		or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY)) then inc(Gear^.Damage, 3);
+
+	dec(i)
+until (i = 0) or (Gear^.Damage > Gear^.Health);
+addfilelog(inttostr(Gear^.Damage));
+
+inc(upd);
+if upd > 3 then
+	begin
+	AmmoShove(Gear, 30, 40);
+	
+	DrawTunnel(HHGear^.X - HHGear^.dX * 10,
+			HHGear^.Y - _3 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 5,
+			HHGear^.dX,
+			HHGear^.dY,
+			20 + cHHRadius * 2,
+			cHHRadius * 2 + 4);
+	
+	upd:= 0
+	end;
+
+if Gear^.Health < Gear^.Damage then
+	begin
+	doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound);
+	AfterAttack;
+	DeleteGear(Gear);
+	DeleteGear(HHGear);
+	end else
+	begin
+	dec(Gear^.Health, Gear^.Damage);
+	Gear^.Damage:= 0
+	end
+end;
+
+procedure doStepKamikaze(Gear: PGear);
+var HHGear: PGear;
+begin
+AllInactive:= false;
+
+HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
+
+HHGear^.dX:= Gear^.dX;
+HHGear^.dY:= Gear^.dY;
+
+Gear^.dX:= SignAs(_0_45, Gear^.dX);
+Gear^.dY:= - _0_9;
+
+Gear^.doStep:= @doStepKamikazeWork
+end;
+
--- a/hedgewars/HHHandlers.inc	Mon Jun 09 15:26:52 2008 +0000
+++ b/hedgewars/HHHandlers.inc	Mon Jun 09 20:34:45 2008 +0000
@@ -158,6 +158,7 @@
                      amTeleport: CurAmmoGear:= AddGear(0, 0, gtTeleport, 0, _0, _0, 0);
                        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);
                   end;
 
         uStats.AmmoUsed(Ammo^[CurSlot, CurAmmo].AmmoType);
--- a/hedgewars/uChat.pas	Mon Jun 09 15:26:52 2008 +0000
+++ b/hedgewars/uChat.pas	Mon Jun 09 20:34:45 2008 +0000
@@ -71,7 +71,7 @@
 SDL_FreeSurface(strSurface);
 
 cl.s:= str;
-cl.Time:= RealTicks + 7500;
+cl.Time:= RealTicks + 12500;
 cl.Tex:= Surface2Tex(resSurface);
 SDL_FreeSurface(resSurface)
 end;
--- a/hedgewars/uConsts.pas	Mon Jun 09 15:26:52 2008 +0000
+++ b/hedgewars/uConsts.pas	Mon Jun 09 20:34:45 2008 +0000
@@ -54,7 +54,7 @@
                    gtFirePunch, gtATStartGame, gtATSmoothWindCh, gtATFinishGame,
                    gtParachute, gtAirAttack, gtAirBomb, gtBlowTorch, gtGirder,
                    gtTeleport, gtSmallDamage, gtSwitcher, gtTarget, gtMortar,
-                   gtWhip);
+                   gtWhip, gtKamikaze);
 
      TVisualGearType = (vgtFlake, vgtCloud);
 
@@ -890,7 +890,8 @@
                                    NameTex: nil;
                                    Probability: 100;
                                    NumberInCase: 1;
-                                   Ammo: (Propz: 0;
+                                   Ammo: (Propz: ammoprop_ForwMsgs or
+                                                 ammoprop_DontHold;
                                           Count: 1;
                                           NumPerTurn: 0;
                                           Timer: 0;
--- a/hedgewars/uGears.pas	Mon Jun 09 15:26:52 2008 +0000
+++ b/hedgewars/uGears.pas	Mon Jun 09 20:34:45 2008 +0000
@@ -136,7 +136,8 @@
                                                                @doStepSwitcher,
                                                                @doStepCase,
                                                                @doStepMortar,
-                                                               @doStepWhip
+                                                               @doStepWhip,
+                                                               @doStepKamikaze
                                                                );
 
 procedure InsertGearToList(Gear: PGear);
@@ -306,6 +307,10 @@
                 Result^.Friction:= _0_08
                 end;
         gtWhip: Result^.Radius:= 20;
+    gtKamikaze: begin
+                Result^.Health:= 2048;
+                Result^.Radius:= 20
+                end;
      end;
 InsertGearToList(Result);
 AddGear:= Result