Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suicide pact with wuboy #2266

Merged
merged 7 commits into from
Feb 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dynamic/src/util.rs
Original file line number Diff line number Diff line change
@@ -234,13 +234,13 @@ pub fn get_game_state() -> *const u64 {

pub unsafe fn get_mapped_controller_inputs_from_id(player: usize) -> &'static MappedInputs {
let base = *((skyline::hooks::getRegionAddress(skyline::hooks::Region::Text) as *mut u8)
.add(0x52c30f0) as *const u64);
.add(0x52c50f0) as *const u64);
&*((base + 0x2b8 + 0x8 * (player as u64)) as *const MappedInputs)
}

pub unsafe fn get_controller_mapping_from_id(player: usize) -> &'static ControllerMapping {
let base = *((skyline::hooks::getRegionAddress(skyline::hooks::Region::Text) as *mut u8)
.add(0x52c30f0) as *const u64);
.add(0x52c50f0) as *const u64);
&*((base + 0x18) as *const ControllerMapping).add(player as usize)
}

@@ -252,7 +252,7 @@ struct SomeControllerStruct {

pub unsafe fn get_controller_from_id(player: usize) -> &'static Controller {
let base = *((skyline::hooks::getRegionAddress(skyline::hooks::Region::Text) as *mut u8)
.add(0x5337860) as *const u64);
.add(0x5339860) as *const u64);
let uVar3 = *((base + 0x298 + (4 * (player as u64))) as *const u32);
let controller_struct = ((base + (0x8 * (uVar3 as i32)) as u64) as *mut SomeControllerStruct);
(*controller_struct).controller
45 changes: 0 additions & 45 deletions fighters/build.rs

This file was deleted.

4 changes: 2 additions & 2 deletions fighters/common/src/function_hooks/attack.rs
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ use std::arch::asm;
use utils::game_modes::CustomMode;


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

@@ -50,7 +50,7 @@ unsafe fn attack_module_set_attack(module: u64, id: i32, group: i32, data: &mut
call_original!(module, id, group, data)
}

#[skyline::hook(offset = 0x403c1c, inline)]
#[skyline::hook(offset = 0x403c3c, inline)]
unsafe fn get_damage_frame_mul(ctx: &mut skyline::hooks::InlineCtx) {
match utils::game_modes::get_custom_mode() {
Some(modes) => {
12 changes: 6 additions & 6 deletions fighters/common/src/function_hooks/aura.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ use super::*;
use utils::ext::*;
use std::arch::asm;

#[skyline::hook(offset = 0xc5bff0)]
#[skyline::hook(offset = 0xc5c010)]
pub unsafe extern "C" fn lucario_check_aura(module_accessor: *mut BattleObjectModuleAccessor) -> f32 {
if WorkModule::get_int(module_accessor, *FIGHTER_INSTANCE_WORK_ID_INT_ENTRY_ID) > 7 {
std::process::abort();
@@ -11,7 +11,7 @@ pub unsafe extern "C" fn lucario_check_aura(module_accessor: *mut BattleObjectMo
get_aura(object)
}

#[skyline::hook(offset = 0xc5be20)]
#[skyline::hook(offset = 0xc5be40)]
pub unsafe extern "C" fn lucario_check_aura2(module: u64) -> f32 {
let module_accessor = &mut *(*((module as *mut u64).offset(1)) as *mut BattleObjectModuleAccessor);
if WorkModule::get_int(module_accessor, *FIGHTER_INSTANCE_WORK_ID_INT_ENTRY_ID) > 7 {
@@ -21,7 +21,7 @@ pub unsafe extern "C" fn lucario_check_aura2(module: u64) -> f32 {
get_aura(object)
}

#[skyline::hook(offset = 0xc5e530)]
#[skyline::hook(offset = 0xc5e550)]
pub unsafe extern "C" fn lucario_handle_aura(_vtable: u64, fighter: &mut Fighter) {
let object = &mut fighter.battle_object;
let module_accessor = object.module_accessor;
@@ -32,7 +32,7 @@ pub unsafe extern "C" fn lucario_handle_aura(_vtable: u64, fighter: &mut Fighter
WorkModule::set_float(module_accessor, aura, *FIGHTER_LUCARIO_INSTANCE_WORK_ID_FLOAT_CURR_AURAPOWER);
}

#[skyline::hook(offset = 0xc5e6d0)]
#[skyline::hook(offset = 0xc5e6f0)]
pub unsafe extern "C" fn lucario_handle_aura2(_vtable: u64, fighter: &mut Fighter) {
let object = &mut fighter.battle_object;
let object_id = object.battle_object_id;
@@ -44,7 +44,7 @@ pub unsafe extern "C" fn lucario_handle_aura2(_vtable: u64, fighter: &mut Fighte
WorkModule::set_float(module_accessor, aura, *FIGHTER_LUCARIO_INSTANCE_WORK_ID_FLOAT_CURR_AURAPOWER);
}

// #[skyline::hook(offset = 0xc5d580)]
// #[skyline::hook(offset = 0xc5d5a0)]
// pub unsafe extern "C" fn lucario_on_grab(_vtable: u64, fighter: &mut Fighter, event: &mut LinkEvent) -> u64 {
// // param_3 + 0x10
// if event.link_event_kind.0 == hash40("capture") {
@@ -98,7 +98,7 @@ unsafe extern "C" fn get_aura(object: *mut BattleObject) -> f32 {
return aura_power;
}

#[skyline::hook(offset = 0xc5ce20)]
#[skyline::hook(offset = 0xc5ce40)]
pub unsafe extern "C" fn lucario_set_effect_scale(vtable: u64, fighter: &mut Fighter) {
original!()(vtable, fighter);
let object = &mut fighter.battle_object;
8 changes: 4 additions & 4 deletions fighters/common/src/function_hooks/camera.rs
Original file line number Diff line number Diff line change
@@ -60,13 +60,13 @@ pub enum QuakeKind {


// Doubles camera speed
#[skyline::hook(offset = 0x4fdbf0)]
#[skyline::hook(offset = 0x4fdc10)]
unsafe fn normal_camera(ptr: u64, float: f32) {
call_original!(ptr, float);
call_original!(ptr, float);
}

#[skyline::hook(offset = 0x26207f0)]
#[skyline::hook(offset = 0x2621470)]
pub fn parse_stprm_active_camera_params(param_obj: u64, params: &mut NormalCameraParams) {
call_original!(param_obj, params);
params.normal_camera_min_distance = params.normal_camera_min_distance.max(140.0);
@@ -78,7 +78,7 @@ pub fn parse_stprm_active_camera_params(param_obj: u64, params: &mut NormalCamer
}

// The following function hook handles Unrestricted Camera
#[skyline::hook(offset = 0x26226b0)]
#[skyline::hook(offset = 0x2623330)]
pub fn parse_stprm_pause_camera_params(param_obj: u64, params: &mut PauseCameraParams) {
call_original!(param_obj, params);
params.pause_camera_min_fov = 4e-44_f32.to_radians();
@@ -99,7 +99,7 @@ pub fn parse_stprm_pause_camera_params(param_obj: u64, params: &mut PauseCameraP
params.pause_camera_gyro_limit_angle_left = 0.0;
}

#[skyline::hook(offset = 0x3ebe00)]
#[skyline::hook(offset = 0x3ebe20)]
unsafe fn camera_module__req_quake(camera_module: *const u64, quake_kind: i32) {
use QuakeKind::*;
let mut quake_kind = std::mem::transmute(quake_kind.clone());
14 changes: 7 additions & 7 deletions fighters/common/src/function_hooks/collision.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ use globals::*;
// Not sure what param_6 is, but when 0, it skips calculations for your ECB's bottom point and just sets it to 0.0, which "locks" your ECB's bottom point to your Top bone
// when 1, it calculates your bottom ECB point normally, like the other 3 points
// Vanilla passes 0 by default, so we have to forcibly pass in 1
#[skyline::hook(offset = 0x45f420)]
#[skyline::hook(offset = 0x45f440)]
unsafe fn ground_module_ecb_point_calc_hook(ground_module: u64, param_1: *mut *mut Hash40, param_2: *mut f32, param_3: *mut f32, param_4: *mut f32, param_5: *mut f32, param_6: u32) {
// The original function calls model_module_joint_global_position_with_offset_hook
let boma = *((ground_module + 0x20) as *mut *mut BattleObjectModuleAccessor);
@@ -76,7 +76,7 @@ unsafe fn ground_module_ecb_point_calc_hook(ground_module: u64, param_1: *mut *m
// This is why your ECB bottom point is always "locked" to your Top bone

// By returning once the Trans bone is passed into this func, we can ignore it and thus use your map_coll_data bones to calculate your bottom ECB point, like the other 3 points
#[skyline::hook(offset = 0x48fc40)]
#[skyline::hook(offset = 0x48fc60)]
unsafe fn model_module_joint_global_position_with_offset_hook(model_module: u64, bone: Hash40, param_3: *mut Vector3f, param_4: *mut Vector3f, param_5: bool) {
let boma = *(model_module as *mut *mut BattleObjectModuleAccessor).add(1);
if (*boma).is_fighter()
@@ -89,13 +89,13 @@ unsafe fn model_module_joint_global_position_with_offset_hook(model_module: u64,
}

// Unused for now
#[skyline::hook(offset = 0x523a60)]
#[skyline::hook(offset = 0x523a80)]
unsafe fn groundcollision__processgroundcollisioninfo(groundcollisioninfo: *mut f32, groundcollision: *mut u64) {
call_original!(groundcollisioninfo, groundcollision)
}

// Performs ground correct/sets situation kind
#[skyline::hook(offset = 0x53fe30)]
#[skyline::hook(offset = 0x53fe50)]
unsafe fn groundcollision__processgroundcollisioninfo_check_landing(groundcollisioninfo: *mut f32, groundcollision: u64) {
let groundcollisionline = *((groundcollision + 0x320) as *mut u64) as *mut GroundCollisionLine;
let groundcollisionline_next = *(groundcollisionline as *mut *mut GroundCollisionLine);
@@ -145,7 +145,7 @@ unsafe fn groundcollision__processgroundcollisioninfo_check_landing(groundcollis
}
}
// Sets GroundCollisionLine
#[skyline::hook(offset = 0x52d900)]
#[skyline::hook(offset = 0x52d920)]
unsafe fn groundcollision__processgroundcollisioninfo_check_landing_sub(groundcollision: u64, arg2: *mut u64, prev_ecb_bottom_pos: *mut smash::phx::Vector2f, ecb_bottom_translation: *mut smash::phx::Vector2f, arg5: u64, arg6: u64, arg7: *mut u64) -> *mut GroundCollisionLine {
if *((groundcollision + 0x39f) as *mut bool) {
// Ignore ground collision
@@ -158,8 +158,8 @@ pub fn install() {
unsafe {
// Removes 0.3 unit leniency above ECB bottom when deciding whether to land
// which reduces frequency of platform cancels
skyline::patching::Patch::in_text(0x540dd8).data(0x529ae148);
skyline::patching::Patch::in_text(0x540ddc).data(0x72a78468);
skyline::patching::Patch::in_text(0x540df8).data(0x529ae148);
skyline::patching::Patch::in_text(0x540dfc).data(0x72a78468);
}
skyline::install_hooks!(
groundcollision__processgroundcollisioninfo_check_landing,
38 changes: 19 additions & 19 deletions fighters/common/src/function_hooks/controls.rs
Original file line number Diff line number Diff line change
@@ -3,12 +3,12 @@ use rand::prelude::SliceRandom;
use rand::Rng;
use utils::ext::*;

#[skyline::hook(offset = 0x16d948c, inline)]
#[skyline::hook(offset = 0x16d85dc, inline)]
unsafe fn packed_packet_creation(ctx: &mut skyline::hooks::InlineCtx) {
*ctx.registers[22].x.as_mut() = 0x2;
}

#[skyline::hook(offset = 0x16d94c0, inline)]
#[skyline::hook(offset = 0x16d8610, inline)]
unsafe fn write_packet(ctx: &mut skyline::hooks::InlineCtx) {
let raw = *ctx.registers[19].x.as_ref();

@@ -927,7 +927,7 @@ struct ControlModuleInternal {
static mut LAST_ALT_STICK: [f32; 2] = [0.0, 0.0];
static mut LAST_ANALOG: f32 = 0.0;

#[skyline::hook(offset = 0x3f7220)]
#[skyline::hook(offset = 0x3f7240)]
unsafe fn parse_inputs(this: &mut ControlModuleInternal) {
const NEUTRAL: f32 = 0.2;
const CLAMP_MAX: f32 = 120.0;
@@ -970,7 +970,7 @@ unsafe fn parse_inputs(this: &mut ControlModuleInternal) {
call_original!(this)
}

#[skyline::hook(offset = 0x6b9c5c, inline)]
#[skyline::hook(offset = 0x6b9c7c, inline)]
unsafe fn after_exec(ctx: &skyline::hooks::InlineCtx) {
let module = *ctx.registers[19].x.as_ref();
let internal_class = *(module as *const u64).add(0x110 / 0x8);
@@ -979,7 +979,7 @@ unsafe fn after_exec(ctx: &skyline::hooks::InlineCtx) {
*(internal_class as *mut f32).add(0x48 / 0x4) = LAST_ANALOG;
}

#[skyline::hook(offset = 0x16d7ee4, inline)]
#[skyline::hook(offset = 0x16d7034, inline)]
unsafe fn handle_incoming_packet(ctx: &mut skyline::hooks::InlineCtx) {
let packet = *ctx.registers[15].x.as_ref();

@@ -1028,7 +1028,7 @@ unsafe extern "C" fn is_throw_stick(fighter: &mut L2CFighterCommon) -> L2CValue
static mut SHOULD_END_RESULT_SCREEN: bool = false;

// Skip results screen with start button
#[skyline::hook(offset = 0x3664040)]
#[skyline::hook(offset = 0x3664CC0)]
unsafe fn process_inputs_handheld(controller: &mut Controller) {
let entry_count = lua_bind::FighterManager::entry_count(utils::singletons::FighterManager());
if lua_bind::FighterManager::is_result_mode(utils::singletons::FighterManager())
@@ -1058,7 +1058,7 @@ unsafe fn process_inputs_handheld(controller: &mut Controller) {

static mut GC_TRIGGERS: [f32; 2] = [0.0, 0.0];

#[skyline::hook(offset = 0x3665e2c, inline)]
#[skyline::hook(offset = 0x3666AAC, inline)]
unsafe fn post_gamecube_process(ctx: &skyline::hooks::InlineCtx) {
let state: *mut skyline::nn::hid::NpadGcState =
(ctx as *const _ as *mut u8).add(0x100) as *mut _;
@@ -1068,7 +1068,7 @@ unsafe fn post_gamecube_process(ctx: &skyline::hooks::InlineCtx) {
GC_TRIGGERS[1] = (*state).RTrigger as f32 / i16::MAX as f32;
}

#[skyline::hook(offset = 0x3665c8c, inline)]
#[skyline::hook(offset = 0x366690C, inline)]
unsafe fn apply_triggers(ctx: &skyline::hooks::InlineCtx) {
let controller: *mut Controller = *ctx.registers[19].x.as_ref() as _;
(*controller).left_trigger = GC_TRIGGERS[0];
@@ -1099,7 +1099,7 @@ unsafe fn analog_trigger_r(ctx: &mut skyline::hooks::InlineCtx) {

// These 2 hooks prevent buffered nair after inputting C-stick on first few frames of jumpsquat
// Both found in ControlModule::exec_command
#[skyline::hook(offset = 0x6be610)]
#[skyline::hook(offset = 0x6be630)]
unsafe fn set_attack_air_stick_hook(control_module: u64, arg: u32) {
// This check passes on the frame FighterControlModuleImpl::reserve_on_attack_button is called
// Only happens during jumpsquat currently
@@ -1111,7 +1111,7 @@ unsafe fn set_attack_air_stick_hook(control_module: u64, arg: u32) {
}
call_original!(control_module, arg);
}
#[skyline::hook(offset = 0x6bd6a4, inline)]
#[skyline::hook(offset = 0x6bd6c4, inline)]
unsafe fn exec_command_reset_attack_air_kind_hook(ctx: &mut skyline::hooks::InlineCtx) {
let control_module = *ctx.registers[21].x.as_ref();
let boma = *(control_module as *mut *mut BattleObjectModuleAccessor).add(1);
@@ -1145,25 +1145,25 @@ fn nro_hook(info: &skyline::nro::NroInfo) {
pub fn install() {
// Custom buffer-state handling
// Always uses the hitlag handling that cat4 uses
skyline::patching::Patch::in_text(0x6bd428).nop();
skyline::patching::Patch::in_text(0x6bd484).nop();
skyline::patching::Patch::in_text(0x6bd448).nop();
skyline::patching::Patch::in_text(0x6bd4a4).nop();

// Stuff for parry input
skyline::patching::Patch::in_text(0x3665e5c).data(0xAA0903EAu32);
skyline::patching::Patch::in_text(0x3665e70).data(0xAA0803EAu32);
skyline::patching::Patch::in_text(0x3666ADC).data(0xAA0903EAu32);
skyline::patching::Patch::in_text(0x3666AF0).data(0xAA0803EAu32);

// Removes 10f C-stick lockout for tilt stick and special stick
skyline::patching::Patch::in_text(0x17527dc).data(0x2A1F03FA);
skyline::patching::Patch::in_text(0x17527e0).nop();
skyline::patching::Patch::in_text(0x17527e4).nop();
skyline::patching::Patch::in_text(0x17527e8).nop();
skyline::patching::Patch::in_text(0x17527b0).nop();
skyline::patching::Patch::in_text(0x17527b4).nop();
skyline::patching::Patch::in_text(0x17527b8).nop();

// Prevents buffered C-stick aerials from triggering nair
skyline::patching::Patch::in_text(0x6be644).data(0x52800040);
skyline::patching::Patch::in_text(0x6be664).data(0x52800040);

// Prevents attack_air_kind from resetting every frame
// Found in ControlModule::exec_command
skyline::patching::Patch::in_text(0x6bd6a4).nop();
skyline::patching::Patch::in_text(0x6bd6c4).nop();

skyline::install_hooks!(
map_controls_hook,
6 changes: 3 additions & 3 deletions fighters/common/src/function_hooks/energy/control.rs
Original file line number Diff line number Diff line change
@@ -96,7 +96,7 @@ impl DerefMut for FighterKineticEnergyControl {
}
}

#[skyline::hook(offset = 0x6d3610)]
#[skyline::hook(offset = 0x6d3630)]
unsafe fn control_update(energy: &mut FighterKineticEnergyControl, boma: &mut BattleObjectModuleAccessor) {
let reset_type = std::mem::transmute(energy.energy_reset_type);

@@ -378,7 +378,7 @@ unsafe fn control_update(energy: &mut FighterKineticEnergyControl, boma: &mut Ba
energy.speed_brake = backup_brake;
}

#[skyline::hook(offset = 0x6d4040)]
#[skyline::hook(offset = 0x6d4060)]
unsafe fn control_initialize(energy: &mut FighterKineticEnergyControl, boma: &mut BattleObjectModuleAccessor) {
use EnergyControllerResetType::*;
let reset_type = std::mem::transmute(energy.energy_reset_type);
@@ -565,7 +565,7 @@ unsafe fn control_initialize(energy: &mut FighterKineticEnergyControl, boma: &mu
}
}

#[skyline::hook(offset = 0x6d4ba0)]
#[skyline::hook(offset = 0x6d4bc0)]
unsafe fn control_setup(energy: &mut FighterKineticEnergyControl, reset_type: EnergyControllerResetType, initial_speed: &Vector3f, unk: u64, boma: &mut BattleObjectModuleAccessor) {
energy.clear_energy();

4 changes: 2 additions & 2 deletions fighters/common/src/function_hooks/energy/mod.rs
Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@ pub struct Vec4 {

impl KineticEnergy {
pub fn adjust_speed_for_ground_normal(speed: &PaddedVec2, boma: &mut BattleObjectModuleAccessor) -> PaddedVec2 {
#[skyline::from_offset(0x47b4d0)]
#[skyline::from_offset(0x47b4f0)]
extern "C" fn adjust_speed_for_ground_normal_internal(speed: Vec2, boma: &mut BattleObjectModuleAccessor) -> Vec2;

unsafe {
@@ -108,7 +108,7 @@ impl KineticEnergy {

pub fn process(&mut self, boma: &mut BattleObjectModuleAccessor) {
unsafe {
#[skyline::from_offset(0x47bf70)]
#[skyline::from_offset(0x47bf90)]
extern "C" fn process_energy(energy: &mut KineticEnergy, boma: &mut BattleObjectModuleAccessor);

process_energy(self, boma)
Loading
Oops, something went wrong.
Loading
Oops, something went wrong.