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

release 0.7: DI toggles

This commit is contained in:
jugeeya 2019-05-19 14:46:19 -07:00
parent 1b5165d211
commit ddd53cd0fb
7 changed files with 200 additions and 147 deletions

View file

@ -7,8 +7,25 @@
#include "l2c_imports.hpp"
#include "lua_helper.hpp"
#include <initializer_list>
#include <vector>
using namespace lib;
struct ACMDReplacement {
void* func;
int battle_object_category;
int battle_object_kind;
const char* acmd_script;
};
std::vector<ACMDReplacement> acmd_replacements;
namespace app::sv_system
{
u64 battle_object_module_accessor(u64) asm("_ZN3app9sv_system29battle_object_module_accessorEP9lua_State") LINKABLE;
}
namespace app::lua_bind
{
namespace AttackModule
@ -70,6 +87,13 @@ namespace app::lua_bind
struct ACMD
{
L2CAgent* l2c_agent;
u64 module_accessor;
ACMD(L2CAgent* agent) {
l2c_agent = agent;
module_accessor = app::sv_system::battle_object_module_accessor(l2c_agent->lua_state_agent);
}
void frame(float f) {
app::sv_animcmd::frame(l2c_agent->lua_state_agent, f);
l2c_agent->clear_lua_stack();
@ -84,6 +108,16 @@ struct ACMD
return excute;
}
void wrap( u64 (*acmd_func)(u64), std::initializer_list<L2CValue> list )
{
l2c_agent->clear_lua_stack();
for( auto elem : list )
l2c_agent->push_lua_stack(&L2CValue(elem));
acmd_func(l2c_agent->lua_state_agent);
l2c_agent->clear_lua_stack();
}
void ATTACK(
u64 i1,
u64 i2,
@ -123,42 +157,42 @@ struct ACMD
u64 i23
) {
L2CValue hitbox_params[36] = {
{.type = L2C_integer, .raw = i1}, // ID
{.type = L2C_integer, .raw = i2}, // Unk
{.type = L2C_hash, .raw = h1}, // Joint
{.type = L2C_number, .raw_float = f1}, // Damage
{.type = L2C_integer, .raw = i3}, // Angle
{.type = L2C_integer, .raw = i4}, // KBG
{.type = L2C_integer, .raw = i5}, // WBKB
{.type = L2C_integer, .raw = i6}, // BKB
{.type = L2C_number, .raw_float = f2}, // Size
{.type = L2C_number, .raw_float = f3}, // X
{.type = L2C_number, .raw_float = f4}, // Y
{.type = L2C_number, .raw_float = f5}, // Z
{.type = L2C_void, .raw = 0}, // X2
{.type = L2C_void, .raw = 0}, // Y2
{.type = L2C_void, .raw = 0}, // Z2
{.type = L2C_number, .raw_float = f6}, // Hitlag
{.type = L2C_number, .raw_float = f7}, // SDI
{.type = L2C_integer, .raw = i7},
{.type = L2C_integer, .raw = i8},
{.type = L2C_integer, .raw = i9},
{.type = L2C_integer, .raw = i10},
{.type = L2C_number, .raw_float = f8},
{.type = L2C_integer, .raw = i11},
{.type = L2C_integer, .raw = i12},
{.type = L2C_integer, .raw = i13},
{.type = L2C_integer, .raw = i14},
{.type = L2C_integer, .raw = i15},
{.type = L2C_integer, .raw = i16},
{.type = L2C_integer, .raw = i17},
{.type = L2C_integer, .raw = i18},
{.type = L2C_integer, .raw = i19},
{.type = L2C_integer, .raw = i20},
{.type = L2C_hash, .raw = h2},
{.type = L2C_integer, .raw = i21},
{.type = L2C_integer, .raw = i22},
{.type = L2C_integer, .raw = i23},
L2CValue(i1), // ID
L2CValue(i2), // Unk
L2CValue(h1), // Joint
L2CValue(f1), // Damage
L2CValue(i3), // Angle
L2CValue(i4), // KBG
L2CValue(i5), // WBKB
L2CValue(i6), // BKB
L2CValue(f2), // Size
L2CValue(f3), // X
L2CValue(f4), // Y
L2CValue(f5), // Z
L2CValue("void"), // X2
L2CValue("void"), // Y2
L2CValue("void"), // Z2
L2CValue(f6), // Hitlag
L2CValue(f7), // SDI
L2CValue(i7),
L2CValue(i8),
L2CValue(i9),
L2CValue(i10),
L2CValue(f8),
L2CValue(i11),
L2CValue(i12),
L2CValue(i13),
L2CValue(i14),
L2CValue(i15),
L2CValue(i16),
L2CValue(i17),
L2CValue(i18),
L2CValue(i19),
L2CValue(i20),
L2CValue(h2),
L2CValue(i21),
L2CValue(i22),
L2CValue(i23)
};
for (size_t i = 0; i < 36; i++)

View file

@ -10,9 +10,6 @@ using namespace app::sv_animcmd;
void (*AttackModule_set_attack_lua_state)(u64, u64);
void (*AttackModule_clear_all_orig)(u64);
void (*AttackModule_clear_orig)(u64, int);
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},
@ -57,13 +54,9 @@ void AttackModule_clear_all_replace(u64 module_accessor) {
}
void push_color(L2CAgent *l2c_agent, Vector3f color) {
L2CValue red = {.type = L2C_number, .raw_float = color.x};
L2CValue green = {.type = L2C_number, .raw_float = color.y};
L2CValue blue = {.type = L2C_number, .raw_float = color.z};
l2c_agent->push_lua_stack(&red);
l2c_agent->push_lua_stack(&green);
l2c_agent->push_lua_stack(&blue);
l2c_agent->push_lua_stack(&L2CValue(color.x));
l2c_agent->push_lua_stack(&L2CValue(color.y));
l2c_agent->push_lua_stack(&L2CValue(color.z));
}
void generate_hitbox_effects(L2CAgent *l2c_agent, L2CValue *id, L2CValue *bone,
@ -73,14 +66,14 @@ void generate_hitbox_effects(L2CAgent *l2c_agent, L2CValue *id, L2CValue *bone,
float sizeMult = 19.0 / 200.0;
Hash40 shieldEffectHash = {.hash = 0xAFAE75F05LL};
L2CValue shieldEffect = {.type = L2C_hash, .raw = shieldEffectHash.hash};
L2CValue xRot = {.type = L2C_number, .raw_float = 0.0};
L2CValue yRot = {.type = L2C_number, .raw_float = 0.0};
L2CValue zRot = {.type = L2C_number, .raw_float = 0.0};
L2CValue terminate = {.type = L2C_bool, .raw = 1};
L2CValue effectSize = {.type = L2C_number, .raw_float = (float)size->raw_float * sizeMult};
L2CValue shieldEffect(shieldEffectHash.hash);
L2CValue xRot(0.0f);
L2CValue yRot(0.0f);
L2CValue zRot(0.0f);
L2CValue terminate(true);
L2CValue effectSize((float)size->raw_float * sizeMult);
L2CValue rate = {.type = L2C_number, .raw_float = 8.0f};
L2CValue rate(8.0f);
// Extended Hitboxes if x2, y2, z2 are not L2CValue::nil
int num_effects;
@ -94,30 +87,14 @@ void generate_hitbox_effects(L2CAgent *l2c_agent, L2CValue *id, L2CValue *bone,
}
for (int i = 0; i < num_effects; i++) {
// EFFECT_FOLLOW_NO_SCALE(graphic, bone, x, y, z, xrot, yrot, zrot, size,
// terminate)
L2CValue currX = {
.type = L2C_number,
.raw_float = x->raw_float + ((x2->raw_float - x->raw_float) / 3 * i)};
L2CValue currY = {
.type = L2C_number,
.raw_float = y->raw_float + ((y2->raw_float - y->raw_float) / 3 * i)};
L2CValue currZ = {
.type = L2C_number,
.raw_float = z->raw_float + ((z2->raw_float - z->raw_float) / 3 * i)};
L2CValue currX(x->raw_float + ((x2->raw_float - x->raw_float) / 3 * i));
L2CValue currY(y->raw_float + ((y2->raw_float - y->raw_float) / 3 * i));
L2CValue currZ(z->raw_float + ((z2->raw_float - z->raw_float) / 3 * i));
l2c_agent->clear_lua_stack();
l2c_agent->push_lua_stack(&shieldEffect);
l2c_agent->push_lua_stack(bone);
l2c_agent->push_lua_stack(&currX);
l2c_agent->push_lua_stack(&currY);
l2c_agent->push_lua_stack(&currZ);
l2c_agent->push_lua_stack(&xRot);
l2c_agent->push_lua_stack(&yRot);
l2c_agent->push_lua_stack(&zRot);
l2c_agent->push_lua_stack(&effectSize);
l2c_agent->push_lua_stack(&terminate);
EFFECT_FOLLOW_NO_SCALE(l2c_agent->lua_state_agent);
ACMD acmd{.l2c_agent = l2c_agent};
acmd.wrap(EFFECT_FOLLOW_NO_SCALE,
{shieldEffect, *bone, currX, currY, currZ, xRot, yRot, zRot, effectSize, terminate}
);
// Set to hitbox ID color
// LAST_EFFECT_SET_COLOR(Red, Green, Blue)
@ -127,9 +104,7 @@ void generate_hitbox_effects(L2CAgent *l2c_agent, L2CValue *id, L2CValue *bone,
// Speed up animation by rate to remove pulsing effect
// LAST_EFFECT_SET_RATE(Rate)
l2c_agent->clear_lua_stack();
l2c_agent->push_lua_stack(&rate);
LAST_EFFECT_SET_RATE(l2c_agent->lua_state_agent);
acmd.wrap(LAST_EFFECT_SET_RATE, {rate});
}
}
@ -165,8 +140,7 @@ void app_sv_animcmd_ATTACK_replace(u64 a1) {
if (HITBOX_VIS && is_training_mode()) {
// Generate hitbox effect(s)
generate_hitbox_effects(&l2c_agent, &id, &bone, &size, &x, &y, &z, &x2, &y2,
&z2);
generate_hitbox_effects(&l2c_agent, &id, &bone, &size, &x, &y, &z, &x2, &y2, &z2);
}
// original code: clear_lua_stack section

View file

@ -61,6 +61,28 @@ namespace lib
struct L2CInnerFunctionBase* raw_innerfunc;
//std::string* raw_string;
};
L2CValue() {}
L2CValue(bool val) {
type = L2C_bool;
raw = val;
}
L2CValue(u64 val) {
type = L2C_integer;
raw = val;
}
L2CValue(float val) {
type = L2C_number;
raw_float = val;
}
L2CValue(const char* str) {
type = L2C_void;
}
};
struct L2CAgent

View file

@ -1,3 +1,6 @@
#ifndef RAYGUN_PRINTER_H
#define RAYGUN_PRINTER_H
#include <switch.h>
#include <ctype.h>
@ -204,4 +207,6 @@ void print_string( u64 module_accessor, const char* print_str) {
line_num++;
}
}
}
}
#endif // RAYGUN_PRINTER_H

View file

@ -9,7 +9,12 @@
#include "acmd_wrapper.hpp"
#include "lua_helper.hpp"
#include "raygun_printer.hpp"
#include "const_value_table.h"
#include "taunt_toggles.h"
#include <vector>
#define LOAD64 *(u64 *)
@ -17,6 +22,9 @@ using namespace lib;
using namespace app::lua_bind;
u64 shine_replace(L2CAgent* l2c_agent, void* variadic);
u64 appeal_lw_replace(L2CAgent* l2c_agent, void* variadic);
u64 appeal_hi_replace(L2CAgent* l2c_agent, void* variadic);
u64 appeal_s_replace(L2CAgent* l2c_agent, void* variadic);
void replace_scripts(L2CAgent* l2c_agent, u8 category, uint kind) {
// fighter
@ -30,12 +38,77 @@ void replace_scripts(L2CAgent* l2c_agent, u8 category, uint kind) {
// peach
if (kind == FIGHTER_KIND_PEACH) {
}
l2c_agent->sv_set_function_hash(&appeal_lw_replace, hash40("effect_appeallwl"));
l2c_agent->sv_set_function_hash(&appeal_lw_replace, hash40("effect_appeallwr"));
l2c_agent->sv_set_function_hash(&appeal_hi_replace, hash40("effect_appealhil"));
l2c_agent->sv_set_function_hash(&appeal_hi_replace, hash40("effect_appealhir"));
l2c_agent->sv_set_function_hash(&appeal_s_replace, hash40("effect_appealsl"));
l2c_agent->sv_set_function_hash(&appeal_s_replace, hash40("effect_appealsr"));
}
}
u64 appeal_lw_replace(L2CAgent* l2c_agent, void* variadic) {
ACMD acmd = ACMD(l2c_agent);
acmd.frame(1);
if (acmd.is_excute()) {
TOGGLE_STATE = (TOGGLE_STATE + 1) % NUM_TOGGLE_STATES;
if (TOGGLE_STATE)
print_string(acmd.module_accessor, "MASH\nAIRDODGE");
else
print_string(acmd.module_accessor, "NONE");
}
return 0;
}
u64 appeal_hi_replace(L2CAgent* l2c_agent, void* variadic) {
ACMD acmd = ACMD(l2c_agent);
acmd.frame(1);
if (acmd.is_excute()) {
HITBOX_VIS = !HITBOX_VIS;
if (HITBOX_VIS)
print_string(acmd.module_accessor, "HITBOX\nVIS");
else
print_string(acmd.module_accessor, "NO\nHITBOX");
}
return 0;
}
void show_angle(u64 module_accessor, float y, float x, float zrot) {
Hash40 raygunShot = {.hash = 0x11e470b07fLL};
Hash40 top = {.hash = 0x031ed91fcaLL};
Vector3f pos = {.x = x, .y = y, .z = 0};
Vector3f rot = {.x = 0, .y = 90, .z = zrot};
Vector3f random = {.x = 0, .y = 0, .z = 0};
float size = 0.5;
EffectModule::req_on_joint(module_accessor, raygunShot.hash, top.hash, &pos,
&rot, size, &random, &random, 0, 0, 0, 0);
}
u64 appeal_s_replace(L2CAgent* l2c_agent, void* variadic) {
ACMD acmd = ACMD(l2c_agent);
acmd.frame(1);
if (acmd.is_excute()) {
DI_STATE = (DI_STATE + 1) % NUM_DI_STATES;
const char* DI_strings[NUM_DI_STATES] = {"NONE", "AWAY", "DOWN AWAY", "DOWN", "DOWN IN",
"IN", "UP IN", "UP", "UP AWAY"};
print_string(acmd.module_accessor, DI_strings[DI_STATE]);
}
return 0;
}
// AnimCMD replacement function
u64 shine_replace(L2CAgent* l2c_agent, void* variadic) {
ACMD acmd = ACMD{.l2c_agent = l2c_agent};
ACMD acmd = ACMD(l2c_agent);
acmd.frame(1);
if (acmd.is_excute()) {

View file

@ -11,7 +11,7 @@ extern bool HITBOX_VIS = 1;
// 0, pi/4, pi/2, 3pi/4, pi, 5pi/4, 3pi/2, 7pi/4
extern int DI_STATE = 0;
#define NUM_DI_STATES 2
#define NUM_DI_STATES 9
// Down Taunt
#define MASH_AIRDODGE 1

View file

@ -28,10 +28,6 @@ void training_mods_main() {
SaltySD_function_replace_sym(
"_ZN3app8lua_bind26WorkModule__get_float_implEPNS_26BattleObjectModuleAccessorEi",
(u64)&WorkModule_get_float_replace);
SaltySD_function_replace_sym(
"_ZN3app8lua_bind32MotionModule__change_motion_implEPNS_26BattleObjectModuleAccessorEN3phx6Hash40Effbfbb",
(u64)&MotionModule_change_motion_replace);
}
bool is_operation_cpu(u64 module_accessor) {
@ -43,6 +39,7 @@ bool is_operation_cpu(u64 module_accessor) {
return FighterInformation::is_operation_cpu(fighter_information);
}
// Force airdodge
u64 WorkModule_enable_transition_term_group_replace(u64 module_accessor,
u64 transition_group) {
if (TOGGLE_STATE == MASH_AIRDODGE && is_training_mode()) {
@ -69,27 +66,18 @@ u64 WorkModule_enable_transition_term_group_replace(u64 module_accessor,
transition_group);
}
void show_angle(u64 module_accessor, float y, float x, float zrot) {
Hash40 raygunShot = {.hash = 0x11e470b07fLL};
Hash40 top = {.hash = 0x031ed91fcaLL};
Vector3f pos = {.x = x, .y = y, .z = 0};
Vector3f rot = {.x = 0, .y = 90, .z = zrot};
Vector3f random = {.x = 0, .y = 0, .z = 0};
float size = 0.5;
EffectModule::req_on_joint(module_accessor, raygunShot.hash, top.hash, &pos,
&rot, size, &random, &random, 0, 0, 0, 0);
}
// Force DI
float WorkModule_get_float_replace(u64 module_accessor, int var) {
if (is_training_mode()) {
if (is_training_mode() && DI_STATE != NONE) {
if (is_operation_cpu(module_accessor)) {
int status_kind = StatusModule::status_kind(module_accessor);
// Damage -> DamageFall
if (status_kind >= 0x48 && status_kind <= 0x50) {
float angle = 0;//(DI_STATE - 1) * PI / 4.0;
float angle = (DI_STATE - 1) * M_PI / 4.0;
// If facing left, reverse angle
if (PostureModule::lr(module_accessor) != -1.0)
angle -= M_PI;
if (var == FIGHTER_STATUS_DAMAGE_WORK_FLOAT_VECOR_CORRECT_STICK_X)
return cos(angle);
@ -108,47 +96,4 @@ float WorkModule_get_float_replace(u64 module_accessor, int var) {
(float (*)(u64, int))(LOAD64(get_float_impl));
return work_module_get_float_impl(work_module, var);
}
void MotionModule_change_motion_replace(u64 module_accessor, u64 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";
char buffer[16];
// Down Taunt
if (hash == hash40(down_taunt_l) || hash == hash40(down_taunt_r)) {
TOGGLE_STATE = (TOGGLE_STATE + 1) % NUM_TOGGLE_STATES;
if (TOGGLE_STATE)
print_string(module_accessor, "MASH\nAIRDODGE");
else
print_string(module_accessor, "NONE");
}
// Up Taunt
else if (hash == hash40(up_taunt_l) || hash == hash40(up_taunt_r)) {
HITBOX_VIS = !HITBOX_VIS;
if (HITBOX_VIS)
print_string(module_accessor, "HITBOX\nVIS");
else
print_string(module_accessor, "NO\nHITBOX");
}
// Side Taunt
else if (hash == hash40(side_taunt_l) || hash == hash40(side_taunt_r)) {
}
// call original WorkModule::enable_transition_term_group_impl
u64 motion_module = LOAD64(module_accessor + 0x88);
u64 change_motion_impl = LOAD64(motion_module) + 0xD8LL;
void (*motion_module_change_motion_impl)(u64, u64, float, float, bool, float, bool, bool) =
(void (*)(u64, u64, float, float, bool, float, bool, bool))(
LOAD64(change_motion_impl));
motion_module_change_motion_impl(motion_module, hash, start_frame, frame_speed_mult, unk1, unk2, unk3, unk4);
}