Skip to content

Commit c565a25

Browse files
committed
Side B4 Back Reimpl
1 parent 7b6e6ae commit c565a25

File tree

5 files changed

+103
-81
lines changed

5 files changed

+103
-81
lines changed

dynamic/src/consts.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,10 @@ pub mod vars {
942942
pub mod instance {
943943
// flags
944944
pub const TRAIL_EFFECT: i32 = 0x0100;
945-
pub const REVERSE_SIDEB: i32 = 0x0101;
945+
}
946+
pub mod status {
947+
// flags
948+
pub const SIDE_B_REVERSE : i32 = 0x1150;
946949
}
947950
}
948951

fighters/roy/src/acmd/specials.rs

-6
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,6 @@ unsafe fn roy_special_air_n_end3_game(fighter: &mut L2CAgentBase) {
330330
unsafe fn game_specials1(fighter: &mut L2CAgentBase) {
331331
let lua_state = fighter.lua_state_agent;
332332
let boma = fighter.boma();
333-
334-
frame(lua_state, 1.0);
335-
if is_excute(fighter) {
336-
VarModule::off_flag(fighter.battle_object, vars::roy::instance::REVERSE_SIDEB);
337-
}
338-
339333
frame(lua_state, 6.0);
340334
if is_excute(fighter) {
341335
ATTACK(fighter, 0, 0, Hash40::new("colonells"), 5.0, 60, 25, 0, 50, 2.34, 0.0, 0.0, 0.0, None, None, None, 0.9, 1.0, *ATTACK_SETOFF_KIND_ON, *ATTACK_LR_CHECK_F, false, 3, 0.0, 0, false, false, false, false, true, *COLLISION_SITUATION_MASK_GA, *COLLISION_CATEGORY_MASK_ALL, *COLLISION_PART_MASK_ALL, false, Hash40::new("collision_attr_cutup"), *ATTACK_SOUND_LEVEL_M, *COLLISION_SOUND_ATTR_ROY_HIT, *ATTACK_REGION_SWORD);

fighters/roy/src/opff.rs

+6-28
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,6 @@ utils::import_noreturn!(common::opff::fighter_common_opff);
33
use super::*;
44
use globals::*;
55

6-
pub unsafe fn double_edge_dance_backwards(fighter: &mut L2CFighterCommon) {
7-
if StatusModule::status_kind(fighter.module_accessor) == *FIGHTER_ROY_STATUS_KIND_SPECIAL_S3 {
8-
if StatusModule::situation_kind(fighter.module_accessor) == *SITUATION_KIND_GROUND {
9-
if WorkModule::is_flag(fighter.module_accessor, *FIGHTER_MARTH_STATUS_SPECIAL_S_FLAG_MOTION_CHANGE_ENABLE) {
10-
let lrc = PostureModule::lr(fighter.module_accessor);
11-
let stick_x = ControlModule::get_stick_x(fighter.module_accessor);
12-
if lrc == 1.0 && stick_x < 0.0 && ControlModule::check_button_on(fighter.module_accessor, *CONTROL_PAD_BUTTON_SPECIAL){
13-
} else if lrc == -1.0 && stick_x > 0.0 && ControlModule::check_button_on(fighter.module_accessor, *CONTROL_PAD_BUTTON_SPECIAL) {
14-
VarModule::on_flag(fighter.battle_object, vars::roy::instance::REVERSE_SIDEB);
15-
}
16-
}
17-
}
18-
else if StatusModule::situation_kind(fighter.module_accessor) == *SITUATION_KIND_AIR {
19-
if WorkModule::is_flag(fighter.module_accessor, *FIGHTER_MARTH_STATUS_SPECIAL_S_FLAG_MOTION_CHANGE_ENABLE) {
20-
let lrc = PostureModule::lr(fighter.module_accessor);
21-
let stick_x = ControlModule::get_stick_x(fighter.module_accessor);
22-
if lrc == 1.0 && stick_x < 0.0 && ControlModule::check_button_on(fighter.module_accessor, *CONTROL_PAD_BUTTON_SPECIAL) {
23-
VarModule::on_flag(fighter.battle_object, vars::roy::instance::REVERSE_SIDEB);
24-
} else if lrc == -1.0 && stick_x > 0.0 && ControlModule::check_button_on(fighter.module_accessor, *CONTROL_PAD_BUTTON_SPECIAL) {
25-
VarModule::on_flag(fighter.battle_object, vars::roy::instance::REVERSE_SIDEB);
26-
}
27-
}
28-
}
29-
}
30-
}
31-
326
pub unsafe fn double_edge_dance_vertical_momentum(boma: &mut BattleObjectModuleAccessor){
337
let fighter_gravity = KineticModule::get_energy(boma, *FIGHTER_KINETIC_ENERGY_ID_GRAVITY) as *mut FighterKineticEnergyGravity;
348
if boma.is_status_one_of(&[*FIGHTER_STATUS_KIND_SPECIAL_S, *FIGHTER_ROY_STATUS_KIND_SPECIAL_S2]) && boma.is_situation(*SITUATION_KIND_AIR) {
@@ -66,9 +40,14 @@ pub unsafe fn double_edge_dance_during_hitlag(fighter: &mut L2CFighterCommon) {
6640
if enable_hi_lw == 0 {
6741
return;
6842
}
43+
let stick_x = fighter.global_table[STICK_X].get_f32();
6944
let stick_y = fighter.global_table[STICK_Y].get_f32();
7045
let squat_stick_y = WorkModule::get_param_float(fighter.module_accessor, hash40("common"), hash40("squat_stick_y"));
71-
if stick_y > -squat_stick_y {
46+
let lr = PostureModule::lr(fighter.module_accessor);
47+
if fighter.is_status(*FIGHTER_ROY_STATUS_KIND_SPECIAL_S3) && stick_x * lr < squat_stick_y {
48+
VarModule::on_flag(fighter.battle_object, vars::roy::status::SIDE_B_REVERSE);
49+
}
50+
else if stick_y > -squat_stick_y {
7251
WorkModule::on_flag(fighter.module_accessor, *FIGHTER_ROY_STATUS_SPECIAL_S_FLAG_INPUT_HI);
7352
}
7453
else if stick_y < squat_stick_y {
@@ -128,7 +107,6 @@ unsafe fn fastfall_specials(fighter: &mut L2CFighterCommon) {
128107

129108
pub unsafe fn moveset(fighter: &mut L2CFighterCommon, boma: &mut BattleObjectModuleAccessor, id: usize, cat: [i32 ; 4], status_kind: i32, situation_kind: i32, motion_kind: u64, stick_x: f32, stick_y: f32, facing: f32, frame: f32) {
130109
double_edge_dance_vertical_momentum(boma);
131-
double_edge_dance_backwards(fighter);
132110
double_edge_dance_during_hitlag(fighter);
133111
up_special_proper_landing(fighter);
134112
fastfall_specials(fighter);

fighters/roy/src/status.rs

+91-44
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use globals::*;
55
pub fn install() {
66
install_status_scripts!(
77
init_specials,
8-
special_s_back
8+
special_s4_main
99
);
1010
}
1111

@@ -16,40 +16,6 @@ pub fn set_gravity_delay_resume_frame(energy: *mut FighterKineticEnergyGravity,
1616
}
1717
}
1818

19-
#[status_script(agent = "roy", status = FIGHTER_ROY_STATUS_KIND_SPECIAL_S4, condition = LUA_SCRIPT_STATUS_FUNC_STATUS_MAIN)]
20-
pub unsafe fn special_s_back(fighter: &mut L2CFighterCommon) -> L2CValue {
21-
if VarModule::is_flag(fighter.battle_object, vars::roy::instance::REVERSE_SIDEB) {
22-
let lrc = PostureModule::lr(fighter.module_accessor);
23-
let stick_x = ControlModule::get_stick_x(fighter.module_accessor);
24-
25-
if fighter.global_table[SITUATION_KIND] == SITUATION_KIND_GROUND {
26-
MotionModule::change_motion_inherit_frame(fighter.module_accessor, Hash40::new("special_s4_back"), 0.0, 1.0, 0.0, false, false);
27-
VarModule::off_flag(fighter.battle_object, vars::roy::instance::REVERSE_SIDEB);
28-
29-
if lrc == 1.0 && stick_x < 0.0 {
30-
PostureModule::set_lr(fighter.module_accessor, -1.0);
31-
} else if lrc == -1.0 && stick_x > 0.0 {
32-
PostureModule::set_lr(fighter.module_accessor, 1.0);
33-
}
34-
35-
return 0.into();
36-
} else {
37-
MotionModule::change_motion_inherit_frame(fighter.module_accessor, Hash40::new("special_air_s4_back"), 0.0, 1.0, 0.0, false, false);
38-
VarModule::off_flag(fighter.battle_object, vars::roy::instance::REVERSE_SIDEB);
39-
40-
if lrc == 1.0 && stick_x < 0.0 {
41-
PostureModule::set_lr(fighter.module_accessor, -1.0);
42-
} else if lrc == -1.0 && stick_x > 0.0 {
43-
PostureModule::set_lr(fighter.module_accessor, 1.0);
44-
}
45-
46-
return 0.into();
47-
}
48-
}
49-
50-
original!(fighter)
51-
}
52-
5319
#[status_script(agent = "roy", status = FIGHTER_STATUS_KIND_SPECIAL_S, condition = LUA_SCRIPT_STATUS_FUNC_INIT_STATUS)]
5420
pub unsafe fn init_specials(fighter: &mut L2CFighterCommon, arg: u64) -> L2CValue {
5521
let fighter_kind = WorkModule::get_int(fighter.module_accessor, *FIGHTER_INSTANCE_WORK_ID_INT_KIND);
@@ -111,10 +77,6 @@ pub unsafe fn init_specials(fighter: &mut L2CFighterCommon, arg: u64) -> L2CValu
11177
smash::app::lua_bind::KineticEnergy::enable(motion_energy);
11278
smash::app::lua_bind::KineticModule::unable_energy(fighter.module_accessor, *FIGHTER_KINETIC_ENERGY_ID_STOP);
11379
smash::app::lua_bind::KineticModule::unable_energy(fighter.module_accessor, *FIGHTER_KINETIC_ENERGY_ID_GRAVITY);
114-
115-
if VarModule::is_flag(fighter.battle_object, vars::roy::instance::REVERSE_SIDEB) {
116-
MotionModule::change_motion(fighter.module_accessor, Hash40::new("special_s4_back"), 0.0, 1.0, false, 0.0, false, false);
117-
}
11880
}
11981
else if current_situation_kind == *SITUATION_KIND_AIR {
12082
let reset_speed_2f = smash::phx::Vector2f { x: 0.0, y: 0.0 };
@@ -123,13 +85,98 @@ pub unsafe fn init_specials(fighter: &mut L2CFighterCommon, arg: u64) -> L2CValu
12385
smash::app::lua_bind::KineticEnergy::reset_energy(gravity_energy, *ENERGY_GRAVITY_RESET_TYPE_GRAVITY, &reset_speed_2f, &reset_speed_3f, fighter.module_accessor);
12486
smash::app::lua_bind::KineticEnergy::enable(stop_energy);
12587
smash::app::lua_bind::KineticEnergy::enable(gravity_energy);
126-
127-
if VarModule::is_flag(fighter.battle_object, vars::roy::instance::REVERSE_SIDEB) {
128-
MotionModule::change_motion(fighter.module_accessor, Hash40::new("special_air_s4_back"), 0.0, 1.0, false, 0.0, false, false);
129-
}
13088
}
13189
}
13290
KineticModule::unable_energy(fighter.module_accessor, *FIGHTER_KINETIC_ENERGY_ID_CONTROL);
13391

13492
0.into()
135-
}
93+
}
94+
95+
#[status_script(agent = "roy", status = FIGHTER_ROY_STATUS_KIND_SPECIAL_S4, condition = LUA_SCRIPT_STATUS_FUNC_STATUS_MAIN)]
96+
pub unsafe fn special_s4_main(fighter: &mut L2CFighterCommon, arg: u64) -> L2CValue {
97+
WorkModule::off_flag(fighter.module_accessor, *FIGHTER_ROY_STATUS_SPECIAL_S_FLAG_CONTINUE_MOT);
98+
let mot = if VarModule::is_flag(fighter.battle_object, vars::roy::status::SIDE_B_REVERSE) {
99+
(hash40("special_s4_back") as i64, hash40("special_air_s4_back") as i64)
100+
}
101+
else if WorkModule::is_flag(fighter.module_accessor, *FIGHTER_ROY_STATUS_SPECIAL_S_FLAG_INPUT_LW) {
102+
(hash40("special_s4_lw") as i64, hash40("special_air_s4_lw") as i64)
103+
}
104+
else if WorkModule::is_flag(fighter.module_accessor, *FIGHTER_ROY_STATUS_SPECIAL_S_FLAG_INPUT_HI) {
105+
(hash40("special_s4_hi") as i64, hash40("special_air_s4_hi") as i64)
106+
}
107+
else {
108+
(hash40("special_s4_s") as i64, hash40("special_air_s4_s") as i64)
109+
};
110+
WorkModule::set_int64(fighter.module_accessor, mot.0, *FIGHTER_ROY_STATUS_SPECIAL_S_WORK_INT_MOTION_KIND);
111+
WorkModule::set_int64(fighter.module_accessor, mot.1, *FIGHTER_ROY_STATUS_SPECIAL_S_WORK_INT_MOTION_KIND_AIR);
112+
VarModule::off_flag(fighter.battle_object, vars::roy::status::SIDE_B_REVERSE);
113+
WorkModule::off_flag(fighter.module_accessor, *FIGHTER_ROY_STATUS_SPECIAL_S_FLAG_INPUT_HI);
114+
WorkModule::off_flag(fighter.module_accessor, *FIGHTER_ROY_STATUS_SPECIAL_S_FLAG_INPUT_LW);
115+
fighter.sub_shift_status_main(L2CValue::Ptr(special_s4_main_loop as *const () as _))
116+
}
117+
118+
unsafe extern "C" fn special_s4_main_loop(fighter: &mut L2CFighterCommon) -> L2CValue {
119+
if !StatusModule::is_changing(fighter.module_accessor) {
120+
if StatusModule::is_situation_changed(fighter.module_accessor) {
121+
special_s_mot_helper(fighter);
122+
}
123+
}
124+
else {
125+
special_s_mot_helper(fighter);
126+
}
127+
if CancelModule::is_enable_cancel(fighter.module_accessor) {
128+
if fighter.sub_wait_ground_check_common(false.into()).get_bool()
129+
|| fighter.sub_air_check_fall_common().get_bool() {
130+
return 0.into();
131+
}
132+
}
133+
if MotionModule::is_end(fighter.module_accessor) {
134+
let sit = fighter.global_table[SITUATION_KIND].get_i32();
135+
if sit != *SITUATION_KIND_GROUND {
136+
fighter.change_status(FIGHTER_STATUS_KIND_FALL.into(), false.into());
137+
}
138+
else {
139+
fighter.change_status(FIGHTER_STATUS_KIND_WAIT.into(), false.into());
140+
}
141+
}
142+
0.into()
143+
}
144+
145+
unsafe extern "C" fn special_s_mot_helper(fighter: &mut L2CFighterCommon) {
146+
let sit = fighter.global_table[SITUATION_KIND].get_i32();
147+
let correct;
148+
let mot;
149+
if sit != *SITUATION_KIND_GROUND {
150+
correct = *GROUND_CORRECT_KIND_AIR;
151+
mot = WorkModule::get_int64(fighter.module_accessor, *FIGHTER_ROY_STATUS_SPECIAL_S_WORK_INT_MOTION_KIND_AIR);
152+
}
153+
else {
154+
correct = *GROUND_CORRECT_KIND_GROUND_CLIFF_STOP;
155+
mot = WorkModule::get_int64(fighter.module_accessor, *FIGHTER_ROY_STATUS_SPECIAL_S_WORK_INT_MOTION_KIND);
156+
}
157+
GroundModule::correct(fighter.module_accessor, GroundCorrectKind(correct));
158+
if !WorkModule::is_flag(fighter.module_accessor, *FIGHTER_ROY_STATUS_SPECIAL_S_FLAG_CONTINUE_MOT) {
159+
MotionModule::change_motion(
160+
fighter.module_accessor,
161+
Hash40::new_raw(mot),
162+
0.0,
163+
1.0,
164+
false,
165+
0.0,
166+
false,
167+
false
168+
);
169+
WorkModule::on_flag(fighter.module_accessor, *FIGHTER_ROY_STATUS_SPECIAL_S_FLAG_CONTINUE_MOT);
170+
}
171+
else {
172+
MotionModule::change_motion_inherit_frame(
173+
fighter.module_accessor,
174+
Hash40::new_raw(mot),
175+
-1.0,
176+
1.0,
177+
0.0,
178+
false,
179+
false
180+
);
181+
}
182+
}

romfs/source/fighter/roy/motion/body/motion_patch.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ attack_lw4:
171171
special_s4_back:
172172
game_script: game_specials4back
173173
flags:
174-
turn: false
174+
turn: true
175175
loop: false
176176
move: true
177177
fix_trans: false
@@ -201,7 +201,7 @@ special_s4_back:
201201
special_air_s4_back:
202202
game_script: game_specials4back
203203
flags:
204-
turn: false
204+
turn: true
205205
loop: false
206206
move: true
207207
fix_trans: false

0 commit comments

Comments
 (0)