Skip to content

Commit f5fffe1

Browse files
committed
refactor: Refactor common code to use smashline 2
1 parent 62f0404 commit f5fffe1

File tree

17 files changed

+325
-307
lines changed

17 files changed

+325
-307
lines changed

Cargo.toml

+90-90
Original file line numberDiff line numberDiff line change
@@ -228,98 +228,98 @@ utils.workspace = true
228228

229229
[features]
230230
default = [
231-
"bayonetta",
232-
"brave",
233-
"buddy",
234-
"captain",
235-
"chrom",
236-
"cloud",
231+
# "bayonetta",
232+
# "brave",
233+
# "buddy",
234+
# "captain",
235+
# "chrom",
236+
# "cloud",
237237
"common",
238-
"daisy",
239-
"dedede",
240-
"demon",
241-
"diddy",
242-
"dolly",
243-
"donkey",
244-
"duckhunt",
245-
"edge",
246-
"eflame",
247-
"elight",
248-
"falco",
249-
"fox",
250-
"gamewatch",
251-
"ganon",
252-
"gaogaen",
253-
"gekkouga",
254-
"ike",
255-
"inkling",
256-
"jack",
257-
"kamui",
258-
"ken",
259-
"kirby",
260-
"koopa",
261-
"koopag",
262-
"koopajr",
263-
"krool",
264-
"link",
265-
"littlemac",
266-
"lucario",
267-
"lucas",
268-
"lucina",
269-
"luigi",
238+
# "daisy",
239+
# "dedede",
240+
# "demon",
241+
# "diddy",
242+
# "dolly",
243+
# "donkey",
244+
# "duckhunt",
245+
# "edge",
246+
# "eflame",
247+
# "elight",
248+
# "falco",
249+
# "fox",
250+
# "gamewatch",
251+
# "ganon",
252+
# "gaogaen",
253+
# "gekkouga",
254+
# "ike",
255+
# "inkling",
256+
# "jack",
257+
# "kamui",
258+
# "ken",
259+
# "kirby",
260+
# "koopa",
261+
# "koopag",
262+
# "koopajr",
263+
# "krool",
264+
# "link",
265+
# "littlemac",
266+
# "lucario",
267+
# "lucas",
268+
# "lucina",
269+
# "luigi",
270270
"mario",
271-
"mariod",
272-
"marth",
273-
"master",
274-
"metaknight",
275-
"mewtwo",
276-
"miifighter",
277-
"miigunner",
278-
"miiswordsman",
279-
"murabito",
280-
"nana",
281-
"ness",
282-
"packun",
283-
"pacman",
284-
"palutena",
285-
"peach",
286-
"pfushigisou",
287-
"pichu",
288-
"pickel",
289-
"pikachu",
290-
"pikmin",
291-
"pit",
292-
"pitb",
293-
"plizardon",
294-
"popo",
295-
"purin",
296-
"pzenigame",
297-
"reflet",
298-
"richter",
299-
"ridley",
300-
"robot",
301-
"rockman",
302-
"rosetta",
303-
"roy",
304-
"ryu",
305-
"samus",
306-
"samusd",
307-
"sheik",
308-
"shizue",
309-
"shulk",
310-
"simon",
311-
"snake",
312-
"sonic",
313-
"szerosuit",
314-
"tantan",
315-
"toonlink",
316-
"trail",
317-
"wario",
318-
"wiifit",
319-
"wolf",
320-
"yoshi",
321-
"younglink",
322-
"zelda",
271+
# "mariod",
272+
# "marth",
273+
# "master",
274+
# "metaknight",
275+
# "mewtwo",
276+
# "miifighter",
277+
# "miigunner",
278+
# "miiswordsman",
279+
# "murabito",
280+
# "nana",
281+
# "ness",
282+
# "packun",
283+
# "pacman",
284+
# "palutena",
285+
# "peach",
286+
# "pfushigisou",
287+
# "pichu",
288+
# "pickel",
289+
# "pikachu",
290+
# "pikmin",
291+
# "pit",
292+
# "pitb",
293+
# "plizardon",
294+
# "popo",
295+
# "purin",
296+
# "pzenigame",
297+
# "reflet",
298+
# "richter",
299+
# "ridley",
300+
# "robot",
301+
# "rockman",
302+
# "rosetta",
303+
# "roy",
304+
# "ryu",
305+
# "samus",
306+
# "samusd",
307+
# "sheik",
308+
# "shizue",
309+
# "shulk",
310+
# "simon",
311+
# "snake",
312+
# "sonic",
313+
# "szerosuit",
314+
# "tantan",
315+
# "toonlink",
316+
# "trail",
317+
# "wario",
318+
# "wiifit",
319+
# "wolf",
320+
# "yoshi",
321+
# "younglink",
322+
# "zelda",
323323
]
324324
dev = ["utils/no-offset-search"]
325325
main_nro = ["skyline-web", "common"]

fighters/common/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ edition = "2018"
99
skyline = "0.2.1"
1010
skyline_smash = { git = "https://github.com/blu-dev/skyline-smash", features = ["weak_l2cvalue"] }
1111
smash_script = { git = "https://github.com/blu-dev/smash-script.git", branch = "development" }
12-
smashline = { git = "https://github.com/blu-dev/smashline.git", branch = "development" }
12+
smashline = { git = "https://github.com/HDR-Development/smashline.git" }
1313
utils = { package = "dynamic", path = "../../dynamic" }
1414
ninput = { git = "https://github.com/blu-dev/ninput" }
1515
interpolation = "0.2.0" # for f32::lerp

fighters/common/src/djc.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ use super::*;
22

33
use globals::*;
44

5+
fn nro_hook(info: &skyline::nro::NroInfo) {
6+
if info.name == "common" {
7+
skyline::install_hooks!(
8+
sub_attack_air_inherit_jump_aerial_motion_uniq_process_init_impl,
9+
sub_attack_air_inherit_jump_aerial_motion_uniq_process_exec_impl
10+
);
11+
}
12+
}
13+
514
pub fn install() {
6-
smashline::install_hooks!(
7-
sub_attack_air_inherit_jump_aerial_motion_uniq_process_init_impl,
8-
sub_attack_air_inherit_jump_aerial_motion_uniq_process_exec_impl
9-
);
15+
skyline::nro::add_hook(nro_hook);
1016
}
1117

1218
// TAGS: DJC, Double Jump Cancel, FIGHTER_STATUS_KIND_ATTACK_AIR
@@ -37,7 +43,7 @@ pub unsafe extern "C" fn attack_air_main_status_loop(fighter: &mut L2CFighterCom
3743

3844
// TAGS: DJC, Double Jump Cancel, FIGHTER_STATUS_KIND_ATTACK_AIR
3945
/// Inherits the double jump animation movement when doing an aerial (init)
40-
#[smashline::hook(module = "common", symbol = "_ZN7lua2cpp16L2CFighterCommon59sub_attack_air_inherit_jump_aerial_motion_uniq_process_initEv")]
46+
#[skyline::hook(replace = L2CFighterCommon_sub_attack_air_inherit_jump_aerial_motion_uniq_process_init)]
4147
pub unsafe extern "C" fn sub_attack_air_inherit_jump_aerial_motion_uniq_process_init_impl(fighter: &mut L2CFighterCommon) -> L2CValue {
4248
if fighter.global_table[FIGHTER_KIND] == FIGHTER_KIND_DEMON {
4349
call_original!(fighter)
@@ -78,7 +84,7 @@ fn sub_attack_air_inherit_jump_aerial_motion_uniq_process_init(fighter: &mut L2C
7884

7985
// TAGS: DJC, Double Jump Cancel, FIGHTER_STATUS_KIND_ATTACK_AIR
8086
/// Inherits the double jump animation movement when doing an aerial (exec)
81-
#[smashline::hook(module = "common", symbol = "_ZN7lua2cpp16L2CFighterCommon59sub_attack_air_inherit_jump_aerial_motion_uniq_process_execEv")]
87+
#[skyline::hook(replace = L2CFighterCommon_sub_attack_air_inherit_jump_aerial_motion_uniq_process_exec)]
8288
pub unsafe extern "C" fn sub_attack_air_inherit_jump_aerial_motion_uniq_process_exec_impl(fighter: &mut L2CFighterCommon) -> L2CValue {
8389
if KineticModule::get_kinetic_type(fighter.module_accessor) == *FIGHTER_KINETIC_TYPE_JUMP_AERIAL_MOTION_2ND
8490
&& fighter.global_table[FIGHTER_KIND] != FIGHTER_KIND_DEMON

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ unsafe fn control_initialize(energy: &mut FighterKineticEnergyControl, boma: &mu
411411
-1.0
412412
}
413413
};
414-
energy.speed_limit = PaddedVec2::new(air_x_speed_max, 0.0);
414+
energy.speed_limit = PaddedVec2::new(dbg!(air_x_speed_max), 0.0);
415415
energy.accel_mul_x = WorkModule::get_param_float(boma, smash::hash40("air_accel_x_mul"), 0);
416416
energy.accel_add_x = WorkModule::get_param_float(boma, smash::hash40("air_accel_x_add"), 0);
417417
VarModule::set_float(boma.object(), vars::common::instance::JUMP_SPEED_MAX_MUL, 1.0);

fighters/common/src/general_statuses/airdodge.rs

+20-22
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,32 @@ use globals::*;
55
// This file contains code for aerial glide tosses, wavelanding
66

77
pub fn install() {
8-
install_status_scripts!(
9-
status_pre_EscapeAir,
10-
status_EscapeAir,
11-
status_end_EscapeAir
12-
);
13-
install_hooks!(
14-
sub_escape_air_common,
15-
sub_escape_air_uniq,
16-
sub_escape_air_common_main,
17-
sub_escape_air_common_strans_main
18-
);
198
skyline::nro::add_hook(nro_hook);
9+
Agent::new("common")
10+
.status(Pre, *FIGHTER_STATUS_KIND_ESCAPE_AIR, status_pre_EscapeAir)
11+
.status(Main, *FIGHTER_STATUS_KIND_ESCAPE_AIR, status_EscapeAir)
12+
.status(End, *FIGHTER_STATUS_KIND_ESCAPE_AIR, status_end_EscapeAir)
13+
.install();
2014
}
2115

2216
fn nro_hook(info: &skyline::nro::NroInfo) {
2317
if info.name == "common" {
2418
skyline::install_hooks!(
2519
setup_escape_air_slide_common,
26-
exec_escape_air_slide
20+
exec_escape_air_slide,
21+
sub_escape_air_common,
22+
sub_escape_air_uniq,
23+
sub_escape_air_common_main,
24+
sub_escape_air_common_strans_main,
25+
status_pre_EscapeAir,
26+
status_EscapeAir,
27+
status_end_EscapeAir
2728
);
2829
}
2930
}
3031

3132
// pre status
32-
#[common_status_script(status = FIGHTER_STATUS_KIND_ESCAPE_AIR, condition = LUA_SCRIPT_STATUS_FUNC_STATUS_PRE,
33-
symbol = "_ZN7lua2cpp16L2CFighterCommon20status_pre_EscapeAirEv")]
33+
#[skyline::hook(replace = L2CFighterCommon_status_pre_EscapeAir)]
3434
pub unsafe fn status_pre_EscapeAir(fighter: &mut L2CFighterCommon) -> L2CValue {
3535
// handles instant wavedashes/wavelands
3636
// we make sure to include this before change_motion so we check for proximity to the ground using our jumpsquat animation's ECB, rather than airdodge anim's ECB
@@ -76,8 +76,7 @@ pub unsafe fn status_pre_EscapeAir(fighter: &mut L2CFighterCommon) -> L2CValue {
7676
0.into()
7777
}
7878

79-
#[common_status_script(status = FIGHTER_STATUS_KIND_ESCAPE_AIR, condition = LUA_SCRIPT_STATUS_FUNC_STATUS_MAIN,
80-
symbol = "_ZN7lua2cpp16L2CFighterCommon16status_EscapeAirEv")]
79+
#[skyline::hook(replace = L2CFighterCommon_status_EscapeAir)]
8180
unsafe fn status_EscapeAir(fighter: &mut L2CFighterCommon) -> L2CValue {
8281
fighter.sub_escape_air_common();
8382
if WorkModule::is_flag(fighter.module_accessor, *FIGHTER_STATUS_ESCAPE_AIR_FLAG_SLIDE) {
@@ -116,8 +115,7 @@ unsafe extern "C" fn status_EscapeAir_Main(fighter: &mut L2CFighterCommon) -> L2
116115
}
117116

118117
// end status
119-
#[common_status_script(status = FIGHTER_STATUS_KIND_ESCAPE_AIR, condition = LUA_SCRIPT_STATUS_FUNC_STATUS_END,
120-
symbol = "_ZN7lua2cpp16L2CFighterCommon20status_end_EscapeAirEv")]
118+
#[skyline::hook(replace = L2CFighterCommon_status_end_EscapeAir)]
121119
pub unsafe fn status_end_EscapeAir(fighter: &mut L2CFighterCommon) -> L2CValue {
122120
let status_kind = fighter.global_table[STATUS_KIND].get_i32();
123121
if [*FIGHTER_STATUS_KIND_FALL,*FIGHTER_STATUS_KIND_LANDING].contains(&status_kind)
@@ -162,7 +160,7 @@ pub unsafe fn status_end_EscapeAir(fighter: &mut L2CFighterCommon) -> L2CValue {
162160
}
163161

164162
// common air dodge init code
165-
#[hook(module = "common", symbol = "_ZN7lua2cpp16L2CFighterCommon21sub_escape_air_commonEv")]
163+
#[skyline::hook(replace = L2CFighterCommon_sub_escape_air_common)]
166164
unsafe fn sub_escape_air_common(fighter: &mut L2CFighterCommon) {
167165
ControlModule::reset_trigger(fighter.module_accessor);
168166
WorkModule::set_int(fighter.module_accessor, 0, *FIGHTER_STATUS_ESCAPE_WORK_INT_FRAME);
@@ -188,7 +186,7 @@ unsafe fn sub_escape_air_common(fighter: &mut L2CFighterCommon) {
188186
}
189187

190188
// custom substatus for airdodges
191-
#[hook(module = "common", symbol = "_ZN7lua2cpp16L2CFighterCommon19sub_escape_air_uniqEN3lib8L2CValueE")]
189+
#[skyline::hook(replace = L2CFighterCommon_sub_escape_air_uniq)]
192190
unsafe extern "C" fn sub_escape_air_uniq(fighter: &mut L2CFighterCommon, arg: L2CValue) -> L2CValue {
193191
if arg.get_bool() {
194192
WorkModule::inc_int(fighter.module_accessor, *FIGHTER_STATUS_ESCAPE_WORK_INT_FRAME);
@@ -276,7 +274,7 @@ unsafe extern "C" fn sub_escape_air_uniq(fighter: &mut L2CFighterCommon, arg: L2
276274
0.into()
277275
}
278276

279-
#[hook(module = "common", symbol = "_ZN7lua2cpp16L2CFighterCommon26sub_escape_air_common_mainEv")]
277+
#[skyline::hook(replace = L2CFighterCommon_sub_escape_air_common_main)]
280278
unsafe extern "C" fn sub_escape_air_common_main(fighter: &mut L2CFighterCommon) -> L2CValue {
281279
let id = VarModule::get_int(fighter.battle_object, vars::common::instance::COSTUME_SLOT_NUMBER) as usize;
282280
let curr_frame = fighter.global_table[CURRENT_FRAME].get_i32();
@@ -349,7 +347,7 @@ unsafe extern "C" fn sub_escape_air_common_main(fighter: &mut L2CFighterCommon)
349347
L2CValue::Bool(true)
350348
}
351349

352-
#[hook(module = "common", symbol = "_ZN7lua2cpp16L2CFighterCommon33sub_escape_air_common_strans_mainEv")]
350+
#[skyline::hook(replace = L2CFighterCommon_sub_escape_air_common_strans_main)]
353351
unsafe extern "C" fn sub_escape_air_common_strans_main(fighter: &mut L2CFighterCommon) -> L2CValue {
354352
let trigger_frame = WorkModule::get_param_int(fighter.module_accessor, hash40("common"), hash40("air_escape_passive_trigger_frame")) as f32;
355353
let curr_frame = WorkModule::get_int(fighter.module_accessor, *FIGHTER_STATUS_ESCAPE_WORK_INT_FRAME);

0 commit comments

Comments
 (0)