mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2024-11-28 04:44:06 +00:00
Extract Shared Condition
This commit is contained in:
parent
be16194528
commit
ce865a70f2
1 changed files with 28 additions and 37 deletions
|
@ -10,66 +10,57 @@ 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);
|
||||
let angle: f64 = get_angle(module_accessor);
|
||||
|
||||
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);
|
||||
let angle: f64 = get_angle(module_accessor);
|
||||
|
||||
if angle == ANGLE_NONE {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(angle.sin() as f32)
|
||||
}
|
||||
|
||||
unsafe fn get_angle(module_accessor: &mut app::BattleObjectModuleAccessor) -> f64 {
|
||||
if !is_training_mode() {
|
||||
return ANGLE_NONE;
|
||||
}
|
||||
|
||||
if !is_operation_cpu(module_accessor) {
|
||||
return ANGLE_NONE;
|
||||
}
|
||||
|
||||
// Currently used for air dodge//Drift only
|
||||
if !(is_airborne(module_accessor) && is_in_hitstun(module_accessor)) {
|
||||
return ANGLE_NONE;
|
||||
}
|
||||
|
||||
STICK_DIRECTION = MENU.di_state;
|
||||
let mut angle: f64 = pick_angle(STICK_DIRECTION);
|
||||
|
||||
if angle == ANGLE_NONE {
|
||||
return ANGLE_NONE;
|
||||
}
|
||||
|
||||
// If facing left, reverse angle
|
||||
if PostureModule::lr(module_accessor) != FIGHTER_FACING_RIGHT {
|
||||
angle -= PI;
|
||||
}
|
||||
|
||||
Some(angle.sin() as f32)
|
||||
angle
|
||||
}
|
||||
|
||||
unsafe fn get_angle(direction: Direction) -> f64 {
|
||||
unsafe fn pick_angle(direction: Direction) -> f64 {
|
||||
if direction == Direction::Random {
|
||||
let rand_direction = get_random_direction();
|
||||
return direction_to_angle(rand_direction);
|
||||
|
|
Loading…
Reference in a new issue