2025-06-24 14:38:16 -04:00
|
|
|
-- Event flags, courtesy of Sapphire
|
|
|
|
-- https://github.com/SapphireServer/Sapphire/blob/bf3368224a00c180cbb7ba413b52395eba58ec0b/src/world/Event/EventDefs.h#L9
|
|
|
|
|
2025-06-27 22:40:40 -04:00
|
|
|
-- Cutscene flags, TODO: move these to Global.lua, or maybe a new file named Cutscene.lua or something along those lines, to store all of them
|
|
|
|
FADE_OUT = 0x00000002
|
|
|
|
HIDE_UI = 0x00000800
|
|
|
|
HIDE_HOTBAR = 0x00002000
|
|
|
|
CONDITION_CUTSCENE = 0x00000400
|
|
|
|
SET_BASE = 0xF8400EFB -- Pulled from Sapphire, perhaps the default flags the server sends for most cutscenes?
|
2025-05-05 23:04:53 -04:00
|
|
|
|
2025-06-27 22:40:40 -04:00
|
|
|
-- Scene numbers
|
|
|
|
SCENE_SHOW_MENU = 00000
|
|
|
|
SCENE_SLEEP_ANIM = 00001
|
|
|
|
SCENE_LOG_OUT = 00002
|
|
|
|
SCENE_DREAMFITTING = 00003
|
|
|
|
SCENE_AWAKEN_ANIM = 00100
|
2025-06-24 14:38:16 -04:00
|
|
|
|
2025-05-05 23:04:53 -04:00
|
|
|
function onTalk(target, player)
|
2025-06-27 22:40:40 -04:00
|
|
|
player:play_scene(target, EVENT_ID, SCENE_SHOW_MENU, HIDE_HOTBAR, {0})
|
2025-05-05 23:04:53 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
function onReturn(scene, results, player)
|
2025-06-27 22:40:40 -04:00
|
|
|
local CUTSCENE_FLAGS <const> = FADE_OUT | HIDE_UI | CONDITION_CUTSCENE
|
|
|
|
-- Decision values the player can choose
|
2025-06-28 11:50:01 -04:00
|
|
|
local CANCEL_SCENE <const> = 0 -- If the player hits escape/cancel on controller to cancel the menu
|
2025-06-27 22:40:40 -04:00
|
|
|
local NOTHING <const> = 1
|
|
|
|
local DREAMFITTING <const> = 2
|
|
|
|
local LOG_OUT <const> = 3
|
|
|
|
local EXIT_GAME <const> = 4 -- LOG_OUT and EXIT_GAME are unused by us in this script, but they are provided here as documentation for the decison values
|
|
|
|
local decision <const> = results[1]
|
2025-05-05 23:04:53 -04:00
|
|
|
|
2025-06-27 22:40:40 -04:00
|
|
|
if scene == SCENE_SHOW_MENU then
|
2025-06-28 11:50:01 -04:00
|
|
|
if decision == NOTHING or decision == CANCEL_SCENE then
|
2025-06-27 22:40:40 -04:00
|
|
|
player:finish_event(EVENT_ID)
|
|
|
|
else
|
2025-06-28 10:33:02 -04:00
|
|
|
if decision == LOG_OUT or decision == EXIT_GAME then
|
|
|
|
player:begin_log_out()
|
|
|
|
end
|
2025-06-27 22:40:40 -04:00
|
|
|
player:play_scene(player.id, EVENT_ID, SCENE_SLEEP_ANIM, CUTSCENE_FLAGS, {decision})
|
|
|
|
end
|
|
|
|
elseif scene == SCENE_SLEEP_ANIM then
|
|
|
|
if decision == DREAMFITTING then
|
|
|
|
player:play_scene(player.id, EVENT_ID, SCENE_DREAMFITTING, CUTSCENE_FLAGS, {0})
|
|
|
|
else
|
|
|
|
-- The player decided to log out or exit the game. The server don't care which, as the client handles itself, so pass along the decision.
|
|
|
|
player:play_scene(player.id, EVENT_ID, SCENE_LOG_OUT, CUTSCENE_FLAGS, {decision})
|
|
|
|
end
|
|
|
|
elseif scene == SCENE_DREAMFITTING then
|
|
|
|
player:play_scene(player.id, EVENT_ID, SCENE_AWAKEN_ANIM, CUTSCENE_FLAGS, {0})
|
|
|
|
else
|
2025-05-05 23:04:53 -04:00
|
|
|
player:finish_event(EVENT_ID)
|
|
|
|
end
|
|
|
|
end
|