# HG changeset patch # User Wuzzy # Date 1547484199 -3600 # Node ID e74acf5141fd9605454d31f74adce091e8101135 # Parent 72b4bdd5052c50de91a190c881af3c87a387b05c ASA moon02: Don't play victory animation if runner died and hero survived diff -r 72b4bdd5052c -r e74acf5141fd 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