Skip to content

Commit 229dc71

Browse files
authored
Merge pull request #2291 from HDR-Development/megaman-adjustments
Megaman Adjustments
2 parents f286d9f + 008f3a6 commit 229dc71

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+825
-890
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/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ 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
16-
smash2 = { package = "smash", git = "https://github.com/blu-dev/smash-rs" }
16+
smash_rs = { package = "smash", git = "https://github.com/blu-dev/smash-rs" }
1717
rand = { git = "https://github.com/skyline-rs/rand" }

fighters/common/src/function_hooks/attack.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::arch::asm;
44
use utils::game_modes::CustomMode;
55

66
#[skyline::hook(offset = 0x3dc180)]
7-
unsafe fn attack_module_set_attack(module: u64, id: i32, group: i32, data: &mut smash2::app::AttackData) {
7+
unsafe fn attack_module_set_attack(module: u64, id: i32, group: i32, data: &mut smash_rs::app::AttackData) {
88
let boma = *(module as *mut *mut BattleObjectModuleAccessor).add(1);
99

1010
// if a hitbox does not intentionally trip 100% of time, remove random trip chance
@@ -21,31 +21,31 @@ unsafe fn attack_module_set_attack(module: u64, id: i32, group: i32, data: &mut
2121
data.r_eff = 50; // KBG
2222
data.r_add = 55; // BKB
2323
data.sub_shield = 0; // shield damage modifier
24-
data.lr_check = smash2::app::AttackLRCheck::Pos; // always allow reverse hit
24+
data.lr_check = smash_rs::app::AttackLRCheck::Pos; // always allow reverse hit
2525
}
2626
if (*boma).is_status(*FIGHTER_STATUS_KIND_SLIP_STAND_ATTACK) {
2727
data.power = 5.0;
2828
data.vector = 361;
2929
data.r_eff = 50;
3030
data.r_add = 55;
3131
data.sub_shield = 0;
32-
data.lr_check = smash2::app::AttackLRCheck::Pos;
32+
data.lr_check = smash_rs::app::AttackLRCheck::Pos;
3333
}
3434
if (*boma).is_status(*FIGHTER_STATUS_KIND_CLIFF_ATTACK) {
3535
data.power = 8.0;
3636
data.vector = 361;
3737
data.r_eff = 50;
3838
data.r_add = 45;
3939
data.sub_shield = 0;
40-
data.lr_check = smash2::app::AttackLRCheck::Pos;
40+
data.lr_check = smash_rs::app::AttackLRCheck::Pos;
4141
}
4242
if (*boma).is_status(*FIGHTER_STATUS_KIND_CATCH_ATTACK) {
4343
if !VarModule::is_flag((*boma).object(), vars::common::status::PUMMEL_OVERRIDE_GLOBAL_STATS) {
4444
data.stop_frame = 3.5; // hitlag mul
4545
}
4646
}
4747
}
48-
48+
4949
call_original!(module, id, group, data)
5050
}
5151

fighters/common/src/function_hooks/mod.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ 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;
29+
mod vtables;
3030

3131
#[repr(C)]
3232
pub struct TempModule {
@@ -362,7 +362,7 @@ unsafe fn before_collision(object: *mut BattleObject) {
362362
app::lua_bind::KineticEnergyNormal::set_speed(damage_energy, &vec2);
363363
}
364364
}
365-
365+
366366
// </HDR>
367367

368368
let func_addr = (skyline::hooks::getRegionAddress(skyline::hooks::Region::Text) as *mut u8).add(0x6212f0);
@@ -384,7 +384,7 @@ unsafe fn before_collision(object: *mut BattleObject) {
384384
let damage_speed_x = KineticModule::get_sum_speed_x(boma, *KINETIC_ENERGY_RESERVE_ATTRIBUTE_DAMAGE);
385385
let mut jostle_energy = KineticModule::get_energy(boma, *FIGHTER_KINETIC_ENERGY_ID_JOSTLE) as *mut app::KineticEnergy;
386386
let jostle_energy_x = app::lua_bind::KineticEnergy::get_speed_x(jostle_energy);
387-
387+
388388
if jostle_energy_x != 0.0
389389
&& (main_speed_x + damage_speed_x).abs() < jostle_energy_x.abs() {
390390
// This check passes if the speed at which your character is moving due to general movement
@@ -622,28 +622,28 @@ unsafe fn after_collision(object: *mut BattleObject) {
622622
{
623623
WorkModule::set_int(boma, 0, *FIGHTER_INSTANCE_WORK_ID_INT_FRAME_IN_AIR);
624624
}
625-
625+
626626
// No need to check for motion kind changes if we are:
627627
// 1. Not currently detecting surface collision
628628
// 2. Neither on the ground nor in the air
629629
if GroundModule::get_correct(boma) != *GROUND_CORRECT_KIND_NONE
630630
&& [*SITUATION_KIND_GROUND, *SITUATION_KIND_AIR].contains(&StatusModule::situation_kind(boma))
631631
&& [*SITUATION_KIND_GROUND, *SITUATION_KIND_AIR].contains(&StatusModule::prev_situation_kind(boma))
632632
{
633-
633+
634634
let ground_module = *(boma as *mut BattleObjectModuleAccessor as *const u64).add(0x58 / 8);
635635
let ground_collision_info = *((ground_module + 0x28) as *mut *mut f32);
636-
636+
637637
let prev_collision_line_up = ((ground_collision_info as u64) + 0x190) as *mut GroundCollisionLine;
638638
let prev_collision_line_left = ((ground_collision_info as u64) + 0x1c0) as *mut GroundCollisionLine;
639639
let prev_collision_line_right = ((ground_collision_info as u64) + 0x1f0) as *mut GroundCollisionLine;
640640
let prev_collision_line_down = ((ground_collision_info as u64) + 0x220) as *mut GroundCollisionLine;
641-
641+
642642
let collision_line_up = ((ground_collision_info as u64) + 0x10) as *mut GroundCollisionLine;
643643
let collision_line_left = ((ground_collision_info as u64) + 0x40) as *mut GroundCollisionLine;
644644
let collision_line_right = ((ground_collision_info as u64) + 0x70) as *mut GroundCollisionLine;
645645
let collision_line_down = ((ground_collision_info as u64) + 0xa0) as *mut GroundCollisionLine;
646-
646+
647647
// This check passes only on the first frame you come into contact with/leave a surface (ground/wall/ceiling)
648648
// except when jumping, as the game already changes motion earlier on
649649
if ( (*(prev_collision_line_up as *mut u64) == 0 && *(collision_line_up as *mut u64) != 0)
@@ -759,18 +759,18 @@ pub fn install() {
759759
collision::install();
760760
camera::install();
761761
shotos::install();
762-
aura::install();
763762
sound::install();
764763
fighterspecializer::install();
765764
fighter_util::install();
765+
vtables::install();
766766

767767
unsafe {
768768
// Handles getting rid of the kill zoom
769769
const KILL_ZOOM_DATA: u32 = 0xD503201Fu32;
770770
skyline::patching::Patch::in_text(utils::offsets::kill_zoom_regular()).nop();
771771
skyline::patching::Patch::in_text(utils::offsets::kill_zoom_throw()).data(KILL_ZOOM_DATA);
772772
// Changes full hops to calculate vertical velocity identically to short hops
773-
skyline::patching::Patch::in_text(0x6d21a8).data(0x52800015u32);
773+
skyline::patching::Patch::in_text(0x6d21a8).data(0x52800015u32);
774774

775775
// removes phantoms
776776
skyline::patching::Patch::in_text(0x3e6d08).data(0x14000012u32);
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+
}

0 commit comments

Comments
 (0)