ASA, desert03: Change box appearance, don't lose as long there are still flames in game
authorWuzzy <almikes@aol.com>
Wed, 27 Sep 2017 23:09:25 +0200
changeset 12563 8a9919381629
parent 12562 68dd14766445
child 12564 6a8c90a53249
ASA, desert03: Change box appearance, don't lose as long there are still flames in game
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert03.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert03.lua	Wed Sep 27 20:47:18 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert03.lua	Wed Sep 27 23:09:25 2017 +0200
@@ -53,6 +53,7 @@
 	{ x = 1200, y = 1310},
 	{ x = 1700, y = 1310},
 }
+local flameCounter = 0
 
 -------------- LuaAPI EVENT HANDLERS ------------------
 
@@ -124,6 +125,18 @@
 	end
 end
 
+function onGearAdd(gear)
+	if GetGearType(gear) == gtFlame then
+		flameCounter = flameCounter + 1
+	end
+end
+
+function onGearDelete(gear)
+	if GetGearType(gear) == gtFlame then
+		flameCounter = flameCounter - 1
+	end
+end
+
 -------------- EVENTS ------------------
 
 function onHeroDeath(gear)
@@ -134,7 +147,7 @@
 end
 
 function onLose(gear)
-	if GetHealth(hero.gear) and currentTarget < 4 and GetAmmoCount(hero.gear, amRCPlane) == 0 then
+	if GetHealth(hero.gear) and currentTarget < 4 and GetAmmoCount(hero.gear, amRCPlane) == 0 and flameCounter <= 0 then
 		return true
 	end
 	return false
@@ -147,6 +160,8 @@
 end
 
 function lose(gear)
+	AddCaption(loc("Out of ammo!"), 0xFFFFFFFF, capgrpMessage2)
+	PlaySound(sndStupid, hero.gear)
 	gameOver()
 end
 
@@ -200,9 +215,8 @@
 			targets[i].gear = AddGear(targets[i].x, targets[i].y, gtTarget, 0, 0, 0, 0)
 		end
 	elseif ct == 3 then
-		SpawnAmmoCrate(rcCrates[3].x, rcCrates[3].y, amRCPlane)
-		SpawnAmmoCrate(rcCrates[3].x, rcCrates[3].y, amRCPlane)
-		SpawnAmmoCrate(rcCrates[4].x, rcCrates[4].y, amNothing)
+		SpawnUtilityCrate(rcCrates[4].x, rcCrates[4].y, amNothing)
+		SpawnAmmoCrate(rcCrates[3].x, rcCrates[3].y, amRCPlane, 2)
 		for i=4,13 do
 			targets[i].gear = AddGear(targets[i].x, targets[i].y, gtTarget, 0, 0, 0, 0)
 		end