A Space Adventure: Add outro sequence / epilogue in the final mission
authorWuzzy <almikes@aol.com>
Fri, 29 Sep 2017 21:44:35 +0200
changeset 12594 d8adae379d3c
parent 12590 b4b5484be651
child 12595 0d4a6ea7f071
A Space Adventure: Add outro sequence / epilogue in the final mission
ChangeLog.txt
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/final.lua
share/hedgewars/Data/Scripts/Animate.lua
--- a/ChangeLog.txt	Fri Sep 29 19:31:25 2017 +0200
+++ b/ChangeLog.txt	Fri Sep 29 21:44:35 2017 +0200
@@ -208,6 +208,7 @@
  + Side missions: Remove or shorten intro sequences
  + Side missions: Generous ready time to give more time to read the mission panel
  + Getting to the device: Put device part in a real crate, improve some dialogues
+ + Final mission: Add outro sequence instead of instantly quitting
  * Spacetrip: Fix various bugs and logic flaws in the initial mission
  * A frozen adventure: Fix bazooka and excess freezers (>6) not retained over checkpoints
  * A frozen adventure: Fix and improve poorly written messages
@@ -307,6 +308,7 @@
  + New variable: ReadyTimeLeft -- Remaining ready time, 0 if turn in progress. Can be set in onNewTurn
  + 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
+ + Animate library: AnimSetInputMask(extraInputMask) -- Set input mask in a manner comptible with the Animate library
  * Fixed call: HideHog(gear) -- Fix crash when gear is invalid. Returns true on success or false otherwise
  * Fixed call: SwitchHog(gear) -- Fix new hog being unable to open ammo menu
  * Removed call: SetAmmoStore -- Old undocumented function of questional use, has never been used
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/final.lua	Fri Sep 29 19:31:25 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/final.lua	Fri Sep 29 21:44:35 2017 +0200
@@ -16,6 +16,8 @@
 							loc("Red areas are indestructible.").."|"..
 							loc("Green areas are portal-proof.").."|"..
 							loc("Mines time: 0 seconds")
+
+local dialog01 = {}
 local explosives = {}
 local currentHealth = 1
 local currentDamage = 0
@@ -88,7 +90,8 @@
 	AddAmmo(hero.gear, amFirePunch, 1)
 
 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
-	AddEvent(onHeroWin, {hero.gear}, heroWin, {hero.gear}, 0)
+	AddEvent(onBoom, {hero.gear}, heroBoomReaction, {hero.gear}, 0)
+	AnimationSetup()
 
 	SendHealthStatsOff()
 end
@@ -111,6 +114,9 @@
 function onNewTurn()
 	currentDamage = 0
 	currentHealth = GetHealth(hero.gear)
+	if onBoom(hero.gear) then
+		heroWin(hero.gear)
+	end
 end
 
 function onGearDamage(gear, damage)
@@ -128,7 +134,7 @@
 	return false
 end
 
-function onHeroWin(gear)
+function onBoom(gear)
 	local win = true
 	for i=1,table.getn(explosives) do
 		if GetHealth(explosives[i]) then
@@ -153,7 +159,19 @@
 	EndGame()
 end
 
+function heroBoomReaction(gear)
+	if GetHealth(gear) and GetHealth(gear) > 0 then
+		HogSay(gear, loc("Kaboom! Hahahaha! Take this, stupid meteorite!"), SAY_SHOUT, 2)
+	end
+end
+
 function heroWin(gear)
+	AddAnim(dialog01)
+end
+
+function win()
+	SetWeapon(amNothing)
+	AnimSetInputMask(0)
 	saveCompletedStatus(7)
 	SaveCampaignVar("Won", "true")
 	checkAllMissionsCompleted()
@@ -162,3 +180,41 @@
 	sendSimpleTeamRankings({teamA.name})
 	EndGame()
 end
+
+------------ ANIMATION STUFF ------------
+
+function Skipanim(anim)
+	if anim == dialog01 then
+		win()
+	end
+end
+
+function onPrecise()
+	if GameTime > 3000 then
+		SetAnimSkip(true)
+	end
+end
+
+function AnimationSetup()
+	-- DIALOG 01 - Start, welcome to moon
+	AddSkipFunction(dialog01, Skipanim, {dialog01})
+	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 100}})
+	table.insert(dialog01, {func = FollowGear, args = {hero.gear}})
+	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Hooray! I actually did it! Hogera is safe!"), SAY_SHOUT, 3000}})
+	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("I'm so glad this is finally over!"), SAY_SAY, 3000}})
+	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 4000}})
+	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Wait a moment …"), SAY_THINK, 2000}})
+	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("If some good old explosives were enough to save Hogera …"), SAY_THINK, 5000}})
+	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("… why did I risk my life to collect all the parts of the anti-gravity device?"), SAY_THINK, 6000}})
+	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("It was completely useless!"), SAY_THINK, 3000}})
+	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("We could just have blown up the meteorite from the the beginning!"), SAY_THINK, 5000}})
+        -- Hogerian =  Inhabitant of the planet Hogera
+	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Stupid, stupid Hogerians!"), SAY_SAY, 5000}})
+	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Or maybe this was all part of an evil plan, so evil that even Prof. Hogevil can't think of it!"), SAY_THINK, 9000}})
+	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Nah, probably everyone was just stupid."), SAY_THINK, 4000}})
+	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Except me, of course! I just saved a whole planet!"), SAY_THINK, 5000}})
+	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("But one thing's for sure:"), SAY_THINK, 4000}})
+	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Hogera is definitely the last planet I saved!"), SAY_THINK, 4000}})
+	table.insert(dialog01, {func = win, args = {hero.gear}})
+end
+
--- a/share/hedgewars/Data/Scripts/Animate.lua	Fri Sep 29 19:31:25 2017 +0200
+++ b/share/hedgewars/Data/Scripts/Animate.lua	Fri Sep 29 21:44:35 2017 +0200
@@ -5,6 +5,8 @@
 local FunctionList, FunctionListNum
 local skipFuncList
 local skipping
+local baseInputMask = 0xFFFFFFFF
+local extraInputMask = baseInputMask
 --------------------------------Animation---------------------------------
 --------------------------(In-game cinematics)----------------------------
 
@@ -50,16 +52,27 @@
   RemoveFunction()
 end
 
+local function updateInputMask()
+     SetInputMask(band(baseInputMask, extraInputMask))
+end
+
 local function startCinemaLock()
      SetCinematicMode(true)
-     SetInputMask(bnot(gmAnimate+gmAttack+gmDown+gmHJump+gmLeft+gmLJump+gmRight+gmSlot+gmSwitch+gmTimer+gmUp+gmWeapon))
+     baseInputMask = bnot(gmAnimate+gmAttack+gmDown+gmHJump+gmLeft+gmLJump+gmRight+gmSlot+gmSwitch+gmTimer+gmUp+gmWeapon)
+     updateInputMask()
 end
 
 local function stopCinemaLock()
-     SetInputMask(0xFFFFFFFF)
+     baseInputMask = 0xFFFFFFFF
+     updateInputMask()
      SetCinematicMode(false)
 end
 
+function AnimSetInputMask(newExtraInputMask)
+     extraInputMask = newExtraInputMask
+     updateInputMask()
+end
+
 function AnimInit(startAnimating)
   lastx = 0
   lasty = 0