From a1a761889cf2a050164960d86aa01f1bc4c149fa Mon Sep 17 00:00:00 2001 From: jam1garner <8260240+jam1garner@users.noreply.github.com> Date: Sat, 16 May 2020 02:27:14 -0400 Subject: [PATCH] Move DI selection from const to an enum --- src/common/consts.rs | 22 +++++++++++++--------- src/common/mod.rs | 2 +- src/training/directional_influence.rs | 7 ++++--- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/common/consts.rs b/src/common/consts.rs index 6e71661..b7dd199 100644 --- a/src/common/consts.rs +++ b/src/common/consts.rs @@ -1,7 +1,5 @@ use smash::lib::lua_const::*; -pub const NONE: i32 = 0; - // Side Taunt // DI @@ -10,8 +8,14 @@ pub const NONE: i32 = 0; 0, pi/4, pi/2, 3pi/4, pi, 5pi/4, 3pi/2, 7pi/4 */ -/* DI */ -pub const DI_RANDOM_IN_AWAY: i32 = 9; +/// DI +#[repr(i32)] +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum DirectionalInfluence { + None = 0, + // lol what goes here jug smh my head + RandomInAway = 9, +} /// Mash Attack States #[repr(i32)] @@ -100,10 +104,10 @@ impl LedgeOption { pub fn into_status(&self) -> Option { Some( match self { - LedgeOption::Neutral => status = *FIGHTER_STATUS_KIND_CLIFF_CLIMB, - LedgeOption::Roll => status = *FIGHTER_STATUS_KIND_CLIFF_ESCAPE, - LedgeOption::Jump => status = *FIGHTER_STATUS_KIND_CLIFF_JUMP1, - LedgeOption::Attack => status = *FIGHTER_STATUS_KIND_CLIFF_ATTACK, + LedgeOption::Neutral => *FIGHTER_STATUS_KIND_CLIFF_CLIMB, + LedgeOption::Roll => *FIGHTER_STATUS_KIND_CLIFF_ESCAPE, + LedgeOption::Jump => *FIGHTER_STATUS_KIND_CLIFF_JUMP1, + LedgeOption::Attack => *FIGHTER_STATUS_KIND_CLIFF_ATTACK, _ => return None, } ) @@ -202,7 +206,7 @@ impl From for Defensive { #[repr(C)] pub struct TrainingModpackMenu { pub hitbox_vis: bool, - pub di_state: i32, + pub di_state: DirectionalInfluence, pub mash_attack_state: Attack, pub ledge_state: LedgeOption, pub tech_state: TechOption, diff --git a/src/common/mod.rs b/src/common/mod.rs index fab2a5a..189a4b2 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -7,7 +7,7 @@ use smash::hash40; pub static mut MENU_STRUCT: consts::TrainingModpackMenu = consts::TrainingModpackMenu { hitbox_vis: true, - di_state: NONE, + di_state: DirectionalInfluence::None, mash_attack_state: Attack::Nair, ledge_state: LedgeOption::Random, tech_state: TechOption::Random, diff --git a/src/training/directional_influence.rs b/src/training/directional_influence.rs index 7afc7d4..624270e 100644 --- a/src/training/directional_influence.rs +++ b/src/training/directional_influence.rs @@ -14,13 +14,14 @@ pub unsafe fn get_float( { if is_training_mode() && is_operation_cpu(module_accessor) && is_in_hitstun(module_accessor) { - if MENU.di_state != NONE { - let mut angle = (MENU.di_state - 1) as f64 * PI / 4.0; + if MENU.di_state != DirectionalInfluence::None { + let mut angle = (MENU.di_state as i32 - 1) as f64 * PI / 4.0; // Either 0 (right) or PI (left) - if MENU.di_state == DI_RANDOM_IN_AWAY { + if MENU.di_state == DirectionalInfluence::RandomInAway { angle = app::sv_math::rand(hash40("fighter"), 2) as f64 * PI; } + // If facing left, reverse angle if PostureModule::lr(module_accessor) != -1.0 { angle -= PI;