Skip to content

Commit d7a5c96

Browse files
committed
allow consecutive buffered rolls with one c-stick press
1 parent adc4ecd commit d7a5c96

File tree

4 files changed

+69
-23
lines changed

4 files changed

+69
-23
lines changed

fighters/common/src/general_statuses/catch/mod.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,24 @@ mod catchcut;
33
mod catchdash;
44
mod catchattack;
55

6+
#[skyline::hook(replace = L2CFighterCommon_sub_transition_group_check_ground_catch)]
7+
unsafe fn sub_transition_group_check_ground_catch(fighter: &mut L2CFighterCommon) -> L2CValue {
8+
// prevents c-stick grabs, making c-stick roll feel smooth
9+
if super::shield::misc::check_cstick_escape_oos(fighter).get_bool() {
10+
return false.into();
11+
}
12+
call_original!(fighter)
13+
}
14+
15+
fn nro_hook(info: &skyline::nro::NroInfo) {
16+
if info.name == "common" {
17+
skyline::install_hooks!(sub_transition_group_check_ground_catch);
18+
}
19+
}
20+
621
pub fn install() {
22+
skyline::nro::add_hook(nro_hook);
723
catchcut::install();
824
catchdash::install();
925
catchattack::install();
10-
}
26+
}

fighters/common/src/general_statuses/shield/guard_on/pre.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ use globals::*;
44

55
#[skyline::hook(replace = L2CFighterCommon_status_pre_GuardOn)]
66
unsafe fn status_pre_GuardOn(fighter: &mut L2CFighterCommon) -> L2CValue {
7-
VarModule::set_flag(
8-
// disables cstick buffered rolls if cstick was already held when entering shield for the first time
9-
fighter.battle_object,
10-
vars::common::instance::DISABLE_CSTICK_BUFFER_ROLL_OOS,
11-
fighter.is_button_on(Buttons::CStickOn)
12-
);
7+
// VarModule::set_flag(
8+
// // disables cstick buffered rolls if cstick was already held when entering shield for the first time
9+
// fighter.battle_object,
10+
// vars::common::instance::DISABLE_CSTICK_BUFFER_ROLL_OOS,
11+
// fighter.is_button_on(Buttons::CStickOn)
12+
// );
1313
StatusModule::init_settings(
1414
fighter.module_accessor,
1515
app::SituationKind(*SITUATION_KIND_GROUND),

fighters/common/src/general_statuses/shield/misc.rs

+45-15
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,9 @@ pub unsafe fn check_guard_attack_special_hi(
209209
false.into()
210210
}
211211

212-
pub unsafe fn check_escape_oos(fighter: &mut L2CFighterCommon) -> L2CValue {
212+
pub unsafe fn check_cstick_escape_oos(fighter: &mut L2CFighterCommon) -> L2CValue {
213213
let boma = fighter.module_accessor;
214214

215-
if fighter.check_guard_hold().get_bool() {
216-
return false.into();
217-
}
218-
219215
let c_stick_override = fighter.is_button_on(Buttons::CStickOverride);
220216
let c_stick_on = dbg!(
221217
!VarModule::is_flag(
@@ -238,22 +234,54 @@ pub unsafe fn check_escape_oos(fighter: &mut L2CFighterCommon) -> L2CValue {
238234
let escapes = [
239235
(
240236
*FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE,
241-
// checks if Cat2::StickEscape, or CStickOn and stick is vertical and below zero
242-
fighter.is_cat_flag(Cat2::StickEscape) || (c_stick_on && stick_vertical),
237+
c_stick_on && stick_vertical,
238+
*FIGHTER_STATUS_KIND_ESCAPE,
239+
),
240+
(
241+
*FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE_F,
242+
c_stick_on && !stick_vertical && sub_stick_x >= 0.0,
243+
*FIGHTER_STATUS_KIND_ESCAPE_F,
244+
),
245+
(
246+
*FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE_B,
247+
c_stick_on && !stick_vertical && sub_stick_x < 0.0,
248+
*FIGHTER_STATUS_KIND_ESCAPE_B,
249+
),
250+
];
251+
252+
for (term, condition, status) in escapes.iter() {
253+
if WorkModule::is_enable_transition_term(boma, *term) && *condition {
254+
// NOTE: DO NOT TOUCH
255+
// We must pass `false` to `change_status` so that the game does not clear our buffer/pad flag.
256+
// When it is done via `change_status`, the game will regenerate them the next time `sub_shift_status_main` is called.
257+
fighter.change_status((*status).into(), false.into());
258+
// We then must pass `true` to `clear_command` so that game "forgets" that we cleared our buffer
259+
// and will not regenerate our pad flags
260+
ControlModule::clear_command(fighter.module_accessor, true);
261+
return true.into();
262+
}
263+
}
264+
265+
return false.into();
266+
}
267+
268+
pub unsafe fn check_escape_oos(fighter: &mut L2CFighterCommon) -> L2CValue {
269+
let boma = fighter.module_accessor;
270+
271+
let escapes = [
272+
(
273+
*FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE,
274+
fighter.is_cat_flag(Cat2::StickEscape),
243275
*FIGHTER_STATUS_KIND_ESCAPE,
244276
),
245277
(
246278
*FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE_F,
247-
// checks if Cat2::StickEscape, or CStickOn and stick is horizontal and above zero
248-
fighter.is_cat_flag(Cat2::StickEscapeF) ||
249-
(c_stick_on && !stick_vertical && sub_stick_x >= 0.0),
279+
fighter.is_cat_flag(Cat2::StickEscapeF),
250280
*FIGHTER_STATUS_KIND_ESCAPE_F,
251281
),
252282
(
253283
*FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE_B,
254-
// checks if Cat2::StickEscape, or CStickOn and stick is horizontal and above zero
255-
fighter.is_cat_flag(Cat2::StickEscapeB) ||
256-
(c_stick_on && !stick_vertical && sub_stick_x < 0.0),
284+
fighter.is_cat_flag(Cat2::StickEscapeB),
257285
*FIGHTER_STATUS_KIND_ESCAPE_B,
258286
),
259287
];
@@ -398,8 +426,10 @@ pub unsafe fn sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue {
398426
return true.into();
399427
}
400428

401-
if check_escape_oos(fighter).get_bool() {
402-
return true.into();
429+
if !guard_hold {
430+
if check_escape_oos(fighter).get_bool() || check_cstick_escape_oos(fighter).get_bool() {
431+
return true.into();
432+
}
403433
}
404434

405435
if ItemModule::is_have_item(fighter.module_accessor, 0) {

fighters/common/src/general_statuses/shield/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mod guard;
44
mod guard_damage;
55
mod guard_off;
66
mod guard_on;
7-
mod misc;
7+
pub mod misc;
88

99
fn nro_hook(info: &skyline::nro::NroInfo) {
1010
if info.name == "common" {

0 commit comments

Comments
 (0)