aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-03-15 19:42:58 +0100
committerShauren <shauren.trinity@gmail.com>2023-03-15 19:42:58 +0100
commit6e309ed17ff448b971f206c7ea7174c736230299 (patch)
tree92b8965f41027de535a112a2a27ccb36e32f7d27
parentd26d38075cdb56dcef77f05276a360e717cc5032 (diff)
Core/Creatures: Allow flagging creatures to not clear their tap list when evading
-rw-r--r--src/server/game/AI/CreatureAI.cpp4
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.cpp4
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp3
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp9
-rw-r--r--src/server/game/Entities/Creature/Creature.h3
5 files changed, 19 insertions, 4 deletions
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp
index 3f2aae8d2de..9a5739b409f 100644
--- a/src/server/game/AI/CreatureAI.cpp
+++ b/src/server/game/AI/CreatureAI.cpp
@@ -310,7 +310,9 @@ bool CreatureAI::_EnterEvadeMode(EvadeReason /*why*/)
me->RemoveAurasOnEvade();
me->CombatStop(true);
- me->SetTappedBy(nullptr);
+ if (!me->IsTapListNotClearedOnEvade())
+ me->SetTappedBy(nullptr);
+
me->ResetPlayerDamageReq();
me->SetLastDamagedTime(0);
me->SetCannotReachTarget(false);
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
index 9b06aebd30a..0d007751677 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
@@ -254,7 +254,9 @@ void ScriptedAI::ForceCombatStop(Creature* who, bool reset /*= true*/)
if (reset)
{
who->LoadCreaturesAddon();
- who->SetTappedBy(nullptr);
+ if (!me->IsTapListNotClearedOnEvade())
+ who->SetTappedBy(nullptr);
+
who->ResetPlayerDamageReq();
who->SetLastDamagedTime(0);
who->SetCannotReachTarget(false);
diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
index 27f3aa8ff31..f5a26fa4efc 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
@@ -94,7 +94,8 @@ void EscortAI::EnterEvadeMode(EvadeReason /*why*/)
{
me->RemoveAllAuras();
me->CombatStop(true);
- me->SetTappedBy(nullptr);
+ if (!me->IsTapListNotClearedOnEvade())
+ me->SetTappedBy(nullptr);
EngagementOver();
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 63c7bd49552..f92733f0143 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -298,7 +298,7 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
return true;
}
-Creature::Creature(bool isWorldObject) : Unit(isWorldObject), MapObject(), m_PlayerDamageReq(0), _pickpocketLootRestore(0),
+Creature::Creature(bool isWorldObject) : Unit(isWorldObject), MapObject(), m_PlayerDamageReq(0), m_dontClearTapListOnEvade(false), _pickpocketLootRestore(0),
m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_ignoreCorpseDecayRatio(false), m_wanderDistance(0.0f), m_boundaryCheckTime(2500), m_combatPulseTime(0), m_combatPulseDelay(0), m_reactState(REACT_AGGRESSIVE),
m_defaultMovementType(IDLE_MOTION_TYPE), m_spawnId(UI64LIT(0)), m_equipmentId(0), m_originalEquipmentId(0), m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false), m_cannotReachTarget(false), m_cannotReachTimer(0),
m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_homePosition(), m_transportHomePosition(), m_creatureInfo(nullptr), m_creatureData(nullptr), _waypointPathId(0), _currentWaypointNodeInfo(0, 0),
@@ -1349,6 +1349,13 @@ void Creature::SetTappedBy(Unit const* unit, bool withGroup)
SetDynamicFlag(UNIT_DYNFLAG_TAPPED);
}
+void Creature::SetDontClearTapListOnEvade(bool dontClear)
+{
+ // only temporary summons are allowed to not clear their tap list
+ if (!m_spawnId)
+ m_dontClearTapListOnEvade = dontClear;
+}
+
// return true if this creature is tapped by the player or by a member of his group.
bool Creature::isTappedBy(Player const* player) const
{
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index 449c83ae9ad..f086743b079 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -245,6 +245,8 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
GuidUnorderedSet const& GetTapList() const { return m_tapList; }
void SetTapList(GuidUnorderedSet tapList) { m_tapList = std::move(tapList); }
bool hasLootRecipient() const { return !m_tapList.empty(); }
+ bool IsTapListNotClearedOnEvade() const { return m_dontClearTapListOnEvade; }
+ void SetDontClearTapListOnEvade(bool dontClear);
bool isTappedBy(Player const* player) const; // return true if the creature is tapped by the player or a member of his party.
Loot* GetLootForPlayer(Player const* player) const override;
bool IsFullyLooted() const;
@@ -426,6 +428,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
static float _GetHealthMod(int32 Rank);
GuidUnorderedSet m_tapList;
+ bool m_dontClearTapListOnEvade;
/// Timers
time_t _pickpocketLootRestore;