52 return effMask & avalibleEffectMask;
60 if (effMask & (
uint32(1) << i))
98 SF_LOG_ERROR(
"spells",
"Aura::_UnapplyForTarget, target:%u, caster:%u, spell:%u was not found in owners application map!",
104 ASSERT(itr->second == auraApp);
144 std::map<Unit*, uint32> targets;
153 std::map<Unit*, uint32>::iterator existing = targets.find(appIter->second->GetTarget());
155 if (existing == targets.end())
156 targetsToRemove.push_back(appIter->second->GetTarget());
161 if (appIter->second->GetEffectMask() != existing->second || !
CanBeAppliedOn(existing->first))
162 targetsToRemove.push_back(appIter->second->GetTarget());
165 targets.erase(existing);
170 for (std::map<Unit*, uint32>::iterator itr = targets.begin(); itr != targets.end();)
180 if (aurApp->GetTarget() != itr->first)
183 targets.erase(itr++);
197 if (itr->first->IsImmunedToSpellEffect(
GetSpellInfo(), effIndex))
198 itr->second &= ~(1 << effIndex);
210 if (itr->first->IsInFlight())
221 for (Unit::AuraApplicationMap::iterator iter = itr->first->GetAppliedAuras().begin(); iter != itr->first->GetAppliedAuras().end(); ++iter)
223 Aura const* aura = iter->second->GetBase();
234 targets.erase(itr++);
238 if (!
GetOwner()->IsSelfOrInSameMap(itr->first))
241 SF_LOG_FATAL(
"spells",
"Aura %u: Owner %s (map %u) is not in the same map as target %s (map %u).",
GetSpellInfo()->Id,
243 itr->first->GetName().c_str(), itr->first->IsInWorld() ? itr->first->GetMap()->GetId() :
uint32(-1));
246 itr->first->_CreateAuraApplication(
this, itr->second);
252 for (UnitList::iterator itr = targetsToRemove.begin(); itr != targetsToRemove.end(); ++itr)
260 for (std::map<Unit*, uint32>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
266 itr->first->_ApplyAura(aurApp, itr->second);
279 if ((appIter->second->GetEffectsToApply() & (1 << effIndex)) && !appIter->second->HasEffect(effIndex))
280 targetList.push_back(appIter->second->GetTarget());
284 for (UnitList::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
290 (*itr)->_ApplyAuraEffect(
this, effIndex);
302 Spell* modSpell = NULL;
361 if (maxDuration != -1 && modOwner)
386 bool resetPeriodic =
true;
392 if (
int32 ampl = eff->GetAmplitude())
393 minAmplitude = std::min(ampl, minAmplitude);
399 resetPeriodic =
false;
423 maxProcCharges = procEntry->charges;
428 return uint8(maxProcCharges);
439 if ((num > 0) && (charges >
int32(maxCharges)))
440 charges = maxCharges;
442 else if (charges <= 0)
458 std::list<AuraApplication*> applications;
461 for (std::list<AuraApplication*>::const_iterator apptItr = applications.begin(); apptItr != applications.end(); ++apptItr)
462 if (!(*apptItr)->GetRemoveMode())
469 for (std::list<AuraApplication*>::const_iterator apptItr = applications.begin(); apptItr != applications.end(); ++apptItr)
470 if (!(*apptItr)->GetRemoveMode())
490 else if (stackAmount <= 0)
523 player->RestoreAllSpellMods(0,
this);
627 int32 resistChance = 0;
636 if (offensive && auraTarget)
640 return 100 - resistChance;
656 m_effects[i]->SetCanBeRecalculated(recalculateMask & (1 << i));
657 m_effects[i]->CalculatePeriodic(caster,
false,
true);
688 m_effects[i]->HandleEffect(aurApp, mode, apply);
695 if (appIter->second->GetEffectMask())
696 applicationList.push_back(appIter->second);
703 appIter->second->SetNeedClientUpdate();
714 if (saBounds.first != saBounds.second)
719 for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
722 if (!itr->second->IsFitToRequirements(target->
ToPlayer(), zone, area))
725 else if (itr->second->autocast)
727 if (!target->
HasAura(itr->second->spellId))
728 target->
CastSpell(target, itr->second->spellId,
true);
741 for (std::vector<int32>::const_iterator itr = spellTriggered->begin(); itr != spellTriggered->end(); ++itr)
755 for (std::vector<int32>::const_iterator itr = spellTriggered->begin(); itr != spellTriggered->end(); ++itr)
765 for (std::vector<int32>::const_iterator itr = spellTriggered->begin(); itr != spellTriggered->end(); ++itr)
780 for (std::vector<int32>::const_iterator itr = spellTriggered->begin(); itr != spellTriggered->end(); ++itr)
783 triggeredAura->ModStackAmount(
GetStackAmount() - triggeredAura->GetStackAmount());
889 SF_LOG_ERROR(
"spells",
"Aura::HandleAuraSpecificMods: Unknown rank of Arcane Potency (%d) found", aurEff->GetId());
891 caster->
CastSpell(caster, spellId,
true);
913 &basepoints0, NULL, NULL,
true, NULL,
GetEffect(0));
915 &heal, NULL, NULL,
true, NULL,
GetEffect(0));
927 &heal, NULL, NULL,
true, 0,
GetEffect(0));
960 int32 remainingDamage = aurEff->GetAmount() * (aurEff->GetTotalTicks() - aurEff->GetTickNumber());
961 if (remainingDamage > 0)
963 NULL, &remainingDamage, NULL,
true);
993 SF_LOG_ERROR(
"spells",
"Aura::HandleAuraSpecificMods: Unknown rank of Improved Fear (%d) found", aurEff->GetId());
995 caster->
CastSpell(target, spellId,
true);
1023 if (
AuraEffect const* aurEff = aura->GetEffect(0))
1025 float multiplier = float(aurEff->GetAmount());
1028 &basepoints0, NULL, NULL,
true);
1141 if (target != caster)
1176 if (
this == existingAura)
1200 if (
m_spellInfo->IsAuraExclusiveBySpecificWith(existingSpellInfo)
1201 || (sameCaster &&
m_spellInfo->IsAuraExclusiveBySpecificPerCasterWith(existingSpellInfo)))
#define MAX_SPELL_EFFECTS
#define SF_LOG_FATAL(filterType__,...)
#define SF_LOG_ERROR(filterType__,...)
@ SPELL_EFFECT_PERSISTENT_AREA_AURA
@ SPELL_ATTR3_STACK_FOR_DIFF_CASTERS
@ SPELLFAMILY_DEATHKNIGHT
@ SPELL_ATTR8_DONT_RESET_PERIODIC_TIMER
@ SPELL_AURA_PERIODIC_DAMAGE
@ SPELL_AURA_ABILITY_IGNORE_AURASTATE
@ SPELL_AURA_OBS_MOD_HEALTH
@ SPELL_AURA_ADD_PCT_MODIFIER
@ SPELL_AURA_PERIODIC_MANA_LEECH
@ SPELL_AURA_CONVERT_RUNE
@ SPELL_AURA_OBS_MOD_POWER
@ SPELL_AURA_CAST_WHILE_WALKING
@ SPELL_AURA_ADD_FLAT_MODIFIER
@ SPELL_AURA_CONTROL_VEHICLE
@ SPELL_AURA_PERIODIC_HEAL
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE
@ SPELL_AURA_PERIODIC_ENERGIZE
@ SPELL_AURA_PERIODIC_LEECH
@ SPELL_AURA_PERIODIC_DUMMY
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
@ SPELL_AURA_MOD_DISPEL_RESIST
#define UPDATE_TARGET_MAP_INTERVAL
@ SPELL_ATTR0_CU_ENCHANT_PROC
@ SPELL_SPECIFIC_JUDGEMENT
@ SPELL_SPECIFIC_MAGE_POLYMORPH
std::pair< SpellAreaForAreaMap::const_iterator, SpellAreaForAreaMap::const_iterator > SpellAreaForAreaMapBounds
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE_FROM_SAME_CASTER
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE
@ SPELLMOD_RESIST_DISPEL_CHANCE
@ AURA_REMOVE_BY_ENEMY_SPELL
std::list< Unit * > UnitList
T RoundToInterval(T &num, T floor, T ceil)
T CalculatePct(T base, U pct)
AuraRemoveMode GetRemoveMode() const
int32 GetTotalTicks() const
void CalculatePeriodic(Unit *caster, bool resetPeriodicTimer=true, bool load=false)
void HandleAllEffects(AuraApplication *aurApp, uint8 mode, bool apply)
Unit::AuraApplicationList m_removedApplications
void SetLoadedState(int32 maxduration, int32 duration, int32 charges, uint8 stackamount, uint32 recalculateMask, int32 *amount)
virtual void _UnapplyForTarget(Unit *target, Unit *caster, AuraApplication *auraApp)
uint64 GetCasterGUID() const
virtual void FillTargetMap(std::map< Unit *, uint32 > &targets, Unit *caster)=0
const AuraApplication * GetApplicationOfTarget(uint64 guid) const
bool CheckAreaTarget(Unit *target)
int32 GetMaxDuration() const
uint64 GetCastItemGUID() const
bool ModStackAmount(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
AuraEffect * m_effects[MAX_SPELL_EFFECTS]
void SetStackAmount(uint8 num)
Unit * GetUnitOwner() const
bool CanBeSentToClient() const
bool CallScriptCheckAreaTargetHandlers(Unit *target)
bool HasEffect(uint8 effIndex) const
void GetApplicationList(Unit::AuraApplicationList &applicationList) const
void Update(uint32 diff, Unit *caster)
WorldObject * GetOwner() const
bool IsSingleTargetWith(Aura const *aura) const
bool ModCharges(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
bool CanStackWith(Aura const *existingAura) const
ApplicationMap m_applications
int32 GetDuration() const
bool IsUsingCharges() const
void UpdateOwner(uint32 diff, WorldObject *owner)
void UnregisterSingleTarget()
bool IsDeathPersistent() const
bool HasEffectType(AuraType type) const
AuraEffect * GetEffect(uint8 effIndex) const
int32 CalcDispelChance(Unit *auraTarget, bool offensive) const
void SetCharges(uint8 charges)
void UpdateTargetMap(Unit *caster, bool apply=true)
void _InitEffects(uint32 effMask, Unit *caster, int32 *baseAmount)
void SetNeedClientUpdateForTargets() const
int32 CalcMaxDuration() const
void SetDuration(int32 duration, bool withMods=false)
SpellInfo const *const m_spellInfo
AuraObjectType GetType() const
uint8 GetStackAmount() const
void _ApplyEffectForTargets(uint8 effIndex)
WorldObject *const m_owner
SpellInfo const * GetSpellInfo() const
uint64 const m_castItemGuid
bool CanBeAppliedOn(Unit *target)
void HandleAuraSpecificMods(AuraApplication const *aurApp, Unit *caster, bool apply, bool onReapply)
void SetIsSingleTarget(bool val)
void _DeleteRemovedApplications()
Aura(SpellInfo const *spellproto, WorldObject *owner, Unit *caster, Item *castItem, uint64 casterGUID)
virtual void _ApplyForTarget(Unit *target, Unit *caster, AuraApplication *auraApp)
uint8 CalcMaxCharges() const
bool IsAppliedOnTarget(uint64 guid) const
void RecalculateAmountOfEffects()
static uint32 BuildEffectMaskForOwner(SpellInfo const *spellProto, uint32 avalibleEffectMask, WorldObject *owner)
int32 m_updateTargetMapInterval
virtual void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)=0
void _Remove(AuraRemoveMode removeMode)
bool IsSingleTarget() const
static T * GetObjectInOrOutOfWorld(uint64 guid, T *)
uint32 GetGUIDLow() const
void SetSpellModTakingSpell(Spell *spell, bool apply)
void RemoveRunesByAuraEffect(AuraEffect const *aura)
bool HasSpellCooldown(uint32 spell_id) const
Item * GetItemByGuid(uint64 guid) const
T ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell *spell=NULL)
void AddSpellAndCategoryCooldowns(SpellInfo const *spellInfo, uint32 itemId, Spell *spell=NULL, bool infinityCooldown=false)
bool ActivateTaxiPathTo(std::vector< uint32 > const &nodes, Creature *npc=NULL, uint32 spellid=0)
void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time)
void SendCooldownEvent(SpellInfo const *spellInfo, uint32 itemId=0, Spell *spell=NULL, bool setCooldown=true)
uint32 GetSpellCooldownDelay(uint32 spell_id) const
void RemoveSpellCooldown(uint32 spell_id, bool update=false)
bool IsUnitOwnedAuraEffect() const
bool IsTargetingArea() const
SpellEffectInfo Effects[MAX_SPELL_EFFECTS]
bool IsDeathPersistent() const
SpellSpecificType GetSpellSpecific() const
bool HasAreaAuraEffect() const
void RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
bool HealthAbovePct(int32 pct) const
void CombatStop(bool includingCast=false)
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
void _UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMode)
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
void RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID=0, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Player * GetSpellModOwner() const
Spell * FindCurrentSpellBySpellId(uint32 spell_id) const
ShapeshiftForm GetShapeshiftForm() const
Aura * GetAura(uint32 spellId, uint64 casterGUID=0, uint64 itemCasterGUID=0, uint32 reqEffMask=0) const
int32 CalcSpellDuration(SpellInfo const *spellProto)
Aura * AddAura(uint32 spellId, Unit *target)
int32 GetMaxPower(Powers power) const
bool HasAura(uint32 spellId, uint64 casterGUID=0, uint64 itemCasterGUID=0, uint32 reqEffMask=0) const
bool IsDuringRemoveFromWorld() const
void RemoveAurasWithFamily(SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, uint64 casterGUID)
uint32 SpellDamageBonusDone(Unit *victim, SpellInfo const *spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack=1) const
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, uint64 casterGUID=0) const
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply)
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
uint32 SpellDamageBonusTaken(Unit *caster, SpellInfo const *spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack=1) const
AuraEffect * GetDummyAuraEffect(SpellFamilyNames name, uint32 iconId, uint8 effIndex) const
int32 GetTotalAuraModifier(AuraType auratype) const
AuraList & GetSingleCastAuras()
Vehicle * GetVehicleKit() const
Aura * GetAuraOfRankedSpell(uint32 spellId, uint64 casterGUID=0, uint64 itemCasterGUID=0, uint32 reqEffMask=0) const
void RemoveMovementImpairingAuras()
uint8 GetAvailableSeatCount() const
Gets the available seat count.
void GetZoneAndAreaId(uint32 &zoneid, uint32 &areaid) const
uint32 GetDrainSoulExecuteAuraSpellId()
uint32 GetDruidBearFormSpellId()
uint32 GetStealthAuraSpellId()
uint32 GetArcanePotencyTriggerSpellId(uint32 auraSpellId)
uint32 GetImprovedDevouringPlagueDamageSpellId()
uint32 GetImprovedDevouringPlagueHealSpellId()
uint32 GetTheBeastWithinTriggerSpellId()
uint32 GetPaladinTier10HolyBonusAuraSpellId()
uint32 GetGlyphOfBlurredSpeedSprintSpellId()
uint32 GetPolymorphPenguinSpellId()
uint32 GetAvengingWrathAuraSpellId()
uint32 GetHeroicFuryCooldownSpellId()
uint32 GetGlyphOfFreezingTrapAuraSpellId()
uint32 GetPolymorphSheepSpellId()
bool IsUnsavableSpecialAura(uint32 auraSpellId)
uint32 GetImprovedFearTriggerSpellId(uint32 auraSpellId)
uint32 GetPaladinTier10HolyBonusTriggerSpellId()
uint32 GetProwlAuraSpellId()
bool IsUnsavableDruidEclipseAura(uint32 auraSpellId)
uint32 GetDruidFeralTier10BonusTriggerSpellId()
uint32 GetDruidFeralTier10BonusAuraSpellId()
uint32 GetForbearanceAuraSpellId()
uint32 GetGlyphOfBlurredSpeedAuraSpellId()
uint32 GetGlyphOfPenguinAuraSpellId()
uint32 GetStonedAuraTriggerSpellId(uint32 auraSpellId)
uint32 GetInvisibilityFadeSpellId()
uint32 GetAvengingWrathMarkerAuraSpellId()
uint32 GetDruidCatFormSpellId()
uint32 GetRaptureEnergizeSpellId()
uint32 GetTheBeastWithinTalentSpellId()
uint32 GetDruidTier8RestorationAuraSpellId()
uint32 GetGlyphOfPowerWordShieldHealSpellId()
uint32 GetGlyphOfFreezingTrapTriggerSpellId()
uint32 GetSharedSufferingTriggerSpellId()
uint32 GetGlyphOfPowerWordShieldAuraSpellId()
uint32 GetDruidTier8RestorationTriggerSpellId()
uint32 GetRaptureRankedSpellId()