diff --git a/src/lib.rs b/src/lib.rs index c6d03c8..2741442 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,6 +42,7 @@ fn nro_main(nro: &NroInfo<'_>) { training::shield::handle_sub_guard_cont, training::directional_influence::handle_correct_damage_vector_common, training::tech::handle_change_status, + training::tech::mod_is_enable_passive, ); } } diff --git a/src/training/tech.rs b/src/training/tech.rs index 894c9cd..9f98108 100644 --- a/src/training/tech.rs +++ b/src/training/tech.rs @@ -6,11 +6,12 @@ use smash::app::{self, lua_bind::*}; use smash::hash40; use smash::lib::lua_const::*; use smash::lib::L2CValue; -use smash::lua2cpp::L2CFighterBase; +use smash::lua2cpp::{L2CFighterBase, L2CFighterCommon}; static mut TECH_ROLL_DIRECTION: Direction = Direction::empty(); static mut MISS_TECH_ROLL_DIRECTION: Direction = Direction::empty(); static mut FRAME_COUNTER: usize = 0; +static mut CAN_TECH: bool = false; pub fn init() { unsafe { @@ -18,6 +19,18 @@ pub fn init() { } } +#[skyline::hook(replace = smash::lua2cpp::L2CFighterCommon_is_enable_passive)] +pub unsafe fn mod_is_enable_passive( + fighter: &mut L2CFighterCommon, +) -> L2CValue { + let ori = original!()(fighter); + let module_accessor = sv_system::battle_object_module_accessor(fighter.lua_state_agent); + if is_training_mode() && is_operation_cpu(module_accessor) { + CAN_TECH = ori.get_bool(); + } + ori +} + #[skyline::hook(replace = smash::lua2cpp::L2CFighterBase_change_status)] pub unsafe fn handle_change_status( fighter: &mut L2CFighterBase, @@ -83,7 +96,9 @@ unsafe fn handle_grnd_tech( let can_tech = WorkModule::is_enable_transition_term( module_accessor, *FIGHTER_STATUS_TRANSITION_TERM_ID_PASSIVE, - ) && (second_prev_status != FIGHTER_STATUS_KIND_CATCHED_AIR_FALL_GANON); + ) + && (second_prev_status != FIGHTER_STATUS_KIND_CATCHED_AIR_FALL_GANON) + && CAN_TECH; if !can_tech { return false; @@ -126,7 +141,7 @@ unsafe fn handle_wall_tech( let can_tech = WorkModule::is_enable_transition_term( module_accessor, *FIGHTER_STATUS_TRANSITION_TERM_ID_PASSIVE_WALL, - ); + ) && CAN_TECH; if ![ *FIGHTER_STATUS_KIND_STOP_WALL, @@ -168,7 +183,7 @@ unsafe fn handle_ceil_tech( let can_tech = WorkModule::is_enable_transition_term( module_accessor, *FIGHTER_STATUS_TRANSITION_TERM_ID_PASSIVE_CEIL, - ); + ) && CAN_TECH; if ![ *FIGHTER_STATUS_KIND_STOP_CEIL,