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

Commit

Permalink
lara_cheat: amend teleporting approach (#223)
Browse files Browse the repository at this point in the history
This changes the animation reset to only occur if Lara is in an extra
animation, therefore allowing any other regular in-game animations to
complete normally after teleporting.

Resolves #222.
  • Loading branch information
lahm86 authored Sep 9, 2024
1 parent 57469f0 commit 3e735f1
Showing 1 changed file with 34 additions and 39 deletions.
73 changes: 34 additions & 39 deletions src/game/lara/lara_cheat.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,15 @@
static void Lara_Cheat_GiveAllGunsImpl(void);
static void Lara_Cheat_GiveAllMedpacksImpl(void);
static void Lara_Cheat_GiveAllKeysImpl(void);
static bool Lara_Cheat_HasFlare(void);
static void Lara_Cheat_ReinitialiseGunMeshes(bool has_flare);
static void Lara_Cheat_ReinitialiseGunMeshes(void);

static bool Lara_Cheat_HasFlare(void)
static void Lara_Cheat_ReinitialiseGunMeshes(void)
{
// TODO: consider refactoring flare check once more is known about overall
// flare control.
return g_Lara.mesh_ptrs[LM_HAND_L]
const bool has_flare = g_Lara.mesh_ptrs[LM_HAND_L]
== g_Meshes[g_Objects[O_LARA_FLARE].mesh_idx + LM_HAND_L];
}

static void Lara_Cheat_ReinitialiseGunMeshes(const bool has_flare)
{
Lara_InitialiseMeshes(g_CurrentLevel);
Gun_InitialiseNewWeapon();
if (has_flare) {
Expand Down Expand Up @@ -95,7 +91,6 @@ bool __cdecl Lara_Cheat_EnterFlyMode(void)
return false;
}

const bool has_flare = Lara_Cheat_HasFlare();
Lara_GetOffVehicle();

if (g_Lara.water_status != LWS_UNDERWATER || g_LaraItem->hit_points <= 0) {
Expand Down Expand Up @@ -124,7 +119,7 @@ bool __cdecl Lara_Cheat_EnterFlyMode(void)
g_Lara.mesh_effects = 0;
g_Lara.extra_anim = 0;

Lara_Cheat_ReinitialiseGunMeshes(has_flare);
Lara_Cheat_ReinitialiseGunMeshes();
g_Camera.type = CAM_CHASE;
Output_AlterFOV(GAME_FOV * PHD_DEGREE);

Expand All @@ -138,8 +133,6 @@ bool __cdecl Lara_Cheat_ExitFlyMode(void)
return false;
}

const bool has_flare = Lara_Cheat_HasFlare();

const ROOM_INFO *const room = &g_Rooms[g_LaraItem->room_num];
const bool room_submerged = (room->flags & RF_UNDERWATER) != 0;
const int16_t water_height = Room_GetWaterHeight(
Expand All @@ -166,7 +159,7 @@ bool __cdecl Lara_Cheat_ExitFlyMode(void)
g_Lara.gun_status = LGS_ARMLESS;
}

Lara_Cheat_ReinitialiseGunMeshes(has_flare);
Lara_Cheat_ReinitialiseGunMeshes();

Console_Log(GS(OSD_FLY_MODE_OFF));
return true;
Expand Down Expand Up @@ -352,34 +345,38 @@ bool Lara_Cheat_Teleport(int32_t x, int32_t y, int32_t z)
g_Lara.gun_status = LGS_ARMLESS;
}

const bool has_flare = Lara_Cheat_HasFlare();
Lara_GetOffVehicle();

const ROOM_INFO *const room = &g_Rooms[g_LaraItem->room_num];
const bool room_submerged = (room->flags & RF_UNDERWATER) != 0;
const int16_t water_height = Room_GetWaterHeight(
g_LaraItem->pos.x, g_LaraItem->pos.y, g_LaraItem->pos.z,
g_LaraItem->room_num);
if (g_Lara.extra_anim) {
const ROOM_INFO *const room = &g_Rooms[g_LaraItem->room_num];
const bool room_submerged = (room->flags & RF_UNDERWATER) != 0;
const int16_t water_height = Room_GetWaterHeight(
g_LaraItem->pos.x, g_LaraItem->pos.y, g_LaraItem->pos.z,
g_LaraItem->room_num);

if (room_submerged || (water_height != NO_HEIGHT && water_height > 0)) {
g_Lara.water_status = LWS_UNDERWATER;
g_LaraItem->current_anim_state = LS_SWIM;
g_LaraItem->goal_anim_state = LS_SWIM;
g_LaraItem->anim_num =
g_Objects[O_LARA].anim_idx + LA_UNDERWATER_SWIM_FORWARD_DRIFT;
g_LaraItem->frame_num = g_Anims[g_LaraItem->anim_num].frame_base;
} else {
g_Lara.water_status = LWS_ABOVE_WATER;
g_LaraItem->current_anim_state = LS_STOP;
g_LaraItem->goal_anim_state = LS_STOP;
g_LaraItem->anim_num = g_Objects[O_LARA].anim_idx + LA_STAND_STILL;
g_LaraItem->frame_num = g_Anims[g_LaraItem->anim_num].frame_base;
g_LaraItem->rot.x = 0;
g_LaraItem->rot.z = 0;
g_Lara.head_x_rot = 0;
g_Lara.head_y_rot = 0;
g_Lara.torso_x_rot = 0;
g_Lara.torso_y_rot = 0;
}

if (room_submerged || (water_height != NO_HEIGHT && water_height > 0)) {
g_Lara.water_status = LWS_UNDERWATER;
g_LaraItem->current_anim_state = LS_SWIM;
g_LaraItem->goal_anim_state = LS_SWIM;
g_LaraItem->anim_num =
g_Objects[O_LARA].anim_idx + LA_UNDERWATER_SWIM_FORWARD_DRIFT;
g_LaraItem->frame_num = g_Anims[g_LaraItem->anim_num].frame_base;
} else {
g_Lara.water_status = LWS_ABOVE_WATER;
g_LaraItem->current_anim_state = LS_STOP;
g_LaraItem->goal_anim_state = LS_STOP;
g_LaraItem->anim_num = g_Objects[O_LARA].anim_idx + LA_STAND_STILL;
g_LaraItem->frame_num = g_Anims[g_LaraItem->anim_num].frame_base;
g_LaraItem->rot.x = 0;
g_LaraItem->rot.z = 0;
g_Lara.head_x_rot = 0;
g_Lara.head_y_rot = 0;
g_Lara.torso_x_rot = 0;
g_Lara.torso_y_rot = 0;
g_Lara.extra_anim = 0;
Lara_Cheat_ReinitialiseGunMeshes();
}

g_Lara.spaz_effect_count = 0;
Expand All @@ -389,9 +386,7 @@ bool Lara_Cheat_Teleport(int32_t x, int32_t y, int32_t z)
g_Lara.air = LARA_MAX_AIR;
g_Lara.death_timer = 0;
g_Lara.mesh_effects = 0;
g_Lara.extra_anim = 0;

Lara_Cheat_ReinitialiseGunMeshes(has_flare);
g_Camera.type = CAM_CHASE;
Output_AlterFOV(GAME_FOV * PHD_DEGREE);

Expand Down

0 comments on commit 3e735f1

Please sign in to comment.