diff --git a/source/taunt_toggles.h b/source/taunt_toggles.h index fc5eea6..0071f14 100644 --- a/source/taunt_toggles.h +++ b/source/taunt_toggles.h @@ -59,8 +59,9 @@ int MASH_STATE = NONE; // Escape States #define ESCAPE_LEDGE 1 +#define ESCAPE_TECH 2 int ESCAPE_STATE = ESCAPE_LEDGE; -#define NUM_ESCAPE_STATES 2 +#define NUM_ESCAPE_STATES 3 // Shield States #define SHIELD_INFINITE 1 diff --git a/source/training/selection.hpp b/source/training/selection.hpp index 728faf4..4eb0898 100644 --- a/source/training/selection.hpp +++ b/source/training/selection.hpp @@ -54,7 +54,7 @@ void menu_replace() { SaltySDCore_ReplaceImport("vsnprintf", (void*)vsnprintf_intercept); } -void change_motion(u64 module_accessor, u64 motion_kind) { +void clear_command(u64 module_accessor, u64 motion_kind) { if (motion_kind == hash40("appeal_lw_l") || motion_kind == hash40("appeal_lw_r")) { if (is_training_mode()) { if (TOGGLE_STATE == MASH_TOGGLES) { @@ -68,7 +68,7 @@ if (motion_kind == hash40("appeal_lw_l") || motion_kind == hash40("appeal_lw_r") if (TOGGLE_STATE == ESCAPE_TOGGLES) { ESCAPE_STATE = (ESCAPE_STATE + 1) % NUM_ESCAPE_STATES; const char* toggle_strings[NUM_ESCAPE_STATES] = - {"NONE", "LEDGE"}; + {"NONE", "LEDGE", "TECH"}; print_string(module_accessor, toggle_strings[ESCAPE_STATE]); } diff --git a/source/training/tech.h b/source/training/tech.h new file mode 100644 index 0000000..ac0772e --- /dev/null +++ b/source/training/tech.h @@ -0,0 +1,31 @@ +#include "common.hpp" + +namespace Tech { +void init_settings(u64 module_accessor, int status_kind) { + if (ESCAPE_STATE == ESCAPE_TECH && is_training_mode() && is_operation_cpu(module_accessor)) { + if (status_kind == FIGHTER_STATUS_KIND_DOWN) { + const int NUM_TECH_STATUSES = 4; + int random_statuses[NUM_TECH_STATUSES] = { + FIGHTER_STATUS_KIND_DOWN, + FIGHTER_STATUS_KIND_PASSIVE, + FIGHTER_STATUS_KIND_PASSIVE_FB, + FIGHTER_STATUS_KIND_PASSIVE_FB + }; + + int random_status_index = app::sv_math::rand(hash40("fighter"), NUM_TECH_STATUSES); + StatusModule::change_status_request_from_script(module_accessor, random_statuses[random_status_index], 1); + } + + 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); + StatusModule::change_status_request_from_script(module_accessor, random_statuses[random_status_index], 1); + } + } +} +} \ No newline at end of file diff --git a/source/training_mods.hpp b/source/training_mods.hpp index 6ec6db5..4c3a50b 100644 --- a/source/training_mods.hpp +++ b/source/training_mods.hpp @@ -21,6 +21,7 @@ #include "training/mash.hpp" #include "training/selection.hpp" #include "training/shield.hpp" +#include "training/tech.h" #include "training/input_recorder.hpp" using namespace lib; @@ -29,7 +30,6 @@ using namespace app::sv_animcmd; namespace app::lua_bind { namespace WorkModule { -// Force DI float get_float_replace(u64 module_accessor, int var) { bool replace; float ret = DirectionalInfluence::get_float(module_accessor, var, replace); @@ -148,7 +148,7 @@ bool check_button_off_replace(u64 module_accessor, int button) { } void clear_command_replace(u64 module_accessor, bool unk1) { - Selection::change_motion(module_accessor, MotionModule::motion_kind(module_accessor)); + Selection::clear_command(module_accessor, MotionModule::motion_kind(module_accessor)); u64 control_module = load_module(module_accessor, 0x48); void (*clear_command)(u64, bool) = @@ -157,10 +157,20 @@ void clear_command_replace(u64 module_accessor, bool unk1) { clear_command(control_module, unk1); } } // namespace ControlModule + +namespace StatusModule { +void init_settings_replace(u64 module_accessor, int situationKind, int unk1, u64 unk2,int groundCliffCheckKind, bool unk3, int unk4, int unk5, int unk6, int unk7) { + Tech::init_settings(module_accessor, StatusModule::status_kind(module_accessor)); + + u64 status_module = load_module(module_accessor, STATUS_MODULE_OFFSET); + void (*init_settings)(u64,int,int,u64,int,bool,int,int,int,int) = + (void (*)(u64,int,int,u64,int,bool,int,int,int,int)) load_module_impl(status_module, INIT_SETTINGS_OFFSET); + + init_settings(status_module, situationKind, unk1, unk2, groundCliffCheckKind, unk3, unk4, unk5, unk6, unk7); +} +} // namespace StatusModule } // namespace app::lua_bind - - void training_mods_main() { fighter_manager_addr = SaltySDCore_FindSymbol( "_ZN3lib9SingletonIN3app14FighterManagerEE9instance_E"); @@ -203,6 +213,11 @@ void training_mods_main() { "_ZN3app8lua_bind31ControlModule__get_stick_y_implEPNS_26BattleObjectModuleAccessorE", (u64)&ControlModule::get_stick_y_replace); + // Tech options + SaltySD_function_replace_sym( + "_ZN3app8lua_bind32StatusModule__init_settings_implEPNS_26BattleObjectModuleAccessorENS_13SituationKindEijNS_20GroundCliffCheckKindEbiiii", + (u64)&StatusModule::init_settings_replace); + Selection::menu_replace(); }