Use player-chosen team identity for training and a few challenges
authorWuzzy <Wuzzy2@mail.ru>
Wed, 19 Dec 2018 20:56:10 +0100
changeset 14485 208359558642
parent 14484 4e5280a9e782
child 14486 65b25ca6ff31
Use player-chosen team identity for training and a few challenges
ChangeLog.txt
share/hedgewars/Data/Missions/Challenge/Basic_Training_-_Sniper_Rifle.lua
share/hedgewars/Data/Missions/Challenge/ClimbHome.lua
share/hedgewars/Data/Missions/Challenge/User_Mission_-_RCPlane_Challenge.lua
share/hedgewars/Data/Missions/Training/Basic_Training_-_Bazooka.lua
share/hedgewars/Data/Missions/Training/Basic_Training_-_Flying_Saucer.lua
share/hedgewars/Data/Missions/Training/Basic_Training_-_Grenade.lua
share/hedgewars/Data/Missions/Training/Basic_Training_-_Movement.lua
share/hedgewars/Data/Missions/Training/Basic_Training_-_Rope.lua
share/hedgewars/Data/Scripts/SpeedShoppa.lua
share/hedgewars/Data/Scripts/TargetPractice.lua
--- a/ChangeLog.txt	Wed Dec 19 20:34:07 2018 +0100
+++ b/ChangeLog.txt	Wed Dec 19 20:56:10 2018 +0100
@@ -28,6 +28,7 @@
  + New return value: AddTeam and AddMissionTeam return team index of new team
  + Utils library: New calls: getReadableChallengeRecord, updateChallengeRecord
  + New callback: onGameResult(winningClan): Called when the game ends normally. winningClan = index of winning clan or -1 on draw
+ + SpeedShoppa/TargetPractice libraries: Remove custom hog and team info settings
  + Params explode, poison in the SpawnFake*Crate functions now optional and default to false
 
 ====================== 0.9.25 ======================
--- a/share/hedgewars/Data/Missions/Challenge/Basic_Training_-_Sniper_Rifle.lua	Wed Dec 19 20:34:07 2018 +0100
+++ b/share/hedgewars/Data/Missions/Challenge/Basic_Training_-_Sniper_Rifle.lua	Wed Dec 19 20:56:10 2018 +0100
@@ -53,7 +53,7 @@
 local delayedTargetTargetX, delayedTargetY
 
 -- Team name of the player's team
-local playerTeamName = loc("Sniperz")
+local playerTeamName
 
 -- This is a custom function to make it easier to
 -- spawn more targets with just one line of code
@@ -133,9 +133,10 @@
 	HealthDecrease = 0
 
 	-- Create the player team
-	AddTeam(playerTeamName, -1, "Simple", "Island", "Default", "cm_crosshair")
+	AddMissionTeam(-1)
+	playerTeamName = GetTeamName(0)
 	-- And add a hog to it
-	player = AddHog(loc("Hunter"), 0, 1, "Sniper")
+	player = AddMissionHog(1)
 	SetGearPosition(player, 602, 1465)
 end
 
--- a/share/hedgewars/Data/Missions/Challenge/ClimbHome.lua	Wed Dec 19 20:34:07 2018 +0100
+++ b/share/hedgewars/Data/Missions/Challenge/ClimbHome.lua	Wed Dec 19 20:56:10 2018 +0100
@@ -23,8 +23,8 @@
     Explosives = 0
     MineDudPercent = 0
     Map = "ClimbHome"
-    AddTeam(loc("Lonely Hog"), -1, "bubble", "Island", "Default")
-    player = AddHog(loc("Climber"), 0, 1, "NoHat")
+    AddMissionTeam(-1)
+    player = AddMissionHog(1)
     if showWaterStats then
         dummyHog = AddHog(" ", 0, 1, "NoHat")
         HH[dummyHog] = nil
--- a/share/hedgewars/Data/Missions/Challenge/User_Mission_-_RCPlane_Challenge.lua	Wed Dec 19 20:34:07 2018 +0100
+++ b/share/hedgewars/Data/Missions/Challenge/User_Mission_-_RCPlane_Challenge.lua	Wed Dec 19 20:56:10 2018 +0100
@@ -35,8 +35,8 @@
 	MinesNum = 0
 	Explosives = 0
 
-	AddTeam(loc("Wannabe Flyboys"), -1, "Simple", "Island", "Default", "cm_scout")
-	player = AddHog(loc("Ace"), 0, 80, "Gasmask")
+	AddMissionTeam(-1)
+	player = AddMissionHog(80)
 	SetGearPosition(player, 1380, 1500)
 
 end
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Bazooka.lua	Wed Dec 19 20:34:07 2018 +0100
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Bazooka.lua	Wed Dec 19 20:56:10 2018 +0100
@@ -47,8 +47,8 @@
 
 	------ TEAM LIST ------
 
-	AddTeam(loc("Bazooka Team"), -1, "Flower", "Earth", "Default", "hedgewars")
-	hog = AddHog(loc("Greenhorn"), 0, 100, "NoHat")
+	AddMissionTeam(-1)
+	hog = AddMissionHog(100)
 	SetGearPosition(hog, 1485, 2001)
 	SetEffect(hog, heResurrectable, 1)
 
@@ -228,7 +228,7 @@
 		end
 		SendStat(siCustomAchievement, loc("Good job!"))
 		SendStat(siGameResult, loc("You have completed the Basic Bazooka Training!"))
-		SendStat(siPlayerKills, "0", loc("Bazooka Team"))
+		SendStat(siPlayerKills, "0", GetHogTeamName(hog))
 		EndGame()
 		gameOver = true
 	end
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Flying_Saucer.lua	Wed Dec 19 20:34:07 2018 +0100
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Flying_Saucer.lua	Wed Dec 19 20:56:10 2018 +0100
@@ -209,7 +209,7 @@
 
 	SendStat(siGameResult, loc("You have finished the Flying Saucer Training!"))
 	SendStat(siCustomAchievement, loc("Good job!"))
-	SendStat(siPlayerKills, "0", loc("Hogonauts"))
+	SendStat(siPlayerKills, "0", GetHogTeamName(Player))
 
 	EndTurn(true)
 	EndGame()
@@ -397,11 +397,9 @@
 	WaterRise = 0
 	HealthDecrease = 0
 
-	-- Team name is a pun on “hedgehog” and “astronauts”
-	AddTeam( loc( "Hogonauts" ), -9, "earth", "Earth", "Default", "cm_galaxy" )
+	AddMissionTeam(-9)
 
-	-- Hedgehog name is a pun on “Neil Armstrong”
-	Player = AddHog( loc( "Neil Hogstrong" ), 0, 1, "NoHat" )
+	Player = AddMissionHog(1)
 	SetGearPosition( Player, StartPos.X, StartPos.Y)
 	SetEffect( Player, heResurrectable, 1 )
 end
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Grenade.lua	Wed Dec 19 20:34:07 2018 +0100
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Grenade.lua	Wed Dec 19 20:56:10 2018 +0100
@@ -39,8 +39,8 @@
 
 	------ TEAM LIST ------
 
-	AddTeam(loc("Grenade Team"), -1, "Flower", "Earth", "Default", "cm_grenade")
-	hog = AddHog(loc("Greenhorn"), 0, 1, "NoHat")
+	AddMissionTeam(-1)
+	hog = AddMissionHog(1)
 	SetGearPosition(hog, 570, 157)
 	SetEffect(hog, heResurrectable, 1)
 
@@ -203,7 +203,7 @@
 		end
 		SendStat(siCustomAchievement, loc("Good job!"))
 		SendStat(siGameResult, loc("You have completed the Basic Grenade Training!"))
-		SendStat(siPlayerKills, "0", loc("Grenade Team"))
+		SendStat(siPlayerKills, "0", GetHogTeamName(hog))
 		EndGame()
 		gameOver = true
 	end
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Movement.lua	Wed Dec 19 20:34:07 2018 +0100
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Movement.lua	Wed Dec 19 20:56:10 2018 +0100
@@ -115,18 +115,18 @@
 	drawMap()
 
 	------ HOG LIST ------
-	AddTeam(loc("Training Team"), -1, "deadhog", "SteelTower", "Default", "hedgewars")
+	AddMissionTeam(-1)
 	
-	hhs[1] = AddHog(loc("Greenhorn"), 0, 100, "NoHat")
+	hhs[1] = AddMissionHog(100)
 	SetGearPosition(hhs[1], 404, 1714)
 	SetEffect(hhs[1], heResurrectable, 1)
 
-	hhs[2] = AddHog(loc("Rhombus"), 0, 100, "NoHat")
+	hhs[2] = AddMissionHog(100)
 	SetGearPosition(hhs[2], 620, 1538)
 	SetEffect(hhs[2], heResurrectable, 1)
 	HogTurnLeft(hhs[2], true)
 
-	hhs[3] = AddHog(loc("Trapped"), 0, 100, "NoHat")
+	hhs[3] = AddMissionHog(100)
 	SetGearPosition(hhs[3], 1573, 1824)
 	SetEffect(hhs[3], heResurrectable, 1)
 	
@@ -135,12 +135,23 @@
 	SetEffect(hhs[4], heResurrectable, 1)
 	HogTurnLeft(hhs[4], true)
 	
-	hhs[5] = AddHog(loc("Ice"), 0, 100, "NoHat")
+	hhs[5] = AddMissionHog(100)
 	SetGearPosition(hhs[5], 1813, 1285)
 	SetEffect(hhs[5], heResurrectable, 1)
 
 	hog_greenhorn = hhs[1]
 	hog_cappy = hhs[4]
+
+	for i=1,#hhs do
+		if hhs[i] ~= hog_cappy then
+			if GetHogName(hhs[i]) == loc("Cappy") then
+				SetHogName(hhs[i], loc("Greenhorn"))
+			end
+			if GetHogHat(hhs[i]) == "cap_red" then
+				SetHogHat(hhs[i], "NoHat")
+			end
+		end
+	end
 	
 	SendHealthStatsOff()
 end
@@ -254,7 +265,7 @@
 	SendStat(siGameResult, loc("You have completed the Basic Movement Training!"))
 	SendStat(siCustomAchievement, loc("Congratulations!"))
 	SendStat(siCustomAchievement, loc("Return to the training menu by pressing the “Go back” button."))
-	SendStat(siPlayerKills, "0", loc("Training Team"))
+	SendStat(siPlayerKills, "0", GetHogTeamName(hog_greenhorn))
 	PlaySound(sndVictory, CurrentHedgehog)
 	-- Disable controls, end game
 	SetInputMask(0)
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Rope.lua	Wed Dec 19 20:34:07 2018 +0100
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Rope.lua	Wed Dec 19 20:56:10 2018 +0100
@@ -96,8 +96,8 @@
 	WaterRise = 0
 	HealthDecrease = 0
 
-	AddTeam(teamName, -1, "Plinko", "Snail", "Default", "cm_yinyang")
-	hog = AddHog(loc("Roper"), 0, initHogHealth, "StrawHat")
+	AddMissionTeam(-1)
+	hog = AddMissionHog(initHogHealth)
 	SetGearPosition(hog, cpX, cpY)
 	SetEffect(hog, heResurrectable, 1)
 
--- a/share/hedgewars/Data/Scripts/SpeedShoppa.lua	Wed Dec 19 20:34:07 2018 +0100
+++ b/share/hedgewars/Data/Scripts/SpeedShoppa.lua	Wed Dec 19 20:56:10 2018 +0100
@@ -45,11 +45,6 @@
 
 	optional fields:
 	- missionTitle:		the name of the mission (optional but highly recommended) (default: "Speed Shoppa")
-	- hogHat:		hat of the hedgehog (default: "NoHat")
-	- hogName:		name of the hedgehog (default: "Roper")
-	- teamName:		name of the hedgehog’s team (default: "Shoppers")
-	- teamGrave:		name of the hedgehog’s grave (default: "Statue")
-	- teamFlag:		name of the team’s flag (default: "cm_shoppa")
 	- clanColor:		color of the (only) clan (default: -1, default first clan color)
 	- goalText:		A short string explaining the goal of the mission
 				(default: "Use your rope to collect all crates as fast as possible.")
@@ -74,14 +69,9 @@
 local crates
 
 function SpeedShoppaMission(params)
-	if params.hogHat == nil then params.hogHat = "NoHat" end
-	if params.hogName == nil then params.hogName = loc("Roper") end
-	if params.teamName == nil then params.teamName = loc("Shoppers") end
 	if params.goalText == nil then params.goalText = loc("Use your rope to collect all crates as fast as possible.") end
 	if params.missionTitle == nil then params.missionTitle = loc("Speed Shoppa") end
 	if params.clanColor == nil then params.clanColor = -1 end
-	if params.teamGrave == nil then params.teamGrave = "Statue" end
-	if params.teamFlag == nil then params.teamFlag = "cm_shoppa" end
 	if params.extra_onGameInit == nil then params.extra_onGameInit = function() end end
 	if params.extra_onGameStart == nil then params.extra_onGameStart = function() end end
 	if params.faceLeft == nil then params.faceLeft = false end
@@ -101,8 +91,8 @@
 		WaterRise = 0
 		HealthDecrease = 0
 	
-		AddTeam(params.teamName, params.clanColor, params.teamGrave, "Castle", "Default", params.teamFlag)
-		playerHog = AddHog(params.hogName, 0, 1, params.hogHat)
+		AddMissionTeam(params.clanColor)
+		playerHog = AddMissionHog(1)
 		HogTurnLeft(playerHog, params.faceLeft)
 		
 		SetGearPosition(playerHog, params.hog_x, params.hog_y)
@@ -119,7 +109,7 @@
 		local append = getReadableChallengeRecord("TimeRecord")
 		ShowMission(params.missionTitle, loc("Challenge"), params.goalText .. "|" .. append, -amRope, 5000)
 		-- <crates collected>/<total number of crates>
-		SetTeamLabel(params.teamName, string.format(loc("%d/%d"), cratesCollected, #crates))
+		SetTeamLabel(GetHogTeamName(playerHog), string.format(loc("%d/%d"), cratesCollected, #crates))
 		for i=1,#crates do
 			spawnCrate(crates[i].x, crates[i].y)
 		end
@@ -134,7 +124,7 @@
 		if GetGearType(gear) == gtCase and not hogHurt and not timeOut then
 			cratesCollected = cratesCollected + 1
 			-- <crates collected>/<total number of crates>
-			SetTeamLabel(params.teamName, string.format(loc("%d/%d"), cratesCollected, #crates))
+			SetTeamLabel(GetHogTeamName(playerHog), string.format(loc("%d/%d"), cratesCollected, #crates))
 			PlaySound(sndShotgunReload)
 			if cratesCollected == #crates then
 				endTime = TurnTimeLeft
@@ -175,14 +165,14 @@
 				SendStat(siGameResult, loc("Challenge completed!"))
 				SendStat(siPointType, loc("milliseconds"))
 				local time = startTime - endTime
-				SendStat(siPlayerKills, tostring(time), params.teamName)
+				SendStat(siPlayerKills, tostring(time), GetHogTeamName(playerHog))
 				SendStat(siCustomAchievement, string.format(loc("You have finished the challenge in %.3f s."), (time/1000)))
 				SetTurnTimeLeft(0)
 				updateChallengeRecord("TimeRecord", time)
 			else
 				SendStat(siGameResult, loc("Challenge failed!"))
 				SendStat(siPointType, loc("crate(s)"))
-				SendStat(siPlayerKills, tostring(cratesCollected), params.teamName)
+				SendStat(siPlayerKills, tostring(cratesCollected), GetHogTeamName(playerHog))
 				SendStat(siCustomAchievement, string.format(loc("You have collected %d out of %d crate(s)."), cratesCollected, #crates))
 			end
 			gameEnded = true
--- a/share/hedgewars/Data/Scripts/TargetPractice.lua	Wed Dec 19 20:34:07 2018 +0100
+++ b/share/hedgewars/Data/Scripts/TargetPractice.lua	Wed Dec 19 20:56:10 2018 +0100
@@ -43,10 +43,6 @@
 	wind = ,
 	solidLand = ,
 	artillery = ,
-	hogHat = ,
-	hogName = ,
-	teamName = ,
-	teamGrave = ,
 	clanColor = ,
 	goalText = ,
 	shootText =
@@ -96,11 +92,6 @@
 	- wind:		the initial wind (-100 to 100) (default: 0 (no wind))
 	- solidLand:	weather the terrain is indestructible (default: false)
 	- artillery:	if true, the hog can’t move (default: false)
-	- hogHat:	hat of the hedgehog (default: "NoHat")
-	- hogName:	name of the hedgehog (default: "Trainee")
-	- teamName:	name of the hedgehog’s team (default: "Training Team")
-	- teamGrave:	name of the hedgehog’s grave
-	- teamFlag:	name of the team’s flag (default: "cm_crosshair")
 	- secGearType:	cluster of projectile gear (if present) (used to re-center camera)
 	- clanColor:	color of the (only) clan (default: -1, default first clan color)
 	- goalText:	A short string explaining the goal of the mission
@@ -115,14 +106,9 @@
 end
 
 function TargetPracticeMission(params)
-	if params.hogHat == nil then params.hogHat = "NoHat" end
-	if params.hogName == nil then params.hogName = loc("Trainee") end
-	if params.teamName == nil then params.teamName = loc("Training Team") end
 	if params.goalText == nil then params.goalText = loc("Eliminate all targets before your time runs out.|You have unlimited ammo for this mission.") end
 	if params.shootText == nil then params.shootText = loc("You have shot %d times.") end
 	if params.clanColor == nil then params.clanColor = -1 end
-	if params.teamGrave == nil then params.teamGrave= "Statue" end
-	if params.teamFlag == nil then params.teamFlag = "cm_crosshair" end
 	if params.wind == nil then params.wind = 0 end
 
 	local solid, artillery
@@ -160,9 +146,9 @@
 
 		SetWind(params.wind)
 
-		AddTeam(loc(params.teamName), params.clanColor, params.teamGrave, "Flowerhog", "Default", params.teamFlag)
+		AddMissionTeam(params.clanColor)
 
-		player = AddHog(loc(params.hogName), 0, 1, params.hogHat)
+		player = AddMissionHog(1)
 		SetGearPosition(player, params.hog_x, params.hog_y)
 	end
 
@@ -170,7 +156,7 @@
 		SendHealthStatsOff()
 		local recordInfo = getReadableChallengeRecord("Highscore")
 		ShowMission(params.missionTitle, loc("Aiming practice"), params.goalText .. "|" .. recordInfo, -params.ammoType, 5000)
-		SetTeamLabel(params.teamName, "0")
+		SetTeamLabel(GetHogTeamName(player), "0")
 		spawnTarget()
 	end
 
@@ -240,7 +226,7 @@
 	_G.onGearDamage = function(gear, damage)
 		if GetGearType(gear) == gtTarget then
 			scored = scored + 1
-			SetTeamLabel(params.teamName, tostring(getTargetsScore()))
+			SetTeamLabel(GetHogTeamName(player), tostring(getTargetsScore()))
 			if scored < total_targets then
 				AddCaption(string.format(loc("Targets left: %d"), (total_targets-scored)), capcolDefault, capgrpMessage)
 				spawnTarget()
@@ -299,7 +285,7 @@
 			local end_score_time = math.ceil(time_goal/(params.time/6000))
 			local end_score_accuracy = math.ceil(accuracy * 60)
 			end_score_overall = end_score_time + end_score_targets + end_score_accuracy
-			SetTeamLabel(params.teamName, tostring(end_score_overall))
+			SetTeamLabel(GetHogTeamName(player), tostring(end_score_overall))
 
 			SendStat(siGameResult, loc("You have finished the target practice!"))
 
@@ -318,7 +304,7 @@
 			end_score_overall = end_score_targets
 		end
 		SendStat(siPointType, loc("point(s)"))
-		SendStat(siPlayerKills, tostring(end_score_overall), loc(params.teamName))
+		SendStat(siPlayerKills, tostring(end_score_overall), GetHogTeamName(player))
 		-- Update highscore
 		updateChallengeRecord("Highscore", end_score_overall)
 	end