mirror of
https://github.com/redstrate/Kawari.git
synced 2025-07-23 21:17:45 +00:00
Add additional logic for the inn wakeup so it doesn't play every time, nor when you log in from elsewhere. (#132)
Add additional logic for the inn wakeup so it doesn't play every time, nor when you log in from elsewhere.
This commit is contained in:
parent
f441cf38bc
commit
8c88c863d8
4 changed files with 34 additions and 10 deletions
|
@ -46,3 +46,8 @@ GM_RANK_SUPPORT = 5
|
|||
GM_RANK_SENIOR = 7
|
||||
GM_RANK_DEBUG = 90
|
||||
GM_RANK_MAX = 255 -- Doesn't exist, used for purposes of testing permissions in scripts
|
||||
|
||||
BED_EVENT_HANDLER = 720916
|
||||
BED_CUTSCENE_FLAGS = 4165480179 -- TODO: remove this hardcode
|
||||
BED_SCENE_WAKEUP_ANIM = 00100
|
||||
ZONE_INTENDED_USE_INN = 2
|
||||
|
|
|
@ -7,10 +7,6 @@ dofile(BASE_DIR.."events/Events.lua")
|
|||
dofile(BASE_DIR.."items/Items.lua")
|
||||
dofile(BASE_DIR.."Global.lua")
|
||||
|
||||
BED_EVENT_HANDLER = 720916
|
||||
BED_CUTSCENE_FLAGS = 4165480179 -- TODO: remove this hardcode
|
||||
BED_SCENE_WAKEUP_ANIM = 00100
|
||||
|
||||
-- Lua error handlers, and other server events like player login
|
||||
function onBeginLogin(player)
|
||||
-- send a welcome message
|
||||
|
@ -18,13 +14,15 @@ function onBeginLogin(player)
|
|||
end
|
||||
|
||||
function onFinishZoning(player)
|
||||
local zone_id = player.zone.id;
|
||||
local in_inn <const> = player.zone.intended_use == ZONE_INTENDED_USE_INN
|
||||
|
||||
-- play the wakeup animation
|
||||
-- the roost
|
||||
-- TODO: check for other inns
|
||||
if zone_id == 179 then
|
||||
player:start_event(player.id, BED_EVENT_HANDLER, 15, zone_id)
|
||||
-- Need this first so if a player logs in from a non-inn zone, they won't get the bed scene when they enter. It should only play on login.
|
||||
if not in_inn then
|
||||
player:set_inn_wakeup(true)
|
||||
elseif in_inn and not player.saw_inn_wakeup then
|
||||
player:set_inn_wakeup(true)
|
||||
-- play the wakeup animation
|
||||
player:start_event(player.id, BED_EVENT_HANDLER, 15, player.zone.id)
|
||||
player:play_scene(player.id, BED_EVENT_HANDLER, BED_SCENE_WAKEUP_ANIM, BED_CUTSCENE_FLAGS, {})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -130,6 +130,7 @@ pub struct PlayerData {
|
|||
/// The server-side copy of NPC shop buyback lists.
|
||||
pub buyback_list: BuyBackList,
|
||||
pub unlocks: UnlockData,
|
||||
pub saw_inn_wakeup: bool,
|
||||
}
|
||||
|
||||
/// Various obsfucation-related bits like the seeds and keys for this connection.
|
||||
|
@ -1027,6 +1028,9 @@ impl ZoneConnection {
|
|||
self.start_event(*actor_id, *event_id, *event_type, *event_arg)
|
||||
.await;
|
||||
}
|
||||
Task::SetInnWakeup { watched } => {
|
||||
self.player_data.saw_inn_wakeup = *watched;
|
||||
}
|
||||
}
|
||||
}
|
||||
player.queued_tasks.clear();
|
||||
|
|
|
@ -91,6 +91,9 @@ pub enum Task {
|
|||
event_type: u8,
|
||||
event_arg: u32,
|
||||
},
|
||||
SetInnWakeup {
|
||||
watched: bool
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
|
@ -470,6 +473,10 @@ impl LuaPlayer {
|
|||
event_arg,
|
||||
});
|
||||
}
|
||||
|
||||
fn set_inn_wakeup(&mut self, watched: bool) {
|
||||
self.queued_tasks.push(Task::SetInnWakeup { watched });
|
||||
}
|
||||
}
|
||||
|
||||
impl UserData for LuaPlayer {
|
||||
|
@ -631,6 +638,13 @@ impl UserData for LuaPlayer {
|
|||
Ok(())
|
||||
},
|
||||
);
|
||||
methods.add_method_mut(
|
||||
"set_inn_wakeup",
|
||||
|_, this, watched: bool| {
|
||||
this.set_inn_wakeup(watched);
|
||||
Ok(())
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
fn add_fields<F: UserDataFields<Self>>(fields: &mut F) {
|
||||
|
@ -654,6 +668,9 @@ impl UserData for LuaPlayer {
|
|||
fields.add_field_method_get("gil", |_, this| {
|
||||
Ok(this.player_data.inventory.currency.gil.quantity)
|
||||
});
|
||||
fields.add_field_method_get("saw_inn_wakeup", |_, this| {
|
||||
Ok(this.player_data.saw_inn_wakeup)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue