1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2025-01-21 01:40:14 +00:00
UltimateTrainingModpack/source/training_mods.hpp

227 lines
8.7 KiB
C++
Raw Normal View History

#ifndef TRAINING_MODS_H
#define TRAINING_MODS_H
2019-06-26 18:27:34 +00:00
#include <stdarg.h>
#include "useful/const_value_table.h"
#include "useful/crc32.h"
#include "useful/useful.h"
2019-07-25 20:00:13 +00:00
#include "useful/raygun_printer.h"
2019-07-25 20:00:13 +00:00
#include "acmd_wrapper.h"
#include "lib/l2c_imports.h"
#include "saltysd/saltysd_dynamic.h"
2019-07-25 20:00:13 +00:00
#include "saltysd/saltysd_helper.h"
2019-05-19 04:16:48 +00:00
#include "taunt_toggles.h"
#include "training/common.hpp"
#include "training/save_states.hpp"
#include "training/directional_influence.hpp"
#include "training/ledge.hpp"
#include "training/mash.hpp"
#include "training/selection.hpp"
#include "training/shield.hpp"
2019-08-01 20:27:29 +00:00
#include "training/tech.h"
2019-07-26 03:42:29 +00:00
#include "training/input_recorder.hpp"
2019-05-19 04:16:48 +00:00
using namespace lib;
using namespace app::lua_bind;
using namespace app::sv_animcmd;
2019-06-04 07:16:52 +00:00
namespace app::lua_bind {
namespace WorkModule {
float get_float_replace(u64 module_accessor, int var) {
bool replace;
float ret = DirectionalInfluence::get_float(module_accessor, var, replace);
if (replace) return ret;
u64 work_module = load_module(module_accessor, 0x50);
2019-07-05 22:24:23 +00:00
float (*get_float)(u64, int) = (float (*)(u64, int)) load_module_impl(work_module, 0x58);
return get_float(work_module, var);
}
float get_param_float_replace(u64 module_accessor, u64 param_type, u64 param_hash) {
bool replace;
float ret = Shield::get_param_float(module_accessor, param_type, param_hash, replace);
if (replace) return ret;
u64 work_module = load_module(module_accessor, 0x50);
2019-07-05 22:24:23 +00:00
float (*get_param_float)(u64, u64, u64) = (float (*)(u64, u64, u64)) load_module_impl(work_module, 0x240);
return get_param_float(work_module, param_type, param_hash);
}
} // namespace WorkModule
namespace ControlModule {
2019-06-21 15:54:43 +00:00
int get_attack_air_kind_replace(u64 module_accessor) {
bool replace;
2019-07-26 22:47:16 +00:00
int kind = InputRecorder::get_attack_air_kind(module_accessor, replace);
if (replace) return kind;
kind = Mash::get_attack_air_kind(module_accessor, replace);
if (replace) return kind;
2019-06-21 15:54:43 +00:00
u64 control_module = load_module(module_accessor, 0x48);
2019-07-05 22:24:23 +00:00
int (*get_attack_air_kind)(u64) = (int (*)(u64)) load_module_impl(control_module, 0x3B0);
return get_attack_air_kind(control_module);
2019-07-05 22:24:23 +00:00
}
int get_command_flag_cat_replace(u64 module_accessor, int category) {
2019-07-05 22:24:23 +00:00
//save_states(module_accessor);
2019-07-05 22:24:23 +00:00
// Pause Effect AnimCMD if hitbox visualization is active
int status_kind = StatusModule::status_kind(module_accessor);
MotionAnimcmdModule::set_sleep_effect(module_accessor,
is_training_mode() &&
HITBOX_VIS &&
!(status_kind >= FIGHTER_STATUS_KIND_CATCH && status_kind <= FIGHTER_STATUS_KIND_TREAD_FALL));
u64 control_module = load_module(module_accessor, 0x48);
int (*get_command_flag_cat)(u64, int) = (int (*)(u64, int)) load_module_impl(control_module, 0x350);
int flag = get_command_flag_cat(control_module, category);
2019-08-01 06:35:18 +00:00
/*bool replace;
2019-07-26 03:42:29 +00:00
int ret = InputRecorder::get_command_flag_cat(module_accessor, category, flag, replace);
2019-08-01 06:35:18 +00:00
if (replace) return ret;*/
2019-07-26 03:42:29 +00:00
Mash::get_command_flag_cat(module_accessor, category, flag);
Ledge::get_command_flag_cat(module_accessor, category, flag);
return flag;
}
int get_pad_flag(u64 module_accessor) {
u64 control_module = load_module(module_accessor, 0x48);
2019-08-01 06:35:18 +00:00
int (*get_pad_flag)(u64) = (int (*)(u64)) load_module_impl(control_module, 0x348);
int pad_flag = get_pad_flag(control_module);
bool replace;
int ret = InputRecorder::get_pad_flag(module_accessor, replace);
if (replace) return ret;
return pad_flag;
}
float get_stick_x_replace(u64 module_accessor) {
u64 control_module = load_module(module_accessor, 0x48);
2019-08-01 06:35:18 +00:00
float (*get_stick_x)(u64) = (float (*)(u64)) load_module_impl(control_module, 0x178);
float stick_x = get_stick_x(control_module);
bool replace;
float ret = InputRecorder::get_stick_x(module_accessor, replace);
if (replace) return ret;
return stick_x;
}
float get_stick_y_replace(u64 module_accessor) {
u64 control_module = load_module(module_accessor, 0x48);
2019-08-01 06:35:18 +00:00
float (*get_stick_y)(u64) = (float (*)(u64)) load_module_impl(control_module, 0x188);
float stick_y = get_stick_y(control_module);
bool replace;
float ret = InputRecorder::get_stick_y(module_accessor, replace);
if (replace) return ret;
return stick_y;
}
bool check_button_on_replace(u64 module_accessor, int button) {
bool replace;
bool ret = Shield::check_button_on(module_accessor, button, replace);
if (replace) return ret;
ret = Mash::check_button_on(module_accessor, button, replace);
if (replace) return ret;
u64 control_module = load_module(module_accessor, 0x48);
2019-07-05 22:24:23 +00:00
bool (*check_button_on)(u64, int) = (bool (*)(u64, int)) load_module_impl(control_module, 0x260);
return check_button_on(control_module, button);
}
bool check_button_off_replace(u64 module_accessor, int button) {
bool replace;
bool ret = Shield::check_button_off(module_accessor, button, replace);
if (replace) return ret;
u64 control_module = load_module(module_accessor, 0x48);
2019-07-05 22:24:23 +00:00
bool (*check_button_off)(u64, int) = (bool (*)(u64, int)) load_module_impl(control_module, 0x268);
return check_button_off(control_module, button);
}
2019-05-22 00:47:24 +00:00
2019-08-01 06:35:18 +00:00
void clear_command_replace(u64 module_accessor, bool unk1) {
2019-08-01 20:27:29 +00:00
Selection::clear_command(module_accessor, MotionModule::motion_kind(module_accessor));
2019-08-01 06:35:18 +00:00
u64 control_module = load_module(module_accessor, 0x48);
void (*clear_command)(u64, bool) =
(void (*)(u64, bool)) load_module_impl(control_module, 0x358);
2019-08-01 06:35:18 +00:00
clear_command(control_module, unk1);
}
2019-08-01 06:35:18 +00:00
} // namespace ControlModule
2019-08-01 20:27:29 +00:00
namespace StatusModule {
2019-08-02 01:57:30 +00:00
void init_settings_replace(u64 module_accessor, int situationKind, int unk1, uint unk2, int groundCliffCheckKind, bool unk3, int unk4, int unk5, int unk6, int unk7) {
bool replace;
Tech::init_settings(module_accessor, StatusModule::status_kind(module_accessor), replace);
if (replace) return;
2019-08-01 20:27:29 +00:00
2019-08-02 01:57:30 +00:00
u64 status_module = load_module(module_accessor, 0x40);
void (*init_settings)(u64,int,int,uint,int,bool,int,int,int,int) =
(void (*)(u64,int,int,uint,int,bool,int,int,int,int)) load_module_impl(status_module, 0x1C8);
2019-08-01 06:35:18 +00:00
2019-08-01 20:27:29 +00:00
init_settings(status_module, situationKind, unk1, unk2, groundCliffCheckKind, unk3, unk4, unk5, unk6, unk7);
}
2019-08-02 01:57:30 +00:00
} // namespace StatusModule
2019-08-01 20:27:29 +00:00
} // namespace app::lua_bind
void training_mods_main() {
fighter_manager_addr = SaltySDCore_FindSymbol(
"_ZN3lib9SingletonIN3app14FighterManagerEE9instance_E");
2019-08-01 06:35:18 +00:00
// Taunt toggles
SaltySD_function_replace_sym(
"_ZN3app8lua_bind33ControlModule__clear_command_implEPNS_26BattleObjectModuleAccessorEb",
(u64)&ControlModule::clear_command_replace);
// Mash airdodge/jump
SaltySD_function_replace_sym(
2019-06-21 15:54:43 +00:00
"_ZN3app8lua_bind40ControlModule__get_command_flag_cat_implEPNS_26BattleObjectModuleAccessorEi",
(u64)&ControlModule::get_command_flag_cat_replace);
// Set DI
SaltySD_function_replace_sym(
2019-06-21 15:54:43 +00:00
"_ZN3app8lua_bind26WorkModule__get_float_implEPNS_26BattleObjectModuleAccessorEi",
(u64)&WorkModule::get_float_replace);
// Hold/Infinite shield
SaltySD_function_replace_sym(
2019-06-21 15:54:43 +00:00
"_ZN3app8lua_bind35ControlModule__check_button_on_implEPNS_26BattleObjectModuleAccessorEi",
(u64)&ControlModule::check_button_on_replace);
SaltySD_function_replace_sym(
2019-06-21 15:54:43 +00:00
"_ZN3app8lua_bind36ControlModule__check_button_off_implEPNS_26BattleObjectModuleAccessorEi",
(u64)&ControlModule::check_button_off_replace);
SaltySD_function_replace_sym(
2019-06-21 15:54:43 +00:00
"_ZN3app8lua_bind32WorkModule__get_param_float_implEPNS_26BattleObjectModuleAccessorEmm",
(u64)&WorkModule::get_param_float_replace);
2019-06-27 00:31:55 +00:00
// Mash attack
SaltySD_function_replace_sym(
2019-06-21 15:54:43 +00:00
"_ZN3app8lua_bind39ControlModule__get_attack_air_kind_implEPNS_26BattleObjectModuleAccessorE",
(u64)&ControlModule::get_attack_air_kind_replace);
// Input recorder
SaltySD_function_replace_sym(
"_ZN3app8lua_bind31ControlModule__get_stick_x_implEPNS_26BattleObjectModuleAccessorE",
(u64)&ControlModule::get_stick_x_replace);
SaltySD_function_replace_sym(
"_ZN3app8lua_bind31ControlModule__get_stick_y_implEPNS_26BattleObjectModuleAccessorE",
(u64)&ControlModule::get_stick_y_replace);
2019-08-01 20:27:29 +00:00
// Tech options
2019-08-09 05:57:39 +00:00
// SaltySD_function_replace_sym(
// "_ZN3app8lua_bind32StatusModule__init_settings_implEPNS_26BattleObjectModuleAccessorENS_13SituationKindEijNS_20GroundCliffCheckKindEbiiii",
// (u64)&StatusModule::init_settings_replace);
2019-08-01 20:27:29 +00:00
Selection::menu_replace();
}
#endif // TRAINING_MODS_H