diff --git a/src/training/left_stick.rs b/src/training/left_stick.rs index 3f172ca..a0794bf 100644 --- a/src/training/left_stick.rs +++ b/src/training/left_stick.rs @@ -10,66 +10,57 @@ static mut STICK_DIRECTION: Direction = Direction::None; pub unsafe fn mod_get_stick_x( module_accessor: &mut app::BattleObjectModuleAccessor, ) -> Option { - if !is_training_mode() { - return None; - } - - if !is_operation_cpu(module_accessor) { - return None; - } - - let status_kind = StatusModule::status_kind(module_accessor); - if !status_kind == FIGHTER_STATUS_KIND_ESCAPE_AIR { - return None; - } - - STICK_DIRECTION = MENU.di_state; - let mut angle: f64 = get_angle(STICK_DIRECTION); + let angle: f64 = get_angle(module_accessor); if angle == ANGLE_NONE { return None; } - // If facing left, reverse angle - if PostureModule::lr(module_accessor) != FIGHTER_FACING_RIGHT { - angle -= PI; - } - Some(angle.cos() as f32) } pub unsafe fn mod_get_stick_y( module_accessor: &mut app::BattleObjectModuleAccessor, ) -> Option { - if !is_training_mode() { - return None; - } - - if !is_operation_cpu(module_accessor) { - return None; - } - - let status_kind = StatusModule::status_kind(module_accessor); - if !status_kind == FIGHTER_STATUS_KIND_ESCAPE_AIR { - return None; - } - - STICK_DIRECTION = MENU.di_state; - let mut angle: f64 = get_angle(STICK_DIRECTION); + let angle: f64 = get_angle(module_accessor); if angle == ANGLE_NONE { return None; } + Some(angle.sin() as f32) +} + +unsafe fn get_angle(module_accessor: &mut app::BattleObjectModuleAccessor) -> f64 { + if !is_training_mode() { + return ANGLE_NONE; + } + + if !is_operation_cpu(module_accessor) { + return ANGLE_NONE; + } + + // Currently used for air dodge//Drift only + if !(is_airborne(module_accessor) && is_in_hitstun(module_accessor)) { + return ANGLE_NONE; + } + + STICK_DIRECTION = MENU.di_state; + let mut angle: f64 = pick_angle(STICK_DIRECTION); + + if angle == ANGLE_NONE { + return ANGLE_NONE; + } + // If facing left, reverse angle if PostureModule::lr(module_accessor) != FIGHTER_FACING_RIGHT { angle -= PI; } - Some(angle.sin() as f32) + angle } -unsafe fn get_angle(direction: Direction) -> f64 { +unsafe fn pick_angle(direction: Direction) -> f64 { if direction == Direction::Random { let rand_direction = get_random_direction(); return direction_to_angle(rand_direction);