1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-05-12 14:47:46 +00:00

Create GenericWarp script to handle simple warps

It turns out that most warps are just a yes/no, and can be handled by
one single script. I scripted the lift attendants from Bulwark Hall <->
Airship Landing <-> Drowning Wench this way.
This commit is contained in:
Joshua Goins 2025-05-05 23:30:36 -04:00
parent 6dc8194aa8
commit e237cbe84d
11 changed files with 21 additions and 30 deletions

View file

@ -3,6 +3,8 @@ function onBeginLogin(player)
player:send_message("Welcome to Kawari!")
end
-- please keep these ids sorted!
-- Actions
registerAction(3, "actions/Sprint.lua")
registerAction(9, "actions/FastBlade.lua")
@ -11,10 +13,13 @@ registerAction(9, "actions/FastBlade.lua")
registerAction(6221, "items/Fantasia.lua")
-- Events
registerEvent(131078, "warp/WarpInnGridania.lua")
registerEvent(131079, "warp/WarpInnLimsaLominsa.lua")
registerEvent(131082, "common/GenericWarp.lua")
registerEvent(131092, "common/GenericWarp.lua")
registerEvent(131093, "common/GenericWarp.lua")
registerEvent(131094, "common/GenericWarp.lua")
registerEvent(720916, "custom/000/cmndefinnbed_00020.lua")
registerEvent(1245185, "opening/OpeningLimsaLominsa.lua")
registerEvent(1245186, "opening/OpeningGridania.lua")
registerEvent(1245187, "opening/OpeningUldah.lua")
registerEvent(131078, "warp/WarpInnGridania.lua")
registerEvent(131079, "warp/WarpInnLimsaLominsa.lua")
registerEvent(131082, "tosort/LimsaInnDoor.lua")
registerEvent(720916, "custom/000/cmndefinnbed_00020.lua")

View file

@ -1,10 +1,6 @@
--- TODO: find a way to hardcode it this way
EVENT_ID = 131082
-- TODO: it seems that these all might share one common function, and the only difference is the event id
-- generic warp, use this for most warps that are just a yes/no option
function onTalk(target, player)
--- prompt to exit the inn
player:play_scene(target, EVENT_ID, 00000, 8192, 0)
end
@ -13,6 +9,6 @@ function onReturn(scene, results, player)
if results[1] == 1 then
-- get warp
player:warp(EVENT_ID)
player:warp(EVENT_ID)
end
end

View file

@ -28,6 +28,9 @@ function onReturn(scene, results, player)
player:finish_event(EVENT_ID)
elseif scene == 1 then -- sleep anim
-- play log out scene
player:play_scene(player.id, EVENT_ID, 2, 8192, 0)
elseif scene == 2 then -- log out
player:finish_event(EVENT_ID)
end
end

View file

@ -1,6 +1,3 @@
--- TODO: find a way to hardcode it this way
EVENT_ID = 1245186
--- load defines from Opening Excel sheet, which has this and we don't need to hardcode it'
POS_START = 2299848

View file

@ -1,6 +1,3 @@
--- TODO: find a way to hardcode it this way
EVENT_ID = 1245185
--- load defines from Opening Excel sheet, which has this and we don't need to hardcode it'
POS_START = 4101800

View file

@ -1,6 +1,3 @@
--- TODO: find a way to hardcode it this way
EVENT_ID = 1245187
--- load defines from Opening Excel sheet, which has this and we don't need to hardcode it'
POS_START = 4101669

View file

@ -1,6 +1,3 @@
--- TODO: find a way to hardcode it this way
EVENT_ID = 131079 -- TODO: wrong, i was testing in limsa
function onTalk(actorId, player)
-- has inn access
-- player:play_scene(131079, 00001, 1, 0)

View file

@ -1,6 +1,3 @@
--- TODO: find a way to hardcode it this way
EVENT_ID = 131079
function onTalk(target, player)
-- has inn access
player:play_scene(target, EVENT_ID, 00001, 8192, 0)

View file

@ -733,7 +733,7 @@ async fn client_loop(
if let Some(event_script) =
state.event_scripts.get(event_id)
{
connection.event = Some(Event::new(&event_script));
connection.event = Some(Event::new(*event_id, &event_script));
connection
.event
.as_mut()

View file

@ -301,9 +301,9 @@ impl ChatHandler {
}
let event = match event_id {
1245185 => Event::new("opening/OpeningLimsaLominsa.lua"),
1245186 => Event::new("opening/OpeningGridania.lua"),
1245187 => Event::new("opening/OpeningUldah.lua"),
1245185 => Event::new(1245185, "opening/OpeningLimsaLominsa.lua"),
1245186 => Event::new(1245186, "opening/OpeningGridania.lua"),
1245187 => Event::new(1245187, "opening/OpeningUldah.lua"),
_ => panic!("Unsupported event!"),
};

View file

@ -9,7 +9,7 @@ pub struct Event {
}
impl Event {
pub fn new(path: &str) -> Self {
pub fn new(id: u32, path: &str) -> Self {
let lua = Lua::new();
let config = get_config();
@ -19,6 +19,8 @@ impl Event {
.exec()
.unwrap();
lua.globals().set("EVENT_ID", id).unwrap();
Self { lua }
}