diff options
author | Shauren <shauren.trinity@gmail.com> | 2022-09-04 21:34:47 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-09-05 22:23:02 +0200 |
commit | 9bfc29f4aff01cd7f366faffcda0a84071970d6a (patch) | |
tree | e227cc2ee422b88d50b7560096be40d31ed4b5c7 /src/server/game/Combat/CombatManager.h | |
parent | ff99952dfb7d2b532de2d1aedc825fb96038f4c2 (diff) |
Core/Combat: Allow PvE combat references to become suppressed, just like PvP ones
(cherry picked from commit e8dfd8c25c69247b17bc9359dfbe3a1d96ef98bf)
Diffstat (limited to 'src/server/game/Combat/CombatManager.h')
-rw-r--r-- | src/server/game/Combat/CombatManager.h | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/server/game/Combat/CombatManager.h b/src/server/game/Combat/CombatManager.h index 7745458788c..1dfd926fa0f 100644 --- a/src/server/game/Combat/CombatManager.h +++ b/src/server/game/Combat/CombatManager.h @@ -29,14 +29,12 @@ class Unit; * (future devs: please keep this up-to-date if you change the system) * * CombatManager maintains a list of dynamically allocated CombatReference entries. Each entry represents a combat state between two distinct units. * * A unit is "in combat" iff it has one or more non-suppressed CombatReference entries in its CombatManager. No exceptions. * - * - Note: Only PvP combat references can be suppressed, and only because Vanish is a very silly spell. Sue Blizzard. * * * * A CombatReference object carries the following implicit guarantees by existing: * * - Both CombatReference.first and CombatReference.second are valid Units, distinct, not nullptr and currently in the world. * * - If the CombatReference was retrieved from the CombatManager of Unit* A, then exactly one of .first and .second is equal to A. * * - Note: Use CombatReference::GetOther to quickly get the other unit for a given reference. * * - Both .first and .second are currently in combat (IsInCombat will always be true) if either of the following hold: * - * - The reference is a PvE combat reference (_isPvP is false) * * - IsSuppressedFor returns false for the respective unit * * * * To end combat between two units, find their CombatReference and call EndCombat. * @@ -60,12 +58,23 @@ struct TC_GAME_API CombatReference void EndCombat(); + // suppressed combat refs do not generate a combat state for one side of the relation + // (used by: vanish, feign death and launched out of combat but not yet landed spell missiles) + void SuppressFor(Unit* who); + bool IsSuppressedFor(Unit const* who) const { return (who == first) ? _suppressFirst : _suppressSecond; } + CombatReference(CombatReference const&) = delete; CombatReference& operator=(CombatReference const&) = delete; protected: CombatReference(Unit* a, Unit* b, bool pvp = false) : first(a), second(b), _isPvP(pvp) { } + void Refresh(); + void Suppress(Unit* who) { (who == first ? _suppressFirst : _suppressSecond) = true; } + + bool _suppressFirst = false; + bool _suppressSecond = false; + friend class CombatManager; }; @@ -74,21 +83,13 @@ struct TC_GAME_API PvPCombatReference : public CombatReference { static const uint32 PVP_COMBAT_TIMEOUT = 5 * IN_MILLISECONDS; - // suppressed combat refs do not generate a combat state for one side of the relation - // (used by: vanish, feign death) - void SuppressFor(Unit* who); - bool IsSuppressedFor(Unit const* who) const { return (who == first) ? _suppressFirst : _suppressSecond; } - private: PvPCombatReference(Unit* first, Unit* second) : CombatReference(first, second, true) { } bool Update(uint32 tdiff); - void Refresh(); - void Suppress(Unit* who) { (who == first ? _suppressFirst : _suppressSecond) = true; } + void RefreshTimer(); uint32 _combatTimer = PVP_COMBAT_TIMEOUT; - bool _suppressFirst = false; - bool _suppressSecond = false; friend class CombatManager; }; @@ -105,7 +106,7 @@ class TC_GAME_API CombatManager Unit* GetOwner() const { return _owner; } bool HasCombat() const { return HasPvECombat() || HasPvPCombat(); } - bool HasPvECombat() const { return !_pveRefs.empty(); } + bool HasPvECombat() const; bool HasPvECombatWithPlayers() const; std::unordered_map<ObjectGuid, CombatReference*> const& GetPvECombatRefs() const { return _pveRefs; } bool HasPvPCombat() const; @@ -114,7 +115,7 @@ class TC_GAME_API CombatManager Unit* GetAnyTarget() const; // return value is the same as calling IsInCombatWith immediately after this returns - bool SetInCombatWith(Unit* who, bool suppressPvpSecond = false); + bool SetInCombatWith(Unit* who, bool addSecondUnitSuppressed = false); bool IsInCombatWith(ObjectGuid const& who) const; bool IsInCombatWith(Unit const* who) const; void InheritCombatStatesFrom(Unit const* who); |