Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

lara_cheat: fix weapon issues #239

Merged
merged 2 commits into from
Sep 19, 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
33 changes: 31 additions & 2 deletions src/game/lara/lara_cheat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -158,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;
}
Expand Down Expand Up @@ -377,6 +405,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();
}

Expand Down