mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-02-01 06:57:25 +00:00
rewrite defensive options
This commit is contained in:
parent
e5185a6c8f
commit
3c174d5097
5 changed files with 89 additions and 47 deletions
|
@ -60,10 +60,11 @@ const char* shield_items[] = { "None", "Infinite", "Hold" };
|
||||||
|
|
||||||
// Defensive States
|
// Defensive States
|
||||||
#define RANDOM_DEFENSIVE 1
|
#define RANDOM_DEFENSIVE 1
|
||||||
#define DEFENSIVE_SHIELD 2
|
#define DEFENSIVE_SPOTDODGE 2
|
||||||
#define DEFENSIVE_SPOTDODGE 3
|
#define DEFENSIVE_ROLL 3
|
||||||
#define DEFENSIVE_JAB 4
|
#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 {
|
struct TrainingModpackMenu {
|
||||||
bool HITBOX_VIS = 1;
|
bool HITBOX_VIS = 1;
|
||||||
|
|
|
@ -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) {
|
if (menu.DEFENSIVE_STATE == RANDOM_DEFENSIVE) {
|
||||||
const int NUM_GROUND_STATUSES = 3;
|
const int NUM_DEFENSIVE_CMDS = 4;
|
||||||
int random_statuses[NUM_GROUND_STATUSES] = {
|
int random_cmds[NUM_DEFENSIVE_CMDS] = {
|
||||||
FIGHTER_STATUS_KIND_ESCAPE,
|
FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE,
|
||||||
FIGHTER_STATUS_KIND_ATTACK,
|
FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_F,
|
||||||
FIGHTER_STATUS_KIND_GUARD_ON
|
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);
|
int random_cmd_index = app::sv_math::rand(hash40("fighter"), NUM_DEFENSIVE_CMDS);
|
||||||
StatusModule::change_status_request_from_script(module_accessor, random_statuses[random_status_index], 1);
|
flag |= random_cmds[random_cmd_index];
|
||||||
} else if (menu.DEFENSIVE_STATE == DEFENSIVE_SHIELD)
|
} else if (menu.DEFENSIVE_STATE == DEFENSIVE_ROLL) {
|
||||||
StatusModule::change_status_request_from_script(module_accessor, FIGHTER_STATUS_KIND_GUARD_ON, 1);
|
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)
|
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)
|
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;
|
||||||
}
|
}
|
|
@ -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) {
|
void defensive_option(u64 module_accessor, int category, int& flag) {
|
||||||
int status = StatusModule::status_kind(module_accessor);
|
int status = StatusModule::status_kind(module_accessor);
|
||||||
int prev_status = StatusModule::prev_status_kind(module_accessor, 0);
|
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;
|
flag |= FIGHTER_PAD_CMD_CAT1_FLAG_AIR_ESCAPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((status == FIGHTER_STATUS_KIND_CLIFF_CLIMB ||
|
if (should_perform_defensive_option(module_accessor, prev_status, status)) {
|
||||||
status == FIGHTER_STATUS_KIND_CLIFF_ATTACK ||
|
perform_defensive_option(module_accessor, flag);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
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)) {
|
if (menu.LEDGE_STATE != NONE && is_training_mode() && is_operation_cpu(module_accessor)) {
|
||||||
force_option(module_accessor);
|
force_option(module_accessor);
|
||||||
|
|
|
@ -28,24 +28,25 @@ void init_settings(u64 module_accessor, int status_kind, bool& replace) {
|
||||||
return;
|
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;
|
replace = false;
|
||||||
return;
|
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) {
|
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)) {
|
if (menu.TECH_STATE != NONE && is_training_mode() && is_operation_cpu(module_accessor)) {
|
||||||
int prev_status = StatusModule::prev_status_kind(module_accessor, 0);
|
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);
|
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);
|
StatusModule::change_status_request_from_script(module_accessor, random_statuses[random_status_index], 1);
|
||||||
}
|
}
|
||||||
else if ((prev_status == FIGHTER_STATUS_KIND_PASSIVE ||
|
else if (should_perform_defensive_option(module_accessor, prev_status, status)) {
|
||||||
prev_status == FIGHTER_STATUS_KIND_PASSIVE_FB ||
|
perform_defensive_option(module_accessor, flag);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
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 (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")) {
|
if (motion_kind == hash40("passive_stand_f") || motion_kind == hash40("passive_stand_b")) {
|
||||||
|
|
|
@ -136,6 +136,10 @@ bool check_button_on_replace(u64 module_accessor, int button) {
|
||||||
if (replace) return ret;
|
if (replace) return ret;
|
||||||
ret = Mash::check_button_on(module_accessor, button, replace);
|
ret = Mash::check_button_on(module_accessor, button, replace);
|
||||||
if (replace) return ret;
|
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);
|
u64 control_module = load_module(module_accessor, 0x48);
|
||||||
bool (*check_button_on)(u64, int) = (bool (*)(u64, int)) load_module_impl(control_module, 0x260);
|
bool (*check_button_on)(u64, int) = (bool (*)(u64, int)) load_module_impl(control_module, 0x260);
|
||||||
|
|
Loading…
Reference in a new issue