[11971] Add wrapper HasAttribute to check if a spell has an attribute

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
Schmoozerd 2012-04-21 02:02:23 +02:00
parent 85c694b53e
commit 7fd1f64319
12 changed files with 382 additions and 352 deletions

View file

@ -2423,7 +2423,7 @@ void Unit::CalculateAbsorbResistBlock(Unit *pCaster, SpellNonMeleeDamage *damage
}
uint32 absorb_affected_damage = pCaster->CalcNotIgnoreAbsorbDamage(damageInfo->damage,GetSpellSchoolMask(spellProto),spellProto);
CalculateDamageAbsorbAndResist(pCaster, GetSpellSchoolMask(spellProto), SPELL_DIRECT_DAMAGE, absorb_affected_damage, &damageInfo->absorb, &damageInfo->resist, !(spellProto->AttributesEx2 & SPELL_ATTR_EX2_CANT_REFLECTED));
CalculateDamageAbsorbAndResist(pCaster, GetSpellSchoolMask(spellProto), SPELL_DIRECT_DAMAGE, absorb_affected_damage, &damageInfo->absorb, &damageInfo->resist, !spellProto->HasAttribute(SPELL_ATTR_EX2_CANT_REFLECTED));
damageInfo->damage-= damageInfo->absorb + damageInfo->resist;
}
@ -2838,7 +2838,7 @@ bool Unit::IsSpellBlocked(Unit *pCaster, SpellEntry const *spellEntry, WeaponAtt
if (spellEntry)
{
// Some spells cannot be blocked
if (spellEntry->Attributes & SPELL_ATTR_IMPOSSIBLE_DODGE_PARRY_BLOCK)
if (spellEntry->HasAttribute(SPELL_ATTR_IMPOSSIBLE_DODGE_PARRY_BLOCK))
return false;
}
@ -2928,7 +2928,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
uint32 missChance = uint32(MeleeSpellMissChance(pVictim, attType, fullSkillDiff, spell)*100.0f);
// Roll miss
uint32 tmp = spell->AttributesEx3 & SPELL_ATTR_EX3_CANT_MISS ? 0 : missChance;
uint32 tmp = spell->HasAttribute(SPELL_ATTR_EX3_CANT_MISS) ? 0 : missChance;
if (roll < tmp)
return SPELL_MISS_MISS;
@ -2954,7 +2954,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
bool canParry = true;
// Same spells cannot be parry/dodge
if (spell->Attributes & SPELL_ATTR_IMPOSSIBLE_DODGE_PARRY_BLOCK)
if (spell->HasAttribute(SPELL_ATTR_IMPOSSIBLE_DODGE_PARRY_BLOCK))
return SPELL_MISS_NONE;
bool from_behind = !pVictim->HasInArc(M_PI_F,this);
@ -3115,7 +3115,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (HitChance < 100) HitChance = 100;
if (HitChance > 10000) HitChance = 10000;
int32 tmp = spell->AttributesEx3 & SPELL_ATTR_EX3_CANT_MISS ? 0 : (10000 - HitChance);
int32 tmp = spell->HasAttribute(SPELL_ATTR_EX3_CANT_MISS) ? 0 : (10000 - HitChance);
int32 rand = irand(0,10000);
@ -3987,7 +3987,7 @@ bool Unit::AddSpellAuraHolder(SpellAuraHolder *holder)
continue;
// Carry over removed Aura's remaining damage if Aura still has ticks remaining
if (foundHolder->GetSpellProto()->AttributesEx4 & SPELL_ATTR_EX4_STACK_DOT_MODIFIER)
if (foundHolder->GetSpellProto()->HasAttribute(SPELL_ATTR_EX4_STACK_DOT_MODIFIER))
{
for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
{
@ -4600,7 +4600,7 @@ void Unit::RemoveAurasWithAttribute(uint32 flags)
{
for (SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end(); )
{
if (iter->second->GetSpellProto()->Attributes & flags)
if (iter->second->GetSpellProto()->HasAttribute((SpellAttributes)flags))
{
RemoveSpellAuraHolder(iter->second);
iter = m_spellAuraHolders.begin();
@ -4811,11 +4811,11 @@ void Unit::RemoveArenaAuras(bool onleave)
// used to remove positive visible auras in arenas
for(SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end();)
{
if (!(iter->second->GetSpellProto()->AttributesEx4 & SPELL_ATTR_EX4_UNK21) &&
if (!iter->second->GetSpellProto()->HasAttribute(SPELL_ATTR_EX4_UNK21) &&
// don't remove stances, shadowform, pally/hunter auras
!iter->second->IsPassive() && // don't remove passive auras
(!(iter->second->GetSpellProto()->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) ||
!(iter->second->GetSpellProto()->Attributes & SPELL_ATTR_UNK8)) &&
(!iter->second->GetSpellProto()->HasAttribute(SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) ||
!iter->second->GetSpellProto()->HasAttribute(SPELL_ATTR_UNK8)) &&
// not unaffected by invulnerability auras or not having that unknown flag (that seemed the most probable)
(iter->second->IsPositive() != onleave)) // remove positive buffs on enter, negative buffs on leave
{
@ -5028,7 +5028,7 @@ void Unit::AddGameObject(GameObject* gameObj)
{
SpellEntry const* createBySpell = sSpellStore.LookupEntry(gameObj->GetSpellId());
// Need disable spell use for owner
if (createBySpell && createBySpell->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE)
if (createBySpell && createBySpell->HasAttribute(SPELL_ATTR_DISABLED_WHILE_ACTIVE))
// note: item based cooldowns and cooldown spell mods with charges ignored (unknown existing cases)
((Player*)this)->AddSpellAndCategoryCooldowns(createBySpell,0,NULL,true);
}
@ -5049,7 +5049,7 @@ void Unit::RemoveGameObject(GameObject* gameObj, bool del)
{
SpellEntry const* createBySpell = sSpellStore.LookupEntry(spellid );
// Need activate spell use for owner
if (createBySpell && createBySpell->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE)
if (createBySpell && createBySpell->HasAttribute(SPELL_ATTR_DISABLED_WHILE_ACTIVE))
// note: item based cooldowns and cooldown spell mods with charges ignored (unknown existing cases)
((Player*)this)->SendCooldownEvent(createBySpell);
}
@ -6230,7 +6230,7 @@ int32 Unit::SpellBonusWithCoeffs(SpellEntry const *spellProto, int32 total, int3
*/
uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack)
{
if(!spellProto || !pVictim || damagetype==DIRECT_DAMAGE || spellProto->AttributesEx6 & SPELL_ATTR_EX6_NO_DMG_MODS)
if (!spellProto || !pVictim || damagetype == DIRECT_DAMAGE || spellProto->HasAttribute(SPELL_ATTR_EX6_NO_DMG_MODS))
return pdamage;
// For totems get damage bonus from owner (statue isn't totem in fact)
@ -6687,7 +6687,7 @@ int32 Unit::SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask)
bool Unit::IsSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType)
{
// not critting spell
if((spellProto->AttributesEx2 & SPELL_ATTR_EX2_CANT_CRIT))
if (spellProto->HasAttribute(SPELL_ATTR_EX2_CANT_CRIT))
return false;
float crit_chance = 0.0f;
@ -7198,8 +7198,8 @@ bool Unit::IsImmuneToSpell(SpellEntry const* spellInfo)
if (itr->type == spellInfo->Dispel)
return true;
if (!(spellInfo->AttributesEx & SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE) && // unaffected by school immunity
!(spellInfo->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)) // can remove immune (by dispell or immune it)
if (!spellInfo->HasAttribute(SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE) && // unaffected by school immunity
!spellInfo->HasAttribute(SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)) // can remove immune (by dispell or immune it)
{
SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL];
for(SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr)
@ -7276,7 +7276,7 @@ bool Unit::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex i
*/
uint32 Unit::MeleeDamageBonusDone(Unit *pVictim, uint32 pdamage,WeaponAttackType attType, SpellEntry const *spellProto, DamageEffectType damagetype, uint32 stack)
{
if (!pVictim || pdamage == 0 || (spellProto && spellProto->AttributesEx6 & SPELL_ATTR_EX6_NO_DMG_MODS))
if (!pVictim || pdamage == 0 || (spellProto && spellProto->HasAttribute(SPELL_ATTR_EX6_NO_DMG_MODS)))
return pdamage;
// differentiate for weapon damage based spells
@ -7660,7 +7660,7 @@ void Unit::ApplySpellDispelImmunity(const SpellEntry * spellProto, DispelType ty
{
ApplySpellImmune(spellProto->Id,IMMUNITY_DISPEL, type, apply);
if (apply && spellProto->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)
if (apply && spellProto->HasAttribute(SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY))
RemoveAurasWithDispelType(type);
}
@ -8782,7 +8782,7 @@ int32 Unit::CalculateSpellDamage(Unit const* target, SpellEntry const* spellProt
}
}
if(spellProto->Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION && spellProto->spellLevel &&
if (spellProto->HasAttribute(SPELL_ATTR_LEVEL_DAMAGE_CALCULATION) && spellProto->spellLevel &&
spellProto->Effect[effect_index] != SPELL_EFFECT_WEAPON_PERCENT_DAMAGE &&
spellProto->Effect[effect_index] != SPELL_EFFECT_KNOCK_BACK &&
(spellProto->Effect[effect_index] != SPELL_EFFECT_APPLY_AURA || spellProto->EffectApplyAuraName[effect_index] != SPELL_AURA_MOD_DECREASE_SPEED))
@ -10476,7 +10476,7 @@ void Unit::RemoveAurasAtMechanicImmunity(uint32 mechMask, uint32 exceptSpellId,
++iter;
else if (non_positive && iter->second->IsPositive())
++iter;
else if (spell->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY)
else if (spell->HasAttribute(SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY))
++iter;
else if (iter->second->HasMechanicMask(mechMask))
{