mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-07-06 17:54:14 +00:00
DI Indicator Fix and Left/Right Directions (#207)
* Only change DI direction on the first frame of the animation * Add left/right DI directions * Add L/R airdodge direction Co-authored-by: asimon-1 <asimon1@protonmail.com>
This commit is contained in:
parent
6f218ead89
commit
5fa0ff135d
4 changed files with 32 additions and 14 deletions
src
|
@ -82,6 +82,8 @@ bitflags! {
|
||||||
const DOWN = 0x40;
|
const DOWN = 0x40;
|
||||||
const DOWN_OUT = 0x80;
|
const DOWN_OUT = 0x80;
|
||||||
const NEUTRAL = 0x100;
|
const NEUTRAL = 0x100;
|
||||||
|
const LEFT = 0x200;
|
||||||
|
const RIGHT = 0x400;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +107,8 @@ impl Direction {
|
||||||
Direction::DOWN_IN => 6,
|
Direction::DOWN_IN => 6,
|
||||||
Direction::DOWN => 7,
|
Direction::DOWN => 7,
|
||||||
Direction::DOWN_OUT => 8,
|
Direction::DOWN_OUT => 8,
|
||||||
|
Direction::LEFT => 5,
|
||||||
|
Direction::RIGHT => 1,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,6 +123,8 @@ impl Direction {
|
||||||
Direction::DOWN_IN => "Down and In",
|
Direction::DOWN_IN => "Down and In",
|
||||||
Direction::DOWN => "Down",
|
Direction::DOWN => "Down",
|
||||||
Direction::DOWN_OUT => "Down and Away",
|
Direction::DOWN_OUT => "Down and Away",
|
||||||
|
Direction::LEFT => "Left",
|
||||||
|
Direction::RIGHT => "Right",
|
||||||
_ => "",
|
_ => "",
|
||||||
}.to_string()
|
}.to_string()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::common::consts::*;
|
use crate::common::consts::*;
|
||||||
use crate::common::*;
|
use crate::common::*;
|
||||||
|
use crate::training::directional_influence::should_reverse_angle;
|
||||||
use core::f64::consts::PI;
|
use core::f64::consts::PI;
|
||||||
use smash::app::{self, lua_bind::*};
|
use smash::app::{self, lua_bind::*};
|
||||||
use smash::lib::lua_const::*;
|
use smash::lib::lua_const::*;
|
||||||
|
@ -30,16 +31,20 @@ unsafe fn get_angle(module_accessor: &mut app::BattleObjectModuleAccessor) -> Op
|
||||||
|
|
||||||
STICK_DIRECTION = MENU.air_dodge_dir.get_random();
|
STICK_DIRECTION = MENU.air_dodge_dir.get_random();
|
||||||
STICK_DIRECTION.into_angle().map(|angle| {
|
STICK_DIRECTION.into_angle().map(|angle| {
|
||||||
let launch_speed_x = KineticEnergy::get_speed_x(KineticModule::get_energy(
|
if !should_reverse_angle(&STICK_DIRECTION) {
|
||||||
module_accessor,
|
// Direction is LEFT/RIGHT, so don't perform any adjustment
|
||||||
*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
|
angle
|
||||||
|
} else {
|
||||||
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,9 @@ use smash::lib::lua_const::*;
|
||||||
use smash::lib::L2CValue;
|
use smash::lib::L2CValue;
|
||||||
use smash::lua2cpp::L2CFighterCommon;
|
use smash::lua2cpp::L2CFighterCommon;
|
||||||
|
|
||||||
|
static mut DI_CASE: Direction = Direction::empty();
|
||||||
|
|
||||||
|
|
||||||
#[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(
|
||||||
fighter: &mut L2CFighterCommon,
|
fighter: &mut L2CFighterCommon,
|
||||||
|
@ -29,11 +32,13 @@ unsafe fn mod_handle_di(fighter: &mut L2CFighterCommon, _arg1: L2CValue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Either left, right, or none
|
// Either left, right, or none
|
||||||
let angle_tuple = MENU.di_state
|
if MotionModule::frame(module_accessor) == 0.0 {
|
||||||
.get_random()
|
DI_CASE = MENU.di_state.get_random();
|
||||||
|
}
|
||||||
|
let angle_tuple = DI_CASE
|
||||||
.into_angle()
|
.into_angle()
|
||||||
.map_or((0.0, 0.0), |angle| {
|
.map_or((0.0, 0.0), |angle| {
|
||||||
let a = if should_reverse_angle() {
|
let a = if should_reverse_angle(&DI_CASE) {
|
||||||
PI - angle
|
PI - angle
|
||||||
} else {
|
} else {
|
||||||
angle
|
angle
|
||||||
|
@ -45,12 +50,14 @@ unsafe fn mod_handle_di(fighter: &mut L2CFighterCommon, _arg1: L2CValue) {
|
||||||
set_x_y(module_accessor, angle_tuple.0 as f32, angle_tuple.1 as f32);
|
set_x_y(module_accessor, angle_tuple.0 as f32, angle_tuple.1 as f32);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn should_reverse_angle() -> bool {
|
pub fn should_reverse_angle(direction: &Direction) -> bool {
|
||||||
|
|
||||||
let cpu_module_accessor = get_module_accessor(FighterId::CPU);
|
let cpu_module_accessor = get_module_accessor(FighterId::CPU);
|
||||||
let player_module_accessor = get_module_accessor(FighterId::Player);
|
let player_module_accessor = get_module_accessor(FighterId::Player);
|
||||||
unsafe {
|
unsafe {
|
||||||
PostureModule::pos_x(player_module_accessor)
|
PostureModule::pos_x(player_module_accessor)
|
||||||
> PostureModule::pos_x(cpu_module_accessor)
|
> PostureModule::pos_x(cpu_module_accessor)
|
||||||
|
&& ![Direction::LEFT, Direction::RIGHT].contains(&direction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ fn mod_sdi_direction(fighter: &mut L2CFighterCommon) -> Option<f64> {
|
||||||
}
|
}
|
||||||
|
|
||||||
DIRECTION.into_angle().map(|angle| {
|
DIRECTION.into_angle().map(|angle| {
|
||||||
if directional_influence::should_reverse_angle() {
|
if directional_influence::should_reverse_angle(&DIRECTION) {
|
||||||
PI - angle
|
PI - angle
|
||||||
} else {
|
} else {
|
||||||
angle
|
angle
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue