Core/Spells: Check both main and offhand weapons if spell attributes require that (see Stormstrike)

* This restores the check probably unintentionally dropped in 14c2b2d6cd
* Build fix
This commit is contained in:
Shauren
2017-01-01 00:14:19 +01:00
parent 4df1b28054
commit 3d3d0492ab

View File

@@ -6551,25 +6551,9 @@ SpellCastResult Spell::CheckItems(uint32* param1 /*= nullptr*/, uint32* param2 /
// check weapon presence in slots for main/offhand weapons
if (!(_triggeredCastFlags & TRIGGERED_IGNORE_EQUIPPED_ITEM_REQUIREMENT) && m_spellInfo->EquippedItemClass >= 0)
{
SpellCastResult itemRes = [this]() -> SpellCastResult
auto weaponCheck = [this](WeaponAttackType attackType) -> SpellCastResult
{
switch (m_attackType)
{
case BASE_ATTACK:
// main hand weapon required
if (!m_spellInfo->HasAttribute(SPELL_ATTR3_MAIN_HAND))
return SPELL_CAST_OK;
break;
case OFF_ATTACK:
// offhand hand weapon required
if (!m_spellInfo->HasAttribute(SPELL_ATTR3_REQ_OFFHAND))
return SPELL_CAST_OK;
break;
default:
return SPELL_CAST_OK;
}
Item const* item = m_caster->ToPlayer()->GetWeaponForAttack(m_attackType);
Item const* item = m_caster->ToPlayer()->GetWeaponForAttack(attackType);
// skip spell if no weapon in slot or broken
if (!item || item->IsBroken())
@@ -6578,10 +6562,23 @@ SpellCastResult Spell::CheckItems(uint32* param1 /*= nullptr*/, uint32* param2 /
// skip spell if weapon not fit to triggered spell
if (!item->IsFitToSpellRequirements(m_spellInfo))
return SPELL_FAILED_EQUIPPED_ITEM_CLASS;
}();
if (itemRes != SPELL_CAST_OK)
return itemRes;
return SPELL_CAST_OK;
};
if (m_spellInfo->HasAttribute(SPELL_ATTR3_MAIN_HAND))
{
SpellCastResult mainHandResult = weaponCheck(BASE_ATTACK);
if (mainHandResult != SPELL_CAST_OK)
return mainHandResult;
}
if (m_spellInfo->HasAttribute(SPELL_ATTR3_REQ_OFFHAND))
{
SpellCastResult offHandResult = weaponCheck(OFF_ATTACK);
if (offHandResult != SPELL_CAST_OK)
return offHandResult;
}
}
return SPELL_CAST_OK;