Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
authorWuzzy <almikes@aol.com>
Sun, 27 Nov 2016 01:30:41 +0100
changeset 12093 1da37e2ba6fd
parent 12092 78e9fbd52ffc
child 12094 0183b4c448bf
Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
ChangeLog.txt
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death01.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert02.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert03.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit01.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua
share/hedgewars/Data/Scripts/Animate.lua
--- a/ChangeLog.txt	Sun Nov 27 00:00:25 2016 +0100
+++ b/ChangeLog.txt	Sun Nov 27 01:30:41 2016 +0100
@@ -151,13 +151,14 @@
  * Mutant script shows now appropriate ranking and graph in stats screen
  * Disable Sudden Death for good in Shoppa game scheme, some game styles and mission maps
 
-Missions:
+Missions and Campaigns:
  + Added Basic Flying Saucer Training
  + Rope-Knocking Challenge was improved (now awards score based on kills and time; taunts for knocking out hedgehogs)
  + A few campaign missions now save your personal best successes (e.g. fastest finish in Hard Flying) which get shown after you finish them agin
  + A Space Adventure shows 2 flowers over fully completed planets (with side missions)
  + Rewrote some help texts in basic rope training
  + Graphical effect (black bars) while in cut scenes
+ * Fix weird behaviour when walking right before the first animation in A Space Adventure missions
  * Portal Mind Challenge was cleaned up and reworked (especially less awful wording)
  * Fixed Target Practice missions getting stuck when a target dropped into water
  * Fixed mistakes and bad wording of strings in several missions, scripts and campaigns
@@ -195,6 +196,7 @@
  + New variable: AirMinesNum -- Number of air mines being placed on a medium-sized map
  + New variable: WorldEdge -- World edge type (weNone, weWrap, weBounce, weSea)
  + Locale library: loc_noop -- Mark string for translation but don't translate it
+ + Animate library: AnimInit([startAnimating]) -- New parameter startAnimating: if true, will start game in cinematic mode with most controls disabled. Must play an animation after that
 
 0.9.21 -> 0.9.22
  + New Weapon / Map object: AirMine (floating mine that will follow nearby hedgehogs)
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua	Sun Nov 27 00:00:25 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua	Sun Nov 27 01:30:41 2016 +0100
@@ -117,18 +117,25 @@
 	if tonumber(GetCampaignVar("CosmosCheckPoint")) then
 		checkPointReached = tonumber(GetCampaignVar("CosmosCheckPoint"))
 	end
+	-- Whether to start with an animation
+	local startSequence
 	-- do checkpoint stuff needed before game starts
 	if checkPointReached == 1 then
 		-- Start of the game
+		startSequence = true
 	elseif checkPointReached == 2 then
 		-- Hero on the column, just took space ship unnoticed
+		startSequence = true
 		AnimSetGearPosition(hero.gear, saucerX, saucerY)
 	elseif checkPointReached == 3 then
 		-- Hero near column, without space ship unnoticed
+		startSequence = true
 	elseif checkPointReached == 4 then
 		-- Hero visited moon for fuels
+		startSequence = true
 		AnimSetGearPosition(hero.gear, 1110, 850)
 	elseif checkPointReached == 5 then
+		startSequence = false
 		-- Hero has visited a planet, he has plenty of fuels and can change planet
 		if GetCampaignVar("Planet") == "moon" then
 			AnimSetGearPosition(hero.gear, 1110, 850)
@@ -144,8 +151,7 @@
 			AnimSetGearPosition(hero.gear, 3080, 850)
 		end
 	end
-
-	AnimInit()
+	AnimInit(startSequence)
 	AnimationSetup()
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death01.lua	Sun Nov 27 00:00:25 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death01.lua	Sun Nov 27 01:30:41 2016 +0100
@@ -130,7 +130,7 @@
 
 	initCheckpoint("death01")
 
-	AnimInit()
+	AnimInit(true)
 	AnimationSetup()
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua	Sun Nov 27 00:00:25 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua	Sun Nov 27 01:30:41 2016 +0100
@@ -78,7 +78,7 @@
 
 	initCheckpoint("death02")
 
-	AnimInit()
+	AnimInit(true)
 	AnimationSetup()
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert02.lua	Sun Nov 27 00:00:25 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert02.lua	Sun Nov 27 01:30:41 2016 +0100
@@ -79,7 +79,7 @@
 
 	initCheckpoint("desert02")
 
-	AnimInit()
+	AnimInit(true)
 	AnimationSetup()
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert03.lua	Sun Nov 27 00:00:25 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert03.lua	Sun Nov 27 01:30:41 2016 +0100
@@ -74,7 +74,7 @@
 
 	initCheckpoint("desert03")
 
-	AnimInit()
+	AnimInit(true)
 	AnimationSetup()
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit01.lua	Sun Nov 27 00:00:25 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit01.lua	Sun Nov 27 01:30:41 2016 +0100
@@ -148,7 +148,7 @@
 
 	initCheckpoint("fruit01")
 
-	AnimInit()
+	AnimInit(true)
 	AnimationSetup()
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua	Sun Nov 27 00:00:25 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua	Sun Nov 27 01:30:41 2016 +0100
@@ -116,7 +116,7 @@
 		AnimSetGearPosition(redHedgehogs[i].gear, 2010 + 50*i, 630)
 	end
 
-	AnimInit()
+	AnimInit(true)
 	AnimationSetup()
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua	Sun Nov 27 00:00:25 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua	Sun Nov 27 01:30:41 2016 +0100
@@ -100,7 +100,7 @@
 
 	initCheckpoint("fruit03")
 
-	AnimInit()
+	AnimInit(true)
 	AnimationSetup()
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua	Sun Nov 27 00:00:25 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua	Sun Nov 27 01:30:41 2016 +0100
@@ -144,7 +144,7 @@
 		AnimSetGearPosition(hero.gear, 1450, 910)
 	end
 
-	AnimInit()
+	AnimInit(true)
 	AnimationSetup()
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua	Sun Nov 27 00:00:25 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua	Sun Nov 27 01:30:41 2016 +0100
@@ -92,7 +92,7 @@
 
 	initCheckpoint("ice02")
 
-	AnimInit()
+	AnimInit(true)
 	AnimationSetup()
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua	Sun Nov 27 00:00:25 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua	Sun Nov 27 01:30:41 2016 +0100
@@ -159,7 +159,7 @@
 		end
 	end
 
-	AnimInit()
+	AnimInit(true)
 	AnimationSetup()
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua	Sun Nov 27 00:00:25 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua	Sun Nov 27 01:30:41 2016 +0100
@@ -73,7 +73,7 @@
 
 	initCheckpoint("moon02")
 
-	AnimInit()
+	AnimInit(true)
 	AnimationSetup()
 end
 
--- a/share/hedgewars/Data/Scripts/Animate.lua	Sun Nov 27 00:00:25 2016 +0100
+++ b/share/hedgewars/Data/Scripts/Animate.lua	Sun Nov 27 01:30:41 2016 +0100
@@ -50,8 +50,17 @@
   RemoveFunction()
 end
 
-function AnimInit()
-  animPos = 1
+local function startCinemaLock()
+     SetCinematicMode(true)
+     SetInputMask(bnot(gmAnimate+gmAttack+gmDown+gmHJump+gmLeft+gmLJump+gmRight+gmSlot+gmSwitch+gmTimer+gmUp+gmWeapon))
+end
+
+local function stopCinemaLock()
+     SetInputMask(0xFFFFFFFF)
+     SetCinematicMode(false)
+end
+
+function AnimInit(startAnimating)
   lastx = 0
   lasty = 0
   jumpTypes = {long = gmLJump, high = gmHJump, back = gmHJump}
@@ -72,6 +81,10 @@
   FunctionListNum = 0
   skipping = false
   skipFuncList = {}
+  animPos = 1
+  if startAnimating then
+     startCinemaLock()
+  end
 end
 
 function AnimSwitchHog(gear)
@@ -288,8 +301,7 @@
 function Animate(steps)
   if skipping == true then
     animPos = 1
-    SetCinematicMode(false)
-    SetInputMask(0xFFFFFFFF)
+    stopCinemaLock()
     SkipAnimation(steps)
     return true
   end
@@ -300,8 +312,7 @@
 
   if steps[animPos] == nil then
       animPos = 1
-      SetCinematicMode(false)
-      SetInputMask(0xFFFFFFFF)
+      stopCinemaLock()
       return true
   end
   
@@ -310,8 +321,7 @@
       AnimSwitchHog(steps[animPos].args[1])
   end
 
-  SetInputMask(bnot(gmAnimate+gmAttack+gmDown+gmHJump+gmLeft+gmLJump+gmRight+gmSlot+gmSwitch+gmTimer+gmUp+gmWeapon))
-  SetCinematicMode(true)
+  startCinemaLock()
   retVal = steps[animPos].func(unpack(steps[animPos].args))
   if (retVal ~= false) then
     animPos = animPos + 1