# HG changeset patch # User Wuzzy # Date 1519249383 -3600 # Node ID 8b42562dcada77283735b8121cd931dfb68d0c16 # Parent ce1b01a5d846dff3742b8df429bc42ade22c7297 SimpleMission: Check regular victory before anything else diff -r ce1b01a5d846 -r 8b42562dcada share/hedgewars/Data/Scripts/SimpleMission.lua --- a/share/hedgewars/Data/Scripts/SimpleMission.lua Wed Feb 21 21:40:52 2018 +0100 +++ b/share/hedgewars/Data/Scripts/SimpleMission.lua Wed Feb 21 22:43:03 2018 +0100 @@ -122,7 +122,7 @@ - customGoalCheck When to check goals and non-goals. Values: "instant" (default), "turnStart", "turnEnd" - missionTitle: The name of the mission (highly recommended) - - customGoalText: A short string explaining the goal of the mission (use this if you set custom goals). + - goalText: A short string explaining the goal of the mission (use this if you set custom goals). GOAL TYPES: - type name of goal type @@ -455,11 +455,31 @@ return false end + -- Declare the game ended if all enemy teams are dead and player teams or allies are still alive + _G.sm.checkRegularVictory = function() + local victory = true + for t=0, TeamsCount-1 do + local team = GetTeamName(t) + local defeat = _G.sm.checkGoal({type="teamDefeat", teamName=team}) + if (defeat == true) and (GetTeamClan(team) == _G.sm.playerClan) then + victory = false + break + elseif (defeat == false) and (GetTeamClan(team) ~= _G.sm.playerClan) then + victory = false + break + end + end + if victory then + _G.sm.gameEnded = true + end + end + -- Checks goals and non goals and wins or loses mission _G.sm.checkWinOrFail = function() if errord then return end + _G.sm.checkRegularVictory() if _G.sm.checkNonGoals() == true or _G.sm.checkGoals() == "fail" then _G.sm.lose() elseif _G.sm.checkGoals() == true then