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
This commit is contained in:
Garrett Cox 2022-10-21 02:03:47 -05:00 committed by GitHub
parent e6e2184fe1
commit ef73aa4f8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include <soh/Enhancements/item-tables/ItemTableManager.h>
#define Path _Path #define Path _Path
@ -315,6 +316,27 @@ static bool ItemHandler(std::shared_ptr<Ship::Console> Console, const std::vecto
return CMD_SUCCESS; return CMD_SUCCESS;
} }
static bool GiveItemHandler(std::shared_ptr<Ship::Console> Console, const std::vector<std::string> 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<Ship::Console> Console, const std::vector<std::string>& args) { static bool EntranceHandler(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>& args) {
if (args.size() != 2) { if (args.size() != 2) {
SohImGui::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); SohImGui::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed");
@ -1041,6 +1063,11 @@ void DebugConsole_Init(void) {
{ "slot", Ship::ArgumentType::NUMBER } { "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.", { CMD_REGISTER("item", { ItemHandler, "Sets item ID in arg 1 into slot arg 2. No boundary checks. Use with caution.", {
{ "slot", Ship::ArgumentType::NUMBER }, { "slot", Ship::ArgumentType::NUMBER },
{ "item id", Ship::ArgumentType::NUMBER } { "item id", Ship::ArgumentType::NUMBER }