Scenarios: Show "Mission succeeded/failed!" in stats screen
authorWuzzy <Wuzzy2@mail.ru>
Fri, 31 May 2019 21:39:47 +0200
changeset 15112 5c8c729a16ce
parent 15111 33eca3f0a9aa
child 15113 ba9d54d1c25d
Scenarios: Show "Mission succeeded/failed!" in stats screen
share/hedgewars/Data/Missions/Scenario/User_Mission_-_Bamboo_Thicket.lua
share/hedgewars/Data/Missions/Scenario/User_Mission_-_Dangerous_Ducklings.lua
share/hedgewars/Data/Missions/Scenario/User_Mission_-_Diver.lua
share/hedgewars/Data/Missions/Scenario/User_Mission_-_Spooky_Tree.lua
share/hedgewars/Data/Missions/Scenario/User_Mission_-_Teamwork.lua
share/hedgewars/Data/Missions/Scenario/User_Mission_-_Teamwork_2.lua
share/hedgewars/Data/Missions/Scenario/portal.lua
share/hedgewars/Data/Scripts/SimpleMission.lua
--- a/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Bamboo_Thicket.lua	Fri May 31 21:10:17 2019 +0200
+++ b/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Bamboo_Thicket.lua	Fri May 31 21:39:47 2019 +0200
@@ -2,6 +2,7 @@
 HedgewarsScriptLoad("/Scripts/Locale.lua")
 HedgewarsScriptLoad("/Scripts/Achievements.lua")
 
+local playerTeamName
 local player = nil 
 local enemy = nil
 local firedShell = false
@@ -24,7 +25,7 @@
 	WaterRise = 0
 	GameFlags = gfDisableWind
 
-	AddMissionTeam(-1)
+	playerTeamName = AddMissionTeam(-1)
 	player = AddMissionHog(10)
 			
 	AddTeam(loc("Cybernetic Empire"), -6, "ring", "Island", "Robot_qau", "cm_cyborg")
@@ -77,17 +78,17 @@
 
 function onGameResult(winner)
 
-	if (winner == 0) then
+	if (winner == GetTeamClan(playerTeamName)) then
 		
 		SaveMissionVar("Won", "true")
-		ShowMission(loc("Bamboo Thicket"), loc("MISSION SUCCESSFUL"), loc("Congratulations!"), 0, 0)
+		SendStat(siGameResult, loc("Mission succeeded!"))
 		
 		if (turnNumber < 6) and (firedShell == false) then
 			awardAchievement(loc("Energetic Engineer"))
 		end
 
 	else
-		ShowMission(loc("Bamboo Thicket"), loc("MISSION FAILED"), loc("Oh no! Just try again!"), -amSkip, 0)
+		SendStat(siGameResult, loc("Mission failed!"))
 	end
 
 end
--- a/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Dangerous_Ducklings.lua	Fri May 31 21:10:17 2019 +0200
+++ b/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Dangerous_Ducklings.lua	Fri May 31 21:39:47 2019 +0200
@@ -116,7 +116,6 @@
 				SetTurnTimeLeft(1)
 				DismissTeam(playerTeamName)
 			end
-			ShowMission(loc("Dangerous Ducklings"), loc("MISSION FAILED"), loc("You've failed. Try again."), -amRope, 5000);
 		end
 	end
 
@@ -139,13 +138,20 @@
 			awardAchievement(loc("Naughty Ninja"))
 			DismissTeam(enemyTeamName)
 			gameWon = true
-			SaveMissionVar("Won", "true")
 		elseif gear == enemy then
 			HogSay(player, loc("Enjoy the swim..."), SAY_THINK)
 			gameWon = true
-			SaveMissionVar("Won", "true")
 			Retreat(3000)
 		end
 
 	end
 end
+
+function onGameResult(winner)
+	if winner == GetTeamClan(playerTeamName) then
+		SaveMissionVar("Won", "true")
+		SendStat(siGameResult, loc("Mission succeeded!"))
+	else
+		SendStat(siGameResult, loc("Mission failed!"))
+	end
+end
--- a/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Diver.lua	Fri May 31 21:10:17 2019 +0200
+++ b/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Diver.lua	Fri May 31 21:39:47 2019 +0200
@@ -1,6 +1,7 @@
 
 HedgewarsScriptLoad("/Scripts/Locale.lua")
 
+local playerTeamName
 local player = nil -- This variable will point to the hog's gear
 local enemy = nil
 
@@ -26,7 +27,7 @@
 	HealthDecrease = 0
 	WaterRise = 0
 
-	AddMissionTeam(-1)
+	playerTeamName = AddMissionTeam(-1)
 	player = AddMissionHog(1)
 			
 	AddTeam(loc("Toxic Team"), -6, "skull", "Island", "Default_qau", "cm_magicskull")
@@ -96,12 +97,12 @@
 
 function onGameResult(winner)
 
-	if winner == 0 then
-		ShowMission(loc("Diver"), loc("MISSION SUCCESSFUL"), loc("Congratulations!"), 0, 0)
+	if winner == GetTeamClan(playerTeamName) then
+		SendStat(siGameResult, loc("Mission succeeded!"))
 		SaveMissionVar("Won", "true")
 		GameOver = true
 	else
-		ShowMission(loc("Diver"), loc("MISSION FAILED"), loc("Oh no! Just try again!"), -amSkip, 0)		
+		SendStat(siGameResult, loc("Mission failed!"))
 		GameOver = true
 	end
 
--- a/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Spooky_Tree.lua	Fri May 31 21:10:17 2019 +0200
+++ b/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Spooky_Tree.lua	Fri May 31 21:39:47 2019 +0200
@@ -3,6 +3,7 @@
 
 ---------------------------------------------------------------
 
+local playerTeamName
 local player = nil -- This variable will point to the hog's gear
 local instructor = nil
 local enemy = nil
@@ -29,7 +30,7 @@
 	HealthDecrease = 0
 	WaterRise = 0
 
-	AddMissionTeam(-1)
+	playerTeamName = AddMissionTeam(-1)
 	player = AddMissionHog(1)
 	AddTeam(loc("Toxic Team"), -6, "skull", "Island", "Default_qau", "cm_magicskull")
 	enemy = AddHog(loc("Poison"), 1, 10, "Skull")
@@ -116,7 +117,6 @@
 	end
 
 	if TurnTimeLeft == 1 then
-		--ShowMission(loc(caption), loc(subcaption), loc(timeout), -amSkip, 0);
 		SetHealth(player, 0)
 		GameOver = true
 	end
@@ -149,12 +149,12 @@
 end
 
 function onGameResult(winner)
-	if winner == 0 then
-		ShowMission(loc("Spooky Tree"), loc("MISSION SUCCESSFUL"), loc("Congratulations!"), 0, 0);
+	if winner == GetTeamClan(playerTeamName) then
 		SaveMissionVar("Won", "true")
+		SendStat(siGameResult, loc("Mission succeeded!"))
 		GameOver = true
 	else
-		ShowMission(loc("Spooky Tree"), loc("MISSION FAILED"), loc("Oh no! Just try again!"), -amSkip, 0)
+		SendStat(siGameResult, loc("Mission failed!"))
 		GameOver = true
 	end
 end
--- a/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Teamwork.lua	Fri May 31 21:10:17 2019 +0200
+++ b/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Teamwork.lua	Fri May 31 21:39:47 2019 +0200
@@ -94,7 +94,6 @@
 	end
 	-- Note: The victory sequence is done automatically by Hedgewars
 	if  ( ((gear == player) or (gear == p2)) and (GameOver == false)) then
-		ShowMission(loc("Teamwork"), loc("MISSION FAILED"), loc("Oh no! Just try again!"), -amSkip, 0)
 		GameOver = true
 		SetHealth(p2,0)
 		SetHealth(player,0)
@@ -102,8 +101,13 @@
 
 end
 
-function onGameResult(winningClan)
-	if winningClan == GetTeamClan(playerTeamName) then
+function onGameResult(winner)
+	if winner == GetTeamClan(playerTeamName) then
 		SaveMissionVar("Won", "true")
+		SendStat(siGameResult, loc("Mission succeeded!"))
+		GameOver = true
+	else
+		SendStat(siGameResult, loc("Mission failed!"))
+		GameOver = true
 	end
 end
--- a/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Teamwork_2.lua	Fri May 31 21:10:17 2019 +0200
+++ b/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Teamwork_2.lua	Fri May 31 21:39:47 2019 +0200
@@ -101,15 +101,19 @@
 	end
 	-- Note: The victory sequence is done automatically by Hedgewars
 	if ( ((gear == player) or (gear == hlayer)) and (GameOver == false)) then
-		ShowMission(loc("Teamwork 2"), loc("MISSION FAILED"), loc("Oh no! Just try again!"), -amSkip, 0)
 		GameOver = true
 		SetHealth(hlayer, 0)
 		SetHealth(player, 0)
 	end
 end
 
-function onGameResult(winningClan)
-	if winningClan == GetTeamClan(playerTeamName) then
+function onGameResult(winner)
+	if winner == GetTeamClan(playerTeamName) then
 		SaveMissionVar("Won", "true")
+		SendStat(siGameResult, loc("Mission succeeded!"))
+		GameOver = true
+	else
+		SendStat(siGameResult, loc("Mission failed!"))
+		GameOver = true
 	end
 end
--- a/share/hedgewars/Data/Missions/Scenario/portal.lua	Fri May 31 21:10:17 2019 +0200
+++ b/share/hedgewars/Data/Missions/Scenario/portal.lua	Fri May 31 21:39:47 2019 +0200
@@ -224,5 +224,8 @@
 function onGameResult(winningClan)
 	if winningClan == GetHogClan(player) then
 		SaveMissionVar("Won", "true")
+		SendStat(siGameResult, loc("Mission succeeded!"))
+	else
+		SendStat(siGameResult, loc("Mission failed!"))
 	end
 end
--- a/share/hedgewars/Data/Scripts/SimpleMission.lua	Fri May 31 21:10:17 2019 +0200
+++ b/share/hedgewars/Data/Scripts/SimpleMission.lua	Fri May 31 21:39:47 2019 +0200
@@ -522,7 +522,7 @@
 				_G.sm.wonVarWritten = true
 			end
 			AddCaption(loc("Victory!"), capcolDefault, capgrpGameState)
-			SendStat(siGameResult, loc("You win!"))
+			SendStat(siGameResult, loc("Mission succeeded!"))
 			_G.sm.makeStats(_G.sm.playerClan)
 			EndGame()
 			if GetHogLevel(CurrentHedgehog) == 0 then
@@ -537,8 +537,8 @@
 	_G.sm.lose = function(failReason)
 		if not _G.sm.gameEnded then
 			_G.sm.gameEnded = true
-			AddCaption(loc("Scenario failed!"), capcolDefault, capgrpGameState)
-			SendStat(siGameResult, loc("You lose!"))
+			AddCaption(loc("Mission failed!"), capcolDefault, capgrpGameState)
+			SendStat(siGameResult, loc("Mission failed!"))
 			if failReason then
 				SendStat(siCustomAchievement, failReason)
 			end
@@ -736,8 +736,11 @@
 
 	_G.onGameResult = function(winningClan)
 		if (params.customGoals == nil) and (not _G.sm.wonVarWritten) and (winningClan == _G.sm.playerClan) then
+			SendStat(siGameResult, loc("Mission succeeded!"))
 			SaveMissionVar("Won", "true")
 			_G.sm.wonVarWritten = true
+		else
+			SendStat(siGameResult, loc("Mission failed!"))
 		end
 	end