summary refs log tree commit diff stats
path: root/res/scripts/common.lua
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-21 18:31:43 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-21 18:31:43 -0500
commitf1118738d56d70989a9a131d6b370b73e8e3bc25 (patch)
treec6fcca0be1f2bb7db35d16f4b1cb38a7de3f632a /res/scripts/common.lua
parent5df0d0616ee3996add0b14e0fb0becd6257d04a2 (diff)
downloadtanetane-f1118738d56d70989a9a131d6b370b73e8e3bc25.tar.gz
tanetane-f1118738d56d70989a9a131d6b370b73e8e3bc25.tar.bz2
tanetane-f1118738d56d70989a9a131d6b370b73e8e3bc25.zip
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.
Diffstat (limited to 'res/scripts/common.lua')
-rw-r--r--res/scripts/common.lua35
1 files changed, 31 insertions, 4 deletions
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 = {
30 ABOVE = 1 30 ABOVE = 1
31} 31}
32 32
33CutsceneOptions = {
34 DO_NOT_CHANGE_ANIMATION = 1 -- Prevents player party animation being set to "frozen" at the start of a cutscene or "still" at the end
35}
36
33gamestate = {} 37gamestate = {}
34 38
35--- Yields until the specified amount of time has passed. 39--- Yields until the specified amount of time has passed.
@@ -42,12 +46,19 @@ end
42 46
43--- Starts a cutscene. 47--- Starts a cutscene.
44-- This takes care of showing the cutscene bars, as well as halting character 48-- This takes care of showing the cutscene bars, as well as halting character
45-- movement. It does not block. 49-- movement. It does not block. See CutsceneOptions for modifiers.
46function StartCutscene() 50function StartCutscene(options)
51 options = options or 0
52
47 local playerId = getPlayerSprite() 53 local playerId = getPlayerSprite()
48 local playerSprite = getSprite(playerId) 54 local playerSprite = getSprite(playerId)
49 playerSprite.controllable = false 55 playerSprite.controllable = false
50 character():halt(playerId) 56 character():halt(playerId)
57
58 if (options & CutsceneOptions.DO_NOT_CHANGE_ANIMATION == 0) then
59 SetPartyAnimation(playerId, "frozen")
60 end
61
51 message():displayCutsceneBars() 62 message():displayCutsceneBars()
52 63
53 local allSprites = getAllSprites() 64 local allSprites = getAllSprites()
@@ -91,8 +102,10 @@ function WaitForEndOfMessage()
91end 102end
92 103
93--- Hides the cutscene bars. 104--- Hides the cutscene bars.
94-- This also re-enables player movement. 105-- This also re-enables player movement. See CutsceneOptions for modifiers.
95function HideCutsceneBars() 106function HideCutsceneBars(options)
107 options = options or 0
108
96 WaitForEndOfMessage() 109 WaitForEndOfMessage()
97 message():hideCutsceneBars() 110 message():hideCutsceneBars()
98 111
@@ -100,6 +113,10 @@ function HideCutsceneBars()
100 local playerSprite = getSprite(playerId) 113 local playerSprite = getSprite(playerId)
101 playerSprite.controllable = true 114 playerSprite.controllable = true
102 115
116 if (options & CutsceneOptions.DO_NOT_CHANGE_ANIMATION == 0) then
117 SetPartyAnimation(playerId, "still")
118 end
119
103 local allSprites = getAllSprites() 120 local allSprites = getAllSprites()
104 for k,v in pairs(allSprites) do 121 for k,v in pairs(allSprites) do
105 getSprite(v).paused = false 122 getSprite(v).paused = false
@@ -212,6 +229,16 @@ function SetPartyDirection(spriteId, direction)
212 end 229 end
213end 230end
214 231
232function SetPartyAnimation(spriteId, animName)
233 animation():setSpriteAnimation(spriteId, animName)
234
235 local sprite = getSprite(spriteId)
236
237 for i=1,#sprite.followers do
238 animation():setSpriteAnimation(sprite.followers[i], animName)
239 end
240end
241
215function ChangeMap(map, warp) 242function ChangeMap(map, warp)
216 local playerId = getPlayerSprite() 243 local playerId = getPlayerSprite()
217 local playerSprite = getSprite(playerId) 244 local playerSprite = getSprite(playerId)