diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 52 | ||||
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.h | 22 |
2 files changed, 40 insertions, 34 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 29f263ff8ee..e0ef6a70e27 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -250,7 +250,7 @@ Creature::Creature(bool isWorldObject): Unit(isWorldObject), MapObject(), m_grou m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_boundaryCheckTime(2500), m_combatPulseTime(0), m_combatPulseDelay(0), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE), m_spawnId(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), - m_formation(nullptr), m_triggerJustAppeared(true), m_respawnCompatibilityMode(false), m_focusSpell(nullptr), m_focusDelay(0), m_shouldReacquireTarget(false), m_suppressedOrientation(0.0f), _lastDamagedTime(0), + m_formation(nullptr), m_triggerJustAppeared(true), m_respawnCompatibilityMode(false), _focusSpell(nullptr), _spellFocusDelay(0), _shouldReacquireSpellFocusTarget(false), _suppressedSpellFocusOrientation(0.0f), _lastDamagedTime(0), _regenerateHealth(true), _regenerateHealthLock(false) { m_regenTimer = CREATURE_REGEN_INTERVAL; @@ -735,21 +735,21 @@ void Creature::Update(uint32 diff) GetThreatManager().Update(diff); - if (m_shouldReacquireTarget && !HandleSpellFocus(nullptr, true)) + if (_shouldReacquireSpellFocusTarget && !HandleSpellFocus(nullptr, true)) { - SetTarget(m_suppressedTarget); + SetTarget(_suppressedSpellFocusTarget); if (!HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISABLE_TURN)) { - if (m_suppressedTarget) + if (_suppressedSpellFocusTarget) { - if (WorldObject const* objTarget = ObjectAccessor::GetWorldObject(*this, m_suppressedTarget)) + if (WorldObject const* objTarget = ObjectAccessor::GetWorldObject(*this, _suppressedSpellFocusTarget)) SetFacingToObject(objTarget, false); } else - SetFacingTo(m_suppressedOrientation, false); + SetFacingTo(_suppressedSpellFocusOrientation, false); } - m_shouldReacquireTarget = false; + _shouldReacquireSpellFocusTarget = false; } // periodic check to see if the creature has passed an evade boundary @@ -3033,7 +3033,7 @@ void Creature::SetDisplayId(uint32 modelId) void Creature::SetTarget(ObjectGuid guid) { if (HandleSpellFocus(nullptr, true)) - m_suppressedTarget = guid; + _suppressedSpellFocusTarget = guid; else SetGuidValue(UNIT_FIELD_TARGET, guid); } @@ -3041,7 +3041,7 @@ void Creature::SetTarget(ObjectGuid guid) void Creature::SetSpellFocusTarget(Spell const* focusSpell, WorldObject const* target) { // already focused - if (m_focusSpell) + if (_focusSpell) return; // Prevent dead/feigning death creatures from setting a focus target, so they won't turn @@ -3068,11 +3068,11 @@ void Creature::SetSpellFocusTarget(Spell const* focusSpell, WorldObject const* t // store pre-cast values for target and orientation (used to later restore) if (!HandleSpellFocus(nullptr, true)) { // only overwrite these fields if we aren't transitioning from one spell focus to another - m_suppressedTarget = GetGuidValue(UNIT_FIELD_TARGET); - m_suppressedOrientation = GetOrientation(); + _suppressedSpellFocusTarget = GetGuidValue(UNIT_FIELD_TARGET); + _suppressedSpellFocusOrientation = GetOrientation(); } - m_focusSpell = focusSpell; + _focusSpell = focusSpell; // set target, then force send update packet to players if it changed to provide appropriate facing ObjectGuid newTarget = target ? target->GetGUID() : ObjectGuid::Empty; @@ -3125,16 +3125,16 @@ bool Creature::HandleSpellFocus(Spell const* focusSpell, bool withDelay) return false; } - if (focusSpell && (focusSpell != m_focusSpell)) + if (focusSpell && (focusSpell != _focusSpell)) return false; - if (!m_focusSpell) + if (!_focusSpell) { - if (!withDelay || !m_focusDelay) + if (!withDelay || !_spellFocusDelay) return false; - if (GetMSTimeDiffToNow(m_focusDelay) > 1000) // @todo figure out if we can get rid of this magic number somehow + if (GetMSTimeDiffToNow(_spellFocusDelay) > 1000) // @todo figure out if we can get rid of this magic number somehow { - m_focusDelay = 0; // save checks in the future + _spellFocusDelay = 0; // save checks in the future return false; } } @@ -3144,34 +3144,34 @@ bool Creature::HandleSpellFocus(Spell const* focusSpell, bool withDelay) void Creature::ReleaseSpellFocus(Spell const* focusSpell, bool withDelay) { - if (!m_focusSpell) + if (!_focusSpell) return; // focused to something else - if (focusSpell && focusSpell != m_focusSpell) + if (focusSpell && focusSpell != _focusSpell) return; if (IsPet() && !HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISABLE_TURN)) // player pets do not use delay system { - SetGuidValue(UNIT_FIELD_TARGET, m_suppressedTarget); - if (m_suppressedTarget) + SetGuidValue(UNIT_FIELD_TARGET, _suppressedSpellFocusTarget); + if (_suppressedSpellFocusTarget) { - if (WorldObject const* objTarget = ObjectAccessor::GetWorldObject(*this, m_suppressedTarget)) + if (WorldObject const* objTarget = ObjectAccessor::GetWorldObject(*this, _suppressedSpellFocusTarget)) SetFacingToObject(objTarget, false); } else - SetFacingTo(m_suppressedOrientation, false); + SetFacingTo(_suppressedSpellFocusOrientation, false); } else // tell the creature that it should reacquire its actual target after the delay expires (this is handled in ::Update) // player pets don't need to do this, as they automatically reacquire their target on focus release MustReacquireTarget(); - if (m_focusSpell->GetSpellInfo()->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST)) + if (_focusSpell->GetSpellInfo()->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST)) ClearUnitState(UNIT_STATE_FOCUSING); - m_focusSpell = nullptr; - m_focusDelay = (!IsPet() && withDelay) ? GameTime::GetGameTimeMS() : 0; // don't allow re-target right away to prevent visual bugs + _focusSpell = nullptr; + _spellFocusDelay = (!IsPet() && withDelay) ? GameTime::GetGameTimeMS() : 0; // don't allow re-target right away to prevent visual bugs } bool Creature::IsMovementPreventedByCasting() const diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index a6a24e662f4..96832971515 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -340,8 +340,14 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma // Handling caster facing during spellcast void SetTarget(ObjectGuid guid) override; - void MustReacquireTarget() { m_shouldReacquireTarget = true; } // flags the Creature for forced (client displayed) target reacquisition in the next ::Update call - void DoNotReacquireTarget() { m_shouldReacquireTarget = false; m_suppressedTarget = ObjectGuid::Empty; SetGuidValue(UNIT_FIELD_TARGET, ObjectGuid::Empty); m_suppressedOrientation = 0.0f; } + void MustReacquireTarget() { _shouldReacquireSpellFocusTarget = true; } // flags the Creature for forced (client displayed) target reacquisition in the next ::Update call + void DoNotReacquireTarget() + { + _shouldReacquireSpellFocusTarget = false; + _suppressedSpellFocusTarget = ObjectGuid::Empty; + SetGuidValue(UNIT_FIELD_TARGET, ObjectGuid::Empty); + _suppressedSpellFocusOrientation = 0.0f; + } void SetSpellFocusTarget(Spell const* focusSpell, WorldObject const* target); bool HandleSpellFocus(Spell const* focusSpell = nullptr, bool withDelay = false) override; void ReleaseSpellFocus(Spell const* focusSpell = nullptr, bool withDelay = true); @@ -425,17 +431,17 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma uint32 _waypointPathId; std::pair<uint32/*nodeId*/, uint32/*pathId*/> _currentWaypointNodeInfo; - //Formation var + // Formation var CreatureGroup* m_formation; bool m_triggerJustAppeared; bool m_respawnCompatibilityMode; /* Spell focus system */ - Spell const* m_focusSpell; // Locks the target during spell cast for proper facing - uint32 m_focusDelay; - bool m_shouldReacquireTarget; - ObjectGuid m_suppressedTarget; // Stores the creature's "real" target while casting - float m_suppressedOrientation; // Stores the creature's "real" orientation while casting + Spell const* _focusSpell; // Locks the target during spell cast for proper facing + uint32 _spellFocusDelay; + bool _shouldReacquireSpellFocusTarget; + ObjectGuid _suppressedSpellFocusTarget; // Stores the creature's "real" target while casting + float _suppressedSpellFocusOrientation; // Stores the creature's "real" orientation while casting time_t _lastDamagedTime; // Part of Evade mechanics CreatureTextRepeatGroup m_textRepeat; |
