Core/Spell: unified handling of SPELL_ATTR5_USABLE_WHILE_* attributes

Allowed mechanic mask is calculated on startup and auras checked against those mechanics
Closes #18798
This commit is contained in:
ariel- authored and roc13x committed 2017-05-04 04:13:49 +01:00
1 parent abae912986
commit 3ccdf57f4a
3 files changed
+110 -29

No files matched your search

+34
View File
@@ -1031,6 +1031,8 @@ SpellInfo::SpellInfo(SpellEntry const* spellEntry, SpellEffectEntry const** effe
_spellSpecific = SPELL_SPECIFIC_NORMAL;
_auraState = AURA_STATE_NONE;
_allowedMechanicMask = 0;
}
SpellInfo::~SpellInfo()
@@ -2920,7 +2922,34 @@ void SpellInfo::_LoadImmunityInfo()
immuneInfo.AuraTypeImmune.shrink_to_fit();
immuneInfo.SpellEffectImmune.shrink_to_fit();
_allowedMechanicMask |= immuneInfo.MechanicImmuneMask;
}
if (HasAttribute(SPELL_ATTR5_USABLE_WHILE_STUNNED))
{
switch (Id)
{
case 22812: // Barkskin
_allowedMechanicMask |=
(1 << MECHANIC_STUN) |
(1 << MECHANIC_FREEZE) |
(1 << MECHANIC_KNOCKOUT) |
(1 << MECHANIC_SLEEP);
break;
case 49039: // Lichborne, don't allow normal stuns
break;
default:
_allowedMechanicMask |= (1 << MECHANIC_STUN);
break;
}
}
if (HasAttribute(SPELL_ATTR5_USABLE_WHILE_CONFUSED))
_allowedMechanicMask |= (1 << MECHANIC_DISORIENTED);
if (HasAttribute(SPELL_ATTR5_USABLE_WHILE_FEARED))
_allowedMechanicMask |= (1 << MECHANIC_FEAR);
}
void SpellInfo::ApplyAllSpellImmunitiesTo(Unit* target, uint8 effIndex, bool apply) const
@@ -3112,6 +3141,11 @@ bool SpellInfo::SpellCancelsAuraEffect(SpellInfo const* auraSpellInfo, uint8 aur
return false;
}
uint32 SpellInfo::GetAllowedMechanicMask() const
{
return _allowedMechanicMask;
}
float SpellInfo::GetMinRange(bool positive) const
{
if (!RangeEntry)