A Classic Fairytale: Harden all missions against missing campaign variables in team file and assume default values
This assumes the worst case in which the team file is missing all campaign variables except Progress.
This has been successfully tested with all 10 missions and still generates a logical storyline.
By default, the game assumes:
- The cyborg's offer in mission 2 was refused
- The traitor in mission 5 was killed
As a consequence, missions 8 and 10 use the princessScene cut scene.
--- a/ChangeLog.txt Fri Mar 09 18:03:59 2018 +0100
+++ b/ChangeLog.txt Fri Mar 09 19:05:59 2018 +0100
@@ -73,6 +73,7 @@
+ Mission 2, Mission 5: Reduce computer hog levels
+ Mission 6: Change mines
* Fix incorrect storytelling in mission descriptions
+ * Missions now work even with corrupted team file, by using a default behaviour
* Mission 1: Fix error message spam when Leaks a Lot drowns
* Mission 3: Fix cannibals sometimes doing nothing for a full turn
* Mission 6: Fix cyborgs sometimes doing nothing for a full turn
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua Fri Mar 09 18:03:59 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua Fri Mar 09 19:05:59 2018 +0100
@@ -885,7 +885,7 @@
function GetVariables()
progress = tonumber(GetCampaignVar("Progress"))
m2DenseDead = tonumber(GetCampaignVar("M2DenseDead"))
- m2Choice = tonumber(GetCampaignVar("M2Choice"))
+ m2Choice = tonumber(GetCampaignVar("M2Choice")) or choiceRefused
m4DenseDead = tonumber(GetCampaignVar("M4DenseDead"))
m4LeaksDead = tonumber(GetCampaignVar("M4LeaksDead"))
m4ChiefDead = tonumber(GetCampaignVar("M4ChiefDead"))
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/dragon.lua Fri Mar 09 18:03:59 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/dragon.lua Fri Mar 09 19:05:59 2018 +0100
@@ -551,7 +551,7 @@
function GetVariables()
progress = tonumber(GetCampaignVar("Progress"))
- m5DeployedNum = tonumber(GetCampaignVar("M5DeployedNum"))
+ m5DeployedNum = tonumber(GetCampaignVar("M5DeployedNum")) or leaksNum
end
function SetupPlace()
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua Fri Mar 09 18:03:59 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua Fri Mar 09 19:05:59 2018 +0100
@@ -457,9 +457,9 @@
function GetVariables()
progress = tonumber(GetCampaignVar("Progress"))
- m5DeployedNum = tonumber(GetCampaignVar("M5DeployedNum"))
- m2Choice = tonumber(GetCampaignVar("M2Choice"))
- m5Choice = tonumber(GetCampaignVar("M5Choice"))
+ m5DeployedNum = tonumber(GetCampaignVar("M5DeployedNum")) or leaksNum
+ m2Choice = tonumber(GetCampaignVar("M2Choice")) or choiceRefused
+ m5Choice = tonumber(GetCampaignVar("M5Choice")) or choiceEliminate
m2DenseDead = tonumber(GetCampaignVar("M2DenseDead"))
m4DenseDead = tonumber(GetCampaignVar("M4DenseDead"))
m5DenseDead = tonumber(GetCampaignVar("M5DenseDead"))
@@ -477,10 +477,10 @@
m8PrincessDead = tonumber(GetCampaignVar("M8PrincessDead"))
m8RamonDead = tonumber(GetCampaignVar("M8RamonDead"))
m8SpikyDead = tonumber(GetCampaignVar("M8SpikyDead"))
- m8DeployedLeader = tonumber(GetCampaignVar("M8DeployedLeader"))
- m8PrincessLeader = tonumber(GetCampaignVar("M8PrincessLeader"))
+ m8DeployedLeader = tonumber(GetCampaignVar("M8DeployedLeader")) or 0
+ m8PrincessLeader = tonumber(GetCampaignVar("M8PrincessLeader")) or 1
m8EnemyFled = tonumber(GetCampaignVar("M8EnemyFled"))
- m8Scene = tonumber(GetCampaignVar("M8Scene"))
+ m8Scene = tonumber(GetCampaignVar("M8Scene")) or princessScene
end
function SetupPlace()
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/epil.lua Fri Mar 09 18:03:59 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/epil.lua Fri Mar 09 19:05:59 2018 +0100
@@ -306,8 +306,8 @@
end
-----------------------------Misc--------------------------------------
function GetVariables()
- m8Scene = tonumber(GetCampaignVar("M8Scene")) or waterScene
- -- waterScene is for fallback if campaign var was not found
+ m8Scene = tonumber(GetCampaignVar("M8Scene")) or princessScene
+ -- princessScene is for fallback if campaign var was not found
end
function AddHogs()
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/family.lua Fri Mar 09 18:03:59 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/family.lua Fri Mar 09 19:05:59 2018 +0100
@@ -490,9 +490,9 @@
function GetVariables()
progress = tonumber(GetCampaignVar("Progress"))
- m5DeployedNum = tonumber(GetCampaignVar("M5DeployedNum"))
- m2Choice = tonumber(GetCampaignVar("M2Choice"))
- m5Choice = tonumber(GetCampaignVar("M5Choice"))
+ m5DeployedNum = tonumber(GetCampaignVar("M5DeployedNum")) or leaksNum
+ m2Choice = tonumber(GetCampaignVar("M2Choice")) or choiceRefused
+ m5Choice = tonumber(GetCampaignVar("M5Choice")) or choiceEliminate
end
function SetupPlace()
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua Fri Mar 09 18:03:59 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua Fri Mar 09 19:05:59 2018 +0100
@@ -1057,7 +1057,7 @@
function onGameInit()
progress = tonumber(GetCampaignVar("Progress"))
- m2Choice = tonumber(GetCampaignVar("M2Choice"))
+ m2Choice = tonumber(GetCampaignVar("M2Choice")) or choiceRefused
m2DenseDead = tonumber(GetCampaignVar("M2DenseDead"))
m2RamonDead = tonumber(GetCampaignVar("M2RamonDead"))
m2SpikyDead = tonumber(GetCampaignVar("M2SpikyDead"))
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/queen.lua Fri Mar 09 18:03:59 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/queen.lua Fri Mar 09 19:05:59 2018 +0100
@@ -612,9 +612,9 @@
function GetVariables()
progress = tonumber(GetCampaignVar("Progress"))
- m5DeployedNum = tonumber(GetCampaignVar("M5DeployedNum"))
- m2Choice = tonumber(GetCampaignVar("M2Choice"))
- m5Choice = tonumber(GetCampaignVar("M5Choice"))
+ m5DeployedNum = tonumber(GetCampaignVar("M5DeployedNum")) or leaksNum
+ m2Choice = tonumber(GetCampaignVar("M2Choice")) or choiceRefused
+ m5Choice = tonumber(GetCampaignVar("M5Choice")) or choiceEliminate
m2DenseDead = tonumber(GetCampaignVar("M2DenseDead"))
m4DenseDead = tonumber(GetCampaignVar("M4DenseDead"))
m5DenseDead = tonumber(GetCampaignVar("M5DenseDead"))
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/united.lua Fri Mar 09 18:03:59 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/united.lua Fri Mar 09 19:05:59 2018 +0100
@@ -26,9 +26,9 @@
HedgewarsScriptLoad("/Scripts/Animate.lua")
-----------------------------Constants---------------------------------
-choiceAccept = 1
-choiceRefuse = 2
-choiceAttack = 3
+choiceAccepted = 1
+choiceRefused = 2
+choiceAttacked = 3
leaksPos = {2067, 509}
densePos = {1882, 503}
@@ -289,7 +289,7 @@
if m2DenseDead == 1 then
denseDead = true
end
- m2Choice = tonumber(GetCampaignVar("M2Choice"))
+ m2Choice = tonumber(GetCampaignVar("M2Choice")) or choiceRefused
end
function SetupPlace()