Skip to content

Commit

Permalink
console/cmd: make /heal extinguish Lara
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Sep 19, 2024
1 parent 651ba88 commit 2425e46
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- fixed Bacon Lara re-spawning after saving and loading (#1500, regression from 0.7)
- fixed config JSON not sanitizing some numeric values (#1515)
- fixed potential crashes in custom levels if hybrid creature objects are not present in the level (#1444)
- changed `/heal` console command to also extinguish Lara
- changed `/tp` console command to look for the closest place to teleport to when targeting items (#1484)
- changed `/set` console command output to always use fully-qualified option names
- changed `/fps`, `/vsync`, `/wireframe`, `/braid` and `/cheats` console commands output to be in line with `/set` console command output
Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ sources = [
'src/game/lara/lara_look.c',
'src/game/lara/lara_misc.c',
'src/game/lara/lara_state.c',
'src/game/lara/misc.c',
'src/game/level.c',
'src/game/los.c',
'src/game/lot.c',
Expand Down
26 changes: 2 additions & 24 deletions src/game/console_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "global/vars.h"

#include <libtrx/game/console/commands/config.h>
#include <libtrx/game/console/commands/heal.h>
#include <libtrx/game/console/commands/pos.h>
#include <libtrx/game/console/commands/set_health.h>
#include <libtrx/game/console/common.h>
Expand All @@ -41,7 +42,6 @@ static COMMAND_RESULT Console_Cmd_Wireframe(const char *const args);
static COMMAND_RESULT Console_Cmd_Braid(const char *const args);
static COMMAND_RESULT Console_Cmd_Cheats(const char *const args);
static COMMAND_RESULT Console_Cmd_Teleport(const char *const args);
static COMMAND_RESULT Console_Cmd_Heal(const char *const args);
static COMMAND_RESULT Console_Cmd_Fly(const char *const args);
static COMMAND_RESULT Console_Cmd_Speed(const char *const args);
static COMMAND_RESULT Console_Cmd_GiveItem(const char *args);
Expand Down Expand Up @@ -220,28 +220,6 @@ static COMMAND_RESULT Console_Cmd_Teleport(const char *const args)
return CR_BAD_INVOCATION;
}

static COMMAND_RESULT Console_Cmd_Heal(const char *const args)
{
if (g_GameInfo.current_level_type == GFL_TITLE
|| g_GameInfo.current_level_type == GFL_DEMO
|| g_GameInfo.current_level_type == GFL_CUTSCENE) {
return CR_UNAVAILABLE;
}

if (!g_Objects[O_LARA].loaded) {
return CR_UNAVAILABLE;
}

if (g_LaraItem->hit_points == LARA_MAX_HITPOINTS) {
Console_Log(GS(OSD_HEAL_ALREADY_FULL_HP));
return CR_SUCCESS;
}

g_LaraItem->hit_points = LARA_MAX_HITPOINTS;
Console_Log(GS(OSD_HEAL_SUCCESS));
return CR_SUCCESS;
}

static COMMAND_RESULT Console_Cmd_Fly(const char *const args)
{
if (g_GameInfo.current_level_type == GFL_TITLE
Expand Down Expand Up @@ -604,7 +582,6 @@ CONSOLE_COMMAND *g_ConsoleCommands[] = {
&(CONSOLE_COMMAND) { .prefix = "braid", .proc = Console_Cmd_Braid },
&(CONSOLE_COMMAND) { .prefix = "cheats", .proc = Console_Cmd_Cheats },
&(CONSOLE_COMMAND) { .prefix = "tp", .proc = Console_Cmd_Teleport },
&(CONSOLE_COMMAND) { .prefix = "heal", .proc = Console_Cmd_Heal },
&(CONSOLE_COMMAND) { .prefix = "fly", .proc = Console_Cmd_Fly },
&(CONSOLE_COMMAND) { .prefix = "speed", .proc = Console_Cmd_Speed },
&(CONSOLE_COMMAND) { .prefix = "give", .proc = Console_Cmd_GiveItem },
Expand All @@ -624,6 +601,7 @@ CONSOLE_COMMAND *g_ConsoleCommands[] = {
&(CONSOLE_COMMAND) { .prefix = "natlastinks",
.proc = Console_Cmd_Abortion },
&g_Console_Cmd_Pos,
&g_Console_Cmd_Heal,
&g_Console_Cmd_SetHealth,
&g_Console_Cmd_Config,
NULL,
Expand Down
18 changes: 18 additions & 0 deletions src/game/lara/misc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "game/effects.h"

#include <libtrx/game/lara/misc.h>

void Lara_Extinguish(void)
{
// put out flame objects
int16_t fx_num = g_NextFxActive;
while (fx_num != NO_ITEM) {
FX_INFO *const fx = &g_Effects[fx_num];
const int16_t next_fx_num = fx->next_active;
if (fx->object_id == O_FLAME && fx->counter < 0) {
fx->counter = 0;
Effect_Kill(fx_num);
}
fx_num = next_fx_num;
}
}

0 comments on commit 2425e46

Please sign in to comment.