Skip to content

Commit

Permalink
add DOZY cheat
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Feb 21, 2021
1 parent 32350ed commit 9eb3f6a
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Currently the following configuration options are supported:
- `enable_cheats`: enables various cheats:
- <kbd>F10</kbd>: immediately end the level.
- <kbd>F11</kbd>: heal Lara. Hold <kbd>WALK</kbd> key to hurt instead.
- <kbd>O</kbd>: enable DOZY cheat (swimming midair). Press the
<kbd>WALK</kbd> key to exit.
- `fix_end_of_level_freeze`: fix game freeze when ending the level with the
Action key held.
- `fix_tihocan_secret_sound`: disable the secret sound incorrectly playing
Expand Down
55 changes: 53 additions & 2 deletions src/game/laramisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,32 @@ void __cdecl LaraControl(int16_t item_num)
ROOM_INFO* r = &RoomInfo[item->room_number];
int32_t room_submerged = r->flags & RF_UNDERWATER;

#ifdef TOMB1M_FEAT_CHEATS
if (Lara.water_status != LWS_CHEAT && (Input & IN_DOZYCHEAT)) {
if (Lara.water_status != LWS_UNDERWATER || item->hit_points <= 0) {
item->pos.y -= 0x80;
item->current_anim_state = AS_SWIM;
item->goal_anim_state = AS_SWIM;
item->anim_number = AA_SWIMGLIDE;
item->frame_number = Anims[item->anim_number].frame_base;
item->gravity_status = 0;
item->pos.x_rot = 30 * PHD_DEGREE;
item->fall_speed = 30;
Lara.head_x_rot = 0;
Lara.head_y_rot = 0;
Lara.torso_x_rot = 0;
Lara.torso_y_rot = 0;
}
Lara.water_status = LWS_CHEAT;
Lara.spaz_effect_count = 0;
Lara.spaz_effect = NULL;
Lara.hit_frames = 0;
Lara.hit_direction = -1;
Lara.air = LARA_AIR;
Lara.death_count = 0;
}
#endif

if (Lara.water_status == LWS_ABOVEWATER && room_submerged) {
Lara.water_status = LWS_UNDERWATER;
Lara.air = LARA_AIR;
Expand Down Expand Up @@ -138,6 +164,31 @@ void __cdecl LaraControl(int16_t item_num)
}
LaraSurface(item, &coll);
break;

#ifdef TOMB1M_FEAT_CHEATS
case LWS_CHEAT:
item->hit_points = LARA_HITPOINTS;
Lara.death_count = 0;
LaraUnderWater(item, &coll);
if ((Input & IN_SLOW) && !(Input & IN_LOOK)) {
int16_t wh = GetWaterHeight(
item->pos.x, item->pos.y, item->pos.z, item->room_number);
if (room_submerged || (wh != NO_HEIGHT && wh > 0)) {
Lara.water_status = LWS_UNDERWATER;
} else {
Lara.water_status = LWS_ABOVEWATER;
item->anim_number = AA_STOP;
item->frame_number = Anims[item->anim_number].frame_base;
item->pos.x_rot = item->pos.z_rot = 0;
Lara.head_x_rot = 0;
Lara.head_y_rot = 0;
Lara.torso_x_rot = 0;
Lara.torso_y_rot = 0;
}
Lara.gun_status = LGS_ARMLESS;
}
break;
#endif
}
}

Expand All @@ -147,7 +198,7 @@ void __cdecl LaraSwapMeshExtra()
return;
}
for (int i = 0; i < 15; i++) {
Lara.mesh_ptrs[i] = Meshes[(&Objects[O_LARA_EXTRA])->mesh_index + i];
Lara.mesh_ptrs[i] = Meshes[Objects[O_LARA_EXTRA].mesh_index + i];
}
}

Expand Down Expand Up @@ -355,7 +406,7 @@ void __cdecl InitialiseLara()
Lara.hit_frames = 0;
Lara.hit_direction = 0;
Lara.death_count = 0;
Lara.target = 0;
Lara.target = NULL;
Lara.spaz_effect = 0;
Lara.spaz_effect_count = 0;
Lara.turn_rate = 0;
Expand Down
5 changes: 5 additions & 0 deletions src/game/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define TOMB1MAIN_GAME_TYPES_H

#include "const.h"
#include "util.h"
#include <stdint.h>

typedef int16_t PHD_ANGLE;
Expand Down Expand Up @@ -543,10 +544,14 @@ typedef enum {
IN_SAVE = (1 << 22),
IN_LOAD = (1 << 23),
IN_ACTION_AUTO = (1 << 24),
#ifdef TOMB1M_FEAT_CHEATS
IN_DOZYCHEAT = (1 << 25),
#else
IN_CHEAT = (1 << 25),
IN_D = (1 << 26),
IN_E = (1 << 27),
IN_F = (1 << 28),
#endif
} INPUT_STATE;

typedef enum {
Expand Down
3 changes: 3 additions & 0 deletions src/specific/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ void __cdecl S_UpdateInput()

#ifdef TOMB1M_FEAT_CHEATS
if (Tomb1MConfig.enable_cheats) {
if (KeyData->keymap[DIK_O]) {
linput |= IN_DOZYCHEAT;
}
if (KeyData->keymap[DIK_F10]) {
LevelComplete = 1;
}
Expand Down

0 comments on commit 9eb3f6a

Please sign in to comment.