diff options
Diffstat (limited to 'src/server/game/Spells/SpellEffects.cpp')
-rwxr-xr-x | src/server/game/Spells/SpellEffects.cpp | 462 |
1 files changed, 230 insertions, 232 deletions
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 9fc8d6cb6dc..491e6db5394 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -258,7 +258,7 @@ void Spell::EffectResurrectNew(SpellEffIndex effIndex) return; uint32 health = damage; - uint32 mana = m_spellInfo->EffectMiscValue[effIndex]; + uint32 mana = m_spellInfo->Effects[effIndex].MiscValue; ExecuteLogEffectResurrect(effIndex, pTarget); pTarget->setResurrectRequestData(m_caster->GetGUID(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), health, mana); SendResurrectRequest(pTarget); @@ -309,11 +309,11 @@ void Spell::EffectEnvirinmentalDMG(SpellEffIndex effIndex) // Note: this hack with damage replace required until GO casting not implemented // environment damage spells already have around enemies targeting but this not help in case not existed GO casting support // currently each enemy selected explicitly and self cast damage, we prevent apply self casted spell bonuses/etc - damage = SpellMgr::CalculateSpellEffectAmount(m_spellInfo, effIndex, m_caster); + damage = m_spellInfo->Effects[effIndex].CalcValue(m_caster); - m_caster->CalcAbsorbResist(m_caster, GetSpellSchoolMask(m_spellInfo), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist, m_spellInfo); + m_caster->CalcAbsorbResist(m_caster, m_spellInfo->GetSchoolMask(), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist, m_spellInfo); - m_caster->SendSpellNonMeleeDamageLog(m_caster, m_spellInfo->Id, damage, GetSpellSchoolMask(m_spellInfo), absorb, resist, false, 0, false); + m_caster->SendSpellNonMeleeDamageLog(m_caster, m_spellInfo->Id, damage, m_spellInfo->GetSchoolMask(), absorb, resist, false, 0, false); if (m_caster->GetTypeId() == TYPEID_PLAYER) m_caster->ToPlayer()->EnvironmentalDamage(DAMAGE_FIRE, damage); } @@ -333,7 +333,7 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex) case SPELLFAMILY_GENERIC: { // Meteor like spells (divided damage to targets) - if (m_customAttr & SPELL_ATTR0_CU_SHARE_DAMAGE) + if (m_spellInfo->AttributesCu & SPELL_ATTR0_CU_SHARE_DAMAGE) { uint32 count = 0; for (std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) @@ -405,10 +405,26 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex) if (unitTarget->GetGUID() == m_caster->GetGUID() || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - float radius = GetSpellRadiusForHostile(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[0])); - if (!radius) return; + float radius = m_spellInfo->Effects[EFFECT_0].CalcRadius(m_caster); + if (!radius) + return; + float distance = m_caster->GetDistance2d(unitTarget); + damage = (distance > radius) ? 0 : int32(m_spellInfo->Effects[EFFECT_0].CalcValue(m_caster) * ((radius - distance)/radius)); + break; + } + // Loken Pulsing Shockwave + case 59837: + case 52942: + { + // don't damage self and only players + if (unitTarget->GetGUID() == m_caster->GetGUID() || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + float radius = m_spellInfo->Effects[EFFECT_0].CalcRadius(m_caster); + if (!radius) + return; float distance = m_caster->GetDistance2d(unitTarget); - damage = (distance > radius) ? 0 : int32(SpellMgr::CalculateSpellEffectAmount(m_spellInfo, 0) * ((radius - distance)/radius)); + damage = (distance > radius) ? 0 : int32(m_spellInfo->Effects[EFFECT_0].CalcValue(m_caster) * distance); break; } // TODO: add spell specific target requirement hook for spells @@ -440,22 +456,6 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex) damage = (m_caster->getLevel() - 60) * 4 + 60; break; } - - // Loken Pulsing Shockwave - case 59837: - case 52942: - { - // don't damage self and only players - if (unitTarget->GetGUID() == m_caster->GetGUID() || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - float radius = GetSpellRadiusForHostile(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[0])); - if (!radius) - return; - float distance = m_caster->GetDistance2d(unitTarget); - damage = (distance > radius) ? 0 : int32(SpellMgr::CalculateSpellEffectAmount(m_spellInfo, 0) * distance); - break; - } } break; } @@ -502,19 +502,19 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex) for (Unit::AuraEffectList::const_iterator i = mPeriodic.begin(); i != mPeriodic.end(); ++i) { // for caster applied auras only - if ((*i)->GetSpellProto()->SpellFamilyName != SPELLFAMILY_WARLOCK || + if ((*i)->GetSpellInfo()->SpellFamilyName != SPELLFAMILY_WARLOCK || (*i)->GetCasterGUID() != m_caster->GetGUID()) continue; // Immolate - if ((*i)->GetSpellProto()->SpellFamilyFlags[0] & 0x4) + if ((*i)->GetSpellInfo()->SpellFamilyFlags[0] & 0x4) { aura = *i; // it selected always if exist break; } // Shadowflame - if ((*i)->GetSpellProto()->SpellFamilyFlags[2] & 0x00000002) + if ((*i)->GetSpellInfo()->SpellFamilyFlags[2] & 0x00000002) aura = *i; // remember but wait possible Immolate as primary priority } @@ -522,13 +522,13 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex) if (aura) { uint32 pdamage = uint32(std::max(aura->GetAmount(), 0)); - pdamage = m_caster->SpellDamageBonus(unitTarget, aura->GetSpellProto(), pdamage, DOT, aura->GetBase()->GetStackAmount()); + pdamage = m_caster->SpellDamageBonus(unitTarget, aura->GetSpellInfo(), pdamage, DOT, aura->GetBase()->GetStackAmount()); uint32 pct_dir = m_caster->CalculateSpellDamage(unitTarget, m_spellInfo, (effIndex + 1)); - uint8 baseTotalTicks = uint8(m_caster->CalcSpellDuration(aura->GetSpellProto()) / aura->GetSpellProto()->EffectAmplitude[0]); + uint8 baseTotalTicks = uint8(m_caster->CalcSpellDuration(aura->GetSpellInfo()) / aura->GetSpellInfo()->Effects[EFFECT_0].Amplitude); damage += int32(CalculatePctU(pdamage * baseTotalTicks, pct_dir)); uint32 pct_dot = m_caster->CalculateSpellDamage(unitTarget, m_spellInfo, (effIndex + 2)) / 3; - m_spellValue->EffectBasePoints[1] = SpellMgr::CalculateSpellEffectBaseAmount(int32(CalculatePctU(pdamage * baseTotalTicks, pct_dot)), m_spellInfo, 1); + m_spellValue->EffectBasePoints[1] = m_spellInfo->Effects[EFFECT_1].CalcBaseValue(int32(CalculatePctU(pdamage * baseTotalTicks, pct_dot))); apply_direct_bonus = false; // Glyph of Conflagrate @@ -574,10 +574,10 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex) 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)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_PRIEST && - ((*i)->GetSpellProto()->SpellIconID == 95)) + if ((*i)->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_PRIEST && + ((*i)->GetSpellInfo()->SpellIconID == 95)) { - int chance = SpellMgr::CalculateSpellEffectAmount((*i)->GetSpellProto(), 1, m_caster); + int chance = (*i)->GetSpellInfo()->Effects[EFFECT_1].CalcValue(m_caster); if (roll_chance_i(chance)) // Mind Trauma m_caster->CastSpell(unitTarget, 48301, true, 0); @@ -594,7 +594,7 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex) { // converts each extra point of energy into ($f1+$AP/410) additional damage float ap = m_caster->GetTotalAttackPowerValue(BASE_ATTACK); - float multiple = ap / 410 + m_spellInfo->EffectDamageMultiplier[effIndex]; + float multiple = ap / 410 + m_spellInfo->Effects[effIndex].DamageMultiplier; int32 energy = -(m_caster->ModifyPower(POWER_ENERGY, -30)); damage += int32(energy * multiple); damage += int32(CalculatePctN(m_caster->ToPlayer()->GetComboPoints() * ap, 7)); @@ -630,9 +630,9 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex) Unit::AuraEffectList const& auraList = m_caster->ToPlayer()->GetAuraEffectsByType(SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL_NOT_STACK); for (Unit::AuraEffectList::const_iterator iter = auraList.begin(); iter != auraList.end(); ++iter) { - if ((*iter)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_ROGUE && (*iter)->GetSpellProto()->SpellIconID == 1960) + if ((*iter)->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_ROGUE && (*iter)->GetSpellInfo()->SpellIconID == 1960) { - uint32 chance = SpellMgr::CalculateSpellEffectAmount((*iter)->GetSpellProto(), 2, m_caster); + uint32 chance = (*iter)->GetSpellInfo()->Effects[EFFECT_2].CalcValue(m_caster); if (chance && roll_chance_i(chance)) needConsume = false; @@ -683,7 +683,7 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex) Unit::AuraEffectList const& decSpeedList = unitTarget->GetAuraEffectsByType(SPELL_AURA_MOD_DECREASE_SPEED); for (Unit::AuraEffectList::const_iterator iter = decSpeedList.begin(); iter != decSpeedList.end(); ++iter) { - if ((*iter)->GetSpellProto()->SpellIconID == 15 && (*iter)->GetSpellProto()->Dispel == 0) + if ((*iter)->GetSpellInfo()->SpellIconID == 15 && (*iter)->GetSpellInfo()->Dispel == 0) { found = true; break; @@ -692,7 +692,7 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex) // TODO: should this be put on taken but not done? if (found) - damage += SpellMgr::CalculateSpellEffectAmount(m_spellInfo, 1); + damage += m_spellInfo->Effects[EFFECT_1].CalcValue(); if (m_caster->GetTypeId() == TYPEID_PLAYER) { @@ -726,7 +726,7 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex) // Shield of Righteousness if (m_spellInfo->SpellFamilyFlags[EFFECT_1] & 0x100000) { - damage += CalculatePctN(m_caster->GetShieldBlockValue(), SpellMgr::CalculateSpellEffectAmount(m_spellInfo, EFFECT_1)); + damage += CalculatePctN(m_caster->GetShieldBlockValue(), m_spellInfo->Effects[EFFECT_1].CalcValue()); break; } break; @@ -797,8 +797,8 @@ void Spell::EffectDummy(SpellEffIndex effIndex) return; } - SpellEntry const* spellInfo = sSpellStore.LookupEntry(12721); - uint32 ticks = GetSpellDuration(spellInfo) / spellInfo->EffectAmplitude[0]; + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(12721); + uint32 ticks = spellInfo->GetDuration() / spellInfo->Effects[EFFECT_0].Amplitude; // Add remaining ticks to damage done if (AuraEffect const* aurEff = unitTarget->GetAuraEffect(12721, EFFECT_0, m_caster->GetGUID())) @@ -979,7 +979,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex) damage = 12000; // maybe wrong value damage /= count; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(42784); + SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(42784); // now deal the damage for (std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) @@ -1163,7 +1163,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex) } } } - if (target && target->IsWithinDist2d(m_targets.GetDst(), GetSpellRadius(m_spellInfo, effIndex, false) * 2)) // now we use *2 because the location of the seat is not correct + if (target && target->IsWithinDist2d(m_targets.GetDst(), m_spellInfo->Effects[effIndex].CalcRadius() * 2)) // now we use *2 because the location of the seat is not correct passenger->EnterVehicle(target, 0); else { @@ -1262,7 +1262,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex) // Sudden Death rage save if (AuraEffect * aurEff = m_caster->GetAuraEffect(SPELL_AURA_PROC_TRIGGER_SPELL, SPELLFAMILY_GENERIC, 1989, EFFECT_0)) { - int32 ragesave = SpellMgr::CalculateSpellEffectAmount(aurEff->GetSpellProto(), EFFECT_1) * 10; + int32 ragesave = aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue() * 10; newRage = std::max(newRage, ragesave); } @@ -1272,7 +1272,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex) if (AuraEffect * aurEff = m_caster->GetAuraEffect(58367, EFFECT_0)) rageUsed += aurEff->GetAmount() * 10; - bp = damage + int32(rageUsed * m_spellInfo->EffectDamageMultiplier[effIndex] + m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.2f); + bp = damage + int32(rageUsed * m_spellInfo->Effects[effIndex].DamageMultiplier + m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.2f); break; } // Concussion Blow @@ -1302,7 +1302,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex) case 27222: case 57946: spFactor = 0.5f; break; } - int32 damage = int32(SpellMgr::CalculateSpellEffectAmount(m_spellInfo, 0) + (6.3875 * m_spellInfo->baseLevel)); + int32 damage = int32(m_spellInfo->Effects[EFFECT_0].CalcValue() + (6.3875 * m_spellInfo->BaseLevel)); int32 mana = int32(damage + (m_caster->ToPlayer()->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+SPELL_SCHOOL_SHADOW) * spFactor)); if (unitTarget && (int32(unitTarget->GetHealth()) > damage)) @@ -1447,10 +1447,10 @@ void Spell::EffectDummy(SpellEffIndex effIndex) if (m_spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG_DK_DEATH_STRIKE) { uint32 count = unitTarget->GetDiseasesByCaster(m_caster->GetGUID()); - int32 bp = int32(count * m_caster->CountPctFromMaxHealth(int32(m_spellInfo->EffectDamageMultiplier[0]))); + int32 bp = int32(count * m_caster->CountPctFromMaxHealth(int32(m_spellInfo->Effects[EFFECT_0].DamageMultiplier))); // Improved Death Strike if (AuraEffect const* aurEff = m_caster->GetAuraEffect(SPELL_AURA_ADD_PCT_MODIFIER, SPELLFAMILY_DEATHKNIGHT, 2751, 0)) - AddPctN(bp, m_caster->CalculateSpellDamage(m_caster, aurEff->GetSpellProto(), 2)); + AddPctN(bp, m_caster->CalculateSpellDamage(m_caster, aurEff->GetSpellInfo(), 2)); m_caster->CastCustomSpell(m_caster, 45470, &bp, NULL, NULL, false); return; } @@ -1517,7 +1517,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex) //spells triggered by dummy effect should not miss if (spell_id) { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); + SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(spell_id); if (!spellInfo) { @@ -1554,10 +1554,10 @@ void Spell::EffectDummy(SpellEffIndex effIndex) void Spell::EffectTriggerSpellWithValue(SpellEffIndex effIndex) { - uint32 triggered_spell_id = m_spellInfo->EffectTriggerSpell[effIndex]; + uint32 triggered_spell_id = m_spellInfo->Effects[effIndex].TriggerSpell; // normal case - SpellEntry const *spellInfo = sSpellStore.LookupEntry(triggered_spell_id); + SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(triggered_spell_id); if (!spellInfo) { @@ -1566,15 +1566,16 @@ void Spell::EffectTriggerSpellWithValue(SpellEffIndex effIndex) } int32 bp = damage; - Unit* caster = GetTriggeredSpellCaster(spellInfo, m_caster, unitTarget); + + Unit* caster = spellInfo->IsRequiringSelectedTarget() ? m_caster : unitTarget; caster->CastCustomSpell(unitTarget, triggered_spell_id, &bp, &bp, &bp, true); } void Spell::EffectTriggerRitualOfSummoning(SpellEffIndex effIndex) { - uint32 triggered_spell_id = m_spellInfo->EffectTriggerSpell[effIndex]; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(triggered_spell_id); + uint32 triggered_spell_id = m_spellInfo->Effects[effIndex].TriggerSpell; + SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(triggered_spell_id); if (!spellInfo) { @@ -1592,10 +1593,10 @@ void Spell::EffectForceCast(SpellEffIndex effIndex) if (!unitTarget) return; - uint32 triggered_spell_id = m_spellInfo->EffectTriggerSpell[effIndex]; + uint32 triggered_spell_id = m_spellInfo->Effects[effIndex].TriggerSpell; // normal case - SpellEntry const *spellInfo = sSpellStore.LookupEntry(triggered_spell_id); + SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(triggered_spell_id); if (!spellInfo) { @@ -1637,10 +1638,10 @@ void Spell::EffectForceCastWithValue(SpellEffIndex effIndex) if (!unitTarget) return; - uint32 triggered_spell_id = m_spellInfo->EffectTriggerSpell[effIndex]; + uint32 triggered_spell_id = m_spellInfo->Effects[effIndex].TriggerSpell; // normal case - SpellEntry const *spellInfo = sSpellStore.LookupEntry(triggered_spell_id); + SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(triggered_spell_id); if (!spellInfo) { @@ -1662,7 +1663,7 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex) return; } - uint32 triggered_spell_id = m_spellInfo->EffectTriggerSpell[effIndex]; + uint32 triggered_spell_id = m_spellInfo->Effects[effIndex].TriggerSpell; Unit* originalCaster = NULL; // special cases @@ -1717,7 +1718,7 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex) case 29284: { // Brittle Armor - SpellEntry const* spell = sSpellStore.LookupEntry(24575); + SpellInfo const* spell = sSpellMgr->GetSpellInfo(24575); if (!spell) return; @@ -1729,7 +1730,7 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex) case 29286: { // Mercurial Shield - SpellEntry const* spell = sSpellStore.LookupEntry(26464); + SpellInfo const* spell = sSpellMgr->GetSpellInfo(26464); if (!spell) return; @@ -1746,14 +1747,14 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex) // Cloak of Shadows case 35729: { - uint32 dispelMask = GetDispelMask(DISPEL_ALL); + uint32 dispelMask = SpellInfo::GetDispelMask(DISPEL_ALL); Unit::AuraApplicationMap& Auras = unitTarget->GetAppliedAuras(); for (Unit::AuraApplicationMap::iterator iter = Auras.begin(); iter != Auras.end();) { // remove all harmful spells on you... - SpellEntry const* spell = iter->second->GetBase()->GetSpellProto(); + SpellInfo const* spell = iter->second->GetBase()->GetSpellInfo(); if ((spell->DmgClass == SPELL_DAMAGE_CLASS_MAGIC // only affect magic spells - || ((1<<spell->Dispel) & dispelMask)) + || ((spell->GetDispelMask()) & dispelMask)) // ignore positive and passive auras && !iter->second->IsPositive() && !iter->second->GetBase()->IsPassive()) { @@ -1784,7 +1785,7 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex) } // normal case - SpellEntry const *spellInfo = sSpellStore.LookupEntry(triggered_spell_id); + SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(triggered_spell_id); if (!spellInfo) { sLog->outError("EffectTriggerSpell of spell %u: triggering unknown spell id %i", m_spellInfo->Id, triggered_spell_id); @@ -1799,17 +1800,17 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex) // Note: not exist spells with weapon req. and IsSpellHaveCasterSourceTargets == true // so this just for speedup places in else - Unit* caster = GetTriggeredSpellCaster(spellInfo, m_caster, unitTarget); + Unit* caster = spellInfo->IsRequiringSelectedTarget() ? m_caster : unitTarget; caster->CastSpell(unitTarget, spellInfo, true, 0, 0, (originalCaster ? originalCaster->GetGUID() : 0)); } void Spell::EffectTriggerMissileSpell(SpellEffIndex effIndex) { - uint32 triggered_spell_id = m_spellInfo->EffectTriggerSpell[effIndex]; + uint32 triggered_spell_id = m_spellInfo->Effects[effIndex].TriggerSpell; // normal case - SpellEntry const *spellInfo = sSpellStore.LookupEntry(triggered_spell_id); + SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(triggered_spell_id); if (!spellInfo) { @@ -1864,7 +1865,7 @@ void Spell::EffectJumpDest(SpellEffIndex effIndex) { m_targets.GetDst()->GetPosition(x, y, z); - if (m_spellInfo->EffectImplicitTargetA[effIndex] == TARGET_DEST_TARGET_BACK) + if (m_spellInfo->Effects[effIndex].TargetA == TARGET_DEST_TARGET_BACK) { // explicit cast data from client or server-side cast // some spell at client send caster @@ -1891,10 +1892,10 @@ void Spell::EffectJumpDest(SpellEffIndex effIndex) void Spell::CalculateJumpSpeeds(uint8 i, float dist, float & speedXY, float & speedZ) { - if (m_spellInfo->EffectMiscValue[i]) - speedZ = float(m_spellInfo->EffectMiscValue[i])/10; - else if (m_spellInfo->EffectMiscValueB[i]) - speedZ = float(m_spellInfo->EffectMiscValueB[i])/10; + 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; speedXY = dist * 10.0f / speedZ; @@ -2085,7 +2086,7 @@ void Spell::EffectUnlearnSpecialization(SpellEffIndex effIndex) return; Player* _player = unitTarget->ToPlayer(); - uint32 spellToUnlearn = m_spellInfo->EffectTriggerSpell[effIndex]; + uint32 spellToUnlearn = m_spellInfo->Effects[effIndex].TriggerSpell; _player->removeSpell(spellToUnlearn); @@ -2094,10 +2095,10 @@ void Spell::EffectUnlearnSpecialization(SpellEffIndex effIndex) void Spell::EffectPowerDrain(SpellEffIndex effIndex) { - if (m_spellInfo->EffectMiscValue[effIndex] < 0 || m_spellInfo->EffectMiscValue[effIndex] >= int8(MAX_POWERS)) + if (m_spellInfo->Effects[effIndex].MiscValue < 0 || m_spellInfo->Effects[effIndex].MiscValue >= int8(MAX_POWERS)) return; - Powers powerType = Powers(m_spellInfo->EffectMiscValue[effIndex]); + Powers powerType = Powers(m_spellInfo->Effects[effIndex].MiscValue); if (!unitTarget || !unitTarget->isAlive() || unitTarget->getPowerType() != powerType || damage < 0) return; @@ -2117,7 +2118,7 @@ void Spell::EffectPowerDrain(SpellEffIndex effIndex) // Don`t restore from self drain if (m_caster != unitTarget) { - gainMultiplier = SpellMgr::CalculateSpellEffectValueMultiplier(m_spellInfo, effIndex, m_originalCaster, this); + gainMultiplier = m_spellInfo->Effects[effIndex].CalcValueMultiplier(m_originalCaster, this); int32 gain = int32(newDamage * gainMultiplier); @@ -2131,7 +2132,7 @@ void Spell::EffectSendEvent(SpellEffIndex effIndex) /* we do not handle a flag dropping or clicking on flag in battleground by sendevent system */ - sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "Spell ScriptStart %u for spellid %u in EffectSendEvent ", m_spellInfo->EffectMiscValue[effIndex], m_spellInfo->Id); + sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "Spell ScriptStart %u for spellid %u in EffectSendEvent ", m_spellInfo->Effects[effIndex].MiscValue, m_spellInfo->Id); Object* target = NULL; if (focusObject) @@ -2142,17 +2143,17 @@ void Spell::EffectSendEvent(SpellEffIndex effIndex) target = gameObjTarget; if (ZoneScript* zoneScript = m_caster->GetZoneScript()) - zoneScript->ProcessEvent(unitTarget, m_spellInfo->EffectMiscValue[effIndex]); + zoneScript->ProcessEvent(unitTarget, m_spellInfo->Effects[effIndex].MiscValue); - m_caster->GetMap()->ScriptsStart(sEventScripts, m_spellInfo->EffectMiscValue[effIndex], m_caster, target); + m_caster->GetMap()->ScriptsStart(sEventScripts, m_spellInfo->Effects[effIndex].MiscValue, m_caster, target); } void Spell::EffectPowerBurn(SpellEffIndex effIndex) { - if (m_spellInfo->EffectMiscValue[effIndex] < 0 || m_spellInfo->EffectMiscValue[effIndex] >= int8(MAX_POWERS)) + if (m_spellInfo->Effects[effIndex].MiscValue < 0 || m_spellInfo->Effects[effIndex].MiscValue >= int8(MAX_POWERS)) return; - Powers powerType = Powers(m_spellInfo->EffectMiscValue[effIndex]); + Powers powerType = Powers(m_spellInfo->Effects[effIndex].MiscValue); if (!unitTarget || !unitTarget->isAlive() || unitTarget->getPowerType() != powerType || damage < 0) return; @@ -2173,7 +2174,7 @@ void Spell::EffectPowerBurn(SpellEffIndex effIndex) int32 newDamage = -(unitTarget->ModifyPower(powerType, -power)); // NO - Not a typo - EffectPowerBurn uses effect value multiplier - not effect damage multiplier - float dmgMultiplier = SpellMgr::CalculateSpellEffectValueMultiplier(m_spellInfo, effIndex, m_originalCaster, this); + float dmgMultiplier = m_spellInfo->Effects[effIndex].CalcValueMultiplier(m_originalCaster, this); // add log data before multiplication (need power amount, not damage) ExecuteLogEffectTakeTargetPower(effIndex, unitTarget, powerType, newDamage, 0.0f); @@ -2221,8 +2222,8 @@ void Spell::SpellDamageHeal(SpellEffIndex /*effIndex*/) AuraEffect *targetAura = NULL; for (Unit::AuraEffectList::const_iterator i = RejorRegr.begin(); i != RejorRegr.end(); ++i) { - if ((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID - && (*i)->GetSpellProto()->SpellFamilyFlags[0] & 0x50) + if ((*i)->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_DRUID + && (*i)->GetSpellInfo()->SpellFamilyFlags[0] & 0x50) { if (!targetAura || (*i)->GetBase()->GetDuration() < targetAura->GetBase()->GetDuration()) targetAura = *i; @@ -2237,16 +2238,16 @@ void Spell::SpellDamageHeal(SpellEffIndex /*effIndex*/) int32 tickheal = targetAura->GetAmount(); if (Unit* auraCaster = targetAura->GetCaster()) - tickheal = auraCaster->SpellHealingBonus(unitTarget, targetAura->GetSpellProto(), tickheal, DOT); - //int32 tickheal = targetAura->GetSpellProto()->EffectBasePoints[idx] + 1; + tickheal = auraCaster->SpellHealingBonus(unitTarget, targetAura->GetSpellInfo(), tickheal, DOT); + //int32 tickheal = targetAura->GetSpellInfo()->EffectBasePoints[idx] + 1; //It is said that talent bonus should not be included int32 tickcount = 0; // Rejuvenation - if (targetAura->GetSpellProto()->SpellFamilyFlags[0] & 0x10) + if (targetAura->GetSpellInfo()->SpellFamilyFlags[0] & 0x10) tickcount = 4; // Regrowth - else // if (targetAura->GetSpellProto()->SpellFamilyFlags[0] & 0x40) + else // if (targetAura->GetSpellInfo()->SpellFamilyFlags[0] & 0x40) tickcount = 6; addhealth += tickheal * tickcount; @@ -2338,7 +2339,7 @@ void Spell::EffectHealthLeech(SpellEffIndex effIndex) sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "HealthLeech :%i", damage); - float healMultiplier = SpellMgr::CalculateSpellEffectValueMultiplier(m_spellInfo, effIndex, m_originalCaster, this); + float healMultiplier = m_spellInfo->Effects[effIndex].CalcValueMultiplier(m_originalCaster, this); m_damage += damage; // get max possible damage, don't count overkill for heal @@ -2464,8 +2465,8 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype) void Spell::EffectCreateItem(SpellEffIndex effIndex) { - DoCreateItem(effIndex, m_spellInfo->EffectItemType[effIndex]); - ExecuteLogEffectCreateItem(effIndex, m_spellInfo->EffectItemType[effIndex]); + DoCreateItem(effIndex, m_spellInfo->Effects[effIndex].ItemType); + ExecuteLogEffectCreateItem(effIndex, m_spellInfo->Effects[effIndex].ItemType); } void Spell::EffectCreateItem2(SpellEffIndex effIndex) @@ -2474,13 +2475,13 @@ void Spell::EffectCreateItem2(SpellEffIndex effIndex) return; Player* player = (Player*)m_caster; - uint32 item_id = m_spellInfo->EffectItemType[effIndex]; + uint32 item_id = m_spellInfo->Effects[effIndex].ItemType; if (item_id) DoCreateItem(effIndex, item_id); // special case: fake item replaced by generate using spell_loot_template - if (IsLootCraftingSpell(m_spellInfo)) + if (m_spellInfo->IsLootCrafting()) { if (item_id) { @@ -2497,7 +2498,7 @@ void Spell::EffectCreateItem2(SpellEffIndex effIndex) else player->AutoStoreLoot(m_spellInfo->Id, LootTemplates_Spell); // create some random items } - // TODO: ExecuteLogEffectCreateItem(i, m_spellInfo->EffectItemType[i]); + // TODO: ExecuteLogEffectCreateItem(i, m_spellInfo->Effects[i].ItemType); } void Spell::EffectCreateRandomItem(SpellEffIndex /*effIndex*/) @@ -2508,18 +2509,16 @@ void Spell::EffectCreateRandomItem(SpellEffIndex /*effIndex*/) // create some random items player->AutoStoreLoot(m_spellInfo->Id, LootTemplates_Spell); - // TODO: ExecuteLogEffectCreateItem(i, m_spellInfo->EffectItemType[i]); + // TODO: ExecuteLogEffectCreateItem(i, m_spellInfo->Effects[i].ItemType); } void Spell::EffectPersistentAA(SpellEffIndex effIndex) { if (!m_spellAura) { - float radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[effIndex])); - if (Player* modOwner = m_originalCaster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius); - Unit* caster = m_caster->GetEntry() == WORLD_TRIGGER ? m_originalCaster : m_caster; + float radius = m_spellInfo->Effects[effIndex].CalcRadius(caster); + // Caster not in world, might be spell triggered from aura removal if (!caster->IsInWorld()) return; @@ -2552,10 +2551,10 @@ void Spell::EffectEnergize(SpellEffIndex effIndex) if (!unitTarget->isAlive()) return; - if (m_spellInfo->EffectMiscValue[effIndex] < 0 || m_spellInfo->EffectMiscValue[effIndex] >= int8(MAX_POWERS)) + if (m_spellInfo->Effects[effIndex].MiscValue < 0 || m_spellInfo->Effects[effIndex].MiscValue >= int8(MAX_POWERS)) return; - Powers power = Powers(m_spellInfo->EffectMiscValue[effIndex]); + Powers power = Powers(m_spellInfo->Effects[effIndex].MiscValue); // Some level depends spells int level_multiplier = 0; @@ -2628,8 +2627,8 @@ void Spell::EffectEnergize(SpellEffIndex effIndex) sSpellMgr->GetSetOfSpellsInSpellGroup(SPELL_GROUP_ELIXIR_BATTLE, avalibleElixirs); for (std::set<uint32>::iterator itr = avalibleElixirs.begin(); itr != avalibleElixirs.end() ;) { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(*itr); - if (spellInfo->spellLevel < m_spellInfo->spellLevel || spellInfo->spellLevel > unitTarget->getLevel()) + SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(*itr); + if (spellInfo->SpellLevel < m_spellInfo->SpellLevel || spellInfo->SpellLevel > unitTarget->getLevel()) avalibleElixirs.erase(itr++); else if (sSpellMgr->IsSpellMemberOfSpellGroup(*itr, SPELL_GROUP_ELIXIR_SHATTRATH)) avalibleElixirs.erase(itr++); @@ -2657,10 +2656,10 @@ void Spell::EffectEnergizePct(SpellEffIndex effIndex) if (!unitTarget->isAlive()) return; - if (m_spellInfo->EffectMiscValue[effIndex] < 0 || m_spellInfo->EffectMiscValue[effIndex] >= int8(MAX_POWERS)) + if (m_spellInfo->Effects[effIndex].MiscValue < 0 || m_spellInfo->Effects[effIndex].MiscValue >= int8(MAX_POWERS)) return; - Powers power = Powers(m_spellInfo->EffectMiscValue[effIndex]); + Powers power = Powers(m_spellInfo->Effects[effIndex].MiscValue); uint32 maxPower = unitTarget->GetMaxPower(power); if (maxPower == 0) @@ -2856,7 +2855,7 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex) if (m_CastItem->GetOwnerGUID() != player->GetGUID()) return; - uint32 newitemid = m_spellInfo->EffectItemType[effIndex]; + uint32 newitemid = m_spellInfo->Effects[effIndex].ItemType; if (!newitemid) return; @@ -2961,21 +2960,21 @@ void Spell::EffectProficiency(SpellEffIndex /*effIndex*/) void Spell::EffectSummonType(SpellEffIndex effIndex) { - uint32 entry = m_spellInfo->EffectMiscValue[effIndex]; + uint32 entry = m_spellInfo->Effects[effIndex].MiscValue; if (!entry) return; - SummonPropertiesEntry const *properties = sSummonPropertiesStore.LookupEntry(m_spellInfo->EffectMiscValueB[effIndex]); + SummonPropertiesEntry const *properties = sSummonPropertiesStore.LookupEntry(m_spellInfo->Effects[effIndex].MiscValueB); if (!properties) { - sLog->outError("EffectSummonType: Unhandled summon type %u", m_spellInfo->EffectMiscValueB[effIndex]); + sLog->outError("EffectSummonType: Unhandled summon type %u", m_spellInfo->Effects[effIndex].MiscValueB); return; } if (!m_originalCaster) return; - int32 duration = GetSpellDuration(m_spellInfo); + int32 duration = m_spellInfo->GetDuration(); if (Player* modOwner = m_originalCaster->GetSpellModOwner()) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration); @@ -3040,7 +3039,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) } default: { - float radius = GetSpellRadiusForHostile(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[effIndex])); + float radius = m_spellInfo->Effects[effIndex].CalcRadius(); uint32 amount = damage > 0 ? damage : 1; if (m_spellInfo->Id == 18662 || // Curse of Doom @@ -3087,7 +3086,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) // The spell that this effect will trigger. It has SPELL_AURA_CONTROL_VEHICLE uint32 spell = VEHICLE_SPELL_RIDE_HARDCODED; - if (SpellEntry const* spellProto = sSpellStore.LookupEntry(SpellMgr::CalculateSpellEffectAmount(m_spellInfo, effIndex))) + if (SpellInfo const* spellProto = sSpellMgr->GetSpellInfo(m_spellInfo->Effects[effIndex].CalcValue())) spell = spellProto->Id; // Hard coded enter vehicle spell @@ -3123,7 +3122,7 @@ void Spell::EffectLearnSpell(SpellEffIndex effIndex) Player* player = (Player*)unitTarget; - uint32 spellToLearn = (m_spellInfo->Id == 483 || m_spellInfo->Id == 55884) ? damage : m_spellInfo->EffectTriggerSpell[effIndex]; + uint32 spellToLearn = (m_spellInfo->Id == 483 || m_spellInfo->Id == 55884) ? damage : m_spellInfo->Effects[effIndex].TriggerSpell; player->learnSpell(spellToLearn, false); sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "Spell: Player %u has learned spell %u from NpcGUID=%u", player->GetGUIDLow(), spellToLearn, m_caster->GetGUIDLow()); @@ -3139,8 +3138,8 @@ void Spell::EffectDispel(SpellEffIndex effIndex) DispelChargesList dispel_list; // Create dispel mask by dispel type - uint32 dispel_type = m_spellInfo->EffectMiscValue[effIndex]; - uint32 dispelMask = GetDispelMask(DispelType(dispel_type)); + uint32 dispel_type = m_spellInfo->Effects[effIndex].MiscValue; + uint32 dispelMask = SpellInfo::GetDispelMask(DispelType(dispel_type)); // we should not be able to dispel diseases if the target is affected by unholy blight if (dispelMask & (1 << DISPEL_DISEASE) && unitTarget->HasAura(50536)) @@ -3158,9 +3157,9 @@ void Spell::EffectDispel(SpellEffIndex effIndex) if (aura->IsPassive()) continue; - if ((1<<aura->GetSpellProto()->Dispel) & dispelMask) + if ((aura->GetSpellInfo()->GetDispelMask()) & dispelMask) { - if (aura->GetSpellProto()->Dispel == DISPEL_MAGIC) + if (aura->GetSpellInfo()->Dispel == DISPEL_MAGIC) { // do not remove positive auras if friendly target // negative auras if non-friendly target @@ -3171,7 +3170,7 @@ void Spell::EffectDispel(SpellEffIndex effIndex) // The charges / stack amounts don't count towards the total number of auras that can be dispelled. // Ie: A dispel on a target with 5 stacks of Winters Chill and a Polymorph has 1 / (1 + 1) -> 50% chance to dispell // Polymorph instead of 1 / (5 + 1) -> 16%. - bool dispel_charges = aura->GetSpellProto()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES; + bool dispel_charges = aura->GetSpellInfo()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES; uint8 charges = dispel_charges ? aura->GetCharges() : aura->GetStackAmount(); if (charges > 0) dispel_list.push_back(std::make_pair(aura, charges)); @@ -3192,16 +3191,16 @@ void Spell::EffectDispel(SpellEffIndex effIndex) DispelChargesList::iterator itr = dispel_list.begin(); std::advance(itr, urand(0, dispel_list.size() - 1)); - bool success = false; + int32 chance = itr->first->CalcDispelChance(unitTarget, !unitTarget->IsFriendlyTo(m_caster)); // 2.4.3 Patch Notes: "Dispel effects will no longer attempt to remove effects that have 100% dispel resistance." - if (!GetDispelChance(itr->first->GetCaster(), unitTarget, itr->first->GetId(), !unitTarget->IsFriendlyTo(m_caster), &success)) + if (!chance) { dispel_list.erase(itr); continue; } else { - if (success) + if (roll_chance_i(chance)) { bool alreadyListed = false; for (DispelChargesList::iterator successItr = success_list.begin(); successItr != success_list.end(); ++successItr) @@ -3260,7 +3259,7 @@ void Spell::EffectDispel(SpellEffIndex effIndex) // Devour Magic if (m_spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellInfo->Category == SPELLCATEGORY_DEVOUR_MAGIC) { - int32 heal_amount = SpellMgr::CalculateSpellEffectAmount(m_spellInfo, 1); + int32 heal_amount = m_spellInfo->Effects[EFFECT_1].CalcValue(); m_caster->CastCustomSpell(m_caster, 19658, &heal_amount, NULL, NULL, true); // Glyph of Felhunter if (Unit* pOwner = m_caster->GetOwner()) @@ -3328,8 +3327,8 @@ void Spell::EffectAddFarsight(SpellEffIndex effIndex) if (m_caster->GetTypeId() != TYPEID_PLAYER) return; - float radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[effIndex])); - int32 duration = GetSpellDuration(m_spellInfo); + float radius = m_spellInfo->Effects[effIndex].CalcRadius(); + int32 duration = m_spellInfo->GetDuration(); // Caster not in world, might be spell triggered from aura removal if (!m_caster->IsInWorld()) return; @@ -3365,7 +3364,7 @@ void Spell::EffectTeleUnitsFaceCaster(SpellEffIndex effIndex) if (unitTarget->isInFlight()) return; - float dis = (float)m_caster->GetSpellRadiusForTarget(unitTarget, sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[effIndex])); + float dis = m_spellInfo->Effects[effIndex].CalcRadius(m_caster); float fx, fy, fz; m_caster->GetClosePoint(fx, fy, fz, unitTarget->GetObjectSize(), dis); @@ -3381,9 +3380,9 @@ void Spell::EffectLearnSkill(SpellEffIndex effIndex) if (damage < 0) return; - uint32 skillid = m_spellInfo->EffectMiscValue[effIndex]; + uint32 skillid = m_spellInfo->Effects[effIndex].MiscValue; uint16 skillval = unitTarget->ToPlayer()->GetPureSkillValue(skillid); - unitTarget->ToPlayer()->SetSkill(skillid, SpellMgr::CalculateSpellEffectAmount(m_spellInfo, effIndex), skillval?skillval:1, damage*75); + unitTarget->ToPlayer()->SetSkill(skillid, m_spellInfo->Effects[effIndex].CalcValue(), skillval?skillval:1, damage*75); } void Spell::EffectAddHonor(SpellEffIndex /*effIndex*/) @@ -3418,7 +3417,7 @@ void Spell::EffectTradeSkill(SpellEffIndex /*effIndex*/) { if (unitTarget->GetTypeId() != TYPEID_PLAYER) return; - // uint32 skillid = m_spellInfo->EffectMiscValue[i]; + // uint32 skillid = m_spellInfo->Effects[i].MiscValue; // uint16 skillmax = unitTarget->ToPlayer()->(skillid); // unitTarget->ToPlayer()->SetSkill(skillid, skillval?skillval:1, skillmax+75); } @@ -3440,7 +3439,7 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex) p_caster->DestroyItemCount(itemTarget, count, true); unitTarget=p_caster; // and add a scroll - DoCreateItem(effIndex, m_spellInfo->EffectItemType[effIndex]); + DoCreateItem(effIndex, m_spellInfo->Effects[effIndex].ItemType); itemTarget=NULL; m_targets.SetItemTarget(NULL); } @@ -3450,7 +3449,7 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex) if (!(m_CastItem && m_CastItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST)) p_caster->UpdateCraftSkill(m_spellInfo->Id); - uint32 enchant_id = m_spellInfo->EffectMiscValue[effIndex]; + uint32 enchant_id = m_spellInfo->Effects[effIndex].MiscValue; if (!enchant_id) return; @@ -3492,7 +3491,7 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex) Player* p_caster = (Player*)m_caster; - uint32 enchant_id = m_spellInfo->EffectMiscValue[effIndex]; + uint32 enchant_id = m_spellInfo->Effects[effIndex].MiscValue; if (!enchant_id) return; @@ -3579,7 +3578,7 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex) return; } - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); + SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(spell_id); if (!spellInfo) { sLog->outError("Spell::EffectEnchantItemTmp: unknown spell id %i", spell_id); @@ -3605,7 +3604,7 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex) if (!itemTarget) return; - uint32 enchant_id = m_spellInfo->EffectMiscValue[effIndex]; + uint32 enchant_id = m_spellInfo->Effects[effIndex].MiscValue; if (!enchant_id) { @@ -3735,7 +3734,7 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex) owner = m_originalCaster->GetCharmerOrOwnerPlayerOrPlayerItself(); } - uint32 petentry = m_spellInfo->EffectMiscValue[effIndex]; + uint32 petentry = m_spellInfo->Effects[effIndex].MiscValue; if (!owner) { @@ -3817,7 +3816,7 @@ void Spell::EffectLearnPetSpell(SpellEffIndex effIndex) if (!pet->isAlive()) return; - SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(m_spellInfo->EffectTriggerSpell[effIndex]); + SpellInfo const *learn_spellproto = sSpellMgr->GetSpellInfo(m_spellInfo->Effects[effIndex].TriggerSpell); if (!learn_spellproto) return; @@ -3878,7 +3877,7 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex) // and handle all effects at once for (uint32 j = effIndex + 1; j < MAX_SPELL_EFFECTS; ++j) { - switch (m_spellInfo->Effect[j]) + switch (m_spellInfo->Effects[j].Effect) { case SPELL_EFFECT_WEAPON_DAMAGE: case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: @@ -3965,7 +3964,7 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex) Unit::AuraApplicationMap const& auras = unitTarget->GetAppliedAuras(); for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { - if (itr->second->GetBase()->GetSpellProto()->Dispel == DISPEL_POISON) + if (itr->second->GetBase()->GetSpellInfo()->Dispel == DISPEL_POISON) { found = true; break; @@ -3984,7 +3983,7 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex) if (m_spellInfo->Id == 20467) { spell_bonus += int32(0.08f * m_caster->GetTotalAttackPowerValue(BASE_ATTACK)); - spell_bonus += int32(0.13f * m_caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellInfo))); + spell_bonus += int32(0.13f * m_caster->SpellBaseDamageBonus(m_spellInfo->GetSchoolMask())); } break; } @@ -4022,7 +4021,7 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex) case SPELLFAMILY_DEATHKNIGHT: { // Plague Strike - if (m_spellInfo->SpellFamilyFlags[EFFECT_0] & 0x1) + if (m_spellInfo->SpellFamilyFlags[0] & 0x1) { // Glyph of Plague Strike if (AuraEffect const* aurEff = m_caster->GetAuraEffect(58657, EFFECT_0)) @@ -4030,9 +4029,9 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex) break; } // Blood Strike - if (m_spellInfo->SpellFamilyFlags[EFFECT_0] & 0x400000) + if (m_spellInfo->SpellFamilyFlags[0] & 0x400000) { - AddPctF(totalDamagePercentMod, SpellMgr::CalculateSpellEffectAmount(m_spellInfo, EFFECT_2) * unitTarget->GetDiseasesByCaster(m_caster->GetGUID()) / 2.0f); + AddPctF(totalDamagePercentMod, m_spellInfo->Effects[EFFECT_2].CalcValue() * unitTarget->GetDiseasesByCaster(m_caster->GetGUID()) / 2.0f); // Glyph of Blood Strike if (m_caster->GetAuraEffect(59332, EFFECT_0)) @@ -4041,16 +4040,16 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex) break; } // Death Strike - if (m_spellInfo->SpellFamilyFlags[EFFECT_0] & 0x10) + if (m_spellInfo->SpellFamilyFlags[0] & 0x10) { // Glyph of Death Strike if (AuraEffect const* aurEff = m_caster->GetAuraEffect(59336, EFFECT_0)) - if (uint32 runic = std::min<uint32>(m_caster->GetPower(POWER_RUNIC_POWER), SpellMgr::CalculateSpellEffectAmount(aurEff->GetSpellProto(), EFFECT_1))) + if (uint32 runic = std::min<uint32>(m_caster->GetPower(POWER_RUNIC_POWER), aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue())) AddPctN(totalDamagePercentMod, runic); break; } // Obliterate (12.5% more damage per disease) - if (m_spellInfo->SpellFamilyFlags[EFFECT_1] & 0x20000) + if (m_spellInfo->SpellFamilyFlags[1] & 0x20000) { bool consumeDiseases = true; // Annihilation @@ -4059,7 +4058,7 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex) if (roll_chance_i(aurEff->GetAmount())) consumeDiseases = false; - AddPctF(totalDamagePercentMod, SpellMgr::CalculateSpellEffectAmount(m_spellInfo, EFFECT_2) * unitTarget->GetDiseasesByCaster(m_caster->GetGUID(), consumeDiseases) / 2.0f); + AddPctF(totalDamagePercentMod, m_spellInfo->Effects[EFFECT_2].CalcValue() * unitTarget->GetDiseasesByCaster(m_caster->GetGUID(), consumeDiseases) / 2.0f); break; } // Blood-Caked Strike - Blood-Caked Blade @@ -4069,9 +4068,9 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex) break; } // Heart Strike - if (m_spellInfo->SpellFamilyFlags[EFFECT_0] & 0x1000000) + if (m_spellInfo->SpellFamilyFlags[0] & 0x1000000) { - AddPctN(totalDamagePercentMod, SpellMgr::CalculateSpellEffectAmount(m_spellInfo, EFFECT_2) * unitTarget->GetDiseasesByCaster(m_caster->GetGUID())); + AddPctN(totalDamagePercentMod, m_spellInfo->Effects[EFFECT_2].CalcValue() * unitTarget->GetDiseasesByCaster(m_caster->GetGUID())); break; } break; @@ -4082,7 +4081,7 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex) float weaponDamagePercentMod = 1.0f; for (int j = 0; j < MAX_SPELL_EFFECTS; ++j) { - switch (m_spellInfo->Effect[j]) + switch (m_spellInfo->Effects[j].Effect) { case SPELL_EFFECT_WEAPON_DAMAGE: case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: @@ -4129,7 +4128,7 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex) { // We assume that a spell have at most one fixed_bonus // and at most one weaponDamagePercentMod - switch(m_spellInfo->Effect[j]) + switch(m_spellInfo->Effects[j].Effect) { case SPELL_EFFECT_WEAPON_DAMAGE: case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: @@ -4205,16 +4204,16 @@ void Spell::EffectInterruptCast(SpellEffIndex effIndex) { if (Spell* spell = unitTarget->GetCurrentSpell(CurrentSpellTypes(i))) { - SpellEntry const* curSpellInfo = spell->m_spellInfo; + SpellInfo const* curSpellInfo = spell->m_spellInfo; // check if we can interrupt spell if ((spell->getState() == SPELL_STATE_CASTING - || (spell->getState() == SPELL_STATE_PREPARING && spell->GetCastTime() > 0.0f)) + || (spell->getState() == SPELL_STATE_PREPARING && spell->CalcCastTime() > 0.0f)) && curSpellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT && curSpellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE) { if (m_originalCaster) { int32 duration = m_originalCaster->ModSpellDuration(m_spellInfo, unitTarget, m_originalCaster->CalcSpellDuration(m_spellInfo), false); - unitTarget->ProhibitSpellSchool(GetSpellSchoolMask(curSpellInfo), duration/*GetSpellDuration(m_spellInfo)*/); + unitTarget->ProhibitSpellSchool(curSpellInfo->GetSchoolMask(), duration/*GetSpellDuration(m_spellInfo)*/); } ExecuteLogEffectInterruptCast(effIndex, unitTarget, curSpellInfo->Id); unitTarget->InterruptSpell(CurrentSpellTypes(i), false); @@ -4225,7 +4224,7 @@ void Spell::EffectInterruptCast(SpellEffIndex effIndex) void Spell::EffectSummonObjectWild(SpellEffIndex effIndex) { - uint32 gameobject_id = m_spellInfo->EffectMiscValue[effIndex]; + uint32 gameobject_id = m_spellInfo->Effects[effIndex].MiscValue; GameObject* pGameObj = new GameObject; @@ -4248,7 +4247,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex) return; } - int32 duration = GetSpellDuration(m_spellInfo); + int32 duration = m_spellInfo->GetDuration(); pGameObj->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0); pGameObj->SetSpellId(m_spellInfo->Id); @@ -4348,13 +4347,13 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) for (Unit::AuraEffectList::const_iterator i = mPeriodic.begin(); i != mPeriodic.end(); ++i) { AuraEffect const* aurEff = *i; - SpellEntry const* spellInfo = aurEff->GetSpellProto(); + SpellInfo const* spellInfo = aurEff->GetSpellInfo(); // search our Blood Plague and Frost Fever on target if (spellInfo->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && spellInfo->SpellFamilyFlags[2] & 0x2 && aurEff->GetCasterGUID() == m_caster->GetGUID()) { uint32 countMin = aurEff->GetBase()->GetMaxDuration(); - uint32 countMax = GetSpellMaxDuration(spellInfo); + uint32 countMax = spellInfo->GetMaxDuration(); // this Glyph countMax += 9000; @@ -4377,7 +4376,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) case 55693: // Remove Collapsing Cave Aura if (!unitTarget) return; - unitTarget->RemoveAurasDueToSpell(SpellMgr::CalculateSpellEffectAmount(m_spellInfo, effIndex)); + unitTarget->RemoveAurasDueToSpell(m_spellInfo->Effects[effIndex].CalcValue()); break; // PX-238 Winter Wondervolt TRAP case 26275: @@ -4640,7 +4639,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) case 45151: { //Workaround for Range ... should be global for every ScriptEffect - float radius = GetSpellRadiusForHostile(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[effIndex])); + float radius = m_spellInfo->Effects[effIndex].CalcRadius(); if (unitTarget && unitTarget->GetTypeId() == TYPEID_PLAYER && unitTarget->GetDistance(m_caster) >= radius && !unitTarget->HasAura(46394) && unitTarget != m_caster) unitTarget->CastSpell(unitTarget, 46394, true); @@ -4772,7 +4771,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) return; float x, y, z; - float radius = GetSpellRadius(m_spellInfo, effIndex, true); + float radius = m_spellInfo->Effects[effIndex].CalcRadius(); for (uint8 i = 0; i < 15; ++i) { m_caster->GetRandomPoint(*m_targets.GetDst(), radius, x, y, z); @@ -4818,8 +4817,8 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || effIndex != 0) return; - uint32 spellID = SpellMgr::CalculateSpellEffectAmount(m_spellInfo, 0); - uint32 questID = SpellMgr::CalculateSpellEffectAmount(m_spellInfo, 1); + uint32 spellID = m_spellInfo->Effects[EFFECT_0].CalcValue(); + uint32 questID = m_spellInfo->Effects[EFFECT_1].CalcValue(); if (unitTarget->ToPlayer()->GetQuestStatus(questID) == QUEST_STATUS_COMPLETE) unitTarget->CastSpell(unitTarget, spellID, true); @@ -5249,12 +5248,12 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) for (Unit::AuraApplicationMap::iterator iter = sealAuras.begin(); iter != sealAuras.end();) { Aura * aura = iter->second->GetBase(); - if (IsSealSpell(aura->GetSpellProto())) + if (aura->GetSpellInfo()->GetSpellSpecific() == SPELL_SPECIFIC_SEAL) { if (AuraEffect * aureff = aura->GetEffect(2)) if (aureff->GetAuraType() == SPELL_AURA_DUMMY) { - if (sSpellStore.LookupEntry(aureff->GetAmount())) + if (sSpellMgr->GetSpellInfo(aureff->GetAmount())) spellId2 = aureff->GetAmount(); break; } @@ -5435,7 +5434,7 @@ void Spell::EffectDuel(SpellEffIndex effIndex) //CREATE DUEL FLAG OBJECT GameObject* pGameObj = new GameObject; - uint32 gameobject_id = m_spellInfo->EffectMiscValue[effIndex]; + uint32 gameobject_id = m_spellInfo->Effects[effIndex].MiscValue; Map* map = m_caster->GetMap(); if (!pGameObj->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), gameobject_id, @@ -5451,7 +5450,7 @@ void Spell::EffectDuel(SpellEffIndex effIndex) pGameObj->SetUInt32Value(GAMEOBJECT_FACTION, m_caster->getFaction()); pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()+1); - int32 duration = GetSpellDuration(m_spellInfo); + int32 duration = m_spellInfo->GetDuration(); pGameObj->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0); pGameObj->SetSpellId(m_spellInfo->Id); @@ -5510,7 +5509,7 @@ void Spell::EffectStuck(SpellEffIndex /*effIndex*/) // pTarget->TeleportTo(pTarget->m_homebindMapId, pTarget->m_homebindX, pTarget->m_homebindY, pTarget->m_homebindZ, pTarget->GetOrientation(), (unitTarget == m_caster ? TELE_TO_SPELL : 0)); // Stuck spell trigger Hearthstone cooldown - SpellEntry const *spellInfo = sSpellStore.LookupEntry(8690); + SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(8690); if (!spellInfo) return; Spell spell(pTarget, spellInfo, true, 0); @@ -5546,7 +5545,7 @@ void Spell::EffectActivateObject(SpellEffIndex /*effIndex*/) ScriptInfo activateCommand; activateCommand.command = SCRIPT_COMMAND_ACTIVATE_OBJECT; - // int32 unk = m_spellInfo->EffectMiscValue[effIndex]; // This is set for EffectActivateObject spells; needs research + // int32 unk = m_spellInfo->Effects[effIndex].MiscValue; // This is set for EffectActivateObject spells; needs research gameObjTarget->GetMap()->ScriptCommandStart(activateCommand, 0, m_caster, gameObjTarget); } @@ -5576,7 +5575,7 @@ void Spell::EffectApplyGlyph(SpellEffIndex effIndex) } // apply new one - if (uint32 glyph = m_spellInfo->EffectMiscValue[effIndex]) + if (uint32 glyph = m_spellInfo->Effects[effIndex].MiscValue) { if (GlyphPropertiesEntry const *gp = sGlyphPropertiesStore.LookupEntry(glyph)) { @@ -5622,10 +5621,10 @@ void Spell::EffectEnchantHeldItem(SpellEffIndex effIndex) if (!item ->IsEquipped()) return; - if (m_spellInfo->EffectMiscValue[effIndex]) + if (m_spellInfo->Effects[effIndex].MiscValue) { - uint32 enchant_id = m_spellInfo->EffectMiscValue[effIndex]; - int32 duration = GetSpellDuration(m_spellInfo); //Try duration index first .. + uint32 enchant_id = m_spellInfo->Effects[effIndex].MiscValue; + int32 duration = m_spellInfo->GetDuration(); //Try duration index first .. if (!duration) duration = damage;//+1; //Base points after .. if (!duration) @@ -5707,7 +5706,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->EffectTriggerSpell[effIndex], &benefit, NULL, NULL, true); + m_caster->CastCustomSpell(pet, m_spellInfo->Effects[effIndex].TriggerSpell, &benefit, NULL, NULL, true); } void Spell::EffectDismissPet(SpellEffIndex effIndex) @@ -5727,10 +5726,10 @@ void Spell::EffectDismissPet(SpellEffIndex effIndex) void Spell::EffectSummonObject(SpellEffIndex effIndex) { - uint32 go_id = m_spellInfo->EffectMiscValue[effIndex]; + uint32 go_id = m_spellInfo->Effects[effIndex].MiscValue; uint8 slot = 0; - switch(m_spellInfo->Effect[effIndex]) + switch(m_spellInfo->Effects[effIndex].Effect) { case SPELL_EFFECT_SUMMON_OBJECT_SLOT1: slot = 0; break; case SPELL_EFFECT_SUMMON_OBJECT_SLOT2: slot = 1; break; @@ -5775,7 +5774,7 @@ void Spell::EffectSummonObject(SpellEffIndex effIndex) } //pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()); - int32 duration = GetSpellDuration(m_spellInfo); + int32 duration = m_spellInfo->GetDuration(); pGameObj->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0); pGameObj->SetSpellId(m_spellInfo->Id); m_caster->AddGameObject(pGameObj); @@ -5887,7 +5886,7 @@ void Spell::EffectReputation(SpellEffIndex effIndex) int32 rep_change = damage;//+1; // field store reputation change -1 - uint32 faction_id = m_spellInfo->EffectMiscValue[effIndex]; + uint32 faction_id = m_spellInfo->Effects[effIndex].MiscValue; FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id); @@ -5912,7 +5911,7 @@ void Spell::EffectQuestComplete(SpellEffIndex effIndex) else return; - uint32 questId = m_spellInfo->EffectMiscValue[effIndex]; + uint32 questId = m_spellInfo->Effects[effIndex].MiscValue; if (questId) { Quest const* quest = sObjectMgr->GetQuestTemplate(questId); @@ -5950,7 +5949,7 @@ void Spell::EffectSelfResurrect(SpellEffIndex effIndex) if (damage < 0) { health = uint32(-damage); - mana = m_spellInfo->EffectMiscValue[effIndex]; + mana = m_spellInfo->Effects[effIndex].MiscValue; } // percent case else @@ -6005,7 +6004,7 @@ void Spell::EffectCharge(SpellEffIndex /*effIndex*/) m_caster->GetMotionMaster()->MoveCharge(x, y, z); // not all charge effects used in negative spells - if (!IsPositiveSpell(m_spellInfo->Id) && m_caster->GetTypeId() == TYPEID_PLAYER) + if (!m_spellInfo->IsPositive() && m_caster->GetTypeId() == TYPEID_PLAYER) m_caster->Attack(target, true); } @@ -6053,20 +6052,20 @@ void Spell::EffectKnockBack(SpellEffIndex effIndex) ratio = ratio * ratio * ratio * 0.1f; // volume = length^3 else ratio = 0.1f; // dbc value ratio - float speedxy = float(m_spellInfo->EffectMiscValue[effIndex]) * ratio; + float speedxy = float(m_spellInfo->Effects[effIndex].MiscValue) * ratio; float speedz = float(damage) * ratio; if (speedxy < 0.1f && speedz < 0.1f) return; float x, y; - if (m_spellInfo->Effect[effIndex] == SPELL_EFFECT_KNOCK_BACK_DEST) + if (m_spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_KNOCK_BACK_DEST) { if (m_targets.HasDst()) m_targets.GetDst()->GetPosition(x, y); else return; } - else //if (m_spellInfo->Effect[i] == SPELL_EFFECT_KNOCK_BACK) + else //if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_KNOCK_BACK) { m_caster->GetPosition(x, y); } @@ -6076,7 +6075,7 @@ void Spell::EffectKnockBack(SpellEffIndex effIndex) void Spell::EffectLeapBack(SpellEffIndex effIndex) { - float speedxy = float(m_spellInfo->EffectMiscValue[effIndex])/10; + float speedxy = float(m_spellInfo->Effects[effIndex].MiscValue)/10; float speedz = float(damage/10); if (!speedxy) { @@ -6101,7 +6100,7 @@ void Spell::EffectQuestClear(SpellEffIndex effIndex) if (!pPlayer) return; - uint32 quest_id = m_spellInfo->EffectMiscValue[effIndex]; + uint32 quest_id = m_spellInfo->Effects[effIndex].MiscValue; Quest const* pQuest = sObjectMgr->GetQuestTemplate(quest_id); @@ -6134,7 +6133,7 @@ void Spell::EffectSendTaxi(SpellEffIndex effIndex) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - unitTarget->ToPlayer()->ActivateTaxiPathTo(m_spellInfo->EffectMiscValue[effIndex], m_spellInfo->Id); + unitTarget->ToPlayer()->ActivateTaxiPathTo(m_spellInfo->Effects[effIndex].MiscValue, m_spellInfo->Id); } void Spell::EffectPullTowards(SpellEffIndex effIndex) @@ -6142,17 +6141,17 @@ void Spell::EffectPullTowards(SpellEffIndex effIndex) if (!unitTarget) return; - float speedZ = (float)(SpellMgr::CalculateSpellEffectAmount(m_spellInfo, effIndex) / 10); - float speedXY = (float)(m_spellInfo->EffectMiscValue[effIndex]/10); + float speedZ = (float)(m_spellInfo->Effects[effIndex].CalcValue() / 10); + float speedXY = (float)(m_spellInfo->Effects[effIndex].MiscValue/10); Position pos; - if (m_spellInfo->Effect[effIndex] == SPELL_EFFECT_PULL_TOWARDS_DEST) + if (m_spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_PULL_TOWARDS_DEST) { if (m_targets.HasDst()) pos.Relocate(*m_targets.GetDst()); else return; } - else //if (m_spellInfo->Effect[i] == SPELL_EFFECT_PULL_TOWARDS) + else //if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_PULL_TOWARDS) { pos.Relocate(m_caster); } @@ -6165,7 +6164,7 @@ void Spell::EffectDispelMechanic(SpellEffIndex effIndex) if (!unitTarget) return; - uint32 mechanic = m_spellInfo->EffectMiscValue[effIndex]; + uint32 mechanic = m_spellInfo->Effects[effIndex].MiscValue; std::queue < std::pair < uint32, uint64 > > dispel_list; @@ -6175,10 +6174,9 @@ void Spell::EffectDispelMechanic(SpellEffIndex effIndex) Aura * aura = itr->second; if (!aura->GetApplicationOfTarget(unitTarget->GetGUID())) continue; - bool success = false; - GetDispelChance(aura->GetCaster(), unitTarget, aura->GetId(), !unitTarget->IsFriendlyTo(m_caster), &success); - if ((GetAllSpellMechanicMask(aura->GetSpellProto()) & (1 << mechanic)) && success) - dispel_list.push(std::make_pair(aura->GetId(), aura->GetCasterGUID())); + if (roll_chance_i(aura->CalcDispelChance(unitTarget, !unitTarget->IsFriendlyTo(m_caster)))) + if ((aura->GetSpellInfo()->GetAllEffectsMechanicMask() & (1 << mechanic))) + dispel_list.push(std::make_pair(aura->GetId(), aura->GetCasterGUID())); } for (; dispel_list.size(); dispel_list.pop()) @@ -6227,10 +6225,10 @@ void Spell::EffectDestroyAllTotems(SpellEffIndex /*effIndex*/) if (totem && totem->isTotem()) { uint32 spell_id = totem->GetUInt32Value(UNIT_CREATED_BY_SPELL); - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id); if (spellInfo) { - mana += spellInfo->manaCost; + mana += spellInfo->ManaCost; mana += int32(CalculatePctU(m_caster->GetCreateMana(), spellInfo->ManaCostPercentage)); } totem->ToTotem()->UnSummon(); @@ -6246,7 +6244,7 @@ void Spell::EffectDurabilityDamage(SpellEffIndex effIndex) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - int32 slot = m_spellInfo->EffectMiscValue[effIndex]; + int32 slot = m_spellInfo->Effects[effIndex].MiscValue; // FIXME: some spells effects have value -1/-2 // Possibly its mean -1 all player equipped items and -2 all items @@ -6271,7 +6269,7 @@ void Spell::EffectDurabilityDamagePCT(SpellEffIndex effIndex) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - int32 slot = m_spellInfo->EffectMiscValue[effIndex]; + int32 slot = m_spellInfo->Effects[effIndex].MiscValue; // FIXME: some spells effects have value -1/-2 // Possibly its mean -1 all player equipped items and -2 all items @@ -6302,7 +6300,7 @@ void Spell::EffectModifyThreatPercent(SpellEffIndex /*effIndex*/) void Spell::EffectTransmitted(SpellEffIndex effIndex) { - uint32 name_id = m_spellInfo->EffectMiscValue[effIndex]; + uint32 name_id = m_spellInfo->Effects[effIndex].MiscValue; GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(name_id); @@ -6317,16 +6315,16 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex) if (m_targets.HasDst()) m_targets.GetDst()->GetPosition(fx, fy, fz); //FIXME: this can be better check for most objects but still hack - else if (m_spellInfo->EffectRadiusIndex[effIndex] && m_spellInfo->speed == 0) + else if (m_spellInfo->Effects[effIndex].HasRadius() && m_spellInfo->Speed == 0) { - float dis = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[effIndex])); + float dis = m_spellInfo->Effects[effIndex].CalcRadius(m_originalCaster); m_caster->GetClosePoint(fx, fy, fz, DEFAULT_WORLD_OBJECT_SIZE, dis); } else { //GO is always friendly to it's creator, get range for friends - float min_dis = GetSpellMinRangeForFriend(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex)); - float max_dis = GetSpellMaxRangeForFriend(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex)); + float min_dis = m_spellInfo->GetMinRange(true); + float max_dis = m_spellInfo->GetMaxRange(true); float dis = (float)rand_norm() * (max_dis - min_dis) + min_dis; m_caster->GetClosePoint(fx, fy, fz, DEFAULT_WORLD_OBJECT_SIZE, dis); @@ -6362,7 +6360,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex) return; } - int32 duration = GetSpellDuration(m_spellInfo); + int32 duration = m_spellInfo->GetDuration(); switch(goinfo->type) { @@ -6505,7 +6503,7 @@ void Spell::EffectSpiritHeal(SpellEffIndex /*effIndex*/) if (!unitTarget->IsInWorld()) return; - //m_spellInfo->EffectBasePoints[i]; == 99 (percent?) + //m_spellInfo->Effects[i].BasePoints; == 99 (percent?) //unitTarget->ToPlayer()->setResurrect(m_caster->GetGUID(), unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), unitTarget->GetMaxHealth(), unitTarget->GetMaxPower(POWER_MANA)); unitTarget->ToPlayer()->ResurrectPlayer(1.0f); unitTarget->ToPlayer()->SpawnCorpseBones(); @@ -6532,7 +6530,7 @@ void Spell::EffectStealBeneficialBuff(SpellEffIndex effIndex) DispelChargesList steal_list; // Create dispel mask by dispel type - uint32 dispelMask = GetDispelMask(DispelType(m_spellInfo->EffectMiscValue[effIndex])); + uint32 dispelMask = SpellInfo::GetDispelMask(DispelType(m_spellInfo->Effects[effIndex].MiscValue)); Unit::AuraMap const& auras = unitTarget->GetOwnedAuras(); for (Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { @@ -6541,16 +6539,16 @@ void Spell::EffectStealBeneficialBuff(SpellEffIndex effIndex) if (!aurApp) continue; - if ((1<<aura->GetSpellProto()->Dispel) & dispelMask) + if ((aura->GetSpellInfo()->GetDispelMask()) & dispelMask) { // Need check for passive? this - if (!aurApp->IsPositive() || aura->IsPassive() || aura->GetSpellProto()->AttributesEx4 & SPELL_ATTR4_NOT_STEALABLE) + if (!aurApp->IsPositive() || aura->IsPassive() || aura->GetSpellInfo()->AttributesEx4 & SPELL_ATTR4_NOT_STEALABLE) continue; // The charges / stack amounts don't count towards the total number of auras that can be dispelled. // Ie: A dispel on a target with 5 stacks of Winters Chill and a Polymorph has 1 / (1 + 1) -> 50% chance to dispell // Polymorph instead of 1 / (5 + 1) -> 16%. - bool dispel_charges = aura->GetSpellProto()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES; + bool dispel_charges = aura->GetSpellInfo()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES; uint8 charges = dispel_charges ? aura->GetCharges() : aura->GetStackAmount(); if (charges > 0) steal_list.push_back(std::make_pair(aura, charges)); @@ -6571,16 +6569,16 @@ void Spell::EffectStealBeneficialBuff(SpellEffIndex effIndex) DispelChargesList::iterator itr = steal_list.begin(); std::advance(itr, urand(0, steal_list.size() - 1)); - bool success = false; + int32 chance = itr->first->CalcDispelChance(unitTarget, !unitTarget->IsFriendlyTo(m_caster)); // 2.4.3 Patch Notes: "Dispel effects will no longer attempt to remove effects that have 100% dispel resistance." - if (!GetDispelChance(itr->first->GetCaster(), unitTarget, itr->first->GetId(), !unitTarget->IsFriendlyTo(m_caster), &success)) + if (!chance) { steal_list.erase(itr); continue; } else { - if (success) + if (roll_chance_i(chance)) { success_list.push_back(std::make_pair(itr->first->GetId(), itr->first->GetCasterGUID())); --itr->second; @@ -6629,7 +6627,7 @@ void Spell::EffectKillCreditPersonal(SpellEffIndex effIndex) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - unitTarget->ToPlayer()->KilledMonsterCredit(m_spellInfo->EffectMiscValue[effIndex], 0); + unitTarget->ToPlayer()->KilledMonsterCredit(m_spellInfo->Effects[effIndex].MiscValue, 0); } void Spell::EffectKillCredit(SpellEffIndex effIndex) @@ -6637,7 +6635,7 @@ void Spell::EffectKillCredit(SpellEffIndex effIndex) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - int32 creatureEntry = m_spellInfo->EffectMiscValue[effIndex]; + int32 creatureEntry = m_spellInfo->Effects[effIndex].MiscValue; if (!creatureEntry) { if (m_spellInfo->Id == 42793) // Burn Body @@ -6653,7 +6651,7 @@ void Spell::EffectQuestFail(SpellEffIndex effIndex) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - unitTarget->ToPlayer()->FailQuest(m_spellInfo->EffectMiscValue[effIndex]); + unitTarget->ToPlayer()->FailQuest(m_spellInfo->Effects[effIndex].MiscValue); } void Spell::EffectQuestStart(SpellEffIndex effIndex) @@ -6662,7 +6660,7 @@ void Spell::EffectQuestStart(SpellEffIndex effIndex) return; Player* player = unitTarget->ToPlayer(); - if (Quest const* qInfo = sObjectMgr->GetQuestTemplate(m_spellInfo->EffectMiscValue[effIndex])) + if (Quest const* qInfo = sObjectMgr->GetQuestTemplate(m_spellInfo->Effects[effIndex].MiscValue)) { if (player->CanTakeQuest(qInfo, false) && player->CanAddQuest(qInfo, false)) { @@ -6688,7 +6686,7 @@ void Spell::EffectActivateRune(SpellEffIndex effIndex) if (count == 0) count = 1; for (uint32 j = 0; j < MAX_RUNES && count > 0; ++j) { - if (plr->GetRuneCooldown(j) && plr->GetCurrentRune(j) == RuneType(m_spellInfo->EffectMiscValue[effIndex])) + if (plr->GetRuneCooldown(j) && plr->GetCurrentRune(j) == RuneType(m_spellInfo->Effects[effIndex].MiscValue)) { plr->SetRuneCooldown(j, 0); --count; @@ -6714,7 +6712,7 @@ void Spell::EffectCreateTamedPet(SpellEffIndex effIndex) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || unitTarget->GetPetGUID() || unitTarget->getClass() != CLASS_HUNTER) return; - uint32 creatureEntry = m_spellInfo->EffectMiscValue[effIndex]; + uint32 creatureEntry = m_spellInfo->Effects[effIndex].MiscValue; Pet* pet = unitTarget->CreateTamedPetFrom(creatureEntry, m_spellInfo->Id); if (!pet) return; @@ -6738,7 +6736,7 @@ void Spell::EffectDiscoverTaxi(SpellEffIndex effIndex) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - uint32 nodeid = m_spellInfo->EffectMiscValue[effIndex]; + uint32 nodeid = m_spellInfo->Effects[effIndex].MiscValue; if (sTaxiNodesStore.LookupEntry(nodeid)) unitTarget->ToPlayer()->GetSession()->SendDiscoverNewTaxiNode(nodeid); } @@ -6785,7 +6783,7 @@ void Spell::EffectGameObjectSetDestructionState(SpellEffIndex effIndex) return; Player* player = m_originalCaster->GetCharmerOrOwnerPlayerOrPlayerItself(); - gameObjTarget->SetDestructibleState(GameObjectDestructibleState(m_spellInfo->EffectMiscValue[effIndex]), player, true); + gameObjTarget->SetDestructibleState(GameObjectDestructibleState(m_spellInfo->Effects[effIndex].MiscValue), player, true); } void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const *properties) @@ -6810,7 +6808,7 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const * //float radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); float radius = 5.0f; uint32 amount = damage > 0 ? damage : 1; - int32 duration = GetSpellDuration(m_spellInfo); + int32 duration = m_spellInfo->GetDuration(); switch (m_spellInfo->Id) { case 1122: // Inferno @@ -6874,7 +6872,7 @@ void Spell::GetSummonPosition(uint32 i, Position &pos, float radius, uint32 coun else { //This is a workaround. Do not have time to write much about it - switch (m_spellInfo->EffectImplicitTargetA[i]) + switch (m_spellInfo->Effects[i].TargetA) { case TARGET_MINION: case TARGET_DEST_CASTER_RANDOM: @@ -6913,7 +6911,7 @@ void Spell::EffectPlayMusic(SpellEffIndex effIndex) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - uint32 soundid = m_spellInfo->EffectMiscValue[effIndex]; + uint32 soundid = m_spellInfo->Effects[effIndex].MiscValue; if (!sSoundEntriesStore.LookupEntry(soundid)) { @@ -6955,7 +6953,7 @@ void Spell::EffectPlayerNotification(SpellEffIndex effIndex) break; } - uint32 soundid = m_spellInfo->EffectMiscValue[effIndex]; + uint32 soundid = m_spellInfo->Effects[effIndex].MiscValue; if (!sSoundEntriesStore.LookupEntry(soundid)) { @@ -6973,7 +6971,7 @@ void Spell::EffectRemoveAura(SpellEffIndex effIndex) if (!unitTarget) return; // there may be need of specifying casterguid of removed auras - unitTarget->RemoveAurasDueToSpell(m_spellInfo->EffectTriggerSpell[effIndex]); + unitTarget->RemoveAurasDueToSpell(m_spellInfo->Effects[effIndex].TriggerSpell); } void Spell::EffectCastButtons(SpellEffIndex effIndex) @@ -6982,8 +6980,8 @@ void Spell::EffectCastButtons(SpellEffIndex effIndex) return; Player* p_caster = m_caster->ToPlayer(); - uint32 button_id = m_spellInfo->EffectMiscValue[effIndex] + 132; - uint32 n_buttons = m_spellInfo->EffectMiscValueB[effIndex]; + uint32 button_id = m_spellInfo->Effects[effIndex].MiscValue + 132; + uint32 n_buttons = m_spellInfo->Effects[effIndex].MiscValueB; for (; n_buttons; n_buttons--, button_id++) { @@ -6998,8 +6996,8 @@ void Spell::EffectCastButtons(SpellEffIndex effIndex) if (p_caster->HasSpellCooldown(spell_id)) continue; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); - uint32 cost = CalculatePowerCost(spellInfo, m_caster, GetSpellSchoolMask(spellInfo)); + SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(spell_id); + uint32 cost = spellInfo->CalcPowerCost(m_caster, spellInfo->GetSchoolMask()); if (m_caster->GetPower(POWER_MANA) < cost) break; @@ -7020,7 +7018,7 @@ void Spell::EffectRechargeManaGem(SpellEffIndex /*effIndex*/) if (!player) return; - uint32 item_id = m_spellInfo->EffectItemType[0]; + uint32 item_id = m_spellInfo->Effects[EFFECT_0].ItemType; ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(item_id); if (!pProto) @@ -7046,7 +7044,7 @@ void Spell::EffectBind(SpellEffIndex effIndex) uint32 area_id; WorldLocation loc; - if (m_spellInfo->EffectImplicitTargetA[effIndex] == TARGET_DST_DB || m_spellInfo->EffectImplicitTargetB[effIndex] == TARGET_DST_DB) + if (m_spellInfo->Effects[effIndex].TargetA == TARGET_DST_DB || m_spellInfo->Effects[effIndex].TargetB == TARGET_DST_DB) { SpellTargetPosition const* st = sSpellMgr->GetSpellTargetPosition(m_spellInfo->Id); if (!st) |