diff --git a/source/training_mods.hpp b/source/training_mods.hpp index e4526fd..001ab2c 100644 --- a/source/training_mods.hpp +++ b/source/training_mods.hpp @@ -133,6 +133,37 @@ u64 enable_transition_term_replace(u64 module_accessor, int transition_id) { } // namespace WorkModule namespace ControlModule { +int get_attack_air_kind_replace(u64 module_accessor) { + // call original + u64 control_module = load_module(module_accessor, 0x48); + int (*get_attack_air_kind)(u64) = + (int (*)(u64))load_module_impl(control_module, 0x3B0); + int kind = get_attack_air_kind(control_module); + + if (is_training_mode() && is_operation_cpu(module_accessor)) { + if (TOGGLE_STATE == MASH_ATTACK) { + switch (ATTACK_STATE) { + case MASH_NAIR: + kind = FIGHTER_COMMAND_ATTACK_AIR_KIND_N; break; + case MASH_FAIR: + kind = FIGHTER_COMMAND_ATTACK_AIR_KIND_F; break; + case MASH_BAIR: + kind = FIGHTER_COMMAND_ATTACK_AIR_KIND_B; break; + case MASH_UPAIR: + kind = FIGHTER_COMMAND_ATTACK_AIR_KIND_HI; break; + case MASH_DAIR: + kind = FIGHTER_COMMAND_ATTACK_AIR_KIND_LW; break; + } + } + + if (TOGGLE_STATE == MASH_RANDOM) { + kind = app::sv_math::rand(hash40("fighter"), 5) + 1; + } + } + + return kind; +} + int get_command_flag_cat_replace(u64 module_accessor, int category) { // call original u64 control_module = load_module(module_accessor, 0x48); @@ -154,15 +185,11 @@ int get_command_flag_cat_replace(u64 module_accessor, int category) { if (category == FIGHTER_PAD_COMMAND_CATEGORY1) { switch (ATTACK_STATE) { case MASH_NAIR: - flag |= lua_const("FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_AIR_N"); break; - case MASH_FAIR: - flag |= lua_const("FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_AIR_F"); break; - case MASH_BAIR: - flag |= lua_const("FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_AIR_B"); break; - case MASH_UPAIR: - flag |= lua_const("FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_AIR_HI"); break; - case MASH_DAIR: - flag |= lua_const("FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_AIR_LW"); break; + case MASH_FAIR: + case MASH_BAIR: + case MASH_UPAIR: + case MASH_DAIR: + flag |= FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_N; break; case MASH_NEUTRAL_B: flag |= FIGHTER_PAD_CMD_CAT1_FLAG_SPECIAL_N; break; case MASH_SIDE_B: @@ -179,11 +206,12 @@ int get_command_flag_cat_replace(u64 module_accessor, int category) { int random_commands[] = { FIGHTER_PAD_CMD_CAT1_FLAG_AIR_ESCAPE, FIGHTER_PAD_CMD_CAT1_FLAG_JUMP_BUTTON, - lua_const("FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_AIR_N"), - lua_const("FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_AIR_F"), - lua_const("FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_AIR_B"), - lua_const("FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_AIR_HI"), - lua_const("FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_AIR_LW"), + // one for each aerial + FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_N, + FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_N, + FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_N, + FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_N, + FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_N, FIGHTER_PAD_CMD_CAT1_FLAG_SPECIAL_N, FIGHTER_PAD_CMD_CAT1_FLAG_SPECIAL_S, FIGHTER_PAD_CMD_CAT1_FLAG_SPECIAL_HI, @@ -368,36 +396,35 @@ void training_mods_main() { "_ZN3lib9SingletonIN3app14FighterManagerEE9instance_E"); // Mash airdodge/jump SaltySD_function_replace_sym( - "_ZN3app8lua_bind40ControlModule__get_command_flag_cat_implEPNS_" - "26BattleObjectModuleAccessorEi", + "_ZN3app8lua_bind40ControlModule__get_command_flag_cat_implEPNS_26BattleObjectModuleAccessorEi", (u64)&ControlModule::get_command_flag_cat_replace); // Set DI SaltySD_function_replace_sym( - "_ZN3app8lua_bind26WorkModule__get_float_implEPNS_" - "26BattleObjectModuleAccessorEi", + "_ZN3app8lua_bind26WorkModule__get_float_implEPNS_26BattleObjectModuleAccessorEi", (u64)&WorkModule::get_float_replace); // Hold/Infinite shield SaltySD_function_replace_sym( - "_ZN3app8lua_bind35ControlModule__check_button_on_implEPNS_" - "26BattleObjectModuleAccessorEi", + "_ZN3app8lua_bind35ControlModule__check_button_on_implEPNS_26BattleObjectModuleAccessorEi", (u64)&ControlModule::check_button_on_replace); SaltySD_function_replace_sym( - "_ZN3app8lua_bind36ControlModule__check_button_off_implEPNS_" - "26BattleObjectModuleAccessorEi", + "_ZN3app8lua_bind36ControlModule__check_button_off_implEPNS_26BattleObjectModuleAccessorEi", (u64)&ControlModule::check_button_off_replace); SaltySD_function_replace_sym( - "_ZN3app8lua_bind32WorkModule__get_param_float_implEPNS_" - "26BattleObjectModuleAccessorEmm", + "_ZN3app8lua_bind32WorkModule__get_param_float_implEPNS_26BattleObjectModuleAccessorEmm", (u64)&WorkModule::get_param_float_replace); // Ledge options SaltySD_function_replace_sym( - "_ZN3app8lua_bind39WorkModule__enable_transition_term_implEPNS_" - "26BattleObjectModuleAccessorEi", + "_ZN3app8lua_bind39WorkModule__enable_transition_term_implEPNS_26BattleObjectModuleAccessorEi", (u64)&WorkModule::enable_transition_term_replace); + // Mash attack + SaltySD_function_replace_sym( + "_ZN3app8lua_bind39ControlModule__get_attack_air_kind_implEPNS_26BattleObjectModuleAccessorE", + (u64)&ControlModule::get_attack_air_kind_replace); + // Save states: in beta /*SaltySD_function_replace_sym( "_ZN3app8lua_bind32ControlModule__get_pad_flag_implEPNS_26BattleObjectModuleAccessorE",