1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2025-01-20 09:20:13 +00:00

rewrite defensive options

This commit is contained in:
jugeeya 2019-11-27 19:45:05 -08:00
parent e5185a6c8f
commit 3c174d5097
5 changed files with 89 additions and 47 deletions

View file

@ -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;

View file

@ -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;
}

View file

@ -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);

View file

@ -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")) {

View file

@ -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);