aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/Spell.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
-rw-r--r--src/server/game/Spells/Spell.cpp144
1 files changed, 67 insertions, 77 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index ada40659922..f9c6b64e7f3 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -492,13 +492,10 @@ void SpellCastTargets::OutDebug() const
TC_LOG_DEBUG("spells", "pitch: %f", m_pitch);
}
-SpellValue::SpellValue(Difficulty diff, SpellInfo const* proto, Unit const* caster)
+SpellValue::SpellValue(SpellInfo const* proto, Unit const* caster)
{
- // todo 6.x
- SpellEffectInfoVector effects = proto->GetEffectsForDifficulty(diff);
- ASSERT(effects.size() <= MAX_SPELL_EFFECTS);
memset(EffectBasePoints, 0, sizeof(EffectBasePoints));
- for (SpellEffectInfo const* effect : effects)
+ for (SpellEffectInfo const* effect : proto->GetEffects())
if (effect)
EffectBasePoints[effect->EffectIndex] = effect->CalcBaseValue(caster, nullptr, 0, -1);
@@ -523,10 +520,8 @@ protected:
Spell::Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags, ObjectGuid originalCasterGUID, bool skipCheck) :
m_spellInfo(info), m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerOrOwner()) ? caster->GetCharmerOrOwner() : caster),
-m_spellValue(new SpellValue(caster->GetMap()->GetDifficultyID(), m_spellInfo, caster)), _spellEvent(nullptr)
+m_spellValue(new SpellValue(m_spellInfo, caster)), _spellEvent(nullptr)
{
- _effects = info->GetEffectsForDifficulty(caster->GetMap()->GetDifficultyID());
-
m_customError = SPELL_CUSTOM_ERROR_NONE;
m_skipCheck = skipCheck;
m_fromClient = false;
@@ -751,7 +746,7 @@ void Spell::SelectSpellTargets()
uint32 processedAreaEffectsMask = 0;
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
{
if (!effect)
continue;
@@ -846,10 +841,10 @@ void Spell::SelectEffectImplicitTargets(SpellEffIndex effIndex, SpellImplicitTar
// targets for effect already selected
if (effectMask & processedEffectMask)
return;
- if (SpellEffectInfo const* _effect = GetEffect(effIndex))
+ if (SpellEffectInfo const* _effect = m_spellInfo->GetEffect(effIndex))
{
// choose which targets we can select at once
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
{
//for (uint32 j = effIndex + 1; j < MAX_SPELL_EFFECTS; ++j)
if (!effect || effect->EffectIndex <= uint32(effIndex))
@@ -1020,7 +1015,7 @@ void Spell::SelectImplicitNearbyTargets(SpellEffIndex effIndex, SpellImplicitTar
return;
}
- SpellEffectInfo const* effect = GetEffect(effIndex);
+ SpellEffectInfo const* effect = m_spellInfo->GetEffect(effIndex);
if (!effect)
return;
@@ -1155,7 +1150,7 @@ void Spell::SelectImplicitConeTargets(SpellEffIndex effIndex, SpellImplicitTarge
std::list<WorldObject*> targets;
SpellTargetObjectTypes objectType = targetType.GetObjectType();
SpellTargetCheckTypes selectionType = targetType.GetCheckType();
- SpellEffectInfo const* effect = GetEffect(effIndex);
+ SpellEffectInfo const* effect = m_spellInfo->GetEffect(effIndex);
if (!effect)
return;
@@ -1241,7 +1236,7 @@ void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTarge
}
std::list<WorldObject*> targets;
- SpellEffectInfo const* effect = GetEffect(effIndex);
+ SpellEffectInfo const* effect = m_spellInfo->GetEffect(effIndex);
if (!effect)
return;
float radius = effect->CalcRadius(m_caster) * m_spellValue->RadiusMod;
@@ -1286,7 +1281,7 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplici
if (SpellTargetPosition const* st = sSpellMgr->GetSpellTargetPosition(m_spellInfo->Id, effIndex))
{
/// @todo fix this check
- if (HasEffect(SPELL_EFFECT_TELEPORT_UNITS) || HasEffect(SPELL_EFFECT_BIND))
+ if (m_spellInfo->HasEffect(SPELL_EFFECT_TELEPORT_UNITS) || m_spellInfo->HasEffect(SPELL_EFFECT_BIND))
dest = SpellDestination(st->target_X, st->target_Y, st->target_Z, st->target_Orientation, (int32)st->target_mapId);
else if (st->target_mapId == m_caster->GetMapId())
dest = SpellDestination(st->target_X, st->target_Y, st->target_Z, st->target_Orientation);
@@ -1334,7 +1329,7 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplici
}
default:
{
- if (SpellEffectInfo const* effect = GetEffect(effIndex))
+ if (SpellEffectInfo const* effect = m_spellInfo->GetEffect(effIndex))
{
float dist = effect->CalcRadius(m_caster);
float angle = targetType.CalcDirectionAngle();
@@ -1393,7 +1388,7 @@ void Spell::SelectImplicitTargetDestTargets(SpellEffIndex effIndex, SpellImplici
break;
default:
{
- if (SpellEffectInfo const* effect = GetEffect(effIndex))
+ if (SpellEffectInfo const* effect = m_spellInfo->GetEffect(effIndex))
{
float angle = targetType.CalcDirectionAngle();
float objSize = target->GetCombatReach();
@@ -1435,7 +1430,7 @@ void Spell::SelectImplicitDestDestTargets(SpellEffIndex effIndex, SpellImplicitT
return;
default:
{
- if (SpellEffectInfo const* effect = GetEffect(effIndex))
+ if (SpellEffectInfo const* effect = m_spellInfo->GetEffect(effIndex))
{
float angle = targetType.CalcDirectionAngle();
float dist = effect->CalcRadius(m_caster);
@@ -1527,7 +1522,7 @@ void Spell::SelectImplicitTargetObjectTargets(SpellEffIndex effIndex, SpellImpli
void Spell::SelectImplicitChainTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType, WorldObject* target, uint32 effMask)
{
- SpellEffectInfo const* effect = GetEffect(effIndex);
+ SpellEffectInfo const* effect = m_spellInfo->GetEffect(effIndex);
if (!effect)
return;
@@ -1538,7 +1533,7 @@ void Spell::SelectImplicitChainTargets(SpellEffIndex effIndex, SpellImplicitTarg
if (maxTargets > 1)
{
// mark damage multipliers as used
- for (SpellEffectInfo const* eff : GetEffects())
+ for (SpellEffectInfo const* eff : m_spellInfo->GetEffects())
if (eff && (effMask & (1 << eff->EffectIndex)))
m_damageMultipliers[eff->EffectIndex] = 1.0f;
m_applyMultiplierMask |= effMask;
@@ -1599,7 +1594,7 @@ void Spell::SelectImplicitTrajTargets(SpellEffIndex effIndex, SpellImplicitTarge
// We should check if triggered spell has greater range (which is true in many cases, and initial spell has too short max range)
// limit max range to 300 yards, sometimes triggered spells can have 50000yds
float bestDist = m_spellInfo->GetMaxRange(false);
- if (SpellInfo const* triggerSpellInfo = sSpellMgr->GetSpellInfo(effect->TriggerSpell))
+ if (SpellInfo const* triggerSpellInfo = sSpellMgr->GetSpellInfo(effect->TriggerSpell, GetCastDifficulty()))
bestDist = std::min(std::max(bestDist, triggerSpellInfo->GetMaxRange(false)), std::min(dist2d, 300.0f));
std::list<WorldObject*>::const_iterator itr = targets.begin();
@@ -1658,7 +1653,7 @@ void Spell::SelectEffectTypeImplicitTargets(uint32 effIndex)
{
// special case for SPELL_EFFECT_SUMMON_RAF_FRIEND and SPELL_EFFECT_SUMMON_PLAYER
/// @todo this is a workaround - target shouldn't be stored in target map for those spells
- SpellEffectInfo const* effect = GetEffect(effIndex);
+ SpellEffectInfo const* effect = m_spellInfo->GetEffect(effIndex);
if (!effect)
return;
switch (effect->Effect)
@@ -2035,7 +2030,7 @@ class ProcReflectDelayed : public BasicEvent
void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*= true*/, bool implicit /*= true*/, Position const* losPosition /*= nullptr*/)
{
uint32 validEffectMask = 0;
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
if (effect && (effectMask & (1 << effect->EffectIndex)) != 0 && CheckEffectTarget(target, effect, losPosition))
validEffectMask |= 1 << effect->EffectIndex;
@@ -2050,7 +2045,7 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*=
return;
// Check for effect immune skip if immuned
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
if (effect && target->IsImmunedToSpellEffect(m_spellInfo, effect->EffectIndex, m_caster))
effectMask &= ~(1 << effect->EffectIndex);
@@ -2133,7 +2128,7 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*=
void Spell::AddGOTarget(GameObject* go, uint32 effectMask)
{
uint32 validEffectMask = 0;
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
if (effect && (effectMask & (1 << effect->EffectIndex)) != 0 && CheckEffectTarget(go, effect))
validEffectMask |= 1 << effect->EffectIndex;
@@ -2191,7 +2186,7 @@ void Spell::AddGOTarget(GameObject* go, uint32 effectMask)
void Spell::AddItemTarget(Item* item, uint32 effectMask)
{
uint32 validEffectMask = 0;
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
if (effect && (effectMask & (1 << effect->EffectIndex)) != 0 && CheckEffectTarget(item, effect))
validEffectMask |= 1 << effect->EffectIndex;
@@ -2240,7 +2235,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
{
uint32 farMask = 0;
// create far target mask
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
if (effect && effect->IsFarUnitTargetEffect())
if ((1 << effect->EffectIndex) & mask)
farMask |= (1 << effect->EffectIndex);
@@ -2255,7 +2250,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
// do far effects on the unit
// can't use default call because of threading, do stuff as fast as possible
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
if (effect && (farMask & (1 << effect->EffectIndex)))
HandleEffects(unit, NULL, NULL, effect->EffectIndex, SPELL_EFFECT_HANDLE_HIT_TARGET);
return;
@@ -2415,7 +2410,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
else if (m_damage > 0)
{
// Fill base damage struct (unitTarget - is real spell target)
- SpellNonMeleeDamage damageInfo(caster, unitTarget, m_spellInfo->Id, m_SpellVisual, m_spellSchoolMask, m_castId);
+ SpellNonMeleeDamage damageInfo(caster, unitTarget, m_spellInfo, m_SpellVisual, m_spellSchoolMask, m_castId);
// Check damage immunity
if (unitTarget->IsImmunedToDamage(m_spellInfo))
@@ -2457,7 +2452,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
else
{
// Fill base damage struct (unitTarget - is real spell target)
- SpellNonMeleeDamage damageInfo(caster, unitTarget, m_spellInfo->Id, m_SpellVisual, m_spellSchoolMask);
+ SpellNonMeleeDamage damageInfo(caster, unitTarget, m_spellInfo, m_SpellVisual, m_spellSchoolMask);
hitMask |= createProcHitMask(&damageInfo, missInfo);
// Do triggers for unit
if (canEffectTrigger)
@@ -2526,7 +2521,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask)
// disable effects to which unit is immune
SpellMissInfo returnVal = SPELL_MISS_IMMUNE;
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
if (effect && (effectMask & (1 << effect->EffectIndex)))
if (unit->IsImmunedToSpellEffect(m_spellInfo, effect->EffectIndex, m_caster))
effectMask &= ~(1 << effect->EffectIndex);
@@ -2579,7 +2574,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask)
}
uint32 aura_effmask = 0;
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
if (effect && (effectMask & (1 << effect->EffectIndex) && effect->IsUnitOwnedAuraEffect()))
aura_effmask |= 1 << effect->EffectIndex;
@@ -2603,7 +2598,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask)
if (m_originalCaster)
{
int32 basePoints[MAX_SPELL_EFFECTS];
- for (SpellEffectInfo const* auraSpellEffect : GetEffects())
+ for (SpellEffectInfo const* auraSpellEffect : m_spellInfo->GetEffects())
if (auraSpellEffect)
basePoints[auraSpellEffect->EffectIndex] = (m_spellValue->CustomBasePointsMask & (1 << auraSpellEffect->EffectIndex)) ?
m_spellValue->EffectBasePoints[auraSpellEffect->EffectIndex] :
@@ -2612,7 +2607,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask)
bool refresh = false;
bool const resetPeriodicTimer = !(_triggeredCastFlags & TRIGGERED_DONT_RESET_PERIODIC_TIMER);
m_spellAura = Aura::TryRefreshStackOrCreate(m_spellInfo, m_castId, effectMask, unit,
- m_originalCaster, basePoints,
+ m_originalCaster, GetCastDifficulty(), basePoints,
m_CastItem, ObjectGuid::Empty, &refresh, resetPeriodicTimer, ObjectGuid::Empty, m_castItemEntry, m_castItemLevel);
if (m_spellAura)
{
@@ -2647,7 +2642,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask)
{
m_spellAura->Remove();
bool found = false;
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
if (effect && (effectMask & (1 << effect->EffectIndex) && effect->Effect != SPELL_EFFECT_APPLY_AURA))
found = true;
if (!found)
@@ -2668,7 +2663,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask)
{
int32 origDuration = duration;
duration = 0;
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
if (effect)
if (AuraEffect const* eff = m_spellAura->GetEffect(effect->EffectIndex))
if (int32 period = eff->GetPeriod()) // period is hastened by UNIT_MOD_CAST_SPEED
@@ -2691,7 +2686,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask)
}
}
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
if (effect && (effectMask & (1 << effect->EffectIndex)))
HandleEffects(unit, NULL, NULL, effect->EffectIndex, SPELL_EFFECT_HANDLE_HIT_TARGET);
@@ -2764,7 +2759,7 @@ void Spell::DoAllEffectOnTarget(GOTargetInfo* target)
PrepareScriptHitHandlers();
CallScriptBeforeHitHandlers(SPELL_MISS_NONE);
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
if (effect && (effectMask & (1 << effect->EffectIndex)))
HandleEffects(NULL, NULL, go, effect->EffectIndex, SPELL_EFFECT_HANDLE_HIT_TARGET);
@@ -2784,7 +2779,7 @@ void Spell::DoAllEffectOnTarget(ItemTargetInfo* target)
PrepareScriptHitHandlers();
CallScriptBeforeHitHandlers(SPELL_MISS_NONE);
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
if (effect && (effectMask & (1 << effect->EffectIndex)))
HandleEffects(NULL, target->item, NULL, effect->EffectIndex, SPELL_EFFECT_HANDLE_HIT_TARGET);
@@ -2801,7 +2796,7 @@ bool Spell::UpdateChanneledTargetList()
uint32 channelTargetEffectMask = m_channelTargetEffectMask;
uint32 channelAuraMask = 0;
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
if (effect && effect->Effect == SPELL_EFFECT_APPLY_AURA)
channelAuraMask |= 1 << effect->EffectIndex;
@@ -2998,7 +2993,7 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
if (!(_triggeredCastFlags & TRIGGERED_IGNORE_AURA_INTERRUPT_FLAGS) && m_spellInfo->IsBreakingStealth())
{
m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CAST);
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
if (effect && effect->GetUsedTargetObjectType() == TARGET_OBJECT_TYPE_UNIT)
{
m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_SPELL_ATTACK);
@@ -3493,7 +3488,7 @@ void Spell::_handle_immediate_phase()
PrepareScriptHitHandlers();
// handle effects with SPELL_EFFECT_HANDLE_HIT mode
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
{
// don't do anything for empty effect
if (!effect || !effect->IsEffect())
@@ -3521,7 +3516,7 @@ void Spell::_handle_finish_phase()
m_caster->m_playerMovingMe->GainSpellComboPoints(m_comboPointGain);
}
- if (m_caster->m_extraAttacks && HasEffect(SPELL_EFFECT_ADD_EXTRA_ATTACKS))
+ if (m_caster->m_extraAttacks && m_spellInfo->HasEffect(SPELL_EFFECT_ADD_EXTRA_ATTACKS))
{
if (Unit* victim = ObjectAccessor::GetUnit(*m_caster, m_targets.GetOrigUnitTargetGUID()))
m_caster->HandleProcExtraAttackFor(victim);
@@ -3572,7 +3567,7 @@ void Spell::update(uint32 difftime)
// check if the player caster has moved before the spell finished
// with the exception of spells affected with SPELL_AURA_CAST_WHILE_WALKING effect
- SpellEffectInfo const* effect = GetEffect(EFFECT_0);
+ SpellEffectInfo const* effect = m_spellInfo->GetEffect(EFFECT_0);
if ((m_caster->GetTypeId() == TYPEID_PLAYER && m_timer != 0) &&
m_caster->isMoving() && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT) &&
((effect && effect->Effect != SPELL_EFFECT_STUCK) || !m_caster->HasUnitMovementFlag(MOVEMENTFLAG_FALLING_FAR)) &&
@@ -3678,7 +3673,7 @@ void Spell::finish(bool ok)
{
// Unsummon statue
uint32 spell = m_caster->m_unitData->CreatedBySpell;
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell);
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell, GetCastDifficulty());
if (spellInfo && spellInfo->IconFileDataId == 134230)
{
TC_LOG_DEBUG("spells", "Statue %s is unsummoned in spell %d finish", m_caster->GetGUID().ToString().c_str(), m_spellInfo->Id);
@@ -3818,7 +3813,7 @@ inline void FillSpellCastFailedArgs(T& packet, ObjectGuid castId, SpellInfo cons
else
{
uint32 item = 0;
- for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(caster->GetMap()->GetDifficultyID()))
+ for (SpellEffectInfo const* effect : spellInfo->GetEffects())
if (effect->ItemType)
item = effect->ItemType;
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item);
@@ -4114,7 +4109,7 @@ void Spell::SendSpellGo()
castFlags |= CAST_FLAG_RUNE_LIST; // rune cooldowns list
}
- if (HasEffect(SPELL_EFFECT_ACTIVATE_RUNE))
+ if (m_spellInfo->HasEffect(SPELL_EFFECT_ACTIVATE_RUNE))
castFlags |= CAST_FLAG_RUNE_LIST; // rune cooldowns list
if (m_targets.HasTraj())
@@ -4290,7 +4285,7 @@ void Spell::SendSpellExecuteLog()
spellExecuteLog.Caster = m_caster->GetGUID();
spellExecuteLog.SpellID = m_spellInfo->Id;
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
{
if (!effect)
continue;
@@ -4803,7 +4798,7 @@ void Spell::HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGOT
gameObjTarget = pGOTarget;
destTarget = &m_destTargets[i]._position;
- effectInfo = GetEffect(i);
+ effectInfo = m_spellInfo->GetEffect(i);
if (!effectInfo)
{
TC_LOG_ERROR("spells", "Spell: %u HandleEffects at EffectIndex: %u missing effect", m_spellInfo->Id, i);
@@ -4950,7 +4945,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
if (m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->ToPlayer()->isMoving() && (!m_caster->IsCharmed() || !m_caster->GetCharmerGUID().IsCreature()) && !m_caster->HasAuraTypeWithAffectMask(SPELL_AURA_CAST_WHILE_WALKING, m_spellInfo))
{
// skip stuck spell to allow use it in falling case and apply spell limitations at movement
- SpellEffectInfo const* effect = GetEffect(EFFECT_0);
+ SpellEffectInfo const* effect = m_spellInfo->GetEffect(EFFECT_0);
if ((!m_caster->HasUnitMovementFlag(MOVEMENTFLAG_FALLING_FAR) || (effect && effect->Effect != SPELL_EFFECT_STUCK)) &&
(IsAutoRepeat() || m_spellInfo->HasAuraInterruptFlag(AURA_INTERRUPT_FLAG_NOT_SEATED)))
return SPELL_FAILED_MOVING;
@@ -5051,7 +5046,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
}
// check pet presence
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
{
if (effect && effect->TargetA.GetTarget() == TARGET_UNIT_PET)
{
@@ -5144,7 +5139,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
if (castResult != SPELL_CAST_OK)
return castResult;
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
{
if (!effect)
continue;
@@ -5181,7 +5176,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
if (!pet)
return SPELL_FAILED_NO_PET;
- SpellInfo const* learn_spellproto = sSpellMgr->GetSpellInfo(effect->TriggerSpell);
+ SpellInfo const* learn_spellproto = sSpellMgr->GetSpellInfo(effect->TriggerSpell, DIFFICULTY_NONE);
if (!learn_spellproto)
return SPELL_FAILED_NOT_KNOWN;
@@ -5212,7 +5207,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
if (!pet || pet->GetOwner() != m_caster)
return SPELL_FAILED_BAD_TARGETS;
- SpellInfo const* learn_spellproto = sSpellMgr->GetSpellInfo(effect->TriggerSpell);
+ SpellInfo const* learn_spellproto = sSpellMgr->GetSpellInfo(effect->TriggerSpell, DIFFICULTY_NONE);
if (!learn_spellproto)
return SPELL_FAILED_NOT_KNOWN;
@@ -5645,7 +5640,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
}
}
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
{
if (!effect)
continue;
@@ -5704,7 +5699,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
}
case SPELL_AURA_MOUNTED:
{
- if (m_caster->IsInWater() && m_spellInfo->HasAura(m_caster->GetMap()->GetDifficultyID(), SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED))
+ if (m_caster->IsInWater() && m_spellInfo->HasAura(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED))
return SPELL_FAILED_ONLY_ABOVEWATER;
// Ignore map check if spell have AreaId. AreaId already checked and this prevent special mount spells
@@ -6069,7 +6064,7 @@ bool Spell::CanAutoCast(Unit* target)
ObjectGuid targetguid = target->GetGUID();
// check if target already has the same or a more powerful aura
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
{
if (!effect)
continue;
@@ -6300,7 +6295,7 @@ SpellCastResult Spell::CheckItems(uint32* param1 /*= nullptr*/, uint32* param2 /
{
// such items should only fail if there is no suitable effect at all - see Rejuvenation Potions for example
SpellCastResult failReason = SPELL_CAST_OK;
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
{
// skip check, pet not required like checks, and for TARGET_UNIT_PET m_targets.GetUnitTarget() is not the real target but the caster
if (!effect || effect->TargetA.GetTarget() == TARGET_UNIT_PET)
@@ -6456,7 +6451,7 @@ SpellCastResult Spell::CheckItems(uint32* param1 /*= nullptr*/, uint32* param2 /
}
// special checks for spell effects
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
{
if (!effect)
continue;
@@ -6491,7 +6486,7 @@ SpellCastResult Spell::CheckItems(uint32* param1 /*= nullptr*/, uint32* param2 /
player->SendEquipError(msg, nullptr, nullptr, effect->ItemType);
return SPELL_FAILED_DONT_REPORT;
}
- else if (SpellEffectInfo const* efi = GetEffect(EFFECT_1))
+ else if (SpellEffectInfo const* efi = m_spellInfo->GetEffect(EFFECT_1))
player->CastSpell(m_caster, efi->CalcValue(), false); // move this to anywhere
return SPELL_FAILED_DONT_REPORT;
}
@@ -6925,7 +6920,7 @@ bool Spell::UpdatePointers()
WorldObject* transport = NULL;
// update effect destinations (in case of moved transport dest target)
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
{
if (!effect)
continue;
@@ -6959,6 +6954,11 @@ CurrentSpellTypes Spell::GetCurrentContainer() const
return CURRENT_GENERIC_SPELL;
}
+Difficulty Spell::GetCastDifficulty() const
+{
+ return m_caster->GetMap()->GetDifficultyID();
+}
+
bool Spell::CheckEffectTarget(Unit const* target, SpellEffectInfo const* effect, Position const* losPosition) const
{
if (!effect->IsEffect())
@@ -7265,7 +7265,7 @@ bool Spell::IsValidDeadOrAliveTarget(Unit const* target) const
void Spell::HandleLaunchPhase()
{
// handle effects with SPELL_EFFECT_HANDLE_LAUNCH mode
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
{
// don't do anything for empty effect
if (!effect || !effect->IsEffect())
@@ -7275,7 +7275,7 @@ void Spell::HandleLaunchPhase()
}
float multiplier[MAX_SPELL_EFFECTS];
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
if (effect && (m_applyMultiplierMask & (1 << effect->EffectIndex)))
multiplier[effect->EffectIndex] = effect->CalcDamageMultiplier(m_originalCaster, this);
@@ -7307,7 +7307,7 @@ void Spell::DoAllEffectOnLaunchTarget(TargetInfo& targetInfo, float* multiplier)
if (!unit)
return;
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
{
if (effect && (targetInfo.effectMask & (1<<effect->EffectIndex)))
{
@@ -7356,7 +7356,7 @@ SpellCastResult Spell::CanOpenLock(uint32 effIndex, uint32 lockId, SkillType& sk
if (!lockInfo)
return SPELL_FAILED_BAD_TARGETS;
- SpellEffectInfo const* effect = GetEffect(effIndex);
+ SpellEffectInfo const* effect = m_spellInfo->GetEffect(effIndex);
if (!effect)
return SPELL_FAILED_BAD_TARGETS; // no idea about correct error
@@ -7691,7 +7691,7 @@ bool Spell::CanExecuteTriggersOnHit(uint32 effMask, SpellInfo const* triggeredBy
{
bool only_on_caster = (triggeredByAura && (triggeredByAura->HasAttribute(SPELL_ATTR4_PROC_ONLY_ON_CASTER)));
// If triggeredByAura has SPELL_ATTR4_PROC_ONLY_ON_CASTER then it can only proc on a cast spell with TARGET_UNIT_CASTER
- for (SpellEffectInfo const* effect : GetEffects())
+ for (SpellEffectInfo const* effect : m_spellInfo->GetEffects())
{
if (effect && ((effMask & (1 << effect->EffectIndex)) && (!only_on_caster || (effect->TargetA.GetTarget() == TARGET_UNIT_CASTER))))
return true;
@@ -7710,7 +7710,7 @@ void Spell::PrepareTriggersExecutedOnHit()
if (!aurEff->IsAffectingSpell(m_spellInfo))
continue;
- if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(aurEff->GetSpellEffectInfo()->TriggerSpell))
+ if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(aurEff->GetSpellEffectInfo()->TriggerSpell, GetCastDifficulty()))
{
// calculate the chance using spell base amount, because aura amount is not updated on combo-points change
// this possibly needs fixing
@@ -7802,16 +7802,6 @@ void Spell::CancelGlobalCooldown()
m_caster->GetSpellHistory()->CancelGlobalCooldown(m_spellInfo);
}
-bool Spell::HasEffect(SpellEffectName effect) const
-{
- for (SpellEffectInfo const* eff : GetEffects())
- {
- if (eff && eff->IsEffect(effect))
- return true;
- }
- return false;
-}
-
namespace Trinity
{