Skip to content

Commit

Permalink
Reset pitch angle when unmorphing
Browse files Browse the repository at this point in the history
  • Loading branch information
UltiNaruto committed Nov 30, 2023
1 parent c11cc91 commit 739d563
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
9 changes: 6 additions & 3 deletions Source/Core/Core/PrimeHack/AddressDBInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)});
Expand Down Expand Up @@ -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});
Expand Down Expand Up @@ -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});
Expand All @@ -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)});
Expand Down
24 changes: 22 additions & 2 deletions Source/Core/Core/PrimeHack/Mods/FpsControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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!!)
Expand Down Expand Up @@ -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)) {
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 739d563

Please sign in to comment.