Skip to content

Commit

Permalink
[9701] Fix basepoints calculation
Browse files Browse the repository at this point in the history
Signed-off-by: Laise <fenrisse@gmail.com>
  • Loading branch information
VladimirMangos authored and Laise committed Apr 8, 2010
1 parent dd10774 commit 27825a9
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/game/DBCStores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,11 @@ void LoadDBCStores(const std::string& dataPath)
// Check loaded DBC files proper version
if( !sAreaStore.LookupEntry(3617) || // last area (areaflag) added in 3.3.3a
!sCharTitlesStore.LookupEntry(177) || // last char title added in 3.3.3a
!sGemPropertiesStore.LookupEntry(1629) || // last added spell in 3.3.3a
!sItemStore.LookupEntry(54860) || // last gem property added in 3.3.3a
!sGemPropertiesStore.LookupEntry(1629) || // last gem property added in 3.3.3a
!sItemStore.LookupEntry(54860) || // last client known item added in 3.3.3a
!sItemExtendedCostStore.LookupEntry(2997) || // last item extended cost added in 3.3.3a
!sMapStore.LookupEntry(724) || // last map added in 3.3.3a
!sSpellStore.LookupEntry(76567) ) // last client known item added in 3.3.3a
!sSpellStore.LookupEntry(76567) ) // last added spell in 3.3.3a
{
sLog.outError("\nYou have mixed version DBC files. Please re-extract DBC files for one from client build: %s",AcceptableClientBuildsListStr().c_str());
exit(1);
Expand Down
3 changes: 2 additions & 1 deletion src/game/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3023,7 +3023,8 @@ void Spell::finish(bool ok)
SpellEntry const *auraSpellInfo = (*i)->GetSpellProto();
SpellEffectIndex auraSpellIdx = (*i)->GetEffIndex();
// Calculate chance at that moment (can be depend for example from combo points)
int32 chance = m_caster->CalculateSpellDamage(auraSpellInfo, auraSpellIdx, (*i)->GetBasePoints(),unit);
int32 auraBasePoints = (*i)->GetBasePoints();
int32 chance = m_caster->CalculateSpellDamage(unit, auraSpellInfo, auraSpellIdx, &auraBasePoints);
if(roll_chance_i(chance))
m_caster->CastSpell(unit, auraSpellInfo->EffectTriggerSpell[auraSpellIdx], true, NULL, (*i));
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/Spell.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class Spell
SpellCastResult CheckOrTakeRunePower(bool take);
SpellCastResult CheckCasterAuras() const;

int32 CalculateDamage(SpellEffectIndex i, Unit* target) { return m_caster->CalculateSpellDamage(m_spellInfo,i,m_currentBasePoints[i],target); }
int32 CalculateDamage(SpellEffectIndex i, Unit* target) { return m_caster->CalculateSpellDamage(target, m_spellInfo, i, &m_currentBasePoints[i]); }
int32 CalculatePowerCost();

bool HaveTargetsForEffect(SpellEffectIndex effect) const;
Expand Down
12 changes: 6 additions & 6 deletions src/game/SpellAuras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ m_isRemovedOnShapeLost(true), m_in_use(0), m_deleted(false)
{
m_caster_guid = caster->GetGUID();

damage = caster->CalculateSpellDamage(m_spellProto,m_effIndex,m_currentBasePoints,target);
damage = caster->CalculateSpellDamage(target, m_spellProto, m_effIndex, &m_currentBasePoints);
m_maxduration = caster->CalculateSpellDuration(m_spellProto, m_effIndex, target);

if (!damage && castItem && castItem->GetItemSuffixFactor())
Expand Down Expand Up @@ -1272,7 +1272,7 @@ void Aura::SetStackAmount(uint8 stackAmount)
if (stackAmount != m_stackAmount)
{
m_stackAmount = stackAmount;
int32 amount = m_stackAmount * caster->CalculateSpellDamage(m_spellProto, m_effIndex, m_currentBasePoints, target);
int32 amount = m_stackAmount * caster->CalculateSpellDamage(target, m_spellProto, m_effIndex, &m_currentBasePoints);
// Reapply if amount change
if (amount!=m_modifier.m_amount)
{
Expand Down Expand Up @@ -3215,7 +3215,7 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real)
if(itr->second.state == PLAYERSPELL_REMOVED) continue;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
if (spellInfo && spellInfo->SpellFamilyName == SPELLFAMILY_WARRIOR && spellInfo->SpellIconID == 139)
Rage_val += m_target->CalculateSpellDamage(spellInfo, EFFECT_INDEX_0, spellInfo->EffectBasePoints[EFFECT_INDEX_0], m_target) * 10;
Rage_val += m_target->CalculateSpellDamage(m_target, spellInfo, EFFECT_INDEX_0) * 10;
}
}

Expand Down Expand Up @@ -6999,7 +6999,7 @@ void Aura::PeriodicTick()
{
uint32 percent =
GetEffIndex() < EFFECT_INDEX_2 && GetSpellProto()->Effect[GetEffIndex()] == SPELL_EFFECT_DUMMY ?
pCaster->CalculateSpellDamage(GetSpellProto(), SpellEffectIndex(GetEffIndex() + 1), GetSpellProto()->EffectBasePoints[GetEffIndex() + 1], m_target) :
pCaster->CalculateSpellDamage(m_target, GetSpellProto(), SpellEffectIndex(GetEffIndex() + 1)) :
100;
if(m_target->GetHealth() * 100 >= m_target->GetMaxHealth() * percent )
{
Expand Down Expand Up @@ -7841,7 +7841,7 @@ void Aura::PeriodicDummyTick()
if (rage == 0)
return;
int32 mod = (rage < 100) ? rage : 100;
int32 points = m_target->CalculateSpellDamage(spell, EFFECT_INDEX_1, spell->EffectBasePoints[EFFECT_INDEX_1], m_target);
int32 points = m_target->CalculateSpellDamage(m_target, spell, EFFECT_INDEX_1);
int32 regen = m_target->GetMaxHealth() * (mod * points / 10) / 1000;
m_target->CastCustomSpell(m_target, 22845, &regen, NULL, NULL, true, NULL, this);
m_target->SetPower(POWER_RAGE, rage-mod);
Expand Down Expand Up @@ -7977,7 +7977,7 @@ void Aura::PeriodicDummyTick()
{
// Increases your attack power by $s1 for every $s2 armor value you have.
// Calculate AP bonus (from 1 efect of this spell)
int32 apBonus = m_modifier.m_amount * m_target->GetArmor() / m_target->CalculateSpellDamage(spell, EFFECT_INDEX_1, spell->EffectBasePoints[EFFECT_INDEX_1], m_target);
int32 apBonus = m_modifier.m_amount * m_target->GetArmor() / m_target->CalculateSpellDamage(m_target, spell, EFFECT_INDEX_1);
m_target->CastCustomSpell(m_target, 61217, &apBonus, &apBonus, NULL, true, NULL, this);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/game/SpellEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx)
// Shockwave ${$m3/100*$AP}
else if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000800000000000))
{
int32 pct = m_caster->CalculateSpellDamage(m_spellInfo, EFFECT_INDEX_2, m_spellInfo->EffectBasePoints[EFFECT_INDEX_2], unitTarget);
int32 pct = m_caster->CalculateSpellDamage(unitTarget, m_spellInfo, EFFECT_INDEX_2);
if (pct > 0)
damage+= int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * pct / 100);
break;
Expand Down Expand Up @@ -736,7 +736,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx)
{
// Add main hand dps * effect[2] amount
float average = (m_caster->GetFloatValue(UNIT_FIELD_MINDAMAGE) + m_caster->GetFloatValue(UNIT_FIELD_MAXDAMAGE)) / 2;
int32 count = m_caster->CalculateSpellDamage(m_spellInfo, EFFECT_INDEX_2, m_spellInfo->EffectBasePoints[EFFECT_INDEX_2], unitTarget);
int32 count = m_caster->CalculateSpellDamage(unitTarget, m_spellInfo, EFFECT_INDEX_2);
damage += count * int32(average * IN_MILLISECONDS) / m_caster->GetAttackTime(BASE_ATTACK);
}
// Shield of Righteousness
Expand Down
9 changes: 5 additions & 4 deletions src/game/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6645,7 +6645,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu
return false;
}

int32 extra_attack_power = CalculateSpellDamage(windfurySpellEntry, EFFECT_INDEX_1, windfurySpellEntry->EffectBasePoints[EFFECT_INDEX_1], pVictim);
int32 extra_attack_power = CalculateSpellDamage(pVictim, windfurySpellEntry, EFFECT_INDEX_1);

// Off-Hand case
if (castItem->GetSlot() == EQUIPMENT_SLOT_OFFHAND)
Expand Down Expand Up @@ -8925,7 +8925,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
// effect 1 m_amount
int32 maxPercent = (*i)->GetModifier()->m_amount;
// effect 0 m_amount
int32 stepPercent = CalculateSpellDamage((*i)->GetSpellProto(), EFFECT_INDEX_0, (*i)->GetSpellProto()->EffectBasePoints[EFFECT_INDEX_0], this);
int32 stepPercent = CalculateSpellDamage(this, (*i)->GetSpellProto(), EFFECT_INDEX_0);
// count affliction effects and calc additional damage in percentage
int32 modPercent = 0;
AuraMap const& victimAuras = pVictim->GetAuras();
Expand Down Expand Up @@ -11291,7 +11291,7 @@ bool Unit::SelectHostileTarget()
//======================================================================
//======================================================================

int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, SpellEffectIndex effect_index, int32 effBasePoints, Unit const* target)
int32 Unit::CalculateSpellDamage(Unit const* target, SpellEntry const* spellProto, SpellEffectIndex effect_index, int32 const* effBasePoints)
{
Player* unitPlayer = (GetTypeId() == TYPEID_PLAYER) ? (Player*)this : NULL;

Expand All @@ -11305,7 +11305,8 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, SpellEffectIndex
level-= (int32)spellProto->spellLevel;

float basePointsPerLevel = spellProto->EffectRealPointsPerLevel[effect_index];
int32 basePoints = int32(effBasePoints + level * basePointsPerLevel);
int32 basePoints = effBasePoints ? *effBasePoints - 1 : spellProto->EffectBasePoints[effect_index];
basePoints += int32(level * basePointsPerLevel);
int32 randomPoints = int32(spellProto->EffectDieSides[effect_index]);
float comboDamage = spellProto->EffectPointsPerComboPoint[effect_index];

Expand Down
2 changes: 1 addition & 1 deletion src/game/Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -1757,7 +1757,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
void _RemoveAllAuraMods();
void _ApplyAllAuraMods();

int32 CalculateSpellDamage(SpellEntry const* spellProto, SpellEffectIndex effect_index, int32 basePoints, Unit const* target);
int32 CalculateSpellDamage(Unit const* target, SpellEntry const* spellProto, SpellEffectIndex effect_index, int32 const* basePoints = NULL);

uint32 CalcNotIgnoreAbsorbDamage( uint32 damage, SpellSchoolMask damageSchoolMask, SpellEntry const* spellInfo = NULL);
uint32 CalcNotIgnoreDamageRedunction( uint32 damage, SpellSchoolMask damageSchoolMask);
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9700"
#define REVISION_NR "9701"
#endif // __REVISION_NR_H__

1 comment on commit 27825a9

@VladimirMangos
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must be fixed in [9709]. Maybe this is last case in spell effect value claculation as result removing in 3.3.3 some spell.dbc fields.

Please sign in to comment.