aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2012-08-22 16:50:42 +0200
committerShauren <shauren.trinity@gmail.com>2012-08-22 16:50:42 +0200
commit5b19f8672c8746985d5ed87cacb2129ee9a2bb99 (patch)
treea2b4e4cdc651ac7a71cd1cee12e4a277840ee072
parent4ee7558aa22f67e5e421e8f8ab3696191d351652 (diff)
Core/Spells: Fixed spell scaling problems with CastTimeMin > CastTimeMax, also minor cleanup
-rw-r--r--src/server/game/DataStores/DBCStructure.h12
-rw-r--r--src/server/game/Spells/SpellInfo.cpp39
-rw-r--r--src/server/game/Spells/SpellInfo.h14
3 files changed, 26 insertions, 39 deletions
diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h
index f743b051ce8..7b076698d9d 100644
--- a/src/server/game/DataStores/DBCStructure.h
+++ b/src/server/game/DataStores/DBCStructure.h
@@ -2006,16 +2006,16 @@ typedef std::map<uint32, SpellReagent> SpellReagentMap;
// SpellScaling.dbc
struct SpellScalingEntry
{
- //uint32 Id; // 0 m_ID
- int32 castTimeMin; // 1
- int32 castTimeMax; // 2
- uint32 castScalingMaxLevel; // 3
- uint32 playerClass; // 4 (index * 100) + charLevel => gtSpellScaling.dbc
+ //uint32 Id; // 0 m_ID
+ int32 CastTimeMin; // 1
+ int32 CastTimeMax; // 2
+ int32 CastTimeMaxLevel; // 3
+ int32 ScalingClass; // 4 (index * 100) + charLevel - 1 => gtSpellScaling.dbc
float Multiplier[3]; // 5-7
float RandomMultiplier[3]; // 8-10
float OtherMultiplier[3]; // 11-13
float CoefBase; // 14 some coefficient, mostly 1.0f
- uint32 CoefLevelBase; // 15 some level
+ int32 CoefLevelBase; // 15 some level
};
struct SpellDurationEntry
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index 53ce893f0a0..72cd40ea1ea 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -417,18 +417,17 @@ int32 SpellEffectInfo::CalcValue(Unit const* caster, int32 const* bp, Unit const
{
if (caster)
{
- uint32 level = caster->getLevel();
+ int32 level = caster->getLevel();
if (target && _spellInfo->IsPositiveEffect(_effIndex) && (Effect == SPELL_EFFECT_APPLY_AURA))
level = target->getLevel();
- SpellScalingEntry const* scaling = _spellInfo->GetSpellScaling(); // must exist, otherwise ScalingMultiplier == 0.0f
- if (GtSpellScalingEntry const* gtScaling = sGtSpellScalingStore.LookupEntry((scaling->playerClass != -1 ? scaling->playerClass - 1 : MAX_CLASSES - 1) * 100 + level - 1))
+ if (GtSpellScalingEntry const* gtScaling = sGtSpellScalingStore.LookupEntry((_spellInfo->ScalingClass != -1 ? _spellInfo->ScalingClass - 1 : MAX_CLASSES - 1) * 100 + level - 1))
{
float multiplier = gtScaling->value;
- if (scaling->castTimeMax > 0 && scaling->castScalingMaxLevel > level)
- multiplier *= float(scaling->castTimeMin + (level - 1) * (scaling->castTimeMax - scaling->castTimeMin) / (scaling->castScalingMaxLevel - 1)) / float(scaling->castTimeMax);
- if (scaling->CoefLevelBase > level)
- multiplier *= (1.0f - scaling->CoefBase) * (float)(level - 1) / (float)(scaling->CoefLevelBase - 1) + scaling->CoefBase;
+ if (_spellInfo->CastTimeMax > 0 && _spellInfo->CastTimeMaxLevel > level)
+ multiplier *= float(_spellInfo->CastTimeMin + (level - 1) * (_spellInfo->CastTimeMax - _spellInfo->CastTimeMin) / (_spellInfo->CastTimeMaxLevel - 1)) / float(_spellInfo->CastTimeMax);
+ if (_spellInfo->CoefLevelBase > level)
+ multiplier *= (1.0f - _spellInfo->CoefBase) * (float)(level - 1) / (float)(_spellInfo->CoefLevelBase - 1) + _spellInfo->CoefBase;
float preciseBasePoints = ScalingMultiplier * multiplier;
if (DeltaScalingMultiplier)
@@ -804,16 +803,10 @@ SpellInfo::SpellInfo(SpellEntry const* spellEntry)
// SpellScalingEntry
SpellScalingEntry const* _scaling = GetSpellScaling();
- castTimeMin = _scaling ? _scaling->castTimeMin : 0;
- castTimeMax = _scaling ?_scaling->castTimeMax : 0;
- castScalingMaxLevel = _scaling ? _scaling->castScalingMaxLevel : 0;
- playerClass = _scaling ? _scaling->playerClass : 0;
- for (uint8 i = 0; i < 3; ++i)
- {
- Multiplier[i] = _scaling ? _scaling->Multiplier[i] : 0;
- RandomMultiplier[i] = _scaling ? _scaling->RandomMultiplier[i] : 0;
- OtherMultiplier[i] = _scaling ? _scaling->OtherMultiplier[i] : 0;
- }
+ CastTimeMin = _scaling ? _scaling->CastTimeMin : 0;
+ CastTimeMax = _scaling ?_scaling->CastTimeMax : 0;
+ CastTimeMaxLevel = _scaling ? _scaling->CastTimeMaxLevel : 0;
+ ScalingClass = _scaling ? _scaling->ScalingClass : 0;
CoefBase = _scaling ? _scaling->CoefBase : 0;
CoefLevelBase = _scaling ? _scaling->CoefLevelBase : 0;
@@ -2092,15 +2085,11 @@ 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
- SpellScalingEntry const* scaling = GetSpellScaling();
- if (scaling && caster)
+ if (caster && CastTimeMax > 0)
{
- 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);
- }
+ castTime = CastTimeMax;
+ if (CastTimeMaxLevel > int32(caster->getLevel()))
+ castTime = CastTimeMin + int32(caster->getLevel() - 1) * (CastTimeMax - CastTimeMin) / (CastTimeMaxLevel - 1);
}
else if (CastTimeEntry)
castTime = CastTimeEntry->CastTime;
diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h
index 9387ad750a0..b77adf6ad58 100644
--- a/src/server/game/Spells/SpellInfo.h
+++ b/src/server/game/Spells/SpellInfo.h
@@ -251,6 +251,7 @@ public:
uint32 TriggerSpell;
flag96 SpellClassMask;
std::list<Condition*>* ImplicitTargetConditions;
+ // SpellScalingEntry
float ScalingMultiplier;
float DeltaScalingMultiplier;
float ComboScalingMultiplier;
@@ -383,15 +384,12 @@ public:
uint32 SpellTargetRestrictionsId;
uint32 SpellTotemsId;
// SpellScalingEntry
- int32 castTimeMin;
- int32 castTimeMax;
- uint32 castScalingMaxLevel;
- uint32 playerClass;
- float Multiplier[3];
- float RandomMultiplier[3];
- float OtherMultiplier[3];
+ int32 CastTimeMin;
+ int32 CastTimeMax;
+ int32 CastTimeMaxLevel;
+ int32 ScalingClass;
float CoefBase;
- uint32 CoefLevelBase;
+ int32 CoefLevelBase;
SpellEffectInfo Effects[MAX_SPELL_EFFECTS];
uint32 ExplicitTargetMask;
SpellChainNode const* ChainEntry;