diff --git a/zone/command.cpp b/zone/command.cpp index e7e73fce7..aa9deb03c 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -259,7 +259,7 @@ int command_init(void) command_add("npcspecialattk", "[flagchar] [perm] - Set NPC special attack flags. Flags are E(nrage) F(lurry) R(ampage) S(ummon).", AccountStatus::QuestTroupe, command_npcspecialattk) || command_add("npcstats", "- Show stats about target NPC", AccountStatus::QuestTroupe, command_npcstats) || command_add("npctype_cache", "[id] or all - Clears the npc type cache for either the id or all npcs.", AccountStatus::GMImpossible, command_npctype_cache) || - command_add("npctypespawn", "[npctypeid] [factionid] - Spawn an NPC from the db", AccountStatus::Steward, command_npctypespawn) || + command_add("npctypespawn", "[NPC ID] [Faction ID] - Spawn an NPC by ID from the database with an option of setting its Faction ID", AccountStatus::Steward, command_npctypespawn) || command_add("nudge", "- Nudge your target's current position by specific values", AccountStatus::QuestTroupe, command_nudge) || command_add("nukebuffs", "[Beneficial|Detrimental|Help] - Strip all buffs by type on you or your target (no argument to remove all buffs)", AccountStatus::Guide, command_nukebuffs) || command_add("nukeitem", "[Item ID] - Removes the specified Item ID from you or your player target's inventory", AccountStatus::GMLeadAdmin, command_nukeitem) || diff --git a/zone/gm_commands/npctypespawn.cpp b/zone/gm_commands/npctypespawn.cpp index 18c757aa6..81d47cfcd 100755 --- a/zone/gm_commands/npctypespawn.cpp +++ b/zone/gm_commands/npctypespawn.cpp @@ -2,13 +2,22 @@ void command_npctypespawn(Client *c, const Seperator *sep) { - if (sep->IsNumber(1)) { - const NPCType *tmp = 0; - if ((tmp = content_db.LoadNPCTypesData(atoi(sep->arg[1])))) { - //tmp->fixedZ = 1; - auto npc = new NPC(tmp, 0, c->GetPosition(), GravityBehavior::Water); - if (npc && sep->IsNumber(2)) { - npc->SetNPCFactionID(atoi(sep->arg[2])); + int arguments = sep->argnum; + if (!arguments || !sep->IsNumber(1)) { + c->Message(Chat::White, "Usage: #npctypespawn [NPC ID] [Faction ID]"); + return; + } + + auto npc_id = std::stoul(sep->arg[1]); + int faction_id = 0; + + auto npc_type = content_db.LoadNPCTypesData(npc_id); + if (npc_type) { + auto npc = new NPC(npc_type, 0, c->GetPosition(), GravityBehavior::Water); + if (npc) { + if (sep->IsNumber(2)) { + faction_id = std::stoi(sep->arg[2]); + npc->SetNPCFactionID(faction_id); } npc->AddLootTable(); @@ -16,14 +25,41 @@ void command_npctypespawn(Client *c, const Seperator *sep) npc->CheckGlobalLootTables(); } entity_list.AddNPC(npc); - } - else { - c->Message(Chat::White, "NPC Type %i not found", atoi(sep->arg[1])); - } - } - else { - c->Message(Chat::White, "Usage: #npctypespawn npctypeid factionid"); - } + c->Message( + Chat::White, + fmt::format( + "Spawned {} ({}){}.", + npc->GetCleanName(), + npc_id, + ( + faction_id ? + fmt::format( + " on the {} Faction ({})", + content_db.GetFactionName(faction_id), + faction_id + ) : + "" + ) + ).c_str() + ); + } else { + c->Message( + Chat::White, + fmt::format( + "Failed to spawn NPC ID {}.", + npc_id + ).c_str() + ); + } + } else { + c->Message( + Chat::White, + fmt::format( + "NPC ID {} was not found.", + npc_id + ).c_str() + ); + } }