From 26769f40d9ad8fa33c8e973c26e8a85c5e8ddacf Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Mon, 22 Jan 2024 17:49:18 -0500 Subject: [PATCH] [Commands] Add `#npcedit set_grid [Grid ID]` to `#npcedit` (#4004) * [Commands] Add #npcedit grid_id to #npcedit # Notes - Adds `#npcedit grid_id [Grid ID]` to `#npcedit`. * set_grid --- zone/gm_commands/npcedit.cpp | 26 ++++++++++++++++++++++++++ zone/gm_commands/petitems.cpp | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/zone/gm_commands/npcedit.cpp b/zone/gm_commands/npcedit.cpp index e462523aa..d51c762b5 100755 --- a/zone/gm_commands/npcedit.cpp +++ b/zone/gm_commands/npcedit.cpp @@ -1645,6 +1645,31 @@ void command_npcedit(Client *c, const Seperator *sep) ); return; } + } else if (!strcasecmp(sep->arg[1], "set_grid")) { + if (sep->IsNumber(2)) { + const uint32 grid_id = Strings::ToUnsignedInt(sep->arg[2]); + if (grid_id) { + d = fmt::format( + "{} now has a Grid ID of {} on Spawn Group ID {}.", + npc_id_string, + grid_id, + Strings::Commify(std::to_string(t->GetSpawnGroupId())) + ); + auto query = fmt::format( + "UPDATE spawn2 SET pathgrid = {} WHERE spawngroupID = {} AND version = {}", + grid_id, + t->GetSpawnGroupId(), + zone->GetInstanceVersion() + ); + content_db.QueryDatabase(query); + } else { + c->Message(Chat::White, "Grid ID must be greater than 0."); + return; + } + } else { + c->Message(Chat::White, "Usage: #npcedit set_grid [Grid ID] - Sets an NPC's Grid ID"); + return; + } } else { SendNPCEditSubCommands(c); return; @@ -1768,4 +1793,5 @@ void SendNPCEditSubCommands(Client *c) c->Message(Chat::White, "Usage: #npcedit keeps_sold_items [Flag] - Sets an NPC's Keeps Sold Items Flag [0 = False, 1 = True]"); c->Message(Chat::White, "Usage: #npcedit setanimation [Animation ID] - Sets an NPC's Animation on Spawn (Stored in spawn2 table)"); c->Message(Chat::White, "Usage: #npcedit respawntime [Respawn Time] - Sets an NPC's Respawn Timer in Seconds (Stored in spawn2 table)"); + c->Message(Chat::White, "Usage: #npcedit set_grid [Grid ID] - Sets an NPC's Grid ID"); } diff --git a/zone/gm_commands/petitems.cpp b/zone/gm_commands/petitems.cpp index 833b9e276..20f4de558 100644 --- a/zone/gm_commands/petitems.cpp +++ b/zone/gm_commands/petitems.cpp @@ -6,7 +6,7 @@ void command_petitems(Client *c, const Seperator *sep) c->Message(Chat::White, "You must have a pet to use this command."); return; } - + auto pet = c->GetPet()->CastToNPC(); auto loot_list = pet->GetLootList(); if (!loot_list.empty()) {