TS: Scale health with the “initial health” setting from game scheme
authorWuzzy <Wuzzy2@mail.ru>
Sat, 05 Jan 2019 22:22:36 +0100
changeset 14544 e176bf229649
parent 14543 d0441c7e9000
child 14545 b5618fa33a49
TS: Scale health with the “initial health” setting from game scheme
share/hedgewars/Data/Scripts/Multiplayer/The_Specialists.lua
--- a/share/hedgewars/Data/Scripts/Multiplayer/The_Specialists.lua	Sat Jan 05 22:05:20 2019 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/The_Specialists.lua	Sat Jan 05 22:22:36 2019 +0100
@@ -160,52 +160,66 @@
 			currTeamIdx = currTeamIdx + 1;
 		end
 
+		-- Scale health of each hog with “initial health” setting from game scheme.
+		-- 100 = default health
+		-- 200 = double health for all hogs
+		-- 50 = half health for all hogs
+		local function scaleHealth(health)
+			local newHealth = div(health * InitHealth, 100)
+			-- At least 1 health
+			if newHealth <= 0 then
+				newHealth = 1
+			end
+			return newHealth
+		end
+
 		if teamRoles[currTeamIdx][z] == 'S' then
 
 			SetHogName(hhs[i],loc("Soldier"))
 			SetHogHat(hhs[i], "sf_vega")
-			SetHealth(hhs[i],200)
+			SetHealth(hhs[i], scaleHealth(200))
 
 		elseif teamRoles[currTeamIdx][z] == 'E' then
 
 			SetHogHat(hhs[i], "Glasses")
 			SetHogName(hhs[i],loc("Engineer"))
+			SetHealth(hhs[i], scaleHealth(100))
 
 		elseif teamRoles[currTeamIdx][z] == 'N' then
 
 			SetHogName(hhs[i],loc("Ninja"))
 			SetHogHat(hhs[i], "NinjaFull")
-			SetHealth(hhs[i],80)
+			SetHealth(hhs[i], scaleHealth(80))
 
 		elseif teamRoles[currTeamIdx][z] == 'D' then
 
 			SetHogName(hhs[i],loc("Demo"))
 			SetHogHat(hhs[i], "Skull")
-			SetHealth(hhs[i],200)
+			SetHealth(hhs[i], scaleHealth(200))
 
 		elseif teamRoles[currTeamIdx][z] == 'I' then
 
 			SetHogName(hhs[i],loc("Sniper"))
 			SetHogHat(hhs[i], "Sniper")
-			SetHealth(hhs[i],120)
+			SetHealth(hhs[i], scaleHealth(120))
 
 		elseif teamRoles[currTeamIdx][z] == 'A' then
 
 			SetHogName(hhs[i],loc("Saint"))
 			SetHogHat(hhs[i], "angel")
-			SetHealth(hhs[i],300)
+			SetHealth(hhs[i], scaleHealth(300))
 
 		elseif teamRoles[currTeamIdx][z] == 'P' then
 
 			SetHogName(hhs[i],loc("Pyro"))
 			SetHogHat(hhs[i], "Gasmask")
-			SetHealth(hhs[i],150)
+			SetHealth(hhs[i], scaleHealth(150))
 
 		elseif teamRoles[currTeamIdx][z] == 'L' then
 
 			SetHogName(hhs[i],loc("Loon"))
 			SetHogHat(hhs[i], "clown")
-			SetHealth(hhs[i],100)
+			SetHealth(hhs[i], scaleHealth(100))
 
 		end