share/hedgewars/Data/Scripts/SimpleMission.lua
changeset 14471 734a7af2dfc2
parent 14469 ead8928a59f8
child 14488 310b167141cc
equal deleted inserted replaced
14470:ca851d0957cf 14471:734a7af2dfc2
   502 				break
   502 				break
   503 			end
   503 			end
   504 		end
   504 		end
   505 		if victory then
   505 		if victory then
   506 			_G.sm.gameEnded = true
   506 			_G.sm.gameEnded = true
   507 			if not _G.sm.wonVarWritten then
       
   508 				SaveMissionVar("Won", "true")
       
   509 				_G.sm.wonVarWritten = true
       
   510 			end
       
   511 		end
   507 		end
   512 	end
   508 	end
   513 
   509 
   514 	-- Checks goals and non goals and wins or loses mission
   510 	-- Checks goals and non goals and wins or loses mission
   515 	_G.sm.checkWinOrFail = function()
   511 	_G.sm.checkWinOrFail = function()
   701 	end
   697 	end
   702 
   698 
   703 	_G.onNewTurn = function()
   699 	_G.onNewTurn = function()
   704 		_G.sm.gameStarted = true
   700 		_G.sm.gameStarted = true
   705 
   701 
   706 		if params.customGoals == nil then
   702 		if params.customGoalCheck == "turnStart" then
   707 			_G.sm.checkRegularVictory()
       
   708 		elseif params.customGoalCheck == "turnStart" then
       
   709 			_G.sm.checkRegularVictory()
   703 			_G.sm.checkRegularVictory()
   710 			_G.sm.checkWinOrFail()
   704 			_G.sm.checkWinOrFail()
   711 		end
   705 		end
   712 	end
   706 	end
   713 
   707 
   714 	_G.onEndTurn = function()
   708 	_G.onEndTurn = function()
   715 		_G.sm.gameTurns = _G.sm.gameTurns + 1
   709 		_G.sm.gameTurns = _G.sm.gameTurns + 1
   716 
   710 
   717 		if params.customGoals == nil then
   711 		if params.customGoalCheck == "turnEnd" then
   718 			_G.sm.checkRegularVictory()
       
   719 		elseif params.customGoalCheck == "turnEnd" then
       
   720 			_G.sm.checkRegularVictory()
   712 			_G.sm.checkRegularVictory()
   721 			_G.sm.checkWinOrFail()
   713 			_G.sm.checkWinOrFail()
       
   714 		end
       
   715 	end
       
   716 
       
   717 	_G.onGameResult = function(winningClan)
       
   718 		if (params.customGoals == nil) and (not _G.sm.wonVarWritten) and (winningClan == _G.sm.playerClan) then
       
   719 			SaveMissionVar("Won", "true")
       
   720 			_G.sm.wonVarWritten = true
   722 		end
   721 		end
   723 	end
   722 	end
   724 
   723 
   725 	_G.onAmmoStoreInit = function()
   724 	_G.onAmmoStoreInit = function()
   726 		local ammoTypesDone = {}
   725 		local ammoTypesDone = {}