mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-29 16:43:47 +00:00
refactor(Core/AI): Some more refactoring prep for Comat Threat system… (#15026)
Co-authored-by: Treeston <14020072+Treeston@users.noreply.github.com>
This commit is contained in:
@@ -68,7 +68,12 @@ void CombatAI::JustDied(Unit* killer)
|
||||
me->CastSpell(killer, *i, true);
|
||||
}
|
||||
|
||||
void CombatAI::EnterCombat(Unit* who)
|
||||
/**
|
||||
* @brief Called for reaction when initially engaged
|
||||
*
|
||||
* @param who Who 'me' Engaged combat with
|
||||
*/
|
||||
void CombatAI::JustEngagedWith(Unit* who)
|
||||
{
|
||||
for (SpellVct::iterator i = spells.begin(); i != spells.end(); ++i)
|
||||
{
|
||||
@@ -114,7 +119,12 @@ void CasterAI::InitializeAI()
|
||||
m_attackDist = MELEE_RANGE;
|
||||
}
|
||||
|
||||
void CasterAI::EnterCombat(Unit* who)
|
||||
/**
|
||||
* @brief Called for reaction when initially engaged
|
||||
*
|
||||
* @param who Who 'me' Engaged combat with
|
||||
*/
|
||||
void CasterAI::JustEngagedWith(Unit* who)
|
||||
{
|
||||
if (spells.empty())
|
||||
return;
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
|
||||
void InitializeAI() override;
|
||||
void Reset() override;
|
||||
void EnterCombat(Unit* who) override;
|
||||
void JustEngagedWith(Unit* who) override;
|
||||
void JustDied(Unit* killer) override;
|
||||
void UpdateAI(uint32 diff) override;
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
void InitializeAI() override;
|
||||
void AttackStart(Unit* victim) override { AttackStartCaster(victim, m_attackDist); }
|
||||
void UpdateAI(uint32 diff) override;
|
||||
void EnterCombat(Unit* /*who*/) override;
|
||||
void JustEngagedWith(Unit* /*who*/) override;
|
||||
private:
|
||||
float m_attackDist;
|
||||
};
|
||||
|
||||
@@ -69,7 +69,7 @@ void PossessedAI::KilledUnit(Unit* /*victim*/)
|
||||
// victim->RemoveDynamicFlag(UNIT_DYNFLAG_LOOTABLE);
|
||||
}
|
||||
|
||||
void CritterAI::EnterCombat(Unit* who)
|
||||
void CritterAI::JustEngagedWith(Unit* who)
|
||||
{
|
||||
if (!me->HasUnitState(UNIT_STATE_FLEEING))
|
||||
{
|
||||
|
||||
@@ -68,7 +68,7 @@ class CritterAI : public PassiveAI
|
||||
public:
|
||||
explicit CritterAI(Creature* c) : PassiveAI(c) { }
|
||||
|
||||
void EnterCombat(Unit* /*who*/) override;
|
||||
void JustEngagedWith(Unit* /*who*/) override;
|
||||
void EnterEvadeMode(EvadeReason why) override;
|
||||
void MovementInform(uint32 type, uint32 id) override;
|
||||
void UpdateAI(uint32 /*diff*/) override { }
|
||||
|
||||
@@ -332,6 +332,21 @@ public:
|
||||
targetList.resize(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when the unit enters combat
|
||||
* (NOTE: Creature engage logic should NOT be here, but in JustEngagedWith, which happens once threat is established!)
|
||||
*
|
||||
* @todo Never invoked right now. Preparation for Combat Threat refactor
|
||||
*/
|
||||
virtual void JustEnteredCombat(Unit* /*who*/) { }
|
||||
|
||||
/**
|
||||
* @brief Called when the unit leaves combat
|
||||
*
|
||||
* @todo Never invoked right now. Preparation for Combat Threat refactor
|
||||
*/
|
||||
virtual void JustExitedCombat() { }
|
||||
|
||||
// Called at any Damage to any victim (before damage apply)
|
||||
virtual void DamageDealt(Unit* /*victim*/, uint32& /*damage*/, DamageEffectType /*damageType*/) { }
|
||||
|
||||
|
||||
@@ -116,8 +116,10 @@ public:
|
||||
// Called for reaction at stopping attack at no attackers or targets
|
||||
virtual void EnterEvadeMode(EvadeReason why = EVADE_REASON_OTHER);
|
||||
|
||||
// Called for reaction when initially engaged
|
||||
virtual void EnterCombat(Unit* /*victim*/) {}
|
||||
/**
|
||||
* @brief Called for reaction when initially engaged
|
||||
*/
|
||||
virtual void JustEngagedWith(Unit* /*who*/) {}
|
||||
|
||||
// Called when the creature is killed
|
||||
virtual void JustDied(Unit* /*killer*/) {}
|
||||
|
||||
@@ -593,7 +593,7 @@ void BossAI::_JustDied()
|
||||
}
|
||||
}
|
||||
|
||||
void BossAI::_EnterCombat()
|
||||
void BossAI::_JustEngagedWith()
|
||||
{
|
||||
me->SetCombatPulseDelay(5);
|
||||
me->setActive(true);
|
||||
@@ -690,7 +690,7 @@ void WorldBossAI::_JustDied()
|
||||
summons.DespawnAll();
|
||||
}
|
||||
|
||||
void WorldBossAI::_EnterCombat()
|
||||
void WorldBossAI::_JustEngagedWith()
|
||||
{
|
||||
Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true);
|
||||
if (target)
|
||||
|
||||
@@ -278,9 +278,9 @@ struct ScriptedAI : public CreatureAI
|
||||
void Reset() override {}
|
||||
|
||||
//Called at creature aggro either by MoveInLOS or Attack Start
|
||||
void EnterCombat(Unit* /*victim*/) override {}
|
||||
void JustEngagedWith(Unit* /*who*/) override {}
|
||||
|
||||
// Called before EnterCombat even before the creature is in combat.
|
||||
// Called before JustEngagedWith even before the creature is in combat.
|
||||
void AttackStart(Unit* /*target*/) override;
|
||||
|
||||
// *************
|
||||
@@ -455,13 +455,13 @@ public:
|
||||
virtual void ScheduleTasks() { }
|
||||
|
||||
void Reset() override { _Reset(); }
|
||||
void EnterCombat(Unit* /*who*/) override { _EnterCombat(); }
|
||||
void JustEngagedWith(Unit* /*who*/) override { _JustEngagedWith(); }
|
||||
void JustDied(Unit* /*killer*/) override { _JustDied(); }
|
||||
void JustReachedHome() override { _JustReachedHome(); }
|
||||
|
||||
protected:
|
||||
void _Reset();
|
||||
void _EnterCombat();
|
||||
void _JustEngagedWith();
|
||||
void _JustDied();
|
||||
void _JustReachedHome() { me->setActive(false); }
|
||||
|
||||
@@ -493,12 +493,12 @@ public:
|
||||
virtual void ExecuteEvent(uint32 /*eventId*/) { }
|
||||
|
||||
void Reset() override { _Reset(); }
|
||||
void EnterCombat(Unit* /*who*/) override { _EnterCombat(); }
|
||||
void JustEngagedWith(Unit* /*who*/) override { _JustEngagedWith(); }
|
||||
void JustDied(Unit* /*killer*/) override { _JustDied(); }
|
||||
|
||||
protected:
|
||||
void _Reset();
|
||||
void _EnterCombat();
|
||||
void _JustEngagedWith();
|
||||
void _JustDied();
|
||||
|
||||
EventMap events;
|
||||
|
||||
@@ -787,7 +787,7 @@ void SmartAI::JustReachedHome()
|
||||
mJustReset = false;
|
||||
}
|
||||
|
||||
void SmartAI::EnterCombat(Unit* enemy)
|
||||
void SmartAI::JustEngagedWith(Unit* enemy)
|
||||
{
|
||||
// Xinef: Interrupt channeled spells
|
||||
if (IsAIControlled())
|
||||
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
void JustReachedHome() override;
|
||||
|
||||
// Called for reaction at enter to combat if not in combat yet (enemy can be nullptr)
|
||||
void EnterCombat(Unit* enemy) override;
|
||||
void JustEngagedWith(Unit* enemy) override;
|
||||
|
||||
// Called for reaction at stopping attack at no attackers or targets
|
||||
void EnterEvadeMode(EvadeReason why = EVADE_REASON_OTHER) override;
|
||||
|
||||
@@ -13675,7 +13675,7 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy, uint32 duration)
|
||||
if (enemy)
|
||||
{
|
||||
if (IsAIEnabled)
|
||||
creature->AI()->EnterCombat(enemy);
|
||||
creature->AI()->JustEngagedWith(enemy);
|
||||
|
||||
if (creature->GetFormation())
|
||||
creature->GetFormation()->MemberEngagingTarget(creature, enemy);
|
||||
|
||||
Reference in New Issue
Block a user