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 757fabad2fd..489320de190 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -306,7 +306,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(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), - 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; @@ -801,21 +801,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 (!HasUnitFlag2(UNIT_FLAG2_DISABLE_TURN)) { - if (!m_suppressedTarget.IsEmpty()) + if (!_suppressedSpellFocusTarget.IsEmpty()) { - 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 @@ -3195,7 +3195,7 @@ void Creature::SetDisplayFromModel(uint32 modelIdx) void Creature::SetTarget(ObjectGuid const& guid) { if (HandleSpellFocus(nullptr, true)) - m_suppressedTarget = guid; + _suppressedSpellFocusTarget = guid; else SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::Target), guid); } @@ -3203,7 +3203,7 @@ void Creature::SetTarget(ObjectGuid const& 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 @@ -3230,11 +3230,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 = GetTarget(); - m_suppressedOrientation = GetOrientation(); + _suppressedSpellFocusTarget = GetTarget(); + _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; @@ -3286,16 +3286,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; } } @@ -3305,34 +3305,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() && !HasUnitFlag2(UNIT_FLAG2_DISABLE_TURN)) // player pets do not use delay system { - SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::Target), m_suppressedTarget); - if (!m_suppressedTarget.IsEmpty()) + SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::Target), _suppressedSpellFocusTarget); + if (!_suppressedSpellFocusTarget.IsEmpty()) { - 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 369f885a28c..14b5db8f242 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -348,8 +348,14 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma // Handling caster facing during spellcast void SetTarget(ObjectGuid const& 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; SetTarget(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; + SetTarget(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); @@ -433,17 +439,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; |