equal
deleted
inserted
replaced
262 |
262 |
263 _G.sm.gameEnded = false |
263 _G.sm.gameEnded = false |
264 |
264 |
265 _G.sm.playerClan = 0 |
265 _G.sm.playerClan = 0 |
266 |
266 |
|
267 _G.sm.wonVarWritten = false |
|
268 |
267 _G.sm.makeStats = function(winningClan, customAchievements) |
269 _G.sm.makeStats = function(winningClan, customAchievements) |
268 for t=0, TeamsCount-1 do |
270 for t=0, TeamsCount-1 do |
269 local team = GetTeamName(t) |
271 local team = GetTeamName(t) |
270 local stats = GetTeamStats(team) |
272 local stats = GetTeamStats(team) |
271 local clan = GetTeamClan(team) |
273 local clan = GetTeamClan(team) |
500 break |
502 break |
501 end |
503 end |
502 end |
504 end |
503 if victory then |
505 if victory then |
504 _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 |
505 end |
511 end |
506 end |
512 end |
507 |
513 |
508 -- Checks goals and non goals and wins or loses mission |
514 -- Checks goals and non goals and wins or loses mission |
509 _G.sm.checkWinOrFail = function() |
515 _G.sm.checkWinOrFail = function() |
522 end |
528 end |
523 |
529 |
524 _G.sm.win = function() |
530 _G.sm.win = function() |
525 if not _G.sm.gameEnded then |
531 if not _G.sm.gameEnded then |
526 _G.sm.gameEnded = true |
532 _G.sm.gameEnded = true |
|
533 if not _G.sm.wonVarWritten then |
|
534 SaveMissionVar("Won", "true") |
|
535 _G.sm.wonVarWritten = true |
|
536 end |
527 AddCaption(loc("Victory!"), capcolDefault, capgrpGameState) |
537 AddCaption(loc("Victory!"), capcolDefault, capgrpGameState) |
528 SendStat(siGameResult, loc("You win!")) |
538 SendStat(siGameResult, loc("You win!")) |
529 if GetHogLevel(CurrentHedgehog) == 0 then |
539 if GetHogLevel(CurrentHedgehog) == 0 then |
530 SetState(CurrentHedgehog, bor(GetState(CurrentHedgehog), gstWinner)) |
540 SetState(CurrentHedgehog, bor(GetState(CurrentHedgehog), gstWinner)) |
531 SetState(CurrentHedgehog, band(GetState(CurrentHedgehog), bnot(gstHHDriven))) |
541 SetState(CurrentHedgehog, band(GetState(CurrentHedgehog), bnot(gstHHDriven))) |
691 end |
701 end |
692 |
702 |
693 _G.onNewTurn = function() |
703 _G.onNewTurn = function() |
694 _G.sm.gameStarted = true |
704 _G.sm.gameStarted = true |
695 |
705 |
696 if params.customGoalCheck == "turnStart" then |
706 if params.customGoals == nil then |
|
707 _G.sm.checkRegularVictory() |
|
708 elseif params.customGoalCheck == "turnStart" then |
697 _G.sm.checkRegularVictory() |
709 _G.sm.checkRegularVictory() |
698 _G.sm.checkWinOrFail() |
710 _G.sm.checkWinOrFail() |
699 end |
711 end |
700 end |
712 end |
701 |
713 |
702 _G.onEndTurn = function() |
714 _G.onEndTurn = function() |
703 _G.sm.gameTurns = _G.sm.gameTurns + 1 |
715 _G.sm.gameTurns = _G.sm.gameTurns + 1 |
704 |
716 |
705 if params.customGoalCheck == "turnEnd" then |
717 if params.customGoals == nil then |
|
718 _G.sm.checkRegularVictory() |
|
719 elseif params.customGoalCheck == "turnEnd" then |
706 _G.sm.checkRegularVictory() |
720 _G.sm.checkRegularVictory() |
707 _G.sm.checkWinOrFail() |
721 _G.sm.checkWinOrFail() |
708 end |
722 end |
709 end |
723 end |
710 |
724 |