1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2025-03-14 02:16:10 +00:00

color hitboxes by ids; speed up shield effect to remove pulsing; clear effect only in training

This commit is contained in:
jugeeya 2019-04-11 00:28:56 -07:00
parent fc9ad5b7ab
commit 1eb40592ca
4 changed files with 103 additions and 30 deletions

View file

@ -41,7 +41,7 @@ EXEFS_SRC := exefs_src
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE -fno-plt -export-dynamic -s
CFLAGS := -Wall -O2 \
CFLAGS := -w -Wall -O2 \
-ffast-math \
$(ARCH) $(DEFINES)

View file

@ -9,3 +9,43 @@ extern uint64_t _ZN3app10sv_animcmd6EFFECTEP9lua_State(__int64_t unk1) LINKABLE;
//__int64_t (*app_sv_animcmd_EFFECT_FOLLOW_FLIP_COLOR)(__int64_t);
#define app_sv_animcmd_EFFECT_FOLLOW_FLIP_COLOR _ZN3app10sv_animcmd24EFFECT_FOLLOW_FLIP_COLOREP9lua_State
extern uint64_t _ZN3app10sv_animcmd24EFFECT_FOLLOW_FLIP_COLOREP9lua_State(__int64_t) LINKABLE;
// app::sv::animcmd::EFFECT_FOLLOW_NO_SCALE(lua_State * a1)
#define app_sv_animcmd_EFFECT_FOLLOW_NO_SCALE _ZN3app10sv_animcmd22EFFECT_FOLLOW_NO_SCALEEP9lua_State
extern uint64_t _ZN3app10sv_animcmd22EFFECT_FOLLOW_NO_SCALEEP9lua_State(__int64_t) LINKABLE;
// app::sv::animcmd::EFFECT_FOLLOW(lua_State * a1)
#define app_sv_animcmd_EFFECT_FOLLOW _ZN3app10sv_animcmd13EFFECT_FOLLOWEP9lua_State
extern uint64_t _ZN3app10sv_animcmd13EFFECT_FOLLOWEP9lua_State(__int64_t) LINKABLE;
// app::sv::animcmd::EFFECT_ATTR(lua_State * a1)
#define app_sv_animcmd_EFFECT_ATTR _ZN3app10sv_animcmd11EFFECT_ATTREP9lua_State
extern uint64_t _ZN3app10sv_animcmd11EFFECT_ATTREP9lua_State(__int64_t) LINKABLE;
// app::sv::animcmd::EFFECT_REMOVE_ATTR(lua_State * a1)
#define app_sv_animcmd_EFFECT_REMOVE_ATTR _ZN3app10sv_animcmd18EFFECT_REMOVE_ATTREP9lua_State
extern uint64_t _ZN3app10sv_animcmd18EFFECT_REMOVE_ATTREP9lua_State(__int64_t) LINKABLE;
// app::sv::animcmd::EFFECT_FOLLOW_arg11(lua_State * a1)
#define app_sv_animcmd_EFFECT_FOLLOW_arg11 _ZN3app10sv_animcmd19EFFECT_FOLLOW_arg11EP9lua_State
extern uint64_t _ZN3app10sv_animcmd19EFFECT_FOLLOW_arg11EP9lua_State(__int64_t) LINKABLE;
// app::sv_module_access::effect(lua_State * a1)
#define app_sv_module_access_effect _ZN3app16sv_module_access6effectEP9lua_State
extern uint64_t _ZN3app16sv_module_access6effectEP9lua_State(__int64_t) LINKABLE;
// app::sv_animcmd::EFFECT_FLW_POS(lua_State * a1)
#define app_sv_animcmd_EFFECT_FLW_POS _ZN3app10sv_animcmd14EFFECT_FLW_POSEP9lua_State
extern uint64_t _ZN3app10sv_animcmd14EFFECT_FLW_POSEP9lua_State(__int64_t) LINKABLE;
// app::sv_animcmd::LAST_EFFECT_SET_COLOR(lua_State * a1)
#define app_sv_animcmd_LAST_EFFECT_SET_COLOR _ZN3app10sv_animcmd21LAST_EFFECT_SET_COLOREP9lua_State
extern uint64_t _ZN3app10sv_animcmd21LAST_EFFECT_SET_COLOREP9lua_State(__int64_t) LINKABLE;
// app::sv_animcmd::LAST_EFFECT_SET_SCALE_W(lua_State * a1)
#define app_sv_animcmd_LAST_EFFECT_SET_SCALE_W _ZN3app10sv_animcmd23LAST_EFFECT_SET_SCALE_WEP9lua_State
extern uint64_t _ZN3app10sv_animcmd23LAST_EFFECT_SET_SCALE_WEP9lua_State(__int64_t) LINKABLE;
// 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;

View file

@ -9,6 +9,13 @@ typedef struct Hash40
uint64_t hash : 40;
} Hash40;
typedef struct Vector3f
{
float x;
float y;
float z;
} Vector3f;
enum L2CVarType
{
L2C_void = 0,

View file

@ -29,9 +29,6 @@ Handle orig_main_thread;
void * orig_ctx;
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) {
@ -62,25 +59,48 @@ void __attribute__((weak)) NORETURN __libnx_exit(int rc) {
__nx_exit(0, orig_saved_lr);
}
Vector3f id_colors[8] = {
{1.0f, 0.0f, 0.0f},
{0.7843f, 0.3529f, 1.0f},
{1.0f, 0.7843f, 0.7843f},
{0.0f, 1.0f, 0.8431f},
{1.0f, 0.4706f, 0.0f},
{0.7843f, 0.7059f, 0.0f},
{0.7843f, 0.0f, 1.0f},
{0.3765f, 0.2863f, 0.5294f},
};
#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);
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));
// Clear graphics every time we clear all hitboxes.
__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);
Hash40 shieldEffectHash = { .hash = 0xAFAE75F05LL };
EffectModule_kill_kind(effect_module, shieldEffectHash.hash, 0, 1);
}
}
void _ZN3app10sv_animcmd6ATTACKEP9lua_State_replace(__int64_t a1) {
void lib_L2CAgent_push_color(__int64_t* l2c_agent, Vector3f color) {
L2CValue red = { .raw_float = color.x, .type = L2C_number };
L2CValue green = { .raw_float = color.y, .type = L2C_number };
L2CValue blue = { .raw_float = color.z, .type = L2C_number };
lib_L2CAgent_push_lua_stack(l2c_agent, &red);
lib_L2CAgent_push_lua_stack(l2c_agent, &green);
lib_L2CAgent_push_lua_stack(l2c_agent, &blue);
}
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
@ -92,7 +112,8 @@ void _ZN3app10sv_animcmd6ATTACKEP9lua_State_replace(__int64_t a1) {
lib_L2CAgent(&l2c_agent, a1);
// Get all necessary hitbox params
L2CValue bone, damage, angle, kbg, wkb, bkb, size, x, y, z, x2, y2, z2;
L2CValue id, bone, damage, angle, kbg, wkb, bkb, size, x, y, z, x2, y2, z2;
get_lua_stack(&l2c_agent, 1, &id);
get_lua_stack(&l2c_agent, 3, &bone);
get_lua_stack(&l2c_agent, 4, &damage);
get_lua_stack(&l2c_agent, 5, &angle);
@ -114,8 +135,8 @@ void _ZN3app10sv_animcmd6ATTACKEP9lua_State_replace(__int64_t a1) {
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 battle_module_object_accessor = *(__int64_t *) (*(__int64_t *) (a1 - 8) + 416LL);
__int64_t attack_module = *(__int64_t *) (battle_module_object_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));
@ -132,11 +153,12 @@ void _ZN3app10sv_animcmd6ATTACKEP9lua_State_replace(__int64_t a1) {
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 unkParam = { .raw = (bool) 1, .type = L2C_bool };
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 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 };
L2CValue rate = { .raw_float = 8.0f, .type = L2C_number };
// Extended Hitboxes if x2, y2, z2 are not L2CValue::nil
int num_effects;
@ -168,10 +190,17 @@ void _ZN3app10sv_animcmd6ATTACKEP9lua_State_replace(__int64_t a1) {
lib_L2CAgent_push_lua_stack(&l2c_agent, &zRot);
lib_L2CAgent_push_lua_stack(&l2c_agent, &effectSize);
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);
app_sv_animcmd_EFFECT_FOLLOW_COLOR(l2c_agent.lua_state_agent);
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);
}
}
@ -182,7 +211,7 @@ void _ZN3app10sv_animcmd6ATTACKEP9lua_State_replace(__int64_t a1) {
*(__int32_t *) (v2 + 8) = 0;
}
*(__int64_t *) (v1 + 16) = i;
} /* _ZN3app10sv_animcmd6ATTACKEP9lua_State_replace */
}
int main(int argc, char * argv[]) {
SaltySD_printf("SaltySD Plugin: alive\n");
@ -190,9 +219,6 @@ int main(int argc, char * argv[]) {
// Get anchor for imports
ANCHOR_ABS = SaltySDCore_getCodeStart();
// Get necessary functions
app_sv_animcmd_EFFECT_FOLLOW_COLOR = (__int64_t (*)(__int64_t))(IMPORT(0x7101955F10));
char * ver = "Ver. %d.%d.%d";
u64 dst_3 = SaltySDCore_findCode(ver, strlen(ver));
if (dst_3) {
@ -201,7 +227,7 @@ int main(int argc, char * argv[]) {
// Install animCMD function replacement
SaltySD_function_replace_sym("_ZN3app10sv_animcmd6ATTACKEP9lua_State",
&_ZN3app10sv_animcmd6ATTACKEP9lua_State_replace);
&app_sv_animcmd_ATTACK_replace);
__libnx_exit(0);
}