aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/SpellInfo.cpp
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2016-12-30 23:50:28 -0300
committerariel- <ariel-@users.noreply.github.com>2016-12-30 23:50:28 -0300
commit14c2b2d6cd2303609f1a1859e727ace7b8ea649c (patch)
tree221c16e623888aacf49aad9046b8d3b0be289bd0 /src/server/game/Spells/SpellInfo.cpp
parent90a330c910804f9cb770681ff646a2362c8c0efa (diff)
Core/Spell: added some helpers to SpellInfo to reduce code duplication
Diffstat (limited to 'src/server/game/Spells/SpellInfo.cpp')
-rw-r--r--src/server/game/Spells/SpellInfo.cpp47
1 files changed, 40 insertions, 7 deletions
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index d6b8545b35e..dbf9bdc5a40 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -1245,6 +1245,45 @@ bool SpellInfo::HasInitialAggro() const
return !(HasAttribute(SPELL_ATTR1_NO_THREAT) || HasAttribute(SPELL_ATTR3_NO_INITIAL_AGGRO));
}
+WeaponAttackType SpellInfo::GetAttackType() const
+{
+ WeaponAttackType result;
+ switch (DmgClass)
+ {
+ case SPELL_DAMAGE_CLASS_MELEE:
+ if (HasAttribute(SPELL_ATTR3_REQ_OFFHAND))
+ result = OFF_ATTACK;
+ else
+ result = BASE_ATTACK;
+ break;
+ case SPELL_DAMAGE_CLASS_RANGED:
+ result = IsRangedWeaponSpell() ? RANGED_ATTACK : BASE_ATTACK;
+ break;
+ default:
+ // Wands
+ if (IsAutoRepeatRangedSpell())
+ result = RANGED_ATTACK;
+ else
+ result = BASE_ATTACK;
+ break;
+ }
+
+ return result;
+}
+
+bool SpellInfo::IsItemFitToSpellRequirements(Item const* item) const
+{
+ // item neutral spell
+ if (EquippedItemClass == -1)
+ return true;
+
+ // item dependent spell
+ if (item && item->IsFitToSpellRequirements(this))
+ return true;
+
+ return false;
+}
+
bool SpellInfo::IsAffected(uint32 familyName, flag96 const& familyFlags) const
{
if (!familyName)
@@ -3093,13 +3132,7 @@ int32 SpellInfo::CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask) c
if (SpellShapeshiftEntry const* ss = sSpellShapeshiftStore.LookupEntry(caster->GetShapeshiftForm()))
speed = ss->attackSpeed;
else
- {
- WeaponAttackType slot = BASE_ATTACK;
- if (HasAttribute(SPELL_ATTR3_REQ_OFFHAND))
- slot = OFF_ATTACK;
-
- speed = caster->GetAttackTime(slot);
- }
+ speed = caster->GetAttackTime(GetAttackType());
powerCost += speed / 100;
}