From 739d563b46df76a6c87fb0813cc69b6ec51959c8 Mon Sep 17 00:00:00 2001 From: UltiNaruto Date: Thu, 30 Nov 2023 23:25:22 +0100 Subject: [PATCH] Reset pitch angle when unmorphing --- Source/Core/Core/PrimeHack/AddressDBInit.cpp | 9 ++++--- .../Core/Core/PrimeHack/Mods/FpsControls.cpp | 24 +++++++++++++++++-- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Source/Core/Core/PrimeHack/AddressDBInit.cpp b/Source/Core/Core/PrimeHack/AddressDBInit.cpp index 5af117f5c1a6..9f761eda23cf 100644 --- a/Source/Core/Core/PrimeHack/AddressDBInit.cpp +++ b/Source/Core/Core/PrimeHack/AddressDBInit.cpp @@ -29,6 +29,7 @@ void init_db(AddressDB& addr_db) { addr_db.register_dynamic_address(Game::PRIME_1, "firstperson_pitch", "player", {mrt1(0x3dc)}); addr_db.register_dynamic_address(Game::PRIME_1, "angular_momentum", "player", {mrt1(0x118)}); addr_db.register_dynamic_address(Game::PRIME_1, "angular_vel", "player", {mrt1(0x154)}); + addr_db.register_dynamic_address(Game::PRIME_1, "camera_state", "player", {mrt1(0x2f0)}); addr_db.register_dynamic_address(Game::PRIME_1, "ball_state", "player", {mrt1(0x2f4)}); addr_db.register_dynamic_address(Game::PRIME_1, "orbit_state", "player", {mrt1(0x300)}); addr_db.register_dynamic_address(Game::PRIME_1, "lockon_state", "state_manager", {mrt1(0xc93)}); @@ -77,8 +78,8 @@ void init_db(AddressDB& addr_db) { addr_db.register_address(Game::PRIME_1_GCN_R1, "fov_tp_offset", -0x7fec); addr_db.register_address(Game::PRIME_1_GCN_R1, "gun_pos", 0x8045bec8); // [r13-5ecc]+4c addr_db.register_address(Game::PRIME_1_GCN_R1, "tweak_player", 0x8045c3e8); - addr_db.register_address(Game::PRIME_1_GCN_R2, "grapple_swing_speed_offset", 0x2b0); - addr_db.register_address(Game::PRIME_1_GCN_R1, "crosshair_color", 0x8045b698); // [r13 - 5ec0]+1c0 + addr_db.register_address(Game::PRIME_1_GCN_R1, "grapple_swing_speed_offset", 0x2b0); + addr_db.register_address(Game::PRIME_1_GCN_R1, "crosshair_color", 0x8045b858); // [r13 - 5ec0]+1c0 addr_db.register_address(Game::PRIME_1_GCN_R1, "transform_offset", 0x34); addr_db.register_dynamic_address(Game::PRIME_1_GCN_R1, "world", "state_manager", {mrt1(0x850), rt0}); addr_db.register_dynamic_address(Game::PRIME_1_GCN_R1, "player", "state_manager", {mrt1(0x84c), rt0}); @@ -149,7 +150,8 @@ void init_db(AddressDB& addr_db) { addr_db.register_dynamic_address(Game::PRIME_2, "angular_momentum", "player", {mrt1(0x178)}); addr_db.register_dynamic_address(Game::PRIME_2, "firstperson_pitch", "player", {mrt1(0x5f0)}); addr_db.register_dynamic_address(Game::PRIME_2, "armcannon_matrix", "player", {mrt1(0xea8), mrt1(0x3b0)}); - addr_db.register_dynamic_address(Game::PRIME_2, "ball_state", "player", {mrt1(0x374)}); + addr_db.register_dynamic_address(Game::PRIME_2, "camera_state", "player", {mrt1(0x374)}); + addr_db.register_dynamic_address(Game::PRIME_2, "ball_state", "player", {mrt1(0x378)}); addr_db.register_dynamic_address(Game::PRIME_2, "powerups_array", "player", {mrt1(0x12ec), rt0}); addr_db.register_dynamic_address(Game::PRIME_2, "active_visor", "powerups_array", {mrt1(0x34)}); addr_db.register_dynamic_address(Game::PRIME_2, "world_id", "world_id_ptr", {rt0, rt0}); @@ -176,6 +178,7 @@ void init_db(AddressDB& addr_db) { addr_db.register_dynamic_address(Game::PRIME_2_GCN, "player_xf", "player", {mrt1(0x24)}); addr_db.register_dynamic_address(Game::PRIME_2_GCN, "orbit_state", "player", {mrt1(0x3a4)}); addr_db.register_dynamic_address(Game::PRIME_2_GCN, "firstperson_pitch", "player", {mrt1(0x604)}); + addr_db.register_dynamic_address(Game::PRIME_2_GCN, "camera_state", "player", {mrt1(0x388)}); addr_db.register_dynamic_address(Game::PRIME_2_GCN, "ball_state", "player", {mrt1(0x38c)}); addr_db.register_dynamic_address(Game::PRIME_2_GCN, "angular_vel", "player", {mrt1(0x1bc)}); addr_db.register_dynamic_address(Game::PRIME_2_GCN, "world_id", "world", {mrt1(0x8)}); diff --git a/Source/Core/Core/PrimeHack/Mods/FpsControls.cpp b/Source/Core/Core/PrimeHack/Mods/FpsControls.cpp index a8cc07f4e892..53923f2ab0c8 100644 --- a/Source/Core/Core/PrimeHack/Mods/FpsControls.cpp +++ b/Source/Core/Core/PrimeHack/Mods/FpsControls.cpp @@ -393,6 +393,7 @@ void FpsControls::run_mod_mp1_gc(Region region) { if (read32(camera_state) != 0) { vec3 fwd = cplayer_xf.fwd(); yaw = atan2f(fwd.y, fwd.x); + pitch = 0.f; return; } @@ -487,6 +488,12 @@ void FpsControls::run_mod_mp2(Region region) { write32(0, cursor + 0x9c); write32(0, cursor + 0x15c); + LOOKUP_DYN(camera_state); + if (read32(camera_state) != 0) { + pitch = 0.f; + return; + } + calculate_pitch_delta(); // Grab the arm cannon address, go to its transform field (NOT the // Actor's xf @ 0x30!!) @@ -566,6 +573,14 @@ void FpsControls::run_mod_mp2_gc(Region region) { return; } + LOOKUP_DYN(camera_state); + if (read32(camera_state) != 0) { + vec3 fwd = cplayer_xf.fwd(); + yaw = atan2f(fwd.y, fwd.x); + pitch = 0.f; + return; + } + LOOKUP(tweak_player_offset); const u32 tweak_player_address = read32(read32(GPR(13) + tweak_player_offset)); if (mem_check(tweak_player_address)) { @@ -581,8 +596,7 @@ void FpsControls::run_mod_mp2_gc(Region region) { } } - LOOKUP_DYN(ball_state); - if (read32(ball_state) == 0) { + if (read32(camera_state) == 0) { calculate_pitchyaw_delta(); writef32(FpsControls::pitch, firstperson_pitch); cplayer_xf.build_rotation(yaw); @@ -787,6 +801,12 @@ void FpsControls::run_mod_mp3(Game active_game, Region active_region) { mp3_handle_cursor(true, true); set_cursor_pos(0, 0); + LOOKUP_DYN(camera_manager); + if (read16(camera_manager) > 3) { + pitch = 0.f; + return; + } + calculate_pitch_delta(); // Gun damping uses its own TOC value, so screw it (I checked the binary) // Byte pattern to find the offset : c0?2???? ec23082a fc60f850