Refactor ACF missions, store team names in variables
authorWuzzy <Wuzzy2@mail.ru>
Fri, 21 Dec 2018 01:04:24 +0100
changeset 14506 f37910a73c19
parent 14505 764ba6182389
child 14507 f8c2b995c009
Refactor ACF missions, store team names in variables
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/dragon.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/epil.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/family.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/first_blood.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/queen.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/united.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua	Thu Dec 20 19:03:34 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua	Fri Dec 21 01:04:24 2018 +0100
@@ -143,6 +143,11 @@
 highJumped = false
 TurnsLeft = 0
 startNativesNum = 0
+nativesTeamName = nil
+tribeTeamName = nil
+cyborgTeamName = nil
+cannibalsTeamName1 = nil
+cannibalsTeamName2 = nil
 
 startAnim = {}
 afterChoiceAnim = {}
@@ -680,9 +685,9 @@
 
 function DoDeployedDead()
   ShowMission(loc("Backstab"), loc("Brutus"), loc("You have failed to save the tribe!"), 0, 6000)
-  DismissTeam(loc("Natives"))
-  DismissTeam(loc("Tribe"))
-  DismissTeam(loc("011101001"))
+  DismissTeam(nativesTeamName)
+  DismissTeam(tribeTeamName)
+  DismissTeam(cyborgTeamName)
   EndTurn(true)
 end
 
@@ -725,8 +730,8 @@
 
 function DoKilledOther()
   ShowMission(loc("Backstab"), loc("Brutus"), loc("You have killed an innocent hedgehog!"), 0, 6000)
-  DismissTeam(loc("Natives"))
-  DismissTeam(loc("Tribe"))
+  DismissTeam(nativesTeamName)
+  DismissTeam(tribeTeamName)
   EndTurn(true)
 end
 
@@ -833,10 +838,10 @@
     end
   end
 
-  DismissTeam(loc("Tribe"))
-  DismissTeam(loc("Assault Team"))
-  DismissTeam(loc("Reinforcements"))
-  DismissTeam(loc("011101001"))
+  DismissTeam(tribeTeamName)
+  DismissTeam(cannibalsTeamName1)
+  DismissTeam(cannibalsTeamName2)
+  DismissTeam(cyborgTeamName)
   EndTurn(true)
 end
 
@@ -956,28 +961,28 @@
 end
 
 function AddHogs()
-  AddTeam(loc("Tribe"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
+  tribeTeamName = AddTeam(loc("Tribe"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
   for i = 8, 9 do
     natives[i] = AddHog(nativeNames[i], 0, 100, nativeHats[i])
   end
 
-  AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
+  nativesTeamName = AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
   for i = 1, 7 do
     natives[i] = AddHog(nativeNames[i], 0, 100, nativeHats[i])
   end
   nativesNum = 7
 
-  AddTeam(loc("Assault Team"), -1, "skull", "Island", "Pirate", "cm_vampire")
+  cannibalsTeamName1 = AddTeam(loc("Assault Team"), -1, "skull", "Island", "Pirate", "cm_vampire")
   for i = 1, 6 do
     cannibals[i] = AddHog(cannibalNames[i], 3, 50, "vampirichog")
   end
 
-  AddTeam(loc("Reinforcements"), -1, "skull", "Island", "Pirate", "cm_vampire")
+  cannibalsTeamName2 = AddTeam(loc("Reinforcements"), -1, "skull", "Island", "Pirate", "cm_vampire")
   for i = 7, 9 do
     cannibals[i] = AddHog(cannibalNames[i], 2, 50, "vampirichog")
   end
 
-  AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot", "cm_binary")
+  cyborgTeamName = AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot", "cm_binary")
   cyborg = AddHog(loc("Unit 334a$7%;.*"), 0, 200, "cyborg1")
 
   for i = 1, 9 do
@@ -1118,13 +1123,13 @@
     AddCaption(string.format(loc("Turns until arrival: %d"), TurnsLeft))
   end
   if deployedHog then
-    if GetHogTeamName(CurrentHedgehog) == loc("Natives") then
+    if GetHogTeamName(CurrentHedgehog) == nativesTeamName then
       AnimSwitchHog(deployedHog)
     end
   end
 
   if stage == spyKillStage then
-    if GetHogTeamName(CurrentHedgehog) ~= loc("Natives") then
+    if GetHogTeamName(CurrentHedgehog) ~= nativesTeamName then
       EndTurn(true)
     else
       if CurrentHedgehog == spyHog then
@@ -1134,7 +1139,7 @@
       SetTurnTimeLeft(MAX_TURN_TIME)
     end
   else
-    if freshDead ~= nil and GetHogTeamName(CurrentHedgehog) == loc("Natives") then
+    if freshDead ~= nil and GetHogTeamName(CurrentHedgehog) == nativesTeamName then
       SetupHogDeadAnim(freshDead)
       AddAnim(hogDeadAnim)
       AddFunction({func = AfterHogDeadAnim, args = {}})
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/dragon.lua	Thu Dec 20 19:03:34 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/dragon.lua	Fri Dec 21 01:04:24 2018 +0100
@@ -170,6 +170,8 @@
 cyborgsPos = {{2937, 831}, {2945, 1264}, {2335, 1701}, {448, 484}}
 cyborgsDir = {"Left", "Left", "Left", "Right"}
 
+cyborgTeamName, fighterTeamName = nil, nil
+
 cratePos = {
             {{788, 1919, amGirder, 2}, true}, {{412, 1615, amGirder, 1}, true},
             {{209, 1474, amSniperRifle, 1}}, {{1178, 637, amDEagle, 1}},
@@ -631,11 +633,11 @@
     gearDead[natives[i]] = false
   end
 
-  AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot", "cm_binary")
+  cyborgTeamName = AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot", "cm_binary")
   cyborg = AddHog(loc("Unit 334a$7%;.*"), 0, 200, "cyborg1")
   gearDead[cyborg] = false
 
-  AddTeam(loc("011101000"), -9, "ring", "UFO", "Robot", "cm_binary")
+  fighterTeamName = AddTeam(loc("011101000"), -9, "ring", "UFO", "Robot", "cm_binary")
   for i = 1, 4 do
     cyborgs[i] = AddHog(cyborgNames[i], 2, 100, "cyborg2")
     gearDead[cyborgs[i]] = false
@@ -710,7 +712,7 @@
 function onGearDelete(gear)
   gearDead[gear] = true
   if GetGearType(gear) == gtHedgehog then
-    if GetHogTeamName(gear) == loc("011101000") then
+    if GetHogTeamName(gear) == fighterTeamName then
       freshDead = GetHogName(gear)
       cyborgsLeft = cyborgsLeft - 1
     end
@@ -740,13 +742,13 @@
     AddFunction({func = AfterStartAnim, args = {}})
     firstTurn = false
   end
-  if GetHogTeamName(CurrentHedgehog) == loc("011101000") then
+  if GetHogTeamName(CurrentHedgehog) == fighterTeamName then
     if TotalRounds % 6 == 0 then
       AddAmmo(CurrentHedgehog, amSniperRifle, 1)
       AddAmmo(CurrentHedgehog, amDEagle, 1)
     end
     SetTurnTimeLeft(30000)
-  elseif GetHogTeamName(CurrentHedgehog) == loc("011101001") then
+  elseif GetHogTeamName(CurrentHedgehog) == cyborgTeamName then
     EndTurn(true)
   end
 end
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua	Thu Dec 20 19:03:34 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua	Fri Dec 21 01:04:24 2018 +0100
@@ -78,6 +78,12 @@
 leaderPos = {3474, 151}
 leaderDir = "Left"
 
+cyborgTeamName = nil
+nativesTeamName = nil
+cannibalsTeamName = nil
+hedgecogsTeamName = nil
+leaderTeamName = nil
+
 -----------------------------Variables---------------------------------
 natives = {}
 origNatives = {}
@@ -419,9 +425,9 @@
 end
 
 function LoseMission()
-  DismissTeam(loc("Natives"))
-  DismissTeam(loc("Cannibals"))
-  DismissTeam(loc("011101001"))
+  DismissTeam(nativesTeamName)
+  DismissTeam(cannibalsTeamName)
+  DismissTeam(cyborgTeamName)
   EndTurn(true)
 end
 
@@ -437,7 +443,7 @@
   if progress and progress<9 then
     SaveCampaignVar("Progress", "9")
   end
-  DismissTeam(loc("011101001"))
+  DismissTeam(cyborgTeamName)
   EndTurn(true)
 end
 -----------------------------Misc--------------------------------------
@@ -519,10 +525,10 @@
 end
 
 function AddHogs()
-  AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot", "cm_binary")
+  cyborgTeamName = AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot", "cm_binary")
   cyborg = AddHog(loc("Unit 334a$7%;.*"), 0, 200, "cyborg1")
 
-  AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
+  nativesTeamName = AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
   -- There are 3-4 natives in this mission
   natives[1] = AddHog(nativeNames[leaksNum], 0, 100, nativeHats[leaksNum])
   if m5DeployedNum ~= leaksNum and m8DeployedLeader == 0 then
@@ -540,7 +546,7 @@
     table.insert(players, natives[i])
   end
 
-  AddTeam(loc("Cannibals"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
+  cannibalsTeamName = AddTeam(loc("Cannibals"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
   for i = 1, cannibalsNum do
     cannibals[i] = AddHog(cannibalNames[i], 0, 100, "Zombi")
     table.insert(players, cannibals[i])
@@ -548,13 +554,13 @@
   playersNum = #players
   playersLeft = playersNum
 
-  AddTeam(loc("Hedge-cogs"), -9, "ring", "UFO", "Robot", "cm_cyborg")
+  hedgecogsTeamName = AddTeam(loc("Hedge-cogs"), -9, "ring", "UFO", "Robot", "cm_cyborg")
   for i = 1, cyborgsNum do
     cyborgs[i] = AddHog(cyborgNames[i], 2, 80, "cyborg2")
   end
 
   if m8EnemyFled == 1 then
-    AddTeam(loc("Leader"), -9, "ring", "UFO", "Robot", "cm_cyborg")
+    leaderTeamName = AddTeam(loc("Leader"), -9, "ring", "UFO", "Robot", "cm_cyborg")
     if m8Scene == denseScene then
       leader = AddHog(loc("Dense Cloud"), 2, 200, nativeHats[denseNum])
     elseif m8Scene == waterScene then
@@ -628,7 +634,7 @@
 function onGearDelete(gear)
   gearDead[gear] = true
   if GetGearType(gear) == gtHedgehog then
-    if GetHogTeamName(gear) == loc("Natives") then
+    if GetHogTeamName(gear) == nativesTeamName then
       for i = 1, nativesLeft do
         if natives[i] == gear then
           table.remove(natives, i)
@@ -637,7 +643,7 @@
           playersLeft = playersLeft - 1
         end
       end
-    elseif GetHogTeamName(gear) == loc("Cannibals") then
+    elseif GetHogTeamName(gear) == cannibalsTeamName then
       for i = 1, cannibalsLeft do
         if cannibals[i] == gear then
           table.remove(cannibals, i)
@@ -646,7 +652,7 @@
           playersLeft = playersLeft - 1
         end
       end
-    elseif GetHogTeamName(gear) == loc("Hedge-cogs") then
+    elseif GetHogTeamName(gear) == hedgecogsTeamName then
       for i = 1, cyborgsLeft do
         if cyborgs[i] == gear then
           table.remove(cyborgs, i)
@@ -684,11 +690,11 @@
   elseif cyborgsDeadFresh then
     cyborgsDeadFresh = false
     WonMission()
-  elseif nativesDeadFresh and GetHogTeamName(CurrentHedgehog) == loc("Cannibals") then
-    AnimSay(CurrentHedgehog, loc("Your deaths will be avenged, Natives!"), SAY_SHOUT, 0)
+  elseif nativesDeadFresh and GetHogTeamName(CurrentHedgehog) == cannibalsTeamName then
+    AnimSay(CurrentHedgehog, string.format(loc("Your deaths will be avenged, %s!"), nativesTeamName), SAY_SHOUT, 0)
     nativesDeadFresh = false
-  elseif cannibalsDeadFresh and GetHogTeamName(CurrentHedgehog) == loc("Natives") then
-    AnimSay(CurrentHedgehog, loc("Your deaths will be avenged, Cannibals!"), SAY_SHOUT, 0)
+  elseif cannibalsDeadFresh and GetHogTeamName(CurrentHedgehog) == nativesTeamName then
+    AnimSay(CurrentHedgehog, string.format(loc("Your deaths will be avenged, %s!"), cannibalsTeamName), SAY_SHOUT, 0)
     cannibalsDeadFresh = false
   end
 end
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/epil.lua	Thu Dec 20 19:03:34 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/epil.lua	Fri Dec 21 01:04:24 2018 +0100
@@ -311,7 +311,7 @@
 end
 
 function AddHogs()
-	AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
+  AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
   for i = 1, 5 do
     natives[i] = AddHog(nativeNames[i], 0, 100, nativeHats[i])
   end
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/family.lua	Thu Dec 20 19:03:34 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/family.lua	Fri Dec 21 01:04:24 2018 +0100
@@ -104,6 +104,11 @@
               {3749, 1040}, {2475, 1338}, {3853, 881}}
 cyborgsDir = {"Left", "Left", "Left", "Left", "Left", "Right"}
 
+princessTeamName = nil
+nativesTeamName = nil
+biomechanicTeamName = nil
+cyborgTeamName = nil
+
 princessPos = {3737, 1181}
 crateConsts = {}
 reactions = {}
@@ -379,7 +384,7 @@
       SaveCampaignVar("Progress", "7")
     end
     princessFreed = true
-    DismissTeam(loc("011101001"))
+    DismissTeam(cyborgTeamName)
     EndTurn(true)
   end
 end
@@ -435,8 +440,8 @@
     RemoveEventFunc(CheckCloseToPrincess)
     RemoveEventFunc(CheckPrincessFreed)
     AddCaption(loc("So the princess was never heard of again ..."))
-    DismissTeam(loc("Natives"))
-    DismissTeam(loc("Princess"))
+    DismissTeam(nativesTeamName)
+    DismissTeam(princessTeamName)
     EndTurn(true)
   end
 end
@@ -519,22 +524,22 @@
 end
 
 function AddHogs()
-  AddTeam(loc("Princess"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
+  princessTeamName = AddTeam(loc("Princess"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
   princess = AddHog(loc("Fell From Heaven"), 0, 333, "tiara")
   SetGearAIHints(princess, aihDoesntMatter)
   gearDead[princess] = false
 
-  AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
+  nativesTeamName = AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
   for i = 7, 9 do
     natives[i-6] = AddHog(nativeNames[i], 0, 100, nativeHats[i])
     gearDead[natives[i-6]] = false
   end
 
-  AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot", "cm_binary")
+  cyborgTeamName = AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot", "cm_binary")
   cyborg = AddHog(loc("Unit 334a$7%;.*"), 0, 200, "cyborg1")
   gearDead[cyborg] = false
 
-  AddTeam(loc("Biomechanic Team"), -1, "ring", "UFO", "Robot", "cm_cyborg")
+  biomechanicTeamName = AddTeam(loc("Biomechanic Team"), -1, "ring", "UFO", "Robot", "cm_cyborg")
   for i = 1, cyborgsNum do
     cyborgs[i] = AddHog(cyborgNames[i], cyborgsDif[i], cyborgsHealth[i], "cyborg2")
     gearDead[cyborgs[i]] = false
@@ -613,7 +618,7 @@
 function onGearDelete(gear)
   gearDead[gear] = true
   if GetGearType(gear) == gtHedgehog then
-    if GetHogTeamName(gear) == loc("Biomechanic Team") then
+    if GetHogTeamName(gear) == biomechanicTeamName then
       cyborgsLeft = cyborgsLeft - 1
     end
   end
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/first_blood.lua	Thu Dec 20 19:03:34 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/first_blood.lua	Fri Dec 21 01:04:24 2018 +0100
@@ -747,8 +747,8 @@
 	Theme = "Nature"
 
 
-	AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
-	youngh = AddHog(loc("Leaks A Lot"), 0, 100, "Rambo")
+  AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
+  youngh = AddHog(loc("Leaks A Lot"), 0, 100, "Rambo")
   elderh = AddHog(loc("Righteous Beard"), 0, 99, "IndianChief")
   princess = AddHog(loc("Fell From Heaven"), 0, 300, "tiara")
   AnimSetGearPosition(princess, 1911, 1361)
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua	Thu Dec 20 19:03:34 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua	Fri Dec 21 01:04:24 2018 +0100
@@ -135,6 +135,11 @@
 TurnsLeft = 0
 stage = 0
 
+nativesTeamName = nil
+princessTeamName = nil
+cannibalsTeamName = nil
+cyborgTeamName = nil
+
 startAnimStarted = false
 blowTaken = false
 fireTaken = false
@@ -179,8 +184,8 @@
 
 --/////////////////////////Animation Functions///////////////////////
 function AfterMidFailAnim()
-  DismissTeam(loc("Natives"))
-  DismissTeam(loc("Princess"))
+  DismissTeam(nativesTeamName)
+  DismissTeam(princessTeamName)
   EndTurn(true)
 end
 
@@ -910,8 +915,8 @@
   if not princessDead then
     EndTurn(true)
     AddCaption(loc("The village, unprepared, was destroyed by the cyborgs..."))
-    DismissTeam(loc("Natives"))
-    DismissTeam(loc("Princess"))
+    DismissTeam(nativesTeamName)
+    DismissTeam(princessTeamName)
   end
 end
 
@@ -923,8 +928,8 @@
   if not princessDead then
     EndTurn(true)
     AddCaption(loc("The village, unprepared, was destroyed by the cyborgs..."))
-    DismissTeam(loc("Natives"))
-    DismissTeam(loc("Princess"))
+    DismissTeam(nativesTeamName)
+    DismissTeam(princessTeamName)
   end
 end
 
@@ -1012,8 +1017,8 @@
   if not (leaksDead or denseDead) then
     AddAnim(endFailAnim)
   end
-  AddFunction({func = DismissTeam, args = {loc("Natives")}})
-  AddFunction({func = DismissTeam, args = {loc("Princess")}})
+  AddFunction({func = DismissTeam, args = {nativesTeamName}})
+  AddFunction({func = DismissTeam, args = {princessTeamName}})
   AddFunction({func = EndTurn, args = {true}})
 end
 
@@ -1032,8 +1037,8 @@
 
 function FinishWon()
   SwitchHog(leaks)
-  DismissTeam(loc("Cannibal Sentry"))
-  DismissTeam(loc("011101001"))
+  DismissTeam(cannibalsTeamName)
+  DismissTeam(cyborgTeamName)
   EndTurn(true)
 end
 
@@ -1086,14 +1091,14 @@
 
   AnimInit(true)
 
-  AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
+  nativesTeamName = AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
   leaks = AddHog(loc("Leaks A Lot"), 0, 100, "Rambo")
   dense = AddHog(loc("Dense Cloud"), 0, 100, "RobinHood")
 
-  AddTeam(loc("Princess"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
+  princessTeamName = AddTeam(loc("Princess"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
   princess = AddHog(loc("Fell From Heaven"), 0, 200, "tiara")
 
-  AddTeam(loc("Cannibal Sentry"), -1, "skull", "Island", "Pirate","cm_vampire")
+  cannibalsTeamName = AddTeam(loc("Cannibal Sentry"), -1, "skull", "Island", "Pirate","cm_vampire")
   cannibals = {}
   for i = 1, 4 do
     cannibals[i] = AddHog(cannibalNames[i], 3, 40, "Zombi")
@@ -1107,7 +1112,7 @@
     SetEffect(cannibals[i], heArtillery, 1)
   end
 
-  AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot", "cm_binary")
+  cyborgTeamName = AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot", "cm_binary")
   cyborg = AddHog(loc("Y3K1337"), 0, 200, "cyborg1")
 
   AnimSetGearPosition(dense, 0, 0)
@@ -1196,7 +1201,7 @@
     AnimSwitchHog(leaks)
     SetGearMessage(leaks, 0)
     SetTurnTimeLeft(MAX_TURN_TIME)
-  elseif GetHogTeamName(CurrentHedgehog) ~= loc("Natives") then
+  elseif GetHogTeamName(CurrentHedgehog) ~= nativesTeamName then
     SetTurnTimeLeft(20000)
   else
     TurnsLeft = TurnsLeft - 1
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/queen.lua	Thu Dec 20 19:03:34 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/queen.lua	Fri Dec 21 01:04:24 2018 +0100
@@ -499,7 +499,7 @@
   if anim == startAnim then
     SetGearPosition(enemy, unpack(enemyPos))
   end
-  if GetHogTeamName(CurrentHedgehog) ~= loc("Natives") then
+  if GetHogTeamName(CurrentHedgehog) ~= nativesTeamName then
     EndTurn(true)
   end
   AnimWait(enemy, 1)
@@ -555,9 +555,9 @@
 
 function KillEnemy()
   if enemyFled == "1" then
-    DismissTeam(loc("Leaderbot"))
+    DismissTeam(leaderbotTeamName)
   end
-  DismissTeam(loc("011101001"))
+  DismissTeam(cyborgTeamName)
   EndTurn(true)
 end
 
@@ -722,8 +722,14 @@
   AddAmmo(natives[1], amMolotov, 0)
 end
 
+nativesTeamName = nil
+beepTeamName = nil
+corpTeamName = nil
+leaderbotTeamName = nil
+cyborgTeamName = nil
+
 function AddHogs()
-	AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
+  nativesTeamName = AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
   for i = 7, 9 do
     natives[i-6] = AddHog(nativeNames[i], 0, 100, nativeHats[i])
     origNatives[i-6] = natives[i-6]
@@ -732,21 +738,21 @@
   origNatives[4] = natives[4]
   nativesLeft = nativesNum
 
-  AddTeam(loc("Beep Loopers"), -1, "ring", "UFO", "Robot", "cm_cyborg")
+  beepTeamName = AddTeam(loc("Beep Loopers"), -1, "ring", "UFO", "Robot", "cm_cyborg")
   for i = 1, cyborgsTeamNum[1] do
     cyborgs[i] = AddHog(cyborgNames[i], cyborgsDif[i], cyborgsHealth[i], "cyborg2")
   end
 
-  AddTeam(loc("Corporationals"), -1, "ring", "UFO", "Robot", "cm_cyborg")
+  corpTeamName = AddTeam(loc("Corporationals"), -1, "ring", "UFO", "Robot", "cm_cyborg")
   for i = cyborgsTeamNum[1] + 1, cyborgsNum do
     cyborgs[i] = AddHog(cyborgNames[i], cyborgsDif[i], cyborgsHealth[i], "cyborg2")
   end
   cyborgsLeft = cyborgsTeamNum[1] + cyborgsTeamNum[2]
 
-  AddTeam(loc("Leaderbot"), -1, "ring", "UFO", "Robot", "cm_cyborg")
+  leaderbotTeamName = AddTeam(loc("Leaderbot"), -1, "ring", "UFO", "Robot", "cm_cyborg")
   enemy = AddHog(loc("Name"), 2, 200, "cyborg1")
 
-  AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot", "cm_binary")
+  cyborgTeamName = AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot", "cm_binary")
   cyborg = AddHog(loc("Unit 334a$7%;.*"), 0, 200, "cyborg1")
   SetGearPosition(cyborg, unpack(cyborgHidePos))
 
@@ -823,7 +829,7 @@
   local toRemove = nil
   gearDead[gear] = true
   if GetGearType(gear) == gtHedgehog then
-    if GetHogTeamName(gear) == loc("Beep Loopers") or GetHogTeamName(gear) == loc("Corporationals") then
+    if GetHogTeamName(gear) == beepTeamName or GetHogTeamName(gear) == corpTeamName then
       cyborgsLeft = cyborgsLeft - 1
     elseif GetHogTeamName(gear) == loc("Natives") then
       for i = 1, nativesLeft do
@@ -859,7 +865,7 @@
     SetTurnTimeLeft(MAX_TURN_TIME)
     return
   end
-  if GetHogTeamName(CurrentHedgehog) == loc("011101001") then
+  if GetHogTeamName(CurrentHedgehog) == cyborgTeamName then
     EndTurn(true)
   end
 end
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua	Thu Dec 20 19:03:34 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua	Fri Dec 21 01:04:24 2018 +0100
@@ -94,6 +94,9 @@
 
 HogNames = {loc("Brainiac"), loc("Corpsemonger"), loc("Femur Lover"), loc("Glark"), loc("Bonely"), loc("Rot Molester"), loc("Bloodrocutor"), loc("Muscle Dissolver"), loc("Bloodsucker")}
 
+nativesTeamName = nil
+weaklingsTeamName = nil
+
 ---POSITIONS---
 
 cannibalPos = {{3108, 1127}, 
@@ -614,13 +617,13 @@
 end
 
 function AddHogs()
-	AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
+  nativesTeamName = AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
   ramon = AddHog(loc("Ramon"), 0, 100, "rasta")
 	leaks = AddHog(loc("Leaks A Lot"), 0, 100, "Rambo")
   dense = AddHog(loc("Dense Cloud"), 0, 100, "RobinHood")
   spiky = AddHog(loc("Spiky Cheese"), 0, 100, "hair_yellow")
 
-  AddTeam(loc("Weaklings"), -1, "skull", "Island", "Pirate","cm_vampire")
+  weaklingsTeamName = AddTeam(loc("Weaklings"), -1, "skull", "Island", "Pirate","cm_vampire")
   cannibals = {}
   cannibals[1] = AddHog(loc("Brainiac"), 5, 20, "Zombi")
 
@@ -794,7 +797,7 @@
   AddAnim(stronglingsAnim)
   AddFunction({func = AfterStronglingsAnim, args = {}})
   stage = interWeakStage
-  DismissTeam(loc("Weaklings"))
+  DismissTeam(weaklingsTeamName)
 end
 
 function CheckRefuse()
@@ -1003,7 +1006,7 @@
   end
   AddCaption(loc("...and so the cyborgs took over the world..."))
   stage = loseStage
-  DismissTeam(loc("Natives"))
+  DismissTeam(nativesTeamName)
 end
 
 function CheckDenseDead()
@@ -1088,9 +1091,9 @@
 end
 
 function onGearAdd(gear)
-  if GetGearType(gear) == gtGrenade and GetHogTeamName(CurrentHedgehog) == loc("Natives") then
+  if GetGearType(gear) == gtGrenade and GetHogTeamName(CurrentHedgehog) == nativesTeamName then
     grenadeUsed = true
-  elseif GetGearType(gear) == gtShotgunShot and GetHogTeamName(CurrentHedgehog) == loc("Natives") then
+  elseif GetGearType(gear) == gtShotgunShot and GetHogTeamName(CurrentHedgehog) == nativesTeamName then
     shotgunUsed = true
   end
 end
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/united.lua	Thu Dec 20 19:03:34 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/united.lua	Fri Dec 21 01:04:24 2018 +0100
@@ -63,6 +63,10 @@
 startAnim = {}
 wave2Anim = {}
 finalAnim = {}
+
+nativesTeamName = nil
+cyborgTeamName = nil
+
 --------------------------Anim skip functions--------------------------
 function AfterHogDeadAnim()
   freshDead = nil
@@ -136,7 +140,7 @@
   if progress and progress<4 then
     SaveCampaignVar("Progress", "4")
   end
-  DismissTeam(loc("011101001"))
+  DismissTeam(cyborgTeamName)
   EndTurn(true)
 end
 -----------------------------Animations--------------------------------
@@ -323,8 +327,8 @@
 end
 
 function AddHogs()
-	AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
-	leaks = AddHog(loc("Leaks A Lot"), 0, 100, "Rambo")
+  nativesTeamName = AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
+  leaks = AddHog(loc("Leaks A Lot"), 0, 100, "Rambo")
   dense = AddHog(loc("Dense Cloud"), 0, 100, "RobinHood")
   water = AddHog(loc("Fiery Water"), 0, 100, "pirate_jack")
   buffalo = AddHog(loc("Raging Buffalo"), 0, 100, "zoo_Bunny")
@@ -342,7 +346,7 @@
     cannibals[i] = AddHog(HogNames[i], 2, 55, "vampirichog")
   end
 
-  AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot", "cm_binary")
+  cyborgTeamName = AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot", "cm_binary")
   cyborg = AddHog(loc("Unit 334a$7%;.*"), 0, 200, "cyborg1")
 
   AnimSetGearPosition(leaks,   unpack(leaksPos))
@@ -534,7 +538,7 @@
     SetTurnTimeLeft(MAX_TURN_TIME)
     return
   end
-  if freshDead ~= nil and GetHogTeamName(CurrentHedgehog) == loc("Natives") then
+  if freshDead ~= nil and GetHogTeamName(CurrentHedgehog) == nativesTeamName then
     SetupHogDeadAnim(freshDead)
     AddAnim(hogDeadAnim)
     AddFunction({func = AfterHogDeadAnim, args = {}})