From f1118738d56d70989a9a131d6b370b73e8e3bc25 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 21 Feb 2021 18:31:43 -0500 Subject: Added frozen animation for cutscenes The player's party will be set to "frozen" at the start of a cutscene and "still" at the end. "frozen" doesn't include idle animations, which are weird to show up during tense exchanges. A CutsceneOptions enum was introduced to be able to modify the growing number of things that StartCutscene() and HideCutsceneBars() do. Currently the lightning mailbox event uses it so that Lucas's animation is not reset to still (instead of the collapsed animation) after he's electrocuted. --- res/scripts/common.lua | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'res/scripts/common.lua') diff --git a/res/scripts/common.lua b/res/scripts/common.lua index 494ace9..45b596d 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua @@ -30,6 +30,10 @@ SpriteLayer = { ABOVE = 1 } +CutsceneOptions = { + DO_NOT_CHANGE_ANIMATION = 1 -- Prevents player party animation being set to "frozen" at the start of a cutscene or "still" at the end +} + gamestate = {} --- Yields until the specified amount of time has passed. @@ -42,12 +46,19 @@ end --- Starts a cutscene. -- This takes care of showing the cutscene bars, as well as halting character --- movement. It does not block. -function StartCutscene() +-- movement. It does not block. See CutsceneOptions for modifiers. +function StartCutscene(options) + options = options or 0 + local playerId = getPlayerSprite() local playerSprite = getSprite(playerId) playerSprite.controllable = false character():halt(playerId) + + if (options & CutsceneOptions.DO_NOT_CHANGE_ANIMATION == 0) then + SetPartyAnimation(playerId, "frozen") + end + message():displayCutsceneBars() local allSprites = getAllSprites() @@ -91,8 +102,10 @@ function WaitForEndOfMessage() end --- Hides the cutscene bars. --- This also re-enables player movement. -function HideCutsceneBars() +-- This also re-enables player movement. See CutsceneOptions for modifiers. +function HideCutsceneBars(options) + options = options or 0 + WaitForEndOfMessage() message():hideCutsceneBars() @@ -100,6 +113,10 @@ function HideCutsceneBars() local playerSprite = getSprite(playerId) playerSprite.controllable = true + if (options & CutsceneOptions.DO_NOT_CHANGE_ANIMATION == 0) then + SetPartyAnimation(playerId, "still") + end + local allSprites = getAllSprites() for k,v in pairs(allSprites) do getSprite(v).paused = false @@ -212,6 +229,16 @@ function SetPartyDirection(spriteId, direction) end end +function SetPartyAnimation(spriteId, animName) + animation():setSpriteAnimation(spriteId, animName) + + local sprite = getSprite(spriteId) + + for i=1,#sprite.followers do + animation():setSpriteAnimation(sprite.followers[i], animName) + end +end + function ChangeMap(map, warp) local playerId = getPlayerSprite() local playerSprite = getSprite(playerId) -- cgit 1.4.1