mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-03-22 22:36:10 +00:00
Reuse Angle Calculation
get_random now returns a random direction instead of the angle directly
This commit is contained in:
parent
cca5072185
commit
2fc1c75ab6
1 changed files with 17 additions and 11 deletions
|
@ -33,12 +33,7 @@ unsafe fn mod_handle_di(fighter: &mut L2CFighterCommon, _arg1: L2CValue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Either left, right, or none
|
// Either left, right, or none
|
||||||
if MENU.di_state == Direction::Random {
|
DI_ANGLE = get_angle(MENU.di_state);
|
||||||
DI_ANGLE = get_random_di();
|
|
||||||
} else {
|
|
||||||
DI_ANGLE = direction_to_angle(MENU.di_state)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Nothig to do on no DI
|
// Nothig to do on no DI
|
||||||
if DI_ANGLE == ANGLE_NONE {
|
if DI_ANGLE == ANGLE_NONE {
|
||||||
return;
|
return;
|
||||||
|
@ -61,12 +56,23 @@ unsafe fn mod_handle_di(fighter: &mut L2CFighterCommon, _arg1: L2CValue) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn get_random_di() -> f64 {
|
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 {
|
||||||
|
// Choose Left/Right/None
|
||||||
let rand = app::sv_math::rand(hash40("fighter"), 3);
|
let rand = app::sv_math::rand(hash40("fighter"), 3);
|
||||||
if [0, 1].contains(&rand) {
|
if rand == 0 {
|
||||||
// Either 0 (right) or PI (left)
|
Direction::Left
|
||||||
rand as f64 * PI
|
} else if rand == 1 {
|
||||||
|
Direction::Right
|
||||||
} else {
|
} else {
|
||||||
ANGLE_NONE
|
Direction::None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue