Skip to content

Commit f272a88

Browse files
committed
further reorg
1 parent 79afe79 commit f272a88

File tree

3 files changed

+105
-0
lines changed

3 files changed

+105
-0
lines changed

fighters/littlemac/src/status.rs

+1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ pub fn install() {
3131
special_lw_cancel::install();
3232
smashline::Agent::new("littlemac")
3333
.on_init(littlemac_init)
34+
.install();
3435
}
+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
use super::*;
2+
3+
// lets down smash travel past ledges during a DACUS
4+
pub unsafe extern "C" fn attack_lw4_main(fighter: &mut L2CFighterCommon) -> L2CValue {
5+
WorkModule::on_flag(fighter.module_accessor, *FIGHTER_STATUS_ATTACK_FLAG_SMASH_SMASH_HOLD_TO_ATTACK);
6+
fighter.attack_lw4_mtrans();
7+
WorkModule::enable_transition_term(fighter.module_accessor, *FIGHTER_STATUS_TRANSITION_TERM_ID_THROW_KIRBY_GROUND);
8+
if !StopModule::is_stop(fighter.module_accessor) {
9+
fighter.status_ThrowKirby_Uniq(L2CValue::Bool(false));
10+
}
11+
fighter.global_table[SUB_STATUS].assign(&L2CValue::Ptr(smash::lua2cpp::L2CFighterCommon_status_ThrowKirby_Uniq as *const () as _));
12+
fighter.sub_shift_status_main(L2CValue::Ptr(trail_attack_lw4_main_loop as *const () as _))
13+
}
14+
15+
pub unsafe extern "C" fn trail_attack_lw4_main_loop(fighter: &mut L2CFighterCommon) -> L2CValue {
16+
if !CancelModule::is_enable_cancel(fighter.module_accessor)
17+
&& !WorkModule::is_enable_transition_term(fighter.module_accessor, *FIGHTER_STATUS_TRANSITION_TERM_ID_THROW_KIRBY_GROUND)
18+
&& !MotionModule::is_end(fighter.module_accessor) {
19+
fighter.sub_status_uniq_process_ThrowKirby_execFixPos();
20+
return 0.into()
21+
}
22+
fighter.status_AttackLw4_Main()
23+
}
24+
25+
pub unsafe extern "C" fn attack_lw4_map_correction(fighter: &mut L2CFighterCommon) -> L2CValue {
26+
let frame = MotionModule::frame(fighter.module_accessor) as i32;
27+
28+
// animation startup
29+
if frame < 6 {
30+
return 0.into()
31+
}
32+
// first frame of being airborne
33+
if frame == 6 {
34+
WorkModule::on_flag(fighter.module_accessor, *FIGHTER_STATUS_THROW_FLAG_START_AIR);
35+
VarModule::set_float(fighter.battle_object, vars::trail::status::DACUS_SPEED_Y, -2.8); // initial speed for sora to start falling
36+
}
37+
// window in which sora will accel downwards
38+
if frame == (18 | 19)
39+
&& fighter.is_situation(*SITUATION_KIND_AIR) {
40+
let speed_y = VarModule::get_float(fighter.battle_object, vars::trail::status::DACUS_SPEED_Y);
41+
let accel_mul = 1.04; // rate in which the decent will accelerate each frame
42+
let new_speed = speed_y * accel_mul;
43+
KineticModule::change_kinetic(fighter.module_accessor, *FIGHTER_KINETIC_TYPE_FALL);
44+
sv_kinetic_energy!(set_speed, fighter, FIGHTER_KINETIC_ENERGY_ID_GRAVITY, new_speed);
45+
sv_kinetic_energy!(set_accel_x_mul, fighter, FIGHTER_KINETIC_ENERGY_ID_CONTROL, 0.05); // level of horizontal control while falling
46+
sv_kinetic_energy!(set_accel_x_add, fighter, FIGHTER_KINETIC_ENERGY_ID_CONTROL, 0.05);
47+
VarModule::set_float(fighter.battle_object, vars::trail::status::DACUS_SPEED_Y, new_speed);
48+
if frame == 19 { // freeze the animation
49+
MotionModule::set_rate(fighter.module_accessor, 0.0);
50+
}
51+
}
52+
// ray check to see if sora is close enough to the ground to finish the animation
53+
let should_land =
54+
GroundModule::ray_check(fighter.module_accessor,
55+
&Vector2f{ x: PostureModule::pos_x(fighter.module_accessor), y: PostureModule::pos_y(fighter.module_accessor)},
56+
&Vector2f{ x: 0.0, y: -6.0}, true) == 1;
57+
if frame == 19 {
58+
if should_land {
59+
//println!("landing!");
60+
KineticModule::clear_speed_energy_id(fighter.module_accessor, *FIGHTER_KINETIC_ENERGY_ID_GRAVITY);
61+
GroundModule::correct(fighter.module_accessor, GroundCorrectKind(*GROUND_CORRECT_KIND_GROUND));
62+
MotionModule::set_rate(fighter.module_accessor, 1.0);
63+
} else {
64+
let fall_frame = VarModule::get_int(fighter.battle_object, vars::trail::status::ATTACK_LW4_TIMER);
65+
if fall_frame < 17 {
66+
VarModule::inc_int(fighter.battle_object, vars::trail::status::ATTACK_LW4_TIMER);
67+
} else {
68+
VarModule::set_int(fighter.battle_object, vars::trail::status::ATTACK_LW4_TIMER, 0);
69+
KineticModule::clear_speed_energy_id(fighter.module_accessor, *FIGHTER_KINETIC_ENERGY_ID_GRAVITY);
70+
fighter.change_status(FIGHTER_STATUS_KIND_FALL.into(), false.into());
71+
return 1.into();
72+
}
73+
}
74+
}
75+
0.into()
76+
}
77+
78+
pub fn install() {
79+
smashline::Agent::new("trail")
80+
.status(Main, *FIGHTER_STATUS_KIND_ATTACK_LW4, attack_lw4_main)
81+
.status(MapCorrection, *FIGHTER_STATUS_KIND_ATTACK_LW4, attack_lw4_map_correction,)
82+
.install();
83+
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use super::*;
2+
3+
// preserve momentum if double jumping out of sonic blade
4+
unsafe extern "C" fn jump_aerial_main(fighter: &mut L2CFighterCommon) -> L2CValue {
5+
let x_speed = VarModule::get_float(fighter.battle_object, vars::trail::instance::JUMP_CANCEL_MOMENTUM_HANDLER);
6+
7+
let original = smashline::original_status(Main, fighter, *FIGHTER_STATUS_KIND_JUMP_AERIAL);
8+
9+
if fighter.is_prev_status(*FIGHTER_TRAIL_STATUS_KIND_SPECIAL_S_ATTACK) {
10+
KineticModule::add_speed(fighter.module_accessor, &Vector3f{x: x_speed.abs() / 3.0, y: 0.0, z: 0.0});
11+
}
12+
13+
original(fighter)
14+
}
15+
16+
17+
pub fn install() {
18+
smashline::Agent::new("trail")
19+
.status(Main, *FIGHTER_STATUS_KIND_JUMP_AERIAL, jump_aerial_main)
20+
.install();
21+
}

0 commit comments

Comments
 (0)