aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI/CreatureAI.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/AI/CreatureAI.h')
-rw-r--r--src/server/game/AI/CreatureAI.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/server/game/AI/CreatureAI.h b/src/server/game/AI/CreatureAI.h
index 165b905803e..eef2cc0bd6b 100644
--- a/src/server/game/AI/CreatureAI.h
+++ b/src/server/game/AI/CreatureAI.h
@@ -84,6 +84,8 @@ class TC_GAME_API CreatureAI : public UnitAI
// Gets the id of the AI (script id)
uint32 GetId() const { return _scriptId; }
+ bool IsEngaged() const { return _isEngaged; }
+
void Talk(uint8 id, WorldObject const* whisperTarget = nullptr);
/// == Reactions At =================================
@@ -97,11 +99,17 @@ class TC_GAME_API CreatureAI : public UnitAI
// Called for reaction at stopping attack at no attackers or targets
virtual void EnterEvadeMode(EvadeReason why = EVADE_REASON_OTHER);
+ // Called for reaction whenever we start being in combat (overridden from base UnitAI)
+ void JustEnteredCombat(Unit* /*who*/) override;
+
+ // Called for reaction whenever a new non-offline unit is added to the threat list
+ virtual void JustStartedThreateningMe(Unit* who) { if (!IsEngaged()) EngagementStart(who); }
+
// Called for reaction when initially engaged - this will always happen _after_ JustEnteredCombat
virtual void JustEngagedWith(Unit* /*who*/) { }
// Called when the creature is killed
- virtual void JustDied(Unit* /*killer*/) { }
+ virtual void JustDied(Unit* /*killer*/) { if (IsEngaged()) EngagementOver(); }
// Called when the creature kills a unit
virtual void KilledUnit(Unit* /*victim*/) { }
@@ -227,6 +235,8 @@ class TC_GAME_API CreatureAI : public UnitAI
// intended for encounter design/debugging. do not use for other purposes. expensive.
int32 VisualizeBoundary(uint32 duration, Unit* owner = nullptr, bool fill = false) const;
+
+ // boundary system methods
virtual bool CheckInRoom();
CreatureBoundary const* GetBoundary() const { return _boundary; }
void SetBoundary(CreatureBoundary const* boundary, bool negativeBoundaries = false);
@@ -235,6 +245,8 @@ class TC_GAME_API CreatureAI : public UnitAI
bool IsInBoundary(Position const* who = nullptr) const;
protected:
+ void EngagementStart(Unit* who);
+ void EngagementOver();
virtual void MoveInLineOfSight(Unit* /*who*/);
bool _EnterEvadeMode(EvadeReason why = EVADE_REASON_OTHER);
@@ -246,6 +258,7 @@ class TC_GAME_API CreatureAI : public UnitAI
void OnOwnerCombatInteraction(Unit* target);
uint32 const _scriptId;
+ bool _isEngaged;
bool _moveInLOSLocked;
};