aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQAston <none@none>2010-07-14 16:57:13 +0200
committerQAston <none@none>2010-07-14 16:57:13 +0200
commita43ec3f158b6c0b813a2996b5369f5c2c168d483 (patch)
tree96c1d615094c08beeae266d3fab1e0b132d35ec2 /src
parent6aa9ee1a2f58ae0ad3b3ab67d90cb2170d52f33b (diff)
*Add SpellMgr::CalculateSpellEffectAmount function for consistency of effect amount calculations in core
*Remove SpellEntry::CalculateSimpleValue function and use the new cuntion instead *Remove some workarounds made because of incorrect effect amount calculations *Since now aura effect amount problems should be gone. --HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/server/game/DataStores/DBCStructure.h3
-rw-r--r--src/server/game/Entities/Player/Player.cpp6
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp71
-rw-r--r--src/server/game/Entities/Unit/Unit.h6
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp21
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp8
-rw-r--r--src/server/game/Spells/Auras/SpellEffects.cpp26
-rw-r--r--src/server/game/Spells/Spell.cpp11
-rw-r--r--src/server/game/Spells/SpellMgr.cpp97
-rw-r--r--src/server/game/Spells/SpellMgr.h25
10 files changed, 142 insertions, 132 deletions
diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h
index e6486baab66..7663aaf3dcb 100644
--- a/src/server/game/DataStores/DBCStructure.h
+++ b/src/server/game/DataStores/DBCStructure.h
@@ -1513,9 +1513,6 @@ struct SpellEntry
//uint32 spellDescriptionVariableID; // 232 3.2.0
//uint32 SpellDifficultyId; // 233 3.3.0
- // helpers
- int32 CalculateSimpleValue(uint8 eff) const { return EffectBasePoints[eff]+int32(1); }
-
private:
// prevent creating custom entries (copy data from original in fact)
SpellEntry(SpellEntry const&); // DON'T must have implementation
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 449ad32859f..0a14be4d35e 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -3431,7 +3431,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
if (!Has310Flyer(false) && pSkill->id == SKILL_MOUNTS)
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED &&
- spellInfo->CalculateSimpleValue(i) == 310)
+ SpellMgr::CalculateSpellEffectAmount(spellInfo, i) == 310)
SetHas310Flyer(true);
if (HasSkill(pSkill->id))
@@ -3705,7 +3705,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank)
SpellEntry const *pSpellInfo = sSpellStore.LookupEntry(spell_id);
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (pSpellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED &&
- pSpellInfo->CalculateSimpleValue(i) == 310)
+ SpellMgr::CalculateSpellEffectAmount(pSpellInfo, i) == 310)
Has310Flyer(true, spell_id); // with true as first argument its also used to set/remove the flag
}
}
@@ -3799,7 +3799,7 @@ bool Player::Has310Flyer(bool checkAllSpells, uint32 excludeSpellId)
pSpellInfo = sSpellStore.LookupEntry(itr->first);
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (pSpellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED &&
- pSpellInfo->CalculateSimpleValue(i) == 310)
+ SpellMgr::CalculateSpellEffectAmount(pSpellInfo, i) == 310)
{
SetHas310Flyer(true);
return true;
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 0e0b4ca2de9..4d4e0e1c135 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -3566,10 +3566,10 @@ void Unit::_AddAura(UnitAura * aura, Unit * caster)
// find current aura from spell and change it's stackamount
if (Aura * foundAura = GetOwnedAura(aura->GetId(), aura->GetCasterGUID(), 0, aura))
{
- if (aura->GetSpellProto()->StackAmount)
- {
- aura->ModStackAmount(foundAura->GetStackAmount());
-
+ if (foundAura->GetSpellProto()->StackAmount)
+ {
+ foundAura->ModStackAmount(foundAura->GetStackAmount());
+
// Update periodic timers from the previous aura
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
@@ -7815,7 +7815,7 @@ bool Unit::HandleAuraProc(Unit * pVictim, uint32 damage, Aura * triggeredByAura,
*handled = true;
if (pVictim->HasAura(53601))
{
- int32 bp0 = (damage/12) * dummySpell->CalculateSimpleValue(2)/100;
+ int32 bp0 = (damage/12) * SpellMgr::CalculateSpellEffectAmount(procSpell, 2)/100;
CastCustomSpell(pVictim, 66922, &bp0, NULL, NULL, true);
return true;
}
@@ -7860,7 +7860,7 @@ bool Unit::HandleAuraProc(Unit * pVictim, uint32 damage, Aura * triggeredByAura,
if (!spInfo)
return false;
- int32 bp0 = this->GetCreateMana() * spInfo->CalculateSimpleValue(0) / 100;
+ int32 bp0 = this->GetCreateMana() * SpellMgr::CalculateSpellEffectAmount(spInfo, 0) / 100;
this->CastCustomSpell(this, 67545, &bp0, NULL, NULL, true, NULL, triggeredByAura->GetEffect(0), this->GetGUID());
return true;
}
@@ -8247,7 +8247,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
}
// percent stored in effect 1 (class scripts) base points
int32 cost = originalSpell->manaCost + originalSpell->ManaCostPercentage * GetCreateMana() / 100;
- basepoints0 = cost*auraSpellInfo->CalculateSimpleValue(1)/100;
+ basepoints0 = cost*SpellMgr::CalculateSpellEffectAmount(auraSpellInfo, 1)/100;
trigger_spell_id = 20272;
target = this;
}
@@ -10205,7 +10205,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
case 49638:
{
if (const SpellEntry *proto=sSpellStore.LookupEntry(itr->first))
- ApCoeffMod *= (100.0f + proto->CalculateSimpleValue(0)) / 100.0f;
+ ApCoeffMod *= (100.0f + SpellMgr::CalculateSpellEffectAmount(proto, 0)) / 100.0f;
}
break;
}
@@ -12515,7 +12515,7 @@ Unit* Creature::SelectVictim()
//======================================================================
//======================================================================
-int32 Unit::ApplyEffectModifiers(SpellEntry const* spellProto, uint8 effect_index, int32 value)
+int32 Unit::ApplyEffectModifiers(SpellEntry const* spellProto, uint8 effect_index, int32 value) const
{
if (Player* modOwner = GetSpellModOwner())
{
@@ -12536,57 +12536,10 @@ int32 Unit::ApplyEffectModifiers(SpellEntry const* spellProto, uint8 effect_inde
return value;
}
-int32 Unit::CalculateSpellDamage(Unit const* /*target*/, SpellEntry const* spellProto, uint8 effect_index, int32 const* effBasePoints)
+// function uses real base points (typically value - 1)
+int32 Unit::CalculateSpellDamage(Unit const* target, SpellEntry const* spellProto, uint8 effect_index, int32 const* basePoints) const
{
- int32 level = int32(getLevel());
- if (level > int32(spellProto->maxLevel) && spellProto->maxLevel > 0)
- level = int32(spellProto->maxLevel);
- else if (level < int32(spellProto->baseLevel))
- level = int32(spellProto->baseLevel);
- level -= int32(spellProto->spellLevel);
-
- float basePointsPerLevel = spellProto->EffectRealPointsPerLevel[effect_index];
- int32 basePoints = effBasePoints ? *effBasePoints - 1 : spellProto->EffectBasePoints[effect_index];
- basePoints += int32(level * basePointsPerLevel);
- int32 randomPoints = int32(spellProto->EffectDieSides[effect_index]);
-
- 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;
- }
-
- int32 value = basePoints;
-
- // random damage
- //if (comboDamage != 0 && unitPlayer /*&& target && (target->GetGUID() == unitPlayer->GetComboTarget())*/)
- if (m_movedPlayer)
- if (uint8 comboPoints = m_movedPlayer->GetComboPoints())
- if (float comboDamage = spellProto->EffectPointsPerComboPoint[effect_index])
- value += int32(comboDamage * comboPoints);
-
- value = ApplyEffectModifiers(spellProto, effect_index, value);
-
- if (!basePointsPerLevel && (spellProto->Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION && spellProto->spellLevel) &&
- spellProto->Effect[effect_index] != SPELL_EFFECT_WEAPON_PERCENT_DAMAGE &&
- spellProto->Effect[effect_index] != SPELL_EFFECT_KNOCK_BACK &&
- spellProto->EffectApplyAuraName[effect_index] != SPELL_AURA_MOD_SPEED_ALWAYS &&
- spellProto->EffectApplyAuraName[effect_index] != SPELL_AURA_MOD_SPEED_NOT_STACK &&
- spellProto->EffectApplyAuraName[effect_index] != SPELL_AURA_MOD_INCREASE_SPEED &&
- spellProto->EffectApplyAuraName[effect_index] != SPELL_AURA_MOD_DECREASE_SPEED)
- //there are many more: slow speed, -healing pct
- value = int32(value*0.25f*exp(getLevel()*(70-spellProto->spellLevel)/1000.0f));
- //value = int32(value * (int32)getLevel() / (int32)(spellProto->spellLevel ? spellProto->spellLevel : 1));
-
- return value;
+ return SpellMgr::CalculateSpellEffectAmount(spellProto, effect_index, this, basePoints, target);
}
int32 Unit::CalcSpellDuration(SpellEntry const* spellProto)
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 87bd997a683..2051123dfb5 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1529,7 +1529,7 @@ class Unit : public WorldObject
void DeleteCharmInfo();
void UpdateCharmAI();
//Player * GetMoverSource() const;
- Player *m_movedPlayer;
+ Player * m_movedPlayer;
SharedVisionList const& GetSharedVisionList() { return m_sharedVision; }
void AddPlayerToVision(Player* plr);
void RemovePlayerFromVision(Player* plr);
@@ -1846,8 +1846,8 @@ class Unit : public WorldObject
void SetHover(bool on);
bool isHover() const { return HasAuraType(SPELL_AURA_HOVER); }
- int32 ApplyEffectModifiers(SpellEntry const* spellProto, uint8 effect_index, int32 value);
- int32 CalculateSpellDamage(Unit const* target, SpellEntry const* spellProto, uint8 effect_index, int32 const* basePoints = NULL);
+ int32 ApplyEffectModifiers(SpellEntry const* spellProto, uint8 effect_index, int32 value) const;
+ int32 CalculateSpellDamage(Unit const* target, SpellEntry const* spellProto, uint8 effect_index, int32 const* basePoints = NULL) const;
int32 CalcSpellDuration(SpellEntry const* spellProto);
int32 ModSpellDuration(SpellEntry const* spellProto, Unit const* target, int32 duration, bool positive);
void ModSpellCastTime(SpellEntry const* spellProto, int32 & castTime, Spell * spell=NULL);
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 91bfa9a36fa..3835e4703a7 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -376,7 +376,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]=
AuraEffect::AuraEffect(Aura * base, uint8 effIndex, int32 *baseAmount, Unit * caster) :
m_base(base), m_spellProto(base->GetSpellProto()), m_spellmod(NULL), m_periodicTimer(0),
m_tickNumber(0), m_effIndex(effIndex), m_isPeriodic(false), m_canBeRecalculated(true),
- m_baseAmount (baseAmount ? *baseAmount : m_spellProto->EffectBasePoints[m_effIndex] + 1)
+ m_baseAmount (baseAmount ? *baseAmount : m_spellProto->EffectBasePoints[m_effIndex])
{
CalculatePeriodic(caster, true);
@@ -405,10 +405,7 @@ int32 AuraEffect::CalculateAmount(Unit * caster)
{
int32 amount;
// default amount calculation
- if (caster)
- amount = caster->CalculateSpellDamage(NULL, m_spellProto, m_effIndex, &m_baseAmount);
- else
- amount = m_baseAmount + 1;
+ amount = SpellMgr::CalculateSpellEffectAmount(m_spellProto, m_effIndex, caster, &m_baseAmount, NULL);
// check item enchant aura cast
if (!amount && caster)
@@ -622,7 +619,7 @@ int32 AuraEffect::CalculateAmount(Unit * caster)
if (spellmgr.GetSpellRank(m_spellProto->Id) >= 9)
{
if (GetBase()->GetUnitOwner()->HasAuraState(AURA_STATE_HEALTH_ABOVE_75_PERCENT, m_spellProto, caster))
- amount += int32(amount * m_spellProto->CalculateSimpleValue(2) / 100.0f);
+ amount += int32(amount * SpellMgr::CalculateSpellEffectAmount(m_spellProto, 2, caster) / 100.0f);
}
}
break;
@@ -2512,7 +2509,7 @@ void AuraEffect::HandleShapeshiftBoosts(Unit * target, bool apply) const
// Heart of the Wild
if ((*i)->GetSpellProto()->SpellIconID == 240 && (*i)->GetMiscValue() == 3)
{
- int32 HotWMod = (*i)->GetSpellProto()->EffectBasePoints[1]+1+1; // +1 for base points and +1 for SetSpellValue (where 1 is substracted)
+ int32 HotWMod = (*i)->GetAmount();
target->CastCustomSpell(target, HotWSpellId, &HotWMod, NULL, NULL, true, NULL, this);
break;
@@ -2543,7 +2540,7 @@ void AuraEffect::HandleShapeshiftBoosts(Unit * target, bool apply) const
// Master Shapeshifter - Cat
if (AuraEffect const * aurEff = target->GetDummyAuraEffect(SPELLFAMILY_GENERIC, 2851, 0))
{
- int32 bp = aurEff->GetAmount()+1;
+ int32 bp = aurEff->GetAmount();
target->CastCustomSpell(target, 48420, &bp, NULL, NULL, true);
}
break;
@@ -2552,13 +2549,13 @@ void AuraEffect::HandleShapeshiftBoosts(Unit * target, bool apply) const
// Master Shapeshifter - Bear
if (AuraEffect const * aurEff = target->GetDummyAuraEffect(SPELLFAMILY_GENERIC, 2851, 0))
{
- int32 bp = aurEff->GetAmount()+1;
+ int32 bp = aurEff->GetAmount();
target->CastCustomSpell(target, 48418, &bp, NULL, NULL, true);
}
// Survival of the Fittest
if (AuraEffect const * aurEff = target->GetAuraEffect(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, SPELLFAMILY_DRUID, 961, 0))
{
- int32 bp = 100 + aurEff->GetSpellProto()->CalculateSimpleValue(2);
+ int32 bp = 100 + SpellMgr::CalculateSpellEffectAmount(aurEff->GetSpellProto(), 2);
target->CastCustomSpell(target, 62069, &bp, NULL, NULL, true, 0, this);
}
break;
@@ -2566,7 +2563,7 @@ void AuraEffect::HandleShapeshiftBoosts(Unit * target, bool apply) const
// Master Shapeshifter - Moonkin
if (AuraEffect const * aurEff = target->GetDummyAuraEffect(SPELLFAMILY_GENERIC, 2851, 0))
{
- int32 bp = aurEff->GetAmount()+1;
+ int32 bp = aurEff->GetAmount();
target->CastCustomSpell(target, 48421, &bp, NULL, NULL, true);
}
break;
@@ -2574,7 +2571,7 @@ void AuraEffect::HandleShapeshiftBoosts(Unit * target, bool apply) const
case FORM_TREE:
if (AuraEffect const * aurEff = target->GetDummyAuraEffect(SPELLFAMILY_GENERIC, 2851, 0))
{
- int32 bp = aurEff->GetAmount()+1;
+ int32 bp = aurEff->GetAmount();
target->CastCustomSpell(target, 48422, &bp, NULL, NULL, true);
}
break;
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index a96471ef0e4..c8672780c13 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -469,7 +469,7 @@ void Aura::UpdateTargetMap(Unit * caster, bool apply)
bool addUnit = true;
// check target immunities
if (itr->first->IsImmunedToSpell(GetSpellProto())
- // check area target requirements
+ // check area target requirements
|| (itr->first != GetOwner() && !CheckAreaTarget(itr->first)))
addUnit = false;
@@ -1497,8 +1497,8 @@ void Aura::HandleAuraSpecificMods(AuraApplication const * aurApp, Unit * caster,
bool Aura::CheckAreaTarget(Unit *target)
{
- // for owner check use Spell::CheckTarget
- assert(GetOwner() != target);
+ // for owner check use Spell::CheckTarget
+ assert(GetOwner() != target);
// some special cases
switch(GetId())
@@ -1532,7 +1532,7 @@ bool Aura::CheckAreaTarget(Unit *target)
}
break;
}
- return true;
+ return true;
}
void Aura::_DeleteRemovedApplications()
diff --git a/src/server/game/Spells/Auras/SpellEffects.cpp b/src/server/game/Spells/Auras/SpellEffects.cpp
index 3f01d8bca2d..88e1ac72928 100644
--- a/src/server/game/Spells/Auras/SpellEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellEffects.cpp
@@ -303,7 +303,7 @@ void Spell::EffectEnvirinmentalDMG(uint32 i)
// 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 = m_spellInfo->CalculateSimpleValue(i);
+ damage = SpellMgr::CalculateSpellEffectAmount(m_spellInfo, i, m_caster);
m_caster->CalcAbsorbResist(m_caster, GetSpellSchoolMask(m_spellInfo), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist, m_spellInfo);
@@ -583,7 +583,7 @@ void Spell::SpellDamageSchoolDmg(uint32 effect_idx)
if ((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_PRIEST &&
((*i)->GetSpellProto()->SpellIconID == 95))
{
- int chance = (*i)->GetSpellProto()->CalculateSimpleValue(1);
+ int chance = SpellMgr::CalculateSpellEffectAmount((*i)->GetSpellProto(), 1, m_caster);
if (roll_chance_i(chance))
// Mind Trauma
m_caster->CastSpell(unitTarget, 48301, true, 0);
@@ -638,7 +638,7 @@ void Spell::SpellDamageSchoolDmg(uint32 effect_idx)
{
if ((*iter)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_ROGUE && (*iter)->GetSpellProto()->SpellIconID == 1960)
{
- uint32 chance = (*iter)->GetSpellProto()->CalculateSimpleValue(2);
+ uint32 chance = SpellMgr::CalculateSpellEffectAmount((*iter)->GetSpellProto(), 2, m_caster);
if (chance && roll_chance_i(chance))
needConsume = false;
@@ -1408,8 +1408,8 @@ void Spell::EffectDummy(uint32 i)
{
case 0:
{
- uint32 spellID = m_spellInfo->CalculateSimpleValue(0);
- uint32 reqAuraID = m_spellInfo->CalculateSimpleValue(1);
+ uint32 spellID = SpellMgr::CalculateSpellEffectAmount(m_spellInfo, 0);
+ uint32 reqAuraID = SpellMgr::CalculateSpellEffectAmount(m_spellInfo, 1);
if (m_caster->HasAuraEffect(reqAuraID,0))
m_caster->CastSpell(m_caster,spellID,true,NULL);
@@ -1840,7 +1840,7 @@ void Spell::EffectDummy(uint32 i)
if (Pet *pPet = m_caster->ToPlayer()->GetPet())
if (pPet->isAlive())
- pPet->CastSpell(unitTarget, m_spellInfo->CalculateSimpleValue(i), true);
+ pPet->CastSpell(unitTarget, SpellMgr::CalculateSpellEffectAmount(m_spellInfo, i), true);
return;
}
}
@@ -2140,7 +2140,7 @@ void Spell::EffectDummy(uint32 i)
{
bp = damage;
}
- m_caster->CastCustomSpell(unitTarget,m_spellInfo->CalculateSimpleValue(1),&bp,NULL,NULL,true);
+ m_caster->CastCustomSpell(unitTarget, SpellMgr::CalculateSpellEffectAmount(m_spellInfo, 1), &bp,NULL,NULL,true);
// Corpse Explosion (Suicide)
unitTarget->CastCustomSpell(unitTarget,43999,&bp,NULL,NULL,true);
// Set corpse look
@@ -3753,7 +3753,7 @@ void Spell::EffectSummonType(uint32 i)
if (m_spellInfo->EffectBasePoints[i])
{
- SpellEntry const *spellProto = sSpellStore.LookupEntry(m_spellInfo->CalculateSimpleValue(i));
+ SpellEntry const *spellProto = sSpellStore.LookupEntry(SpellMgr::CalculateSpellEffectAmount(m_spellInfo, i));
if (spellProto)
m_caster->CastSpell(summon, spellProto, true);
}
@@ -3905,7 +3905,7 @@ void Spell::EffectDispel(uint32 i)
// Devour Magic
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellInfo->Category == SPELLCATEGORY_DEVOUR_MAGIC)
{
- int32 heal_amount = m_spellInfo->CalculateSimpleValue(1);
+ int32 heal_amount = SpellMgr::CalculateSpellEffectAmount(m_spellInfo, 1);
m_caster->CastCustomSpell(m_caster, 19658, &heal_amount, NULL, NULL, true);
}
}
@@ -4018,7 +4018,7 @@ void Spell::EffectLearnSkill(uint32 i)
uint32 skillid = m_spellInfo->EffectMiscValue[i];
uint16 skillval = unitTarget->ToPlayer()->GetPureSkillValue(skillid);
- unitTarget->ToPlayer()->SetSkill(skillid, m_spellInfo->CalculateSimpleValue(i), skillval?skillval:1, damage*75);
+ unitTarget->ToPlayer()->SetSkill(skillid, SpellMgr::CalculateSpellEffectAmount(m_spellInfo, i), skillval?skillval:1, damage*75);
}
void Spell::EffectAddHonor(uint32 /*i*/)
@@ -5035,7 +5035,7 @@ void Spell::EffectScriptEffect(uint32 effIndex)
case 55693: // Remove Collapsing Cave Aura
if (!unitTarget)
return;
- unitTarget->RemoveAurasDueToSpell(m_spellInfo->CalculateSimpleValue(effIndex));
+ unitTarget->RemoveAurasDueToSpell(SpellMgr::CalculateSpellEffectAmount(m_spellInfo, effIndex));
break;
// PX-238 Winter Wondervolt TRAP
case 26275:
@@ -5578,8 +5578,8 @@ void Spell::EffectScriptEffect(uint32 effIndex)
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || effIndex != 0)
return;
- uint32 spellID = m_spellInfo->CalculateSimpleValue(0);
- uint32 questID = m_spellInfo->CalculateSimpleValue(1);
+ uint32 spellID = SpellMgr::CalculateSpellEffectAmount(m_spellInfo, 0);
+ uint32 questID = SpellMgr::CalculateSpellEffectAmount(m_spellInfo, 1);
if (unitTarget->ToPlayer()->GetQuestStatus(questID) == QUEST_STATUS_COMPLETE && !unitTarget->ToPlayer()->GetQuestRewardStatus (questID))
unitTarget->CastSpell(unitTarget, spellID, true);
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index c3b0fdb1405..c371d518a04 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -399,13 +399,12 @@ Spell::Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 origin
}
for (int i=0; i <3; ++i)
- m_currentBasePoints[i] = m_spellInfo->CalculateSimpleValue(i);
+ m_currentBasePoints[i] = m_spellInfo->EffectBasePoints[i];
m_spellState = SPELL_STATE_NULL;
m_TriggerSpells.clear();
m_IsTriggeredSpell = triggered;
- //m_AreaAura = false;
m_CastItem = NULL;
unitTarget = NULL;
@@ -5997,7 +5996,7 @@ SpellCastResult Spell::CheckItems()
else if (!(p_caster->HasItemCount(m_spellInfo->EffectItemType[i],1)))
return SPELL_FAILED_TOO_MANY_OF_ITEM;
else
- p_caster->CastSpell(m_caster,m_spellInfo->CalculateSimpleValue(1),false); // move this to anywhere
+ p_caster->CastSpell(m_caster,SpellMgr::CalculateSpellEffectAmount(m_spellInfo, 1),false); // move this to anywhere
return SPELL_FAILED_DONT_REPORT;
}
}
@@ -6883,15 +6882,15 @@ void Spell::SetSpellValue(SpellValueMod mod, int32 value)
switch(mod)
{
case SPELLVALUE_BASE_POINT0:
- m_spellValue->EffectBasePoints[0] = value - int32(1);
+ m_spellValue->EffectBasePoints[0] = SpellMgr::CalculateSpellEffectBaseAmount(value);
m_currentBasePoints[0] = m_spellValue->EffectBasePoints[0]; //this should be removed in the future
break;
case SPELLVALUE_BASE_POINT1:
- m_spellValue->EffectBasePoints[1] = value - int32(1);
+ m_spellValue->EffectBasePoints[1] = SpellMgr::CalculateSpellEffectBaseAmount(value);
m_currentBasePoints[1] = m_spellValue->EffectBasePoints[1];
break;
case SPELLVALUE_BASE_POINT2:
- m_spellValue->EffectBasePoints[2] = value - int32(1);
+ m_spellValue->EffectBasePoints[2] = SpellMgr::CalculateSpellEffectBaseAmount(value);
m_currentBasePoints[2] = m_spellValue->EffectBasePoints[2];
break;
case SPELLVALUE_RADIUS_MOD:
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index 7fd3650d6f4..5ebb927eb80 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -838,16 +838,16 @@ bool SpellMgr::_isPositiveEffect(uint32 spellId, uint32 effIndex, bool deep) con
case SPELL_AURA_MOD_HEALING_PCT:
case SPELL_AURA_MOD_HEALING_DONE:
case SPELL_AURA_MOD_DAMAGE_PERCENT_DONE:
- if (spellproto->CalculateSimpleValue(effIndex) < 0)
+ if (SpellMgr::CalculateSpellEffectAmount(spellproto, effIndex) < 0)
return false;
break;
case SPELL_AURA_MOD_DAMAGE_TAKEN: // dependent from bas point sign (positive -> negative)
- if (spellproto->CalculateSimpleValue(effIndex) > 0)
+ if (SpellMgr::CalculateSpellEffectAmount(spellproto, effIndex) > 0)
return false;
break;
case SPELL_AURA_MOD_CRIT_PCT:
case SPELL_AURA_MOD_SPELL_CRIT_CHANCE:
- if (spellproto->CalculateSimpleValue(effIndex) > 0)
+ if (SpellMgr::CalculateSpellEffectAmount(spellproto, effIndex) > 0)
return true; // some expected positive spells have SPELL_ATTR_EX_NEGATIVE
break;
case SPELL_AURA_ADD_TARGET_TRIGGER:
@@ -925,7 +925,7 @@ bool SpellMgr::_isPositiveEffect(uint32 spellId, uint32 effIndex, bool deep) con
switch(spellproto->EffectMiscValue[effIndex])
{
case SPELLMOD_COST: // dependent from bas point sign (negative -> positive)
- if (spellproto->CalculateSimpleValue(effIndex) > 0)
+ if (SpellMgr::CalculateSpellEffectAmount(spellproto, effIndex) > 0)
{
if (!deep)
{
@@ -1810,6 +1810,80 @@ bool SpellMgr::IsSkillBonusSpell(uint32 spellId) const
return false;
}
+bool SpellMgr::IsSkillTypeSpell(uint32 spellId, SkillType type) const
+{
+ SkillLineAbilityMapBounds bounds = GetSkillLineAbilityMapBounds(spellId);
+
+ for (SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx)
+ if (_spell_idx->second->skillId == uint32(type))
+ return true;
+
+ return false;
+}
+
+// basepoints provided here have to be valid basepoints (use SpellMgr::CalculateSpellEffectBaseAmount)
+int32 SpellMgr::CalculateSpellEffectAmount(SpellEntry const * spellEntry, uint8 effIndex, Unit const * caster, int32 const * effBasePoints, Unit const * target)
+{
+ float basePointsPerLevel = spellEntry->EffectRealPointsPerLevel[effIndex];
+ int32 basePoints = effBasePoints ? *effBasePoints : spellEntry->EffectBasePoints[effIndex];
+ int32 randomPoints = int32(spellEntry->EffectDieSides[effIndex]);
+
+ // base amount modification based on spell lvl vs caster lvl
+ if (caster)
+ {
+ int32 level = int32(caster->getLevel());
+ if (level > int32(spellEntry->maxLevel) && spellEntry->maxLevel > 0)
+ level = int32(spellEntry->maxLevel);
+ else if (level < int32(spellEntry->baseLevel))
+ level = int32(spellEntry->baseLevel);
+ level -= int32(spellEntry->spellLevel);
+ basePoints += int32(level * basePointsPerLevel);
+ }
+
+ // roll in a range <1;EffectDieSides> as of patch 3.3.3
+ 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;
+ }
+
+ int32 value = basePoints;
+
+ // random damage
+ if (caster)
+ {
+ // bonus amount from combo points
+ if (caster->m_movedPlayer)
+ if (uint8 comboPoints = caster->m_movedPlayer->GetComboPoints())
+ if (float comboDamage = spellEntry->EffectPointsPerComboPoint[effIndex])
+ value += int32(comboDamage * comboPoints);
+
+ value = caster->ApplyEffectModifiers(spellEntry, effIndex, value);
+
+ // amount multiplication based on caster's level
+ if (!basePointsPerLevel && (spellEntry->Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION && spellEntry->spellLevel) &&
+ spellEntry->Effect[effIndex] != SPELL_EFFECT_WEAPON_PERCENT_DAMAGE &&
+ spellEntry->Effect[effIndex] != SPELL_EFFECT_KNOCK_BACK &&
+ spellEntry->EffectApplyAuraName[effIndex] != SPELL_AURA_MOD_SPEED_ALWAYS &&
+ spellEntry->EffectApplyAuraName[effIndex] != SPELL_AURA_MOD_SPEED_NOT_STACK &&
+ spellEntry->EffectApplyAuraName[effIndex] != SPELL_AURA_MOD_INCREASE_SPEED &&
+ spellEntry->EffectApplyAuraName[effIndex] != SPELL_AURA_MOD_DECREASE_SPEED)
+ //there are many more: slow speed, -healing pct
+ value = int32(value*0.25f*exp(caster->getLevel()*(70-spellEntry->spellLevel)/1000.0f));
+ //value = int32(value * (int32)getLevel() / (int32)(spellProto->spellLevel ? spellProto->spellLevel : 1));
+ }
+
+ return value;
+}
+
SpellEntry const* SpellMgr::SelectAuraRankForPlayerLevel(SpellEntry const* spellInfo, uint32 playerLevel) const
{
// ignore passive spells
@@ -1872,7 +1946,7 @@ void SpellMgr::LoadSpellLearnSkills()
{
SpellLearnSkillNode dbc_node;
dbc_node.skill = entry->EffectMiscValue[i];
- dbc_node.step = entry->CalculateSimpleValue(i);
+ dbc_node.step = SpellMgr::CalculateSpellEffectAmount(entry, i);
if (dbc_node.skill != SKILL_RIDING)
dbc_node.value = 1;
else
@@ -2059,7 +2133,7 @@ void SpellMgr::LoadSpellPetAuras()
continue;
}
- PetAura pa(pet, aura, spellInfo->EffectImplicitTargetA[eff] == TARGET_UNIT_PET, spellInfo->CalculateSimpleValue(eff));
+ PetAura pa(pet, aura, spellInfo->EffectImplicitTargetA[eff] == TARGET_UNIT_PET, SpellMgr::CalculateSpellEffectAmount(spellInfo, eff));
mSpellPetAuraMap[(spell<<8) + eff] = pa;
}
@@ -3840,17 +3914,6 @@ void SpellMgr::LoadEnchantCustomAttr()
sLog.outString(">> Loaded %u custom enchant attributes", count);
}
-bool SpellMgr::IsSkillTypeSpell(uint32 spellId, SkillType type) const
-{
- SkillLineAbilityMapBounds bounds = GetSkillLineAbilityMapBounds(spellId);
-
- for (SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx)
- if (_spell_idx->second->skillId == uint32(type))
- return true;
-
- return false;
-}
-
void SpellMgr::LoadSpellLinked()
{
mSpellLinkedMap.clear(); // need for reload case
diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h
index bb76dd92880..872a19a27f1 100644
--- a/src/server/game/Spells/SpellMgr.h
+++ b/src/server/game/Spells/SpellMgr.h
@@ -1212,6 +1212,8 @@ class SpellMgr
bool IsSkillBonusSpell(uint32 spellId) const;
bool IsSkillTypeSpell(uint32 spellId, SkillType type) const;
+ static int32 CalculateSpellEffectAmount(SpellEntry const * spellEntry, uint8 effIndex, Unit const * caster = NULL, int32 const * basePoints = NULL, Unit const * target = NULL);
+ static int32 CalculateSpellEffectBaseAmount(int32 value) {return value-1;};
// Spell correctess for client using
static bool IsSpellValid(SpellEntry const * spellInfo, Player* pl = NULL, bool msg = true);
@@ -1322,21 +1324,20 @@ class SpellMgr
}
void SetSpellDifficultyId(uint32 spellId, uint32 id) { mSpellDifficultySearcherMap[spellId] = id; }
- const SpellsRequiringSpellMap GetSpellsRequiringSpell()
- {
- return this->mSpellsReqSpell;
- }
-
- uint32 GetSpellRequired(uint32 spell_id) const
- {
- SpellRequiredMap::const_iterator itr = mSpellReq.find(spell_id);
+ const SpellsRequiringSpellMap GetSpellsRequiringSpell()
+ {
+ return this->mSpellsReqSpell;
+ }
- if (itr == mSpellReq.end())
- return NULL;
+ uint32 GetSpellRequired(uint32 spell_id) const
+ {
+ SpellRequiredMap::const_iterator itr = mSpellReq.find(spell_id);
- return itr->second;
- }
+ if (itr == mSpellReq.end())
+ return NULL;
+ return itr->second;
+ }
// Modifiers
public: