mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 13:16:23 +00:00
fix(Core/SAI): implement response for ranged mode on interrupt (#24175)
This commit is contained in:
@@ -81,6 +81,7 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c)
|
||||
|
||||
_currentRangeMode = false;
|
||||
_attackDistance = 0.f;
|
||||
_mainSpellId = 0;
|
||||
}
|
||||
|
||||
bool SmartAI::IsAIControlled() const
|
||||
@@ -1122,6 +1123,7 @@ void SmartAI::SetMainSpell(uint32 spellId)
|
||||
if (maxRange <= NOMINAL_MELEE_RANGE)
|
||||
return;
|
||||
|
||||
_mainSpellId = spellId;
|
||||
_attackDistance = std::max(maxRange - NOMINAL_MELEE_RANGE, 0.0f);
|
||||
_currentRangeMode = true;
|
||||
}
|
||||
@@ -1222,6 +1224,27 @@ void SmartAI::DistancingEnded()
|
||||
_pendingDistancing = 0.f;
|
||||
}
|
||||
|
||||
bool SmartAI::IsMainSpellPrevented(SpellInfo const* spellInfo) const
|
||||
{
|
||||
if (me->HasSpellCooldown(spellInfo->Id))
|
||||
return true;
|
||||
|
||||
if (spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
|
||||
return true;
|
||||
if (spellInfo->PreventionType == SPELL_PREVENTION_TYPE_PACIFY && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void SmartAI::OnSpellCastFinished(SpellInfo const* spell, SpellFinishReason reason)
|
||||
{
|
||||
CreatureAI::OnSpellCastFinished(spell, reason);
|
||||
if (reason == SPELL_FINISHED_CANCELED && _mainSpellId == spell->Id)
|
||||
if (_currentRangeMode && IsMainSpellPrevented(spell))
|
||||
SetCurrentRangeMode(false);
|
||||
}
|
||||
|
||||
void SmartGameObjectAI::SummonedCreatureDies(Creature* summon, Unit* /*killer*/)
|
||||
{
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_SUMMONED_UNIT_DIES, summon);
|
||||
|
||||
@@ -214,6 +214,10 @@ public:
|
||||
|
||||
void DistancingEnded() override;
|
||||
|
||||
bool IsMainSpellPrevented(SpellInfo const* spellInfo) const;
|
||||
|
||||
void OnSpellCastFinished(SpellInfo const* spell, SpellFinishReason reason) override;
|
||||
|
||||
private:
|
||||
bool mIsCharmed;
|
||||
uint32 mFollowCreditType;
|
||||
@@ -265,6 +269,7 @@ private:
|
||||
bool _currentRangeMode;
|
||||
float _attackDistance;
|
||||
float _pendingDistancing;
|
||||
uint32 _mainSpellId;
|
||||
};
|
||||
|
||||
class SmartGameObjectAI : public GameObjectAI
|
||||
|
||||
Reference in New Issue
Block a user