mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-25 00:17:45 +00:00
Add scripting function to change a player's territory
This commit is contained in:
parent
e31d81743f
commit
65747b0632
2 changed files with 18 additions and 0 deletions
|
@ -296,6 +296,11 @@ impl ZoneConnection {
|
||||||
self.send_segment(segment.clone()).await;
|
self.send_segment(segment.clone()).await;
|
||||||
}
|
}
|
||||||
player.queued_segments.clear();
|
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) {
|
pub async fn process_effects_list(&mut self) {
|
||||||
|
|
|
@ -11,11 +11,16 @@ use super::{
|
||||||
ipc::{ActorSetPos, EventPlay, ServerZoneIpcData, ServerZoneIpcSegment},
|
ipc::{ActorSetPos, EventPlay, ServerZoneIpcData, ServerZoneIpcSegment},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub struct ChangeTerritoryTask {
|
||||||
|
pub zone_id: u16,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct LuaPlayer {
|
pub struct LuaPlayer {
|
||||||
pub player_data: PlayerData,
|
pub player_data: PlayerData,
|
||||||
pub status_effects: StatusEffects,
|
pub status_effects: StatusEffects,
|
||||||
pub queued_segments: Vec<PacketSegment<ServerZoneIpcSegment>>,
|
pub queued_segments: Vec<PacketSegment<ServerZoneIpcSegment>>,
|
||||||
|
pub queued_tasks: Vec<ChangeTerritoryTask>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LuaPlayer {
|
impl LuaPlayer {
|
||||||
|
@ -90,6 +95,10 @@ impl LuaPlayer {
|
||||||
segment_type: SegmentType::Ipc { data: ipc },
|
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 {
|
impl UserData for LuaPlayer {
|
||||||
|
@ -116,6 +125,10 @@ impl UserData for LuaPlayer {
|
||||||
this.set_position(position);
|
this.set_position(position);
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
methods.add_method_mut("change_territory", |_, this, zone_id: u16| {
|
||||||
|
this.change_territory(zone_id);
|
||||||
|
Ok(())
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue