*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
This commit is contained in:
QAston
2010-07-14 16:57:13 +02:00
parent 6aa9ee1a2f
commit a43ec3f158
10 changed files with 142 additions and 132 deletions
@@ -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;
+4 -4
View File
@@ -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()
+13 -13
View File
@@ -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);