summary refs log tree commit diff stats
path: root/res/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'res/scripts')
-rw-r--r--res/scripts/common.lua44
-rw-r--r--res/scripts/hallucination_interior.lua32
2 files changed, 71 insertions, 5 deletions
diff --git a/res/scripts/common.lua b/res/scripts/common.lua index 123f2a0..8eb491f 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua
@@ -35,7 +35,8 @@ CutsceneOptions = {
35} 35}
36 36
37ChangeMapOptions = { 37ChangeMapOptions = {
38 DO_NOT_FADE = 1 -- Prevents fading to and from black 38 DO_NOT_FADE = 1, -- Prevents fading to and from black
39 DO_NOT_CHANGE_MUSIC = 2 -- Prevents stopping or starting music as part of the map change
39} 40}
40 41
41PathfindingOptions = { 42PathfindingOptions = {
@@ -289,10 +290,12 @@ function ChangeMap(map, warp, options)
289 loadMap(map) 290 loadMap(map)
290 character():transplantParty(playerId, getMap():getWarpPoint(warp), direction) 291 character():transplantParty(playerId, getMap():getWarpPoint(warp), direction)
291 292
292 if (mixer():isPlayingMusic() and not getMap():hasMusic()) then 293 if (options & ChangeMapOptions.DO_NOT_CHANGE_MUSIC == 0) then
293 mixer():fadeoutMusic(150) 294 if (mixer():isPlayingMusic() and not getMap():hasMusic()) then
294 elseif (getMap():hasMusic() and (not mixer():isPlayingMusic() or not (mixer():getPlayingTrack() == getMap():getMusic()))) then 295 mixer():fadeoutMusic(150)
295 mixer():playMusic(getMap():getMusic(), 150) 296 elseif (getMap():hasMusic() and (not mixer():isPlayingMusic() or not (mixer():getPlayingTrack() == getMap():getMusic()))) then
297 mixer():playMusic(getMap():getMusic(), 150)
298 end
296 end 299 end
297 300
298 coroutine.yield() 301 coroutine.yield()
@@ -413,3 +416,34 @@ function WaitForSpritePath(spriteName)
413 coroutine.yield() 416 coroutine.yield()
414 end 417 end
415end 418end
419
420--- Fades out the currently playing music.
421-- This does not block. If you want it to block, call Delay for the same amount
422-- of time.
423-- @param length the fadeout time in milliseconds
424function FadeoutMusic(length)
425 mixer():fadeoutMusic(length)
426end
427
428--- Plays the specified track.
429-- @param song the name of the song to play
430-- @param length the time in milliseconds to fade in. if left blank, the track starts immediately
431function PlayMusic(song, length)
432 length = length or 0
433
434 mixer():playMusic(song, length)
435end
436
437--- Makes the player sprite non-controllable.
438function DisablePlayerControl()
439 local playerId = getPlayerSprite()
440 local playerSprite = getSprite(playerId)
441 playerSprite.controllable = false
442end
443
444--- Makes the player sprite controllable again.
445function EnablePlayerControl()
446 local playerId = getPlayerSprite()
447 local playerSprite = getSprite(playerId)
448 playerSprite.controllable = true
449end
diff --git a/res/scripts/hallucination_interior.lua b/res/scripts/hallucination_interior.lua index bd075f1..4fbaa99 100644 --- a/res/scripts/hallucination_interior.lua +++ b/res/scripts/hallucination_interior.lua
@@ -187,3 +187,35 @@ function hallucination_interior.talk_to_ionia()
187 SetAnimation("ionia", "still") 187 SetAnimation("ionia", "still")
188 HideCutsceneBars() 188 HideCutsceneBars()
189end 189end
190
191function hallucination_interior.mailbox_time_passage()
192 StartCutscene()
193 DisplayMessage("* The mailbox lid is open...\n* Peek inside?", "", SpeakerType.NONE)
194 ShowChoice("Yes", "No")
195 WaitForEndOfMessage()
196
197 if GetChoiceSelection() == 1 then
198 HideCutsceneBars()
199 return
200 end
201
202 FadeoutMusic(2000)
203 Delay(4000)
204
205 DisplayMessage("* Inside the mailbox is a long hallway.", "", SpeakerType.NONE)
206 WaitForEndOfMessage()
207
208 Delay(1000)
209
210 FadeToBlack(1000)
211
212 HideCutsceneBars()
213 DisablePlayerControl()
214 ChangeMap("time_passage", "fromMailbox", ChangeMapOptions.DO_NOT_FADE | ChangeMapOptions.DO_NOT_CHANGE_MUSIC)
215 Delay(1000)
216
217 PlayMusic("time_passage", 2000)
218 RemoveFadeout(2000)
219
220 EnablePlayerControl()
221end