ASA moon02: Don't play victory animation if runner died and hero survived
authorWuzzy <Wuzzy2@mail.ru>
Mon, 14 Jan 2019 17:43:19 +0100
changeset 14582 e74acf5141fd
parent 14581 72b4bdd5052c
child 14583 914f04315f21
ASA moon02: Don't play victory animation if runner died and hero survived
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua	Mon Jan 14 17:12:12 2019 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua	Mon Jan 14 17:43:19 2019 +0100
@@ -97,6 +97,7 @@
 	FollowGear(hero.gear)
 
 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
+	AddEvent(onRunnerDeath, {runner.gear}, runnerDeath, {runner.gear}, 0)
 
 	if record ~= nil then
 		goals[dialog01][3] = goals[dialog01][3] .. "|" .. string.format(loc("Personal best: %.3f seconds"), record/1000)
@@ -194,12 +195,23 @@
 	return false
 end
 
+function onRunnerDeath(gear)
+	if not GetHealth(runner.gear) then
+		return true
+	end
+	return false
+end
+
 -------------- ACTIONS ------------------
 
 function heroDeath(gear)
 	lose()
 end
 
+function runnerDeath(gear)
+	loseRunnerDeath()
+end
+
 -------------- ANIMATIONS ------------------
 
 function Skipanim(anim)
@@ -312,6 +324,21 @@
 	EndGame()
 end
 
+function loseRunnerDeath()
+	if lostGame then
+		return
+	end
+	lostGame = true
+	SendStat(siGameResult, loc("Race failed!"))
+	SendStat(siCustomAchievement, loc("The other hog has died, he should have survived!"))
+	SendStat(siCustomAchievement, loc("You have to catch the other hog 3 times."))
+	SendStat(siTeamRank, "1")
+	SendStat(siPlayerKills, tostring(GetTeamStats(teamB.name).Kills), teamB.name)
+	SendStat(siTeamRank, "1")
+	SendStat(siPlayerKills, tostring(GetTeamStats(teamA.name).Kills), teamA.name)
+	EndGame()
+end
+
 function win()
 	SendStat(siGameResult, loc("Congratulations, you are the fastest!"))
 	-- siCustomAchievements were added earlier