From a27c86a385aacfa34cac82f8da07b91be1837a37 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 24 Aug 2020 19:09:32 -0400 Subject: [PATCH] Scripts/Commands: .npc delete and .gobj delete now work while the specified guid is despawned. Port From (https://github.com/TrinityCore/TrinityCore/commit/2924ae08038314e3c935a132cc56a4135d9f103c) --- Source/Game/Chat/Commands/GameObjectCommands.cs | 5 ++++- Source/Game/Chat/Commands/NPCCommands.cs | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/Game/Chat/Commands/GameObjectCommands.cs b/Source/Game/Chat/Commands/GameObjectCommands.cs index 54d6b8927..3d12faf21 100644 --- a/Source/Game/Chat/Commands/GameObjectCommands.cs +++ b/Source/Game/Chat/Commands/GameObjectCommands.cs @@ -72,6 +72,9 @@ namespace Game.Chat if (!ulong.TryParse(id, out ulong guidLow) || guidLow == 0) return false; + Player player = handler.GetSession().GetPlayer(); + // force respawn to make sure we find something + player.GetMap().RemoveRespawnTime(SpawnObjectType.GameObject, guidLow, true); GameObject obj = handler.GetObjectFromPlayerMapByDbGuid(guidLow); if (!obj) { @@ -82,7 +85,7 @@ namespace Game.Chat ObjectGuid ownerGuid = obj.GetOwnerGUID(); if (ownerGuid.IsEmpty()) { - Unit owner = Global.ObjAccessor.GetUnit(handler.GetPlayer(), ownerGuid); + Unit owner = Global.ObjAccessor.GetUnit(player, ownerGuid); if (!owner || !ownerGuid.IsPlayer()) { handler.SendSysMessage(CypherStrings.CommandDelobjrefercreature, ownerGuid.ToString(), obj.GetGUID().ToString()); diff --git a/Source/Game/Chat/Commands/NPCCommands.cs b/Source/Game/Chat/Commands/NPCCommands.cs index 074c9ca99..d557563b5 100644 --- a/Source/Game/Chat/Commands/NPCCommands.cs +++ b/Source/Game/Chat/Commands/NPCCommands.cs @@ -879,6 +879,9 @@ namespace Game.Chat if (!ulong.TryParse(cId, out ulong guidLow) || guidLow == 0) return false; + // force respawn to make sure we find something + handler.GetSession().GetPlayer().GetMap().RemoveRespawnTime(SpawnObjectType.Creature, guidLow, true); + // then try to find it creature = handler.GetCreatureFromPlayerMapByDbGuid(guidLow); } else