diff options
author | Treeston <treeston.mmoc@gmail.com> | 2018-01-04 04:46:22 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-05-16 21:56:05 +0200 |
commit | 5aee452943e5c76f54f58eea9e6880b54a61ec9c (patch) | |
tree | f604cbf92a9207d6d9f8d94ff1a8d8b08f3d248f /src/server/game/Combat/ThreatManager.cpp | |
parent | 83159544b52bf48e8ba3a6eb98c1f4918c0b7bbe (diff) |
Core/Misc: A variety of clean-up changes, mostly following up on 532ab1c to fix legacy bugs exposed by it:
- Triggers can no longer have a threat list (this may expose some ugliness in old legacy scripts)
- Threat entries are forced to OFFLINE if the AI refuses to attack the target
- Clean up passive creature evade behavior to be more consistent
- Fix a months old issue in spawn group management that would cause "Inactive" to incorrectly show in .list respawns for system groups outside of map 0
- Valithria script cleanups, remove old hacks and make it work with the new system. Closes #21174.
- Some strings cleanup
(cherry picked from commit 9f9507e6a1fd50a5ce643a4096c1712700244a61)
Diffstat (limited to 'src/server/game/Combat/ThreatManager.cpp')
-rw-r--r-- | src/server/game/Combat/ThreatManager.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp index 16511b14a3b..03d12c12def 100644 --- a/src/server/game/Combat/ThreatManager.cpp +++ b/src/server/game/Combat/ThreatManager.cpp @@ -94,6 +94,8 @@ ThreatReference::OnlineState ThreatReference::SelectOnlineState() return ONLINE_STATE_OFFLINE; if (!FlagsAllowFighting(_owner, _victim) || !FlagsAllowFighting(_victim, _owner)) return ONLINE_STATE_OFFLINE; + if (_owner->IsAIEnabled && !_owner->GetAI()->CanAIAttack(_victim)) + return ONLINE_STATE_OFFLINE; // next, check suppression (immunity to chosen melee attack school) if (_victim->IsImmunedToDamage(_owner->GetMeleeDamageSchoolMask())) return ONLINE_STATE_SUPPRESSED; @@ -135,16 +137,17 @@ void ThreatReference::ClearThreat(bool sendRemove) /*static*/ bool ThreatManager::CanHaveThreatList(Unit const* who) { + Creature const* cWho = who->ToCreature(); // only creatures can have threat list - if (who->GetTypeId() != TYPEID_UNIT) + if (!cWho) return false; - // pets and totems cannot have threat list - if (who->IsPet() || who->IsTotem()) + // pets, totems and triggers cannot have threat list + if (cWho->IsPet() || cWho->IsTotem() || cWho->IsTrigger()) return false; // summons cannot have a threat list, unless they are controlled by a creature - if (who->HasUnitTypeMask(UNIT_MASK_MINION | UNIT_MASK_GUARDIAN) && !who->GetOwnerGUID().IsCreature()) + if (cWho->HasUnitTypeMask(UNIT_MASK_MINION | UNIT_MASK_GUARDIAN) && !cWho->GetOwnerGUID().IsCreature()) return false; return true; |