diff --git a/meson.build b/meson.build index f1c21428..25e950e0 100644 --- a/meson.build +++ b/meson.build @@ -96,7 +96,6 @@ dll_sources = [ 'src/game/console/cmd/exit_to_title.c', 'src/game/console/cmd/flipmap.c', 'src/game/console/cmd/fly.c', - 'src/game/console/cmd/kill.c', 'src/game/console/cmd/load_game.c', 'src/game/console/cmd/play_demo.c', 'src/game/console/cmd/play_level.c', diff --git a/src/game/console/cmd/kill.c b/src/game/console/cmd/kill.c deleted file mode 100644 index a80a8425..00000000 --- a/src/game/console/cmd/kill.c +++ /dev/null @@ -1,124 +0,0 @@ -#include "game/console/cmd/kill.h" - -#include "game/creature.h" -#include "game/game_string.h" -#include "game/items.h" -#include "game/lara/lara_cheat.h" -#include "game/lara/lara_control.h" -#include "game/objects/names.h" -#include "game/objects/vars.h" -#include "global/vars.h" - -#include -#include -#include -#include - -static bool M_CanTargetObjectCreature(GAME_OBJECT_ID object_id); -static COMMAND_RESULT M_Entrypoint(const char *args); - -static bool M_CanTargetObjectCreature(const GAME_OBJECT_ID object_id) -{ - return Object_IsObjectType(object_id, g_EnemyObjects) - || Object_IsObjectType(object_id, g_FriendObjects); -} - -static COMMAND_RESULT M_Entrypoint(const char *const args) -{ - // kill all the enemies in the level - if (String_Equivalent(args, "all")) { - int32_t num_killed = 0; - for (int16_t item_num = 0; item_num < Item_GetTotalCount(); - item_num++) { - const ITEM_INFO *const item = &g_Items[item_num]; - if (!Creature_IsEnemy(item)) { - continue; - } - if (Lara_Cheat_KillEnemy(item_num)) { - num_killed++; - } - } - - if (num_killed == 0) { - Console_Log(GS(OSD_KILL_ALL_FAIL)); - return CR_FAILURE; - } - - Console_Log(GS(OSD_KILL_ALL), num_killed); - return CR_SUCCESS; - } - - // kill all the enemies around Lara within one tile, or a single nearest - // enemy - if (String_Equivalent(args, "")) { - bool found = false; - while (true) { - const int16_t best_item_num = Lara_GetNearestEnemy(); - if (best_item_num == NO_ITEM) { - break; - } - - const ITEM_INFO *const item = &g_Items[best_item_num]; - const int32_t distance = Item_GetDistance(item, &g_LaraItem->pos); - found |= Lara_Cheat_KillEnemy(best_item_num); - if (distance >= WALL_L) { - break; - } - } - - if (!found) { - Console_Log(GS(OSD_KILL_FAIL)); - return CR_FAILURE; - } - - Console_Log(GS(OSD_KILL)); - return CR_SUCCESS; - } - - // kill a single enemy type - { - bool matches_found = false; - int32_t num_killed = 0; - int32_t match_count = 0; - GAME_OBJECT_ID *matching_objs = - Object_IdsFromName(args, &match_count, M_CanTargetObjectCreature); - - for (int16_t item_num = 0; item_num < Item_GetTotalCount(); - item_num++) { - const ITEM_INFO *const item = &g_Items[item_num]; - - bool is_matched = false; - for (int32_t i = 0; i < match_count; i++) { - if (matching_objs[i] == item->object_id) { - is_matched = true; - break; - } - } - if (!is_matched) { - continue; - } - matches_found = true; - - if (Lara_Cheat_KillEnemy(item_num)) { - num_killed++; - } - } - Memory_FreePointer(&matching_objs); - - if (!matches_found) { - Console_Log(GS(OSD_INVALID_OBJECT), args); - return CR_FAILURE; - } - if (num_killed == 0) { - Console_Log(GS(OSD_OBJECT_NOT_FOUND), args); - return CR_FAILURE; - } - Console_Log(GS(OSD_KILL_ALL), num_killed); - return CR_SUCCESS; - } -} - -CONSOLE_COMMAND g_Console_Cmd_Kill = { - .prefix = "kill", - .proc = M_Entrypoint, -}; diff --git a/src/game/console/cmd/kill.h b/src/game/console/cmd/kill.h deleted file mode 100644 index 3766fe1f..00000000 --- a/src/game/console/cmd/kill.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include - -extern CONSOLE_COMMAND g_Console_Cmd_Kill; diff --git a/src/game/console/setup.c b/src/game/console/setup.c index edc0fbdb..9c962381 100644 --- a/src/game/console/setup.c +++ b/src/game/console/setup.c @@ -6,7 +6,6 @@ #include "game/console/cmd/exit_to_title.h" #include "game/console/cmd/flipmap.h" #include "game/console/cmd/fly.h" -#include "game/console/cmd/kill.h" #include "game/console/cmd/load_game.h" #include "game/console/cmd/play_demo.h" #include "game/console/cmd/play_level.h" @@ -16,6 +15,7 @@ #include #include #include +#include #include #include diff --git a/src/game/creature.c b/src/game/creature.c index fb1b273b..390b33aa 100644 --- a/src/game/creature.c +++ b/src/game/creature.c @@ -952,5 +952,5 @@ bool Creature_IsEnemy(const ITEM_INFO *const item) bool Creature_IsAlly(const ITEM_INFO *const item) { - return Object_IsObjectType(item->object_id, g_FriendObjects); + return Object_IsObjectType(item->object_id, g_AllyObjects); } diff --git a/src/game/game_string.def b/src/game/game_string.def index 70f7ddc6..894f82be 100644 --- a/src/game/game_string.def +++ b/src/game/game_string.def @@ -13,15 +13,9 @@ GS_DEFINE(OSD_FLIPMAP_ON, "Flipmap set to ON") GS_DEFINE(OSD_FLIPMAP_OFF, "Flipmap set to OFF") GS_DEFINE(OSD_FLIPMAP_FAIL_ALREADY_ON, "Flipmap is already ON") GS_DEFINE(OSD_FLIPMAP_FAIL_ALREADY_OFF, "Flipmap is already OFF") -GS_DEFINE(OSD_KILL_ALL, "Poof! %d enemies gone!") -GS_DEFINE(OSD_KILL_ALL_FAIL, "Uh-oh, there are no enemies left to kill...") -GS_DEFINE(OSD_KILL, "Bye-bye!") -GS_DEFINE(OSD_KILL_FAIL, "No enemy nearby...") GS_DEFINE(OSD_COMPLETE_LEVEL, "Level complete!") GS_DEFINE(OSD_PLAY_LEVEL, "Loading %s") GS_DEFINE(OSD_INVALID_ROOM, "Invalid room: %d. Valid rooms are 0-%d") -GS_DEFINE(OSD_INVALID_OBJECT, "Invalid object") -GS_DEFINE(OSD_OBJECT_NOT_FOUND, "Object not found") GS_DEFINE(OSD_INVALID_LEVEL, "Invalid level") GS_DEFINE(OSD_INVALID_SAVE_SLOT, "Invalid save slot %d") GS_DEFINE(OSD_UNKNOWN_COMMAND, "Unknown command: %s") diff --git a/src/game/items.c b/src/game/items.c index a3653b81..c5119df6 100644 --- a/src/game/items.c +++ b/src/game/items.c @@ -732,3 +732,8 @@ int32_t Item_GetDistance( { return XYZ_32_GetDistance(&item->pos, target); } + +ITEM_INFO *Item_Get(const int16_t item_num) +{ + return &g_Items[item_num]; +} diff --git a/src/game/objects/vars.c b/src/game/objects/vars.c index b63e1fc4..b9391414 100644 --- a/src/game/objects/vars.c +++ b/src/game/objects/vars.c @@ -44,7 +44,7 @@ const GAME_OBJECT_ID g_EnemyObjects[] = { // clang-format on }; -const GAME_OBJECT_ID g_FriendObjects[] = { +const GAME_OBJECT_ID g_AllyObjects[] = { // clang-format off O_LARA, O_WINSTON, diff --git a/src/game/objects/vars.h b/src/game/objects/vars.h index 832e2059..563ed664 100644 --- a/src/game/objects/vars.h +++ b/src/game/objects/vars.h @@ -4,7 +4,7 @@ #include "global/types.h" extern const GAME_OBJECT_ID g_EnemyObjects[]; -extern const GAME_OBJECT_ID g_FriendObjects[]; +extern const GAME_OBJECT_ID g_AllyObjects[]; extern const GAME_OBJECT_ID g_PickupObjects[]; extern const GAME_OBJECT_ID g_DoorObjects[]; extern const GAME_OBJECT_ID g_TrapdoorObjects[]; diff --git a/subprojects/libtrx b/subprojects/libtrx index 540cc8f3..e2a0bcdb 160000 --- a/subprojects/libtrx +++ b/subprojects/libtrx @@ -1 +1 @@ -Subproject commit 540cc8f36bf23f0970e5309006023bcb725349ff +Subproject commit e2a0bcdb17a3838636cb381e2757262254fa36ba