From 5cc1dd1a61f09a819b3fa75a56cf84e8eb85f78d Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 18 May 2021 12:45:55 -0400 Subject: [PATCH] Core/Map: New Map::ForceRespawn to override objections and force a respawn (equivalent to force = true). Use this to fix various GM commands. Port From (https://github.com/TrinityCore/TrinityCore/commit/8b7728f82e6e7c326b7945efd719218179e9767a) --- Source/Game/AI/ScriptedAI/ScriptedEscortAI.cs | 13 ++++++++----- Source/Game/Chat/Commands/GameObjectCommands.cs | 2 +- Source/Game/Chat/Commands/NPCCommands.cs | 8 ++++---- Source/Game/Combat/ThreatManager.cs | 1 + Source/Game/Maps/Map.cs | 7 +++++++ .../2021_05_16_09_world_2018_01_07_03_world.sql | 10 ++++++++++ 6 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 sql/updates/world/master/2021_05_16_09_world_2018_01_07_03_world.sql diff --git a/Source/Game/AI/ScriptedAI/ScriptedEscortAI.cs b/Source/Game/AI/ScriptedAI/ScriptedEscortAI.cs index 3c26baa51..d4750a636 100644 --- a/Source/Game/AI/ScriptedAI/ScriptedEscortAI.cs +++ b/Source/Game/AI/ScriptedAI/ScriptedEscortAI.cs @@ -250,7 +250,7 @@ namespace Game.AI //Check if player or any member of his group is within range - if (_despawnAtFar && HasEscortState(EscortState.Escorting) && !_playerGUID.IsEmpty() && !me.GetVictim() && !HasEscortState(EscortState.Returning)) + if (_despawnAtFar && HasEscortState(EscortState.Escorting) && !_playerGUID.IsEmpty() && !me.IsEngaged() && !HasEscortState(EscortState.Returning)) { if (_playerCheckTimer <= diff) { @@ -263,10 +263,13 @@ namespace Game.AI if (creatureData != null) isEscort = (WorldConfig.GetBoolValue(WorldCfg.RespawnDynamicEscortNpc) && creatureData.spawnGroupData.flags.HasAnyFlag(SpawnGroupFlags.EscortQuestNpc)); - if (_instantRespawn && !isEscort) - me.DespawnOrUnsummon(0, TimeSpan.FromSeconds(1)); - else if (_instantRespawn && isEscort) - me.GetMap().RemoveRespawnTime(SpawnObjectType.Creature, me.GetSpawnId(), true); + if (_instantRespawn) + { + if (!isEscort) + me.DespawnOrUnsummon(0, TimeSpan.FromSeconds(1)); + else + me.GetMap().RemoveRespawnTime(SpawnObjectType.Creature, me.GetSpawnId(), true); + } else me.DespawnOrUnsummon(); diff --git a/Source/Game/Chat/Commands/GameObjectCommands.cs b/Source/Game/Chat/Commands/GameObjectCommands.cs index 8113a1769..2647df80e 100644 --- a/Source/Game/Chat/Commands/GameObjectCommands.cs +++ b/Source/Game/Chat/Commands/GameObjectCommands.cs @@ -74,7 +74,7 @@ namespace Game.Chat Player player = handler.GetSession().GetPlayer(); // force respawn to make sure we find something - player.GetMap().RemoveRespawnTime(SpawnObjectType.GameObject, guidLow, true); + player.GetMap().ForceRespawn(SpawnObjectType.GameObject, guidLow); GameObject obj = handler.GetObjectFromPlayerMapByDbGuid(guidLow); if (!obj) { diff --git a/Source/Game/Chat/Commands/NPCCommands.cs b/Source/Game/Chat/Commands/NPCCommands.cs index 5b6beb5ea..a44a24cde 100644 --- a/Source/Game/Chat/Commands/NPCCommands.cs +++ b/Source/Game/Chat/Commands/NPCCommands.cs @@ -129,7 +129,7 @@ namespace Game.Chat uint mechanicImmuneMask = cInfo.MechanicImmuneMask; uint displayid = target.GetDisplayId(); uint nativeid = target.GetNativeDisplayId(); - uint Entry = target.GetEntry(); + uint entry = target.GetEntry(); long curRespawnDelay = target.GetRespawnCompatibilityMode() ? target.GetRespawnTimeEx() - GameTime.GetGameTime() : target.GetMap().GetCreatureRespawnTime(target.GetSpawnId()) - GameTime.GetGameTime(); if (curRespawnDelay < 0) @@ -138,7 +138,7 @@ namespace Game.Chat string curRespawnDelayStr = Time.secsToTimeString((ulong)curRespawnDelay, true); string defRespawnDelayStr = Time.secsToTimeString(target.GetRespawnDelay(), true); - handler.SendSysMessage(CypherStrings.NpcinfoChar, target.GetSpawnId(), target.GetGUID().ToString(), faction, npcflags, Entry, displayid, nativeid); + handler.SendSysMessage(CypherStrings.NpcinfoChar, target.GetName(), target.GetSpawnId(), target.GetGUID().ToString(), entry, faction, npcflags, displayid, nativeid); if (target.GetCreatureData() != null && target.GetCreatureData().spawnGroupData.groupId != 0) { SpawnGroupTemplateData groupData = target.GetCreatureData().spawnGroupData; @@ -184,7 +184,7 @@ namespace Game.Chat if (cInfo.FlagsExtra.HasAnyFlag((CreatureFlagsExtra)value)) handler.SendSysMessage("{0} (0x{1:X})", (CreatureFlagsExtra)value, value); - handler.SendSysMessage(CypherStrings.NpcinfoNpcFlags, npcflags); + handler.SendSysMessage(CypherStrings.NpcinfoNpcFlags, target.m_unitData.NpcFlags[0]); foreach (uint value in Enum.GetValues(typeof(NPCFlags))) if (npcflags.HasAnyFlag(value)) handler.SendSysMessage("{0} (0x{1:X})", (NPCFlags)value, value); @@ -880,7 +880,7 @@ namespace Game.Chat return false; // force respawn to make sure we find something - handler.GetSession().GetPlayer().GetMap().RemoveRespawnTime(SpawnObjectType.Creature, guidLow, true); + handler.GetSession().GetPlayer().GetMap().ForceRespawn(SpawnObjectType.Creature, guidLow); // then try to find it creature = handler.GetCreatureFromPlayerMapByDbGuid(guidLow); } diff --git a/Source/Game/Combat/ThreatManager.cs b/Source/Game/Combat/ThreatManager.cs index dc5a7451a..98d81756c 100644 --- a/Source/Game/Combat/ThreatManager.cs +++ b/Source/Game/Combat/ThreatManager.cs @@ -82,6 +82,7 @@ namespace Game.Combat { if (!CanHaveThreatList() || !IsEngaged()) return; + if (_updateClientTimer <= tdiff) { _updateClientTimer = CLIENT_THREAT_UPDATE_INTERVAL; diff --git a/Source/Game/Maps/Map.cs b/Source/Game/Maps/Map.cs index 1b0d71eca..6b887dc61 100644 --- a/Source/Game/Maps/Map.cs +++ b/Source/Game/Maps/Map.cs @@ -2555,6 +2555,13 @@ namespace Game.Maps _respawnTimes.Remove(info); } + public void ForceRespawn(SpawnObjectType type, ulong spawnId) + { + RespawnInfo info = GetRespawnInfo(type, spawnId); + if (info != null) + Respawn(info, true); + } + public void RemoveRespawnTime(RespawnInfo info, bool doRespawn = false, SQLTransaction dbTrans = null) { PreparedStatement stmt; diff --git a/sql/updates/world/master/2021_05_16_09_world_2018_01_07_03_world.sql b/sql/updates/world/master/2021_05_16_09_world_2018_01_07_03_world.sql new file mode 100644 index 000000000..418ba4c7b --- /dev/null +++ b/sql/updates/world/master/2021_05_16_09_world_2018_01_07_03_world.sql @@ -0,0 +1,10 @@ +-- +DELETE FROM `linked_respawn` WHERE `guid`=137752 AND `linkedguid`=137752 AND `linkType`=0; +UPDATE `trinity_string` SET `content_default`='NPC currently selected by player: +Name: %s +SpawnID: %s. +GUID: %s. +Entry: %u. +Faction: %u. +NPC Flags: %s. +DisplayID: %u (Native: %u).' WHERE `entry`=539;