Use proper infinite fuel feature in flying saucer training
authorWuzzy <Wuzzy2@mail.ru>
Thu, 02 Aug 2018 01:34:26 +0200
changeset 13599 ddd90e92c4c3
parent 13598 083733ec7941
child 13600 0adc82afb784
Use proper infinite fuel feature in flying saucer training
share/hedgewars/Data/Missions/Training/Basic_Training_-_Flying_Saucer.lua
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Flying_Saucer.lua	Thu Aug 02 01:24:40 2018 +0200
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Flying_Saucer.lua	Thu Aug 02 01:34:26 2018 +0200
@@ -267,6 +267,7 @@
 	else
 		InfFuel = false
 	end
+	UpdateInfFuel()
 
 	-- Func (if present) will be run instead of the ordinary spawning handling
 	if TargetPos[TargetNumber].Modifier then -- If there is a modifier, run the function
@@ -356,6 +357,7 @@
 	else
 		InfFuel = false
 	end
+	UpdateInfFuel()
 
 	SetGearPosition(Player, X, Y)
 end
@@ -430,6 +432,7 @@
 		if (TargetNumber == LaunchTarget or TargetNumber == UnderwaterAttackTarget) and BazookasLeft > 0 then
 			AddAmmo(Player, amBazooka, BazookasLeft)
 		end
+		UpdateInfFuel()
 		-- If player starts using saucer, the player probably finished reading and the mission panel
 		-- would just get in the way. So we hide it!
 		HideMission()
@@ -526,20 +529,18 @@
 			end
 		end
 	end
-	ResetFuel()
 end
 
--- Used to ensure infinite fuel
-function ResetFuel()
-	if SaucerGear and InfFuel then
-		SetHealth(SaucerGear, 2000)
+function UpdateInfFuel()
+	if SaucerGear then
+		if InfFuel then
+			SetHealth(SaucerGear, JETPACK_FUEL_INFINITE)
+		elseif GetHealth(SaucerGear == JETPACK_FUEL_INFINITE) then
+			SetHealth(SaucerGear, 2000)
+		end
 	end
 end
 
-onUp = ResetFuel
-onLeft = ResetFuel
-onRight = ResetFuel
-
 function onGearDamage(Gear)
 	if Gear == Player then
 		CleanUpGears()