Skip to content

Commit 359add8

Browse files
authored
Merge pull request #2298 from HDR-Development/floating
Custom Floats Reimplementation
2 parents b6f6458 + 6386f5b commit 359add8

File tree

30 files changed

+1221
-378
lines changed

30 files changed

+1221
-378
lines changed

dynamic/src/consts.rs

+39-17
Original file line numberDiff line numberDiff line change
@@ -182,38 +182,39 @@ pub mod vars {
182182

183183
pub const IS_INIT: i32 = 0x0065;
184184

185+
pub const IS_FLOAT: i32 = 0x0066;
186+
185187
// ints
186188

187189
pub const LAST_ATTACK_RECEIVER_ENTRY_ID: i32 = 0x0000;
188190

189191
pub const COSTUME_SLOT_NUMBER: i32 = 0x0001; // Unironically why does this need to exist? We have WorkModule.
190192

191-
pub const FLOAT_TIMER: i32 = 0x0002;
192-
pub const FLOAT_DURATION: i32 = 0x0003;
193-
pub const FLOAT_STYLE: i32 = 0x0004;
193+
pub const FLOAT_DURATION: i32 = 0x0002;
194+
pub const FLOAT_STATUS_KIND: i32 = 0x0003;
194195

195-
pub const HITFALL_BUFFER: i32 = 0x0005;
196+
pub const HITFALL_BUFFER: i32 = 0x0004;
196197

197-
pub const JUMP_SQUAT_FRAME: i32 = 0x0006;
198+
pub const JUMP_SQUAT_FRAME: i32 = 0x0005;
198199

199-
pub const GIMMICK_TIMER: i32 = 0x0007;
200+
pub const GIMMICK_TIMER: i32 = 0x0006;
200201

201-
pub const AIR_ESCAPE_MAGNET_FRAME: i32 = 0x0008;
202+
pub const AIR_ESCAPE_MAGNET_FRAME: i32 = 0x0007;
202203

203-
pub const CSTICK_LIFE: i32 = 0x0009;
204+
pub const CSTICK_LIFE: i32 = 0x0008;
204205

205-
pub const AGT_USED_COUNTER: i32 = 0x000A;
206+
pub const AGT_USED_COUNTER: i32 = 0x0009;
206207

207-
pub const CLIFF_XLU_FRAME: i32 = 0x000B;
208-
pub const LAST_ATTACK_HITBOX_ID: i32 = 0x000C;
209-
pub const SHIELD_EFFECT_HANDLE: i32 = 0x000D;
208+
pub const CLIFF_XLU_FRAME: i32 = 0x000A;
209+
pub const LAST_ATTACK_HITBOX_ID: i32 = 0x000B;
210+
pub const SHIELD_EFFECT_HANDLE: i32 = 0x000C;
210211

211-
pub const FRAME_COUNTER: i32 = 0x000E;
212+
pub const FRAME_COUNTER: i32 = 0x000D;
212213

213-
pub const LEFT_STICK_FLICK_X: i32 = 0x000F;
214-
pub const LEFT_STICK_FLICK_Y: i32 = 0x0010;
214+
pub const LEFT_STICK_FLICK_X: i32 = 0x000E;
215+
pub const LEFT_STICK_FLICK_Y: i32 = 0x000F;
215216

216-
pub const LEDGE_ID: i32 = 0x0011;
217+
pub const LEDGE_ID: i32 = 0x0010;
217218

218219
// floats
219220

@@ -284,10 +285,16 @@ pub mod vars {
284285

285286
pub const CSTICK_IRAR: i32 = 0x1000;
286287

288+
pub const FLOAT_INHERIT_AERIAL: i32 = 0x1000;
289+
287290
// ints
288291

289292
pub const DOWN_STAND_FB_KIND: i32 = 0x1000;
290293

294+
pub const FLOAT_FRAME: i32 = 0x1000;
295+
pub const FLOAT_ENABLE_UNIQ: i32 = 0x1001;
296+
pub const FLOAT_MTRANS: i32 = 0x1002;
297+
291298
// floats
292299

293300
pub const INITIAL_KNOCKBACK_VEL_X: i32 = 0x1000;
@@ -957,9 +964,12 @@ pub mod vars {
957964
pub const ELWIND1_CANCEL: i32 = 0x1100;
958965
}
959966
pub mod instance {
960-
//flags
967+
// flags
961968
pub const THUNDER_CHARGE: i32 = 0x0100;
962969
pub const UP_SPECIAL_FREEFALL: i32 = 0x0101;
970+
971+
// ints
972+
pub const LEVIN_AERIAL_LENIENCY: i32 = 0x0100;
963973
}
964974
}
965975

@@ -1482,6 +1492,10 @@ pub mod statuses {
14821492
pub const SPECIAL_HI_FINISH2: i32 = 0x1F1;
14831493
}
14841494

1495+
pub mod samusd {
1496+
pub const FLOAT: i32 = 0x1F6;
1497+
}
1498+
14851499
pub mod falco {
14861500
pub const SPECIAL_LW_LOOP: i32 = 0x1e8;
14871501
pub const SPECIAL_LW_END: i32 = 0x1e9;
@@ -1495,6 +1509,14 @@ pub mod statuses {
14951509
pub const SPECIAL_N_FLOAT: i32 = 0x1EC;
14961510
}
14971511

1512+
pub mod mewtwo {
1513+
pub const FLOAT: i32 = 0x1E9;
1514+
}
1515+
1516+
pub mod reflet {
1517+
pub const FLOAT: i32 = 0x1FD;
1518+
}
1519+
14981520
pub mod ryu {
14991521
pub const AIR_DASH: i32 = 0x202;
15001522
}

fighters/common/src/function_hooks/energy/control.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ unsafe fn control_update(energy: &mut FighterKineticEnergyControl, boma: &mut Ba
136136
0.0
137137
};
138138

139-
let mut change_y = energy.accel.y;
140-
141139
use EnergyControllerResetType::*;
142140

143141
let mut do_standard_accel = true;
@@ -213,7 +211,7 @@ unsafe fn control_update(energy: &mut FighterKineticEnergyControl, boma: &mut Ba
213211
// If stick is at neutral
214212
do_standard_accel = false;
215213
energy.accel.x = 0.0;
216-
energy.accel.y = change_y;
214+
energy.accel.y = 0.0;
217215
energy.speed_max.x = 0.0;
218216
0.0
219217
} else {
@@ -230,8 +228,8 @@ unsafe fn control_update(energy: &mut FighterKineticEnergyControl, boma: &mut Ba
230228
}
231229
},
232230
Free => {
233-
change_y = accel_add_y * stick.y.signum() + stick.y * energy.accel_mul_y;
234-
energy.speed_max.y = stick.y * energy.speed_max.y;
231+
energy.accel.y = accel_add_y * stick.y.signum() + stick.y * energy.accel_mul_y;
232+
energy.speed_max.y = stick.y.abs() * energy.speed_max.y;
235233
accel_add_x * stick.x.signum() + stick.x * energy.accel_mul_x
236234
},
237235
ItemLift => loop {

fighters/common/src/function_hooks/transition.rs

+2-30
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,7 @@ unsafe fn is_enable_transition_term_hook(boma: &mut BattleObjectModuleAccessor,
1515
let fighter_kind = boma.kind();
1616
let status_kind = StatusModule::status_kind(boma);
1717
let id = WorkModule::get_int(boma, *FIGHTER_INSTANCE_WORK_ID_INT_ENTRY_ID) as usize;
18-
19-
// disable jumping while using floats
20-
if [*FIGHTER_STATUS_KIND_FALL,
21-
*FIGHTER_STATUS_KIND_FALL_AERIAL,
22-
*FIGHTER_STATUS_KIND_JUMP,
23-
*FIGHTER_STATUS_KIND_JUMP_AERIAL,
24-
*FIGHTER_STATUS_KIND_CLIFF_JUMP1,
25-
*FIGHTER_STATUS_KIND_CLIFF_JUMP2,
26-
*FIGHTER_STATUS_KIND_CLIFF_JUMP3,
27-
*FIGHTER_STATUS_KIND_ATTACK_AIR,
28-
*FIGHTER_STATUS_KIND_DAMAGE_FALL].contains(&status_kind)
29-
&& WorkModule::is_flag(boma, *FIGHTER_STATUS_WORK_ID_FLAG_RESERVE_FALL_SLOWLY)
30-
|| VarModule::is_flag(boma.object(), vars::common::instance::OMNI_FLOAT) {
31-
if [*FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_JUMP_AERIAL_BUTTON,
32-
*FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_JUMP_AERIAL].contains(&flag) {
33-
return false;
34-
}
35-
}
36-
18+
3719
// Disallow airdodge out of tumble until you reach your stable fall speed
3820
if flag == *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE_AIR
3921
&& [*FIGHTER_STATUS_KIND_DAMAGE_FLY, *FIGHTER_STATUS_KIND_DAMAGE_FLY_ROLL, *FIGHTER_STATUS_KIND_DAMAGE_FLY_METEOR].contains(&status_kind) {
@@ -78,17 +60,7 @@ unsafe fn is_enable_transition_term_hook(boma: &mut BattleObjectModuleAccessor,
7860
if flag == *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_SPECIAL_S_COMMAND && (VarModule::is_flag(boma.object(), vars::common::instance::SIDE_SPECIAL_CANCEL) || VarModule::is_flag(boma.object(), vars::common::instance::SIDE_SPECIAL_CANCEL_NO_HIT)) {
7961
return false;
8062
}
81-
82-
// Disable transition to double jump if you have float juice and are holding down
83-
if [*FIGHTER_KIND_SAMUSD, *FIGHTER_KIND_MEWTWO, *FIGHTER_KIND_REFLET].contains(&fighter_kind) {
84-
if [*FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_JUMP_AERIAL, *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_JUMP_AERIAL_BUTTON].contains(&flag) {
85-
if boma.left_stick_y() < -0.66 {
86-
if WorkModule::get_int(boma, *FIGHTER_INSTANCE_WORK_ID_INT_SUPERLEAF_FALL_SLOWLY_FRAME) > 0 {
87-
return false;
88-
}
89-
}
90-
}
91-
}
63+
9264
if fighter_kind == *FIGHTER_KIND_PEACH {
9365
if status_kind == *FIGHTER_STATUS_KIND_JUMP_AERIAL {
9466
if flag == *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_JUMP_AERIAL || flag == *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_JUMP_AERIAL_BUTTON {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
use super::*;
2+
3+
#[no_mangle]
4+
unsafe fn attack_air_float_pre(fighter: &mut L2CFighterCommon, float_status: L2CValue) -> L2CValue {
5+
let prev_status_kind = fighter.global_table[PREV_STATUS_KIND].get_i32();
6+
let keep = if prev_status_kind == float_status.get_i32() {
7+
(
8+
*FIGHTER_STATUS_WORK_KEEP_FLAG_ALL_FLAG,
9+
*FIGHTER_STATUS_WORK_KEEP_FLAG_ALL_INT,
10+
*FIGHTER_STATUS_WORK_KEEP_FLAG_ALL_FLOAT
11+
)
12+
}
13+
else {
14+
(
15+
*FIGHTER_STATUS_WORK_KEEP_FLAG_ATTACK_AIR_FLAG,
16+
*FIGHTER_STATUS_WORK_KEEP_FLAG_ATTACK_AIR_INT,
17+
*FIGHTER_STATUS_WORK_KEEP_FLAG_ATTACK_AIR_FLOAT
18+
)
19+
};
20+
StatusModule::init_settings(
21+
fighter.module_accessor,
22+
SituationKind(*SITUATION_KIND_AIR),
23+
*FIGHTER_KINETIC_TYPE_MOTION_FALL,
24+
*GROUND_CORRECT_KIND_AIR as u32,
25+
GroundCliffCheckKind(*GROUND_CLIFF_CHECK_KIND_NONE),
26+
true,
27+
keep.0,
28+
keep.1,
29+
keep.2,
30+
*FS_SUCCEEDS_KEEP_VISIBILITY | *FS_SUCCEEDS_KEEP_ATTACK | *FS_SUCCEEDS_KEEP_EFFECT
31+
);
32+
FighterStatusModuleImpl::set_fighter_status_data(
33+
fighter.module_accessor,
34+
false,
35+
*FIGHTER_TREADED_KIND_NO_REAC,
36+
false,
37+
false,
38+
false,
39+
*FIGHTER_LOG_MASK_FLAG_ACTION_CATEGORY_KEEP as u64,
40+
*FIGHTER_STATUS_ATTR_CLEAR_MOTION_ENERGY as u32,
41+
*FIGHTER_POWER_UP_ATTACK_BIT_ATTACK_AIR as u32,
42+
0
43+
);
44+
0.into()
45+
}
46+
47+
#[no_mangle]
48+
unsafe fn attack_air_float_main(fighter: &mut L2CFighterCommon, float_status: L2CValue) -> L2CValue {
49+
let prev_status_kind = fighter.global_table[PREV_STATUS_KIND].get_i32();
50+
if prev_status_kind != float_status.get_i32() {
51+
return smashline::original_status(Main, fighter, *FIGHTER_STATUS_KIND_ATTACK_AIR)(fighter);
52+
}
53+
54+
let motion = MotionModule::motion_kind(fighter.module_accessor);
55+
56+
let log = match motion {
57+
0xc3a4e2597 => Some(FIGHTER_LOG_ATTACK_KIND_ATTACK_AIR_N),
58+
0xc3495ada5 => Some(FIGHTER_LOG_ATTACK_KIND_ATTACK_AIR_F),
59+
0xc33f869bc => Some(FIGHTER_LOG_ATTACK_KIND_ATTACK_AIR_B),
60+
0xdde67d935 => Some(FIGHTER_LOG_ATTACK_KIND_ATTACK_AIR_HI),
61+
0xd40042152 => Some(FIGHTER_LOG_ATTACK_KIND_ATTACK_AIR_LW),
62+
_ => None
63+
};
64+
65+
if let Some(log) = log {
66+
notify_event_msc_cmd!(fighter, Hash40::new_raw(0x2b94de0d96), FIGHTER_LOG_ACTION_CATEGORY_KEEP, log);
67+
}
68+
69+
// fighter.status_AttackAir_Main_common();
70+
WorkModule::set_int64(fighter.module_accessor, motion as i64, *FIGHTER_STATUS_ATTACK_AIR_WORK_INT_MOTION_KIND);
71+
72+
// allow fast fall during float release aerials
73+
if !StopModule::is_stop(fighter.module_accessor) {
74+
fighter.sub_fall_common_uniq(false.into());
75+
}
76+
fighter.global_table[SUB_STATUS].assign(&L2CValue::Ptr(L2CFighterCommon_sub_fall_common_uniq as *const () as _));
77+
78+
fighter.sub_shift_status_main(L2CValue::Ptr(L2CFighterCommon_status_AttackAir_Main as *const () as _))
79+
}
80+
81+
#[skyline::hook(replace = L2CFighterCommon_status_AttackAir_Main_common)]
82+
unsafe extern "C" fn status_attackair_main_common(fighter: &mut L2CFighterCommon) -> L2CValue {
83+
if !CancelModule::is_enable_cancel(fighter.module_accessor)
84+
&& VarModule::is_flag(fighter.battle_object, vars::common::instance::OMNI_FLOAT)
85+
&& !VarModule::is_flag(fighter.battle_object, vars::common::instance::IS_FLOAT)
86+
&& ControlModule::check_button_on(fighter.module_accessor, *CONTROL_PAD_BUTTON_JUMP) {
87+
let mut dive_cont_value = WorkModule::get_param_float(fighter.module_accessor, hash40("common"), hash40("dive_cont_value"));
88+
let mut dive_flick_frame_value = WorkModule::get_param_int(fighter.module_accessor, hash40("common"), hash40("dive_flick_frame_value"));
89+
if fighter.left_stick_y() <= dive_cont_value
90+
&& VarModule::get_int(fighter.battle_object, vars::common::instance::LEFT_STICK_FLICK_Y) < dive_flick_frame_value {
91+
let status_kind = VarModule::get_int(fighter.battle_object, vars::common::instance::FLOAT_STATUS_KIND);
92+
if status_kind != 0 {
93+
VarModule::on_flag(fighter.battle_object, vars::common::status::FLOAT_INHERIT_AERIAL);
94+
fighter.change_status(status_kind.into(), true.into());
95+
return 0.into();
96+
}
97+
}
98+
}
99+
original!()(fighter)
100+
}
101+
102+
fn nro_hook(info: &skyline::nro::NroInfo) {
103+
if info.name == "common" {
104+
skyline::install_hooks!(
105+
status_attackair_main_common
106+
);
107+
}
108+
}
109+
pub fn install() {
110+
skyline::nro::add_hook(nro_hook);
111+
}

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

+4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ mod attack;
33
mod attackx4;
44
mod attackdash;
55

6+
mod attackair;
7+
68
pub fn install() {
79
attack::install();
810
attackx4::install();
911
attackdash::install();
12+
13+
attackair::install();
1014
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use super::*;
2+
3+
#[no_mangle]
4+
unsafe fn float_end_common(fighter: &mut L2CFighterCommon) -> L2CValue {
5+
if fighter.global_table[STATUS_KIND].get_i32() == *FIGHTER_STATUS_KIND_LANDING_ATTACK_AIR {
6+
let motion = MotionModule::motion_kind(fighter.module_accessor);
7+
WorkModule::set_int64(fighter.module_accessor, motion as i64, *FIGHTER_STATUS_ATTACK_AIR_WORK_INT_MOTION_KIND);
8+
}
9+
AttackModule::set_shield_stiff_mul(fighter.module_accessor, 1.0);
10+
0.into()
11+
}

0 commit comments

Comments
 (0)