Core/Spells: Implemented spell level scaling

This commit is contained in:
Shauren
2012-08-17 00:10:19 +02:00
parent 69c74bb3c5
commit f447403f6c
6 changed files with 82 additions and 38 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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());

View File

@@ -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);
}
basePoints = int32(preciseBasePoints);
}
}
}
// roll in a range <1;EffectDieSides> as of patch 3.3.3
switch (randomPoints)
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
{
// not all spells have cast time index and this is all is pasiive abilities
if (!CastTimeEntry)
return 0;
int32 castTime = 0;
int32 castTime = CastTimeEntry->CastTime;
// not all spells have cast time index and this is all is pasiive abilities
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;
if (!castTime)
return 0;
if (caster)
caster->ModSpellCastTime(this, castTime, spell);

View File

@@ -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);