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

tr1/lara/cheat: reset meshes in fly cheat #2571

Merged
merged 1 commit into from
Mar 2, 2025
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions docs/tr1/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- fixed several instances of the camera going out of bounds (#1034)
- fixed the bear AI fix option being applied in the Vilcabamba demo (#2559, regression from 4.8)
- fixed extremely large item quantities crashing the game (#2497, regression from 0.3)
- fixed Lara's meshes not resetting after using the fly cheat (#2565, #2572, regressions from 4.8)

## [4.8.3](https://github.com/LostArtefacts/TRX/compare/tr1-4.8.2...tr1-4.8.3) - 2025-02-17
- fixed some of Lara's speech in the gym not playing in response to player action (#2514, regression from 4.8)
Expand Down
7 changes: 7 additions & 0 deletions src/tr1/game/lara/cheat.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ bool Lara_Cheat_EnterFlyMode(void)
return false;
}

g_Lara.request_gun_type = LGT_UNARMED;
if (g_LaraItem->hit_points <= 0) {
g_Lara.gun_status = LGS_ARMLESS;
Lara_InitialiseMeshes(GF_GetCurrentLevel());
}

if (g_Lara.water_status != LWS_UNDERWATER || g_LaraItem->hit_points <= 0) {
g_LaraItem->pos.y -= STEP_L;
g_LaraItem->current_anim_state = LS_SWIM;
Expand Down Expand Up @@ -193,6 +199,7 @@ bool Lara_Cheat_ExitFlyMode(void)
g_Lara.torso_rot.y = 0;
}
g_Lara.gun_status = LGS_ARMLESS;
Lara_InitialiseMeshes(GF_GetCurrentLevel());
Console_Log(GS(OSD_FLY_MODE_OFF));
return true;
}
Expand Down
42 changes: 26 additions & 16 deletions src/tr1/game/lara/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,31 +655,41 @@ void Lara_RevertToPistolsIfNeeded(void)
void Lara_InitialiseMeshes(const GF_LEVEL *const level)
{
const RESUME_INFO *const resume = Savegame_GetCurrentInfo(level);

if (resume != nullptr && resume->flags.costume) {
for (LARA_MESH mesh = LM_FIRST; mesh < LM_NUMBER_OF; mesh++) {
Lara_SwapSingleMesh(mesh, mesh == LM_HEAD ? O_LARA : O_LARA_EXTRA);
}
return;
}
const bool use_costume = resume != nullptr && resume->flags.costume
&& Object_Get(O_LARA_EXTRA)->loaded;

for (LARA_MESH mesh = LM_FIRST; mesh < LM_NUMBER_OF; mesh++) {
Lara_SwapSingleMesh(mesh, O_LARA);
Lara_SwapSingleMesh(
mesh, mesh == LM_HEAD || !use_costume ? O_LARA : O_LARA_EXTRA);
}

LARA_GUN_TYPE holsters_gun_type =
resume != nullptr ? resume->holsters_gun_type : LGT_UNKNOWN;
LARA_GUN_TYPE back_gun_type =
resume != nullptr ? resume->back_gun_type : LGT_UNKNOWN;
LARA_GUN_TYPE back_gun_type = g_Lara.back_gun_type;
LARA_GUN_TYPE holsters_gun_type = g_Lara.holsters_gun_type;

if (holsters_gun_type != LGT_UNKNOWN) {
Gun_SetLaraHolsterLMesh(holsters_gun_type);
Gun_SetLaraHolsterRMesh(holsters_gun_type);
if (back_gun_type == LGT_UNARMED && Inv_RequestItem(O_SHOTGUN_ITEM)) {
back_gun_type = LGT_SHOTGUN;
}

if (back_gun_type != LGT_UNKNOWN) {
if (holsters_gun_type == LGT_UNARMED) {
if (g_Lara.gun_type != LGT_UNARMED && g_Lara.gun_type != LGT_SHOTGUN) {
holsters_gun_type = g_Lara.gun_type;
} else if (Inv_RequestItem(O_PISTOL_ITEM)) {
holsters_gun_type = LGT_PISTOLS;
} else if (Inv_RequestItem(O_MAGNUM_ITEM)) {
holsters_gun_type = LGT_MAGNUMS;
} else if (Inv_RequestItem(O_UZI_ITEM)) {
holsters_gun_type = LGT_UZIS;
}
}

if (back_gun_type != LGT_UNARMED && back_gun_type != LGT_UNKNOWN) {
Gun_SetLaraBackMesh(back_gun_type);
}

if (holsters_gun_type != LGT_UNARMED && holsters_gun_type != LGT_UNKNOWN) {
Gun_SetLaraHolsterLMesh(holsters_gun_type);
Gun_SetLaraHolsterRMesh(holsters_gun_type);
}
}

bool Lara_IsNearItem(const XYZ_32 *pos, int32_t distance)
Expand Down
1 change: 0 additions & 1 deletion src/tr1/game/savegame/savegame.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ void Savegame_PersistGameToCurrentInfo(const GF_LEVEL *const level)

current->lara_hitpoints = g_LaraItem->hit_points;
current->flags.available = 1;
current->flags.costume = 0;

current->pistol_ammo = 1000;
if (Inv_RequestItem(O_PISTOL_ITEM)) {
Expand Down