1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-20 00:46:34 +00:00

training-mode-only for termination

This commit is contained in:
jugeeya 2019-03-31 18:05:52 -07:00
parent c2259f858b
commit 22d3346d98

View file

@ -67,19 +67,20 @@ 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);
__int64_t battle_object_module_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);
__int64_t effect_module = *(__int64_t *)(battle_object_module_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) {
// Stretched bones fix: Scale down by ModelModule::scale() with lua_State arg of bone?
SaltySD_printf("In attack code with lua_state ptr: %llx\n", a1);
__int64_t v1; // x19
uint64_t v2; // x9
@ -90,19 +91,7 @@ void _ZN3app10sv_animcmd6ATTACKEP9lua_State_replace(__int64_t a1) {
lib_L2CAgent(&l2c_agent, a1);
// Get all necessary hitbox params
L2CValue bone;
L2CValue damage;
L2CValue angle;
L2CValue kbg;
L2CValue wkb;
L2CValue bkb;
L2CValue size;
L2CValue x;
L2CValue y;
L2CValue z;
L2CValue x2;
L2CValue y2;
L2CValue z2;
L2CValue bone, damage, angle, kbg, wkb, bkb, size, x, y, z, x2, y2, z2;
get_lua_stack(&l2c_agent, 3, &bone);
get_lua_stack(&l2c_agent, 4, &damage);
get_lua_stack(&l2c_agent, 5, &angle);
@ -116,20 +105,24 @@ void _ZN3app10sv_animcmd6ATTACKEP9lua_State_replace(__int64_t a1) {
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;
// original code: parse lua stack and call AttackModule::set_attack()
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);
// EFFECT_FOLLOW_COLOR(Graphic, Bone, Z, Y, X, ZRot, YRot, XRot, Size, unknown=0x1, Red, Green, Blue)
if (is_training_mode()){
if (is_training_mode()){
// Replace AttackModule::clear_all()
__int64_t battle_object_module_accessor = *(__int64_t *)(*(__int64_t *)(a1 - 8) + 416LL);
__int64_t attack_module = *(__int64_t *)(battle_object_module_accessor + 0xA0);
__int64_t attack_module_clear_all = *(__int64_t *)(attack_module) + 0x50LL;
if (AttackModule_clear_all_orig == 0) {
AttackModule_clear_all_orig = (void (*)(__int64_t))(*(__int64_t*)(attack_module_clear_all));
}
*(__int64_t*)(attack_module_clear_all) = AttackModule_clear_all_replace;
// Generate hitbox effect
// EFFECT_FOLLOW_COLOR(Graphic, Bone, Z, Y, X, ZRot, YRot, XRot, Size, unknown=0x1, Red, Green, Blue)
float sizeMult = 19.0 / 200.0;
Hash40 shieldEffectHash = {.hash = 0xAFAE75F05LL};
@ -137,15 +130,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 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 terminate = {.raw = (int) 1, .type = L2C_integer};
L2CValue unkParam = {.raw = (bool) 1, .type = L2C_bool};
L2CValue effectSize = {.raw_float = (float) size.raw_float * sizeMult, .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};
// Extended Hitboxes if x2, y2, z2 are not L2CValue::nil
int num_effects;
if (x2.type != L2C_void && y2.type != L2C_void && z2.type != L2C_void) {
num_effects = 4;
@ -171,7 +163,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, &unkParam1);
lib_L2CAgent_push_lua_stack(&l2c_agent, &terminate);
lib_L2CAgent_push_lua_stack(&l2c_agent, &red);
lib_L2CAgent_push_lua_stack(&l2c_agent, &green);
lib_L2CAgent_push_lua_stack(&l2c_agent, &blue);
@ -179,7 +171,7 @@ void _ZN3app10sv_animcmd6ATTACKEP9lua_State_replace(__int64_t a1) {
}
}
// clear_lua_stack section
// original code: clear_lua_stack section
v2 = *(__int64_t *)(v1 + 16);
for ( i = **(__int64_t **)(v1 + 32) + 16LL; v2 < i; v2 = *(__int64_t *)(v1 + 16) )
{
@ -202,7 +194,7 @@ int main(int argc, char *argv[])
char* ver = "Ver. %d.%d.%d";
u64 dst_3 = SaltySDCore_findCode(ver, strlen(ver));
if (dst_3) {
SaltySD_Memcpy(dst_3, "noice v%d%d%d", 13);
SaltySD_Memcpy(dst_3, "Noice v%d%d%d", 13);
}
// Install animCMD function replacement