mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-03-16 11:26:11 +00:00
Add Left Stick Mod
Currently only used for air dodges
This commit is contained in:
parent
2fc1c75ab6
commit
be16194528
2 changed files with 132 additions and 6 deletions
84
src/training/left_stick.rs
Normal file
84
src/training/left_stick.rs
Normal file
|
@ -0,0 +1,84 @@
|
|||
use crate::common::consts::*;
|
||||
use crate::common::*;
|
||||
use core::f64::consts::PI;
|
||||
use smash::app::{self, lua_bind::*};
|
||||
use smash::hash40;
|
||||
use smash::lib::lua_const::*;
|
||||
|
||||
static mut STICK_DIRECTION: Direction = Direction::None;
|
||||
|
||||
pub unsafe fn mod_get_stick_x(
|
||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||
) -> Option<f32> {
|
||||
if !is_training_mode() {
|
||||
return None;
|
||||
}
|
||||
|
||||
if !is_operation_cpu(module_accessor) {
|
||||
return None;
|
||||
}
|
||||
|
||||
let status_kind = StatusModule::status_kind(module_accessor);
|
||||
if !status_kind == FIGHTER_STATUS_KIND_ESCAPE_AIR {
|
||||
return None;
|
||||
}
|
||||
|
||||
STICK_DIRECTION = MENU.di_state;
|
||||
let mut angle: f64 = get_angle(STICK_DIRECTION);
|
||||
|
||||
if angle == ANGLE_NONE {
|
||||
return None;
|
||||
}
|
||||
|
||||
// If facing left, reverse angle
|
||||
if PostureModule::lr(module_accessor) != FIGHTER_FACING_RIGHT {
|
||||
angle -= PI;
|
||||
}
|
||||
|
||||
Some(angle.cos() as f32)
|
||||
}
|
||||
|
||||
pub unsafe fn mod_get_stick_y(
|
||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||
) -> Option<f32> {
|
||||
if !is_training_mode() {
|
||||
return None;
|
||||
}
|
||||
|
||||
if !is_operation_cpu(module_accessor) {
|
||||
return None;
|
||||
}
|
||||
|
||||
let status_kind = StatusModule::status_kind(module_accessor);
|
||||
if !status_kind == FIGHTER_STATUS_KIND_ESCAPE_AIR {
|
||||
return None;
|
||||
}
|
||||
|
||||
STICK_DIRECTION = MENU.di_state;
|
||||
let mut angle: f64 = get_angle(STICK_DIRECTION);
|
||||
|
||||
if angle == ANGLE_NONE {
|
||||
return None;
|
||||
}
|
||||
|
||||
// If facing left, reverse angle
|
||||
if PostureModule::lr(module_accessor) != FIGHTER_FACING_RIGHT {
|
||||
angle -= PI;
|
||||
}
|
||||
|
||||
Some(angle.sin() as f32)
|
||||
}
|
||||
|
||||
unsafe fn get_angle(direction: Direction) -> f64 {
|
||||
if direction == Direction::Random {
|
||||
let rand_direction = get_random_direction();
|
||||
return direction_to_angle(rand_direction);
|
||||
}
|
||||
|
||||
direction_to_angle(direction)
|
||||
}
|
||||
|
||||
unsafe fn get_random_direction() -> Direction {
|
||||
let rand = app::sv_math::rand(hash40("fighter"), 8);
|
||||
Direction::from(rand)
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
use crate::common::FIGHTER_MANAGER_ADDR;
|
||||
use crate::common::*;
|
||||
use crate::hitbox_visualizer;
|
||||
use skyline::nn::ro::LookupSymbol;
|
||||
use smash::app::{self, lua_bind::*};
|
||||
|
@ -7,6 +8,7 @@ pub mod directional_influence;
|
|||
pub mod shield;
|
||||
pub mod tech;
|
||||
|
||||
mod left_stick;
|
||||
mod ledge;
|
||||
mod mash;
|
||||
mod save_states;
|
||||
|
@ -54,6 +56,43 @@ pub unsafe fn handle_get_command_flag_cat(
|
|||
flag
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called to get the stick position when
|
||||
* shielding (shield tilt)
|
||||
* 1 is fully right, -1 is fully left
|
||||
*/
|
||||
#[skyline::hook(replace = ControlModule::get_stick_x_no_clamp)]
|
||||
pub unsafe fn get_stick_x_no_clamp(module_accessor: &mut app::BattleObjectModuleAccessor) -> f32 {
|
||||
left_stick::mod_get_stick_x(module_accessor).unwrap_or_else(|| original!()(module_accessor))
|
||||
}
|
||||
/**
|
||||
* This is called to get the stick position when
|
||||
* shielding (shield tilt)
|
||||
* 1 is fully up, -1 is fully down
|
||||
*/
|
||||
#[skyline::hook(replace = ControlModule::get_stick_y_no_clamp)]
|
||||
pub unsafe fn get_stick_y_no_clamp(module_accessor: &mut app::BattleObjectModuleAccessor) -> f32 {
|
||||
left_stick::mod_get_stick_y(module_accessor).unwrap_or_else(|| original!()(module_accessor))
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when:
|
||||
* Walking in the facing direction
|
||||
* Air Dodging
|
||||
*/
|
||||
#[skyline::hook(replace = ControlModule::get_stick_x)]
|
||||
pub unsafe fn get_stick_x(module_accessor: &mut app::BattleObjectModuleAccessor) -> f32 {
|
||||
left_stick::mod_get_stick_x(module_accessor).unwrap_or_else(|| original!()(module_accessor))
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
#[skyline::hook(replace = ControlModule::get_stick_y)]
|
||||
pub unsafe fn get_stick_y(module_accessor: &mut app::BattleObjectModuleAccessor) -> f32 {
|
||||
left_stick::mod_get_stick_y(module_accessor).unwrap_or_else(|| original!()(module_accessor))
|
||||
}
|
||||
|
||||
// int get_pad_flag(u64 module_accessor) {
|
||||
// u64 control_module = load_module(module_accessor, 0x48);
|
||||
// int (*get_pad_flag)(u64) = (int (*)(u64)) load_module_impl(control_module, 0x348);
|
||||
|
@ -78,13 +117,13 @@ pub unsafe fn handle_get_command_flag_cat(
|
|||
// return stick_x;
|
||||
// }
|
||||
|
||||
// float get_stick_y_replace(u64 module_accessor) {
|
||||
// float get_attack_air_stick_x_replace(u64 module_accessor) {
|
||||
// u64 control_module = load_module(module_accessor, 0x48);
|
||||
// float (*get_stick_y)(u64) = (float (*)(u64)) load_module_impl(control_module, 0x188);
|
||||
// float stick_y = get_stick_y(control_module);
|
||||
// float (*get_attack_air_stick_x)(u64) = (float (*)(u64)) load_module_impl(control_module, 0x188);
|
||||
// float stick_y = get_attack_air_stick_x(control_module);
|
||||
|
||||
// bool replace;
|
||||
// float ret = InputRecorder::get_stick_y(module_accessor, replace);
|
||||
// float ret = InputRecorder::get_attack_air_stick_x(module_accessor, replace);
|
||||
// if (replace) return ret;
|
||||
|
||||
// return stick_y;
|
||||
|
@ -161,6 +200,9 @@ pub fn training_mods() {
|
|||
handle_get_attack_air_kind,
|
||||
// Tech options
|
||||
handle_change_motion,
|
||||
// Directional AirDodge,
|
||||
get_stick_x,
|
||||
get_stick_y,
|
||||
);
|
||||
|
||||
// // Input recorder
|
||||
|
@ -168,6 +210,6 @@ pub fn training_mods() {
|
|||
// "_ZN3app8lua_bind31ControlModule__get_stick_x_implEPNS_26BattleObjectModuleAccessorE",
|
||||
// (u64)&ControlModule::get_stick_x_replace);
|
||||
// SaltySD_function_replace_sym(
|
||||
// "_ZN3app8lua_bind31ControlModule__get_stick_y_implEPNS_26BattleObjectModuleAccessorE",
|
||||
// (u64)&ControlModule::get_stick_y_replace);
|
||||
// "_ZN3app8lua_bind31ControlModule__get_attack_air_stick_x_implEPNS_26BattleObjectModuleAccessorE",
|
||||
// (u64)&ControlModule::get_attack_air_stick_x_replace);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue