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

Implement Longer Ledge Delays (#211)

* Add workflow_dispatch

* Add LongDelay bitflag type for ledge delays, and change into_index() calls to into_delay/into_longdelay

* Override default ledge climb

Co-authored-by: asimon-1 <asimon1@protonmail.com>
This commit is contained in:
asimon-1 2021-07-20 07:17:56 -07:00 committed by GitHub
parent bbbf2ac898
commit 3973ff6d65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 79 additions and 15 deletions

View file

@ -405,10 +405,63 @@ impl Delay {
// TODO: add
return self.to_string()
}
pub fn into_delay(&self) -> u32 {
return self.to_index()
}
}
extra_bitflag_impls! {Delay}
bitflags! {
pub struct LongDelay : u32 {
const D0 = 0x1;
const D10 = 0x2;
const D20 = 0x4;
const D30 = 0x8;
const D40 = 0x10;
const D50 = 0x20;
const D60 = 0x40;
const D70 = 0x80;
const D80 = 0x100;
const D90 = 0x200;
const D100 = 0x400;
const D110 = 0x800;
const D120 = 0x1000;
const D130 = 0x2000;
const D140 = 0x4000;
const D150 = 0x8000;
const D160 = 0x10000;
const D170 = 0x20000;
const D180 = 0x40000;
const D190 = 0x80000;
const D200 = 0x0010_0000;
const D210 = 0x0020_0000;
const D220 = 0x0040_0000;
const D230 = 0x0080_0000;
const D240 = 0x0100_0000;
const D250 = 0x0200_0000;
const D260 = 0x0400_0000;
const D270 = 0x0800_0000;
const D280 = 0x1000_0000;
const D290 = 0x2000_0000;
const D300 = 0x4000_0000;
}
}
impl LongDelay {
pub fn into_string(self) -> String {
// TODO: Is this used for the menu?
return self.to_string()
}
pub fn into_longdelay(&self) -> u32 {
return self.to_index() * 10
}
}
extra_bitflag_impls! {LongDelay}
bitflags! {
pub struct BoolFlag : u32 {
const TRUE = 0x1;
@ -473,7 +526,7 @@ pub struct TrainingModpackMenu {
pub follow_up: Action,
pub attack_angle: AttackAngle,
pub ledge_state: LedgeOption,
pub ledge_delay: Delay,
pub ledge_delay: LongDelay,
pub tech_state: TechFlags,
pub miss_tech_state: MissTechFlags,
pub shield_state: Shield,
@ -513,7 +566,7 @@ impl TrainingModpackMenu {
(follow_up = Action::from_bits(val))
(ledge_state = LedgeOption::from_bits(val))
(ledge_delay = Delay::from_bits(val))
(ledge_delay = LongDelay::from_bits(val))
(tech_state = TechFlags::from_bits(val))
(miss_tech_state = MissTechFlags::from_bits(val))

View file

@ -190,7 +190,7 @@ pub unsafe fn render_menu() -> String {
add_bitflag_submenu!(overall_menu, "Attack Angle", attack_angle, AttackAngle);
add_bitflag_submenu!(overall_menu, "Ledge Options", ledge_state, LedgeOption);
add_bitflag_submenu!(overall_menu, "Ledge Delay", ledge_delay, Delay);
add_bitflag_submenu!(overall_menu, "Ledge Delay", ledge_delay, LongDelay);
add_bitflag_submenu!(overall_menu, "Tech Options", tech_state, TechFlags);
add_bitflag_submenu!(overall_menu, "Miss Tech Options", miss_tech_state, MissTechFlags);
add_bitflag_submenu!(overall_menu, "Defensive Options", defensive_state, Defensive);

View file

@ -17,7 +17,7 @@ pub static mut MENU: consts::TrainingModpackMenu = consts::TrainingModpackMenu {
follow_up: Action::empty(),
attack_angle: AttackAngle::empty(),
ledge_state: LedgeOption::all(),
ledge_delay: Delay::empty(),
ledge_delay: LongDelay::empty(),
tech_state: TechFlags::all(),
miss_tech_state: MissTechFlags::all(),
shield_state: Shield::None,

View file

@ -46,7 +46,7 @@ pub fn get_command_flag_cat(module_accessor: &mut app::BattleObjectModuleAccesso
unsafe {
if !is_falling(module_accessor) {
// Roll FF delay
DELAY = MENU.fast_fall_delay.get_random().to_index();
DELAY = MENU.fast_fall_delay.get_random().into_delay();
frame_counter::full_reset(FRAME_COUNTER);
return;
}

View file

@ -18,13 +18,17 @@ pub fn init() {
pub fn reset_ledge_delay() {
unsafe {
LEDGE_DELAY = NOT_SET;
if LEDGE_DELAY != NOT_SET {
LEDGE_DELAY = NOT_SET;
frame_counter::full_reset(LEDGE_DELAY_COUNTER);
}
}
}
pub fn reset_ledge_case() {
unsafe {
if LEDGE_CASE != LedgeOption::empty() {
// Don't roll another ledge option if one is already selected
LEDGE_CASE = LedgeOption::empty();
}
}
@ -33,10 +37,11 @@ pub fn reset_ledge_case() {
fn roll_ledge_delay() {
unsafe {
if LEDGE_DELAY != NOT_SET {
// Don't roll another ledge delay if one is already selected
return;
}
LEDGE_DELAY = MENU.ledge_delay.get_random().to_index();
LEDGE_DELAY = MENU.ledge_delay.get_random().into_longdelay();
}
}
@ -54,7 +59,9 @@ fn roll_ledge_case() {
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
// No longer on ledge, so re-roll the ledge case and reset the delay counter for next time
reset_ledge_case();
reset_ledge_delay();
return;
}
@ -75,11 +82,10 @@ pub unsafe fn force_option(module_accessor: &mut app::BattleObjectModuleAccessor
}
if frame_counter::should_delay(LEDGE_DELAY, LEDGE_DELAY_COUNTER) {
// Not yet time to perform the ledge action
return;
}
reset_ledge_delay();
let status = LEDGE_CASE.into_status().unwrap_or(0);
match LEDGE_CASE {
LedgeOption::JUMP => {
@ -95,8 +101,13 @@ 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 {
// Only handle ledge scenarios from menu
if StatusModule::status_kind(_module_accessor) as i32 != *FIGHTER_STATUS_KIND_CLIFF_WAIT || MENU.ledge_state == LedgeOption::empty() {
return None;
}
// Disallow the default cliff-climb if we are waiting
if LEDGE_CASE == LedgeOption::WAIT || frame_counter::get_frame_count(LEDGE_DELAY_COUNTER) < LEDGE_DELAY {
if term == *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_CLIFF_CLIMB {
return Some(false);
}

View file

@ -413,7 +413,7 @@ fn roll_aerial_delay(action: Action) {
return;
}
unsafe {
AERIAL_DELAY = MENU.aerial_delay.get_random().to_index();
AERIAL_DELAY = MENU.aerial_delay.get_random().into_delay();
}
}

View file

@ -49,7 +49,7 @@ fn reset_oos_offset() {
* Need to offset by 1, since we decrease as soon as shield gets hit
* but only check later if we can OOS
*/
MULTI_HIT_OFFSET = MENU.oos_offset.get_random().to_index() + 1;
MULTI_HIT_OFFSET = MENU.oos_offset.get_random().into_delay() + 1;
}
}
@ -67,7 +67,7 @@ unsafe fn handle_oos_offset(module_accessor: &mut app::BattleObjectModuleAccesso
}
// Roll shield delay
SHIELD_DELAY = MENU.reaction_time.get_random().to_index();
SHIELD_DELAY = MENU.reaction_time.get_random().into_delay();
// Decrease offset once if needed
if MULTI_HIT_OFFSET > 0 {