From 1ef4078ec15e2a3d49d21164819d5ab2aeb63496 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 29 Mar 2025 14:38:40 -0400 Subject: [PATCH] Fixes and workarounds for battling --- resources/scripts/test.lua | 3 ++- src/bin/kawari-world.rs | 19 +++++++++++++------ src/world/connection.rs | 4 ++-- src/world/ipc/action_result.rs | 13 ++++++++++++- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/resources/scripts/test.lua b/resources/scripts/test.lua index f2d23a0..bfbfc76 100644 --- a/resources/scripts/test.lua +++ b/resources/scripts/test.lua @@ -5,5 +5,6 @@ end function doAction(player) -- give sprint - player:give_status_effect(50, 5.0) + -- commented out because it breaks other stats due to stubs + --player:give_status_effect(50, 5.0) end diff --git a/src/bin/kawari-world.rs b/src/bin/kawari-world.rs index 24bebdc..775e909 100644 --- a/src/bin/kawari-world.rs +++ b/src/bin/kawari-world.rs @@ -814,6 +814,14 @@ async fn main() { // tell them the action results { + let mut effects = [ActionEffect::default(); 8]; + effects[0] = ActionEffect { + action_type: 3, + value: 22, + param1: 133, + ..Default::default() + }; + let ipc = ServerZoneIpcSegment { op_code: ServerZoneIpcType::ActionResult, timestamp: timestamp_secs(), @@ -823,18 +831,17 @@ async fn main() { object_id: ObjectId(0x106ad804), object_type: 0, }, + target_id_again: ObjectTypeId { + object_id: ObjectId(0x106ad804), + object_type: 0, + }, action_id: 31, animation_lock_time: 0.6, rotation: connection.player_data.rotation, action_animation_id: 31, flag: 1, effect_count: 1, - effects: [ActionEffect { - action_type: 3, - value: 50, - ..Default::default() - }; - 8], + effects, ..Default::default() }, ), diff --git a/src/world/connection.rs b/src/world/connection.rs index 541a350..2ac33f5 100644 --- a/src/world/connection.rs +++ b/src/world/connection.rs @@ -348,8 +348,8 @@ impl ZoneConnection { }; self.send_segment(PacketSegment { - source_actor: self.player_data.actor_id, - target_actor: actor_id.0, + source_actor: actor_id.0, + target_actor: self.player_data.actor_id, segment_type: SegmentType::Ipc { data: ipc }, }) .await; diff --git a/src/world/ipc/action_result.rs b/src/world/ipc/action_result.rs index 48cf59f..8092551 100644 --- a/src/world/ipc/action_result.rs +++ b/src/world/ipc/action_result.rs @@ -35,8 +35,9 @@ pub struct ActionResult { pub effect_count: u8, pub unk4: u16, pub unk5: [u8; 6], - #[brw(pad_after = 18)] // idk, target is here too? pub effects: [ActionEffect; 8], + #[brw(pad_before = 6, pad_after = 4)] + pub target_id_again: ObjectTypeId, } #[cfg(test)] @@ -59,6 +60,10 @@ mod tests { let action_result = ActionResult::read_le(&mut buffer).unwrap(); assert_eq!(action_result.main_target.object_id, ObjectId(0x400097d0)); + assert_eq!( + action_result.target_id_again.object_id, + ObjectId(0x400097d0) + ); assert_eq!(action_result.action_id, 31); assert_eq!(action_result.animation_lock_time, 0.6); assert_eq!(action_result.rotation, 1.9694216); @@ -68,6 +73,12 @@ mod tests { // effect 0: attack assert_eq!(action_result.effects[0].action_type, 3); + assert_eq!(action_result.effects[0].param0, 0); + assert_eq!(action_result.effects[0].param1, 113); + assert_eq!(action_result.effects[0].param2, 0); + assert_eq!(action_result.effects[0].param3, 0); + assert_eq!(action_result.effects[0].param4, 0); + assert_eq!(action_result.effects[0].value, 22); // effect 1: start action combo assert_eq!(action_result.effects[1].action_type, 27);