aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2012-08-17 00:10:19 +0200
committerShauren <shauren.trinity@gmail.com>2012-08-17 00:10:19 +0200
commitf447403f6c570cdf3d8e0293d3dc53bd53d750bb (patch)
tree77352918cade6840bac9cf718b9cf9d4b9ace43b /src
parent69c74bb3c52682eaf4e26fbe8da832ddf1a94ff7 (diff)
Core/Spells: Implemented spell level scaling
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/Combat/ThreatManager.cpp2
-rwxr-xr-xsrc/server/game/Entities/Unit/StatSystem.cpp2
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp2
-rw-r--r--src/server/game/Spells/SpellEffects.cpp12
-rw-r--r--src/server/game/Spells/SpellInfo.cpp97
-rw-r--r--src/server/game/Spells/SpellInfo.h3
6 files changed, 81 insertions, 37 deletions
diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp
index 87853a53b6c..ea2e8099aff 100755
--- a/src/server/game/Combat/ThreatManager.cpp
+++ b/src/server/game/Combat/ThreatManager.cpp
@@ -420,7 +420,7 @@ void ThreatManager::doAddThreat(Unit* victim, float threat)
Unit* redirectTarget = victim->GetMisdirectionTarget();
if (redirectTarget)
if (Aura* glyphAura = redirectTarget->GetAura(63326)) // Glyph of Vigilance
- reducedThreadPercent += glyphAura->GetSpellInfo()->Effects[0].CalcValue();
+ reducedThreadPercent += glyphAura->GetSpellInfo()->Effects[0].CalcValue(glyphAura->GetCaster());
float reducedThreat = threat * reducedThreadPercent / 100.0f;
threat -= reducedThreat;
diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp
index 48aebc7d17e..75e82235611 100755
--- a/src/server/game/Entities/Unit/StatSystem.cpp
+++ b/src/server/game/Entities/Unit/StatSystem.cpp
@@ -997,7 +997,7 @@ bool Guardian::UpdateStats(Stats stat)
if (aurEff)
{
SpellInfo const* spellInfo = aurEff->GetSpellInfo(); // Then get the SpellProto and add the dummy effect value
- AddPctN(mod, spellInfo->Effects[EFFECT_1].CalcValue()); // Ravenous Dead edits the original scale
+ AddPctN(mod, spellInfo->Effects[EFFECT_1].CalcValue(owner)); // Ravenous Dead edits the original scale
}
// Glyph of the Ghoul
aurEff = owner->GetAuraEffect(58686, 0);
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index edfc55dec44..38afbc28417 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -1597,7 +1597,7 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
// Survival of the Fittest
if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, SPELLFAMILY_DRUID, 961, 0))
{
- int32 bp = aurEff->GetSpellInfo()->Effects[EFFECT_2].CalcValue();
+ int32 bp = aurEff->GetSpellInfo()->Effects[EFFECT_2].CalcValue(GetCaster());
target->CastCustomSpell(target, 62069, &bp, NULL, NULL, true, 0, this);
}
break;
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 4751584b650..e2e758d8427 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -608,7 +608,7 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
// TODO: should this be put on taken but not done?
if (found)
- damage += m_spellInfo->Effects[EFFECT_1].CalcValue();
+ damage += m_spellInfo->Effects[EFFECT_1].CalcValue(m_caster);
if (Player* caster = m_caster->ToPlayer())
{
@@ -2566,7 +2566,7 @@ void Spell::EffectDispel(SpellEffIndex effIndex)
// Devour Magic
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellInfo->Category == SPELLCATEGORY_DEVOUR_MAGIC)
{
- int32 heal_amount = m_spellInfo->Effects[EFFECT_1].CalcValue();
+ 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())
@@ -3324,7 +3324,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
// Blood Strike
if (m_spellInfo->SpellFamilyFlags[0] & 0x400000)
{
- float bonusPct = m_spellInfo->Effects[EFFECT_2].CalcValue() * unitTarget->GetDiseasesByCaster(m_caster->GetGUID()) / 2.0f;
+ 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))
AddPctF(bonusPct, aurEff->GetAmount());
@@ -3341,7 +3341,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
{
// 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), aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue()))
+ if (uint32 runic = std::min<uint32>(m_caster->GetPower(POWER_RUNIC_POWER), aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue(m_caster)))
AddPctN(totalDamagePercentMod, runic);
break;
}
@@ -3355,7 +3355,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
if (roll_chance_i(aurEff->GetAmount()))
consumeDiseases = false;
- float bonusPct = m_spellInfo->Effects[EFFECT_2].CalcValue() * unitTarget->GetDiseasesByCaster(m_caster->GetGUID(), consumeDiseases) / 2.0f;
+ float bonusPct = m_spellInfo->Effects[EFFECT_2].CalcValue(m_caster) * unitTarget->GetDiseasesByCaster(m_caster->GetGUID(), consumeDiseases) / 2.0f;
// Death Knight T8 Melee 4P Bonus
if (AuraEffect const* aurEff = m_caster->GetAuraEffect(64736, EFFECT_0))
AddPctF(bonusPct, aurEff->GetAmount());
@@ -3371,7 +3371,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
// Heart Strike
if (m_spellInfo->SpellFamilyFlags[0] & 0x1000000)
{
- float bonusPct = m_spellInfo->Effects[EFFECT_2].CalcValue() * unitTarget->GetDiseasesByCaster(m_caster->GetGUID());
+ 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))
AddPctF(bonusPct, aurEff->GetAmount());
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index 16409b94ffe..7eb1cab28d7 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -320,6 +320,7 @@ SpellImplicitTargetInfo::StaticData SpellImplicitTargetInfo::_data[TOTAL_SPELL_
SpellEffectInfo::SpellEffectInfo(SpellEntry const* spellEntry, SpellInfo const* spellInfo, uint8 effIndex)
{
SpellEffectEntry const* _effect = spellEntry->GetSpellEffect(effIndex);
+ SpellScalingEntry const* scaling = spellInfo->GetSpellScaling();
_spellInfo = spellInfo;
_effIndex = effIndex;
@@ -344,6 +345,9 @@ SpellEffectInfo::SpellEffectInfo(SpellEntry const* spellEntry, SpellInfo const*
TriggerSpell = _effect ? _effect->EffectTriggerSpell : 0;
SpellClassMask = _effect ? _effect->EffectSpellClassMask : flag96(0);
ImplicitTargetConditions = NULL;
+ ScalingMultiplier = scaling ? scaling->Multiplier[effIndex] : 0.0f;
+ DeltaScalingMultiplier = scaling ? scaling->RandomMultiplier[effIndex] : 0.0f;
+ ComboScalingMultiplier = scaling ? scaling->OtherMultiplier[effIndex] : 0.0f;
}
bool SpellEffectInfo::IsEffect() const
@@ -406,33 +410,58 @@ int32 SpellEffectInfo::CalcValue(Unit const* caster, int32 const* bp, Unit const
{
float basePointsPerLevel = RealPointsPerLevel;
int32 basePoints = bp ? *bp : BasePoints;
- int32 randomPoints = int32(DieSides);
+ float comboDamage = PointsPerComboPoint;
+ SpellScalingEntry const* scaling = _spellInfo->GetSpellScaling();
// base amount modification based on spell lvl vs caster lvl
- if (caster)
+ if (scaling)
{
- int32 level = int32(caster->getLevel());
- if (level > int32(_spellInfo->MaxLevel) && _spellInfo->MaxLevel > 0)
- level = int32(_spellInfo->MaxLevel);
- else if (level < int32(_spellInfo->BaseLevel))
- level = int32(_spellInfo->BaseLevel);
- level -= int32(_spellInfo->SpellLevel);
- basePoints += int32(level * basePointsPerLevel);
- }
+ if (caster)
+ {
+ if (GtSpellScalingEntry const* gtScaling = sGtSpellScalingStore.LookupEntry((scaling->playerClass != -1 ? caster->getClass() : 11) * 100 + caster->getLevel() - 1))
+ {
+ float preciseBasePoints = ScalingMultiplier * gtScaling->value;
+ comboDamage = ComboScalingMultiplier * gtScaling->value;
+ if (DeltaScalingMultiplier)
+ {
+ float delta = DeltaScalingMultiplier * ScalingMultiplier * gtScaling->value * 0.5f;
+ preciseBasePoints += frand(-delta, delta);
+ }
- // roll in a range <1;EffectDieSides> as of patch 3.3.3
- switch (randomPoints)
+ basePoints = int32(preciseBasePoints);
+ }
+ }
+ }
+ else
{
- case 0: break;
- case 1: basePoints += 1; break; // range 1..1
- default:
- // range can have positive (1..rand) and negative (rand..1) values, so order its for irand
- int32 randvalue = (randomPoints >= 1)
- ? irand(1, randomPoints)
- : irand(randomPoints, 1);
+ if (caster)
+ {
+ int32 level = int32(caster->getLevel());
+ if (level > int32(_spellInfo->MaxLevel) && _spellInfo->MaxLevel > 0)
+ level = int32(_spellInfo->MaxLevel);
+ else if (level < int32(_spellInfo->BaseLevel))
+ level = int32(_spellInfo->BaseLevel);
+ level -= int32(_spellInfo->SpellLevel);
+ basePoints += int32(level * basePointsPerLevel);
+ }
- basePoints += randvalue;
- break;
+ // roll in a range <1;EffectDieSides> as of patch 3.3.3
+ int32 randomPoints = int32(DieSides);
+ switch (randomPoints)
+ {
+ case 0: break;
+ case 1: basePoints += 1; break; // range 1..1
+ default:
+ {
+ // range can have positive (1..rand) and negative (rand..1) values, so order its for irand
+ int32 randvalue = (randomPoints >= 1)
+ ? irand(1, randomPoints)
+ : irand(randomPoints, 1);
+
+ basePoints += randvalue;
+ break;
+ }
+ }
}
float value = float(basePoints);
@@ -441,15 +470,14 @@ int32 SpellEffectInfo::CalcValue(Unit const* caster, int32 const* bp, Unit const
if (caster)
{
// bonus amount from combo points
- if (caster->m_movedPlayer)
+ if (caster->m_movedPlayer && comboDamage)
if (uint8 comboPoints = caster->m_movedPlayer->GetComboPoints())
- if (float comboDamage = PointsPerComboPoint)
- value += comboDamage* comboPoints;
+ value += comboDamage * comboPoints;
value = caster->ApplyEffectModifiers(_spellInfo, _effIndex, value);
// amount multiplication based on caster's level
- if (!basePointsPerLevel && (_spellInfo->Attributes & SPELL_ATTR0_LEVEL_DAMAGE_CALCULATION && _spellInfo->SpellLevel) &&
+ if (!_spellInfo->GetSpellScaling() && !basePointsPerLevel && (_spellInfo->Attributes & SPELL_ATTR0_LEVEL_DAMAGE_CALCULATION && _spellInfo->SpellLevel) &&
Effect != SPELL_EFFECT_WEAPON_PERCENT_DAMAGE &&
Effect != SPELL_EFFECT_KNOCK_BACK &&
Effect != SPELL_EFFECT_ADD_EXTRA_ATTACKS &&
@@ -2044,11 +2072,24 @@ int32 SpellInfo::GetMaxDuration() const
uint32 SpellInfo::CalcCastTime(Unit* caster, Spell* spell) const
{
+ int32 castTime = 0;
+
// not all spells have cast time index and this is all is pasiive abilities
- if (!CastTimeEntry)
- return 0;
+ SpellScalingEntry const* scaling = GetSpellScaling();
+ if (scaling && caster)
+ {
+ if (scaling->castTimeMax > 0)
+ {
+ castTime = scaling->castTimeMax;
+ if (scaling->castScalingMaxLevel > caster->getLevel())
+ castTime = scaling->castTimeMin + (caster->getLevel() - 1) * (scaling->castTimeMax - scaling->castTimeMin) / (scaling->castScalingMaxLevel - 1);
+ }
+ }
+ else if (CastTimeEntry)
+ castTime = CastTimeEntry->CastTime;
- int32 castTime = CastTimeEntry->CastTime;
+ if (!castTime)
+ return 0;
if (caster)
caster->ModSpellCastTime(this, castTime, spell);
diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h
index a338b8d627f..2fb0234997c 100644
--- a/src/server/game/Spells/SpellInfo.h
+++ b/src/server/game/Spells/SpellInfo.h
@@ -249,6 +249,9 @@ public:
uint32 TriggerSpell;
flag96 SpellClassMask;
std::list<Condition*>* ImplicitTargetConditions;
+ float ScalingMultiplier;
+ float DeltaScalingMultiplier;
+ float ComboScalingMultiplier;
SpellEffectInfo() {}
SpellEffectInfo(SpellEntry const* spellEntry, SpellInfo const* spellInfo, uint8 effIndex);