1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2025-03-22 22:36:10 +00:00

Jump Toggles (#103)

* Code Formatting

* Cleanup

* Implement Tilts

* Update TrainingModpackOverlay

* Move is_shielding to Commong

* Fix Flash Shield

Fixed not dropping shield again

* Formatting

* Remove ToDos

* Use Generic OnOff Enum

* Add Falling Aerial Toggle

* Implement Full Hop Toggle

* Add Comments
This commit is contained in:
sidschingis 2020-06-28 22:41:51 +02:00 committed by GitHub
parent 186c6ddc2d
commit 5cb981c268
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 103 additions and 25 deletions

@ -1 +1 @@
Subproject commit ff248838a589e1d3316d1493e1cd16f89e1e1373 Subproject commit 60ae2fbb5260f074c4c1763d2b4cc0b6d1070744

View file

@ -257,17 +257,9 @@ impl From<i32> for Defensive {
} }
} }
/// Mash in neutral
#[repr(i32)] #[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
pub enum MashInNeutral { pub enum OnOff {
Off = 0,
On = 1,
}
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum FastFall {
Off = 0, Off = 0,
On = 1, On = 1,
} }
@ -284,8 +276,10 @@ pub struct TrainingModpackMenu {
pub shield_state: Shield, pub shield_state: Shield,
pub defensive_state: Defensive, pub defensive_state: Defensive,
pub oos_offset: i32, pub oos_offset: i32,
pub mash_in_neutral: MashInNeutral, pub mash_in_neutral: OnOff,
pub fast_fall: FastFall, pub fast_fall: OnOff,
pub falling_aerials: OnOff,
pub full_hop: OnOff,
} }
// Fighter Ids // Fighter Ids

View file

@ -15,8 +15,10 @@ pub static mut MENU_STRUCT: consts::TrainingModpackMenu = consts::TrainingModpac
shield_state: Shield::None, shield_state: Shield::None,
defensive_state: Defensive::Random, defensive_state: Defensive::Random,
oos_offset: 0, oos_offset: 0,
mash_in_neutral: MashInNeutral::Off, mash_in_neutral: OnOff::Off,
fast_fall: FastFall::Off, fast_fall: OnOff::Off,
falling_aerials: OnOff::Off,
full_hop: OnOff::Off,
}; };
pub static mut MENU: &'static mut consts::TrainingModpackMenu = unsafe { &mut MENU_STRUCT }; pub static mut MENU: &'static mut consts::TrainingModpackMenu = unsafe { &mut MENU_STRUCT };

View file

@ -1,4 +1,4 @@
use crate::common::consts::FastFall; use crate::common::consts::OnOff;
use crate::common::*; use crate::common::*;
use smash::app::{self, lua_bind::*}; use smash::app::{self, lua_bind::*};
use smash::lib::lua_const::*; use smash::lib::lua_const::*;
@ -17,7 +17,7 @@ pub unsafe fn get_command_flag_cat(
return; return;
} }
if MENU.fast_fall != FastFall::On { if MENU.fast_fall != OnOff::On {
return; return;
} }
@ -29,14 +29,12 @@ pub unsafe fn get_command_flag_cat(
return; return;
} }
let y_speed =
KineticModule::get_sum_speed_y(module_accessor, *FIGHTER_KINETIC_ENERGY_ID_GRAVITY);
// Need to be falling // Need to be falling
if y_speed >= 0.0 { if !is_falling(module_accessor) {
return; return;
} }
// Can't fastfall in hitstun // Can't fastfall in hitstun // tumble // meteor
if is_in_hitstun(module_accessor) { if is_in_hitstun(module_accessor) {
return; return;
} }
@ -56,6 +54,14 @@ pub unsafe fn get_command_flag_cat(
add_spark_effect(module_accessor); add_spark_effect(module_accessor);
} }
pub fn is_falling(module_accessor: &mut app::BattleObjectModuleAccessor)->bool {
unsafe {
let y_speed =
KineticModule::get_sum_speed_y(module_accessor, *FIGHTER_KINETIC_ENERGY_ID_GRAVITY);
y_speed < 0.0
}
}
unsafe fn add_spark_effect(module_accessor: &mut app::BattleObjectModuleAccessor) { unsafe fn add_spark_effect(module_accessor: &mut app::BattleObjectModuleAccessor) {
// Mock Spark effect // Mock Spark effect
let pos = Vector3f { let pos = Vector3f {

64
src/training/full_hop.rs Normal file
View file

@ -0,0 +1,64 @@
use crate::common::consts::*;
use crate::common::*;
use smash::app::{self, lua_bind::*};
use smash::lib::lua_const::*;
/**
* This is needed to have the CPU put up shield
*/
pub unsafe fn check_button_on(
module_accessor: &mut app::BattleObjectModuleAccessor,
button: i32,
) -> Option<bool> {
if should_return_none_in_check_button(module_accessor, button) {
return None;
}
Some(true)
}
/**
* This is needed to prevent dropping shield immediately
*/
pub unsafe fn check_button_off(
module_accessor: &mut app::BattleObjectModuleAccessor,
button: i32,
) -> Option<bool> {
if should_return_none_in_check_button(module_accessor, button) {
return None;
}
Some(false)
}
/**
* AKA should the cpu hold the jump button
*/
unsafe fn should_return_none_in_check_button(
module_accessor: &mut app::BattleObjectModuleAccessor,
button: i32,
) -> bool {
if !is_training_mode() {
return true;
}
if !is_operation_cpu(module_accessor) {
return true;
}
// We only care about the jump button
if ![*CONTROL_PAD_BUTTON_JUMP, *CONTROL_PAD_BUTTON_FLICK_JUMP].contains(&button) {
return true;
}
// Nothing to do if not toggled
if MENU.full_hop != OnOff::On{
return true;
}
// Only need to hold during jump squat
let status_kind = StatusModule::status_kind(module_accessor) as i32;
if status_kind != FIGHTER_STATUS_KIND_JUMP_SQUAT {
return true;
}
false
}

View file

@ -1,5 +1,6 @@
use crate::common::consts::*; use crate::common::consts::*;
use crate::common::*; use crate::common::*;
use crate::training::fast_fall;
use crate::training::shield; use crate::training::shield;
use smash::app::{self, lua_bind::*}; use smash::app::{self, lua_bind::*};
use smash::hash40; use smash::hash40;
@ -86,7 +87,7 @@ unsafe fn check_buffer(module_accessor: &mut app::BattleObjectModuleAccessor) {
return; return;
} }
if !is_in_hitstun(module_accessor) && MENU.mash_in_neutral != MashInNeutral::On { if !is_in_hitstun(module_accessor) && MENU.mash_in_neutral != OnOff::On {
return; return;
} }
@ -268,6 +269,12 @@ unsafe fn get_aerial_flag(
transition_flag = *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ATTACK_AIR; transition_flag = *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ATTACK_AIR;
} }
if MENU.falling_aerials == OnOff::On && !fast_fall::is_falling(module_accessor) {
// Keep Buffering until we are falling
buffer_action(Mash::Attack);
return flag;
}
let action_flag: i32; let action_flag: i32;
match attack { match attack {

View file

@ -11,6 +11,7 @@ pub mod tech;
pub mod combo; pub mod combo;
mod fast_fall; mod fast_fall;
mod frame_counter; mod frame_counter;
mod full_hop;
mod ledge; mod ledge;
mod left_stick; mod left_stick;
mod mash; mod mash;
@ -151,8 +152,10 @@ pub unsafe fn handle_check_button_on(
module_accessor: &mut app::BattleObjectModuleAccessor, module_accessor: &mut app::BattleObjectModuleAccessor,
button: i32, button: i32,
) -> bool { ) -> bool {
shield::check_button_on(module_accessor, button) shield::check_button_on(module_accessor, button).unwrap_or_else(|| {
.unwrap_or_else(|| original!()(module_accessor, button)) full_hop::check_button_on(module_accessor, button)
.unwrap_or_else(|| original!()(module_accessor, button))
})
} }
#[skyline::hook(replace = ControlModule::check_button_off)] #[skyline::hook(replace = ControlModule::check_button_off)]
@ -160,8 +163,10 @@ pub unsafe fn handle_check_button_off(
module_accessor: &mut app::BattleObjectModuleAccessor, module_accessor: &mut app::BattleObjectModuleAccessor,
button: i32, button: i32,
) -> bool { ) -> bool {
shield::check_button_off(module_accessor, button) shield::check_button_off(module_accessor, button).unwrap_or_else(|| {
.unwrap_or_else(|| original!()(module_accessor, button)) full_hop::check_button_off(module_accessor, button)
.unwrap_or_else(|| original!()(module_accessor, button))
})
} }
#[skyline::hook(replace = MotionModule::change_motion)] #[skyline::hook(replace = MotionModule::change_motion)]