mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2024-11-20 00:46:34 +00:00
Ledge hang (#180)
* Initial work on ledge hang * Change ledge hang logic from a delay to a persistent selected option * Disallow ledge-climb if WAIT is picked * Move is_enable_transition_term hook from lib.rs into existing mod.rs hook Co-authored-by: Andrew Simon <asimon@domeng.com>
This commit is contained in:
parent
ebc046db1d
commit
509f2383ac
5 changed files with 59 additions and 13 deletions
|
@ -87,7 +87,9 @@ position).
|
|||
x(type,Neutral,"Neutral") \
|
||||
x(type,Roll,"Roll") \
|
||||
x(type,Jump,"Jump") \
|
||||
x(type,Attack,"Attack")
|
||||
x(type,Attack,"Attack") \
|
||||
x(type,Wait,"Wait")
|
||||
|
||||
|
||||
// clang-format on
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@ bitflags! {
|
|||
const ROLL = 0x2;
|
||||
const JUMP = 0x4;
|
||||
const ATTACK = 0x8;
|
||||
const WAIT = 0x10;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,6 +121,7 @@ impl LedgeOption {
|
|||
LedgeOption::ROLL => *FIGHTER_STATUS_KIND_CLIFF_ESCAPE,
|
||||
LedgeOption::JUMP => *FIGHTER_STATUS_KIND_CLIFF_JUMP1,
|
||||
LedgeOption::ATTACK => *FIGHTER_STATUS_KIND_CLIFF_ATTACK,
|
||||
LedgeOption::WAIT => *FIGHTER_STATUS_KIND_CLIFF_WAIT,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ fn nro_main(nro: &NroInfo<'_>) {
|
|||
training::shield::handle_sub_guard_cont,
|
||||
training::directional_influence::handle_correct_damage_vector_common,
|
||||
training::sdi::process_hit_stop_delay,
|
||||
training::tech::handle_change_status
|
||||
training::tech::handle_change_status,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use smash::lib::lua_const::*;
|
|||
const NOT_SET: u32 = 9001;
|
||||
static mut LEDGE_DELAY: u32 = NOT_SET;
|
||||
static mut LEDGE_DELAY_COUNTER: usize = 0;
|
||||
static mut LEDGE_CASE: LedgeOption = LedgeOption::empty();
|
||||
|
||||
pub fn init() {
|
||||
unsafe {
|
||||
|
@ -21,6 +22,14 @@ pub fn reset_ledge_delay() {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn reset_ledge_case() {
|
||||
unsafe {
|
||||
if LEDGE_CASE != LedgeOption::empty() {
|
||||
LEDGE_CASE = LedgeOption::empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn roll_ledge_delay() {
|
||||
unsafe {
|
||||
if LEDGE_DELAY != NOT_SET {
|
||||
|
@ -31,17 +40,37 @@ fn roll_ledge_delay() {
|
|||
}
|
||||
}
|
||||
|
||||
fn roll_ledge_case() {
|
||||
unsafe {
|
||||
// Don't re-roll if there is already a ledge option selected
|
||||
// This prevents choosing a different ledge option during LedgeOption::WAIT
|
||||
if LEDGE_CASE != LedgeOption::empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
LEDGE_CASE = MENU.ledge_state.get_random();
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn force_option(module_accessor: &mut app::BattleObjectModuleAccessor) {
|
||||
if StatusModule::status_kind(module_accessor) as i32 != *FIGHTER_STATUS_KIND_CLIFF_WAIT {
|
||||
reset_ledge_case(); // No longer on ledge, so re-roll the ledge case next time
|
||||
return;
|
||||
}
|
||||
|
||||
if !WorkModule::is_enable_transition_term(
|
||||
module_accessor,
|
||||
*FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_CLIFF_ATTACK,
|
||||
) {
|
||||
// Not able to take any action yet
|
||||
return;
|
||||
}
|
||||
|
||||
roll_ledge_delay();
|
||||
roll_ledge_case();
|
||||
|
||||
if !WorkModule::is_enable_transition_term(
|
||||
module_accessor,
|
||||
*FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_CLIFF_CLIMB,
|
||||
) {
|
||||
if LEDGE_CASE == LedgeOption::WAIT {
|
||||
// Do nothing, but don't reset the ledge case.
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -51,10 +80,8 @@ pub unsafe fn force_option(module_accessor: &mut app::BattleObjectModuleAccessor
|
|||
|
||||
reset_ledge_delay();
|
||||
|
||||
let ledge_case: LedgeOption = MENU.ledge_state.get_random();
|
||||
let status = ledge_case.into_status().unwrap_or(0);
|
||||
|
||||
match ledge_case {
|
||||
let status = LEDGE_CASE.into_status().unwrap_or(0);
|
||||
match LEDGE_CASE {
|
||||
LedgeOption::JUMP => {
|
||||
mash::buffer_menu_mash();
|
||||
}
|
||||
|
@ -64,6 +91,19 @@ pub unsafe fn force_option(module_accessor: &mut app::BattleObjectModuleAccessor
|
|||
StatusModule::change_status_request_from_script(module_accessor, status, true);
|
||||
}
|
||||
|
||||
pub unsafe fn is_enable_transition_term(
|
||||
module_accessor: *mut app::BattleObjectModuleAccessor,
|
||||
term: i32,
|
||||
) -> Option<bool> {
|
||||
// Disallow cliff-climb if waiting on ledge per the current menu selection
|
||||
if LEDGE_CASE == LedgeOption::WAIT {
|
||||
if term == *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_CLIFF_CLIMB {
|
||||
return Some(false);
|
||||
}
|
||||
}
|
||||
return None
|
||||
}
|
||||
|
||||
pub fn get_command_flag_cat(module_accessor: &mut app::BattleObjectModuleAccessor) {
|
||||
if !is_operation_cpu(module_accessor) {
|
||||
return;
|
||||
|
|
|
@ -11,6 +11,7 @@ pub mod directional_influence;
|
|||
pub mod sdi;
|
||||
pub mod shield;
|
||||
pub mod tech;
|
||||
pub mod ledge;
|
||||
|
||||
mod air_dodge_direction;
|
||||
mod attack_angle;
|
||||
|
@ -20,7 +21,6 @@ mod frame_counter;
|
|||
mod full_hop;
|
||||
mod input_delay;
|
||||
mod input_record;
|
||||
mod ledge;
|
||||
mod mash;
|
||||
mod reset;
|
||||
mod save_states;
|
||||
|
@ -255,8 +255,10 @@ pub unsafe fn handle_is_enable_transition_term(
|
|||
}
|
||||
|
||||
combo::is_enable_transition_term(module_accessor, transition_term, ori);
|
||||
|
||||
ori
|
||||
match ledge::is_enable_transition_term(module_accessor, transition_term) {
|
||||
Some(r) => r,
|
||||
None => ori,
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
Loading…
Reference in a new issue