diff --git a/src/common/mod.rs b/src/common/mod.rs index 5cb3a48..a917696 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -70,15 +70,28 @@ pub unsafe fn is_airborne(module_accessor: &mut app::BattleObjectModuleAccessor) situation_kind == SITUATION_KIND_AIR } -pub unsafe fn is_idle(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool { - let status_kind = StatusModule::status_kind(module_accessor); +pub fn is_idle(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool { + let status_kind; + unsafe { + status_kind = StatusModule::status_kind(module_accessor); + } status_kind == FIGHTER_STATUS_KIND_WAIT } -pub unsafe fn is_in_hitstun(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool { - let status_kind = StatusModule::status_kind(module_accessor); +pub fn is_in_hitstun(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool { + let status_kind; + unsafe { + status_kind = StatusModule::status_kind(module_accessor); + } (*FIGHTER_STATUS_KIND_DAMAGE..=*FIGHTER_STATUS_KIND_DAMAGE_FALL).contains(&status_kind) } +pub fn is_in_footstool(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool { + let status_kind; + unsafe { + status_kind = StatusModule::status_kind(module_accessor); + } + (*FIGHTER_STATUS_KIND_TREAD_DAMAGE..=*FIGHTER_STATUS_KIND_TREAD_FALL).contains(&status_kind) +} pub fn is_shielding(module_accessor: *mut app::BattleObjectModuleAccessor) -> bool { unsafe { diff --git a/src/training/mash.rs b/src/training/mash.rs index 29e93ff..4bdd6d1 100644 --- a/src/training/mash.rs +++ b/src/training/mash.rs @@ -116,20 +116,65 @@ unsafe fn check_buffer(module_accessor: &mut app::BattleObjectModuleAccessor) { Reset when CPU is idle to prevent deadlocks and to reset when using the training mode reset */ - if is_idle(module_accessor) { + if should_reset(module_accessor) { reset(); } return; } - if !is_in_hitstun(module_accessor) && MENU.mash_in_neutral != OnOff::On { + if !should_buffer(module_accessor) { return; } buffer_menu_mash(module_accessor); } +fn should_reset(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool { + if !is_idle(module_accessor) { + return false; + } + + let prev_status; + + unsafe { + prev_status = StatusModule::prev_status_kind(module_accessor, 0); + } + + // Don't reset after teching + if prev_status == *FIGHTER_STATUS_KIND_DOWN { + return false; + } + + if prev_status == *FIGHTER_STATUS_KIND_PASSIVE { + return false; + } + + if prev_status == *FIGHTER_STATUS_KIND_PASSIVE_FB { + return false; + } + + return true; +} + +fn should_buffer(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool { + unsafe{ + if MENU.mash_in_neutral == OnOff::On { + return true; + } + } + + if is_in_hitstun(module_accessor) { + return true; + } + + if is_in_footstool(module_accessor) { + return true; + } + + return false; +} + // Temp Translation pub fn buffer_menu_mash(module_accessor: &mut app::BattleObjectModuleAccessor) -> Action { unsafe {