hedgewars/GSHandlers.inc
changeset 2376 ece7b87f1334
parent 2367 86c9aadea817
child 2424 b52344de23ae
equal deleted inserted replaced
2375:99f05a01a6a3 2376:ece7b87f1334
    98 Gear^.Y:= Gear^.Y + cDrownSpeed;
    98 Gear^.Y:= Gear^.Y + cDrownSpeed;
    99 Gear^.X:= Gear^.X + Gear^.dX * cDrownSpeed;
    99 Gear^.X:= Gear^.X + Gear^.dX * cDrownSpeed;
   100 if hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater then DeleteGear(Gear);
   100 if hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater then DeleteGear(Gear);
   101 // Create some bubbles (0.5% might be better but causes too few bubbles sometimes)
   101 // Create some bubbles (0.5% might be better but causes too few bubbles sometimes)
   102 if (GameTicks and $1F) = 0 then
   102 if (GameTicks and $1F) = 0 then
   103     if (Gear^.Kind = gtHedgehog) and (Random(4) = 0) then 
   103     if (Gear^.Kind = gtHedgehog) and (Random(4) = 0) then
   104         AddVisualGear(hwRound(Gear^.X) - Gear^.Radius, hwRound(Gear^.Y) - Gear^.Radius, vgtBubble)
   104         AddVisualGear(hwRound(Gear^.X) - Gear^.Radius, hwRound(Gear^.Y) - Gear^.Radius, vgtBubble)
   105     else if Random(12) = 0 then
   105     else if Random(12) = 0 then
   106         AddVisualGear(hwRound(Gear^.X) - Gear^.Radius, hwRound(Gear^.Y) - Gear^.Radius, vgtBubble)
   106         AddVisualGear(hwRound(Gear^.X) - Gear^.Radius, hwRound(Gear^.Y) - Gear^.Radius, vgtBubble)
   107 end;
   107 end;
   108 
   108 
   494     PlaySound(sndGun, false, nil);
   494     PlaySound(sndGun, false, nil);
   495     Gear^.doStep:= @doStepBulletWork;
   495     Gear^.doStep:= @doStepBulletWork;
   496     end
   496     end
   497 else
   497 else
   498     if (GameTicks mod 32) = 0 then
   498     if (GameTicks mod 32) = 0 then
   499         if (GameTicks mod 4096) < 2048 then 
   499         if (GameTicks mod 4096) < 2048 then
   500             begin
   500             begin
   501             if(HHGear^.Angle + 1 <= cMaxAngle) then inc(HHGear^.Angle)
   501             if(HHGear^.Angle + 1 <= cMaxAngle) then inc(HHGear^.Angle)
   502             end
   502             end
   503         else
   503         else
   504             if(HHGear^.Angle - 1 >= 0) then dec(HHGear^.Angle);
   504             if(HHGear^.Angle - 1 >= 0) then dec(HHGear^.Angle);
   505 
   505 
   506 if (TurnTimeLeft > 0) then 
   506 if (TurnTimeLeft > 0) then
   507     dec(TurnTimeLeft)
   507     dec(TurnTimeLeft)
   508 else
   508 else
   509     begin
   509     begin
   510     PHedgehog(Gear^.Hedgehog)^.AttacksNum:= Gear^.Ammo^.NumPerTurn+1;
   510     PHedgehog(Gear^.Hedgehog)^.AttacksNum:= Gear^.Ammo^.NumPerTurn+1;
   511 	DeleteGear(Gear);
   511 	DeleteGear(Gear);
   675 
   675 
   676 	if ((HHGear^.State and gstMoving) = 0) then
   676 	if ((HHGear^.State and gstMoving) = 0) then
   677 		begin
   677 		begin
   678 		HHGear^.State:= HHGear^.State and not gstAttacking;
   678 		HHGear^.State:= HHGear^.State and not gstAttacking;
   679 		prevX:= hwRound(HHGear^.X);
   679 		prevX:= hwRound(HHGear^.X);
   680 	
   680 
   681 // why the call to HedgehogStep then a further increment of X?	
   681 // why the call to HedgehogStep then a further increment of X?
   682         if (prevX = hwRound(HHGear^.X)) and 
   682         if (prevX = hwRound(HHGear^.X)) and
   683            CheckLandValue(hwRound(HHGear^.X + SignAs(_6, HHGear^.dX)), hwRound(HHGear^.Y), COLOR_INDESTRUCTIBLE) then HedgehogStep(HHGear);
   683            CheckLandValue(hwRound(HHGear^.X + SignAs(_6, HHGear^.dX)), hwRound(HHGear^.Y), COLOR_INDESTRUCTIBLE) then HedgehogStep(HHGear);
   684 		
   684 
   685         if (prevX = hwRound(HHGear^.X)) and 
   685         if (prevX = hwRound(HHGear^.X)) and
   686            CheckLandValue(hwRound(HHGear^.X + SignAs(_6, HHGear^.dX)), hwRound(HHGear^.Y), COLOR_INDESTRUCTIBLE) then HHGear^.X:= HHGear^.X + SignAs(_1, HHGear^.dX);
   686            CheckLandValue(hwRound(HHGear^.X + SignAs(_6, HHGear^.dX)), hwRound(HHGear^.Y), COLOR_INDESTRUCTIBLE) then HHGear^.X:= HHGear^.X + SignAs(_1, HHGear^.dX);
   687 		HHGear^.State:= HHGear^.State or gstAttacking
   687 		HHGear^.State:= HHGear^.State or gstAttacking
   688 		end;
   688 		end;
   689 
   689 
   690 	inc(BTSteps);
   690 	inc(BTSteps);
   757 	begin
   757 	begin
   758 	Gear^.X:= HHGear^.X;
   758 	Gear^.X:= HHGear^.X;
   759 	Gear^.Y:= HHGear^.Y;
   759 	Gear^.Y:= HHGear^.Y;
   760 
   760 
   761 	ApplyAngleBounds(PHedgehog(Gear^.Hedgehog)^, amRope);
   761 	ApplyAngleBounds(PHedgehog(Gear^.Hedgehog)^, amRope);
   762 	
   762 
   763 	Gear^.dX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX);
   763 	Gear^.dX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX);
   764 	Gear^.dY:= -AngleCos(HHGear^.Angle);
   764 	Gear^.dY:= -AngleCos(HHGear^.Angle);
   765 	Gear^.Friction:= _450;
   765 	Gear^.Friction:= _450;
   766 	Gear^.Elasticity:= _0;
   766 	Gear^.Elasticity:= _0;
   767 	Gear^.State:= Gear^.State and not gsttmpflag;
   767 	Gear^.State:= Gear^.State and not gsttmpflag;
   850 	haveDivided:= false;
   850 	haveDivided:= false;
   851 	// check whether rope needs dividing
   851 	// check whether rope needs dividing
   852 	len:= _1 / Distance(ropeDx, ropeDy); // old rope pos
   852 	len:= _1 / Distance(ropeDx, ropeDy); // old rope pos
   853 	nx:= ropeDx * len;
   853 	nx:= ropeDx * len;
   854 	ny:= ropeDy * len;
   854 	ny:= ropeDy * len;
   855 	
   855 
   856 	len:= Gear^.Elasticity - _0_3x70;
   856 	len:= Gear^.Elasticity - _0_3x70;
   857 	while len > _3 do
   857 	while len > _3 do
   858 			begin
   858 			begin
   859 			lx:= hwRound(Gear^.X + mdX * len);
   859 			lx:= hwRound(Gear^.X + mdX * len);
   860 			ly:= hwRound(Gear^.Y + mdY * len);
   860 			ly:= hwRound(Gear^.Y + mdY * len);
   871 				with RopePoints.rounded[RopePoints.Count] do
   871 				with RopePoints.rounded[RopePoints.Count] do
   872 					begin
   872 					begin
   873 					X:= hwRound(Gear^.X);
   873 					X:= hwRound(Gear^.X);
   874 					Y:= hwRound(Gear^.Y);
   874 					Y:= hwRound(Gear^.Y);
   875 					end;
   875 					end;
   876 				
   876 
   877 				Gear^.X:= Gear^.X + nx * len;
   877 				Gear^.X:= Gear^.X + nx * len;
   878 				Gear^.Y:= Gear^.Y + ny * len;
   878 				Gear^.Y:= Gear^.Y + ny * len;
   879 				inc(RopePoints.Count);
   879 				inc(RopePoints.Count);
   880 				TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true);
   880 				TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true);
   881 				Gear^.Elasticity:= Gear^.Elasticity - len;
   881 				Gear^.Elasticity:= Gear^.Elasticity - len;
   953 		OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^);
   953 		OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^);
   954 		Gear^.State:= Gear^.State or gstAttacked
   954 		Gear^.State:= Gear^.State or gstAttacked
   955 		end;
   955 		end;
   956 	ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^)
   956 	ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^)
   957 	end;
   957 	end;
   958 	
   958 
   959 begin
   959 begin
   960 Gear^.X:= Gear^.X - Gear^.dX;
   960 Gear^.X:= Gear^.X - Gear^.dX;
   961 Gear^.Y:= Gear^.Y - Gear^.dY;
   961 Gear^.Y:= Gear^.Y - Gear^.dY;
   962 Gear^.Elasticity:= Gear^.Elasticity + _1;
   962 Gear^.Elasticity:= Gear^.Elasticity + _1;
   963 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
   963 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
   964 DeleteCI(HHGear);
   964 DeleteCI(HHGear);
   965 if (HHGear^.State and gstMoving) <> 0 then
   965 if (HHGear^.State and gstMoving) <> 0 then
   966 	begin
   966 	begin
   967 	if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX);
   967 	if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX);
   968 	if HHGear^.dY.isNegative and TestCollisionYwithGear(HHGear, -1) then HHGear^.dY:= _0;
   968 	if HHGear^.dY.isNegative and TestCollisionYwithGear(HHGear, -1) then HHGear^.dY:= _0;
   969 	
   969 
   970 	HHGear^.X:= HHGear^.X + HHGear^.dX;
   970 	HHGear^.X:= HHGear^.X + HHGear^.dX;
   971 	Gear^.X:= Gear^.X + HHGear^.dX;
   971 	Gear^.X:= Gear^.X + HHGear^.dX;
   972 
   972 
   973 	if TestCollisionYwithGear(HHGear, 1) then
   973 	if TestCollisionYwithGear(HHGear, 1) then
   974 		begin
   974 		begin
   991 				Gear^.X:= Gear^.X + tx;
   991 				Gear^.X:= Gear^.X + tx;
   992 				Gear^.Y:= Gear^.Y + ty;
   992 				Gear^.Y:= Gear^.Y + ty;
   993 				Gear^.Elasticity:= tt;
   993 				Gear^.Elasticity:= tt;
   994 				Gear^.doStep:= @doStepRopeWork;
   994 				Gear^.doStep:= @doStepRopeWork;
   995 				with HHGear^ do State:= State and not (gstAttacking or gstHHJumping or gstHHHJump);
   995 				with HHGear^ do State:= State and not (gstAttacking or gstHHJumping or gstHHHJump);
   996 				
   996 
   997 				RemoveFromAmmo;
   997 				RemoveFromAmmo;
   998 				
   998 
   999 				tt:= _0;
   999 				tt:= _0;
  1000 				exit
  1000 				exit
  1001 				end;
  1001 				end;
  1002 			tx:= tx + Gear^.dX + Gear^.dX;
  1002 			tx:= tx + Gear^.dX + Gear^.dX;
  1003 			ty:= ty + Gear^.dY + Gear^.dY;
  1003 			ty:= ty + Gear^.dY + Gear^.dY;
  1015 		begin
  1015 		begin
  1016 		Gear^.doStep:= @doStepRopeWork;
  1016 		Gear^.doStep:= @doStepRopeWork;
  1017 		with HHGear^ do State:= State and not (gstAttacking or gstHHJumping or gstHHHJump);
  1017 		with HHGear^ do State:= State and not (gstAttacking or gstHHJumping or gstHHHJump);
  1018 
  1018 
  1019 		RemoveFromAmmo;
  1019 		RemoveFromAmmo;
  1020 		
  1020 
  1021 		exit
  1021 		exit
  1022 		end;
  1022 		end;
  1023 
  1023 
  1024 if (Gear^.Elasticity > Gear^.Friction)
  1024 if (Gear^.Elasticity > Gear^.Friction)
  1025 or ((Gear^.Message and gm_Attack) = 0)
  1025 or ((Gear^.Message and gm_Attack) = 0)
  1150 	begin
  1150 	begin
  1151 	x:= hwRound(Gear^.X);
  1151 	x:= hwRound(Gear^.X);
  1152 	y:= hwRound(Gear^.Y);
  1152 	y:= hwRound(Gear^.Y);
  1153 	k:= Gear^.Kind;
  1153 	k:= Gear^.Kind;
  1154 	DeleteGear(Gear); // <-- delete gear!
  1154 	DeleteGear(Gear); // <-- delete gear!
  1155 	
  1155 
  1156 	if k = gtCase then
  1156 	if k = gtCase then
  1157 		begin
  1157 		begin
  1158 		doMakeExplosion(x, y, 25, EXPLAutoSound);
  1158 		doMakeExplosion(x, y, 25, EXPLAutoSound);
  1159 		for i:= 0 to 63 do
  1159 		for i:= 0 to 63 do
  1160 			AddGear(x, y, gtFlame, 0, _0, _0, 0);
  1160 			AddGear(x, y, gtFlame, 0, _0, _0, 0);
  1238 	if hwAbs(Gear^.dX) > _0_01 then
  1238 	if hwAbs(Gear^.dX) > _0_01 then
  1239 		Gear^.dX:= Gear^.dX * _0_995;
  1239 		Gear^.dX:= Gear^.dX * _0_995;
  1240 
  1240 
  1241 	Gear^.dY:= Gear^.dY + cGravity;
  1241 	Gear^.dY:= Gear^.dY + cGravity;
  1242 	if hwAbs(Gear^.dY) > _0_2 then Gear^.dY:= Gear^.dY * _0_995;
  1242 	if hwAbs(Gear^.dY) > _0_2 then Gear^.dY:= Gear^.dY * _0_995;
  1243 	
  1243 
  1244 	Gear^.X:= Gear^.X + Gear^.dX + cWindSpeed * 640;
  1244 	Gear^.X:= Gear^.X + Gear^.dX + cWindSpeed * 640;
  1245 	Gear^.Y:= Gear^.Y + Gear^.dY;
  1245 	Gear^.Y:= Gear^.Y + Gear^.dY;
  1246 	
  1246 
  1247 	if (hwRound(Gear^.Y) > cWaterLine) then
  1247 	if (hwRound(Gear^.Y) > cWaterLine) then
  1248 		begin
  1248 		begin
  1249 		for i:= 0 to 3 do
  1249 		for i:= 0 to 3 do
  1250 			begin
  1250 			begin
  1251 			AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 16 + Random(16), vgtSteam);
  1251 			AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 16 + Random(16), vgtSteam);
  1303 	DeleteGear(Gear);
  1303 	DeleteGear(Gear);
  1304 	AfterAttack;
  1304 	AfterAttack;
  1305 	exit
  1305 	exit
  1306 	end;
  1306 	end;
  1307 
  1307 
  1308 if CheckLandValue(hwRound(HHGear^.X), hwRound(HHGear^.Y + HHGear^.dY + SignAs(_6,Gear^.dY)), COLOR_INDESTRUCTIBLE) then 
  1308 if CheckLandValue(hwRound(HHGear^.X), hwRound(HHGear^.Y + HHGear^.dY + SignAs(_6,Gear^.dY)), COLOR_INDESTRUCTIBLE) then
  1309    HHGear^.Y:= HHGear^.Y + HHGear^.dY
  1309    HHGear^.Y:= HHGear^.Y + HHGear^.dY
  1310 end;
  1310 end;
  1311 
  1311 
  1312 procedure doStepFirePunch(Gear: PGear);
  1312 procedure doStepFirePunch(Gear: PGear);
  1313 var HHGear: PGear;
  1313 var HHGear: PGear;
  1637 		begin
  1637 		begin
  1638 		dX:= Gear^.dX + (GetRandom - _0_5) * _0_03;
  1638 		dX:= Gear^.dX + (GetRandom - _0_5) * _0_03;
  1639 		dY:= Gear^.dY + (GetRandom - _0_5) * _0_03;
  1639 		dY:= Gear^.dY + (GetRandom - _0_5) * _0_03;
  1640 		AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25);
  1640 		AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25);
  1641 		end;
  1641 		end;
  1642 	
  1642 
  1643 	DeleteGear(Gear);
  1643 	DeleteGear(Gear);
  1644 	exit
  1644 	exit
  1645 	end;
  1645 	end;
  1646 
  1646 
  1647 if (GameTicks and $3F) = 0 then
  1647 if (GameTicks and $3F) = 0 then
  1677 
  1677 
  1678 inc(upd);
  1678 inc(upd);
  1679 if upd > 3 then
  1679 if upd > 3 then
  1680 	begin
  1680 	begin
  1681 	if Gear^.Health < 1500 then Gear^.Pos:= 2;
  1681 	if Gear^.Health < 1500 then Gear^.Pos:= 2;
  1682 	
  1682 
  1683 	AmmoShove(Gear, 30, 40);
  1683 	AmmoShove(Gear, 30, 40);
  1684 	
  1684 
  1685 	DrawTunnel(HHGear^.X - HHGear^.dX * 10,
  1685 	DrawTunnel(HHGear^.X - HHGear^.dX * 10,
  1686 			HHGear^.Y - _2 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 2,
  1686 			HHGear^.Y - _2 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 2,
  1687 			HHGear^.dX,
  1687 			HHGear^.dX,
  1688 			HHGear^.dY,
  1688 			HHGear^.dY,
  1689 			20 + cHHRadius * 2,
  1689 			20 + cHHRadius * 2,
  1690 			cHHRadius * 2 + 6);
  1690 			cHHRadius * 2 + 6);
  1691 	
  1691 
  1692 	upd:= 0
  1692 	upd:= 0
  1693 	end;
  1693 	end;
  1694 
  1694 
  1695 if Gear^.Health < Gear^.Damage then
  1695 if Gear^.Health < Gear^.Damage then
  1696 	begin
  1696 	begin
  1790 
  1790 
  1791 	procedure PrevAngle;
  1791 	procedure PrevAngle;
  1792 	begin
  1792 	begin
  1793 	Gear^.Angle:= (LongInt(Gear^.Angle) + 4 - dA) mod 4
  1793 	Gear^.Angle:= (LongInt(Gear^.Angle) + 4 - dA) mod 4
  1794 	end;
  1794 	end;
  1795 	
  1795 
  1796 	procedure NextAngle;
  1796 	procedure NextAngle;
  1797 	begin
  1797 	begin
  1798 	Gear^.Angle:= (LongInt(Gear^.Angle) + 4 + dA) mod 4
  1798 	Gear^.Angle:= (LongInt(Gear^.Angle) + 4 + dA) mod 4
  1799 	end;
  1799 	end;
  1800 	
  1800 
  1801 begin
  1801 begin
  1802 AllInactive:= false;
  1802 AllInactive:= false;
  1803 
  1803 
  1804 inc(Gear^.Tag);
  1804 inc(Gear^.Tag);
  1805 if Gear^.Tag < 7 then exit;
  1805 if Gear^.Tag < 7 then exit;
  2043 	end else begin //explode right on contact with HH
  2043 	end else begin //explode right on contact with HH
  2044 		doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
  2044 		doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
  2045 		DeleteGear(Gear);
  2045 		DeleteGear(Gear);
  2046 		exit;
  2046 		exit;
  2047 		end;
  2047 		end;
  2048 	
  2048 
  2049 	Gear^.doStep:= @doStepDrillDrilling;
  2049 	Gear^.doStep:= @doStepDrillDrilling;
  2050 	dec(Gear^.Timer)
  2050 	dec(Gear^.Timer)
  2051 	end
  2051 	end
  2052 end;
  2052 end;
  2053 
  2053 
  2062 	HedgehogChAngle(HHGear);
  2062 	HedgehogChAngle(HHGear);
  2063 	if (Gear^.Timer mod 100) = 0 then
  2063 	if (Gear^.Timer mod 100) = 0 then
  2064 		begin
  2064 		begin
  2065 		rx:= rndSign(getRandom * _0_1);
  2065 		rx:= rndSign(getRandom * _0_1);
  2066 		ry:= rndSign(getRandom * _0_1);
  2066 		ry:= rndSign(getRandom * _0_1);
  2067 		
  2067 
  2068 		AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBall, 0,
  2068 		AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBall, 0,
  2069 				SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx,
  2069 				SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx,
  2070 				AngleCos(HHGear^.Angle) * ( - _0_8) + ry,
  2070 				AngleCos(HHGear^.Angle) * ( - _0_8) + ry,
  2071 				0);
  2071 				0);
  2072 		
  2072 
  2073 		PlaySound(sndGun, false, nil);
  2073 		PlaySound(sndGun, false, nil);
  2074 		end;
  2074 		end;
  2075 
  2075 
  2076 	if (Gear^.Timer = 0) or (HHGear^.Damage <> 0) then
  2076 	if (Gear^.Timer = 0) or (HHGear^.Damage <> 0) then
  2077 		begin
  2077 		begin
  2175 	or CheckGearDrowning(Gear) then
  2175 	or CheckGearDrowning(Gear) then
  2176 	begin
  2176 	begin
  2177 	StopSound(sndRCPlane);
  2177 	StopSound(sndRCPlane);
  2178 	StopSound(sndRideOfTheValkyries);
  2178 	StopSound(sndRideOfTheValkyries);
  2179 	ResumeMusic;
  2179 	ResumeMusic;
  2180 	
  2180 
  2181 	if ((Gear^.State and gstCollision) <> 0) then
  2181 	if ((Gear^.State and gstCollision) <> 0) then
  2182 		begin
  2182 		begin
  2183 		doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, EXPLAutoSound);
  2183 		doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, EXPLAutoSound);
  2184 		for i:= 0 to 32 do
  2184 		for i:= 0 to 32 do
  2185 			begin
  2185 			begin
  2241     dec(Gear^.Health, fuel div 5);
  2241     dec(Gear^.Health, fuel div 5);
  2242     Gear^.MsgParam:= Gear^.MsgParam or (HHGear^.Message and (gm_Left or gm_Right));
  2242     Gear^.MsgParam:= Gear^.MsgParam or (HHGear^.Message and (gm_Left or gm_Right));
  2243     Gear^.Timer:= GameTicks
  2243     Gear^.Timer:= GameTicks
  2244     end;
  2244     end;
  2245 
  2245 
  2246 // erases them all at once :-/ 
  2246 // erases them all at once :-/
  2247 if (Gear^.Timer <> 0) and (GameTicks - Gear^.Timer > 250) then
  2247 if (Gear^.Timer <> 0) and (GameTicks - Gear^.Timer > 250) then
  2248     begin
  2248     begin
  2249     Gear^.Timer:= 0;
  2249     Gear^.Timer:= 0;
  2250     Gear^.MsgParam:= 0
  2250     Gear^.MsgParam:= 0
  2251     end;
  2251     end;
  2252 
  2252 
  2253 if Gear^.Health < 0 then Gear^.Health:= 0;
  2253 if Gear^.Health < 0 then Gear^.Health:= 0;
  2254 if (GameTicks and $3F) = 0 then 
  2254 if (GameTicks and $3F) = 0 then
  2255        begin
  2255        begin
  2256 //AddCaption('Fuel: '+inttostr(round(Gear^.Health/20))+'%', $FFFFFF, capgrpAmmostate);
  2256 //AddCaption('Fuel: '+inttostr(round(Gear^.Health/20))+'%', $FFFFFF, capgrpAmmostate);
  2257        if Gear^.Tex <> nil then FreeTexture(Gear^.Tex);
  2257        if Gear^.Tex <> nil then FreeTexture(Gear^.Tex);
  2258        Gear^.Tex:= RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(round(Gear^.Health / 20)) + '%', $FFFFFFFF, fntSmall)
  2258        Gear^.Tex:= RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(round(Gear^.Health / 20)) + '%', $FFFFFFFF, fntSmall)
  2259        end;
  2259        end;
  2260 
  2260 
  2261 if HHGear^.Message and (gm_Attack or gm_Up or gm_Precise or gm_Left or gm_Right) <> 0 then Gear^.State:= Gear^.State and not gsttmpFlag;
  2261 if HHGear^.Message and (gm_Attack or gm_Up or gm_Precise or gm_Left or gm_Right) <> 0 then Gear^.State:= Gear^.State and not gsttmpFlag;
  2262 HHGear^.Message:= HHGear^.Message and not (gm_Up or gm_Precise or gm_Left or gm_Right);
  2262 HHGear^.Message:= HHGear^.Message and not (gm_Up or gm_Precise or gm_Left or gm_Right);
  2263 HHGear^.State:= HHGear^.State or gstMoving; 
  2263 HHGear^.State:= HHGear^.State or gstMoving;
  2264 
  2264 
  2265 Gear^.X:= HHGear^.X;
  2265 Gear^.X:= HHGear^.X;
  2266 Gear^.Y:= HHGear^.Y;
  2266 Gear^.Y:= HHGear^.Y;
  2267 // For some reason I need to reapply followgear here, something else grabs it otherwise.
  2267 // For some reason I need to reapply followgear here, something else grabs it otherwise.
  2268 if not bShowAmmoMenu then FollowGear:= HHGear;
  2268 if not bShowAmmoMenu then FollowGear:= HHGear;
  2270 if ((Gear^.State and gsttmpFlag) = 0) or (HHGear^.dY < _0) then doStepHedgehogMoving(HHGear);
  2270 if ((Gear^.State and gsttmpFlag) = 0) or (HHGear^.dY < _0) then doStepHedgehogMoving(HHGear);
  2271 
  2271 
  2272 if  (Gear^.Health = 0)
  2272 if  (Gear^.Health = 0)
  2273     or (HHGear^.Damage <> 0)
  2273     or (HHGear^.Damage <> 0)
  2274 	or CheckGearDrowning(HHGear)
  2274 	or CheckGearDrowning(HHGear)
  2275     or (TurnTimeLeft = 0) 
  2275     or (TurnTimeLeft = 0)
  2276     // allow brief ground touches - to be fair on this, might need another counter
  2276     // allow brief ground touches - to be fair on this, might need another counter
  2277     or (((GameTicks and $1FF) = 0) and (not HHGear^.dY.isNegative) and TestCollisionYwithGear(HHGear, 1))
  2277     or (((GameTicks and $1FF) = 0) and (not HHGear^.dY.isNegative) and TestCollisionYwithGear(HHGear, 1))
  2278 	or ((Gear^.Message and gm_Attack) <> 0) then
  2278 	or ((Gear^.Message and gm_Attack) <> 0) then
  2279 	begin
  2279 	begin
  2280 	with HHGear^ do
  2280 	with HHGear^ do