Use player-chosen team identity for most challenges and scenarios
authorWuzzy <Wuzzy2@mail.ru>
Thu, 20 Dec 2018 17:51:46 +0100
changeset 14503 d4aa64f51c9f
parent 14502 65b25ca6ff31
child 14504 310b167141cc
Use player-chosen team identity for most challenges and scenarios
share/hedgewars/Data/Missions/Challenge/User_Mission_-_Rope_Knock_Challenge.lua
share/hedgewars/Data/Missions/Challenge/User_Mission_-_That_Sinking_Feeling.lua
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
--- a/share/hedgewars/Data/Missions/Challenge/User_Mission_-_Rope_Knock_Challenge.lua	Thu Dec 20 15:53:22 2018 +0100
+++ b/share/hedgewars/Data/Missions/Challenge/User_Mission_-_Rope_Knock_Challenge.lua	Thu Dec 20 17:51:46 2018 +0100
@@ -73,7 +73,7 @@
 
 				}
 
-local playerTeamName = loc("Wannabe Shoppsta")
+local playerTeam, playerTeamName
 
 function GetKillScore()
 	return math.ceil((hogsKilled / 16)*6000)
@@ -174,8 +174,9 @@
 	MinesNum = 0
 	Explosives = 0
 
-	AddTeam(playerTeamName, -1, "money", "Island", "Default", "cm_shoppa")
-	hhs[0] = AddHog(loc("Ace"), 0, 1, "Gasmask")
+	playerTeam = AddMissionTeam(-1)
+	playerTeamName = GetTeamName(playerName)
+	hhs[0] = AddMissionHog(1)
 	SetGearPosition(player, 1380, 1500)
 
 	AddTeam(loc("Unsuspecting Louts"), -2, "Simple", "Island", "Default", "cm_face")
--- a/share/hedgewars/Data/Missions/Challenge/User_Mission_-_That_Sinking_Feeling.lua	Thu Dec 20 15:53:22 2018 +0100
+++ b/share/hedgewars/Data/Missions/Challenge/User_Mission_-_That_Sinking_Feeling.lua	Thu Dec 20 17:51:46 2018 +0100
@@ -5,6 +5,7 @@
 HedgewarsScriptLoad("/Scripts/Achievements.lua")
 
 local player
+local playerTeamName, haplessTeamName
 local hh = {}
 local hhCount = 8
 local GameOver = false
@@ -23,7 +24,7 @@
 	if show then
 		recordInfo = getReadableChallengeRecord("Highscore")
 	end
-	ShowMission(loc("That Sinking Feeling"), loc("Challenge"), loc("Save as many hapless hogs as possible!")
+	ShowMission(loc("That Sinking Feeling"), loc("Challenge"), loc("Save as many hogs as possible!")
 	.. "|" .. recordInfo, 4, 0)
 end
 
@@ -53,7 +54,8 @@
 	HealthDecrease = 0
 	WaterRise = 0
 
-	AddTeam(loc("Hapless Hogs"), -1, "Simple", "Island", "Default")
+	local idx = AddTeam(loc("Hapless Hogs"), -1, "Simple", "Island", "Default")
+	haplessTeamName = GetTeamName(idx)
 	hh[0] = AddHog(loc("Sinky"), 1, 100, "fr_lemon")
 	hh[1] = AddHog(loc("Drowner"), 1, 100, "fr_orange")
 	hh[2] = AddHog(loc("Heavy"), 1, 100, "dish_Teapot")
@@ -63,8 +65,9 @@
 	hh[6] = AddHog(loc("Sponge"), 1, 100, "sf_chunli")
 	hh[7] = AddHog(loc("Deadweight"), 1, 100, "dish_Teacup")
 
-	AddTeam(loc("Nameless Heroes"), -1, "Simple", "Island", "Default", "cm_crossedswords")
-	player = AddHog(loc("The Nameless One"), 0, 1, "NoHat")
+	idx = AddMissionTeam(-1)
+	playerTeamName = GetTeamName(idx)
+	player = AddMissionHog(1)
 
 	SetGearPosition(player, 3992, 733)
 	SetGearPosition(hh[0], 938, 1369)
@@ -213,7 +216,7 @@
 			if genCounter == 2000 then
 				introStage = 110
 				FollowGear(CurrentHedgehog)
-				ShowMission(loc("That Sinking Feeling"), loc("User Challenge"), loc("Save as many hapless hogs as possible!"), 4, 0)
+				ShowMission(loc("That Sinking Feeling"), loc("User Challenge"), loc("Save as many hogs as possible!"), 4, 0)
 				SetInputMask(0xFFFFFFFF)
 			end
 
@@ -241,7 +244,7 @@
 				AddCaption(loc("The flood has stopped! Challenge over."))
 				SendStat(siGameResult, loc("Challenge completed!"))
 				SendStat(siPointType, loc("rescues"))
-				SendStat(siPlayerKills, tostring(hhCount), loc("Nameless Heroes"))
+				SendStat(siPlayerKills, tostring(hhCount), playerTeamName)
 
 				-- Do not count drowning hedgehogs
 				local hhLeft = hhCount
@@ -252,7 +255,7 @@
 					end
 				end
 
-				SendStat(siCustomAchievement, string.format(loc("You saved %d of 8 Hapless Hogs."), hhLeft))
+				SendStat(siCustomAchievement, string.format(loc("You saved %d of 8 hegehogs."), hhLeft))
 
 				-- Update highscore
 				updateChallengeRecord("Highscore", hhLeft)
@@ -292,9 +295,9 @@
 function onGearDelete(gear)
 
 	if GetGearType(gear) == gtHedgehog then
-		if GetHogTeamName(gear) == loc("Hapless Hogs") then
+		if GetHogTeamName(gear) == haplessTeamName then
 			hhCount = hhCount - 1
-			AddCaption(string.format(loc("%d Hapless Hogs left"), hhCount))
+			AddCaption(string.format(loc("Hedgehogs left: %d"), hhCount))
 		end
 	end
 
@@ -308,7 +311,7 @@
 			SendStat(siCustomAchievement, loc("You haven't rescued anyone."))
 		end
 		SendStat(siPointType, loc("points"))
-		SendStat(siPlayerKills, "0", loc("Nameless Heroes"))
+		SendStat(siPlayerKills, "0", playerTeamName)
 		local highscore = tonumber(GetMissionVar("Highscore"))
 		show = (type(highscore) == "number") and (highscore > 0)
 		updateChallengeRecord("Highscore", 0, show)
--- a/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Bamboo_Thicket.lua	Thu Dec 20 15:53:22 2018 +0100
+++ b/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Bamboo_Thicket.lua	Thu Dec 20 17:51:46 2018 +0100
@@ -24,8 +24,8 @@
 	WaterRise = 0
 	GameFlags = gfDisableWind
 
-	AddTeam(loc("Pathetic Resistance"), -1, "Plinko", "Island", "Default", "cm_yinyang")
-	player = AddHog(loc("Ikeda"), 0, 10, "StrawHat")
+	AddMissionTeam(-1)
+	player = AddMissionHog(10)
 			
 	AddTeam(loc("Cybernetic Empire"), -6, "ring", "Island", "Robot", "cm_cyborg")
 	enemy = AddHog(loc("Unit 835"), 1, 10, "cyborg1")
--- a/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Dangerous_Ducklings.lua	Thu Dec 20 15:53:22 2018 +0100
+++ b/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Dangerous_Ducklings.lua	Thu Dec 20 17:51:46 2018 +0100
@@ -30,8 +30,8 @@
 	HealthDecrease = 0
 	WaterRise = 0
 
-	AddTeam(loc("Bloody Rookies"), -1, "Rubberduck", "Island", "Default", "cm_duckhead")
-	player = AddHog(loc("Hunter"), 0, 1, "NoHat")
+	AddMissionTeam(-1)
+	player = AddMissionHog(1)
 	instructor = AddHog(loc("Instructor"), 0, 100, "sf_vega")
 
 	AddTeam(loc("Blue Team"), -2, "bubble", "Island", "Default", "somalia")
@@ -54,7 +54,7 @@
 
 	FollowGear(player)
 
-	ShowMission(loc("Dangerous Ducklings"), loc("Scenario"), loc("Eliminate the Blue Team before the time runs out."), -amRope, 5000);
+	ShowMission(loc("Dangerous Ducklings"), loc("Scenario"), loc("Eliminate the enemy before the time runs out."), -amRope, 5000);
 
 end
 
@@ -114,7 +114,7 @@
 			if endTimer >= 3000 then
 				--SetHealth(instructor,0)
 				SetTurnTimeLeft(1)
-				DismissTeam(loc("Bloody Rookies"))
+				DismissTeam(GetHogTeamName(player))
 			end
 			ShowMission(loc("Dangerous Ducklings"), loc("MISSION FAILED"), loc("You've failed. Try again."), -amRope, 5000);
 		end
@@ -137,7 +137,7 @@
 			HogSay(player, loc("See ya!"), SAY_THINK)
 			Retreat(3000)
 			awardAchievement(loc("Naughty Ninja"))
-			DismissTeam(loc("Blue Team"))
+			DismissTeam(GetHogTeamName(enemy))
 			gameWon = true
 			SaveMissionVar("Won", "true")
 		elseif gear == enemy then
--- a/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Diver.lua	Thu Dec 20 15:53:22 2018 +0100
+++ b/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Diver.lua	Thu Dec 20 17:51:46 2018 +0100
@@ -26,8 +26,8 @@
 	HealthDecrease = 0
 	WaterRise = 0
 
-	AddTeam(loc("Bloody Rookies"), -1, "deadhog", "Island", "Default", "cm_eyes")
-	player = AddHog(loc("Hunter"), 0, 1, "NoHat")
+	AddMissionTeam(-1)
+	player = AddMissionHog(1)
 			
 	AddTeam(loc("Toxic Team"), -6, "skull", "Island", "Default", "cm_magicskull")
 	enemy = AddHog(loc("Poison"), 1, 100, "Skull")
--- a/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Spooky_Tree.lua	Thu Dec 20 15:53:22 2018 +0100
+++ b/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Spooky_Tree.lua	Thu Dec 20 17:51:46 2018 +0100
@@ -29,8 +29,8 @@
 	HealthDecrease = 0
 	WaterRise = 0
 
-	AddTeam(loc("Bloody Rookies"), -1, "deadhog", "Island", "Default", "cm_eyes")
-	player = AddHog(loc("Hunter"), 0, 1, "NoHat")
+	AddMissionTeam(-1)
+	player = AddMissionHog(1)
 	AddTeam(loc("Toxic Team"), -6, "skull", "Island", "Default", "cm_magicskull")
 	enemy = AddHog(loc("Poison"), 1, 10, "Skull")
 
--- a/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Teamwork.lua	Thu Dec 20 15:53:22 2018 +0100
+++ b/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Teamwork.lua	Thu Dec 20 17:51:46 2018 +0100
@@ -24,9 +24,10 @@
 	HealthDecrease = 0
 	WaterRise = 0
 
-	AddTeam(playerTeamName, -1, "Statue", "Island", "Default", "cm_kiwi")
-	player = AddHog(loc("Greg"), 0, 50, "NoHat")
-	p2 = AddHog(loc("Mark"), 0, 20, "NoHat")
+	local idx = AddMissionTeam(-1)
+	playerTeamName = GetTeamName(idx)
+	player = AddMissionHog(50)
+	p2 = AddMissionHog(20)
 
 	AddTeam(loc("Cybernetic Empire"), -6, "ring", "Island", "Robot", "cm_cyborg")
 	enemy = AddHog(loc("Unit 3378"), 5, 30, "cyborg1")
--- a/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Teamwork_2.lua	Thu Dec 20 15:53:22 2018 +0100
+++ b/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Teamwork_2.lua	Thu Dec 20 17:51:46 2018 +0100
@@ -9,7 +9,7 @@
 local Pack = nil
 local help = false
 local GameOver = false
-local playerTeamName = loc("Feeble Resistance")
+local playerTeamName
 
 function onGameInit()
 	Seed = 0
@@ -26,9 +26,10 @@
 	Map = "CrazyMission"
 	Theme = "CrazyMission"
 
-	AddTeam(playerTeamName, -1, "Statue", "Island", "Default", "cm_kiwi")
-	player = AddHog(loc("Greg"), 0, 30, "NoHat")
-	hlayer = AddHog(loc("Mark"), 0, 40, "NoHat")
+	local idx = AddMissionTeam(-1)
+	playerTeamName = GetTeamName(idx)
+	player = AddMissionHog(30)
+	hlayer = AddMissionHog(40)
 
 	AddTeam(loc("Cybernetic Empire"), -6, "ring", "Island", "Robot", "cm_binary")
 	enemy = AddHog(loc("WatchBot 4000"), 5, 50, "cyborg1")
--- a/share/hedgewars/Data/Missions/Scenario/portal.lua	Thu Dec 20 15:53:22 2018 +0100
+++ b/share/hedgewars/Data/Missions/Scenario/portal.lua	Thu Dec 20 17:51:46 2018 +0100
@@ -19,8 +19,8 @@
 	HealthDecrease = 0
 	WaterRise = 0
 
-	AddTeam(loc("Subjects"), -9, "Simple", "Island", "Default", "cm_test")
-	player = AddHog(loc("Subject 1"), 0, 10, "Terminator_Glasses")
+	AddMissionTeam(-9)
+	player = AddMissionHog(10)
 
 	AddTeam(loc("Hell Army"), -1, "skull", "Island", "Default", "cm_hellish")
 	enemy1 = AddHog(loc("Lucifer"), 1, 200, "InfernalHorns")