White/Black smoke, break out rolling barrel into its own routine, adjust rolling barrel impact damage. NEEDS TESTING
authornemo
Fri, 05 Mar 2010 17:32:13 +0000
changeset 2941 566f967ec22f
parent 2940 c02119eee12a
child 2942 eaccabb4059b
White/Black smoke, break out rolling barrel into its own routine, adjust rolling barrel impact damage. NEEDS TESTING
hedgewars/GSHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
hedgewars/uVisualGears.pas
share/hedgewars/Data/Graphics/SmokeWhite.png
--- a/hedgewars/GSHandlers.inc	Fri Mar 05 15:54:23 2010 +0000
+++ b/hedgewars/GSHandlers.inc	Fri Mar 05 17:32:13 2010 +0000
@@ -1239,15 +1239,62 @@
 end;
 
 ///////////////////////////////////////////////////////////////////////////////
+
+(*
+TODO
+Increase damage as barrel smokes?
+Try tweaking friction some more
+*)
+procedure doStepRollingBarrel(Gear: PGear);
+var i: LongInt;
+	particle: PVisualGear;
+begin
+Gear^.State:= Gear^.State or gstAnimation;
+if ((Gear^.dX.QWordValue <> 0) or (Gear^.dY.QWordValue <> 0))  then
+    begin
+    DeleteCI(Gear);
+    AllInactive:= false;
+    if Gear^.dY.isNegative and (Gear^.dY < -_0_02) and TestCollisionYwithGear(Gear, -1) then
+        inc(Gear^.Damage, hwRound(Gear^.dY * _70) * -1);
+    if not Gear^.dY.isNegative and (Gear^.dY > _0_02) and TestCollisionYwithGear(Gear, 1) then
+        begin
+        inc(Gear^.Damage, hwRound(Gear^.dY * _70));
+	    for i:= min(12, hwRound(Gear^.dY*_10)) downto 0 do 
+            begin
+		    particle:= AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust);
+            if particle <> nil then particle^.dX := particle^.dX + (Gear^.dX / 5)
+            end
+        end;
+    if Gear^.dX.isNegative and (Gear^.dX < -_0_02) and TestCollisionXwithGear(Gear, -1) then
+        inc(Gear^.Damage, hwRound(Gear^.dX * _70)*-1);
+    if not Gear^.dX.isNegative and (Gear^.dX > _0_02) and TestCollisionYwithGear(Gear, 1) then
+        inc(Gear^.Damage, hwRound(Gear^.dX * _70));
+    if Gear^.Damage <> 0 then PlaySound(sndGraveImpact);
+    doStepFallingGear(Gear);
+    CalcRotationDirAngle(Gear);
+	CheckGearDrowning(Gear)
+    end
+else AddGearCI(Gear);
+    
+if ((Gear^.Health * 100 div cBarrelHealth) < random(90)) and ((GameTicks and $FF) = 0) then
+    if (cBarrelHealth div Gear^.Health) > 2 then 
+        AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmoke)
+    else
+        AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmokeWhite);
+dec(Gear^.Health, Gear^.Damage);
+Gear^.Damage:= 0;
+if Gear^.Health <= 0 then Gear^.doStep:= @doStepCase; // Hand off to doStepCase for the explosion
+
+end;
+
 procedure doStepCase(Gear: PGear);
 var i, x, y: LongInt;
 	k: TGearType;
 	exBoom: boolean;
-	dX, dY, V: HWFloat;
+	dX, dY: HWFloat;
 begin
 k:= Gear^.Kind;
 exBoom:= false;
-V:= _0;
 
 if (Gear^.Message and gm_Destroy) > 0 then
 	begin
@@ -1261,24 +1308,19 @@
 
 if k = gtExplosives then
 	begin
-    V:= hwSqr(Gear^.dX) + hwSqr(Gear^.dY);
     //if V > _0_03 then Gear^.State:= Gear^.State or gstAnimation;
-    if hwAbs(Gear^.dX) > _0_15 then Gear^.State:= Gear^.State or gstAnimation;
-    if ((Gear^.State and gstAnimation) <> 0) and ((Gear^.dX.QWordValue <> 0) or (Gear^.dY.QWordValue <> 0))  then
-        begin
-        AllInactive:= false;
-        doStepFallingGear(Gear);
-        CalcRotationDirAngle(Gear)
-        end;
+    if hwAbs(Gear^.dX) > _0_15 then Gear^.doStep:= @doStepRollingBarrel;
     
-	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);
+    if ((Gear^.Health * 100 div cBarrelHealth) < random(90)) and ((GameTicks and $FF) = 0) then
+        if (cBarrelHealth div Gear^.Health) > 2 then 
+            AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmoke)
+        else
+            AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmokeWhite);
 	dec(Gear^.Health, Gear^.Damage);
 	Gear^.Damage:= 0;
 	if Gear^.Health <= 0 then
 		exBoom:= true;
 	end;
-if ((Gear^.State and gstAnimation) = 0) or (hwAbs(Gear^.dX) < _0_001) then Gear^.dX:= _0;
 
 if (Gear^.Damage > 0) or exBoom then
 	begin
@@ -1309,17 +1351,14 @@
 if (Gear^.dY.QWordValue <> 0) or (not TestCollisionYwithGear(Gear, 1)) then
 	begin
 	AllInactive:= false;
-    if not ((k = gtExplosives) and ((Gear^.State and gstAnimation) <> 0)) then
-        begin
-        Gear^.dY:= Gear^.dY + cGravity;
-        Gear^.Y:= Gear^.Y + Gear^.dY;
-	    if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0
-        end;
+    Gear^.dY:= Gear^.dY + cGravity;
+    Gear^.Y:= Gear^.Y + Gear^.dY;
     if (not Gear^.dY.isNegative) and (Gear^.dY > _0_001) then SetAllHHToActive;
+	if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0;
 	if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then
 		begin
-        if (V > _0_02) and (k = gtExplosives) then
-            inc(Gear^.Damage, hwRound(V * _70));
+        if (Gear^.dY > _0_02) and (k = gtExplosives) then
+            inc(Gear^.Damage, hwRound(Gear^.dY * _70));
 
 		if Gear^.dY > _0_2 then
 	        for i:= min(12, hwRound(Gear^.dY*_10)) downto 0 do 
@@ -1332,8 +1371,8 @@
 	CheckGearDrowning(Gear);
 	end;
 
-if (Gear^.dX.QWordValue = 0) and (Gear^.dY.QWordValue = 0) then AddGearCI(Gear)
-	else DeleteCI(Gear)
+if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear)
+       else if (Gear^.dY.QWordValue <> 0) then DeleteCI(Gear)
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
--- a/hedgewars/uConsts.pas	Fri Mar 05 15:54:23 2010 +0000
+++ b/hedgewars/uConsts.pas	Fri Mar 05 17:32:13 2010 +0000
@@ -72,7 +72,7 @@
 			sprThoughtCorner, sprThoughtEdge, sprThoughtTail,
 			sprShoutCorner, sprShoutEdge, sprShoutTail,
 			sprSniperRifle, sprBubbles, sprJetpack, sprHealth, sprHandMolotov, sprMolotov,
-			sprSmoke, sprShell, sprDust, sprExplosives, sprExplosivesRoll, sprAmTeleport);
+			sprSmoke, sprSmokeWhite, sprShell, sprDust, sprExplosives, sprExplosivesRoll, sprAmTeleport);
 
 	TGearType = (gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag, // 3
 			gtGrave, gtUFO, gtShotgunShot, gtPickHammer, gtRope, // 8
@@ -87,7 +87,7 @@
 
 	TVisualGearType = (vgtFlake, vgtCloud, vgtExplPart, vgtExplPart2, vgtFire,
 			vgtSmallDamageTag, vgtTeamHealthSorter, vgtSpeechBubble, vgtBubble,
-			vgtSteam, vgtSmoke, vgtHealth, vgtShell, vgtDust);
+			vgtSteam, vgtSmoke, vgtSmokeWhite, vgtHealth, vgtShell, vgtDust);
 
 	TGearsType = set of TGearType;
 
@@ -670,6 +670,8 @@
 			Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprMolotov
 			(FileName: 'Smoke'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
 			Width:  22; Height: 22; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSmoke
+			(FileName: 'SmokeWhite'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
+			Width:  22; Height: 22; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSmokeWhite
 			(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;
--- a/hedgewars/uGears.pas	Fri Mar 05 15:54:23 2010 +0000
+++ b/hedgewars/uGears.pas	Fri Mar 05 17:32:13 2010 +0000
@@ -126,6 +126,7 @@
 procedure ShotgunShot(Gear: PGear); forward;
 procedure PickUp(HH, Gear: PGear); forward;
 procedure HHSetWeapon(Gear: PGear); forward;
+procedure doStepCase(Gear: PGear); forward;
 
 
 {$INCLUDE "GSHandlers.inc"}
--- a/hedgewars/uVisualGears.pas	Fri Mar 05 15:54:23 2010 +0000
+++ b/hedgewars/uVisualGears.pas	Fri Mar 05 17:32:13 2010 +0000
@@ -386,6 +386,7 @@
 			@doStepBubble,
 			@doStepSteam,
 			@doStepSmoke,
+			@doStepSmoke,
 			@doStepHealth,
 			@doStepShell,
 			@doStepDust
@@ -480,6 +481,7 @@
 				Frame:= 7 - random(3);
 				FrameTicks:= cExplFrameTicks * 2;
 				end;
+  vgtSmokeWhite, 
   vgtSmoke: begin
 				dx:= _0_0002 * (random(45) + 10);
 				dx.isNegative:= random(2) = 0;
@@ -561,6 +563,7 @@
 			if not cReducedQuality then
 				case Gear^.Kind of
 					vgtSmoke: DrawSprite(sprSmoke, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
+					vgtSmokeWhite: DrawSprite(sprSmokeWhite, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
 					vgtDust: DrawSprite(sprDust, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
 				end;
 		Gear:= Gear^.NextGear
Binary file share/hedgewars/Data/Graphics/SmokeWhite.png has changed