share/hedgewars/Data/Scripts/SimpleMission.lua
changeset 13053 8b42562dcada
parent 13049 f18cefc4309d
child 13054 2d0f3e12fcad
equal deleted inserted replaced
13052:ce1b01a5d846 13053:8b42562dcada
   120 				blowing up a crate which you should have collected.ed.
   120 				blowing up a crate which you should have collected.ed.
   121 	- customNonGoals	Table of non-goals, the player loses if one of them is achieved
   121 	- customNonGoals	Table of non-goals, the player loses if one of them is achieved
   122 	- customGoalCheck	When to check goals and non-goals. Values: "instant" (default), "turnStart", "turnEnd"
   122 	- customGoalCheck	When to check goals and non-goals. Values: "instant" (default), "turnStart", "turnEnd"
   123 
   123 
   124 	- missionTitle:		The name of the mission (highly recommended)
   124 	- missionTitle:		The name of the mission (highly recommended)
   125 	- customGoalText:	A short string explaining the goal of the mission (use this if you set custom goals).
   125 	- goalText:		A short string explaining the goal of the mission (use this if you set custom goals).
   126 
   126 
   127 	GOAL TYPES:
   127 	GOAL TYPES:
   128 	- type			name of goal type
   128 	- type			name of goal type
   129 	- type="destroy"	Gear must be destroyed
   129 	- type="destroy"	Gear must be destroyed
   130 		- id		Gear to destroy
   130 		- id		Gear to destroy
   453 			end
   453 			end
   454 		end
   454 		end
   455 		return false
   455 		return false
   456 	end
   456 	end
   457 
   457 
       
   458 	-- Declare the game ended if all enemy teams are dead and player teams or allies are still alive
       
   459 	_G.sm.checkRegularVictory = function()
       
   460 		local victory = true
       
   461 		for t=0, TeamsCount-1 do
       
   462 			local team = GetTeamName(t)
       
   463 			local defeat = _G.sm.checkGoal({type="teamDefeat", teamName=team})
       
   464 			if (defeat == true) and (GetTeamClan(team) == _G.sm.playerClan) then
       
   465 				victory = false
       
   466 				break
       
   467 			elseif (defeat == false) and (GetTeamClan(team) ~= _G.sm.playerClan) then
       
   468 				victory = false
       
   469 				break
       
   470 			end
       
   471 		end
       
   472 		if victory then
       
   473 			_G.sm.gameEnded = true
       
   474 		end
       
   475 	end
       
   476 
   458 	-- Checks goals and non goals and wins or loses mission
   477 	-- Checks goals and non goals and wins or loses mission
   459 	_G.sm.checkWinOrFail = function()
   478 	_G.sm.checkWinOrFail = function()
   460 		if errord then
   479 		if errord then
   461 			return
   480 			return
   462 		end
   481 		end
       
   482 		_G.sm.checkRegularVictory()
   463 		if _G.sm.checkNonGoals() == true or _G.sm.checkGoals() == "fail" then
   483 		if _G.sm.checkNonGoals() == true or _G.sm.checkGoals() == "fail" then
   464 			_G.sm.lose()
   484 			_G.sm.lose()
   465 		elseif _G.sm.checkGoals() == true then
   485 		elseif _G.sm.checkGoals() == true then
   466 			_G.sm.win()
   486 			_G.sm.win()
   467 		end
   487 		end