ASA, Spacetrip: Fix mission fail if touching ground in flying saucer but still got fuel
authorWuzzy <almikes@aol.com>
Mon, 25 Sep 2017 19:25:39 +0200
changeset 12518 94bba599efd3
parent 12517 193b5882429d
child 12519 206cb38d030f
ASA, Spacetrip: Fix mission fail if touching ground in flying saucer but still got fuel
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua	Mon Sep 25 19:16:14 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua	Mon Sep 25 19:25:39 2017 +0200
@@ -54,6 +54,8 @@
 local teamA = {}
 local teamB = {}
 local teamC = {}
+-- to check if flying saucer is active
+local saucerGear = nil
 -- hedgehogs values
 hero.name = loc("Hog Solo")
 hero.x = 1450
@@ -275,9 +277,17 @@
 	return false
 end
 
+function onGearAdd(gear)
+	if GetGearType(gear) == gtJetpack then
+		saucerGear = gear
+	end
+end
+
 function onGearDelete(gear)
 	if GetGearType(gear) == gtCase and band(GetGearMessage(gear), gmDestroy) ~= 0 then
 		heroAtSaucerPosition()
+	elseif GetGearType(gear) == gtJetpack then
+		saucerGear = nil
 	end
 end
 
@@ -332,7 +342,7 @@
 
 function onNoFuelAtLand(gear)
 	if checkPointReached > 1 and GetHealth(hero.gear) and GetY(gear) > 1400 and
-			GetAmmoCount(gear, amJetpack) == 0 and StoppedGear(gear) then
+			GetAmmoCount(gear, amJetpack) == 0 and saucerGear == nil and StoppedGear(gear) then
 		return true
 	end
 	return false