diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/AI/CreatureAI.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 15 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/Creature.h | 4 | ||||
-rw-r--r-- | src/server/game/Grids/Notifiers/GridNotifiers.cpp | 19 | ||||
-rw-r--r-- | src/server/game/Grids/Notifiers/GridNotifiers.h | 9 |
5 files changed, 47 insertions, 2 deletions
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index 9130e10bf13..a31455d5c09 100644 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -124,7 +124,7 @@ void CreatureAI::MoveInLineOfSight(Unit* who) if (me->IsEngaged()) return; - if (me->HasReactState(REACT_AGGRESSIVE) && me->CanStartAttack(who, false)) + if (me->HasReactState(REACT_AGGRESSIVE) && me->CanStartAttack(who, false) && (me->IsAggroGracePeriodExpired() || me->GetMap()->Instanceable())) me->EngageWithTarget(who); } diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 0a5c0c88612..466ddec3800 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -315,7 +315,7 @@ Creature::Creature(bool isWorldObject) : Unit(isWorldObject), MapObject(), m_Pla 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), m_creatureDifficulty(nullptr), m_stringIds(), _waypointPathId(0), _currentWaypointNodeInfo(0, 0), - m_formation(nullptr), m_triggerJustAppeared(true), m_respawnCompatibilityMode(false), _lastDamagedTime(0), + m_formation(nullptr), m_triggerJustAppeared(true), m_respawnCompatibilityMode(false), _aggroGracePeriodExpired(false), _lastDamagedTime(0), _regenerateHealth(true), _creatureImmunitiesId(0), _gossipMenuId(0), _sparringHealthPct(0) { m_regenTimer = CREATURE_REGEN_INTERVAL; @@ -929,6 +929,16 @@ void Creature::Heartbeat() // Creatures with CREATURE_STATIC_FLAG_2_FORCE_PARTY_MEMBERS_INTO_COMBAT periodically force party members into combat ForcePartyMembersIntoCombat(); + + // creatures should only attack surroundings initially after heartbeat has passed or until attacked + if (!_aggroGracePeriodExpired) + { + _aggroGracePeriodExpired = true; + + // trigger MoveInLineOfSight + Trinity::CreatureAggroGracePeriodExpiredNotifier notifier(*this); + Cell::VisitAllObjects(this, notifier, GetVisibilityRange()); + } } void Creature::Regenerate(Powers power) @@ -2335,6 +2345,7 @@ void Creature::Respawn(bool force) ai->Reset(); m_triggerJustAppeared = true; + _aggroGracePeriodExpired = false; uint32 poolid = GetCreatureData() ? GetCreatureData()->poolId : 0; if (poolid) @@ -3672,6 +3683,8 @@ void Creature::AtEngage(Unit* target) { Unit::AtEngage(target); + _aggroGracePeriodExpired = true; + GetThreatManager().ResetUpdateTimer(); if (!HasFlag(CREATURE_STATIC_FLAG_2_ALLOW_MOUNTED_COMBAT)) diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index a7f6113aab6..7bf4560e4e4 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -455,6 +455,8 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma void SetNoThreatFeedback(bool noThreatFeedback) { _staticFlags.ApplyFlag(CREATURE_STATIC_FLAG_3_NO_THREAT_FEEDBACK, noThreatFeedback); } void ForcePartyMembersIntoCombat(); + bool IsAggroGracePeriodExpired() { return _aggroGracePeriodExpired; } + void OverrideSparringHealthPct(float healthPct) { _sparringHealthPct = healthPct; } void OverrideSparringHealthPct(std::vector<float> const& healthPct); float GetSparringHealthPct() const { return _sparringHealthPct; } @@ -579,6 +581,8 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma bool m_triggerJustAppeared; bool m_respawnCompatibilityMode; + bool _aggroGracePeriodExpired; + /* Spell focus system */ void ReacquireSpellFocusTarget(); struct diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.cpp b/src/server/game/Grids/Notifiers/GridNotifiers.cpp index 067898f671b..f004e15b564 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.cpp +++ b/src/server/game/Grids/Notifiers/GridNotifiers.cpp @@ -242,6 +242,25 @@ void AIRelocationNotifier::Visit(CreatureMapType &m) } } +void CreatureAggroGracePeriodExpiredNotifier::Visit(CreatureMapType& m) +{ + for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) + { + Creature* c = iter->GetSource(); + CreatureUnitRelocationWorker(c, &i_creature); + CreatureUnitRelocationWorker(&i_creature, c); + } +} + +void CreatureAggroGracePeriodExpiredNotifier::Visit(PlayerMapType& m) +{ + for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter) + { + Player* player = iter->GetSource(); + CreatureUnitRelocationWorker(&i_creature, player); + } +} + /* void MessageDistDeliverer::VisitObject(Player* player) diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index 1abf2c06d96..fe62b36225d 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -108,6 +108,15 @@ namespace Trinity void Visit(CreatureMapType &); }; + struct TC_GAME_API CreatureAggroGracePeriodExpiredNotifier + { + Creature& i_creature; + CreatureAggroGracePeriodExpiredNotifier(Creature& c) : i_creature(c) { } + template<class T> void Visit(GridRefManager<T>&) { } + void Visit(CreatureMapType&); + void Visit(PlayerMapType&); + }; + struct GridUpdater { GridType &i_grid; |