1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-24 10:54:16 +00:00

Move Angle Calculation To Common

Renamed NO_DI to ANGLE_NONE and moved to common
This commit is contained in:
sidschingis 2020-06-13 21:34:06 +02:00
parent 18290df236
commit 715c28dd6c
2 changed files with 19 additions and 7 deletions

View file

@ -1,3 +1,4 @@
use core::f64::consts::PI;
use smash::lib::lua_const::*;
/// Hitbox Visualization
@ -19,7 +20,7 @@ pub enum HitboxVisualization {
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Direction {
None = 0,
Right =1,
Right = 1,
UpRight = 2,
Up = 3,
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
#[repr(i32)]
#[derive(PartialEq, Debug, Copy, Clone)]
@ -254,5 +267,5 @@ pub struct TrainingModpackMenu {
pub shield_state: Shield,
pub defensive_state: Defensive,
pub oos_offset: i32,
pub mash_in_neutral: MashInNeutral
pub mash_in_neutral: MashInNeutral,
}

View file

@ -8,7 +8,6 @@ use smash::lib::L2CValue;
use smash::lua2cpp::L2CFighterCommon;
pub static mut DI_ANGLE: f64 = 0.0;
pub static NO_DI: f64 = -69.0;
#[skyline::hook(replace = smash::lua2cpp::L2CFighterCommon_FighterStatusDamage__correctDamageVectorCommon)]
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 {
DI_ANGLE = get_random_di();
} 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 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;
}
// Nothig to do on no DI
if DI_ANGLE == NO_DI {
if DI_ANGLE == ANGLE_NONE {
return;
}
@ -68,6 +67,6 @@ unsafe fn get_random_di() -> f64 {
// Either 0 (right) or PI (left)
rand as f64 * PI
} else {
NO_DI
ANGLE_NONE
}
}