Skip to content

Commit 68f1ca5

Browse files
committed
Moved vtables
1 parent 28f6737 commit 68f1ca5

File tree

14 files changed

+239
-380
lines changed

14 files changed

+239
-380
lines changed

dynamic/src/ext.rs

+14-137
Original file line numberDiff line numberDiff line change
@@ -1519,142 +1519,19 @@ pub struct MappedInputs {
15191519
pub rstick_y: i8,
15201520
}
15211521

1522-
pub type StatusFunc = unsafe extern "C" fn(&mut L2CFighterCommon) -> L2CValue;
1523-
15241522
#[repr(C)]
1525-
pub struct StatusInfo {
1526-
pub pre: Option<StatusFunc>,
1527-
pub main: Option<StatusFunc>,
1528-
pub end: Option<StatusFunc>,
1529-
pub init: Option<StatusFunc>,
1530-
pub exec: Option<StatusFunc>,
1531-
pub exec_stop: Option<StatusFunc>,
1532-
pub exec_post: Option<StatusFunc>,
1533-
pub exit: Option<StatusFunc>,
1534-
pub map_correction: Option<StatusFunc>,
1535-
pub fix_camera: Option<StatusFunc>,
1536-
pub fix_pos_slow: Option<StatusFunc>,
1537-
pub check_damage: Option<StatusFunc>,
1538-
pub check_attack: Option<StatusFunc>,
1539-
pub on_change_lr: Option<StatusFunc>,
1540-
pub leave_stop: Option<StatusFunc>,
1541-
pub notify_event_gimmick: Option<StatusFunc>,
1542-
pub calc_param: Option<StatusFunc>,
1543-
}
1544-
1545-
impl StatusInfo {
1546-
pub fn new() -> StatusInfo {
1547-
StatusInfo {
1548-
pre: None,
1549-
main: None,
1550-
end: None,
1551-
init: None,
1552-
exec: None,
1553-
exec_stop: None,
1554-
exec_post: None,
1555-
exit: None,
1556-
map_correction: None,
1557-
fix_camera: None,
1558-
fix_pos_slow: None,
1559-
check_damage: None,
1560-
check_attack: None,
1561-
on_change_lr: None,
1562-
leave_stop: None,
1563-
notify_event_gimmick: None,
1564-
calc_param: None,
1565-
}
1566-
}
1567-
1568-
pub fn with_pre(mut self, pre: StatusFunc) -> Self {
1569-
self.pre = Some(pre);
1570-
self
1571-
}
1572-
1573-
pub fn with_main(mut self, main: StatusFunc) -> Self {
1574-
self.main = Some(main);
1575-
self
1576-
}
1577-
1578-
pub fn with_end(mut self, end: StatusFunc) -> Self {
1579-
self.end = Some(end);
1580-
self
1581-
}
1582-
1583-
pub fn with_init(mut self, init: StatusFunc) -> Self {
1584-
self.init = Some(init);
1585-
self
1586-
}
1587-
1588-
pub fn with_exec(mut self, exec: StatusFunc) -> Self {
1589-
self.exec = Some(exec);
1590-
self
1591-
}
1592-
1593-
pub fn with_exec_stop(mut self, exec_stop: StatusFunc) -> Self {
1594-
self.exec_stop = Some(exec_stop);
1595-
self
1596-
}
1597-
1598-
pub fn with_exec_post(mut self, exec_post: StatusFunc) -> Self {
1599-
self.exec_post = Some(exec_post);
1600-
self
1601-
}
1602-
1603-
pub fn with_exit(mut self, exit: StatusFunc) -> Self {
1604-
self.exit = Some(exit);
1605-
self
1606-
}
1607-
1608-
pub fn with_map_correction(mut self, map_correction: StatusFunc) -> Self {
1609-
self.map_correction = Some(map_correction);
1610-
self
1611-
}
1612-
1613-
pub fn with_fix_camera(mut self, fix_camera: StatusFunc) -> Self {
1614-
self.fix_camera = Some(fix_camera);
1615-
self
1616-
}
1617-
1618-
pub fn with_fix_pos_slow(mut self, fix_pos_slow: StatusFunc) -> Self {
1619-
self.fix_pos_slow = Some(fix_pos_slow);
1620-
self
1621-
}
1622-
1623-
pub fn with_check_damage(mut self, check_damage: StatusFunc) -> Self {
1624-
self.check_damage = Some(check_damage);
1625-
self
1626-
}
1627-
1628-
pub fn with_check_attack(mut self, check_attack: StatusFunc) -> Self {
1629-
self.check_attack = Some(check_attack);
1630-
self
1631-
}
1632-
1633-
pub fn with_on_change_lr(mut self, on_change_lr: StatusFunc) -> Self {
1634-
self.on_change_lr = Some(on_change_lr);
1635-
self
1636-
}
1637-
1638-
pub fn with_leave_stop(mut self, leave_stop: StatusFunc) -> Self {
1639-
self.leave_stop = Some(leave_stop);
1640-
self
1641-
}
1642-
1643-
pub fn with_notify_event_gimmick(mut self, notify_event_gimmick: StatusFunc) -> Self {
1644-
self.notify_event_gimmick = Some(notify_event_gimmick);
1645-
self
1646-
}
1647-
1648-
pub fn with_calc_param(mut self, calc_param: StatusFunc) -> Self {
1649-
self.calc_param = Some(calc_param);
1650-
self
1651-
}
1652-
}
1653-
1654-
pub fn is_hdr_available() -> bool {
1655-
let mut symbol = 0usize;
1656-
unsafe {
1657-
skyline::nn::ro::LookupSymbol(&mut symbol, "hdr_is_available\0".as_ptr());
1658-
}
1659-
symbol != 0
1523+
pub struct CollisionLog {
1524+
pub next: *mut CollisionLog,
1525+
pub end: *mut CollisionLog,
1526+
pub location: Vector3f,
1527+
pub padding_0: u32,
1528+
pub padding_1: u32,
1529+
pub opponent_battle_object_id: u32,
1530+
pub padding_2: [u8;7],
1531+
pub collision_kind: u8,
1532+
pub receiver_part_id: u8,
1533+
pub collider_part_id: u8,
1534+
pub receiver_id: u8,
1535+
pub collider_id: u8,
1536+
pub padding_3: [u8;10]
16601537
}

fighters/common/src/function_hooks/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ pub mod attack;
2323
pub mod collision;
2424
pub mod camera;
2525
pub mod shotos;
26-
pub mod aura;
2726
pub mod sound;
2827
mod fighterspecializer;
2928
mod fighter_util;
@@ -760,7 +759,6 @@ pub fn install() {
760759
collision::install();
761760
camera::install();
762761
shotos::install();
763-
aura::install();
764762
sound::install();
765763
fighterspecializer::install();
766764
fighter_util::install();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use super::*;
2+
use utils::ext::*;
3+
4+
extern "C" {
5+
#[link_name = "_ZN3app24FighterSpecializer_Brave23special_lw_open_commandERNS_7FighterE"]
6+
fn special_lw_open_command();
7+
}
8+
9+
extern "C" {
10+
#[link_name = "hero_rng_hook_impl"]
11+
fn hero_rng_hook_impl(fighter: *mut BattleObject);
12+
}
13+
14+
#[skyline::hook(replace = special_lw_open_command)]
15+
pub unsafe fn hero_rng_hook(fighter: *mut BattleObject) {
16+
hero_rng_hook_impl(fighter);
17+
}
18+
19+
#[skyline::hook(offset = 0x853e10)]
20+
pub unsafe fn psych_up_hit() {
21+
// do nothing
22+
}
23+
24+
pub fn install() {
25+
skyline::install_hooks!(
26+
hero_rng_hook,
27+
psych_up_hit
28+
);
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use super::*;
2+
use utils::ext::*;
3+
4+
#[skyline::hook(offset = 0x993ee0)]
5+
pub unsafe extern "C" fn donkey_link_event(vtable: u64, fighter: &mut Fighter, event: &mut smash_rs::app::LinkEvent) -> u64 {
6+
// param_3 + 0x10
7+
if event.link_event_kind.0 == hash40("capture") {
8+
// println!("hi");
9+
let capture_event : &mut smash_rs::app::LinkEventCapture = std::mem::transmute(event);
10+
let module_accessor = fighter.battle_object.module_accessor;
11+
if StatusModule::status_kind(module_accessor) == *FIGHTER_STATUS_KIND_SPECIAL_LW {
12+
// param_3[0x28]
13+
capture_event.result = true;
14+
// capture_event.constraint = false;
15+
// param_3 + 0x30
16+
capture_event.node = smash_rs::phx::Hash40::new("throw");
17+
StatusModule::change_status_request(module_accessor, *FIGHTER_STATUS_KIND_CATCH_PULL, false);
18+
return 0;
19+
}
20+
return 1;
21+
}
22+
original!()(vtable, fighter, event)
23+
}
24+
25+
pub fn install() {
26+
skyline::install_hooks!(
27+
donkey_link_event
28+
);
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use super::*;
2+
use utils::ext::*;
3+
4+
extern "C" {
5+
#[link_name = "krool_belly_damage_hook_impl"]
6+
fn krool_belly_damage_hook_impl(damage: f32, fighter: *mut Fighter, unk: bool);
7+
}
8+
9+
// #[skyline::hook(offset = 0xc050d8, inline)]
10+
// pub unsafe fn krool_belly_toggle_hook(ctx: &mut skyline::hooks::InlineCtx) {
11+
// krool_belly_toggle_hook_impl(ctx);
12+
// }
13+
14+
#[skyline::hook(offset = 0xc055f0)]
15+
pub unsafe fn krool_belly_damage_hook(damage: f32, fighter: *mut Fighter, unk: bool) {
16+
krool_belly_damage_hook_impl(damage, fighter, unk);
17+
}
18+
19+
pub fn install() {
20+
skyline::install_hooks!(
21+
krool_belly_damage_hook
22+
);
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
use super::*;
2+
use utils::ext::*;
3+
4+
#[skyline::hook(offset = 0xc456a0)]
5+
pub unsafe extern "C" fn hook_ko_meter_gain(vtable: u64, battle_object: *mut BattleObject, collisionLog: CollisionLog, damage: f32) -> u64 {
6+
let boma = (&mut *(battle_object)).boma();
7+
let opponent_boma = &mut *(sv_battle_object::module_accessor(collisionLog.opponent_battle_object_id));
8+
//if HitModule::get_status(opponent_boma, collisionLog.receiver_part_id as i32, 0) != 0 { return call_original!(vtable, battle_object, collisionLog, 0.0); }
9+
let mut meter_gain = 5.0;
10+
11+
// this effectively stubs the logic handling critical zoom unless at full meter
12+
if boma.is_status(*FIGHTER_LITTLEMAC_STATUS_KIND_SPECIAL_N2) {
13+
let meter = WorkModule::get_float(boma, *FIGHTER_LITTLEMAC_INSTANCE_WORK_ID_FLOAT_KO_GAGE);
14+
if meter != 100.0 {
15+
let size = if meter < 40.0 { 0.5 } else { 0.7 };
16+
EffectModule::req_on_joint(boma, Hash40::new("sys_hit_normal_l"), Hash40::new("handr"), &Vector3f::zero(), &Vector3f::zero(), 0.8, &Vector3f::zero(), &Vector3f::zero(), false, 0, 0, 0);
17+
return 1
18+
}
19+
}
20+
21+
// modify meter gain based on opponent action
22+
if opponent_boma.is_status_one_of(&[
23+
*FIGHTER_STATUS_KIND_DAMAGE,
24+
*FIGHTER_STATUS_KIND_DAMAGE_AIR,
25+
*FIGHTER_STATUS_KIND_DAMAGE_FLY,
26+
*FIGHTER_STATUS_KIND_DAMAGE_FLY_ROLL,
27+
*FIGHTER_STATUS_KIND_DAMAGE_FLY_METEOR,
28+
*FIGHTER_STATUS_KIND_DAMAGE_FLY_REFLECT_LR,
29+
*FIGHTER_STATUS_KIND_DAMAGE_FLY_REFLECT_U,
30+
*FIGHTER_STATUS_KIND_DAMAGE_FLY_REFLECT_D,
31+
*FIGHTER_STATUS_KIND_DAMAGE_FALL]) {
32+
meter_gain = 10.0;
33+
}
34+
if opponent_boma.is_status_one_of(&[
35+
*FIGHTER_STATUS_KIND_ATTACK_S4_HOLD,
36+
*FIGHTER_STATUS_KIND_ATTACK_HI4_HOLD,
37+
*FIGHTER_STATUS_KIND_ATTACK_LW4_HOLD]) {
38+
EffectModule::req_on_joint(boma, Hash40::new("sys_sp_flash"), Hash40::new("top"), &Vector3f::new(0.0, 15.0, 4.0), &Vector3f::new(0.0, 0.0, 0.0), 1.0, &Vector3f::zero(), &Vector3f::zero(), true, 0, 0, 0);
39+
meter_gain = 30.0;
40+
}
41+
if opponent_boma.is_status(*FIGHTER_STATUS_KIND_APPEAL) {
42+
if TeamModule::hit_team_no(boma) != TeamModule::hit_team_no(opponent_boma) {
43+
SlowModule::set_whole(boma, 4, 60);
44+
EffectModule::req_on_joint(boma, Hash40::new("sys_hit_dead"), Hash40::new("bust"), &Vector3f::new(0.0, 0.0, 0.0), &Vector3f::new(0.0, 0.0, 0.0), 0.6, &Vector3f::zero(), &Vector3f::zero(), true, 0, 0, 0);
45+
SoundModule::play_se_no3d(boma, Hash40::new("vc_littlemac_appeal05"), true, true);
46+
SoundModule::play_se_no3d(boma, Hash40::new("vc_littlemac_missfoot02"), true, true);
47+
meter_gain = 100.0;
48+
}
49+
}
50+
51+
// modify meter based on the attack used
52+
if boma.is_status_one_of(&[
53+
*FIGHTER_STATUS_KIND_ATTACK_100,
54+
*FIGHTER_STATUS_KIND_ATTACK_S3,
55+
*FIGHTER_STATUS_KIND_SPECIAL_HI,
56+
*FIGHTER_LITTLEMAC_STATUS_KIND_SPECIAL_HI_JUMP,
57+
*FIGHTER_LITTLEMAC_STATUS_KIND_SPECIAL_HI_START,
58+
*FIGHTER_STATUS_KIND_ATTACK]) {
59+
if !VarModule::is_flag(boma.object(), vars::littlemac::status::LIMIT_METER_GAIN) {
60+
VarModule::on_flag(boma.object(), vars::littlemac::status::LIMIT_METER_GAIN);
61+
}
62+
else {
63+
meter_gain *= if boma.is_status(*FIGHTER_STATUS_KIND_ATTACK_100) { 0.1 }
64+
else if boma.is_status_one_of(&[
65+
*FIGHTER_STATUS_KIND_SPECIAL_HI,
66+
*FIGHTER_LITTLEMAC_STATUS_KIND_SPECIAL_HI_JUMP,
67+
*FIGHTER_LITTLEMAC_STATUS_KIND_SPECIAL_HI_START
68+
]) { 0.2 } else { 0.5 };
69+
}
70+
if boma.is_motion(Hash40::new("attack_13"))
71+
&& VarModule::is_flag(boma.object(), vars::littlemac::instance::IS_DREAMLAND_EXPRESS) {
72+
EffectModule::req_on_joint(boma, Hash40::new("sys_hit_magic"), Hash40::new("handl"), &Vector3f::zero(), &Vector3f::zero(), 0.4, &Vector3f::zero(), &Vector3f::zero(), false, 0, 0, 0);
73+
meter_gain += 10.0;
74+
}
75+
}
76+
if boma.is_status(*FIGHTER_LITTLEMAC_STATUS_KIND_SPECIAL_S_JUMP) {
77+
meter_gain = 0.0;
78+
}
79+
if boma.is_status_one_of(&[
80+
*FIGHTER_STATUS_KIND_ATTACK_S4,
81+
*FIGHTER_STATUS_KIND_ATTACK_HI4,
82+
*FIGHTER_STATUS_KIND_ATTACK_LW4]) {
83+
meter_gain *= 2.0;
84+
}
85+
86+
// Example on how to call update_littlemac_ui
87+
88+
// let meter = WorkModule::get_float(boma, *FIGHTER_LITTLEMAC_INSTANCE_WORK_ID_FLOAT_KO_GAGE);
89+
// println!("Current Meter: {}", meter);
90+
// println!("Gained Meter: {}", meter_gain);
91+
// println!();
92+
93+
// let entry_id = WorkModule::get_int(boma, *FIGHTER_INSTANCE_WORK_ID_INT_ENTRY_ID);
94+
// update_littlemac_ui(entry_id, meter + meter_gain);
95+
96+
call_original!(vtable, battle_object, collisionLog, meter_gain)
97+
}
98+
99+
pub fn install() {
100+
skyline::install_hooks!(
101+
hook_ko_meter_gain,
102+
);
103+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
use super::*;
22

3+
mod donkey;
4+
mod ganon;
5+
mod lucario;
6+
mod ptrainer;
7+
mod littlemac;
38
mod rockman;
9+
mod krool;
10+
mod brave;
411

512
pub fn install() {
13+
donkey::install();
14+
ganon::install();
15+
lucario::install();
16+
ptrainer::install();
17+
littlemac::install();
618
rockman::install();
19+
krool::install();
20+
brave::install();
721
}

0 commit comments

Comments
 (0)