mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2024-11-27 20:34:03 +00:00
mash airdodge, DI right; taunt toggles implemented
This commit is contained in:
parent
dd12397967
commit
11af0e0bee
7 changed files with 352 additions and 74 deletions
|
@ -48,4 +48,14 @@ extern uint64_t _ZN3app10sv_animcmd23LAST_EFFECT_SET_SCALE_WEP9lua_State(__int64
|
|||
|
||||
// app::sv_animcmd::LAST_EFFECT_SET_RATE(lua_State * a1)
|
||||
#define app_sv_animcmd_LAST_EFFECT_SET_RATE _ZN3app10sv_animcmd20LAST_EFFECT_SET_RATEEP9lua_State
|
||||
extern uint64_t _ZN3app10sv_animcmd20LAST_EFFECT_SET_RATEEP9lua_State(__int64_t) LINKABLE;
|
||||
extern uint64_t _ZN3app10sv_animcmd20LAST_EFFECT_SET_RATEEP9lua_State(__int64_t) LINKABLE;
|
||||
|
||||
// app::sv_animcmd::LAST_EFFECT_SET_ALPHA(lua_State * a1)
|
||||
#define app_sv_animcmd_LAST_EFFECT_SET_ALPHA _ZN3app10sv_animcmd21LAST_EFFECT_SET_ALPHAEP9lua_State
|
||||
extern uint64_t _ZN3app10sv_animcmd21LAST_EFFECT_SET_ALPHAEP9lua_State(__int64_t) LINKABLE;
|
||||
|
||||
#define app_sv_animcmd_frame _ZN3app10sv_animcmd5frameEP9lua_Statef
|
||||
extern uint64_t _ZN3app10sv_animcmd5frameEP9lua_Statef(__int64_t, float) LINKABLE;
|
||||
|
||||
#define app_sv_animcmd_is_excute _ZN3app10sv_animcmd9is_excuteEP9lua_State
|
||||
extern uint64_t _ZN3app10sv_animcmd9is_excuteEP9lua_State(__int64_t) LINKABLE;
|
82
source/crc32.h
Normal file
82
source/crc32.h
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*-
|
||||
* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or
|
||||
* code or tables extracted from it, as desired without restriction.
|
||||
*/
|
||||
|
||||
#ifndef CRC32_H
|
||||
#define CRC32_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
const uint32_t crc32_tab[] = {
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
|
||||
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
||||
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
|
||||
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
||||
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
|
||||
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
|
||||
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
|
||||
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
||||
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
|
||||
0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
||||
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
|
||||
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
||||
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
|
||||
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
|
||||
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
||||
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
||||
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
|
||||
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
|
||||
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
|
||||
0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
||||
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
|
||||
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
|
||||
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
|
||||
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
||||
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
|
||||
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
|
||||
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
|
||||
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
||||
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
|
||||
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
||||
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
|
||||
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
||||
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
|
||||
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
|
||||
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
||||
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
||||
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
|
||||
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
|
||||
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
|
||||
0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
||||
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
|
||||
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
||||
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
||||
};
|
||||
|
||||
uint32_t crc32_part(const void *buf, size_t size, uint32_t crc)
|
||||
{
|
||||
const uint8_t* p = (const uint8_t*)buf;
|
||||
crc = crc ^ ~0U;
|
||||
while (size--)
|
||||
crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8);
|
||||
return crc ^ ~0U;
|
||||
}
|
||||
|
||||
uint32_t crc32(const void *buf, size_t size)
|
||||
{
|
||||
const uint8_t* p = (const uint8_t*)buf;
|
||||
uint32_t crc;
|
||||
crc = ~0U;
|
||||
while (size--)
|
||||
crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8);
|
||||
return crc ^ ~0U;
|
||||
}
|
||||
|
||||
uint64_t hash40(const void* data, size_t len)
|
||||
{
|
||||
return crc32(data, len) | (len & 0xFF) << 32;
|
||||
}
|
||||
|
||||
#endif // CRC32_H
|
|
@ -79,8 +79,8 @@ typedef struct L2CAgent
|
|||
uint64_t unk20;
|
||||
uint64_t unk28;
|
||||
uint64_t unk30;
|
||||
uint64_t unk38;
|
||||
uint64_t lua_state_agentbase;
|
||||
uint64_t battle_object;
|
||||
uint64_t battle_module_object_accessor;
|
||||
} L2CAgent;
|
||||
|
||||
typedef struct lua_State_smash
|
||||
|
|
|
@ -29,3 +29,12 @@ extern uint64_t _ZN3lib8L2CAgent13pop_lua_stackEi(__int64_t unk1, int unk2) LINK
|
|||
// __int64_t (*lib_L2CAgent_clear_lua_stack)(__int64_t);
|
||||
#define lib_L2CAgent_clear_lua_stack _ZN3lib8L2CAgent15clear_lua_stackEv
|
||||
extern uint64_t _ZN3lib8L2CAgent15clear_lua_stackEv(__int64_t unk1) LINKABLE;
|
||||
|
||||
#define lib_utility_Variadic_get_format _ZN3lib7utility8VariadicC1Ev
|
||||
extern uint64_t _ZN3lib7utility8VariadicC1Ev(__int64_t unk1) LINKABLE;
|
||||
|
||||
#define lib_L2CValue_push_variadic _ZN3lib8L2CValue13push_variadicEmPKcRNS_7utility8VariadicE
|
||||
extern uint64_t _ZN3lib8L2CValue13push_variadicEmPKcRNS_7utility8VariadicE(__int64_t unk1, __int64_t unk2, __int64_t unk3, __int64_t unk4) LINKABLE;
|
||||
|
||||
#define lib_L2CValue_del_L2CValue _ZN3lib8L2CValueD1Ev
|
||||
extern uint64_t _ZN3lib8L2CValueD1Ev(__int64_t unk1) LINKABLE;
|
||||
|
|
19
source/lua_bind.h
Normal file
19
source/lua_bind.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include <switch.h>
|
||||
|
||||
#define StatusModule__change_status_request_from_script _ZN3app8lua_bind52StatusModule__change_status_request_from_script_implEPNS_26BattleObjectModuleAccessorEib
|
||||
extern uint64_t _ZN3app8lua_bind52StatusModule__change_status_request_from_script_implEPNS_26BattleObjectModuleAccessorEib(__int64_t, int, bool) LINKABLE;
|
||||
|
||||
#define StatusModule_status_kind _ZN3app8lua_bind30StatusModule__status_kind_implEPNS_26BattleObjectModuleAccessorE
|
||||
extern int _ZN3app8lua_bind30StatusModule__status_kind_implEPNS_26BattleObjectModuleAccessorE(__int64_t) LINKABLE;
|
||||
|
||||
#define FighterInformation_is_operation_cpu _ZN3app8lua_bind41FighterInformation__is_operation_cpu_implEPNS_18FighterInformationE
|
||||
extern bool _ZN3app8lua_bind41FighterInformation__is_operation_cpu_implEPNS_18FighterInformationE(__int64_t) LINKABLE;
|
||||
|
||||
#define WorkModule_get_int _ZN3app8lua_bind24WorkModule__get_int_implEPNS_26BattleObjectModuleAccessorEi
|
||||
extern int _ZN3app8lua_bind24WorkModule__get_int_implEPNS_26BattleObjectModuleAccessorEi(__int64_t, int) LINKABLE;
|
||||
|
||||
#define FighterManager_get_fighter_information _ZN3app8lua_bind44FighterManager__get_fighter_information_implEPNS_14FighterManagerENS_14FighterEntryIDE
|
||||
extern void* _ZN3app8lua_bind44FighterManager__get_fighter_information_implEPNS_14FighterManagerENS_14FighterEntryIDE(__int64_t, int) LINKABLE;
|
||||
|
||||
#define lib_lua_bind_get_value _ZN3lib18lua_bind_get_valueIiEEbmRT_
|
||||
extern bool _ZN3lib18lua_bind_get_valueIiEEbmRT_(uint64_t, int*) LINKABLE;
|
288
source/main.c
288
source/main.c
|
@ -8,6 +8,7 @@
|
|||
#include <switch/kernel/ipc.h>
|
||||
|
||||
#include "useful.h"
|
||||
#include "crc32.h"
|
||||
|
||||
#include "saltysd_core.h"
|
||||
#include "saltysd_ipc.h"
|
||||
|
@ -20,6 +21,9 @@
|
|||
#include "saltysd_helper.h"
|
||||
#include "l2c_imports.h"
|
||||
#include "acmd_imports.h"
|
||||
#include "lua_bind.h"
|
||||
|
||||
#include "taunt_toggles.h"
|
||||
|
||||
u32 __nx_applet_type = AppletType_None;
|
||||
|
||||
|
@ -29,9 +33,15 @@ Handle orig_main_thread;
|
|||
void *orig_ctx;
|
||||
void *orig_saved_lr;
|
||||
|
||||
u64 effect_manager_addr;
|
||||
u64 fighter_manager_addr;
|
||||
|
||||
u64 sv_set_function_hash_addr;
|
||||
|
||||
void (*AttackModule_set_attack_lua_state)(__int64_t, __int64_t);
|
||||
|
||||
void (*AttackModule_clear_all_orig)(__int64_t);
|
||||
void (*AttackModule_clear_orig)(__int64_t, int);
|
||||
|
||||
void __libnx_init(void *ctx, Handle main_thread, void *saved_lr)
|
||||
{
|
||||
|
@ -83,19 +93,25 @@ void AttackModule_clear_all_replace(__int64_t attack_module)
|
|||
|
||||
if (is_training_mode())
|
||||
{
|
||||
__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);
|
||||
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));
|
||||
__int64_t effect_module = *(__int64_t *)(battle_object_module_accessor + 0x140);
|
||||
void (*EffectModule_kill_kind)(__int64_t, __int64_t, bool, bool) =
|
||||
(void (*)(__int64_t, __int64_t, bool, bool))(*(__int64_t *)(*(__int64_t *)(effect_module) + 0xE0LL));
|
||||
|
||||
Hash40 shieldEffectHash = {.hash = 0xAFAE75F05LL};
|
||||
EffectModule_kill_kind(effect_module, shieldEffectHash.hash, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void AttackModule_clear_replace(__int64_t attack_module, int id)
|
||||
{
|
||||
AttackModule_clear_orig(attack_module, id);
|
||||
|
||||
// TODO: Kill effect based on hitbox ID
|
||||
}
|
||||
|
||||
void lib_L2CAgent_push_color(__int64_t *l2c_agent, Vector3f color)
|
||||
{
|
||||
L2CValue red = {.raw_float = color.x, .type = L2C_number};
|
||||
|
@ -107,10 +123,81 @@ void lib_L2CAgent_push_color(__int64_t *l2c_agent, Vector3f color)
|
|||
lib_L2CAgent_push_lua_stack(l2c_agent, &blue);
|
||||
}
|
||||
|
||||
void generate_hitbox_effects(L2CAgent* l2c_agent, L2CValue *id, L2CValue *bone, L2CValue *size, L2CValue *x, L2CValue *y, L2CValue *z, L2CValue *x2, L2CValue *y2, L2CValue *z2) {
|
||||
__int64_t battle_object_module_accessor = *(__int64_t *)(*(__int64_t *)(l2c_agent->lua_state_agent - 8) + 416LL);
|
||||
|
||||
float sizeMult = 19.0 / 200.0;
|
||||
Hash40 shieldEffectHash = {.hash = 0xAFAE75F05LL};
|
||||
|
||||
L2CValue shieldEffect = {.raw = shieldEffectHash.hash, .type = L2C_hash};
|
||||
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 terminate = {.raw = (bool)1, .type = L2C_bool};
|
||||
// for EFFECT_ATTR: NO_JOINT_SCALE | FOLLOW | SYNC_STOP | CONCLUDE_STATUS
|
||||
L2CValue attribute = {.raw = 0x101C000, .type = L2C_integer};
|
||||
L2CValue l2c_true = {.raw = (bool)1, .type = L2C_bool};
|
||||
L2CValue l2c_false = {.raw = (bool)0, .type = L2C_bool};
|
||||
L2CValue effectSize = {.raw_float = (float)size->raw_float * sizeMult, .type = L2C_number};
|
||||
|
||||
L2CValue rate = {.raw_float = 8.0f, .type = L2C_number};
|
||||
|
||||
__int64_t last_handle;
|
||||
L2CValue alpha = {.raw_float = 0.0f, .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;
|
||||
}
|
||||
else
|
||||
{
|
||||
*x2 = *x;
|
||||
*y2 = *y;
|
||||
*z2 = *z;
|
||||
num_effects = 1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_effects; i++)
|
||||
{
|
||||
// EFFECT_FOLLOW_NO_SCALE(graphic, bone, x, y, z, xrot, yrot, zrot, size, terminate)
|
||||
L2CValue currX =
|
||||
{.raw_float = (float)x->raw_float + ((x2->raw_float - x->raw_float) / 3 * i), .type = L2C_number};
|
||||
L2CValue currY =
|
||||
{.raw_float = (float)y->raw_float + ((y2->raw_float - y->raw_float) / 3 * i), .type = L2C_number};
|
||||
L2CValue currZ =
|
||||
{.raw_float = (float)z->raw_float + ((z2->raw_float - z->raw_float) / 3 * i), .type = L2C_number};
|
||||
|
||||
lib_L2CAgent_clear_lua_stack(l2c_agent);
|
||||
lib_L2CAgent_push_lua_stack(l2c_agent, &shieldEffect);
|
||||
lib_L2CAgent_push_lua_stack(l2c_agent, bone);
|
||||
lib_L2CAgent_push_lua_stack(l2c_agent, &currX);
|
||||
lib_L2CAgent_push_lua_stack(l2c_agent, &currY);
|
||||
lib_L2CAgent_push_lua_stack(l2c_agent, &currZ);
|
||||
lib_L2CAgent_push_lua_stack(l2c_agent, &xRot);
|
||||
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, &terminate);
|
||||
last_handle = app_sv_animcmd_EFFECT_FOLLOW_NO_SCALE(l2c_agent->lua_state_agent);
|
||||
|
||||
// Set to hitbox ID color
|
||||
// LAST_EFFECT_SET_COLOR(Red, Green, Blue)
|
||||
lib_L2CAgent_clear_lua_stack(l2c_agent);
|
||||
lib_L2CAgent_push_color(l2c_agent, id_colors[id->raw % 8]);
|
||||
app_sv_animcmd_LAST_EFFECT_SET_COLOR(l2c_agent->lua_state_agent);
|
||||
|
||||
// Speed up animation by rate to remove pulsing effect
|
||||
// LAST_EFFECT_SET_RATE(Rate)
|
||||
lib_L2CAgent_clear_lua_stack(l2c_agent);
|
||||
lib_L2CAgent_push_lua_stack(l2c_agent, &rate);
|
||||
app_sv_animcmd_LAST_EFFECT_SET_RATE(l2c_agent->lua_state_agent);
|
||||
}
|
||||
}
|
||||
|
||||
void app_sv_animcmd_ATTACK_replace(__int64_t a1)
|
||||
{
|
||||
SaltySD_printf("In attack code with lua_state ptr: %llx\n", a1);
|
||||
|
||||
__int64_t v1; // x19
|
||||
uint64_t v2; // x9
|
||||
uint64_t i; // x8
|
||||
|
@ -140,11 +227,11 @@ void app_sv_animcmd_ATTACK_replace(__int64_t a1)
|
|||
v1 = a1;
|
||||
AttackModule_set_attack_lua_state(*(__int64_t *)(*(__int64_t *)(a1 - 8) + 416LL), a1);
|
||||
|
||||
if (is_training_mode())
|
||||
if (HITBOX_VIS && is_training_mode())
|
||||
{
|
||||
// Replace AttackModule::clear_all()
|
||||
__int64_t battle_module_object_accessor = *(__int64_t *)(*(__int64_t *)(a1 - 8) + 416LL);
|
||||
__int64_t attack_module = *(__int64_t *)(battle_module_object_accessor + 0xA0);
|
||||
// Replace AttackModule::clear_all() and AttackModule::clear(int)
|
||||
__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)
|
||||
{
|
||||
|
@ -152,69 +239,15 @@ void app_sv_animcmd_ATTACK_replace(__int64_t a1)
|
|||
}
|
||||
*(__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};
|
||||
|
||||
L2CValue shieldEffect = {.raw = shieldEffectHash.hash, .type = L2C_hash};
|
||||
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 terminate = {.raw = (int)1, .type = L2C_integer};
|
||||
L2CValue attribute = {.raw = 0x101C000, .type = L2C_integer}; // for EFFECT_ATTR
|
||||
L2CValue l2c_true = {.raw = (bool)1, .type = L2C_bool};
|
||||
L2CValue l2c_false = {.raw = (bool)0, .type = L2C_bool};
|
||||
L2CValue effectSize = {.raw_float = (float)size.raw_float * sizeMult, .type = L2C_number};
|
||||
|
||||
L2CValue rate = {.raw_float = 8.0f, .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)
|
||||
__int64_t attack_module_clear = *(__int64_t *)(attack_module) + 0x58LL;
|
||||
if (AttackModule_clear_orig == 0)
|
||||
{
|
||||
num_effects = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
x2 = x;
|
||||
y2 = y;
|
||||
z2 = z;
|
||||
num_effects = 1;
|
||||
AttackModule_clear_orig = (void (*)(__int64_t))(*(__int64_t *)(attack_module_clear));
|
||||
}
|
||||
*(__int64_t *)(attack_module_clear) = AttackModule_clear_replace;
|
||||
|
||||
for (int i = 0; i < num_effects; i++)
|
||||
{
|
||||
L2CValue currX =
|
||||
{.raw_float = (float)x.raw_float + ((x2.raw_float - x.raw_float) / 3 * i), .type = L2C_number};
|
||||
L2CValue currY =
|
||||
{.raw_float = (float)y.raw_float + ((y2.raw_float - y.raw_float) / 3 * i), .type = L2C_number};
|
||||
L2CValue currZ =
|
||||
{.raw_float = (float)z.raw_float + ((z2.raw_float - z.raw_float) / 3 * i), .type = L2C_number};
|
||||
|
||||
lib_L2CAgent_clear_lua_stack(&l2c_agent);
|
||||
lib_L2CAgent_push_lua_stack(&l2c_agent, &shieldEffect);
|
||||
lib_L2CAgent_push_lua_stack(&l2c_agent, &bone);
|
||||
lib_L2CAgent_push_lua_stack(&l2c_agent, &currX);
|
||||
lib_L2CAgent_push_lua_stack(&l2c_agent, &currY);
|
||||
lib_L2CAgent_push_lua_stack(&l2c_agent, &currZ);
|
||||
lib_L2CAgent_push_lua_stack(&l2c_agent, &xRot);
|
||||
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, &terminate);
|
||||
app_sv_animcmd_EFFECT_FOLLOW_NO_SCALE(l2c_agent.lua_state_agent);
|
||||
|
||||
// Set to hitbox ID color
|
||||
lib_L2CAgent_clear_lua_stack(&l2c_agent);
|
||||
lib_L2CAgent_push_color(&l2c_agent, id_colors[id.raw % 8]);
|
||||
app_sv_animcmd_LAST_EFFECT_SET_COLOR(l2c_agent.lua_state_agent);
|
||||
|
||||
// Speed up animation by rate to remove pulsing effect
|
||||
lib_L2CAgent_clear_lua_stack(&l2c_agent);
|
||||
lib_L2CAgent_push_lua_stack(&l2c_agent, &rate);
|
||||
app_sv_animcmd_LAST_EFFECT_SET_RATE(l2c_agent.lua_state_agent);
|
||||
}
|
||||
// Generate hitbox effect(s)
|
||||
generate_hitbox_effects(&l2c_agent, &id, &bone, &size, &x, &y, &z, &x2, &y2, &z2);
|
||||
}
|
||||
|
||||
// original code: clear_lua_stack section
|
||||
|
@ -227,6 +260,107 @@ void app_sv_animcmd_ATTACK_replace(__int64_t a1)
|
|||
*(__int64_t *)(v1 + 16) = i;
|
||||
}
|
||||
|
||||
bool is_operation_cpu(__int64_t battle_object_module_accessor) {
|
||||
//int entry_id_var = 0x10000000;
|
||||
int entry_id_var;
|
||||
if ( lib_lua_bind_get_value(0xF370199DB936C5ED, &entry_id_var) & 1 ) {
|
||||
int entry_id = WorkModule_get_int(battle_object_module_accessor, entry_id_var);
|
||||
void* fighter_information = FighterManager_get_fighter_information(*(__int64_t*) fighter_manager_addr, entry_id);
|
||||
return FighterInformation_is_operation_cpu(fighter_information);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t WorkModule_enable_transition_term_group_impl_replace(__int64_t battle_object_module_accessor, __int64_t transition_group) {
|
||||
if (TOGGLE_STATE == MASH_AIRDODGE && is_training_mode()) {
|
||||
// 0x1F00000D for airdodge
|
||||
if (transition_group == 0x1F00000D) {
|
||||
if ( is_operation_cpu(battle_object_module_accessor)) {
|
||||
int status_kind = StatusModule_status_kind(battle_object_module_accessor);
|
||||
// Damage -> DamageFall
|
||||
if (status_kind >= 0x48 && status_kind <= 0x50)
|
||||
StatusModule__change_status_request_from_script(battle_object_module_accessor, 0x22, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// call original WorkModule::enable_transition_term_group_impl
|
||||
__int64_t work_module = *(__int64_t *)(battle_object_module_accessor + 0x50);
|
||||
__int64_t enable_transition_term_group_impl = *(__int64_t *)(work_module) + 0x140LL;
|
||||
|
||||
uint64_t (*work_module_enable_transition_term_group_impl)(__int64_t, __int64_t) =
|
||||
(uint64_t (*)(__int64_t, __int64_t))(*(__int64_t *)(enable_transition_term_group_impl));
|
||||
|
||||
return work_module_enable_transition_term_group_impl(work_module, transition_group);
|
||||
}
|
||||
|
||||
float WorkModule_get_float_replace(__int64_t battle_object_module_accessor, int var) {
|
||||
if (DI_STATE == DI_RIGHT && is_training_mode()) {
|
||||
if (is_operation_cpu(battle_object_module_accessor)) {
|
||||
int status_kind = StatusModule_status_kind(battle_object_module_accessor);
|
||||
// Damage -> DamageFall
|
||||
if (status_kind >= 0x48 && status_kind <= 0x50) {
|
||||
int DI_stick_x_ID;
|
||||
int DI_stick_y_ID;
|
||||
|
||||
if ( lib_lua_bind_get_value(0xA4D50A730E36970E, &DI_stick_x_ID) && var == DI_stick_x_ID)
|
||||
return 1.0;
|
||||
|
||||
if ( lib_lua_bind_get_value(0xEED4095B229D825B, &DI_stick_y_ID) && var == DI_stick_y_ID)
|
||||
return 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// call original WorkModule::get_float_impl
|
||||
__int64_t work_module = *(__int64_t *)(battle_object_module_accessor + 0x50);
|
||||
__int64_t get_float_impl = *(__int64_t *)(work_module) + 0x58LL;
|
||||
|
||||
float (*work_module_get_float_impl)(__int64_t, int) =
|
||||
(float (*)(__int64_t, int))(*(__int64_t *)(get_float_impl));
|
||||
|
||||
return work_module_get_float_impl(work_module, var);
|
||||
}
|
||||
|
||||
void MotionModule_change_motion_replace(__int64_t battle_object_module_accessor,
|
||||
__int64_t hash, float start_frame, float frame_speed_mult,
|
||||
bool unk1, float unk2, bool unk3, bool unk4) {
|
||||
const char* down_taunt_l = "appeal_lw_l";
|
||||
const char* down_taunt_r = "appeal_lw_r";
|
||||
const char* up_taunt_l = "appeal_hi_l";
|
||||
const char* up_taunt_r = "appeal_hi_r";
|
||||
const char* side_taunt_l = "appeal_s_l";
|
||||
const char* side_taunt_r = "appeal_s_r";
|
||||
|
||||
// Down Taunt
|
||||
if (hash == hash40(down_taunt_l, strlen(down_taunt_l)) ||
|
||||
hash == hash40(down_taunt_r, strlen(down_taunt_r))) {
|
||||
TOGGLE_STATE = (TOGGLE_STATE + 1) % NUM_TOGGLE_STATES;
|
||||
}
|
||||
// Up Taunt
|
||||
else if (hash == hash40(up_taunt_l, strlen(up_taunt_l)) ||
|
||||
hash == hash40(up_taunt_r, strlen(up_taunt_r))) {
|
||||
HITBOX_VIS = !HITBOX_VIS;
|
||||
}
|
||||
// Side Taunt
|
||||
else if (hash == hash40(side_taunt_l, strlen(side_taunt_l)) ||
|
||||
hash == hash40(side_taunt_r, strlen(side_taunt_r))) {
|
||||
DI_STATE = (DI_STATE + 1) % NUM_DI_STATES;
|
||||
}
|
||||
|
||||
|
||||
// call original WorkModule::enable_transition_term_group_impl
|
||||
__int64_t motion_module = *(__int64_t *)(battle_object_module_accessor + 0x88);
|
||||
__int64_t change_motion_impl = *(__int64_t *)(motion_module) + 0xD8LL;
|
||||
|
||||
void (*motion_module_change_motion_impl)(__int64_t, __int64_t, float, float, bool, float, bool, bool) =
|
||||
(void (*)(__int64_t, __int64_t, float, float, bool, float, bool, bool))(*(__int64_t *)(change_motion_impl));
|
||||
|
||||
motion_module_change_motion_impl(motion_module, hash, start_frame, frame_speed_mult,
|
||||
unk1, unk2, unk3, unk4);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SaltySD_printf("SaltySD Plugin: alive\n");
|
||||
|
@ -241,11 +375,23 @@ int main(int argc, char *argv[])
|
|||
SaltySD_Memcpy(dst_3, "Noice v%d%d%d", 13);
|
||||
}
|
||||
|
||||
effect_manager_addr = SaltySDCore_FindSymbol("_ZN3lib9SingletonINS_13EffectManagerEE9instance_E");
|
||||
fighter_manager_addr = SaltySDCore_FindSymbol("_ZN3lib9SingletonIN3app14FighterManagerEE9instance_E");
|
||||
|
||||
AttackModule_set_attack_lua_state = SaltySDCore_FindSymbol("_ZN3app10sv_animcmd6ATTACKEP9lua_State") + 0xD0 - 0x70;
|
||||
|
||||
// Install animCMD function replacement
|
||||
SaltySD_function_replace_sym("_ZN3app10sv_animcmd6ATTACKEP9lua_State",
|
||||
&app_sv_animcmd_ATTACK_replace);
|
||||
|
||||
SaltySD_function_replace_sym("_ZN3app8lua_bind45WorkModule__enable_transition_term_group_implEPNS_26BattleObjectModuleAccessorEi",
|
||||
&WorkModule_enable_transition_term_group_impl_replace);
|
||||
|
||||
SaltySD_function_replace_sym("_ZN3app8lua_bind26WorkModule__get_float_implEPNS_26BattleObjectModuleAccessorEi",
|
||||
&WorkModule_get_float_replace);
|
||||
|
||||
SaltySD_function_replace_sym("_ZN3app8lua_bind32MotionModule__change_motion_implEPNS_26BattleObjectModuleAccessorEN3phx6Hash40Effbfbb",
|
||||
&MotionModule_change_motion_replace);
|
||||
|
||||
__libnx_exit(0);
|
||||
}
|
||||
|
|
12
source/taunt_toggles.h
Normal file
12
source/taunt_toggles.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
bool HITBOX_VIS = 1;
|
||||
|
||||
const int DI_RIGHT = 1;
|
||||
|
||||
uint DI_STATE = 0;
|
||||
const uint NUM_DI_STATES = 2;
|
||||
|
||||
const uint NONE = 0;
|
||||
const uint MASH_AIRDODGE = 1;
|
||||
|
||||
uint TOGGLE_STATE = MASH_AIRDODGE;
|
||||
const uint NUM_TOGGLE_STATES = 2;
|
Loading…
Reference in a new issue