Engine:
authorsmxx
Tue, 02 Mar 2010 17:22:36 +0000
changeset 2911 cd355befa683
parent 2910 d5051cc8a313
child 2912 76d43f7458ad
Engine: * Explosive crates: Use them as cover - but watch out, they may explode spreading fire everywhere! * Temporary hack for testing: Replaced all mines with explosive crates
hedgewars/GSHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
share/hedgewars/Data/Graphics/Explosives.png
--- a/hedgewars/GSHandlers.inc	Tue Mar 02 15:04:31 2010 +0000
+++ b/hedgewars/GSHandlers.inc	Tue Mar 02 17:22:36 2010 +0000
@@ -1242,7 +1242,11 @@
 procedure doStepCase(Gear: PGear);
 var i, x, y: LongInt;
 	k: TGearType;
+	exBoom: boolean;
+	dX, dY: HWFloat;
 begin
+exBoom:= false;
+
 if (Gear^.Message and gm_Destroy) > 0 then
 	begin
 	DeleteGear(Gear);
@@ -1253,7 +1257,17 @@
 	exit
 	end;
 
-if Gear^.Damage > 0 then
+if Gear^.Kind = gtExplosives then
+	begin
+	if ((Gear^.Health * 100 div cBarrelHealth) < random(90)) and ((GameTicks and $FF) = 0) then
+		AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmoke);
+	dec(Gear^.Health, Gear^.Damage);
+	Gear^.Damage:= 0;
+	if Gear^.Health <= 0 then
+		exBoom:= true;
+	end;
+
+if (Gear^.Damage > 0) or exBoom then
 	begin
 	x:= hwRound(Gear^.X);
 	y:= hwRound(Gear^.Y);
@@ -1265,6 +1279,17 @@
 		doMakeExplosion(x, y, 25, EXPLAutoSound);
 		for i:= 0 to 63 do
 			AddGear(x, y, gtFlame, 0, _0, _0, 0);
+		end
+	else if k = gtExplosives then
+		begin
+		doMakeExplosion(x, y, 25, EXPLAutoSound);
+		for i:= 0 to 31 do
+			begin
+			dX:= AngleCos(i * 64) * _0_5 * (getrandom + _1);
+			dY:= AngleSin(i * 64) * _0_5 * (getrandom + _1);
+			AddGear(x, y, gtFlame, 0, dX, dY, 0);
+			AddGear(x, y, gtFlame, 0, -dX, -dY, 0)^.State:= gsttmpFlag;
+			end
 		end;
 	exit
 	end;
--- a/hedgewars/uConsts.pas	Tue Mar 02 15:04:31 2010 +0000
+++ b/hedgewars/uConsts.pas	Tue Mar 02 17:22:36 2010 +0000
@@ -68,11 +68,11 @@
 			sprEvilTrace, sprHellishBomb, sprSeduction, sprDress,
 			sprCensored, sprDrill, sprHandDrill, sprHandBallgun, sprBalls,
 			sprPlane, sprHandPlane, sprUtility, sprInvulnerable, sprVampiric, sprGirder,
-            sprSpeechCorner, sprSpeechEdge, sprSpeechTail,
-            sprThoughtCorner, sprThoughtEdge, sprThoughtTail,
-            sprShoutCorner, sprShoutEdge, sprShoutTail,
-            sprSniperRifle, sprBubbles, sprJetpack, sprHealth, sprHandMolotov, sprMolotov,
-						sprSmoke, sprShell, sprDust);
+			sprSpeechCorner, sprSpeechEdge, sprSpeechTail,
+			sprThoughtCorner, sprThoughtEdge, sprThoughtTail,
+			sprShoutCorner, sprShoutEdge, sprShoutTail,
+			sprSniperRifle, sprBubbles, sprJetpack, sprHealth, sprHandMolotov, sprMolotov,
+			sprSmoke, sprShell, sprDust, sprExplosives);
 
 	TGearType = (gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag, // 3
 			gtGrave, gtUFO, gtShotgunShot, gtPickHammer, gtRope, // 8
@@ -83,7 +83,7 @@
 			gtTeleport, gtSwitcher, gtTarget, gtMortar, // 31
 			gtWhip, gtKamikaze, gtCake, gtSeduction, gtWatermelon, gtMelonPiece, // 37
 			gtHellishBomb, gtEvilTrace, gtWaterUp, gtDrill, gtBallGun, gtBall,gtRCPlane,
-			gtSniperRifleShot, gtJetpack, gtMolotov);
+			gtSniperRifleShot, gtJetpack, gtMolotov, gtExplosives);
 
 	TVisualGearType = (vgtFlake, vgtCloud, vgtExplPart, vgtExplPart2, vgtFire,
 			vgtSmallDamageTag, vgtTeamHealthSorter, vgtSpeechBubble, vgtBubble,
@@ -266,6 +266,7 @@
 	cCurrHHZ = Succ(cHHZ);
 	cOnHHZ = 2000;
 
+	cBarrelHealth = 75;
 	cShotgunRadius = 22;
 	cBlowTorchC    = 6;
 
@@ -309,6 +310,7 @@
 	gfPlaceHog       = $00008000;
 	gfSharedAmmo     = $00010000;
 	gfDisableGirders = $00020000;
+	gfExplosives     = $00040000;
 	// NOTE: When adding new game flags, ask yourself
 	// if a "game start notice" would be useful. If so,
 	// add one in uWorld.pas - look for "AddGoal".
@@ -671,7 +673,9 @@
 			(FileName: 'Shells'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
 			Width:  8; Height: 8; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprShell
 			(FileName: 'Dust'; Path: ptCurrTheme; AltPath: ptGraphics; Texture: nil; Surface: nil;
-			Width:  22; Height: 22; imageWidth: 0; imageHeight: 0; saveSurf: false)// sprDust
+			Width:  22; Height: 22; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprDust
+			(FileName: 'Explosives'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
+			Width:  48; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false) // sprExplosives
 			);
 
 	Wavez: array [TWave] of record
--- a/hedgewars/uGears.pas	Tue Mar 02 15:04:31 2010 +0000
+++ b/hedgewars/uGears.pas	Tue Mar 02 17:22:36 2010 +0000
@@ -177,7 +177,8 @@
 			@doStepRCPlane,
 			@doStepSniperRifleShot,
 			@doStepJetpack,
-			@doStepMolotov
+			@doStepMolotov,
+			@doStepCase
 			);
 
 procedure InsertGearToList(Gear: PGear);
@@ -325,6 +326,11 @@
                 gear^.Radius:= 16;
                 gear^.Elasticity:= _0_3
                 end;
+  gtExplosives: begin
+                gear^.Radius:= 16;
+                gear^.Elasticity:= _0_3;
+                gear^.Health:= cBarrelHealth
+                end;
   gtDEagleShot: begin
                 gear^.Radius:= 1;
                 gear^.Health:= 50
@@ -1576,6 +1582,11 @@
                                         DrawSprite(sprUtility, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i);
                                         end;
                          end;
+      gtExplosives: begin
+                    i:= (GameTicks shr 6) mod 64;
+                    if i > 18 then i:= 0;
+                    DrawSprite(sprExplosives, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i);
+                    end;
         gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1);
      gtClusterBomb: DrawRotated(sprClusterBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
          gtCluster: DrawSprite(sprClusterParticle, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, 0);
@@ -1633,23 +1644,34 @@
 begin
 AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000);
 
+// HACK: just for testing explosives!
+if (GameFlags and gfMines) <> 0 then
+	GameFlags:= (GameFlags or gfExplosives) and not gfMines;
+
 if (TrainingFlags and tfSpawnTargets) <> 0 then
 	begin
 	TrainingTargetGear:= AddGear(0, 0, gtTarget, 0, _0, _0, 0);
 	FindPlace(TrainingTargetGear, false, 0, LAND_WIDTH);
 	end;
 
-if ((GameFlags and gfForts) = 0) and ((GameFlags and gfMines) <> 0) then
-	for i:= 0 to Pred(cLandAdditions) do
-		begin
-		Gear:= AddGear(0, 0, gtMine, 0, _0, _0, 0);
-		Gear^.TriggerId:= i + 1;
-		FindPlace(Gear, false, 0, LAND_WIDTH);
-{		if(Gear <> nil) then
-			ParseCommand('addtrig s' + inttostr(Gear^.TriggerId) + ' 1 5 11 ' +
-				inttostr(hwRound(Gear^.X)) + ' ' + inttostr(hwRound(Gear^.Y)) +
-				' ' + inttostr(Gear^.TriggerId), true);
-}		end;
+if ((GameFlags and gfForts) = 0) then
+	begin
+	// TODO: exclude each other or allow both, mines and explosives, on same map?
+	if ((GameFlags and gfMines) <> 0) then
+		for i:= 0 to Pred(cLandAdditions) do
+			begin
+			Gear:= AddGear(0, 0, gtMine, 0, _0, _0, 0);
+			Gear^.TriggerId:= i + 1;
+			FindPlace(Gear, false, 0, LAND_WIDTH);
+			end;
+	if ((GameFlags and gfExplosives) <> 0) then
+		for i:= 0 to Pred(cLandAdditions) do
+			begin
+			Gear:= AddGear(0, 0, gtExplosives, 0, _0, _0, 0);
+			Gear^.TriggerId:= i + 1;
+			FindPlace(Gear, false, 0, LAND_WIDTH);
+			end;
+	end;
 
 if (GameFlags and gfLowGravity) <> 0 then
     cGravity:= cMaxWindSpeed / 2;
@@ -1699,7 +1721,8 @@
 				gtMine,
 				gtCase,
 				gtTarget,
-				gtFlame: begin
+				gtFlame,
+				gtExplosives: begin
 						//{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF}
 						if (Mask and EXPLNoDamage) = 0 then
 							begin
@@ -1749,7 +1772,8 @@
 		gtHedgehog,
 			gtMine,
 			gtCase,
-			gtTarget: begin
+			gtTarget,
+			gtExplosives: begin
                     if (not t^.Invulnerable) then
                         ApplyDamage(t, dmg)
                     else
@@ -1794,7 +1818,8 @@
 			gtHedgehog,
 			gtMine,
 			gtTarget,
-			gtCase: begin
+			gtCase,
+			gtExplosives: begin
 					if (Ammo^.Kind = gtDrill) then begin Ammo^.Timer:= 0; exit; end;
                     if (not Gear^.Invulnerable) then
                         ApplyDamage(Gear, tmpDmg)
@@ -2097,7 +2122,7 @@
 
 			if (y - sy > Gear^.Radius * 2)
 				and (y < LAND_HEIGHT)
-				and (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase], 110, 110) = nil) then
+				and (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 110, 110) = nil) then
 				begin
 				ar[cnt].X:= x;
 				if withFall then ar[cnt].Y:= sy + Gear^.Radius
Binary file share/hedgewars/Data/Graphics/Explosives.png has changed