Core/Spell: added some helpers to SpellInfo to reduce code duplication
This commit is contained in:
@@ -1479,14 +1479,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
expertise += GetTotalAuraModifier(AuraType.ModExpertise, aurEff =>
|
expertise += GetTotalAuraModifier(AuraType.ModExpertise, aurEff =>
|
||||||
{
|
{
|
||||||
// item neutral spell
|
return aurEff.GetSpellInfo().IsItemFitToSpellRequirements(weapon);
|
||||||
if ((int)aurEff.GetSpellInfo().EquippedItemClass == -1)
|
|
||||||
return true;
|
|
||||||
// item dependent spell
|
|
||||||
else if (weapon != null && weapon.IsFitToSpellRequirements(aurEff.GetSpellInfo()))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (expertise < 0)
|
if (expertise < 0)
|
||||||
|
|||||||
+17
-32
@@ -55,25 +55,7 @@ namespace Game.Spells
|
|||||||
m_needComboPoints = m_spellInfo.NeedsComboPoints();
|
m_needComboPoints = m_spellInfo.NeedsComboPoints();
|
||||||
|
|
||||||
// Get data for type of attack
|
// Get data for type of attack
|
||||||
switch (m_spellInfo.DmgClass)
|
m_attackType = info.GetAttackType();
|
||||||
{
|
|
||||||
case SpellDmgClass.Melee:
|
|
||||||
if (m_spellInfo.HasAttribute(SpellAttr3.ReqOffhand))
|
|
||||||
m_attackType = WeaponAttackType.OffAttack;
|
|
||||||
else
|
|
||||||
m_attackType = WeaponAttackType.BaseAttack;
|
|
||||||
break;
|
|
||||||
case SpellDmgClass.Ranged:
|
|
||||||
m_attackType = m_spellInfo.IsRangedWeaponSpell() ? WeaponAttackType.RangedAttack : WeaponAttackType.BaseAttack;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// Wands
|
|
||||||
if (m_spellInfo.HasAttribute(SpellAttr2.AutorepeatFlag))
|
|
||||||
m_attackType = WeaponAttackType.RangedAttack;
|
|
||||||
else
|
|
||||||
m_attackType = WeaponAttackType.BaseAttack;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_spellSchoolMask = m_spellInfo.GetSchoolMask(); // Can be override for some spell (wand shoot for example)
|
m_spellSchoolMask = m_spellInfo.GetSchoolMask(); // Can be override for some spell (wand shoot for example)
|
||||||
|
|
||||||
@@ -6252,32 +6234,35 @@ namespace Game.Spells
|
|||||||
// check weapon presence in slots for main/offhand weapons
|
// check weapon presence in slots for main/offhand weapons
|
||||||
if (!Convert.ToBoolean(_triggeredCastFlags & TriggerCastFlags.IgnoreEquippedItemRequirement) && m_spellInfo.EquippedItemClass >= 0)
|
if (!Convert.ToBoolean(_triggeredCastFlags & TriggerCastFlags.IgnoreEquippedItemRequirement) && m_spellInfo.EquippedItemClass >= 0)
|
||||||
{
|
{
|
||||||
// main hand weapon required
|
var weaponCheck = new Func<WeaponAttackType, SpellCastResult>(attackType =>
|
||||||
if (m_spellInfo.HasAttribute(SpellAttr3.MainHand))
|
|
||||||
{
|
{
|
||||||
Item item = m_caster.ToPlayer().GetWeaponForAttack(WeaponAttackType.BaseAttack);
|
Item item = m_caster.ToPlayer().GetWeaponForAttack(attackType);
|
||||||
|
|
||||||
// skip spell if no weapon in slot or broken
|
// skip spell if no weapon in slot or broken
|
||||||
if (item == null || item.IsBroken())
|
if (!item || item.IsBroken())
|
||||||
return SpellCastResult.EquippedItemClass;
|
return SpellCastResult.EquippedItemClass;
|
||||||
|
|
||||||
// skip spell if weapon not fit to triggered spell
|
// skip spell if weapon not fit to triggered spell
|
||||||
if (!item.IsFitToSpellRequirements(m_spellInfo))
|
if (!item.IsFitToSpellRequirements(m_spellInfo))
|
||||||
return SpellCastResult.EquippedItemClass;
|
return SpellCastResult.EquippedItemClass;
|
||||||
|
|
||||||
|
return SpellCastResult.SpellCastOk;
|
||||||
|
});
|
||||||
|
|
||||||
|
// main hand weapon required
|
||||||
|
if (m_spellInfo.HasAttribute(SpellAttr3.MainHand))
|
||||||
|
{
|
||||||
|
SpellCastResult mainHandResult = weaponCheck(WeaponAttackType.BaseAttack);
|
||||||
|
if (mainHandResult != SpellCastResult.SpellCastOk)
|
||||||
|
return mainHandResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
// offhand hand weapon required
|
// offhand hand weapon required
|
||||||
if (m_spellInfo.HasAttribute(SpellAttr3.ReqOffhand))
|
if (m_spellInfo.HasAttribute(SpellAttr3.ReqOffhand))
|
||||||
{
|
{
|
||||||
Item item = m_caster.ToPlayer().GetWeaponForAttack(WeaponAttackType.OffAttack);
|
SpellCastResult offHandResult = weaponCheck(WeaponAttackType.OffAttack);
|
||||||
|
if (offHandResult != SpellCastResult.SpellCastOk)
|
||||||
// skip spell if no weapon in slot or broken
|
return offHandResult;
|
||||||
if (item == null || item.IsBroken())
|
|
||||||
return SpellCastResult.EquippedItemClass;
|
|
||||||
|
|
||||||
// skip spell if weapon not fit to triggered spell
|
|
||||||
if (!item.IsFitToSpellRequirements(m_spellInfo))
|
|
||||||
return SpellCastResult.EquippedItemClass;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -634,6 +634,45 @@ namespace Game.Spells
|
|||||||
return !(HasAttribute(SpellAttr1.NoThreat) || HasAttribute(SpellAttr3.NoInitialAggro));
|
return !(HasAttribute(SpellAttr1.NoThreat) || HasAttribute(SpellAttr3.NoInitialAggro));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WeaponAttackType GetAttackType()
|
||||||
|
{
|
||||||
|
WeaponAttackType result;
|
||||||
|
switch (DmgClass)
|
||||||
|
{
|
||||||
|
case SpellDmgClass.Melee:
|
||||||
|
if (HasAttribute(SpellAttr3.ReqOffhand))
|
||||||
|
result = WeaponAttackType.OffAttack;
|
||||||
|
else
|
||||||
|
result = WeaponAttackType.BaseAttack;
|
||||||
|
break;
|
||||||
|
case SpellDmgClass.Ranged:
|
||||||
|
result = IsRangedWeaponSpell() ? WeaponAttackType.RangedAttack : WeaponAttackType.BaseAttack;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Wands
|
||||||
|
if (IsAutoRepeatRangedSpell())
|
||||||
|
result = WeaponAttackType.RangedAttack;
|
||||||
|
else
|
||||||
|
result = WeaponAttackType.BaseAttack;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsItemFitToSpellRequirements(Item item)
|
||||||
|
{
|
||||||
|
// item neutral spell
|
||||||
|
if (EquippedItemClass == ItemClass.None)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// item dependent spell
|
||||||
|
if (item && item.IsFitToSpellRequirements(this))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsAffected(SpellFamilyNames familyName, FlagArray128 familyFlags)
|
public bool IsAffected(SpellFamilyNames familyName, FlagArray128 familyFlags)
|
||||||
{
|
{
|
||||||
if (familyName == 0)
|
if (familyName == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user