Use EndTurn to replace TurnTimeLeft=0 in ASA campaign (fixes #225)
authorWuzzy <almikes@aol.com>
Mon, 25 Sep 2017 18:02:35 +0200 (2017-09-25)
changeset 12519 d89dabfd07ce
parent 12518 d90db45a0c4f
child 12520 2df340544f25
Use EndTurn to replace TurnTimeLeft=0 in ASA campaign (fixes #225)
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death01.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert02.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit01.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua	Mon Sep 25 17:06:35 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua	Mon Sep 25 18:02:35 2017 +0200
@@ -251,7 +251,7 @@
 
 function onNewTurn()
 	if CurrentHedgehog == director.gear or CurrentHedgehog == doctor.gear then
-		TurnTimeLeft = 0
+		EndTurn(true)
 	end
 	if guard1.keepTurning then
 		AnimSwitchHog(hero.gear)
@@ -350,7 +350,7 @@
 end
 
 function heroAtSaucerPosition(gear)
-	TurnTimeLeft = 0
+	EndTurn(true)
 	-- save check point
 	SaveCampaignVar("CosmosCheckPoint", "2")
 	checkPointReached = 2
@@ -606,7 +606,7 @@
 function startCombat()
 	-- use this so guard2 will gain control
 	AnimSwitchHog(hero.gear)
-	TurnTimeLeft = 0
+	EndTurn(true)
 end
 
 function sendStats(planetMsg)
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death01.lua	Mon Sep 25 17:06:35 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death01.lua	Mon Sep 25 18:02:35 2017 +0200
@@ -202,7 +202,7 @@
 function onNewTurn()
 	if CurrentHedgehog == paoth1.gear or CurrentHedgehog == paoth2.gear then
 		AnimSwitchHog(hero.gear)
-		TurnTimeLeft = 0
+		EndTurn(true)
 	end
 end
 
@@ -317,5 +317,5 @@
 	DeleteGear(professor.human)
 	RestoreHog(professor.bot)
 	AnimSwitchHog(professor.gear)
-	TurnTimeLeft = 0
+	EndTurn(true)
 end
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua	Mon Sep 25 17:06:35 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua	Mon Sep 25 18:02:35 2017 +0200
@@ -244,20 +244,20 @@
 
 function onNewTurn()
 	if CurrentHedgehog ~= hero.gear and not heroIsInBattle then
-		TurnTimeLeft = 0
+		EndTurn(true)
 	elseif CurrentHedgehog == hero.gear and not heroIsInBattle then
 		TurnTimeLeft = -1
 	elseif (CurrentHedgehog == smuggler2.gear or CurrentHedgehog == smuggler3.gear) and ongoingBattle == 1 then
 		AnimSwitchHog(hero.gear)
-		TurnTimeLeft = 0
+		EndTurn(true)
 	elseif (CurrentHedgehog == smuggler1.gear or CurrentHedgehog == smuggler3.gear) and ongoingBattle == 2 then
 		AnimSwitchHog(hero.gear)
-		TurnTimeLeft = 0
+		EndTurn(true)
 	elseif (CurrentHedgehog == smuggler1.gear or CurrentHedgehog == smuggler2.gear) and ongoingBattle == 3 then
 		AnimSwitchHog(hero.gear)
-		TurnTimeLeft = 0
+		EndTurn(true)
 	elseif CurrentHedgehog == ally.gear then
-		TurnTimeLeft = 0
+		EndTurn(true)
 	end
 end
 
@@ -408,16 +408,16 @@
 
 function heroAtFirstBattle(gear)
 	AnimCaption(hero.gear, loc("A smuggler! Prepare for battle"), 5000)
-	TurnTimeLeft = 0
+	EndTurn(true)
 	heroIsInBattle = true
 	ongoingBattle = 1
 	AnimSwitchHog(smuggler1.gear)
-	TurnTimeLeft = 0
+	EndTurn(true)
 end
 
 function heroFleeFirstBattle(gear)
 	AnimSay(smuggler1.gear, loc("Run away, you coward!"), SAY_SHOUT, 4000)
-	TurnTimeLeft = 0
+	EndTurn(true)
 	heroIsInBattle = false
 	ongoingBattle = 0
 end
@@ -445,7 +445,7 @@
 	ongoingBattle = 3
 	AnimSay(smuggler3.gear, loc("Who's there?! I'll get you!"), SAY_SHOUT, 5000)
 	AnimSwitchHog(smuggler3.gear)
-	TurnTimeLeft = 0
+	EndTurn(true)
 end
 
 function crateDestroyed(gear)
@@ -508,7 +508,7 @@
 
 function startMission()
 	AnimSwitchHog(ally.gear)
-	TurnTimeLeft = 0
+	EndTurn(true)
 end
 
 function secondBattle()
@@ -520,7 +520,7 @@
 	ongoingBattle = 2
 	AnimSay(smuggler2.gear, loc("This is seems like a wealthy hedgehog, nice ..."), SAY_THINK, 5000)
 	AnimSwitchHog(smuggler2.gear)
-	TurnTimeLeft = 0
+	EndTurn(true)
 end
 
 function saveCheckPointLocal(cpoint)
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert02.lua	Mon Sep 25 17:06:35 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert02.lua	Mon Sep 25 18:02:35 2017 +0200
@@ -198,5 +198,5 @@
 
 function challengeStart()
 	startChallenge = true
-	TurnTimeLeft = 0
+	EndTurn(true)
 end
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit01.lua	Mon Sep 25 17:06:35 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit01.lua	Mon Sep 25 18:02:35 2017 +0200
@@ -200,17 +200,17 @@
 
 function onNewTurn()
 	if not heroPlayedFirstTurn and CurrentHedgehog ~= hero.gear and startBattleCalled then
-		TurnTimeLeft = 0
+		EndTurn(true)
 	elseif not heroPlayedFirstTurn and CurrentHedgehog == hero.gear and startBattleCalled then
 		heroPlayedFirstTurn = true
 	elseif not heroPlayedFirstTurn and CurrentHedgehog == green1.gear then
-		TurnTimeLeft = 0
+		EndTurn(true)
 	else
 		if chooseToBattle then
 			if CurrentHedgehog == green1.gear then
 				TotalRounds = TotalRounds - 2
 				AnimSwitchHog(previousHog)
-				TurnTimeLeft = 0
+				EndTurn(true)
 			end
 			previousHog = CurrentHedgehog
 		end
@@ -353,7 +353,7 @@
 end
 
 function heroSelect(gear)
-	TurnTimeLeft = 0
+	EndTurn(true)
 	FollowGear(hero.gear)
 	if GetX(hero.gear) < hero.x then
 		chooseToBattle = true
@@ -443,7 +443,7 @@
 	DeleteGear(green1.human)
 	green1.gear = green1.bot
 	startBattleCalled = true
-	TurnTimeLeft = 0
+	EndTurn(true)
 end
 
 function gameLost()
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua	Mon Sep 25 17:06:35 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua	Mon Sep 25 18:02:35 2017 +0200
@@ -223,7 +223,7 @@
 	if checkPointReached < 5 then
 		SpawnAmmoCrate(eagleCrate.x, eagleCrate.y, eagleCrate.name)
 	end
-	SpawnAmmoCrate(ropeCrate.x, ropeCrate.y, ropeCrate.name)
+	SpawnUtilityCrate(ropeCrate.x, ropeCrate.y, ropeCrate.name)
 
 	if tookPartInBattle then
 		SpawnAmmoCrate(weaponCrate.x, weaponCrate.y, amWatermelon)
@@ -236,17 +236,17 @@
 
 function onNewTurn()
 	if not inBattle and CurrentHedgehog == green1.gear then
-		TurnTimeLeft = 0
+		EndTurn(true)
 	elseif CurrentHedgehog == green2.gear or CurrentHedgehog == green3.gear then
-		TurnTimeLeft = 0
+		EndTurn(true)
 	elseif inBattle then
 		if CurrentHedgehog == green1.gear and previousHog ~= hero.gear then
-			TurnTimeLeft = 0
+			EndTurn(true)
 			return
 		end
 		for i=1,table.getn(redHedgehogs) do
 			if CurrentHedgehog == redHedgehogs[i].gear and previousHog ~= hero.gear then
-				TurnTimeLeft = 0
+				EndTurn(true)
 				return
 			end
 		end
@@ -256,7 +256,7 @@
 		TurnTimeLeft = -1
 		wind()
 	else
-		TurnTimeLeft = 0
+		EndTurn(true)
 	end
 	previousHog = CurrentHedgehog
 end
@@ -418,7 +418,7 @@
 end
 
 function deviceCrates(gear)
-	TurnTimeLeft = 0
+	EndTurn(true)
 	if not tookPartInBattle then
 		AddAnim(dialog03)
 	else
@@ -499,7 +499,7 @@
 	if goals[anim] ~= nil then
 		ShowMission(unpack(goals[anim]))
     end
-    TurnTimeLeft = 0
+    EndTurn(true)
 end
 
 function AnimationSetup()
@@ -549,7 +549,7 @@
 ------------- OTHER FUNCTIONS ---------------
 
 function goToThesurface()
-	TurnTimeLeft = 0
+	EndTurn(true)
 end
 
 function wind()
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua	Mon Sep 25 17:06:35 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua	Mon Sep 25 18:02:35 2017 +0200
@@ -291,7 +291,7 @@
 
 function startBattle()
 	AnimSwitchHog(enemiesOdd[table.getn(enemiesOdd)].gear)
-	TurnTimeLeft = 0
+	EndTurn(true)
 	-- these 2 are needed in order hero has 10 sec more in the first turn
 	timeLeft = 0
 	AddAmmo(hero.gear, amSkip, 100)
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua	Mon Sep 25 17:06:35 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua	Mon Sep 25 18:02:35 2017 +0200
@@ -232,23 +232,23 @@
 	heroDamageAtCurrentTurn = 0
 	-- round has to start if hero goes near the column
 	if not heroVisitedAntiFlyArea and CurrentHedgehog ~= hero.gear then
-		TurnTimeLeft = 0
+		EndTurn(true)
 	elseif not heroVisitedAntiFlyArea and CurrentHedgehog == hero.gear then
 		TurnTimeLeft = -1
 	elseif not heroAtFinalStep and (CurrentHedgehog == bandit1.gear or CurrentHedgehog == bandit4.gear or CurrentHedgehog == bandit5.gear) then
 		AnimSwitchHog(hero.gear)
-		TurnTimeLeft = 0
+		EndTurn(true)
 	elseif heroAtFinalStep and (CurrentHedgehog == bandit2.gear or CurrentHedgehog == bandit3.gear) then
 		if (GetHealth(bandit1.gear) and GetEffect(bandit1.gear,heFrozen) > 256) and
 			((GetHealth(bandit4.gear) and GetEffect(bandit4.gear,heFrozen) > 256) or not GetHealth(bandit4.gear)) and
 			((GetHealth(bandit5.gear) and GetEffect(bandit5.gear,heFrozen) > 256) or not GetHealth(bandit5.gear)) then
-			TurnTimeLeft = 0
+			EndTurn(true)
 		else
 			AnimSwitchHog(hero.gear)
-			TurnTimeLeft = 0
+			EndTurn(true)
 		end
 	elseif CurrentHedgehog == ally.gear then
-		TurnTimeLeft = 0
+		EndTurn(true)
 	end
 	-- frozen hogs accounting
 	if CurrentHedgehog == hero.gear and heroAtFinalStep and TurnTimeLeft > 0 then
@@ -409,11 +409,12 @@
 function antiFlyArea(gear)
 	heroAtAntiFlyArea = true
 	if not heroVisitedAntiFlyArea then
-		TurnTimeLeft = 0
+		EndTurn(true)
 		FollowGear(hero.gear)
 		AnimSwitchHog(bandit1.gear)
 		FollowGear(hero.gear)
-		TurnTimeLeft = 0
+		HogSay(hero.gear, loc("My flying saucer stopped working!"), SAY_THINK)
+		EndTurn(true)
 	end
 	AddAmmo(hero.gear, amJetpack, 0)
 	AddAmmo(hero.gear, amSkip, 100)
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua	Mon Sep 25 17:06:35 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua	Mon Sep 25 18:02:35 2017 +0200
@@ -224,7 +224,7 @@
 
 function startFlying()
 	AnimSwitchHog(ally.gear)
-	TurnTimeLeft = 0
+	EndTurn(true)
 	challengeStarted = true
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua	Mon Sep 25 17:06:35 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua	Mon Sep 25 18:02:35 2017 +0200
@@ -194,7 +194,7 @@
 		SpawnAmmoCrate(grenadeX, weaponsY, amGrenade)
 		SpawnAmmoCrate(deserteagleX, weaponsY, amDEagle)
 		AddEvent(onWeaponsPlatform, {hero.gear}, weaponsPlatform, {hero.gear}, 0)
-		TurnTimeLeft = 0
+		EndTurn(true)
 		AddAnim(dialog01)
 	elseif checkPointReached == 2 then
 		AddAmmo(hero.gear, amBazooka, 3)
@@ -205,7 +205,7 @@
 		GameFlags = bor(GameFlags,gfDisableWind)
 		weaponsAcquired = true
 		afterDialog02 = true
-		TurnTimeLeft = 0
+		EndTurn(true)
 		AddAnim(dialog02)
 	end
 	-- this event check goes here to be executed after the onWeaponsPlatform check
@@ -230,24 +230,24 @@
 	ExecuteAfterAnimations()
 	CheckEvents()
 	if CurrentHedgehog ~= hero.gear and not battleZone then
-		TurnTimeLeft = 0
+		EndTurn(true)
 	end
 end
 
 function onNewTurn()
 	-- rounds start if hero got his weapons or got near the enemies
 	if not weaponsAcquired and not battleZoneReached and CurrentHedgehog ~= hero.gear then
-		TurnTimeLeft = 0
+		EndTurn(true)
 	elseif weaponsAcquired and not battleZoneReached and CurrentHedgehog ~= hero.gear and afterDialog02 then
 		battleZone(hero.gear)
 	elseif not weaponsAcquired and not battleZoneReached and CurrentHedgehog == hero.gear then
 		TurnTimeLeft = -1
 	elseif CurrentHedgehog == paoth1.gear or CurrentHedgehog == paoth2.gear
 		or CurrentHedgehog == paoth3.gear or CurrentHedgehog == paoth4.gear then
-		TurnTimeLeft = 0
+		EndTurn(true)
 	elseif CurrentHedgehog == professor.gear then
 		AnimSwitchHog(hero.gear)
-		TurnTimeLeft = 0
+		EndTurn(true)
 	end
 end
 
@@ -320,7 +320,7 @@
 function weaponsPlatform(gear)
 	saveCheckpoint("2")
 	SaveCampaignVar("HeroHealth",GetHealth(hero.gear))
-	TurnTimeLeft = 0
+	EndTurn(true)
 	weaponsAcquired = true
 	SetWind(60)
 	GameFlags = bor(GameFlags,gfDisableWind)
@@ -339,7 +339,7 @@
 end
 
 function battleZone(gear)
-	TurnTimeLeft = 0
+	EndTurn(true)
 	battleZoneReached = true
 	if weaponsAcquired then
 		AddAnim(dialog04)
@@ -456,7 +456,7 @@
 function startCombat()
 	-- use this so minion3 will gain control
 	AnimSwitchHog(minion3.gear)
-	TurnTimeLeft = 0
+	EndTurn(true)
 end
 
 function setAfterDialog02()