mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-20 06:37:45 +00:00
Begin wiring status effect Lua API
This commit is contained in:
parent
652beadaa4
commit
c5e04ba33f
3 changed files with 50 additions and 30 deletions
|
@ -2,3 +2,8 @@ function onBeginLogin(player)
|
||||||
-- send a welcome message
|
-- send a welcome message
|
||||||
player:send_message("Welcome to Kawari!")
|
player:send_message("Welcome to Kawari!")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function doAction(player)
|
||||||
|
-- give sprint
|
||||||
|
player:give_status_effect(50, 5.0)
|
||||||
|
end
|
||||||
|
|
|
@ -722,36 +722,20 @@ async fn main() {
|
||||||
|
|
||||||
println!("Found action: {:#?}", action_row);
|
println!("Found action: {:#?}", action_row);
|
||||||
|
|
||||||
// send new status list
|
let lua = lua.lock().unwrap();
|
||||||
{
|
lua.scope(|scope| {
|
||||||
let ipc = ServerZoneIpcSegment {
|
let connection_data = scope
|
||||||
op_code: ServerZoneIpcType::StatusEffectList,
|
.create_userdata_ref_mut(&mut lua_player)
|
||||||
timestamp: timestamp_secs(),
|
.unwrap();
|
||||||
data: ServerZoneIpcData::StatusEffectList(
|
|
||||||
kawari::world::ipc::StatusEffectList {
|
|
||||||
statues: [StatusEffect {
|
|
||||||
effect_id: 50,
|
|
||||||
param: 0,
|
|
||||||
duration: 50.0,
|
|
||||||
source_actor_id: connection
|
|
||||||
.player_data
|
|
||||||
.actor_id,
|
|
||||||
};
|
|
||||||
30],
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
connection
|
let func: Function =
|
||||||
.send_segment(PacketSegment {
|
lua.globals().get("doAction").unwrap();
|
||||||
source_actor: connection.player_data.actor_id,
|
|
||||||
target_actor: connection.player_data.actor_id,
|
func.call::<()>(connection_data).unwrap();
|
||||||
segment_type: SegmentType::Ipc { data: ipc },
|
|
||||||
|
Ok(())
|
||||||
})
|
})
|
||||||
.await;
|
.unwrap();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ClientZoneIpcData::Unk16 { .. } => {
|
ClientZoneIpcData::Unk16 { .. } => {
|
||||||
tracing::info!("Recieved Unk16!");
|
tracing::info!("Recieved Unk16!");
|
||||||
|
|
|
@ -14,7 +14,8 @@ use super::{
|
||||||
Inventory, Item, Zone,
|
Inventory, Item, Zone,
|
||||||
ipc::{
|
ipc::{
|
||||||
ActorSetPos, ClientZoneIpcSegment, ContainerInfo, ContainerType, InitZone, ItemInfo,
|
ActorSetPos, ClientZoneIpcSegment, ContainerInfo, ContainerType, InitZone, ItemInfo,
|
||||||
ServerZoneIpcData, ServerZoneIpcSegment, UpdateClassInfo, WeatherChange,
|
ServerZoneIpcData, ServerZoneIpcSegment, StatusEffect, StatusEffectList, UpdateClassInfo,
|
||||||
|
WeatherChange,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -299,6 +300,29 @@ impl LuaPlayer {
|
||||||
segment_type: SegmentType::Ipc { data: ipc },
|
segment_type: SegmentType::Ipc { data: ipc },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn give_status_effect(&mut self, effect_id: u16, duration: f32) {
|
||||||
|
let ipc = ServerZoneIpcSegment {
|
||||||
|
op_code: ServerZoneIpcType::StatusEffectList,
|
||||||
|
timestamp: timestamp_secs(),
|
||||||
|
data: ServerZoneIpcData::StatusEffectList(StatusEffectList {
|
||||||
|
statues: [StatusEffect {
|
||||||
|
effect_id,
|
||||||
|
param: 0,
|
||||||
|
duration,
|
||||||
|
source_actor_id: self.player_data.actor_id,
|
||||||
|
}; 30],
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
self.queue_segment(PacketSegment {
|
||||||
|
source_actor: self.player_data.actor_id,
|
||||||
|
target_actor: self.player_data.actor_id,
|
||||||
|
segment_type: SegmentType::Ipc { data: ipc },
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UserData for LuaPlayer {
|
impl UserData for LuaPlayer {
|
||||||
|
@ -307,5 +331,12 @@ impl UserData for LuaPlayer {
|
||||||
this.send_message(&message);
|
this.send_message(&message);
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
methods.add_method_mut(
|
||||||
|
"give_status_effect",
|
||||||
|
|_, this, (effect_id, duration): (u16, f32)| {
|
||||||
|
this.give_status_effect(effect_id, duration);
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue