1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-04-24 16:17:44 +00:00

Add scripting function to change a player's territory

This commit is contained in:
Joshua Goins 2025-03-28 23:43:27 -04:00
parent e31d81743f
commit 65747b0632
2 changed files with 18 additions and 0 deletions

View file

@ -296,6 +296,11 @@ impl ZoneConnection {
self.send_segment(segment.clone()).await;
}
player.queued_segments.clear();
for task in &player.queued_tasks {
self.change_zone(task.zone_id).await;
}
player.queued_tasks.clear();
}
pub async fn process_effects_list(&mut self) {

View file

@ -11,11 +11,16 @@ use super::{
ipc::{ActorSetPos, EventPlay, ServerZoneIpcData, ServerZoneIpcSegment},
};
pub struct ChangeTerritoryTask {
pub zone_id: u16,
}
#[derive(Default)]
pub struct LuaPlayer {
pub player_data: PlayerData,
pub status_effects: StatusEffects,
pub queued_segments: Vec<PacketSegment<ServerZoneIpcSegment>>,
pub queued_tasks: Vec<ChangeTerritoryTask>,
}
impl LuaPlayer {
@ -90,6 +95,10 @@ impl LuaPlayer {
segment_type: SegmentType::Ipc { data: ipc },
});
}
fn change_territory(&mut self, zone_id: u16) {
self.queued_tasks.push(ChangeTerritoryTask { zone_id });
}
}
impl UserData for LuaPlayer {
@ -116,6 +125,10 @@ impl UserData for LuaPlayer {
this.set_position(position);
Ok(())
});
methods.add_method_mut("change_territory", |_, this, zone_id: u16| {
this.change_territory(zone_id);
Ok(())
});
}
}