1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-04-23 23:57:46 +00:00

Create EffectKind enum to hold the different effect kinds

This commit is contained in:
Joshua Goins 2025-03-30 10:01:41 -04:00
parent 3d128c8fab
commit 7f75a378f4
4 changed files with 19 additions and 10 deletions

View file

@ -13,9 +13,9 @@ use kawari::packet::{
send_packet, send_packet,
}; };
use kawari::world::ipc::{ use kawari::world::ipc::{
ActionEffect, ActionResult, ClientZoneIpcData, CommonSpawn, DisplayFlag, GameMasterCommandType, ActionEffect, ActionResult, ClientZoneIpcData, CommonSpawn, DisplayFlag, EffectKind,
GameMasterRank, ObjectKind, OnlineStatus, PlayerSubKind, ServerZoneIpcData, GameMasterCommandType, GameMasterRank, ObjectKind, OnlineStatus, PlayerSubKind,
ServerZoneIpcSegment, SocialListRequestType, ServerZoneIpcData, ServerZoneIpcSegment, SocialListRequestType,
}; };
use kawari::world::{ use kawari::world::{
ChatHandler, Inventory, Zone, ZoneConnection, ChatHandler, Inventory, Zone, ZoneConnection,
@ -824,11 +824,10 @@ async fn main() {
connection.get_actor(request.target.object_id) connection.get_actor(request.target.object_id)
{ {
for effect in &effects_builder.effects { for effect in &effects_builder.effects {
match effect.action_type { match effect.kind {
3 => { EffectKind::Damage => {
actor.hp -= effect.value as u32; actor.hp -= effect.value as u32;
} }
_ => {}
} }
} }

View file

@ -2,11 +2,19 @@ use binrw::binrw;
use crate::common::{ObjectTypeId, read_quantized_rotation, write_quantized_rotation}; use crate::common::{ObjectTypeId, read_quantized_rotation, write_quantized_rotation};
#[binrw]
#[derive(Debug, Eq, PartialEq, Clone, Copy, Default)]
#[brw(repr = u8)]
pub enum EffectKind {
#[default]
Damage = 3,
}
#[binrw] #[binrw]
#[brw(little)] #[brw(little)]
#[derive(Debug, Clone, Copy, Default)] #[derive(Debug, Clone, Copy, Default)]
pub struct ActionEffect { pub struct ActionEffect {
pub action_type: u8, pub kind: EffectKind,
pub param0: u8, pub param0: u8,
pub param1: u8, pub param1: u8,
pub param2: u8, pub param2: u8,

View file

@ -60,7 +60,7 @@ mod event_start;
pub use event_start::EventStart; pub use event_start::EventStart;
mod action_result; mod action_result;
pub use action_result::{ActionEffect, ActionResult}; pub use action_result::{ActionEffect, ActionResult, EffectKind};
use crate::common::Position; use crate::common::Position;
use crate::common::read_string; use crate::common::read_string;

View file

@ -8,7 +8,9 @@ use crate::{
use super::{ use super::{
PlayerData, StatusEffects, Zone, PlayerData, StatusEffects, Zone,
ipc::{ActionEffect, ActorSetPos, EventPlay, ServerZoneIpcData, ServerZoneIpcSegment}, ipc::{
ActionEffect, ActorSetPos, EffectKind, EventPlay, ServerZoneIpcData, ServerZoneIpcSegment,
},
}; };
pub struct ChangeTerritoryTask { pub struct ChangeTerritoryTask {
@ -171,7 +173,7 @@ impl UserData for EffectsBuilder {
fn add_methods<M: UserDataMethods<Self>>(methods: &mut M) { fn add_methods<M: UserDataMethods<Self>>(methods: &mut M) {
methods.add_method_mut("damage", |_, this, amount: u16| { methods.add_method_mut("damage", |_, this, amount: u16| {
this.effects.push(ActionEffect { this.effects.push(ActionEffect {
action_type: 3, kind: EffectKind::Damage,
value: amount, value: amount,
param1: 133, param1: 133,
..Default::default() ..Default::default()