mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-03-16 11:26:11 +00:00
refactor ANGLE_NONE
This commit is contained in:
parent
67dec0402d
commit
e62d602895
6 changed files with 51 additions and 91 deletions
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
|
@ -5,7 +5,10 @@
|
|||
"clippy",
|
||||
"--workspace",
|
||||
"--message-format=json",
|
||||
"--all-features"
|
||||
"--all-features",
|
||||
"--",
|
||||
"-A",
|
||||
"clippy::borrow_interior_mutable_const"
|
||||
],
|
||||
"rust-analyzer.updates.channel": "nightly",
|
||||
}
|
|
@ -91,14 +91,14 @@ bitflags! {
|
|||
}
|
||||
|
||||
impl Direction {
|
||||
pub fn into_angle(self) -> f64 {
|
||||
pub fn into_angle(self) -> Option<f64> {
|
||||
let index = self.into_index();
|
||||
|
||||
if index == 0 {
|
||||
return ANGLE_NONE;
|
||||
return None;
|
||||
}
|
||||
|
||||
(index as i32 - 1) as f64 * PI / 4.0
|
||||
Some((index as i32 - 1) as f64 * PI / 4.0)
|
||||
}
|
||||
fn into_index(self) -> i32 {
|
||||
match self {
|
||||
|
@ -117,8 +117,6 @@ impl Direction {
|
|||
get_random_impl! {Direction}
|
||||
}
|
||||
|
||||
pub static ANGLE_NONE: f64 = -69.0;
|
||||
|
||||
// Ledge Option
|
||||
bitflags! {
|
||||
pub struct LedgeOption : u32
|
||||
|
|
|
@ -9,63 +9,41 @@ static mut STICK_DIRECTION: Direction = Direction::empty();
|
|||
pub unsafe fn mod_get_stick_x(
|
||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||
) -> Option<f32> {
|
||||
let angle: f64 = get_angle(module_accessor);
|
||||
|
||||
if angle == ANGLE_NONE {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(angle.cos() as f32)
|
||||
get_angle(module_accessor).map(|a| a.cos() as f32)
|
||||
}
|
||||
|
||||
pub unsafe fn mod_get_stick_y(
|
||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||
) -> Option<f32> {
|
||||
let angle: f64 = get_angle(module_accessor);
|
||||
|
||||
if angle == ANGLE_NONE {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(angle.sin() as f32)
|
||||
get_angle(module_accessor).map(|a| a.sin() as f32)
|
||||
}
|
||||
|
||||
unsafe fn get_angle(module_accessor: &mut app::BattleObjectModuleAccessor) -> f64 {
|
||||
unsafe fn get_angle(module_accessor: &mut app::BattleObjectModuleAccessor) -> Option<f64> {
|
||||
if !is_operation_cpu(module_accessor) {
|
||||
return ANGLE_NONE;
|
||||
return None;
|
||||
}
|
||||
|
||||
// Currently used for air dodge//Drift only
|
||||
if !is_correct_status(module_accessor) {
|
||||
return ANGLE_NONE;
|
||||
return None;
|
||||
}
|
||||
|
||||
STICK_DIRECTION = MENU.air_dodge_dir.get_random();
|
||||
let mut angle: f64 = STICK_DIRECTION.into_angle();
|
||||
|
||||
if angle == ANGLE_NONE {
|
||||
return ANGLE_NONE;
|
||||
}
|
||||
|
||||
let launch_speed_x = KineticEnergy::get_speed_x(KineticModule::get_energy(
|
||||
module_accessor,
|
||||
*FIGHTER_KINETIC_ENERGY_ID_DAMAGE,
|
||||
) as *mut smash::app::KineticEnergy);
|
||||
|
||||
// If we're launched left, reverse stick X
|
||||
if launch_speed_x < 0.0 {
|
||||
angle = PI - angle;
|
||||
}
|
||||
|
||||
angle
|
||||
STICK_DIRECTION.into_angle().map(|angle| {
|
||||
let launch_speed_x = KineticEnergy::get_speed_x(KineticModule::get_energy(
|
||||
module_accessor,
|
||||
*FIGHTER_KINETIC_ENERGY_ID_DAMAGE,
|
||||
) as *mut smash::app::KineticEnergy);
|
||||
|
||||
// If we're launched left, reverse stick X
|
||||
if launch_speed_x < 0.0 {
|
||||
PI - angle
|
||||
} else {
|
||||
angle
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn is_correct_status(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
|
||||
let air_dodge_condition= is_airborne(module_accessor) && is_in_hitstun(module_accessor);
|
||||
|
||||
if air_dodge_condition {
|
||||
return true;
|
||||
}
|
||||
|
||||
false
|
||||
is_airborne(module_accessor) && is_in_hitstun(module_accessor)
|
||||
}
|
|
@ -29,18 +29,20 @@ unsafe fn mod_handle_di(fighter: &mut L2CFighterCommon, _arg1: L2CValue) {
|
|||
}
|
||||
|
||||
// Either left, right, or none
|
||||
let mut angle = MENU.di_state.get_random().into_angle();
|
||||
// Nothing to do on no DI
|
||||
if angle == ANGLE_NONE {
|
||||
set_x_y(module_accessor, 0.0, 0.0);
|
||||
return;
|
||||
}
|
||||
let angle_tuple = MENU.di_state
|
||||
.get_random()
|
||||
.into_angle()
|
||||
.map_or((0.0, 0.0), |angle| {
|
||||
let a = if should_reverse_angle() {
|
||||
PI - angle
|
||||
} else {
|
||||
angle
|
||||
};
|
||||
|
||||
if should_reverse_angle() {
|
||||
angle = PI - angle;
|
||||
}
|
||||
(a.cos(), a.sin())
|
||||
});
|
||||
|
||||
set_x_y(module_accessor, angle.cos() as f32, angle.sin() as f32);
|
||||
set_x_y(module_accessor, angle_tuple.0 as f32, angle_tuple.1 as f32);
|
||||
}
|
||||
|
||||
pub fn should_reverse_angle() -> bool {
|
||||
|
|
|
@ -48,22 +48,15 @@ fn mod_sdi_direction(fighter: &mut L2CFighterCommon) -> Option<f64> {
|
|||
if !is_operation_cpu(module_accessor) {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
let mut angle: f64;
|
||||
|
||||
unsafe {
|
||||
angle = DIRECTION.into_angle();
|
||||
DIRECTION.into_angle().map(|angle| {
|
||||
if directional_influence::should_reverse_angle() {
|
||||
PI - angle
|
||||
} else {
|
||||
angle
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if angle == ANGLE_NONE {
|
||||
return None;
|
||||
}
|
||||
|
||||
if directional_influence::should_reverse_angle() {
|
||||
angle = PI - angle;
|
||||
}
|
||||
|
||||
Some(angle)
|
||||
}
|
||||
|
||||
#[skyline::hook(replace = FighterControlModuleImpl::check_hit_stop_delay_command)]
|
||||
|
|
|
@ -13,33 +13,19 @@ pub fn roll_direction() {
|
|||
pub unsafe fn mod_get_stick_x(
|
||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||
) -> Option<f32> {
|
||||
let angle: f64 = get_angle(module_accessor);
|
||||
|
||||
if angle == ANGLE_NONE {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(angle.cos() as f32)
|
||||
get_angle(module_accessor).map(|a| a.cos() as f32)
|
||||
}
|
||||
|
||||
pub unsafe fn mod_get_stick_y(
|
||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||
) -> Option<f32> {
|
||||
let angle: f64 = get_angle(module_accessor);
|
||||
get_angle(module_accessor).map(|a| a.sin() as f32)
|
||||
}
|
||||
|
||||
if angle == ANGLE_NONE {
|
||||
unsafe fn get_angle(module_accessor: &mut app::BattleObjectModuleAccessor) -> Option<f64> {
|
||||
if !is_operation_cpu(module_accessor) {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(angle.sin() as f32)
|
||||
}
|
||||
|
||||
unsafe fn get_angle(module_accessor: &mut app::BattleObjectModuleAccessor) -> f64 {
|
||||
if !is_operation_cpu(module_accessor) {
|
||||
return ANGLE_NONE;
|
||||
}
|
||||
|
||||
let angle: f64 = STICK_DIRECTION.into_angle();
|
||||
|
||||
angle
|
||||
STICK_DIRECTION.into_angle()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue