# HG changeset patch # User Wuzzy # Date 1506368498 -7200 # Node ID f2a19a6056be90e5fcd048019860d21d55401c1e # Parent 228ebbc8656d5a7639caabfbcad42133e374e579 ASA: Reset mission checkpoints when going to Spacetrip diff -r 228ebbc8656d -r f2a19a6056be share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua --- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua Mon Sep 25 21:18:59 2017 +0200 +++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua Mon Sep 25 21:41:38 2017 +0200 @@ -191,6 +191,11 @@ AddAmmo(hero.gear, amJetpack, 100) end + -- Reset checkpoint of other missions when entering this mission. + -- The player has left the planet, so we count that “abandoning” any incomplete missions. + -- This also allows the player (indirectly) to reset the checkpointed missions. + abandoned = resetCheckpoint() + AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0) AddEvent(onNoFuelAtLand, {hero.gear}, noFuelAtLand, {hero.gear}, 0) -- always check for landings diff -r 228ebbc8656d -r f2a19a6056be share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua --- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua Mon Sep 25 21:18:59 2017 +0200 +++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua Mon Sep 25 21:41:38 2017 +0200 @@ -118,13 +118,16 @@ if GetCampaignVar("CurrentMission") ~= mission then SaveCampaignVar("CurrentMission", mission) SaveCampaignVar("CurrentMissionCheckpoint", 1) - SaveCampaignVar("HogsPosition", "") else - checkPoint = tonumber(GetCampaignVar("currentMissionCheckpoint")) + checkPoint = tonumber(GetCampaignVar("CurrentMissionCheckpoint")) end return checkPoint end +function resetCheckpoint(mission) + SaveCampaignVar("CurrentMissionCheckpoint", 1) +end + function saveCheckpoint(cp) SaveCampaignVar("CurrentMissionCheckpoint", cp) end