From 36d946b2d7fc8de91b657282611b66f4b284fed0 Mon Sep 17 00:00:00 2001 From: lahm86 <33758420+lahm86@users.noreply.github.com> Date: Sun, 15 Sep 2024 13:16:23 +0100 Subject: [PATCH 1/2] lara_cheat: reset gun status after extra anim Part of #237. --- src/game/lara/lara_cheat.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/game/lara/lara_cheat.c b/src/game/lara/lara_cheat.c index f205d142..f00d1299 100644 --- a/src/game/lara/lara_cheat.c +++ b/src/game/lara/lara_cheat.c @@ -26,6 +26,7 @@ static void Lara_Cheat_GiveAllGunsImpl(void); static void Lara_Cheat_GiveAllMedpacksImpl(void); static void Lara_Cheat_GiveAllKeysImpl(void); static void Lara_Cheat_ReinitialiseGunMeshes(void); +static void Lara_Cheat_ResetGunStatus(void); static void Lara_Cheat_ReinitialiseGunMeshes(void) { @@ -79,6 +80,30 @@ static void Lara_Cheat_GiveAllKeysImpl(void) Inv_AddItem(O_PICKUP_ITEM_2); } +static void Lara_Cheat_ResetGunStatus(void) +{ + const bool has_flare = g_Lara.mesh_ptrs[LM_HAND_L] + == g_Meshes[g_Objects[O_LARA_FLARE].mesh_idx + LM_HAND_L]; + if (has_flare) { + g_Lara.gun_type = LGT_FLARE; + return; + } + + g_Lara.gun_status = LGS_ARMLESS; + g_Lara.gun_type = LGT_UNARMED; + g_Lara.request_gun_type = LGT_UNARMED; + g_Lara.weapon_item = NO_ITEM; + g_Lara.gun_status = LGS_ARMLESS; + g_Lara.left_arm.frame_num = 0; + g_Lara.left_arm.lock = 0; + g_Lara.right_arm.frame_num = 0; + g_Lara.right_arm.lock = 0; + g_Lara.left_arm.anim_num = g_LaraItem->anim_num; + g_Lara.right_arm.anim_num = g_LaraItem->anim_num; + g_Lara.left_arm.frame_base = g_Anims[g_LaraItem->anim_num].frame_ptr; + g_Lara.right_arm.frame_base = g_Anims[g_LaraItem->anim_num].frame_ptr; +} + void __cdecl Lara_Cheat_EndLevel(void) { g_LevelComplete = true; @@ -91,6 +116,10 @@ bool __cdecl Lara_Cheat_EnterFlyMode(void) return false; } + if (g_Lara.extra_anim) { + Lara_Cheat_ResetGunStatus(); + } + Lara_GetOffVehicle(); if (g_Lara.water_status != LWS_UNDERWATER || g_LaraItem->hit_points <= 0) { @@ -377,6 +406,7 @@ bool Lara_Cheat_Teleport(int32_t x, int32_t y, int32_t z) } g_Lara.extra_anim = 0; + Lara_Cheat_ResetGunStatus(); Lara_Cheat_ReinitialiseGunMeshes(); } From d89bef906bf98d899911ede238d5d48ec45dc653 Mon Sep 17 00:00:00 2001 From: lahm86 <33758420+lahm86@users.noreply.github.com> Date: Sun, 15 Sep 2024 14:03:51 +0100 Subject: [PATCH 2/2] lara_cheat: adjust fly cheat gun reset This allows the gun undrawing animation to complete fully, avoiding mesh issues if the cheat is exited very quickly. Part of #237. --- src/game/lara/lara_cheat.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/game/lara/lara_cheat.c b/src/game/lara/lara_cheat.c index f00d1299..c91c6336 100644 --- a/src/game/lara/lara_cheat.c +++ b/src/game/lara/lara_cheat.c @@ -187,10 +187,9 @@ bool __cdecl Lara_Cheat_ExitFlyMode(void) g_Lara.gun_status = LGS_UNDRAW; } else { g_Lara.gun_status = LGS_ARMLESS; + Lara_Cheat_ReinitialiseGunMeshes(); } - Lara_Cheat_ReinitialiseGunMeshes(); - Console_Log(GS(OSD_FLY_MODE_OFF)); return true; }