From b3cf1a69f47e9be1b9d6a7c1515fae76d70546e2 Mon Sep 17 00:00:00 2001 From: sidschingis Date: Wed, 10 Jun 2020 20:51:43 +0200 Subject: [PATCH] Code Formatting (#82) * Update TrainingModpackOverlay * Apply Auto Formatter --- TrainingModpackOverlay | 2 +- src/common/consts.rs | 48 +++++++++++------------ src/common/mod.rs | 12 +++--- src/hitbox_visualizer/mod.rs | 34 +++++------------ src/lib.rs | 11 ++++-- src/training/directional_influence.rs | 27 +++++++++---- src/training/ledge.rs | 5 ++- src/training/mash.rs | 4 +- src/training/mod.rs | 8 ++-- src/training/save_states.rs | 18 +++++---- src/training/shield.rs | 33 +++++++++++----- src/training/tech.rs | 55 +++++++++++++++++---------- 12 files changed, 144 insertions(+), 113 deletions(-) diff --git a/TrainingModpackOverlay b/TrainingModpackOverlay index 5a5350b..0361716 160000 --- a/TrainingModpackOverlay +++ b/TrainingModpackOverlay @@ -1 +1 @@ -Subproject commit 5a5350b52d53dec2ae3c1aa1ab0a158731daf640 +Subproject commit 036171692ee4c704d6794f7c263509c316f48a9c diff --git a/src/common/consts.rs b/src/common/consts.rs index 0a77ece..937b18c 100644 --- a/src/common/consts.rs +++ b/src/common/consts.rs @@ -31,7 +31,7 @@ pub enum Attack { UpB = 7, DownB = 8, UpSmash = 9, - Grab = 10 + Grab = 10, } impl From for Attack { @@ -50,7 +50,7 @@ impl From for Attack { 8 => DownB, 9 => UpSmash, 10 => Grab, - _ => panic!("Invalid mash attack state {}", x) + _ => panic!("Invalid mash attack state {}", x), } } } @@ -59,16 +59,14 @@ impl Attack { pub fn into_attack_air_kind(&self) -> Option { use Attack::*; - Some( - match self { - Nair => *FIGHTER_COMMAND_ATTACK_AIR_KIND_N, - Fair => *FIGHTER_COMMAND_ATTACK_AIR_KIND_F, - Bair => *FIGHTER_COMMAND_ATTACK_AIR_KIND_B, - Dair => *FIGHTER_COMMAND_ATTACK_AIR_KIND_LW, - UpAir => *FIGHTER_COMMAND_ATTACK_AIR_KIND_HI, - _ => return None, - } - ) + Some(match self { + Nair => *FIGHTER_COMMAND_ATTACK_AIR_KIND_N, + Fair => *FIGHTER_COMMAND_ATTACK_AIR_KIND_F, + Bair => *FIGHTER_COMMAND_ATTACK_AIR_KIND_B, + Dair => *FIGHTER_COMMAND_ATTACK_AIR_KIND_LW, + UpAir => *FIGHTER_COMMAND_ATTACK_AIR_KIND_HI, + _ => return None, + }) } } @@ -95,22 +93,20 @@ impl From for LedgeOption { 3 => Roll, 4 => Jump, 5 => Attack, - _ => panic!("Invalid ledge option {}", x) + _ => panic!("Invalid ledge option {}", x), } } } impl LedgeOption { pub fn into_status(&self) -> Option { - Some( - match self { - 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, - } - ) + Some(match self { + 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, + }) } } @@ -122,7 +118,7 @@ pub enum TechOption { Random = 1, InPlace = 2, Roll = 3, - Miss = 4 + Miss = 4, } impl From for TechOption { @@ -135,7 +131,7 @@ impl From for TechOption { 2 => InPlace, 3 => Roll, 4 => Miss, - _ => panic!("Invalid tech option {}", x) + _ => panic!("Invalid tech option {}", x), } } } @@ -165,7 +161,7 @@ impl From for Mash { 5 => Mash::RollForward, 6 => Mash::RollBack, 7 => Mash::Random, - _ => panic!("Invalid mash state {}", x) + _ => panic!("Invalid mash state {}", x), } } } @@ -202,7 +198,7 @@ impl From for Defensive { 3 => Roll, 4 => Jab, 5 => Shield, - _ => panic!("Invalid mash state {}", x) + _ => panic!("Invalid mash state {}", x), } } } diff --git a/src/common/mod.rs b/src/common/mod.rs index f43e882..9f1e192 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -2,8 +2,8 @@ pub mod consts; use crate::common::consts::*; use smash::app::{self, lua_bind::*}; -use smash::lib::lua_const::*; use smash::hash40; +use smash::lib::lua_const::*; pub static mut MENU_STRUCT: consts::TrainingModpackMenu = consts::TrainingModpackMenu { hitbox_vis: true, @@ -25,8 +25,8 @@ extern "C" { #[link_name = "\u{1}_ZN3app9smashball16is_training_modeEv"] pub fn is_training_mode() -> bool; - //#[link_name = "\u{1}_ZN3app7utility8get_kindEPKNS_26BattleObjectModuleAccessorE"] - //pub fn get_kind(module_accessor: &mut app::BattleObjectModuleAccessor) -> i32; +//#[link_name = "\u{1}_ZN3app7utility8get_kindEPKNS_26BattleObjectModuleAccessorE"] +//pub fn get_kind(module_accessor: &mut app::BattleObjectModuleAccessor) -> i32; } pub fn get_category(module_accessor: &mut app::BattleObjectModuleAccessor) -> i32 { @@ -46,7 +46,8 @@ pub unsafe fn is_operation_cpu(module_accessor: &mut app::BattleObjectModuleAcce WorkModule::get_int(module_accessor, *FIGHTER_INSTANCE_WORK_ID_INT_ENTRY_ID) as i32; let entry_id = app::FighterEntryID(entry_id_int); let mgr = *(FIGHTER_MANAGER_ADDR as *mut *mut app::FighterManager); - let fighter_information = FighterManager::get_fighter_information( mgr, entry_id) as *mut app::FighterInformation; + let fighter_information = + FighterManager::get_fighter_information(mgr, entry_id) as *mut app::FighterInformation; FighterInformation::is_operation_cpu(fighter_information) } @@ -72,7 +73,8 @@ pub unsafe fn is_in_shieldstun(module_accessor: &mut app::BattleObjectModuleAcce pub unsafe fn is_in_landing(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool { let status_kind = StatusModule::status_kind(module_accessor); - (*FIGHTER_STATUS_KIND_LANDING..=*FIGHTER_STATUS_KIND_LANDING_DAMAGE_LIGHT).contains(&status_kind) + (*FIGHTER_STATUS_KIND_LANDING..=*FIGHTER_STATUS_KIND_LANDING_DAMAGE_LIGHT) + .contains(&status_kind) } pub unsafe fn is_in_footstool(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool { diff --git a/src/hitbox_visualizer/mod.rs b/src/hitbox_visualizer/mod.rs index bf50b3a..b508f3c 100644 --- a/src/hitbox_visualizer/mod.rs +++ b/src/hitbox_visualizer/mod.rs @@ -160,8 +160,12 @@ pub unsafe fn get_command_flag_cat( ) { if is_training_mode() { // Pause Effect AnimCMD if hitbox visualization is active - MotionAnimcmdModule::set_sleep_effect(module_accessor, MENU.hitbox_vis - && !((*FIGHTER_STATUS_KIND_CATCH..=*FIGHTER_STATUS_KIND_TREAD_FALL).contains(&StatusModule::status_kind(module_accessor)))); + MotionAnimcmdModule::set_sleep_effect( + module_accessor, + MENU.hitbox_vis + && !((*FIGHTER_STATUS_KIND_CATCH..=*FIGHTER_STATUS_KIND_TREAD_FALL) + .contains(&StatusModule::status_kind(module_accessor))), + ); } // apply only once per frame @@ -170,17 +174,8 @@ pub unsafe fn get_command_flag_cat( if !(*FIGHTER_STATUS_KIND_CATCH..=*FIGHTER_STATUS_KIND_CATCH_TURN).contains(&status_kind) && !is_shielding(module_accessor) { - EffectModule::set_visible_kind( - module_accessor, - Hash40::new("sys_shield"), - false, - ); - EffectModule::kill_kind( - module_accessor, - Hash40::new("sys_shield"), - false, - true, - ); + EffectModule::set_visible_kind(module_accessor, Hash40::new("sys_shield"), false); + EffectModule::kill_kind(module_accessor, Hash40::new("sys_shield"), false, true); for i in 0..8 { if AttackModule::is_attack(module_accessor, i, false) { let attack_data = *AttackModule::attack_data(module_accessor, i, false); @@ -312,17 +307,8 @@ pub unsafe fn handle_set_rebound( if is_training_mode() && rebound == false { // only if we're not shielding if !is_shielding(module_accessor) { - EffectModule::set_visible_kind( - module_accessor, - Hash40::new("sys_shield"), - false, - ); - EffectModule::kill_kind( - module_accessor, - Hash40::new("sys_shield"), - false, - true, - ); + EffectModule::set_visible_kind(module_accessor, Hash40::new("sys_shield"), false); + EffectModule::kill_kind(module_accessor, Hash40::new("sys_shield"), false, true); } } diff --git a/src/lib.rs b/src/lib.rs index 6021ffc..c04f631 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,7 @@ mod training; use crate::common::*; use skyline::c_str; -use skyline::libc::{c_void, mkdir, fclose, fopen, fwrite}; +use skyline::libc::{c_void, fclose, fopen, fwrite, mkdir}; use skyline::nro::{self, NroInfo}; fn nro_main(nro: &NroInfo<'_>) { @@ -34,10 +34,15 @@ pub fn main() { unsafe { let buffer = format!("{:x}", MENU as *const _ as u64); - println!("[Training Modpack] Writing training_modpack.log with {}...", buffer); + println!( + "[Training Modpack] Writing training_modpack.log with {}...", + buffer + ); mkdir("sd:/TrainingModpack/\u{0}".as_bytes().as_ptr(), 0777); let f = fopen( - "sd:/TrainingModpack/training_modpack.log\u{0}".as_bytes().as_ptr(), + "sd:/TrainingModpack/training_modpack.log\u{0}" + .as_bytes() + .as_ptr(), "w\u{0}".as_bytes().as_ptr(), ); diff --git a/src/training/directional_influence.rs b/src/training/directional_influence.rs index a4bb024..6afc07d 100644 --- a/src/training/directional_influence.rs +++ b/src/training/directional_influence.rs @@ -1,17 +1,20 @@ -use crate::common::*; use crate::common::consts::*; +use crate::common::*; use core::f64::consts::PI; -use smash::app::{self, sv_system, lua_bind::*}; +use smash::app::{self, lua_bind::*, sv_system}; use smash::hash40; use smash::lib::lua_const::*; use smash::lib::L2CValue; use smash::lua2cpp::L2CFighterCommon; -pub static mut DI_ANGLE : f64 = 0.0; -pub static NO_DI : f64 = -69.0; +pub static mut DI_ANGLE: f64 = 0.0; +pub static NO_DI: f64 = -69.0; #[skyline::hook(replace = smash::lua2cpp::L2CFighterCommon_FighterStatusDamage__correctDamageVectorCommon)] -pub unsafe fn handle_correct_damage_vector_common(fighter: &mut L2CFighterCommon, arg1: L2CValue) -> L2CValue { +pub unsafe fn handle_correct_damage_vector_common( + fighter: &mut L2CFighterCommon, + arg1: L2CValue, +) -> L2CValue { let module_accessor = sv_system::battle_object_module_accessor(fighter.lua_state_agent); if is_training_mode() && is_operation_cpu(module_accessor) { if MENU.di_state != DirectionalInfluence::None { @@ -19,7 +22,7 @@ pub unsafe fn handle_correct_damage_vector_common(fighter: &mut L2CFighterCommon // Either left, right, or none if MENU.di_state == DirectionalInfluence::RandomInAway { - let rand = app::sv_math::rand(hash40("fighter"), 3) ; + let rand = app::sv_math::rand(hash40("fighter"), 3); // Either 0 (right) or PI (left) if [0, 1].contains(&rand) { DI_ANGLE = rand as f64 * PI; @@ -33,8 +36,16 @@ pub unsafe fn handle_correct_damage_vector_common(fighter: &mut L2CFighterCommon } if DI_ANGLE != NO_DI { - WorkModule::set_float(module_accessor, DI_ANGLE.cos() as f32, *FIGHTER_STATUS_DAMAGE_WORK_FLOAT_VECOR_CORRECT_STICK_X); - WorkModule::set_float(module_accessor, DI_ANGLE.sin() as f32, *FIGHTER_STATUS_DAMAGE_WORK_FLOAT_VECOR_CORRECT_STICK_Y); + WorkModule::set_float( + module_accessor, + DI_ANGLE.cos() as f32, + *FIGHTER_STATUS_DAMAGE_WORK_FLOAT_VECOR_CORRECT_STICK_X, + ); + WorkModule::set_float( + module_accessor, + DI_ANGLE.sin() as f32, + *FIGHTER_STATUS_DAMAGE_WORK_FLOAT_VECOR_CORRECT_STICK_Y, + ); } } } diff --git a/src/training/ledge.rs b/src/training/ledge.rs index b3483a9..ba70a26 100644 --- a/src/training/ledge.rs +++ b/src/training/ledge.rs @@ -91,7 +91,10 @@ pub unsafe fn get_command_flag_cat( category: i32, flag: &mut i32, ) { - if MENU.ledge_state != LedgeOption::None && is_training_mode() && is_operation_cpu(module_accessor) { + if MENU.ledge_state != LedgeOption::None + && is_training_mode() + && is_operation_cpu(module_accessor) + { force_option(module_accessor); defensive_option(module_accessor, category, flag); } diff --git a/src/training/mash.rs b/src/training/mash.rs index 6547009..d79b8a3 100644 --- a/src/training/mash.rs +++ b/src/training/mash.rs @@ -153,7 +153,9 @@ pub unsafe fn check_button_on( if [*CONTROL_PAD_BUTTON_GUARD_HOLD, *CONTROL_PAD_BUTTON_GUARD].contains(&button) { if is_training_mode() && is_operation_cpu(module_accessor) { if MENU.mash_state == Mash::Airdodge - && (is_in_hitstun(module_accessor) || is_in_landing(module_accessor) || is_in_footstool(module_accessor)) + && (is_in_hitstun(module_accessor) + || is_in_landing(module_accessor) + || is_in_footstool(module_accessor)) { return Some(true); } diff --git a/src/training/mod.rs b/src/training/mod.rs index 244bb08..aa663cf 100644 --- a/src/training/mod.rs +++ b/src/training/mod.rs @@ -144,23 +144,21 @@ pub fn training_mods() { unsafe { LookupSymbol( &mut FIGHTER_MANAGER_ADDR, - "_ZN3lib9SingletonIN3app14FighterManagerEE9instance_E\u{0}".as_bytes().as_ptr(), + "_ZN3lib9SingletonIN3app14FighterManagerEE9instance_E\u{0}" + .as_bytes() + .as_ptr(), ); } skyline::install_hooks!( // Mash airdodge/jump handle_get_command_flag_cat, - // Hold/Infinite shield handle_check_button_on, handle_check_button_off, - handle_get_param_float, - // Mash attack handle_get_attack_air_kind, - // Tech options handle_change_motion, ); diff --git a/src/training/save_states.rs b/src/training/save_states.rs index e576174..62bdedc 100644 --- a/src/training/save_states.rs +++ b/src/training/save_states.rs @@ -1,7 +1,7 @@ use crate::common::*; use smash::app::{self, lua_bind::*}; use smash::lib::lua_const::*; -use smash::phx::{Vector3f, Hash40}; +use smash::phx::{Hash40, Vector3f}; #[derive(PartialEq)] enum SaveState { @@ -68,8 +68,8 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) if *save_state == CameraMove { *save_state = PosMove; - let left_right = - (PostureModule::pos_x(module_accessor) > 0.0) as i32 as f32 - (PostureModule::pos_x(module_accessor) < 0.0) as i32 as f32; + let left_right = (PostureModule::pos_x(module_accessor) > 0.0) as i32 as f32 + - (PostureModule::pos_x(module_accessor) < 0.0) as i32 as f32; let y_pos = 20.0; let pos = Vector3f { @@ -81,7 +81,11 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) // force aerial, because from aerial state we can move anywhere if StatusModule::situation_kind(module_accessor) == SITUATION_KIND_GROUND { - StatusModule::change_status_request(module_accessor, *FIGHTER_STATUS_KIND_JUMP_SQUAT, false); + StatusModule::change_status_request( + module_accessor, + *FIGHTER_STATUS_KIND_JUMP_SQUAT, + false, + ); } return; } @@ -124,8 +128,7 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) *FIGHTER_STATUS_KIND_CLIFF_WAIT, false, ); - } - else if *save_state_situation_kind == SITUATION_KIND_AIR + } else if *save_state_situation_kind == SITUATION_KIND_AIR && status != FIGHTER_STATUS_KIND_FALL { StatusModule::change_status_request( @@ -133,8 +136,7 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) *FIGHTER_STATUS_KIND_FALL, false, ); - } - else if *save_state_situation_kind == SITUATION_KIND_CLIFF + } else if *save_state_situation_kind == SITUATION_KIND_CLIFF && status != FIGHTER_STATUS_KIND_CLIFF_CATCH_MOVE && status != FIGHTER_STATUS_KIND_CLIFF_CATCH { diff --git a/src/training/shield.rs b/src/training/shield.rs index a19dab9..9fde5fb 100644 --- a/src/training/shield.rs +++ b/src/training/shield.rs @@ -1,10 +1,10 @@ use crate::common::consts::*; use crate::common::*; use smash::app; -use smash::hash40; -use smash::lib::lua_const::*; use smash::app::lua_bind::*; use smash::app::sv_system; +use smash::hash40; +use smash::lib::lua_const::*; use smash::lib::L2CValue; use smash::lua2cpp::L2CFighterCommon; @@ -154,8 +154,9 @@ pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue // Enable shield decay if is_training_mode() - && is_operation_cpu(module_accessor) - && StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE { + && is_operation_cpu(module_accessor) + && StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE + { set_shield_decay(true); } @@ -169,7 +170,9 @@ pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue if is_training_mode() && is_operation_cpu(module_accessor) { if MENU.mash_state == Mash::Attack && MENU.mash_attack_state == Attack::Grab { - if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE { + if StatusModule::prev_status_kind(module_accessor, 0) + == FIGHTER_STATUS_KIND_GUARD_DAMAGE + { if WorkModule::get_int( module_accessor, *FIGHTER_INSTANCE_WORK_ID_INT_INVALID_CATCH_FRAME, @@ -188,7 +191,9 @@ pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue } } if MENU.mash_state == Mash::Spotdodge { - if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE { + if StatusModule::prev_status_kind(module_accessor, 0) + == FIGHTER_STATUS_KIND_GUARD_DAMAGE + { if WorkModule::is_enable_transition_term( module_accessor, *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE, @@ -201,7 +206,9 @@ pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue } } if MENU.mash_state == Mash::RollForward { - if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE { + if StatusModule::prev_status_kind(module_accessor, 0) + == FIGHTER_STATUS_KIND_GUARD_DAMAGE + { if WorkModule::is_enable_transition_term( module_accessor, *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE, @@ -214,7 +221,9 @@ pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue } } if MENU.mash_state == Mash::RollBack { - if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE { + if StatusModule::prev_status_kind(module_accessor, 0) + == FIGHTER_STATUS_KIND_GUARD_DAMAGE + { if WorkModule::is_enable_transition_term( module_accessor, *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE, @@ -228,7 +237,9 @@ pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue } if MENU.mash_state == Mash::Attack { if MENU.mash_attack_state == Attack::UpB { - if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE { + if StatusModule::prev_status_kind(module_accessor, 0) + == FIGHTER_STATUS_KIND_GUARD_DAMAGE + { if WorkModule::is_enable_transition_term( module_accessor, *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_JUMP_SQUAT_BUTTON, @@ -241,7 +252,9 @@ pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue } } if MENU.mash_attack_state == Attack::UpSmash { - if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE { + if StatusModule::prev_status_kind(module_accessor, 0) + == FIGHTER_STATUS_KIND_GUARD_DAMAGE + { if WorkModule::is_enable_transition_term( module_accessor, *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_JUMP_SQUAT_BUTTON, diff --git a/src/training/tech.rs b/src/training/tech.rs index 5ea07b5..45d4f08 100644 --- a/src/training/tech.rs +++ b/src/training/tech.rs @@ -1,20 +1,28 @@ use crate::common::consts::*; use crate::common::*; +use smash::app::sv_system; use smash::app::{self, lua_bind::*}; use smash::hash40; use smash::lib::lua_const::*; -use smash::app::sv_system; use smash::lib::L2CValue; use smash::lua2cpp::L2CFighterBase; #[skyline::hook(replace = smash::lua2cpp::L2CFighterBase_change_status)] -pub unsafe fn handle_change_status(fighter: &mut L2CFighterBase, status_kind: L2CValue, unk: L2CValue) -> L2CValue { +pub unsafe fn handle_change_status( + fighter: &mut L2CFighterBase, + status_kind: L2CValue, + unk: L2CValue, +) -> L2CValue { let mut status_kind = status_kind; let mut unk = unk; let module_accessor = sv_system::battle_object_module_accessor(fighter.lua_state_agent); if is_training_mode() && is_operation_cpu(module_accessor) { - let status_kind_int = status_kind.try_get_int().unwrap_or(*FIGHTER_STATUS_KIND_WAIT as u64) as i32; - if status_kind_int == FIGHTER_STATUS_KIND_DOWN || status_kind_int == FIGHTER_STATUS_KIND_DAMAGE_FLY_REFLECT_D { + let status_kind_int = status_kind + .try_get_int() + .unwrap_or(*FIGHTER_STATUS_KIND_WAIT as u64) as i32; + if status_kind_int == FIGHTER_STATUS_KIND_DOWN + || status_kind_int == FIGHTER_STATUS_KIND_DAMAGE_FLY_REFLECT_D + { match MENU.tech_state { TechOption::Random => { let random_statuses = vec![ @@ -27,7 +35,8 @@ pub unsafe fn handle_change_status(fighter: &mut L2CFighterBase, status_kind: L2 app::sv_math::rand(hash40("fighter"), random_statuses.len() as i32) as usize; if random_statuses[random_status_index] != FIGHTER_STATUS_KIND_DOWN { - status_kind = L2CValue::new_int(random_statuses[random_status_index] as u64); + status_kind = + L2CValue::new_int(random_statuses[random_status_index] as u64); unk = L2CValue::new_bool(true); } } @@ -41,12 +50,16 @@ pub unsafe fn handle_change_status(fighter: &mut L2CFighterBase, status_kind: L2 } _ => (), } - } else if status_kind_int == FIGHTER_STATUS_KIND_STOP_WALL || status_kind_int == FIGHTER_STATUS_KIND_DAMAGE_FLY_REFLECT_LR { + } else if status_kind_int == FIGHTER_STATUS_KIND_STOP_WALL + || status_kind_int == FIGHTER_STATUS_KIND_DAMAGE_FLY_REFLECT_LR + { if MENU.tech_state != TechOption::None && MENU.tech_state != TechOption::Miss { status_kind = L2CValue::new_int(*FIGHTER_STATUS_KIND_PASSIVE_WALL as u64); unk = L2CValue::new_bool(true); } - } else if status_kind_int == FIGHTER_STATUS_KIND_STOP_CEIL || status_kind_int == FIGHTER_STATUS_KIND_DAMAGE_FLY_REFLECT_U { + } else if status_kind_int == FIGHTER_STATUS_KIND_STOP_CEIL + || status_kind_int == FIGHTER_STATUS_KIND_DAMAGE_FLY_REFLECT_U + { if MENU.tech_state != TechOption::None && MENU.tech_state != TechOption::Miss { status_kind = L2CValue::new_int(*FIGHTER_STATUS_KIND_PASSIVE_CEIL as u64); unk = L2CValue::new_bool(true); @@ -75,18 +88,12 @@ pub unsafe fn should_perform_defensive_option( *FIGHTER_STATUS_KIND_DOWN_STAND_FB, *FIGHTER_STATUS_KIND_DOWN_STAND_ATTACK, ] - .contains(&status) - ) - && ( - WorkModule::is_enable_transition_term( - module_accessor, - *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_GUARD_ON, - ) - || - MotionModule::is_end(module_accessor) - || - CancelModule::is_enable_cancel(module_accessor) - ) + .contains(&status)) + && (WorkModule::is_enable_transition_term( + module_accessor, + *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_GUARD_ON, + ) || MotionModule::is_end(module_accessor) + || CancelModule::is_enable_cancel(module_accessor)) } pub unsafe fn get_command_flag_cat( @@ -94,7 +101,10 @@ pub unsafe fn get_command_flag_cat( _category: i32, flag: &mut i32, ) { - if MENU.tech_state != TechOption::None && is_training_mode() && is_operation_cpu(module_accessor) { + if MENU.tech_state != TechOption::None + && is_training_mode() + && is_operation_cpu(module_accessor) + { let prev_status = StatusModule::prev_status_kind(module_accessor, 0) as i32; let status = StatusModule::status_kind(module_accessor) as i32; if [ @@ -145,7 +155,10 @@ pub unsafe fn change_motion( module_accessor: &mut app::BattleObjectModuleAccessor, motion_kind: u64, ) -> Option { - if MENU.tech_state != TechOption::None && is_training_mode() && is_operation_cpu(module_accessor) { + if MENU.tech_state != TechOption::None + && is_training_mode() + && is_operation_cpu(module_accessor) + { if [hash40("passive_stand_f"), hash40("passive_stand_b")].contains(&motion_kind) { if app::sv_math::rand(hash40("fighter"), 2) != 0 { return Some(hash40("passive_stand_f"));