[11144] Prevents abilities that are 'usable while stunned' being usable while in non-stun effects. The usability while stunned is restricted only to stun auras with mechanic stun

Signed-off-by: Ambal <pogrebniak@gala.net>
This commit is contained in:
darkstalker 2011-02-12 15:59:09 +02:00 committed by Ambal
parent 01e4f25888
commit 3d4caa275b
4 changed files with 29 additions and 4 deletions

View file

@ -5602,8 +5602,25 @@ SpellCastResult Spell::CheckCasterAuras() const
SpellCastResult prevented_reason = SPELL_CAST_OK; SpellCastResult prevented_reason = SPELL_CAST_OK;
// Have to check if there is a stun aura. Otherwise will have problems with ghost aura apply while logging out // Have to check if there is a stun aura. Otherwise will have problems with ghost aura apply while logging out
uint32 unitflag = m_caster->GetUInt32Value(UNIT_FIELD_FLAGS); // Get unit state uint32 unitflag = m_caster->GetUInt32Value(UNIT_FIELD_FLAGS); // Get unit state
if (unitflag & UNIT_FLAG_STUNNED && !(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_STUNNED)) if (unitflag & UNIT_FLAG_STUNNED)
{
// spell is usable while stunned, check if aura has mechanic stun
if (m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_STUNNED)
{
bool is_stun_mechanic = true;
Unit::AuraList const& stunAuras = m_caster->GetAurasByType(SPELL_AURA_MOD_STUN);
for (Unit::AuraList::const_iterator itr = stunAuras.begin(); itr != stunAuras.end(); ++itr)
if (!(*itr)->HasMechanic(MECHANIC_STUN))
{
is_stun_mechanic = false;
break;
}
if (!is_stun_mechanic)
prevented_reason = SPELL_FAILED_STUNNED; prevented_reason = SPELL_FAILED_STUNNED;
}
else
prevented_reason = SPELL_FAILED_STUNNED;
}
else if (unitflag & UNIT_FLAG_CONFUSED && !(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED)) else if (unitflag & UNIT_FLAG_CONFUSED && !(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED))
prevented_reason = SPELL_FAILED_CONFUSED; prevented_reason = SPELL_FAILED_CONFUSED;
else if (unitflag & UNIT_FLAG_FLEEING && !(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_FEARED)) else if (unitflag & UNIT_FLAG_FLEEING && !(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_FEARED))
@ -5652,7 +5669,7 @@ SpellCastResult Spell::CheckCasterAuras() const
switch(aura->GetModifier()->m_auraname) switch(aura->GetModifier()->m_auraname)
{ {
case SPELL_AURA_MOD_STUN: case SPELL_AURA_MOD_STUN:
if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_STUNNED)) if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_STUNNED) || !aura->HasMechanic(MECHANIC_STUN))
return SPELL_FAILED_STUNNED; return SPELL_FAILED_STUNNED;
break; break;
case SPELL_AURA_MOD_CONFUSE: case SPELL_AURA_MOD_CONFUSE:

View file

@ -8180,6 +8180,12 @@ bool Aura::IsLastAuraOnHolder()
return true; return true;
} }
bool Aura::HasMechanic(uint32 mechanic) const
{
return GetSpellProto()->Mechanic == mechanic ||
GetSpellProto()->EffectMechanic[m_effIndex] == mechanic;
}
SpellAuraHolder::SpellAuraHolder(SpellEntry const* spellproto, Unit *target, WorldObject *caster, Item *castItem) : SpellAuraHolder::SpellAuraHolder(SpellEntry const* spellproto, Unit *target, WorldObject *caster, Item *castItem) :
m_target(target), m_castItemGuid(castItem ? castItem->GetObjectGuid() : ObjectGuid()), m_target(target), m_castItemGuid(castItem ? castItem->GetObjectGuid() : ObjectGuid()),
m_auraSlot(MAX_AURAS), m_auraFlags(AFLAG_NONE), m_auraLevel(1), m_procCharges(0), m_auraSlot(MAX_AURAS), m_auraFlags(AFLAG_NONE), m_auraLevel(1), m_procCharges(0),

View file

@ -436,6 +436,8 @@ class MANGOS_DLL_SPEC Aura
SpellAuraHolder* const GetHolder() const { return m_spellAuraHolder; } SpellAuraHolder* const GetHolder() const { return m_spellAuraHolder; }
bool IsLastAuraOnHolder(); bool IsLastAuraOnHolder();
bool HasMechanic(uint32 mechanic) const;
protected: protected:
Aura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster = NULL, Item* castItem = NULL); Aura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster = NULL, Item* castItem = NULL);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "11143" #define REVISION_NR "11144"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__