aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/SpellEffects.cpp
diff options
context:
space:
mode:
authorRat <gmstreetrat@gmail.com>2014-11-17 20:38:56 +0100
committerRat <gmstreetrat@gmail.com>2014-11-17 20:38:56 +0100
commite9f9719af2bce7f3bcbe9b7e449a50f03b3e0513 (patch)
tree6e09a5aad017a43282f6a2787855c25787251bd5 /src/server/game/Spells/SpellEffects.cpp
parent588143b9b69a81eee69d5fb3b9690c8aafc1a38f (diff)
Core/Spells: spell system updates (no-compile-version_2)
Diffstat (limited to 'src/server/game/Spells/SpellEffects.cpp')
-rw-r--r--src/server/game/Spells/SpellEffects.cpp400
1 files changed, 175 insertions, 225 deletions
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index c1e588c7edf..bd577af2b5a 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -284,7 +284,7 @@ void Spell::EffectResurrectNew(SpellEffIndex effIndex)
return;
uint32 health = damage;
- uint32 mana = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 mana = GetEffect(effIndex)->MiscValue;
ExecuteLogEffectResurrect(effIndex, target);
target->SetResurrectRequestData(m_caster, health, mana, 0);
SendResurrectRequest(target);
@@ -419,23 +419,6 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
}
case SPELLFAMILY_PRIEST:
{
- // Improved Mind Blast (Mind Blast in shadow form bonus)
- if (m_caster->GetShapeshiftForm() == FORM_SHADOW && (m_spellInfo->SpellFamilyFlags[0] & 0x00002000))
- {
- Unit::AuraEffectList const& ImprMindBlast = m_caster->GetAuraEffectsByType(SPELL_AURA_ADD_FLAT_MODIFIER);
- for (Unit::AuraEffectList::const_iterator i = ImprMindBlast.begin(); i != ImprMindBlast.end(); ++i)
- {
- if ((*i)->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_PRIEST &&
- ((*i)->GetSpellInfo()->SpellIconID == 95))
- {
- int chance = (*i)->GetSpellInfo()->Effects[EFFECT_1].CalcValue(m_caster);
- if (roll_chance_i(chance))
- // Mind Trauma
- m_caster->CastSpell(unitTarget, 48301, true, nullptr);
- break;
- }
- }
- }
break;
}
case SPELLFAMILY_DRUID:
@@ -464,31 +447,14 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
if (AuraEffect const* aurEff = unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_ROGUE, 0x00010000, 0, 0, m_caster->GetGUID()))
{
// count consumed deadly poison doses at target
- bool needConsume = true;
uint32 spellId = aurEff->GetId();
uint32 doses = aurEff->GetBase()->GetStackAmount();
if (doses > combo)
doses = combo;
- // Master Poisoner
- Unit::AuraEffectList const& auraList = player->GetAuraEffectsByType(SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL_NOT_STACK);
- for (Unit::AuraEffectList::const_iterator iter = auraList.begin(); iter != auraList.end(); ++iter)
- {
- if ((*iter)->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_ROGUE && (*iter)->GetSpellInfo()->SpellIconID == 1960)
- {
- uint32 chance = (*iter)->GetSpellInfo()->Effects[EFFECT_2].CalcValue(m_caster);
-
- if (chance && roll_chance_i(chance))
- needConsume = false;
-
- break;
- }
- }
-
- if (needConsume)
- for (uint32 i = 0; i < doses; ++i)
- unitTarget->RemoveAuraFromStack(spellId, m_caster->GetGUID());
+ for (uint32 i = 0; i < doses; ++i)
+ unitTarget->RemoveAuraFromStack(spellId, m_caster->GetGUID());
damage *= doses;
damage += int32(player->GetTotalAttackPowerValue(BASE_ATTACK) * 0.09f * combo);
@@ -618,10 +584,10 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex)
&& effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH)
return;
- uint32 triggered_spell_id = m_spellInfo->Effects[effIndex].TriggerSpell;
+ uint32 triggered_spell_id = GetEffect(effIndex)->TriggerSpell;
/// @todo move those to spell scripts
- if (m_spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_TRIGGER_SPELL
+ if (GetEffect(effIndex)->Effect == SPELL_EFFECT_TRIGGER_SPELL
&& effectHandleMode == SPELL_EFFECT_HANDLE_LAUNCH_TARGET)
{
// special cases
@@ -718,13 +684,13 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex)
SpellCastTargets targets;
if (effectHandleMode == SPELL_EFFECT_HANDLE_LAUNCH_TARGET)
{
- if (!spellInfo->NeedsToBeTriggeredByCaster(m_spellInfo))
+ if (!spellInfo->NeedsToBeTriggeredByCaster(m_spellInfo, m_caster->GetMap()->GetDifficulty()))
return;
targets.SetUnitTarget(unitTarget);
}
else //if (effectHandleMode == SPELL_EFFECT_HANDLE_LAUNCH)
{
- if (spellInfo->NeedsToBeTriggeredByCaster(m_spellInfo) && (m_spellInfo->Effects[effIndex].GetProvidedTargetMask() & TARGET_FLAG_UNIT_MASK))
+ if (spellInfo->NeedsToBeTriggeredByCaster(m_spellInfo, m_caster->GetMap()->GetDifficulty()) && (GetEffect(effIndex)->GetProvidedTargetMask() & TARGET_FLAG_UNIT_MASK))
return;
if (spellInfo->GetExplicitTargetMask() & TARGET_FLAG_DEST_LOCATION)
@@ -738,7 +704,7 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex)
CustomSpellValues values;
// set basepoints for trigger with value effect
- if (m_spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE)
+ if (GetEffect(effIndex)->Effect == SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE)
{
values.AddSpellMod(SPELLVALUE_BASE_POINT0, damage);
values.AddSpellMod(SPELLVALUE_BASE_POINT1, damage);
@@ -760,7 +726,7 @@ void Spell::EffectTriggerMissileSpell(SpellEffIndex effIndex)
&& effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
- uint32 triggered_spell_id = m_spellInfo->Effects[effIndex].TriggerSpell;
+ uint32 triggered_spell_id = GetEffect(effIndex)->TriggerSpell;
// normal case
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(triggered_spell_id);
@@ -773,13 +739,13 @@ void Spell::EffectTriggerMissileSpell(SpellEffIndex effIndex)
SpellCastTargets targets;
if (effectHandleMode == SPELL_EFFECT_HANDLE_HIT_TARGET)
{
- if (!spellInfo->NeedsToBeTriggeredByCaster(m_spellInfo))
+ if (!spellInfo->NeedsToBeTriggeredByCaster(m_spellInfo, m_caster->GetMap()->GetDifficulty()))
return;
targets.SetUnitTarget(unitTarget);
}
else //if (effectHandleMode == SPELL_EFFECT_HANDLE_HIT)
{
- if (spellInfo->NeedsToBeTriggeredByCaster(m_spellInfo) && (m_spellInfo->Effects[effIndex].GetProvidedTargetMask() & TARGET_FLAG_UNIT_MASK))
+ if (spellInfo->NeedsToBeTriggeredByCaster(m_spellInfo, m_caster->GetMap()->GetDifficulty()) && (GetEffect(effIndex)->GetProvidedTargetMask() & TARGET_FLAG_UNIT_MASK))
return;
if (spellInfo->GetExplicitTargetMask() & TARGET_FLAG_DEST_LOCATION)
@@ -790,7 +756,7 @@ void Spell::EffectTriggerMissileSpell(SpellEffIndex effIndex)
CustomSpellValues values;
// set basepoints for trigger with value effect
- if (m_spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_TRIGGER_MISSILE_SPELL_WITH_VALUE)
+ if (GetEffect(effIndex)->Effect == SPELL_EFFECT_TRIGGER_MISSILE_SPELL_WITH_VALUE)
{
// maybe need to set value only when basepoints == 0?
values.AddSpellMod(SPELLVALUE_BASE_POINT0, damage);
@@ -815,7 +781,7 @@ void Spell::EffectForceCast(SpellEffIndex effIndex)
if (!unitTarget)
return;
- uint32 triggered_spell_id = m_spellInfo->Effects[effIndex].TriggerSpell;
+ uint32 triggered_spell_id = GetEffect(effIndex)->TriggerSpell;
// normal case
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(triggered_spell_id);
@@ -826,7 +792,7 @@ void Spell::EffectForceCast(SpellEffIndex effIndex)
return;
}
- if (m_spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_FORCE_CAST && damage)
+ if (GetEffect(effIndex)->Effect == SPELL_EFFECT_FORCE_CAST && damage)
{
switch (m_spellInfo->Id)
{
@@ -850,7 +816,7 @@ void Spell::EffectForceCast(SpellEffIndex effIndex)
CustomSpellValues values;
// set basepoints for trigger with value effect
- if (m_spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_FORCE_CAST_WITH_VALUE)
+ if (GetEffect(effIndex)->Effect == SPELL_EFFECT_FORCE_CAST_WITH_VALUE)
{
// maybe need to set value only when basepoints == 0?
values.AddSpellMod(SPELLVALUE_BASE_POINT0, damage);
@@ -869,7 +835,7 @@ void Spell::EffectTriggerRitualOfSummoning(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
- uint32 triggered_spell_id = m_spellInfo->Effects[effIndex].TriggerSpell;
+ uint32 triggered_spell_id = GetEffect(effIndex)->TriggerSpell;
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(triggered_spell_id);
if (!spellInfo)
@@ -924,12 +890,16 @@ void Spell::EffectJumpDest(SpellEffIndex effIndex)
void Spell::CalculateJumpSpeeds(uint8 i, float dist, float & speedXY, float & speedZ)
{
- if (m_spellInfo->Effects[i].MiscValue)
- speedZ = float(m_spellInfo->Effects[i].MiscValue)/10;
- else if (m_spellInfo->Effects[i].MiscValueB)
- speedZ = float(m_spellInfo->Effects[i].MiscValueB)/10;
- else
- speedZ = 10.0f;
+ SpellEffectInfo const* effect = GetEffect(i);
+ if (effect)
+ {
+ if (effect->MiscValue)
+ speedZ = float(effect->MiscValue) / 10;
+ else if (effect->MiscValueB)
+ speedZ = float(effect->MiscValueB) / 10;
+ else
+ speedZ = 10.0f;
+ }
speedXY = dist * 10.0f / speedZ;
}
@@ -1096,7 +1066,7 @@ void Spell::EffectUnlearnSpecialization(SpellEffIndex effIndex)
return;
Player* player = unitTarget->ToPlayer();
- uint32 spellToUnlearn = m_spellInfo->Effects[effIndex].TriggerSpell;
+ uint32 spellToUnlearn = GetEffect(effIndex)->TriggerSpell;
player->RemoveSpell(spellToUnlearn);
@@ -1108,10 +1078,10 @@ void Spell::EffectPowerDrain(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return;
- if (m_spellInfo->Effects[effIndex].MiscValue < 0 || m_spellInfo->Effects[effIndex].MiscValue >= int8(MAX_POWERS))
+ if (GetEffect(effIndex)->MiscValue < 0 || GetEffect(effIndex)->MiscValue >= int8(MAX_POWERS))
return;
- Powers powerType = Powers(m_spellInfo->Effects[effIndex].MiscValue);
+ Powers powerType = Powers(GetEffect(effIndex)->MiscValue);
if (!unitTarget || !unitTarget->IsAlive() || unitTarget->getPowerType() != powerType || damage < 0)
return;
@@ -1127,7 +1097,7 @@ void Spell::EffectPowerDrain(SpellEffIndex effIndex)
// Don't restore from self drain
if (m_caster != unitTarget)
{
- gainMultiplier = m_spellInfo->Effects[effIndex].CalcValueMultiplier(m_originalCaster, this);
+ gainMultiplier = GetEffect(effIndex)->CalcValueMultiplier(m_originalCaster, this);
int32 gain = int32(newDamage* gainMultiplier);
@@ -1159,7 +1129,7 @@ void Spell::EffectSendEvent(SpellEffIndex effIndex)
// this check was requested by scripters, but it has some downsides:
// now it's impossible to script (using sEventScripts) a cast which misses all targets
// or to have an ability to script the moment spell hits dest (in a case when there are object targets present)
- if (m_spellInfo->Effects[effIndex].GetProvidedTargetMask() & (TARGET_FLAG_UNIT_MASK | TARGET_FLAG_GAMEOBJECT_MASK))
+ if (GetEffect(effIndex)->GetProvidedTargetMask() & (TARGET_FLAG_UNIT_MASK | TARGET_FLAG_GAMEOBJECT_MASK))
return;
// some spells have no target entries in dbc and they use focus target
if (focusObject)
@@ -1167,14 +1137,14 @@ void Spell::EffectSendEvent(SpellEffIndex effIndex)
/// @todo there should be a possibility to pass dest target to event script
}
- TC_LOG_DEBUG("spells", "Spell ScriptStart %u for spellid %u in EffectSendEvent ", m_spellInfo->Effects[effIndex].MiscValue, m_spellInfo->Id);
+ TC_LOG_DEBUG("spells", "Spell ScriptStart %u for spellid %u in EffectSendEvent ", GetEffect(effIndex)->MiscValue, m_spellInfo->Id);
if (ZoneScript* zoneScript = m_caster->GetZoneScript())
- zoneScript->ProcessEvent(target, m_spellInfo->Effects[effIndex].MiscValue);
+ zoneScript->ProcessEvent(target, GetEffect(effIndex)->MiscValue);
else if (InstanceScript* instanceScript = m_caster->GetInstanceScript()) // needed in case Player is the caster
- instanceScript->ProcessEvent(target, m_spellInfo->Effects[effIndex].MiscValue);
+ instanceScript->ProcessEvent(target, GetEffect(effIndex)->MiscValue);
- m_caster->GetMap()->ScriptsStart(sEventScripts, m_spellInfo->Effects[effIndex].MiscValue, m_caster, target);
+ m_caster->GetMap()->ScriptsStart(sEventScripts, GetEffect(effIndex)->MiscValue, m_caster, target);
}
void Spell::EffectPowerBurn(SpellEffIndex effIndex)
@@ -1182,10 +1152,10 @@ void Spell::EffectPowerBurn(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return;
- if (m_spellInfo->Effects[effIndex].MiscValue < 0 || m_spellInfo->Effects[effIndex].MiscValue >= int8(MAX_POWERS))
+ if (GetEffect(effIndex)->MiscValue < 0 || GetEffect(effIndex)->MiscValue >= int8(MAX_POWERS))
return;
- Powers powerType = Powers(m_spellInfo->Effects[effIndex].MiscValue);
+ Powers powerType = Powers(GetEffect(effIndex)->MiscValue);
if (!unitTarget || !unitTarget->IsAlive() || unitTarget->getPowerType() != powerType || damage < 0)
return;
@@ -1201,7 +1171,7 @@ void Spell::EffectPowerBurn(SpellEffIndex effIndex)
int32 newDamage = -(unitTarget->ModifyPower(powerType, -damage));
// NO - Not a typo - EffectPowerBurn uses effect value multiplier - not effect damage multiplier
- float dmgMultiplier = m_spellInfo->Effects[effIndex].CalcValueMultiplier(m_originalCaster, this);
+ float dmgMultiplier = GetEffect(effIndex)->CalcValueMultiplier(m_originalCaster, this);
// add log data before multiplication (need power amount, not damage)
ExecuteLogEffectTakeTargetPower(effIndex, unitTarget, powerType, newDamage, 0.0f);
@@ -1356,7 +1326,7 @@ void Spell::EffectHealthLeech(SpellEffIndex effIndex)
TC_LOG_DEBUG("spells", "HealthLeech :%i", damage);
- float healMultiplier = m_spellInfo->Effects[effIndex].CalcValueMultiplier(m_originalCaster, this);
+ float healMultiplier = GetEffect(effIndex)->CalcValueMultiplier(m_originalCaster, this);
m_damage += damage;
// get max possible damage, don't count overkill for heal
@@ -1491,8 +1461,8 @@ void Spell::EffectCreateItem(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return;
- DoCreateItem(effIndex, m_spellInfo->Effects[effIndex].ItemType);
- ExecuteLogEffectCreateItem(effIndex, m_spellInfo->Effects[effIndex].ItemType);
+ DoCreateItem(effIndex, GetEffect(effIndex)->ItemType);
+ ExecuteLogEffectCreateItem(effIndex, GetEffect(effIndex)->ItemType);
}
void Spell::EffectCreateItem2(SpellEffIndex effIndex)
@@ -1505,7 +1475,7 @@ void Spell::EffectCreateItem2(SpellEffIndex effIndex)
Player* player = unitTarget->ToPlayer();
- uint32 item_id = m_spellInfo->Effects[effIndex].ItemType;
+ uint32 item_id = GetEffect(effIndex)->ItemType;
if (item_id)
DoCreateItem(effIndex, item_id);
@@ -1553,7 +1523,7 @@ void Spell::EffectPersistentAA(SpellEffIndex effIndex)
if (!m_spellAura)
{
Unit* caster = m_caster->GetEntry() == WORLD_TRIGGER ? m_originalCaster : m_caster;
- float radius = m_spellInfo->Effects[effIndex].CalcRadius(caster);
+ float radius = GetEffect(effIndex)->CalcRadius(caster);
// Caster not in world, might be spell triggered from aura removal
if (!caster->IsInWorld())
@@ -1588,10 +1558,10 @@ void Spell::EffectEnergize(SpellEffIndex effIndex)
if (!unitTarget->IsAlive())
return;
- if (m_spellInfo->Effects[effIndex].MiscValue < 0 || m_spellInfo->Effects[effIndex].MiscValue >= int8(MAX_POWERS))
+ if (GetEffect(effIndex)->MiscValue < 0 || GetEffect(effIndex)->MiscValue >= int8(MAX_POWERS))
return;
- Powers power = Powers(m_spellInfo->Effects[effIndex].MiscValue);
+ Powers power = Powers(GetEffect(effIndex)->MiscValue);
if (unitTarget->GetTypeId() == TYPEID_PLAYER && unitTarget->getPowerType() != power && !(m_spellInfo->AttributesEx7 & SPELL_ATTR7_CAN_RESTORE_SECONDARY_POWER))
return;
@@ -1697,10 +1667,10 @@ void Spell::EffectEnergizePct(SpellEffIndex effIndex)
if (!unitTarget->IsAlive())
return;
- if (m_spellInfo->Effects[effIndex].MiscValue < 0 || m_spellInfo->Effects[effIndex].MiscValue >= int8(MAX_POWERS))
+ if (GetEffect(effIndex)->MiscValue < 0 || GetEffect(effIndex)->MiscValue >= int8(MAX_POWERS))
return;
- Powers power = Powers(m_spellInfo->Effects[effIndex].MiscValue);
+ Powers power = Powers(GetEffect(effIndex)->MiscValue);
if (unitTarget->GetTypeId() == TYPEID_PLAYER && unitTarget->getPowerType() != power && !(m_spellInfo->AttributesEx7 & SPELL_ATTR7_CAN_RESTORE_SECONDARY_POWER))
return;
@@ -1905,7 +1875,7 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
if (m_CastItem->GetOwnerGUID() != player->GetGUID())
return;
- uint32 newitemid = m_spellInfo->Effects[effIndex].ItemType;
+ uint32 newitemid = GetEffect(effIndex)->ItemType;
if (!newitemid)
return;
@@ -2022,14 +1992,14 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
- uint32 entry = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 entry = GetEffect(effIndex)->MiscValue;
if (!entry)
return;
- SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(m_spellInfo->Effects[effIndex].MiscValueB);
+ SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(GetEffect(effIndex)->MiscValueB);
if (!properties)
{
- TC_LOG_ERROR("spells", "EffectSummonType: Unhandled summon type %u", m_spellInfo->Effects[effIndex].MiscValueB);
+ TC_LOG_ERROR("spells", "EffectSummonType: Unhandled summon type %u", GetEffect(effIndex)->MiscValueB);
return;
}
@@ -2130,7 +2100,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
}
default:
{
- float radius = m_spellInfo->Effects[effIndex].CalcRadius();
+ float radius = GetEffect(effIndex)->CalcRadius();
TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
@@ -2175,8 +2145,8 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
// The spell that this effect will trigger. It has SPELL_AURA_CONTROL_VEHICLE
uint32 spellId = VEHICLE_SPELL_RIDE_HARDCODED;
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(m_spellInfo->Effects[effIndex].CalcValue());
- if (spellInfo && spellInfo->HasAura(SPELL_AURA_CONTROL_VEHICLE))
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(GetEffect(effIndex)->CalcValue());
+ if (spellInfo && spellInfo->HasAura(m_originalCaster->GetMap()->GetDifficulty(), SPELL_AURA_CONTROL_VEHICLE))
spellId = spellInfo->Id;
// Hard coded enter vehicle spell
@@ -2214,7 +2184,7 @@ void Spell::EffectLearnSpell(SpellEffIndex effIndex)
Player* player = unitTarget->ToPlayer();
- uint32 spellToLearn = (m_spellInfo->Id == 483 || m_spellInfo->Id == 55884) ? damage : m_spellInfo->Effects[effIndex].TriggerSpell;
+ uint32 spellToLearn = (m_spellInfo->Id == 483 || m_spellInfo->Id == 55884) ? damage : GetEffect(effIndex)->TriggerSpell;
player->LearnSpell(spellToLearn, false);
TC_LOG_DEBUG("spells", "Spell: %s has learned spell %u from %s", player->GetGUID().ToString().c_str(), spellToLearn, m_caster->GetGUID().ToString().c_str());
@@ -2229,7 +2199,7 @@ void Spell::EffectDispel(SpellEffIndex effIndex)
return;
// Create dispel mask by dispel type
- uint32 dispel_type = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 dispel_type = GetEffect(effIndex)->MiscValue;
uint32 dispelMask = SpellInfo::GetDispelMask(DispelType(dispel_type));
DispelChargesList dispel_list;
@@ -2316,12 +2286,15 @@ void Spell::EffectDispel(SpellEffIndex effIndex)
// Devour Magic
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellInfo->GetCategory() == SPELLCATEGORY_DEVOUR_MAGIC)
{
- int32 heal_amount = m_spellInfo->Effects[EFFECT_1].CalcValue(m_caster);
- m_caster->CastCustomSpell(m_caster, 19658, &heal_amount, NULL, NULL, true);
- // Glyph of Felhunter
- if (Unit* owner = m_caster->GetOwner())
+ if (SpellEffectInfo const* effect = GetEffect(EFFECT_1))
+ {
+ int32 heal_amount = effect->CalcValue(m_caster);
+ m_caster->CastCustomSpell(m_caster, 19658, &heal_amount, NULL, NULL, true);
+ // Glyph of Felhunter
+ if (Unit* owner = m_caster->GetOwner())
if (owner->GetAura(56249))
owner->CastCustomSpell(owner, 19658, &heal_amount, NULL, NULL, true);
+ }
}
}
@@ -2384,7 +2357,7 @@ void Spell::EffectAddFarsight(SpellEffIndex effIndex)
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return;
- float radius = m_spellInfo->Effects[effIndex].CalcRadius();
+ float radius = GetEffect(effIndex)->CalcRadius();
int32 duration = m_spellInfo->GetDuration();
// Caster not in world, might be spell triggered from aura removal
if (!m_caster->IsInWorld())
@@ -2423,7 +2396,7 @@ void Spell::EffectTeleUnitsFaceCaster(SpellEffIndex effIndex)
if (unitTarget->IsInFlight())
return;
- float dis = m_spellInfo->Effects[effIndex].CalcRadius(m_caster);
+ float dis = GetEffect(effIndex)->CalcRadius(m_caster);
float fx, fy, fz;
m_caster->GetClosePoint(fx, fy, fz, unitTarget->GetObjectSize(), dis);
@@ -2442,7 +2415,7 @@ void Spell::EffectLearnSkill(SpellEffIndex effIndex)
if (damage < 0)
return;
- uint32 skillid = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 skillid = GetEffect(effIndex)->MiscValue;
SkillRaceClassInfoEntry const* rcEntry = GetSkillRaceClassInfo(skillid, unitTarget->getRace(), unitTarget->getClass());
if (!rcEntry)
return;
@@ -2452,7 +2425,7 @@ void Spell::EffectLearnSkill(SpellEffIndex effIndex)
return;
uint16 skillval = unitTarget->ToPlayer()->GetPureSkillValue(skillid);
- unitTarget->ToPlayer()->SetSkill(skillid, m_spellInfo->Effects[effIndex].CalcValue(), std::max<uint16>(skillval, 1), tier->Value[damage - 1]);
+ unitTarget->ToPlayer()->SetSkill(skillid, GetEffect(effIndex)->CalcValue(), std::max<uint16>(skillval, 1), tier->Value[damage - 1]);
}
void Spell::EffectPlayMovie(SpellEffIndex effIndex)
@@ -2462,12 +2435,14 @@ void Spell::EffectPlayMovie(SpellEffIndex effIndex)
if (unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
+ if (SpellEffectInfo const* effect = GetEffect(effIndex))
+ {
+ uint32 movieId = effect->MiscValue;
+ if (!sMovieStore.LookupEntry(movieId))
+ return;
- uint32 movieId = GetSpellInfo()->Effects[effIndex].MiscValue;
- if (!sMovieStore.LookupEntry(movieId))
- return;
-
- unitTarget->ToPlayer()->SendMovieStart(movieId);
+ unitTarget->ToPlayer()->SendMovieStart(movieId);
+ }
}
void Spell::EffectTradeSkill(SpellEffIndex /*effIndex*/)
@@ -2502,7 +2477,7 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex)
player->DestroyItemCount(itemTarget, count, true);
unitTarget = player;
// and add a scroll
- DoCreateItem(effIndex, m_spellInfo->Effects[effIndex].ItemType);
+ DoCreateItem(effIndex, GetEffect(effIndex)->ItemType);
itemTarget = NULL;
m_targets.SetItemTarget(NULL);
}
@@ -2512,7 +2487,7 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex)
if (!(m_CastItem && m_CastItem->GetTemplate()->Flags[0] & ITEM_PROTO_FLAG_TRIGGERED_CAST))
player->UpdateCraftSkill(m_spellInfo->Id);
- uint32 enchant_id = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 enchant_id = GetEffect(effIndex)->MiscValue;
if (!enchant_id)
return;
@@ -2558,7 +2533,7 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex)
if (!player)
return;
- uint32 enchantId = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 enchantId = GetEffect(effIndex)->MiscValue;
if (!enchantId)
return;
@@ -2622,7 +2597,7 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex)
if (!itemTarget)
return;
- uint32 enchant_id = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 enchant_id = GetEffect(effIndex)->MiscValue;
if (!enchant_id)
{
@@ -2757,7 +2732,7 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex)
owner = m_originalCaster->GetCharmerOrOwnerPlayerOrPlayerItself();
}
- uint32 petentry = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 petentry = GetEffect(effIndex)->MiscValue;
if (!owner)
{
@@ -2843,7 +2818,7 @@ void Spell::EffectLearnPetSpell(SpellEffIndex effIndex)
if (!pet)
return;
- SpellInfo const* learn_spellproto = sSpellMgr->GetSpellInfo(m_spellInfo->Effects[effIndex].TriggerSpell);
+ SpellInfo const* learn_spellproto = sSpellMgr->GetSpellInfo(GetEffect(effIndex)->TriggerSpell);
if (!learn_spellproto)
return;
@@ -2898,9 +2873,11 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
// multiple weapon dmg effect workaround
// execute only the last weapon damage
// and handle all effects at once
- for (uint32 j = effIndex + 1; j < MAX_SPELL_EFFECTS; ++j)
+ for (SpellEffectInfo const* effect : GetEffects())
{
- switch (m_spellInfo->Effects[j].Effect)
+ if (!effect)
+ continue;
+ switch (effect->Effect)
{
case SPELL_EFFECT_WEAPON_DAMAGE:
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL:
@@ -2988,48 +2965,14 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
// Blood Strike
if (m_spellInfo->SpellFamilyFlags[0] & 0x400000)
{
- float bonusPct = m_spellInfo->Effects[EFFECT_2].CalcValue(m_caster) * unitTarget->GetDiseasesByCaster(m_caster->GetGUID()) / 2.0f;
- // Death Knight T8 Melee 4P Bonus
- if (AuraEffect const* aurEff = m_caster->GetAuraEffect(64736, EFFECT_0))
- AddPct(bonusPct, aurEff->GetAmount());
- AddPct(totalDamagePercentMod, bonusPct);
- break;
- }
- // Death Strike
- if (m_spellInfo->SpellFamilyFlags[0] & 0x10)
- {
- // Glyph of Death Strike
- // 2% more damage per 5 runic power, up to a maximum of 40%
- if (AuraEffect const* aurEff = m_caster->GetAuraEffect(59336, EFFECT_0))
- if (uint32 runic = std::min<uint32>(uint32(m_caster->GetPower(POWER_RUNIC_POWER) / 2.5f), aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue(m_caster)))
- AddPct(totalDamagePercentMod, runic);
- break;
- }
- // Obliterate (12.5% more damage per disease)
- if (m_spellInfo->SpellFamilyFlags[1] & 0x20000)
- {
- float bonusPct = m_spellInfo->Effects[EFFECT_2].CalcValue(m_caster) * unitTarget->GetDiseasesByCaster(m_caster->GetGUID(), false) / 2.0f;
- // Death Knight T8 Melee 4P Bonus
- if (AuraEffect const* aurEff = m_caster->GetAuraEffect(64736, EFFECT_0))
- AddPct(bonusPct, aurEff->GetAmount());
- AddPct(totalDamagePercentMod, bonusPct);
- break;
- }
- // Blood-Caked Strike - Blood-Caked Blade
- if (m_spellInfo->SpellIconID == 1736)
- {
- AddPct(totalDamagePercentMod, unitTarget->GetDiseasesByCaster(m_caster->GetGUID()) * 50.0f);
- break;
- }
- // Heart Strike
- if (m_spellInfo->SpellFamilyFlags[0] & 0x1000000)
- {
- float bonusPct = m_spellInfo->Effects[EFFECT_2].CalcValue(m_caster) * unitTarget->GetDiseasesByCaster(m_caster->GetGUID());
- // Death Knight T8 Melee 4P Bonus
- if (AuraEffect const* aurEff = m_caster->GetAuraEffect(64736, EFFECT_0))
- AddPct(bonusPct, aurEff->GetAmount());
-
- AddPct(totalDamagePercentMod, bonusPct);
+ if (SpellEffectInfo const* effect = GetEffect(EFFECT_2))
+ {
+ float bonusPct = effect->CalcValue(m_caster) * unitTarget->GetDiseasesByCaster(m_caster->GetGUID()) / 2.0f;
+ // Death Knight T8 Melee 4P Bonus
+ if (AuraEffect const* aurEff = m_caster->GetAuraEffect(64736, EFFECT_0))
+ AddPct(bonusPct, aurEff->GetAmount());
+ AddPct(totalDamagePercentMod, bonusPct);
+ }
break;
}
break;
@@ -3038,20 +2981,22 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
bool normalized = false;
float weaponDamagePercentMod = 1.0f;
- for (int j = 0; j < MAX_SPELL_EFFECTS; ++j)
+ for (SpellEffectInfo const* effect : GetEffects())
{
- switch (m_spellInfo->Effects[j].Effect)
+ if (!effect)
+ continue;
+ switch (effect->Effect)
{
case SPELL_EFFECT_WEAPON_DAMAGE:
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL:
- fixed_bonus += CalculateDamage(j, unitTarget);
+ fixed_bonus += CalculateDamage(effect->EffectIndex, unitTarget);
break;
case SPELL_EFFECT_NORMALIZED_WEAPON_DMG:
- fixed_bonus += CalculateDamage(j, unitTarget);
+ fixed_bonus += CalculateDamage(effect->EffectIndex, unitTarget);
normalized = true;
break;
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE:
- ApplyPct(weaponDamagePercentMod, CalculateDamage(j, unitTarget));
+ ApplyPct(weaponDamagePercentMod, CalculateDamage(effect->EffectIndex, unitTarget));
break;
default:
break; // not weapon damage effect, just skip
@@ -3083,11 +3028,13 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
int32 weaponDamage = m_caster->CalculateDamage(m_attackType, normalized, true);
// Sequence is important
- for (int j = 0; j < MAX_SPELL_EFFECTS; ++j)
+ for (SpellEffectInfo const* effect : GetEffects())
{
+ if (!effect)
+ continue;
// We assume that a spell have at most one fixed_bonus
// and at most one weaponDamagePercentMod
- switch (m_spellInfo->Effects[j].Effect)
+ switch (effect->Effect)
{
case SPELL_EFFECT_WEAPON_DAMAGE:
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL:
@@ -3189,7 +3136,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
- uint32 gameobject_id = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 gameobject_id = GetEffect(effIndex)->MiscValue;
GameObject* pGameObj = new GameObject;
@@ -3321,7 +3268,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
case 55693: // Remove Collapsing Cave Aura
if (!unitTarget)
return;
- unitTarget->RemoveAurasDueToSpell(m_spellInfo->Effects[effIndex].CalcValue());
+ unitTarget->RemoveAurasDueToSpell(GetEffect(effIndex)->CalcValue());
break;
// Bending Shinbone
case 8856:
@@ -3455,7 +3402,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
case 45151:
{
//Workaround for Range ... should be global for every ScriptEffect
- float radius = m_spellInfo->Effects[effIndex].CalcRadius();
+ float radius = GetEffect(effIndex)->CalcRadius();
if (unitTarget && unitTarget->GetTypeId() == TYPEID_PLAYER && unitTarget->GetDistance(m_caster) >= radius && !unitTarget->HasAura(46394) && unitTarget != m_caster)
unitTarget->CastSpell(unitTarget, 46394, true);
@@ -3567,7 +3514,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
return;
float x, y, z;
- float radius = m_spellInfo->Effects[effIndex].CalcRadius();
+ float radius = GetEffect(effIndex)->CalcRadius();
for (uint8 i = 0; i < 15; ++i)
{
m_caster->GetRandomPoint(*destTarget, radius, x, y, z);
@@ -3613,8 +3560,9 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || effIndex != 0)
return;
- uint32 spellID = m_spellInfo->Effects[EFFECT_0].CalcValue();
- uint32 questID = m_spellInfo->Effects[EFFECT_1].CalcValue();
+ // Effects for 58418 and 58420 are all DIFFICULTY_NONE so always valid
+ uint32 spellID = GetEffect(EFFECT_0)->CalcValue();
+ uint32 questID = GetEffect(EFFECT_1)->CalcValue();
if (unitTarget->ToPlayer()->GetQuestStatus(questID) == QUEST_STATUS_COMPLETE)
unitTarget->CastSpell(unitTarget, spellID, true);
@@ -3664,7 +3612,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
{
/// @todo a hack, range = 11, should after some time cast, otherwise too far
m_caster->CastSpell(parent, 62496, true);
- unitTarget->CastSpell(parent, m_spellInfo->Effects[EFFECT_0].CalcValue());
+ unitTarget->CastSpell(parent, GetEffect(EFFECT_0)->CalcValue()); // DIFFICULTY_NONE, so effect always valid
}
}
}
@@ -3856,7 +3804,7 @@ void Spell::EffectDuel(SpellEffIndex effIndex)
//CREATE DUEL FLAG OBJECT
GameObject* pGameObj = new GameObject;
- uint32 gameobject_id = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 gameobject_id = GetEffect(effIndex)->MiscValue;
Map* map = m_caster->GetMap();
if (!pGameObj->Create(sObjectMgr->GetGenerator<HighGuid::GameObject>()->Generate(), gameobject_id,
@@ -3981,7 +3929,7 @@ void Spell::EffectActivateObject(SpellEffIndex /*effIndex*/)
ScriptInfo activateCommand;
activateCommand.command = SCRIPT_COMMAND_ACTIVATE_OBJECT;
- // int32 unk = m_spellInfo->Effects[effIndex].MiscValue; // This is set for EffectActivateObject spells; needs research
+ // int32 unk = GetEffect(effIndex)->MiscValue; // This is set for EffectActivateObject spells; needs research
gameObjTarget->GetMap()->ScriptCommandStart(activateCommand, 0, m_caster, gameObjTarget);
}
@@ -4020,7 +3968,7 @@ void Spell::EffectApplyGlyph(SpellEffIndex effIndex)
}
// apply new one
- if (uint32 newGlyph = m_spellInfo->Effects[effIndex].MiscValue)
+ if (uint32 newGlyph = GetEffect(effIndex)->MiscValue)
{
if (GlyphPropertiesEntry const* newGlyphProperties = sGlyphPropertiesStore.LookupEntry(newGlyph))
{
@@ -4078,9 +4026,9 @@ void Spell::EffectEnchantHeldItem(SpellEffIndex effIndex)
if (!item->IsEquipped())
return;
- if (m_spellInfo->Effects[effIndex].MiscValue)
+ if (GetEffect(effIndex)->MiscValue)
{
- uint32 enchant_id = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 enchant_id = GetEffect(effIndex)->MiscValue;
int32 duration = m_spellInfo->GetDuration(); //Try duration index first ..
if (!duration)
duration = damage;//+1; //Base points after ..
@@ -4174,7 +4122,7 @@ void Spell::EffectFeedPet(SpellEffIndex effIndex)
player->DestroyItemCount(foodItem, count, true);
/// @todo fix crash when a spell has two effects, both pointed at the same item target
- m_caster->CastCustomSpell(pet, m_spellInfo->Effects[effIndex].TriggerSpell, &benefit, NULL, NULL, true);
+ m_caster->CastCustomSpell(pet, GetEffect(effIndex)->TriggerSpell, &benefit, NULL, NULL, true);
}
void Spell::EffectDismissPet(SpellEffIndex effIndex)
@@ -4196,8 +4144,8 @@ void Spell::EffectSummonObject(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
- uint32 go_id = m_spellInfo->Effects[effIndex].MiscValue;
- uint8 slot = m_spellInfo->Effects[effIndex].Effect - SPELL_EFFECT_SUMMON_OBJECT_SLOT1;
+ uint32 go_id = GetEffect(effIndex)->MiscValue;
+ uint8 slot = GetEffect(effIndex)->Effect - SPELL_EFFECT_SUMMON_OBJECT_SLOT1;
ObjectGuid guid = m_caster->m_ObjectSlot[slot];
if (!guid.IsEmpty())
{
@@ -4332,7 +4280,7 @@ void Spell::EffectReputation(SpellEffIndex effIndex)
int32 repChange = damage;
- uint32 factionId = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 factionId = GetEffect(effIndex)->MiscValue;
FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId);
if (!factionEntry)
@@ -4352,7 +4300,7 @@ void Spell::EffectQuestComplete(SpellEffIndex effIndex)
return;
Player* player = unitTarget->ToPlayer();
- uint32 questId = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 questId = GetEffect(effIndex)->MiscValue;
if (questId)
{
Quest const* quest = sObjectMgr->GetQuestTemplate(questId);
@@ -4396,7 +4344,7 @@ void Spell::EffectSelfResurrect(SpellEffIndex effIndex)
if (damage < 0)
{
health = uint32(-damage);
- mana = m_spellInfo->Effects[effIndex].MiscValue;
+ mana = GetEffect(effIndex)->MiscValue;
}
// percent case
else
@@ -4509,13 +4457,13 @@ void Spell::EffectKnockBack(SpellEffIndex effIndex)
unitTarget->InterruptNonMeleeSpells(true);
float ratio = 0.1f;
- float speedxy = float(m_spellInfo->Effects[effIndex].MiscValue) * ratio;
+ float speedxy = float(GetEffect(effIndex)->MiscValue) * ratio;
float speedz = float(damage) * ratio;
if (speedxy < 0.1f && speedz < 0.1f)
return;
float x, y;
- if (m_spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_KNOCK_BACK_DEST)
+ if (GetEffect(effIndex)->Effect == SPELL_EFFECT_KNOCK_BACK_DEST)
{
if (m_targets.HasDst())
destTarget->GetPosition(x, y);
@@ -4538,7 +4486,7 @@ void Spell::EffectLeapBack(SpellEffIndex effIndex)
if (!unitTarget)
return;
- float speedxy = float(m_spellInfo->Effects[effIndex].MiscValue)/10;
+ float speedxy = float(GetEffect(effIndex)->MiscValue)/10;
float speedz = float(damage/10);
//1891: Disengage
m_caster->JumpTo(speedxy, speedz, m_spellInfo->SpellIconID != 1891);
@@ -4553,7 +4501,7 @@ void Spell::EffectQuestClear(SpellEffIndex effIndex)
return;
Player* player = unitTarget->ToPlayer();
- uint32 quest_id = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 quest_id = GetEffect(effIndex)->MiscValue;
Quest const* quest = sObjectMgr->GetQuestTemplate(quest_id);
@@ -4595,7 +4543,7 @@ void Spell::EffectSendTaxi(SpellEffIndex effIndex)
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
- unitTarget->ToPlayer()->ActivateTaxiPathTo(m_spellInfo->Effects[effIndex].MiscValue, m_spellInfo->Id);
+ unitTarget->ToPlayer()->ActivateTaxiPathTo(GetEffect(effIndex)->MiscValue, m_spellInfo->Id);
}
void Spell::EffectPullTowards(SpellEffIndex effIndex)
@@ -4607,7 +4555,7 @@ void Spell::EffectPullTowards(SpellEffIndex effIndex)
return;
Position pos;
- if (m_spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_PULL_TOWARDS_DEST)
+ if (GetEffect(effIndex)->Effect == SPELL_EFFECT_PULL_TOWARDS_DEST)
{
if (m_targets.HasDst())
pos.Relocate(*destTarget);
@@ -4619,7 +4567,7 @@ void Spell::EffectPullTowards(SpellEffIndex effIndex)
pos.Relocate(m_caster);
}
- float speedXY = float(m_spellInfo->Effects[effIndex].MiscValue) * 0.1f;
+ float speedXY = float(GetEffect(effIndex)->MiscValue) * 0.1f;
float speedZ = unitTarget->GetDistance(pos) / speedXY * 0.5f * Movement::gravity;
unitTarget->GetMotionMaster()->MoveJump(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), speedXY, speedZ);
@@ -4633,7 +4581,7 @@ void Spell::EffectDispelMechanic(SpellEffIndex effIndex)
if (!unitTarget)
return;
- uint32 mechanic = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 mechanic = GetEffect(effIndex)->MiscValue;
DispelList dispel_list;
Unit::AuraMap const& auras = unitTarget->GetOwnedAuras();
for (Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
@@ -4752,7 +4700,7 @@ void Spell::EffectDurabilityDamage(SpellEffIndex effIndex)
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
- int32 slot = m_spellInfo->Effects[effIndex].MiscValue;
+ int32 slot = GetEffect(effIndex)->MiscValue;
// -1 means all player equipped items and -2 all items
if (slot < 0)
@@ -4781,7 +4729,7 @@ void Spell::EffectDurabilityDamagePCT(SpellEffIndex effIndex)
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
- int32 slot = m_spellInfo->Effects[effIndex].MiscValue;
+ int32 slot = GetEffect(effIndex)->MiscValue;
// FIXME: some spells effects have value -1/-2
// Possibly its mean -1 all player equipped items and -2 all items
@@ -4818,7 +4766,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
- uint32 name_id = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 name_id = GetEffect(effIndex)->MiscValue;
GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(name_id);
@@ -4833,9 +4781,9 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex)
if (m_targets.HasDst())
destTarget->GetPosition(fx, fy, fz);
//FIXME: this can be better check for most objects but still hack
- else if (m_spellInfo->Effects[effIndex].HasRadius() && m_spellInfo->Speed == 0)
+ else if (GetEffect(effIndex)->HasRadius() && m_spellInfo->Speed == 0)
{
- float dis = m_spellInfo->Effects[effIndex].CalcRadius(m_originalCaster);
+ float dis = GetEffect(effIndex)->CalcRadius(m_originalCaster);
m_caster->GetClosePoint(fx, fy, fz, DEFAULT_WORLD_OBJECT_SIZE, dis);
}
else
@@ -5057,7 +5005,7 @@ void Spell::EffectStealBeneficialBuff(SpellEffIndex effIndex)
DispelChargesList steal_list;
// Create dispel mask by dispel type
- uint32 dispelMask = SpellInfo::GetDispelMask(DispelType(m_spellInfo->Effects[effIndex].MiscValue));
+ uint32 dispelMask = SpellInfo::GetDispelMask(DispelType(GetEffect(effIndex)->MiscValue));
Unit::AuraMap const& auras = unitTarget->GetOwnedAuras();
for (Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
{
@@ -5157,7 +5105,7 @@ void Spell::EffectKillCreditPersonal(SpellEffIndex effIndex)
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
- unitTarget->ToPlayer()->KilledMonsterCredit(m_spellInfo->Effects[effIndex].MiscValue);
+ unitTarget->ToPlayer()->KilledMonsterCredit(GetEffect(effIndex)->MiscValue);
}
void Spell::EffectKillCredit(SpellEffIndex effIndex)
@@ -5168,7 +5116,7 @@ void Spell::EffectKillCredit(SpellEffIndex effIndex)
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
- int32 creatureEntry = m_spellInfo->Effects[effIndex].MiscValue;
+ int32 creatureEntry = GetEffect(effIndex)->MiscValue;
if (!creatureEntry)
{
if (m_spellInfo->Id == 42793) // Burn Body
@@ -5187,7 +5135,7 @@ void Spell::EffectQuestFail(SpellEffIndex effIndex)
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
- unitTarget->ToPlayer()->FailQuest(m_spellInfo->Effects[effIndex].MiscValue);
+ unitTarget->ToPlayer()->FailQuest(GetEffect(effIndex)->MiscValue);
}
void Spell::EffectQuestStart(SpellEffIndex effIndex)
@@ -5202,7 +5150,7 @@ void Spell::EffectQuestStart(SpellEffIndex effIndex)
if (!player)
return;
- if (Quest const* quest = sObjectMgr->GetQuestTemplate(m_spellInfo->Effects[effIndex].MiscValue))
+ if (Quest const* quest = sObjectMgr->GetQuestTemplate(GetEffect(effIndex)->MiscValue))
{
if (!player->CanTakeQuest(quest, false))
return;
@@ -5234,10 +5182,10 @@ void Spell::EffectActivateRune(SpellEffIndex effIndex)
if (count == 0) count = 1;
for (uint32 j = 0; j < MAX_RUNES && count > 0; ++j)
{
- if (player->GetRuneCooldown(j) && player->GetCurrentRune(j) == RuneType(m_spellInfo->Effects[effIndex].MiscValue))
+ if (player->GetRuneCooldown(j) && player->GetCurrentRune(j) == RuneType(GetEffect(effIndex)->MiscValue))
{
if (m_spellInfo->Id == 45529)
- if (player->GetBaseRune(j) != RuneType(m_spellInfo->Effects[effIndex].MiscValueB))
+ if (player->GetBaseRune(j) != RuneType(GetEffect(effIndex)->MiscValueB))
continue;
player->SetRuneCooldown(j, 0);
--count;
@@ -5250,7 +5198,7 @@ void Spell::EffectActivateRune(SpellEffIndex effIndex)
for (uint32 l = 0; l + 1 < MAX_RUNES && count > 0; ++l)
{
// Check if both runes are on cd as that is the only time when this needs to come into effect
- if ((player->GetRuneCooldown(l) && player->GetCurrentRune(l) == RuneType(m_spellInfo->Effects[effIndex].MiscValueB)) && (player->GetRuneCooldown(l+1) && player->GetCurrentRune(l+1) == RuneType(m_spellInfo->Effects[effIndex].MiscValueB)))
+ if ((player->GetRuneCooldown(l) && player->GetCurrentRune(l) == RuneType(GetEffect(effIndex)->MiscValueB)) && (player->GetRuneCooldown(l+1) && player->GetCurrentRune(l+1) == RuneType(GetEffect(effIndex)->MiscValueB)))
{
// Should always update the rune with the lowest cd
if (l + 1 < MAX_RUNES && player->GetRuneCooldown(l) >= player->GetRuneCooldown(l+1))
@@ -5288,7 +5236,7 @@ void Spell::EffectCreateTamedPet(SpellEffIndex effIndex)
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || !unitTarget->GetPetGUID().IsEmpty() || unitTarget->getClass() != CLASS_HUNTER)
return;
- uint32 creatureEntry = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 creatureEntry = GetEffect(effIndex)->MiscValue;
Pet* pet = unitTarget->CreateTamedPetFrom(creatureEntry, m_spellInfo->Id);
if (!pet)
return;
@@ -5320,7 +5268,7 @@ void Spell::EffectDiscoverTaxi(SpellEffIndex effIndex)
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
- uint32 nodeid = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 nodeid = GetEffect(effIndex)->MiscValue;
if (sTaxiNodesStore.LookupEntry(nodeid))
unitTarget->ToPlayer()->GetSession()->SendDiscoverNewTaxiNode(nodeid);
}
@@ -5382,7 +5330,7 @@ void Spell::EffectGameObjectSetDestructionState(SpellEffIndex effIndex)
return;
Player* player = m_originalCaster->GetCharmerOrOwnerPlayerOrPlayerItself();
- gameObjTarget->SetDestructibleState(GameObjectDestructibleState(m_spellInfo->Effects[effIndex].MiscValue), player, true);
+ gameObjTarget->SetDestructibleState(GameObjectDestructibleState(GetEffect(effIndex)->MiscValue), player, true);
}
void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const* properties, uint32 numGuardians)
@@ -5472,7 +5420,7 @@ void Spell::EffectPlayMusic(SpellEffIndex effIndex)
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
- uint32 soundid = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 soundid = GetEffect(effIndex)->MiscValue;
if (!sSoundEntriesStore.LookupEntry(soundid))
{
@@ -5529,7 +5477,7 @@ void Spell::EffectPlaySound(SpellEffIndex effIndex)
break;
}
- uint32 soundId = m_spellInfo->Effects[effIndex].MiscValue;
+ uint32 soundId = GetEffect(effIndex)->MiscValue;
if (!sSoundEntriesStore.LookupEntry(soundId))
{
@@ -5548,7 +5496,7 @@ void Spell::EffectRemoveAura(SpellEffIndex effIndex)
if (!unitTarget)
return;
// there may be need of specifying casterguid of removed auras
- unitTarget->RemoveAurasDueToSpell(m_spellInfo->Effects[effIndex].TriggerSpell);
+ unitTarget->RemoveAurasDueToSpell(GetEffect(effIndex)->TriggerSpell);
}
void Spell::EffectDamageFromMaxHealthPCT(SpellEffIndex /*effIndex*/)
@@ -5570,7 +5518,7 @@ void Spell::EffectGiveCurrency(SpellEffIndex effIndex)
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
- unitTarget->ToPlayer()->ModifyCurrency(m_spellInfo->Effects[effIndex].MiscValue, damage);
+ unitTarget->ToPlayer()->ModifyCurrency(GetEffect(effIndex)->MiscValue, damage);
}
void Spell::EffectCastButtons(SpellEffIndex effIndex)
@@ -5582,8 +5530,8 @@ void Spell::EffectCastButtons(SpellEffIndex effIndex)
return;
Player* p_caster = m_caster->ToPlayer();
- uint32 button_id = m_spellInfo->Effects[effIndex].MiscValue + 132;
- uint32 n_buttons = m_spellInfo->Effects[effIndex].MiscValueB;
+ uint32 button_id = GetEffect(effIndex)->MiscValue + 132;
+ uint32 n_buttons = GetEffect(effIndex)->MiscValueB;
for (; n_buttons; --n_buttons, ++button_id)
{
@@ -5628,21 +5576,23 @@ void Spell::EffectRechargeManaGem(SpellEffIndex /*effIndex*/)
if (!player)
return;
-
- uint32 item_id = m_spellInfo->Effects[EFFECT_0].ItemType;
-
- ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(item_id);
- if (!pProto)
+ if (SpellEffectInfo const* effect = GetEffect(EFFECT_0))
{
- player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
- return;
- }
+ uint32 item_id = effect->ItemType;
- if (Item* pItem = player->GetItemByEntry(item_id))
- {
- for (int x = 0; x < pProto->Effects.size(); ++x)
- pItem->SetSpellCharges(x, pProto->Effects[x].Charges);
- pItem->SetState(ITEM_CHANGED, player);
+ ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(item_id);
+ if (!pProto)
+ {
+ player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
+ return;
+ }
+
+ if (Item* pItem = player->GetItemByEntry(item_id))
+ {
+ for (int x = 0; x < pProto->Effects.size(); ++x)
+ pItem->SetSpellCharges(x, pProto->Effects[x].Charges);
+ pItem->SetState(ITEM_CHANGED, player);
+ }
}
}
@@ -5659,8 +5609,8 @@ void Spell::EffectBind(SpellEffIndex effIndex)
WorldLocation homeLoc;
uint32 areaId = player->GetAreaId();
- if (m_spellInfo->Effects[effIndex].MiscValue)
- areaId = m_spellInfo->Effects[effIndex].MiscValue;
+ if (GetEffect(effIndex)->MiscValue)
+ areaId = GetEffect(effIndex)->MiscValue;
if (m_targets.HasDst())
homeLoc.WorldRelocate(*destTarget);
@@ -5696,7 +5646,7 @@ void Spell::EffectSummonRaFFriend(SpellEffIndex effIndex)
if (m_caster->GetTypeId() != TYPEID_PLAYER || !unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
- m_caster->CastSpell(unitTarget, m_spellInfo->Effects[effIndex].TriggerSpell, true);
+ m_caster->CastSpell(unitTarget, GetEffect(effIndex)->TriggerSpell, true);
}
void Spell::EffectUnlockGuildVaultTab(SpellEffIndex effIndex)
@@ -5707,7 +5657,7 @@ void Spell::EffectUnlockGuildVaultTab(SpellEffIndex effIndex)
// Safety checks done in Spell::CheckCast
Player* caster = m_caster->ToPlayer();
if (Guild* guild = caster->GetGuild())
- guild->HandleBuyBankTab(caster->GetSession(), m_spellInfo->Effects[effIndex].BasePoints - 1); // Bank tabs start at zero internally
+ guild->HandleBuyBankTab(caster->GetSession(), GetEffect(effIndex)->BasePoints - 1); // Bank tabs start at zero internally
}
void Spell::EffectResurrectWithAura(SpellEffIndex effIndex)
@@ -5731,8 +5681,8 @@ void Spell::EffectResurrectWithAura(SpellEffIndex effIndex)
uint32 health = target->CountPctFromMaxHealth(damage);
uint32 mana = CalculatePct(target->GetMaxPower(POWER_MANA), damage);
uint32 resurrectAura = 0;
- if (sSpellMgr->GetSpellInfo(GetSpellInfo()->Effects[effIndex].TriggerSpell))
- resurrectAura = GetSpellInfo()->Effects[effIndex].TriggerSpell;
+ if (sSpellMgr->GetSpellInfo(GetEffect(effIndex)->TriggerSpell))
+ resurrectAura = GetEffect(effIndex)->TriggerSpell;
if (resurrectAura && target->HasAura(resurrectAura))
return;
@@ -5754,9 +5704,9 @@ void Spell::EffectCreateAreaTrigger(SpellEffIndex effIndex)
pos = destTarget->GetPosition();
// trigger entry/miscvalue relation is currently unknown, for now use MiscValue as trigger entry
- uint32 triggerEntry = GetSpellInfo()->Effects[effIndex].MiscValue;
+ uint32 triggerEntry = GetEffect(effIndex)->MiscValue;
AreaTrigger * areaTrigger = new AreaTrigger;
if (!areaTrigger->CreateAreaTrigger(sObjectMgr->GetGenerator<HighGuid::AreaTrigger>()->Generate(), triggerEntry, GetCaster(), GetSpellInfo(), pos))
delete areaTrigger;
-}
+} \ No newline at end of file