diff --git a/source/taunt_toggles.h b/source/taunt_toggles.h index 666443f..44c2894 100644 --- a/source/taunt_toggles.h +++ b/source/taunt_toggles.h @@ -60,10 +60,11 @@ const char* shield_items[] = { "None", "Infinite", "Hold" }; // Defensive States #define RANDOM_DEFENSIVE 1 -#define DEFENSIVE_SHIELD 2 -#define DEFENSIVE_SPOTDODGE 3 +#define DEFENSIVE_SPOTDODGE 2 +#define DEFENSIVE_ROLL 3 #define DEFENSIVE_JAB 4 -const char* defensive_items[] = { "None", "Random", "Flash Shield", "Spotdodge", "Jab" }; +#define DEFENSIVE_SHIELD 5 +const char* defensive_items[] = { "None", "Random", "Spotdodge", "Roll", "Jab", "Flash Shield" }; struct TrainingModpackMenu { bool HITBOX_VIS = 1; diff --git a/source/training/common.h b/source/training/common.h index cc51222..29f8f7a 100644 --- a/source/training/common.h +++ b/source/training/common.h @@ -50,21 +50,26 @@ bool is_in_landing(u64 module_accessor) { } -void perform_defensive_option(u64 module_accessor) { +void perform_defensive_option(u64 module_accessor, int& flag) { if (menu.DEFENSIVE_STATE == RANDOM_DEFENSIVE) { - const int NUM_GROUND_STATUSES = 3; - int random_statuses[NUM_GROUND_STATUSES] = { - FIGHTER_STATUS_KIND_ESCAPE, - FIGHTER_STATUS_KIND_ATTACK, - FIGHTER_STATUS_KIND_GUARD_ON + const int NUM_DEFENSIVE_CMDS = 4; + int random_cmds[NUM_DEFENSIVE_CMDS] = { + FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE, + FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_F, + FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_B, + FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_N }; - int random_status_index = app::sv_math::rand(hash40("fighter"), NUM_GROUND_STATUSES); - StatusModule::change_status_request_from_script(module_accessor, random_statuses[random_status_index], 1); - } else if (menu.DEFENSIVE_STATE == DEFENSIVE_SHIELD) - StatusModule::change_status_request_from_script(module_accessor, FIGHTER_STATUS_KIND_GUARD_ON, 1); + int random_cmd_index = app::sv_math::rand(hash40("fighter"), NUM_DEFENSIVE_CMDS); + flag |= random_cmds[random_cmd_index]; + } else if (menu.DEFENSIVE_STATE == DEFENSIVE_ROLL) { + if (app::sv_math::rand(hash40("fighter"), 2)) + flag |= FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_F; + else + flag |= FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_B; + } else if (menu.DEFENSIVE_STATE == DEFENSIVE_SPOTDODGE) - StatusModule::change_status_request_from_script(module_accessor, FIGHTER_STATUS_KIND_ESCAPE, 1); + flag |= FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE; else if (menu.DEFENSIVE_STATE == DEFENSIVE_JAB) - StatusModule::change_status_request_from_script(module_accessor, FIGHTER_STATUS_KIND_ATTACK, 1); + flag |= FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_N; } \ No newline at end of file diff --git a/source/training/ledge.h b/source/training/ledge.h index da1efa9..550df73 100644 --- a/source/training/ledge.h +++ b/source/training/ledge.h @@ -35,6 +35,17 @@ void force_option(u64 module_accessor) { } } +bool should_perform_defensive_option(u64 module_accessor, int prev_status, int status) { + return (status == FIGHTER_STATUS_KIND_CLIFF_CLIMB || + status == FIGHTER_STATUS_KIND_CLIFF_ATTACK || + status == FIGHTER_STATUS_KIND_CLIFF_ESCAPE || + prev_status == FIGHTER_STATUS_KIND_CLIFF_CLIMB || + prev_status == FIGHTER_STATUS_KIND_CLIFF_ATTACK || + prev_status == FIGHTER_STATUS_KIND_CLIFF_ESCAPE) && + (WorkModule::is_enable_transition_term(module_accessor, FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE) || + CancelModule::is_enable_cancel(module_accessor)); +} + void defensive_option(u64 module_accessor, int category, int& flag) { int status = StatusModule::status_kind(module_accessor); int prev_status = StatusModule::prev_status_kind(module_accessor, 0); @@ -44,18 +55,29 @@ void defensive_option(u64 module_accessor, int category, int& flag) { flag |= FIGHTER_PAD_CMD_CAT1_FLAG_AIR_ESCAPE; } - if ((status == FIGHTER_STATUS_KIND_CLIFF_CLIMB || - status == FIGHTER_STATUS_KIND_CLIFF_ATTACK || - status == FIGHTER_STATUS_KIND_CLIFF_ESCAPE || - prev_status == FIGHTER_STATUS_KIND_CLIFF_CLIMB || - prev_status == FIGHTER_STATUS_KIND_CLIFF_ATTACK || - prev_status == FIGHTER_STATUS_KIND_CLIFF_ESCAPE) && - (WorkModule::is_enable_transition_term(module_accessor, FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE) || - CancelModule::is_enable_cancel(module_accessor))) { - perform_defensive_option(module_accessor); + if (should_perform_defensive_option(module_accessor, prev_status, status)) { + perform_defensive_option(module_accessor, flag); } } +bool check_button_on(u64 module_accessor, int button, bool& replace) { + if (button == CONTROL_PAD_BUTTON_GUARD_HOLD || button == CONTROL_PAD_BUTTON_GUARD) { + if (is_training_mode() && is_operation_cpu(module_accessor)) { + if (menu.DEFENSIVE_STATE == DEFENSIVE_SHIELD && + should_perform_defensive_option( + module_accessor, + StatusModule::prev_status_kind(module_accessor, 0), + StatusModule::status_kind(module_accessor))) { + replace = true; + return true; + } + } + } + + replace = false; + return false; +} + void get_command_flag_cat(u64 module_accessor, int category, int& flag) { if (menu.LEDGE_STATE != NONE && is_training_mode() && is_operation_cpu(module_accessor)) { force_option(module_accessor); diff --git a/source/training/tech.h b/source/training/tech.h index 8c42c26..80ac98e 100644 --- a/source/training/tech.h +++ b/source/training/tech.h @@ -28,24 +28,25 @@ void init_settings(u64 module_accessor, int status_kind, bool& replace) { return; } } - - // else if (status_kind == FIGHTER_STATUS_KIND_PASSIVE) { - // const int NUM_TECH_STATUSES = 2; - // int random_statuses[NUM_TECH_STATUSES] = { - // FIGHTER_STATUS_KIND_PASSIVE, - // FIGHTER_STATUS_KIND_PASSIVE_FB - // }; - - // int random_status_index = app::sv_math::rand(hash40("fighter"), NUM_TECH_STATUSES); - // if (random_statuses[random_status_index] != FIGHTER_STATUS_KIND_PASSIVE) - // StatusModule::change_status_request_from_script(module_accessor, random_statuses[random_status_index], 1); - // } } replace = false; return; } +bool should_perform_defensive_option(u64 module_accessor, int prev_status, int status) { + return (prev_status == FIGHTER_STATUS_KIND_PASSIVE || + prev_status == FIGHTER_STATUS_KIND_PASSIVE_FB || + prev_status == FIGHTER_STATUS_KIND_DOWN_STAND || + prev_status == FIGHTER_STATUS_KIND_DOWN_STAND_FB || + prev_status == FIGHTER_STATUS_KIND_DOWN_STAND_ATTACK || + status == FIGHTER_STATUS_KIND_DOWN_STAND || + status == FIGHTER_STATUS_KIND_DOWN_STAND_FB || + status == FIGHTER_STATUS_KIND_DOWN_STAND_ATTACK) && + (WorkModule::is_enable_transition_term(module_accessor, FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_GUARD_ON) || + CancelModule::is_enable_cancel(module_accessor)); +} + void get_command_flag_cat(u64 module_accessor, int category, int& flag) { if (menu.TECH_STATE != NONE && is_training_mode() && is_operation_cpu(module_accessor)) { int prev_status = StatusModule::prev_status_kind(module_accessor, 0); @@ -61,21 +62,30 @@ void get_command_flag_cat(u64 module_accessor, int category, int& flag) { int random_status_index = app::sv_math::rand(hash40("fighter"), NUM_GETUP_STATUSES); StatusModule::change_status_request_from_script(module_accessor, random_statuses[random_status_index], 1); } - else if ((prev_status == FIGHTER_STATUS_KIND_PASSIVE || - prev_status == FIGHTER_STATUS_KIND_PASSIVE_FB || - prev_status == FIGHTER_STATUS_KIND_DOWN_STAND || - prev_status == FIGHTER_STATUS_KIND_DOWN_STAND_FB || - prev_status == FIGHTER_STATUS_KIND_DOWN_STAND_ATTACK || - status == FIGHTER_STATUS_KIND_DOWN_STAND || - status == FIGHTER_STATUS_KIND_DOWN_STAND_FB || - status == FIGHTER_STATUS_KIND_DOWN_STAND_ATTACK) && - (WorkModule::is_enable_transition_term(module_accessor, FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_GUARD_ON) || - CancelModule::is_enable_cancel(module_accessor))) { - perform_defensive_option(module_accessor); + else if (should_perform_defensive_option(module_accessor, prev_status, status)) { + perform_defensive_option(module_accessor, flag); } } } +bool check_button_on(u64 module_accessor, int button, bool& replace) { + if (button == CONTROL_PAD_BUTTON_GUARD_HOLD || button == CONTROL_PAD_BUTTON_GUARD) { + if (is_training_mode() && is_operation_cpu(module_accessor)) { + if (menu.DEFENSIVE_STATE == DEFENSIVE_SHIELD && + should_perform_defensive_option( + module_accessor, + StatusModule::prev_status_kind(module_accessor, 0), + StatusModule::status_kind(module_accessor))) { + replace = true; + return true; + } + } + } + + replace = false; + return false; +} + u64 change_motion(u64 module_accessor, u64 motion_kind, bool& replace) { if (menu.TECH_STATE != NONE && is_training_mode() && is_operation_cpu(module_accessor)) { if (motion_kind == hash40("passive_stand_f") || motion_kind == hash40("passive_stand_b")) { diff --git a/source/training_mods.h b/source/training_mods.h index 52457f2..d74eb72 100644 --- a/source/training_mods.h +++ b/source/training_mods.h @@ -136,6 +136,10 @@ bool check_button_on_replace(u64 module_accessor, int button) { if (replace) return ret; ret = Mash::check_button_on(module_accessor, button, replace); if (replace) return ret; + ret = Tech::check_button_on(module_accessor, button, replace); + if (replace) return ret; + ret = Ledge::check_button_on(module_accessor, button, replace); + if (replace) return ret; u64 control_module = load_module(module_accessor, 0x48); bool (*check_button_on)(u64, int) = (bool (*)(u64, int)) load_module_impl(control_module, 0x260);