1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-30 22:00:16 +00:00

termination (clear_all) implemented ; training mode fix

This commit is contained in:
jugeeya 2019-03-31 11:11:30 -07:00
parent e1313c17b0
commit c2259f858b

View file

@ -32,6 +32,8 @@ void* orig_saved_lr;
// app::sv::animcmd::EFFECT_FOLLOW_COLOR(lua_State* a1)
__int64_t (*app_sv_animcmd_EFFECT_FOLLOW_COLOR)(__int64_t);
void (*AttackModule_clear_all_orig)(__int64_t);
void __libnx_init(void* ctx, Handle main_thread, void* saved_lr)
{
extern char* fake_heap_start;
@ -60,9 +62,20 @@ void __attribute__((weak)) NORETURN __libnx_exit(int rc)
__nx_exit(0, orig_saved_lr);
}
uint64_t is_training_mode() {
u8 *modeByte_71066b5720 = IMPORT(0x71066b5720);
return (*modeByte_71066b5720 == 0xC) || (*modeByte_71066b5720 == 0x20);
#define is_training_mode _ZN3app9smashball16is_training_modeEv
extern uint64_t _ZN3app9smashball16is_training_modeEv(void) LINKABLE;
void AttackModule_clear_all_replace(__int64_t attack_module) {
AttackModule_clear_all_orig(attack_module);
__int64_t battle_module_object_accessor = *(__int64_t*)(attack_module + 0x8);
// Clear graphics every time we clear all hitboxes.
__int64_t effect_module = *(__int64_t *)(battle_module_object_accessor + 0x140);
void (*EffectModule_kill_kind)(__int64_t, __int64_t, __int64_t, __int64_t) = (void (*)(__int64_t, __int64_t, __int64_t, __int64_t))(*(__int64_t*)(*(__int64_t *)(effect_module) + 0xE0LL));
Hash40 shieldEffectHash = {.hash = 0xAFAE75F05LL};
EffectModule_kill_kind(effect_module, shieldEffectHash.hash, 0, 1);
}
void _ZN3app10sv_animcmd6ATTACKEP9lua_State_replace(__int64_t a1) {
@ -76,43 +89,41 @@ void _ZN3app10sv_animcmd6ATTACKEP9lua_State_replace(__int64_t a1) {
L2CAgent l2c_agent;
lib_L2CAgent(&l2c_agent, a1);
// Getting and replacing a value on the stack. Works!
/*
L2CValue damage;
get_lua_stack(&l2c_agent, 4, &damage);
L2CValue inject_dmg = {.raw_float = ((float)(damage.raw_float) + 10.0), .type = L2C_number};
lib_L2CAgent_push_lua_stack(&l2c_agent, &inject_dmg);
lua_replace((lua_State*) l2c_agent.lua_state_agent, 4);
*/
// Get all necessary hitbox params
L2CValue bone;
get_lua_stack(&l2c_agent, 3, &bone);
L2CValue damage;
get_lua_stack(&l2c_agent, 4, &damage);
L2CValue angle;
get_lua_stack(&l2c_agent, 5, &angle);
L2CValue kbg;
get_lua_stack(&l2c_agent, 6, &kbg);
L2CValue wkb;
get_lua_stack(&l2c_agent, 7, &wkb);
L2CValue bkb;
get_lua_stack(&l2c_agent, 8, &bkb);
L2CValue size;
get_lua_stack(&l2c_agent, 9, &size);
L2CValue x;
get_lua_stack(&l2c_agent, 10, &x);
L2CValue y;
get_lua_stack(&l2c_agent, 11, &y);
L2CValue z;
get_lua_stack(&l2c_agent, 12, &z);
L2CValue x2;
get_lua_stack(&l2c_agent, 13, &x2);
L2CValue y2;
get_lua_stack(&l2c_agent, 14, &y2);
L2CValue z2;
get_lua_stack(&l2c_agent, 3, &bone);
get_lua_stack(&l2c_agent, 4, &damage);
get_lua_stack(&l2c_agent, 5, &angle);
get_lua_stack(&l2c_agent, 6, &kbg);
get_lua_stack(&l2c_agent, 7, &wkb);
get_lua_stack(&l2c_agent, 8, &bkb);
get_lua_stack(&l2c_agent, 9, &size);
get_lua_stack(&l2c_agent, 10, &x);
get_lua_stack(&l2c_agent, 11, &y);
get_lua_stack(&l2c_agent, 12, &z);
get_lua_stack(&l2c_agent, 13, &x2);
get_lua_stack(&l2c_agent, 14, &y2);
get_lua_stack(&l2c_agent, 15, &z2);
__int64_t battle_module_object_accessor = *(__int64_t *)(*(__int64_t *)(a1 - 8) + 416LL);
__int64_t attack_module = *(__int64_t *)(battle_module_object_accessor + 0xA0);
if (AttackModule_clear_all_orig == 0) {
AttackModule_clear_all_orig = (void (*)(__int64_t))(*(__int64_t*)(*(__int64_t *)(attack_module) + 0x50LL));
}
*(__int64_t*)(*(__int64_t *)(attack_module) + 0x50LL) = AttackModule_clear_all_replace;
v1 = a1;
void (*sub_71019420D0)(__int64_t, __int64_t) = (void (*)(__int64_t, __int64_t))(IMPORT(0x71019420D0));
sub_71019420D0(*(__int64_t *)(*(__int64_t *)(a1 - 8) + 416LL), a1);
@ -126,12 +137,14 @@ void _ZN3app10sv_animcmd6ATTACKEP9lua_State_replace(__int64_t a1) {
L2CValue xRot = {.raw_float = (float) 0.0, .type = L2C_number};
L2CValue yRot = {.raw_float = (float) 0.0, .type = L2C_number};
L2CValue zRot = {.raw_float = (float) 0.0, .type = L2C_number};
L2CValue unkParam = {.raw = (int) 1, .type = L2C_integer};
L2CValue unkParam0 = {.raw = (int) 0, .type = L2C_integer};
L2CValue unkParam1 = {.raw = (int) 1, .type = L2C_integer};
L2CValue unkParam2 = {.raw = (float) 35.0f, .type = L2C_number};
L2CValue effectSize = {.raw_float = (float) size.raw_float * sizeMult, .type = L2C_number};
L2CValue red = {.raw_float = (float) 255.0, .type = L2C_number};
L2CValue green = {.raw_float = (float) 0.0, .type = L2C_number};
L2CValue blue = {.raw_float = (float) 0.0, .type = L2C_number};
L2CValue red = {.raw_float = 255.0f, .type = L2C_number};
L2CValue green = {.raw_float = 0.0, .type = L2C_number};
L2CValue blue = {.raw_float = 0.0, .type = L2C_number};
int num_effects;
if (x2.type != L2C_void && y2.type != L2C_void && z2.type != L2C_void) {
@ -158,7 +171,7 @@ void _ZN3app10sv_animcmd6ATTACKEP9lua_State_replace(__int64_t a1) {
lib_L2CAgent_push_lua_stack(&l2c_agent, &yRot);
lib_L2CAgent_push_lua_stack(&l2c_agent, &zRot);
lib_L2CAgent_push_lua_stack(&l2c_agent, &effectSize);
lib_L2CAgent_push_lua_stack(&l2c_agent, &unkParam);
lib_L2CAgent_push_lua_stack(&l2c_agent, &unkParam1);
lib_L2CAgent_push_lua_stack(&l2c_agent, &red);
lib_L2CAgent_push_lua_stack(&l2c_agent, &green);
lib_L2CAgent_push_lua_stack(&l2c_agent, &blue);
@ -197,4 +210,3 @@ int main(int argc, char *argv[])
__libnx_exit(0);
}