From a2dca1d5feb367446f848c52bf01d0545d0698d6 Mon Sep 17 00:00:00 2001 From: Andy Newjack Date: Wed, 8 Apr 2020 19:41:12 -0300 Subject: [PATCH] send all the weapon bytes --- src/entity/item/weapon.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/entity/item/weapon.rs b/src/entity/item/weapon.rs index 3cc2db9..10c698b 100644 --- a/src/entity/item/weapon.rs +++ b/src/entity/item/weapon.rs @@ -3,6 +3,7 @@ use serde::{Serialize, Deserialize}; #[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)] pub enum Attribute { + None, Native, ABeast, Machine, @@ -16,9 +17,16 @@ pub struct WeaponAttribute { pub value: i8, } +impl WeaponAttribute { + pub fn value(&self) -> [u8; 2] { + [self.attr as u8, self.value as u8] + } +} + #[derive(Debug, Copy, Clone, PartialEq)] pub enum WeaponSpecial { + None, Draw, Drain, Fill, @@ -61,6 +69,12 @@ pub enum WeaponSpecial { Demons, } +impl WeaponSpecial { + pub fn value(&self) -> u8 { + *self as u8 + } +} + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, enum_utils::FromStr, derive_more::Display)] pub enum WeaponType { Saber, @@ -879,7 +893,15 @@ impl Weapon { let mut result = [0u8; 16]; result[0..3].copy_from_slice(&self.weapon.value()); result[3] = self.grind; - // TODO: percents + result[4] = self.special.unwrap().value(); + + if self.tekked == false { + result[4] += 0x80 + }; + + result[6..8].copy_from_slice(&self.attrs[0].unwrap_or(WeaponAttribute{attr: Attribute::None, value: 0}).value()); + result[8..10].copy_from_slice(&self.attrs[1].unwrap_or(WeaponAttribute{attr: Attribute::None, value: 0}).value()); + result[10..12].copy_from_slice(&self.attrs[2].unwrap_or(WeaponAttribute{attr: Attribute::None, value: 0}).value()); result } }