hedgewars/GSHandlers.inc
changeset 2602 3deb9ff104da
parent 2558 b1cb0f71b704
child 2603 abed6070a669
--- a/hedgewars/GSHandlers.inc	Thu Nov 05 20:40:31 2009 +0000
+++ b/hedgewars/GSHandlers.inc	Thu Nov 05 20:47:42 2009 +0000
@@ -16,6 +16,32 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  *)
 
+procedure makeHogsWorry(x, y: hwFloat; r: LongInt);
+var gi: PGear;
+     d: LongInt;
+begin
+	gi:= GearsList;
+	while gi <> nil do
+		begin
+		d:= r - hwRound(Distance(gi^.X - x, gi^.Y - y));
+		if (d > 1) and (gi^.Kind = gtHedgehog) and not gi^.Invulnerable then
+			begin
+			if (gi^.State and gstMoving) = 0 then
+				gi^.State:= gi^.State or gstLoser;
+			if (CurrentHedgehog^.Gear = gi) then
+				PlaySound(sndOops, false, PHedgehog(gi^.Hedgehog)^.Team^.voicepack)
+			else
+				begin
+				if d > r div 2 then
+					PlaySound(sndNooo, false, PHedgehog(gi^.Hedgehog)^.Team^.voicepack)
+				else
+					PlaySound(sndUhOh, false, PHedgehog(gi^.Hedgehog)^.Team^.voicepack);
+				end;
+			end;
+		gi:= gi^.NextGear
+		end;
+end;
+////////////////////////////////////////////////////////////////////////////////
 procedure doStepDrowningGear(Gear: PGear); forward;
 
 function CheckGearDrowning(Gear: PGear): boolean;
@@ -161,6 +187,13 @@
 doStepFallingGear(Gear);
 
 dec(Gear^.Timer);
+if Gear^.Timer = 1000 then // might need adjustments
+	case Gear^.Kind of
+		gtAmmo_Bomb: makeHogsWorry(Gear^.X, Gear^.Y, 50);
+		gtClusterBomb: makeHogsWorry(Gear^.X, Gear^.Y, 20);
+		gtWatermelon: makeHogsWorry(Gear^.X, Gear^.Y, 75);
+		gtHellishBomb: makeHogsWorry(Gear^.X, Gear^.Y, 90);
+	end;
 if Gear^.Timer = 0 then
 	begin
 	case Gear^.Kind of
@@ -251,7 +284,6 @@
 procedure doStepWatermelon(Gear: PGear);
 begin
 AllInactive:= false;
-PlaySound(sndMelon, false, nil);
 Gear^.doStep:= @doStepBomb
 end;
 
@@ -1159,6 +1191,8 @@
 doStepFallingGear(Gear);
 AllInactive:= false;
 if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag);
+if Gear^.Timer = 1000 then // might need better timing
+	makeHogsWorry(Gear^.X, Gear^.Y, 75);
 if Gear^.Timer = 0 then
 	begin
 	doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound);
@@ -1324,10 +1358,8 @@
 	if (hwRound(Gear^.Y) > cWaterLine) then
 		begin
 		for i:= 0 to 3 do
-			begin
 			AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 16 + Random(16), vgtSteam);
-			PlaySound(sndVaporize, false, nil);
-			end;
+		PlaySound(sndVaporize, false, nil);
 		DeleteGear(Gear);
 		exit
 		end
@@ -1530,7 +1562,6 @@
 
 Gear^.Health:= 6;
 Gear^.doStep:= @doStepAirAttackWork;
-PlaySound(sndIncoming, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack)
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -2423,6 +2454,7 @@
 	end
 end;
 
+////////////////////////////////////////////////////////////////////////////////
 procedure doStepJetpack(Gear: PGear);
 var HHGear: PGear;
 begin