From a2dca1d5feb367446f848c52bf01d0545d0698d6 Mon Sep 17 00:00:00 2001 From: Andy Newjack Date: Wed, 8 Apr 2020 19:41:12 -0300 Subject: [PATCH 1/3] 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 } } From 895891fabc3b58fb366a2628fc4042ca6ca3ae1c Mon Sep 17 00:00:00 2001 From: Andy Newjack Date: Wed, 8 Apr 2020 20:02:06 -0300 Subject: [PATCH 2/3] oops forgot to handle missing specials --- src/entity/item/weapon.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entity/item/weapon.rs b/src/entity/item/weapon.rs index 10c698b..0309cb8 100644 --- a/src/entity/item/weapon.rs +++ b/src/entity/item/weapon.rs @@ -893,7 +893,7 @@ impl Weapon { let mut result = [0u8; 16]; result[0..3].copy_from_slice(&self.weapon.value()); result[3] = self.grind; - result[4] = self.special.unwrap().value(); + result[4] = self.special.unwrap_or(WeaponSpecial::None).value(); if self.tekked == false { result[4] += 0x80 From 332f22f34ec9066bee9176c853001cd92d4cd6a5 Mon Sep 17 00:00:00 2001 From: Andy Newjack Date: Fri, 10 Apr 2020 02:04:37 -0300 Subject: [PATCH 3/3] weapon % fix v2 and give the level 199 guy a 100h hell gun --- src/entity/item/weapon.rs | 15 +++++++-------- src/main.rs | 6 ++++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/entity/item/weapon.rs b/src/entity/item/weapon.rs index 0309cb8..b9fee33 100644 --- a/src/entity/item/weapon.rs +++ b/src/entity/item/weapon.rs @@ -3,8 +3,7 @@ use serde::{Serialize, Deserialize}; #[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)] pub enum Attribute { - None, - Native, + Native = 1, ABeast, Machine, Dark, @@ -26,8 +25,7 @@ impl WeaponAttribute { #[derive(Debug, Copy, Clone, PartialEq)] pub enum WeaponSpecial { - None, - Draw, + Draw = 1, Drain, Fill, Gush, @@ -893,15 +891,16 @@ impl Weapon { let mut result = [0u8; 16]; result[0..3].copy_from_slice(&self.weapon.value()); result[3] = self.grind; - result[4] = self.special.unwrap_or(WeaponSpecial::None).value(); + result[4] = self.special.map(|s| s.value()).unwrap_or(0); 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[6..8].copy_from_slice(&self.attrs[0].map(|s| s.value()).unwrap_or([0,0])); + result[8..10].copy_from_slice(&self.attrs[1].map(|s| s.value()).unwrap_or([0,0])); + result[10..12].copy_from_slice(&self.attrs[2].map(|s| s.value()).unwrap_or([0,0])); + result } } diff --git a/src/main.rs b/src/main.rs index f587da2..4e06152 100644 --- a/src/main.rs +++ b/src/main.rs @@ -87,8 +87,10 @@ fn main() { item::weapon::Weapon { weapon: item::weapon::WeaponType::Handgun, grind: 5, - special: None, - attrs: [None; 3], + special: Some(item::weapon::WeaponSpecial::Hell), + attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 100}), + None, + None,], tekked: true, } ),