mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-03-14 02:16:10 +00:00
Add SDI Toggle (#139)
This commit is contained in:
parent
9b0ede64b9
commit
1835be9cfb
8 changed files with 144 additions and 2 deletions
|
@ -9,6 +9,7 @@ static struct TrainingModpackMenu
|
|||
{
|
||||
int HITBOX_VIS = true;
|
||||
Directions DI_STATE = Directions::None;
|
||||
Directions SDI_STATE = Directions::None;
|
||||
Directions LEFT_STICK = Directions::None;
|
||||
ActionFlags MASH_STATE = ActionFlags::None;
|
||||
ActionFlags FOLLOW_UP = ActionFlags::None;
|
||||
|
@ -406,6 +407,8 @@ tsl::elm::Element* GuiMain::createUI()
|
|||
|
||||
list->addItem(createBitFlagOption(&menu.DI_STATE, "Set DI", di_help));
|
||||
|
||||
list->addItem(createBitFlagOption(&menu.SDI_STATE, "Set SDI", ""));
|
||||
|
||||
list->addItem(createBitFlagOption(&menu.LEFT_STICK, "Left Stick", left_stick_help));
|
||||
|
||||
list->addItem(createBitFlagOption(&menu.OOS_OFFSET, "OOS Offset", oos_help));
|
||||
|
|
|
@ -283,6 +283,7 @@ impl BoolFlag {
|
|||
pub struct TrainingModpackMenu {
|
||||
pub hitbox_vis: HitboxVisualization,
|
||||
pub di_state: Direction,
|
||||
pub sdi_state: Direction,
|
||||
pub left_stick: Direction, // Currently only used for air dodge direction
|
||||
pub mash_state: Action,
|
||||
pub follow_up: Action,
|
||||
|
|
|
@ -8,6 +8,7 @@ use smash::lib::lua_const::*;
|
|||
pub static mut MENU_STRUCT: consts::TrainingModpackMenu = consts::TrainingModpackMenu {
|
||||
hitbox_vis: HitboxVisualization::On,
|
||||
di_state: Direction::empty(),
|
||||
sdi_state: Direction::empty(),
|
||||
left_stick: Direction::empty(),
|
||||
mash_state: Action::empty(),
|
||||
follow_up: Action::empty(),
|
||||
|
|
|
@ -21,6 +21,8 @@ fn nro_main(nro: &NroInfo<'_>) {
|
|||
skyline::install_hooks!(
|
||||
training::shield::handle_sub_guard_cont,
|
||||
training::directional_influence::handle_correct_damage_vector_common,
|
||||
training::sdi::process_hit_stop_delay,
|
||||
training::sdi::check_hit_stop_delay_command,
|
||||
training::tech::handle_change_status
|
||||
);
|
||||
}
|
||||
|
|
|
@ -37,14 +37,22 @@ unsafe fn mod_handle_di(fighter: &mut L2CFighterCommon, _arg1: L2CValue) {
|
|||
return;
|
||||
}
|
||||
|
||||
let player_module_accessor = get_module_accessor(FighterId::Player);
|
||||
if PostureModule::pos_x(player_module_accessor) > PostureModule::pos_x(module_accessor) {
|
||||
if should_reverse_angle() {
|
||||
angle = PI - angle;
|
||||
}
|
||||
|
||||
set_x_y(module_accessor, angle.cos() as f32, angle.sin() as f32);
|
||||
}
|
||||
|
||||
pub fn should_reverse_angle() -> bool {
|
||||
let cpu_module_accessor = get_module_accessor(FighterId::CPU);
|
||||
let player_module_accessor = get_module_accessor(FighterId::Player);
|
||||
unsafe {
|
||||
return PostureModule::pos_x(player_module_accessor)
|
||||
> PostureModule::pos_x(cpu_module_accessor);
|
||||
}
|
||||
}
|
||||
|
||||
fn set_x_y(module_accessor: &mut app::BattleObjectModuleAccessor, x: f32, y: f32) {
|
||||
unsafe {
|
||||
WorkModule::set_float(
|
||||
|
|
|
@ -4,6 +4,7 @@ use crate::training::character_specific;
|
|||
use crate::training::fast_fall;
|
||||
use crate::training::full_hop;
|
||||
use crate::training::shield;
|
||||
use crate::training::sdi;
|
||||
use smash::app::{self, lua_bind::*};
|
||||
use smash::lib::lua_const::*;
|
||||
|
||||
|
@ -179,6 +180,7 @@ pub fn buffer_menu_mash() -> Action {
|
|||
full_hop::roll_full_hop();
|
||||
fast_fall::roll_fast_fall();
|
||||
FALLING_AERIAL = MENU.falling_aerials.get_random().into_bool();
|
||||
sdi::roll_direction();
|
||||
|
||||
action
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ use smash::app::{self, lua_bind::*};
|
|||
use smash::lib::lua_const::*;
|
||||
|
||||
pub mod directional_influence;
|
||||
pub mod sdi;
|
||||
pub mod shield;
|
||||
pub mod tech;
|
||||
|
||||
|
|
124
src/training/sdi.rs
Normal file
124
src/training/sdi.rs
Normal file
|
@ -0,0 +1,124 @@
|
|||
use crate::common::consts::*;
|
||||
use crate::common::*;
|
||||
use crate::training::directional_influence;
|
||||
use core::f64::consts::PI;
|
||||
use smash::app::{self, lua_bind::*, sv_system};
|
||||
use smash::lib::L2CValue;
|
||||
use smash::lua2cpp::L2CFighterCommon;
|
||||
use smash::Vector2f;
|
||||
|
||||
static mut COUNTER: u32 = 0;
|
||||
|
||||
static mut DIRECTION: Direction = Direction::NEUTRAL;
|
||||
|
||||
pub fn roll_direction() {
|
||||
unsafe {
|
||||
DIRECTION = MENU.sdi_state.get_random();
|
||||
}
|
||||
}
|
||||
|
||||
#[skyline::hook(replace = smash::lua2cpp::L2CFighterCommon_FighterStatusUniqProcessDamage_hit_stop_delay)]
|
||||
pub unsafe fn process_hit_stop_delay(
|
||||
fighter: &mut L2CFighterCommon,
|
||||
arg1: L2CValue,
|
||||
hit_stop_delay_flick_mul: L2CValue,
|
||||
x: L2CValue,
|
||||
y: L2CValue,
|
||||
) -> L2CValue {
|
||||
|
||||
let res;
|
||||
|
||||
let new_x: L2CValue;
|
||||
let new_y: L2CValue;
|
||||
let vector = mod_sdi_direction(fighter);
|
||||
if vector.is_some() {
|
||||
new_x = vector.unwrap().x.into();
|
||||
new_y = vector.unwrap().y.into();
|
||||
}
|
||||
else {
|
||||
new_x = x;
|
||||
new_y = y;
|
||||
}
|
||||
|
||||
res = original!()(fighter, arg1, hit_stop_delay_flick_mul, new_x, new_y);
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
fn mod_sdi_direction(fighter: &mut L2CFighterCommon) -> Option<Vector2f> {
|
||||
unsafe {
|
||||
let module_accessor = sv_system::battle_object_module_accessor(fighter.lua_state_agent);
|
||||
|
||||
if !is_training_mode() {
|
||||
return None;
|
||||
}
|
||||
|
||||
if !is_operation_cpu(module_accessor) {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
let mut angle: f64;
|
||||
|
||||
unsafe {
|
||||
angle = DIRECTION.into_angle();
|
||||
}
|
||||
|
||||
if angle == ANGLE_NONE {
|
||||
return None;
|
||||
}
|
||||
|
||||
if directional_influence::should_reverse_angle() {
|
||||
angle = PI - angle;
|
||||
}
|
||||
|
||||
return Some(Vector2f {
|
||||
x: angle.cos() as f32,
|
||||
y: angle.sin() as f32,
|
||||
});
|
||||
}
|
||||
|
||||
#[skyline::hook(replace = FighterControlModuleImpl::check_hit_stop_delay_command)]
|
||||
pub unsafe fn check_hit_stop_delay_command(
|
||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||
arg1: Vector2f,
|
||||
) -> u64 {
|
||||
let ori = original!()(module_accessor, arg1);
|
||||
let res = mod_check_hit_stop_delay_command(module_accessor, arg1).unwrap_or_else(|| ori);
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
/**
|
||||
* Returning Some(1) here has the effect of enabling the call to process_hit_stop_delay()
|
||||
*/
|
||||
fn mod_check_hit_stop_delay_command(
|
||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||
_arg1: Vector2f,
|
||||
) -> Option<u64> {
|
||||
unsafe {
|
||||
if !is_training_mode() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
if !is_operation_cpu(module_accessor) {
|
||||
return None;
|
||||
}
|
||||
unsafe {
|
||||
if DIRECTION == Direction::empty() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
unsafe {
|
||||
COUNTER = (COUNTER + 1) % 4;
|
||||
}
|
||||
|
||||
unsafe {
|
||||
if COUNTER != 1 {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
return Some(1);
|
||||
}
|
Loading…
Add table
Reference in a new issue