diff -r ca851d0957cf -r 734a7af2dfc2 share/hedgewars/Data/Scripts/SimpleMission.lua --- a/share/hedgewars/Data/Scripts/SimpleMission.lua Tue Dec 18 18:26:13 2018 +0100 +++ b/share/hedgewars/Data/Scripts/SimpleMission.lua Tue Dec 18 18:37:58 2018 +0100 @@ -504,10 +504,6 @@ end if victory then _G.sm.gameEnded = true - if not _G.sm.wonVarWritten then - SaveMissionVar("Won", "true") - _G.sm.wonVarWritten = true - end end end @@ -703,9 +699,7 @@ _G.onNewTurn = function() _G.sm.gameStarted = true - if params.customGoals == nil then - _G.sm.checkRegularVictory() - elseif params.customGoalCheck == "turnStart" then + if params.customGoalCheck == "turnStart" then _G.sm.checkRegularVictory() _G.sm.checkWinOrFail() end @@ -714,14 +708,19 @@ _G.onEndTurn = function() _G.sm.gameTurns = _G.sm.gameTurns + 1 - if params.customGoals == nil then - _G.sm.checkRegularVictory() - elseif params.customGoalCheck == "turnEnd" then + if params.customGoalCheck == "turnEnd" then _G.sm.checkRegularVictory() _G.sm.checkWinOrFail() end end + _G.onGameResult = function(winningClan) + if (params.customGoals == nil) and (not _G.sm.wonVarWritten) and (winningClan == _G.sm.playerClan) then + SaveMissionVar("Won", "true") + _G.sm.wonVarWritten = true + end + end + _G.onAmmoStoreInit = function() local ammoTypesDone = {} -- Read script's stated ammo wishes