mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-15 10:00:28 +00:00
fix(Core/Unit): perform melee attack when unit has not enough power for melee spell (#7996)
This commit is contained in:
@@ -2269,10 +2269,35 @@ void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extr
|
||||
if (attType != BASE_ATTACK && attType != OFF_ATTACK)
|
||||
return; // ignore ranged case
|
||||
|
||||
bool meleeAttack = true;
|
||||
|
||||
// melee attack spell casted at main hand attack only - no normal melee dmg dealt
|
||||
if (attType == BASE_ATTACK && m_currentSpells[CURRENT_MELEE_SPELL] && !extra)
|
||||
m_currentSpells[CURRENT_MELEE_SPELL]->cast();
|
||||
else
|
||||
{
|
||||
meleeAttack = false; // The melee attack is replaced by the melee spell
|
||||
|
||||
Spell* meleeSpell = m_currentSpells[CURRENT_MELEE_SPELL];
|
||||
SpellCastResult castResult = meleeSpell->CheckCast(false);
|
||||
if (castResult != SPELL_CAST_OK)
|
||||
{
|
||||
meleeSpell->SendCastResult(castResult);
|
||||
meleeSpell->SendInterrupted(0);
|
||||
|
||||
meleeSpell->finish(false);
|
||||
meleeSpell->SetExecutedCurrently(false);
|
||||
|
||||
if (castResult == SPELL_FAILED_NO_POWER)
|
||||
{
|
||||
// Not enough rage, do a regular melee attack instead
|
||||
meleeAttack = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
meleeSpell->cast(true);
|
||||
}
|
||||
}
|
||||
if (meleeAttack)
|
||||
{
|
||||
// attack can be redirected to another target
|
||||
victim = GetMeleeHitRedirectTarget(victim);
|
||||
|
||||
Reference in New Issue
Block a user