diff --git a/src/lib.rs b/src/lib.rs index 682c978..931794a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,7 +13,7 @@ use crate::common::consts::*; use crate::common::*; use skyline::c_str; -use skyline::libc::{c_void, fclose, fopen, fwrite}; +use skyline::libc::{c_void, mkdir, fclose, fopen, fwrite}; use skyline::nro::{self, NroInfo}; use smash::app::lua_bind::*; use smash::app::sv_system::{self}; @@ -25,35 +25,63 @@ use smash::lua2cpp::L2CFighterCommon; #[skyline::hook(replace = smash::lua2cpp::L2CFighterCommon_sub_guard_cont)] pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue { let module_accessor = sv_system::battle_object_module_accessor(fighter.lua_state_agent); - if (*menu).MASH_STATE == MASH_ATTACK && (*menu).ATTACK_STATE == MASH_GRAB { - 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, - ) == 0 - { + if is_training_mode() && is_operation_cpu(module_accessor) { + if (*menu).MASH_STATE == MASH_ATTACK && (*menu).ATTACK_STATE == MASH_GRAB { + 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, + ) == 0 + { + if WorkModule::is_enable_transition_term( + module_accessor, + *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_CATCH, + ) { + fighter.fighter_base.change_status( + L2CValue::new_int(*FIGHTER_STATUS_KIND_CATCH as u64), + L2CValue::new_bool(true), + ); + } + } + } + } + if (*menu).MASH_STATE == MASH_SPOTDODGE { + 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_CATCH, + *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE, ) { fighter.fighter_base.change_status( - L2CValue::new_int(*FIGHTER_STATUS_KIND_CATCH as u64), + L2CValue::new_int(*FIGHTER_STATUS_KIND_ESCAPE as u64), L2CValue::new_bool(true), ); } } } - } - if (*menu).MASH_STATE == MASH_SPOTDODGE { - 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, - ) { - fighter.fighter_base.change_status( - L2CValue::new_int(*FIGHTER_STATUS_KIND_ESCAPE as u64), - L2CValue::new_bool(true), - ); + if (*menu).MASH_STATE == MASH_UP_B { + 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, + // ) { + fighter.fighter_base.change_status( + L2CValue::new_int(*FIGHTER_STATUS_KIND_SPECIAL_HI as u64), + L2CValue::new_bool(false), + ); + // } + } + } + if (*menu).MASH_STATE == MASH_UP_SMASH { + 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, + // ) { + fighter.fighter_base.change_status( + L2CValue::new_int(*FIGHTER_STATUS_KIND_ATTACK_HI4_START as u64), + L2CValue::new_bool(false), + ); + // } } } } @@ -81,8 +109,9 @@ pub fn main() { common::menu = &mut common::menu_struct; let buffer = format!("{:x}", common::menu as u64); println!("Writing training_modpack.log with {}...\n", buffer); + mkdir("sd:/TrainingModpack/\u{0}".as_bytes().as_ptr(), 0777); let f = fopen( - "sd:/SaltySD/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/Mash.rs b/src/training/Mash.rs index 64f47b9..324dc1b 100644 --- a/src/training/Mash.rs +++ b/src/training/Mash.rs @@ -73,10 +73,6 @@ pub unsafe fn get_command_flag_cat( MASH_GRAB => *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_CATCH, _ => (), } - } else if category == 1 { - if (*menu).ATTACK_STATE == MASH_GRAB { - *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_CATCH; - } } } MASH_RANDOM => { @@ -152,16 +148,5 @@ pub unsafe fn check_button_on( } } - if [*CONTROL_PAD_BUTTON_ATTACK, *CONTROL_PAD_BUTTON_CATCH].contains(&button) { - if is_training_mode() && is_operation_cpu(module_accessor) { - if (*menu).MASH_STATE == MASH_ATTACK - && (*menu).ATTACK_STATE == MASH_GRAB - && is_in_shieldstun(module_accessor) - { - return Some(true); - } - } - } - None } diff --git a/src/training/Shield.rs b/src/training/Shield.rs index 7d52518..3cffd2c 100644 --- a/src/training/Shield.rs +++ b/src/training/Shield.rs @@ -44,6 +44,10 @@ pub unsafe fn should_hold_shield(module_accessor: &mut app::BattleObjectModuleAc // We will only drop shield if we are in shieldstun and our attack can be performed OOS if (*menu).MASH_STATE == MASH_ATTACK { if [MASH_NEUTRAL_B, MASH_SIDE_B, MASH_DOWN_B].contains(&(*menu).ATTACK_STATE) { + return false; + } + + if [MASH_SPOTDODGE, MASH_GRAB].contains(&(*menu).ATTACK_STATE) { return true; } } diff --git a/src/training/Tech.rs b/src/training/Tech.rs index ccd2508..559a4f9 100644 --- a/src/training/Tech.rs +++ b/src/training/Tech.rs @@ -68,12 +68,12 @@ pub unsafe fn should_perform_defensive_option( *FIGHTER_STATUS_KIND_DOWN_STAND_ATTACK, ] .contains(&prev_status) - // || [ - // *FIGHTER_STATUS_KIND_DOWN_STAND, - // *FIGHTER_STATUS_KIND_DOWN_STAND_FB, - // *FIGHTER_STATUS_KIND_DOWN_STAND_ATTACK, - // ] - // .contains(&status) + || [ + *FIGHTER_STATUS_KIND_DOWN_STAND, + *FIGHTER_STATUS_KIND_DOWN_STAND_FB, + *FIGHTER_STATUS_KIND_DOWN_STAND_ATTACK, + ] + .contains(&status) ) && ( WorkModule::is_enable_transition_term(