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

Commit

Permalink
console/cmd/heal: import
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Sep 19, 2024
1 parent a444a38 commit 39c2d55
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/libtrx/game/console/commands/heal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "../common.h"

extern CONSOLE_COMMAND g_Console_Cmd_Heal;
2 changes: 2 additions & 0 deletions include/libtrx/game/game_string.def
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ GS_DEFINE(OSD_CONFIG_OPTION_SET, "%s changed to %s")
GS_DEFINE(OSD_CONFIG_OPTION_UNKNOWN_OPTION, "Unknown option: %s")
GS_DEFINE(MISC_ON, "On")
GS_DEFINE(MISC_OFF, "Off")
GS_DEFINE(OSD_HEAL_ALREADY_FULL_HP, "Lara's already at full health")
GS_DEFINE(OSD_HEAL_SUCCESS, "Healed Lara back to full health")
3 changes: 3 additions & 0 deletions include/libtrx/game/lara/misc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

void Lara_Extinguish(void);
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ sources = [
'src/enum_str.c',
'src/filesystem.c',
'src/game/console/commands/config.c',
'src/game/console/commands/heal.c',
'src/game/console/commands/pos.c',
'src/game/console/commands/set_health.c',
'src/game/items.c',
Expand Down
29 changes: 29 additions & 0 deletions src/game/console/commands/heal.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "game/console/commands/heal.h"

#include "game/game.h"
#include "game/game_string.h"
#include "game/lara/common.h"
#include "game/lara/misc.h"

static COMMAND_RESULT Console_Cmd_Heal(const char *const args)
{
if (!Game_IsPlayable()) {
return CR_UNAVAILABLE;
}

ITEM_INFO *const lara_item = Lara_GetItem();
if (lara_item->hit_points == LARA_MAX_HITPOINTS) {
Console_Log(GS(OSD_HEAL_ALREADY_FULL_HP));
return CR_SUCCESS;
}

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

CONSOLE_COMMAND g_Console_Cmd_Heal = {
.prefix = "heal",
.proc = Console_Cmd_Heal,
};

0 comments on commit 39c2d55

Please sign in to comment.