mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2024-11-20 08:54:15 +00:00
Move Angle Calculation To Common
Renamed NO_DI to ANGLE_NONE and moved to common
This commit is contained in:
parent
18290df236
commit
715c28dd6c
2 changed files with 19 additions and 7 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
use core::f64::consts::PI;
|
||||||
use smash::lib::lua_const::*;
|
use smash::lib::lua_const::*;
|
||||||
|
|
||||||
/// Hitbox Visualization
|
/// Hitbox Visualization
|
||||||
|
@ -19,7 +20,7 @@ pub enum HitboxVisualization {
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub enum Direction {
|
pub enum Direction {
|
||||||
None = 0,
|
None = 0,
|
||||||
Right =1,
|
Right = 1,
|
||||||
UpRight = 2,
|
UpRight = 2,
|
||||||
Up = 3,
|
Up = 3,
|
||||||
UpLeft = 4,
|
UpLeft = 4,
|
||||||
|
@ -49,6 +50,18 @@ impl From<i32> for Direction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//pub static FIGHTER_FACING_LEFT: f32 = 1.0;
|
||||||
|
pub static FIGHTER_FACING_RIGHT: f32 = -1.0;
|
||||||
|
pub static ANGLE_NONE: f64 = -69.0;
|
||||||
|
pub fn direction_to_angle(direction: Direction) -> f64 {
|
||||||
|
match direction {
|
||||||
|
Direction::None => ANGLE_NONE,
|
||||||
|
Direction::Random => ANGLE_NONE, // Random Direction should be handled by the calling context
|
||||||
|
_ => (direction as i32 - 1) as f64 * PI / 4.0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Mash Attack States
|
/// Mash Attack States
|
||||||
#[repr(i32)]
|
#[repr(i32)]
|
||||||
#[derive(PartialEq, Debug, Copy, Clone)]
|
#[derive(PartialEq, Debug, Copy, Clone)]
|
||||||
|
@ -254,5 +267,5 @@ pub struct TrainingModpackMenu {
|
||||||
pub shield_state: Shield,
|
pub shield_state: Shield,
|
||||||
pub defensive_state: Defensive,
|
pub defensive_state: Defensive,
|
||||||
pub oos_offset: i32,
|
pub oos_offset: i32,
|
||||||
pub mash_in_neutral: MashInNeutral
|
pub mash_in_neutral: MashInNeutral,
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ use smash::lib::L2CValue;
|
||||||
use smash::lua2cpp::L2CFighterCommon;
|
use smash::lua2cpp::L2CFighterCommon;
|
||||||
|
|
||||||
pub static mut DI_ANGLE: f64 = 0.0;
|
pub static mut DI_ANGLE: f64 = 0.0;
|
||||||
pub static NO_DI: f64 = -69.0;
|
|
||||||
|
|
||||||
#[skyline::hook(replace = smash::lua2cpp::L2CFighterCommon_FighterStatusDamage__correctDamageVectorCommon)]
|
#[skyline::hook(replace = smash::lua2cpp::L2CFighterCommon_FighterStatusDamage__correctDamageVectorCommon)]
|
||||||
pub unsafe fn handle_correct_damage_vector_common(
|
pub unsafe fn handle_correct_damage_vector_common(
|
||||||
|
@ -37,16 +36,16 @@ unsafe fn mod_handle_di(fighter: &mut L2CFighterCommon, _arg1: L2CValue) {
|
||||||
if MENU.di_state == Direction::Random {
|
if MENU.di_state == Direction::Random {
|
||||||
DI_ANGLE = get_random_di();
|
DI_ANGLE = get_random_di();
|
||||||
} else {
|
} else {
|
||||||
DI_ANGLE = (MENU.di_state as i32 - 1) as f64 * PI / 4.0;
|
DI_ANGLE = direction_to_angle(MENU.di_state)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If facing left, reverse angle
|
// If facing left, reverse angle
|
||||||
if DI_ANGLE != NO_DI && PostureModule::lr(module_accessor) != -1.0 {
|
if DI_ANGLE != ANGLE_NONE && PostureModule::lr(module_accessor) != FIGHTER_FACING_RIGHT {
|
||||||
DI_ANGLE -= PI;
|
DI_ANGLE -= PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothig to do on no DI
|
// Nothig to do on no DI
|
||||||
if DI_ANGLE == NO_DI {
|
if DI_ANGLE == ANGLE_NONE {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +67,6 @@ unsafe fn get_random_di() -> f64 {
|
||||||
// Either 0 (right) or PI (left)
|
// Either 0 (right) or PI (left)
|
||||||
rand as f64 * PI
|
rand as f64 * PI
|
||||||
} else {
|
} else {
|
||||||
NO_DI
|
ANGLE_NONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue