From ef73aa4f8d9890fdf5cadd726c31dc7c8d6a44c9 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Fri, 21 Oct 2022 02:03:47 -0500 Subject: [PATCH] Add command for giving item as if it was given from an actor (#1145) * Add command for giving item as if it was given from an actor * Add modID argument to give item command and add give from skull command * Adjustment and remove skull option since this isn't pointed at rando-next * Fix string compare --- soh/soh/Enhancements/debugconsole.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index 7c4e6e127..7c462acd9 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -7,6 +7,7 @@ #include #include #include "soh/OTRGlobals.h" +#include #define Path _Path @@ -315,6 +316,27 @@ static bool ItemHandler(std::shared_ptr Console, const std::vecto return CMD_SUCCESS; } +static bool GiveItemHandler(std::shared_ptr Console, const std::vector args) { + if (args.size() != 3) { + SohImGui::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + return CMD_FAILED; + } + GetItemEntry getItemEntry = GET_ITEM_NONE; + + if (args[1].compare("vanilla") == 0) { + getItemEntry = ItemTableManager::Instance->RetrieveItemEntry(MOD_NONE, std::stoi(args[2])); + } else if (args[1].compare("randomizer") == 0) { + getItemEntry = ItemTableManager::Instance->RetrieveItemEntry(MOD_RANDOMIZER, std::stoi(args[2])); + } else { + SohImGui::GetConsole()->SendErrorMessage("[SOH] Invalid argument passed, must be 'vanilla' or 'randomizer'"); + return CMD_FAILED; + } + + GiveItemEntryWithoutActor(gGlobalCtx, getItemEntry); + + return CMD_SUCCESS; +} + static bool EntranceHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() != 2) { SohImGui::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); @@ -1041,6 +1063,11 @@ void DebugConsole_Init(void) { { "slot", Ship::ArgumentType::NUMBER } }}); + CMD_REGISTER("give_item", { GiveItemHandler, "Gives an item to the player as if it was given from an actor", { + { "vanilla|randomizer", Ship::ArgumentType::TEXT }, + { "giveItemID", Ship::ArgumentType::NUMBER } + }}); + CMD_REGISTER("item", { ItemHandler, "Sets item ID in arg 1 into slot arg 2. No boundary checks. Use with caution.", { { "slot", Ship::ArgumentType::NUMBER }, { "item id", Ship::ArgumentType::NUMBER }