mirror of
https://github.com/mangosfour/server.git
synced 2025-12-18 01:37:01 +00:00
[11971] Add wrapper HasAttribute to check if a spell has an attribute
Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
parent
85c694b53e
commit
7fd1f64319
12 changed files with 382 additions and 352 deletions
|
|
@ -392,7 +392,7 @@ Spell::Spell( Unit* caster, SpellEntry const *info, bool triggered, ObjectGuid o
|
|||
|
||||
m_spellFlags = SPELL_FLAG_NORMAL;
|
||||
|
||||
if(m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC && !(m_spellInfo->AttributesEx2 & SPELL_ATTR_EX2_CANT_REFLECTED))
|
||||
if(m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC && !m_spellInfo->HasAttribute(SPELL_ATTR_EX2_CANT_REFLECTED))
|
||||
{
|
||||
for(int j = 0; j < MAX_EFFECT_INDEX; ++j)
|
||||
{
|
||||
|
|
@ -402,7 +402,7 @@ Spell::Spell( Unit* caster, SpellEntry const *info, bool triggered, ObjectGuid o
|
|||
if(!IsPositiveTarget(m_spellInfo->EffectImplicitTargetA[j], m_spellInfo->EffectImplicitTargetB[j]))
|
||||
m_canReflect = true;
|
||||
else
|
||||
m_canReflect = (m_spellInfo->AttributesEx & SPELL_ATTR_EX_NEGATIVE) ? true : false;
|
||||
m_canReflect = m_spellInfo->HasAttribute(SPELL_ATTR_EX_NEGATIVE);
|
||||
|
||||
if(m_canReflect)
|
||||
continue;
|
||||
|
|
@ -764,7 +764,7 @@ void Spell::prepareDataForTriggerSystem()
|
|||
break;
|
||||
case SPELL_DAMAGE_CLASS_RANGED:
|
||||
// Auto attack
|
||||
if (m_spellInfo->AttributesEx2 & SPELL_ATTR_EX2_AUTOREPEAT_FLAG)
|
||||
if (m_spellInfo->HasAttribute(SPELL_ATTR_EX2_AUTOREPEAT_FLAG))
|
||||
{
|
||||
m_procAttacker = PROC_FLAG_SUCCESSFUL_RANGED_HIT;
|
||||
m_procVictim = PROC_FLAG_TAKEN_RANGED_HIT;
|
||||
|
|
@ -781,7 +781,7 @@ void Spell::prepareDataForTriggerSystem()
|
|||
m_procAttacker = PROC_FLAG_SUCCESSFUL_POSITIVE_SPELL;
|
||||
m_procVictim = PROC_FLAG_TAKEN_POSITIVE_SPELL;
|
||||
}
|
||||
else if (m_spellInfo->AttributesEx2 & SPELL_ATTR_EX2_AUTOREPEAT_FLAG) // Wands auto attack
|
||||
else if (m_spellInfo->HasAttribute(SPELL_ATTR_EX2_AUTOREPEAT_FLAG)) // Wands auto attack
|
||||
{
|
||||
m_procAttacker = PROC_FLAG_SUCCESSFUL_RANGED_HIT;
|
||||
m_procVictim = PROC_FLAG_TAKEN_RANGED_HIT;
|
||||
|
|
@ -1037,7 +1037,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target)
|
|||
if(real_caster && real_caster != unit)
|
||||
{
|
||||
// can cause back attack (if detected)
|
||||
if (!(m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_NO_INITIAL_AGGRO) && !IsPositiveSpell(m_spellInfo->Id) &&
|
||||
if (!m_spellInfo->HasAttribute(SPELL_ATTR_EX3_NO_INITIAL_AGGRO) && !IsPositiveSpell(m_spellInfo->Id) &&
|
||||
m_caster->isVisibleForOrDetect(unit, unit, false))
|
||||
{
|
||||
if (!unit->isInCombat() && unit->GetTypeId() != TYPEID_PLAYER && ((Creature*)unit)->AI())
|
||||
|
|
@ -1110,7 +1110,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target)
|
|||
|
||||
// trigger weapon enchants for weapon based spells; exclude spells that stop attack, because may break CC
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER && m_spellInfo->EquippedItemClass == ITEM_CLASS_WEAPON &&
|
||||
!(m_spellInfo->Attributes & SPELL_ATTR_STOP_ATTACK_TARGET))
|
||||
!m_spellInfo->HasAttribute(SPELL_ATTR_STOP_ATTACK_TARGET))
|
||||
((Player*)m_caster)->CastItemCombatSpell(unitTarget, m_attackType);
|
||||
|
||||
// Haunt (NOTE: for avoid use additional field damage stored in dummy value (replace unused 100%)
|
||||
|
|
@ -1225,15 +1225,15 @@ void Spell::DoSpellHitOnUnit(Unit *unit, uint32 effectMask)
|
|||
}
|
||||
|
||||
// not break stealth by cast targeting
|
||||
if (!(m_spellInfo->AttributesEx & SPELL_ATTR_EX_NOT_BREAK_STEALTH))
|
||||
if (!m_spellInfo->HasAttribute(SPELL_ATTR_EX_NOT_BREAK_STEALTH))
|
||||
unit->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
|
||||
|
||||
// can cause back attack (if detected), stealth removed at Spell::cast if spell break it
|
||||
if (!(m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_NO_INITIAL_AGGRO) && !IsPositiveSpell(m_spellInfo->Id) &&
|
||||
if (!m_spellInfo->HasAttribute(SPELL_ATTR_EX3_NO_INITIAL_AGGRO) && !IsPositiveSpell(m_spellInfo->Id) &&
|
||||
m_caster->isVisibleForOrDetect(unit, unit, false))
|
||||
{
|
||||
// use speedup check to avoid re-remove after above lines
|
||||
if (m_spellInfo->AttributesEx & SPELL_ATTR_EX_NOT_BREAK_STEALTH)
|
||||
if (m_spellInfo->HasAttribute(SPELL_ATTR_EX_NOT_BREAK_STEALTH))
|
||||
unit->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
|
||||
|
||||
// caster can be detected but have stealth aura
|
||||
|
|
@ -1267,7 +1267,7 @@ void Spell::DoSpellHitOnUnit(Unit *unit, uint32 effectMask)
|
|||
if (unit->hasUnitState(UNIT_STAT_ATTACK_PLAYER))
|
||||
realCaster->SetContestedPvP();
|
||||
|
||||
if (unit->isInCombat() && !(m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_NO_INITIAL_AGGRO))
|
||||
if (unit->isInCombat() && !m_spellInfo->HasAttribute(SPELL_ATTR_EX3_NO_INITIAL_AGGRO))
|
||||
{
|
||||
realCaster->SetInCombatState(unit->GetCombatTimer() > 0);
|
||||
unit->getHostileRefManager().threatAssist(realCaster, 0.0f, m_spellInfo);
|
||||
|
|
@ -2140,7 +2140,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
|||
// remove not targetable units if spell has no script targets
|
||||
for (UnitList::iterator itr = targetUnitMap.begin(); itr != targetUnitMap.end(); )
|
||||
{
|
||||
if (!(*itr)->isTargetableForAttack(m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_CAST_ON_DEAD))
|
||||
if (!(*itr)->isTargetableForAttack(m_spellInfo->HasAttribute(SPELL_ATTR_EX3_CAST_ON_DEAD)))
|
||||
targetUnitMap.erase(itr++);
|
||||
else
|
||||
++itr;
|
||||
|
|
@ -2893,7 +2893,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
|||
break;
|
||||
case SPELL_EFFECT_APPLY_AREA_AURA_PARTY:
|
||||
// AreaAura
|
||||
if(m_spellInfo->Attributes == 0x9050000 || m_spellInfo->Attributes == 0x10000)
|
||||
if ((m_spellInfo->Attributes == (SPELL_ATTR_NOT_SHAPESHIFT | SPELL_ATTR_UNK18 | SPELL_ATTR_CASTABLE_WHILE_MOUNTED | SPELL_ATTR_CASTABLE_WHILE_SITTING)) || (m_spellInfo->Attributes == SPELL_ATTR_NOT_SHAPESHIFT))
|
||||
SetTargetMap(effIndex, TARGET_AREAEFFECT_PARTY, targetUnitMap);
|
||||
break;
|
||||
case SPELL_EFFECT_SKIN_PLAYER_CORPSE:
|
||||
|
|
@ -3542,7 +3542,7 @@ void Spell::SendSpellCooldown()
|
|||
}
|
||||
|
||||
// (1) have infinity cooldown but set at aura apply, (2) passive cooldown at triggering
|
||||
if(m_spellInfo->Attributes & (SPELL_ATTR_DISABLED_WHILE_ACTIVE | SPELL_ATTR_PASSIVE))
|
||||
if (m_spellInfo->HasAttribute(SPELL_ATTR_DISABLED_WHILE_ACTIVE) || m_spellInfo->HasAttribute(SPELL_ATTR_PASSIVE))
|
||||
return;
|
||||
|
||||
_player->AddSpellAndCategoryCooldowns(m_spellInfo, m_CastItem ? m_CastItem->GetEntry() : 0, this);
|
||||
|
|
@ -3752,7 +3752,7 @@ void Spell::finish(bool ok)
|
|||
CastTriggerSpells();
|
||||
|
||||
// Stop Attack for some spells
|
||||
if( m_spellInfo->Attributes & SPELL_ATTR_STOP_ATTACK_TARGET )
|
||||
if (m_spellInfo->HasAttribute(SPELL_ATTR_STOP_ATTACK_TARGET))
|
||||
m_caster->AttackStop();
|
||||
|
||||
// update encounter state if needed
|
||||
|
|
@ -4721,7 +4721,7 @@ void Spell::CastPreCastSpells(Unit* target)
|
|||
SpellCastResult Spell::CheckCast(bool strict)
|
||||
{
|
||||
// check cooldowns to prevent cheating (ignore passive spells, that client side visual only)
|
||||
if (m_caster->GetTypeId()==TYPEID_PLAYER && !(m_spellInfo->Attributes & SPELL_ATTR_PASSIVE) &&
|
||||
if (m_caster->GetTypeId()==TYPEID_PLAYER && !m_spellInfo->HasAttribute(SPELL_ATTR_PASSIVE) &&
|
||||
((Player*)m_caster)->HasSpellCooldown(m_spellInfo->Id))
|
||||
{
|
||||
if(m_triggeredByAuraSpell)
|
||||
|
|
@ -4748,11 +4748,11 @@ SpellCastResult Spell::CheckCast(bool strict)
|
|||
sWorld.getConfig(CONFIG_BOOL_VMAP_INDOOR_CHECK) &&
|
||||
VMAP::VMapFactory::createOrGetVMapManager()->isLineOfSightCalcEnabled())
|
||||
{
|
||||
if (m_spellInfo->Attributes & SPELL_ATTR_OUTDOORS_ONLY &&
|
||||
if (m_spellInfo->HasAttribute(SPELL_ATTR_OUTDOORS_ONLY) &&
|
||||
!m_caster->GetTerrain()->IsOutdoors(m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ()))
|
||||
return SPELL_FAILED_ONLY_OUTDOORS;
|
||||
|
||||
if(m_spellInfo->Attributes & SPELL_ATTR_INDOORS_ONLY &&
|
||||
if(m_spellInfo->HasAttribute(SPELL_ATTR_INDOORS_ONLY) &&
|
||||
m_caster->GetTerrain()->IsOutdoors(m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ()))
|
||||
return SPELL_FAILED_ONLY_INDOORS;
|
||||
}
|
||||
|
|
@ -4768,7 +4768,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
|||
if(shapeError != SPELL_CAST_OK)
|
||||
return shapeError;
|
||||
|
||||
if ((m_spellInfo->Attributes & SPELL_ATTR_ONLY_STEALTHED) && !(m_caster->HasStealthAura()))
|
||||
if (m_spellInfo->HasAttribute(SPELL_ATTR_ONLY_STEALTHED) && !(m_caster->HasStealthAura()))
|
||||
return SPELL_FAILED_ONLY_STEALTHED;
|
||||
}
|
||||
}
|
||||
|
|
@ -4841,8 +4841,8 @@ SpellCastResult Spell::CheckCast(bool strict)
|
|||
|
||||
// totem immunity for channeled spells(needs to be before spell cast)
|
||||
// spell attribs for player channeled spells
|
||||
if ((m_spellInfo->AttributesEx & SPELL_ATTR_EX_UNK14)
|
||||
&& (m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_UNK13)
|
||||
if (m_spellInfo->HasAttribute(SPELL_ATTR_EX_UNK14)
|
||||
&& m_spellInfo->HasAttribute(SPELL_ATTR_EX5_UNK13)
|
||||
&& target->GetTypeId() == TYPEID_UNIT
|
||||
&& ((Creature*)target)->IsTotem())
|
||||
return SPELL_FAILED_IMMUNE;
|
||||
|
|
@ -5010,7 +5010,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
|||
return SPELL_FAILED_TARGET_AURASTATE;
|
||||
|
||||
//Must be behind the target.
|
||||
if( m_spellInfo->AttributesEx2 == 0x100000 && (m_spellInfo->AttributesEx & 0x200) == 0x200 && target->HasInArc(M_PI_F, m_caster) )
|
||||
if (m_spellInfo->AttributesEx2 == SPELL_ATTR_EX2_UNK20 && m_spellInfo->HasAttribute(SPELL_ATTR_EX_UNK9) && target->HasInArc(M_PI_F, m_caster))
|
||||
{
|
||||
// Exclusion for Pounce: Facing Limitation was removed in 2.0.1, but it still uses the same, old Ex-Flags
|
||||
// Exclusion for Mutilate:Facing Limitation was removed in 2.0.1 and 3.0.3, but they still use the same, old Ex-Flags
|
||||
|
|
@ -5025,14 +5025,14 @@ SpellCastResult Spell::CheckCast(bool strict)
|
|||
}
|
||||
|
||||
//Target must be facing you.
|
||||
if((m_spellInfo->Attributes == 0x150010) && !target->HasInArc(M_PI_F, m_caster) )
|
||||
if ((m_spellInfo->Attributes == (SPELL_ATTR_UNK4 | SPELL_ATTR_NOT_SHAPESHIFT | SPELL_ATTR_UNK18 | SPELL_ATTR_STOP_ATTACK_TARGET)) && !target->HasInArc(M_PI_F, m_caster))
|
||||
{
|
||||
SendInterrupted(2);
|
||||
return SPELL_FAILED_NOT_INFRONT;
|
||||
}
|
||||
|
||||
// check if target is in combat
|
||||
if (non_caster_target && (m_spellInfo->AttributesEx & SPELL_ATTR_EX_NOT_IN_COMBAT_TARGET) && target->isInCombat())
|
||||
if (non_caster_target && m_spellInfo->HasAttribute(SPELL_ATTR_EX_NOT_IN_COMBAT_TARGET) && target->isInCombat())
|
||||
return SPELL_FAILED_TARGET_AFFECTING_COMBAT;
|
||||
}
|
||||
// zone check
|
||||
|
|
@ -5046,7 +5046,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
|||
|
||||
// not let players cast spells at mount (and let do it to creatures)
|
||||
if (m_caster->IsMounted() && m_caster->GetTypeId()==TYPEID_PLAYER && !m_IsTriggeredSpell &&
|
||||
!IsPassiveSpell(m_spellInfo) && !(m_spellInfo->Attributes & SPELL_ATTR_CASTABLE_WHILE_MOUNTED))
|
||||
!IsPassiveSpell(m_spellInfo) && !m_spellInfo->HasAttribute(SPELL_ATTR_CASTABLE_WHILE_MOUNTED))
|
||||
{
|
||||
if (m_caster->IsTaxiFlying())
|
||||
return SPELL_FAILED_NOT_ON_TAXI;
|
||||
|
|
@ -5951,7 +5951,7 @@ SpellCastResult Spell::CheckCasterAuras() const
|
|||
{
|
||||
// Flag drop spells totally immuned to caster auras
|
||||
// FIXME: find more nice check for all totally immuned spells
|
||||
// AttributesEx3 & 0x10000000?
|
||||
// HasAttribute(SPELL_ATTR_EX3_UNK28) ?
|
||||
if (m_spellInfo->Id == 23336 || // Alliance Flag Drop
|
||||
m_spellInfo->Id == 23334 || // Horde Flag Drop
|
||||
m_spellInfo->Id == 34991) // Summon Netherstorm Flag
|
||||
|
|
@ -5963,7 +5963,7 @@ SpellCastResult Spell::CheckCasterAuras() const
|
|||
|
||||
// Check if the spell grants school or mechanic immunity.
|
||||
// We use bitmasks so the loop is done only once and not on every aura check below.
|
||||
if ( m_spellInfo->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY )
|
||||
if (m_spellInfo->HasAttribute(SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY))
|
||||
{
|
||||
for(int i = 0; i < MAX_EFFECT_INDEX; ++i)
|
||||
{
|
||||
|
|
@ -5984,7 +5984,7 @@ SpellCastResult Spell::CheckCasterAuras() const
|
|||
|
||||
// Check whether the cast should be prevented by any state you might have.
|
||||
SpellCastResult prevented_reason = SPELL_CAST_OK;
|
||||
bool spellUsableWhileStunned = m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_STUNNED;
|
||||
bool spellUsableWhileStunned = m_spellInfo->HasAttribute(SPELL_ATTR_EX5_USABLE_WHILE_STUNNED);
|
||||
|
||||
// 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
|
||||
|
|
@ -6014,9 +6014,9 @@ SpellCastResult Spell::CheckCasterAuras() const
|
|||
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->HasAttribute(SPELL_ATTR_EX5_USABLE_WHILE_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->HasAttribute(SPELL_ATTR_EX5_USABLE_WHILE_FEARED))
|
||||
prevented_reason = SPELL_FAILED_FLEEING;
|
||||
else if (unitflag & UNIT_FLAG_SILENCED && m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE)
|
||||
prevented_reason = SPELL_FAILED_SILENCED;
|
||||
|
|
@ -6047,7 +6047,7 @@ SpellCastResult Spell::CheckCasterAuras() const
|
|||
SpellAuraHolder *holder = itr->second;
|
||||
SpellEntry const * pEntry = holder->GetSpellProto();
|
||||
|
||||
if ((GetSpellSchoolMask(pEntry) & school_immune) && !(pEntry->AttributesEx & SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE))
|
||||
if ((GetSpellSchoolMask(pEntry) & school_immune) && !pEntry->HasAttribute(SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE))
|
||||
continue;
|
||||
if ((1<<(pEntry->Dispel)) & dispel_immune)
|
||||
continue;
|
||||
|
|
@ -6069,11 +6069,11 @@ SpellCastResult Spell::CheckCasterAuras() const
|
|||
return SPELL_FAILED_STUNNED;
|
||||
break;
|
||||
case SPELL_AURA_MOD_CONFUSE:
|
||||
if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED))
|
||||
if (!m_spellInfo->HasAttribute(SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED))
|
||||
return SPELL_FAILED_CONFUSED;
|
||||
break;
|
||||
case SPELL_AURA_MOD_FEAR:
|
||||
if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_FEARED))
|
||||
if (!m_spellInfo->HasAttribute(SPELL_ATTR_EX5_USABLE_WHILE_FEARED))
|
||||
return SPELL_FAILED_FLEEING;
|
||||
break;
|
||||
case SPELL_AURA_MOD_SILENCE:
|
||||
|
|
@ -6212,7 +6212,7 @@ uint32 Spell::CalculatePowerCost(SpellEntry const* spellInfo, Unit* caster, Spel
|
|||
return 0;
|
||||
|
||||
// Spell drain all exist power on cast (Only paladin lay of Hands)
|
||||
if (spellInfo->AttributesEx & SPELL_ATTR_EX_DRAIN_ALL_POWER)
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR_EX_DRAIN_ALL_POWER))
|
||||
{
|
||||
// If power type - health drain all
|
||||
if (spellInfo->powerType == POWER_HEALTH)
|
||||
|
|
@ -6257,14 +6257,14 @@ uint32 Spell::CalculatePowerCost(SpellEntry const* spellInfo, Unit* caster, Spel
|
|||
// Flat mod from caster auras by spell school
|
||||
powerCost += caster->GetInt32Value(UNIT_FIELD_POWER_COST_MODIFIER + school);
|
||||
// Shiv - costs 20 + weaponSpeed*10 energy (apply only to non-triggered spell with energy cost)
|
||||
if (spellInfo->AttributesEx4 & SPELL_ATTR_EX4_SPELL_VS_EXTEND_COST)
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR_EX4_SPELL_VS_EXTEND_COST))
|
||||
powerCost += caster->GetAttackTime(OFF_ATTACK) / 100;
|
||||
// Apply cost mod by spell
|
||||
if (spell)
|
||||
if (Player* modOwner = caster->GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_COST, powerCost, spell);
|
||||
|
||||
if (spellInfo->Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION)
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR_LEVEL_DAMAGE_CALCULATION))
|
||||
powerCost = int32(powerCost/ (1.117f * spellInfo->spellLevel / caster->getLevel() -0.1327f));
|
||||
|
||||
// PCT mod from user auras by school
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue