From 93c5b1cf1d42b0ba2527c7383b4d3950b43d458c Mon Sep 17 00:00:00 2001 From: Yaki Khadafi Date: Fri, 17 Aug 2012 03:43:40 +0300 Subject: [PATCH] [0111] Implement rest of spell scaling Signed-off-by: Yaki Khadafi --- src/game/DBCStructure.h | 2 +- src/game/SpellMgr.cpp | 3 +- src/game/Unit.cpp | 89 ++++++++++++++++++++++++++-------------- src/shared/revision_nr.h | 2 +- 4 files changed, 61 insertions(+), 35 deletions(-) diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h index 8c2e64ae1..c48c3defc 100644 --- a/src/game/DBCStructure.h +++ b/src/game/DBCStructure.h @@ -1798,7 +1798,7 @@ struct SpellScalingEntry uint32 castTimeMin; // 1 uint32 castTimeMax; // 2 uint32 castScalingMaxLevel; // 3 - uint32 playerClass; // 4 (index * 100) + charLevel => gtSpellScaling.dbc + int32 playerClass; // 4 (index * 100) + charLevel => gtSpellScaling.dbc float coeff1[3]; // 5-7 float coeff2[3]; // 8-10 float coeff3[3]; // 11-13 diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index cf4e43e3d..c1997dcaf 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -136,8 +136,7 @@ uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell const* spell) { if (levelsEntry->maxLevel) level = std::min(level, levelsEntry->maxLevel); - if (levelsEntry->baseLevel) - level = std::max(level, levelsEntry->baseLevel) - levelsEntry->baseLevel; + level = std::max(level, levelsEntry->baseLevel) - levelsEntry->baseLevel; } // currently only profession spells have CastTimePerLevel data filled, always negative diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 090e7943a..a2c4ddccd 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -9257,43 +9257,70 @@ bool Unit::SelectHostileTarget() int32 Unit::CalculateSpellDamage(Unit const* target, SpellEntry const* spellProto, SpellEffectIndex effect_index, int32 const* effBasePoints) { - Player* unitPlayer = (GetTypeId() == TYPEID_PLAYER) ? (Player*)this : NULL; - - uint8 comboPoints = unitPlayer ? unitPlayer->GetComboPoints() : 0; - - int32 level = int32(getLevel()); - uint32 maxLevel = spellProto->GetMaxLevel(); - uint32 baseLevel = spellProto->GetBaseLevel(); - uint32 spellLevel = spellProto->GetSpellLevel(); - if (level > (int32)maxLevel && maxLevel > 0) - level = (int32)maxLevel; - else if (level < (int32)baseLevel) - level = (int32)baseLevel; - level-= (int32)spellLevel; - SpellEffectEntry const* spellEffect = spellProto->GetSpellEffect(effect_index); if(!spellEffect) return 0; - float basePointsPerLevel = spellEffect->EffectRealPointsPerLevel; - int32 basePoints = effBasePoints ? *effBasePoints - 1 : spellEffect->EffectBasePoints; - basePoints += int32(level * basePointsPerLevel); - int32 randomPoints = int32(spellEffect->EffectDieSides); - float comboDamage = spellEffect->EffectPointsPerComboPoint; + Player* unitPlayer = (GetTypeId() == TYPEID_PLAYER) ? (Player*)this : NULL; - switch (randomPoints) + uint8 comboPoints = unitPlayer ? unitPlayer->GetComboPoints() : 0; + + int32 basePoints = 0; + uint32 spellLevel = 0; + float comboDamage = 0.0f; + + SpellScalingEntry const* scalingEntry = spellProto->GetSpellScaling(); + GtSpellScalingEntry const* gtScalingEntry = NULL; + if (scalingEntry) { - case 0: // not used - 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); + uint32 gtSpellScalingId = getLevel() - 1; + if (scalingEntry->playerClass == -1) + gtSpellScalingId += 11 * 100; + else + gtSpellScalingId += (getClass() - 1) * 100; - basePoints += randvalue; - break; + gtScalingEntry = sGtSpellScalingStore.LookupEntry(gtSpellScalingId); + } + + if (gtScalingEntry) + { + basePoints = int32(scalingEntry->coeff1[effect_index] * gtScalingEntry->value); + int32 randomPoints = int32(scalingEntry->coeff1[effect_index] * gtScalingEntry->value * scalingEntry->coeff2[effect_index]); + basePoints += irand(-randomPoints, randomPoints) / 2; + comboDamage = uint32(scalingEntry->coeff3[effect_index] * gtScalingEntry->value); + } + else + { + spellLevel = spellProto->GetSpellLevel(); + uint32 level = getLevel(); + uint32 maxLevel = spellProto->GetMaxLevel(); + uint32 baseLevel = spellProto->GetBaseLevel(); + + if (maxLevel) + level = std::min(level, maxLevel); + level = std::max(level, baseLevel); + level = std::max(level, spellLevel) - spellLevel; + + float basePointsPerLevel = spellEffect->EffectRealPointsPerLevel; + basePoints = effBasePoints ? *effBasePoints - 1 : spellEffect->EffectBasePoints; + basePoints += int32(level * basePointsPerLevel); + int32 randomPoints = int32(spellEffect->EffectDieSides); + comboDamage = spellEffect->EffectPointsPerComboPoint; + + switch (randomPoints) + { + case 0: // not used + 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; + } } } @@ -9322,7 +9349,7 @@ int32 Unit::CalculateSpellDamage(Unit const* target, SpellEntry const* spellProt } } - if(spellProto->Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION && spellLevel && + if (!gtScalingEntry && spellProto->Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION && spellLevel && spellEffect->Effect != SPELL_EFFECT_WEAPON_PERCENT_DAMAGE && spellEffect->Effect != SPELL_EFFECT_KNOCK_BACK && (spellEffect->Effect != SPELL_EFFECT_APPLY_AURA || spellEffect->EffectApplyAuraName != SPELL_AURA_MOD_DECREASE_SPEED)) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 316c21d72..bfa5fc022 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "0110" + #define REVISION_NR "0111" #endif // __REVISION_NR_H__