From c984f369d2e7903ec0cd4c5fa5724aeaa8d571b2 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sat, 21 Sep 2024 12:42:19 +0200 Subject: [PATCH] console/cmd: import /abortion --- include/libtrx/game/console/cmd/die.h | 5 ++++ meson.build | 1 + src/game/console/cmd/die.c | 38 +++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 include/libtrx/game/console/cmd/die.h create mode 100644 src/game/console/cmd/die.c diff --git a/include/libtrx/game/console/cmd/die.h b/include/libtrx/game/console/cmd/die.h new file mode 100644 index 0000000..4c9349f --- /dev/null +++ b/include/libtrx/game/console/cmd/die.h @@ -0,0 +1,5 @@ +#pragma once + +#include "../common.h" + +extern CONSOLE_COMMAND g_Console_Cmd_Die; diff --git a/meson.build b/meson.build index e9a9786..01e40b8 100644 --- a/meson.build +++ b/meson.build @@ -68,6 +68,7 @@ sources = [ 'src/filesystem.c', 'src/game/backpack.c', 'src/game/console/cmd/config.c', + 'src/game/console/cmd/die.c', 'src/game/console/cmd/fly.c', 'src/game/console/cmd/give_item.c', 'src/game/console/cmd/heal.c', diff --git a/src/game/console/cmd/die.c b/src/game/console/cmd/die.c new file mode 100644 index 0000000..1efcaef --- /dev/null +++ b/src/game/console/cmd/die.c @@ -0,0 +1,38 @@ +#include "game/console/cmd/die.h" + +#include "game/effects/exploding_death.h" +#include "game/items.h" +#include "game/lara/common.h" +#include "game/objects/common.h" +#include "game/objects/ids.h" +#include "game/sound.h" + +static COMMAND_RESULT M_Entrypoint(const char *args); + +static COMMAND_RESULT M_Entrypoint(const char *const args) +{ + if (!Object_GetObject(O_LARA)->loaded) { + return CR_UNAVAILABLE; + } + + LARA_INFO *const lara = Lara_GetLaraInfo(); + ITEM_INFO *const lara_item = Lara_GetItem(); + if (lara_item->hit_points <= 0) { + return CR_UNAVAILABLE; + } + + Sound_Effect(SFX_LARA_FALL, &lara_item->pos, SPM_NORMAL); +#if TR_VERSION == 1 + Sound_Effect(SFX_EXPLOSION_CHEAT, &lara_item->pos, SPM_NORMAL); +#endif + Effect_ExplodingDeath(lara->item_num, -1, 1); + + lara_item->hit_points = 0; + lara_item->flags |= IF_INVISIBLE; + return CR_SUCCESS; +} + +CONSOLE_COMMAND g_Console_Cmd_Die = { + .prefix = "abortion|natlastinks", + .proc = M_Entrypoint, +};