From 4c3d2805bd2bcea7b8e3ef60be97c231e2e1731e Mon Sep 17 00:00:00 2001 From: Laise Date: Sun, 9 May 2010 20:30:32 +0300 Subject: [PATCH] [9854] Fix negative amounts for spell base damage/healing and fix heal effects to correctly benefit from heal increasing/reducing auras --- sql/mangos.sql | 2 +- .../9854_01_mangos_spell_bonus_data.sql | 2 + sql/updates/Makefile.am | 2 + src/game/SpellAuras.cpp | 10 ++-- src/game/SpellEffects.cpp | 52 ++++++++++--------- src/game/Unit.cpp | 7 +-- src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 8 files changed, 45 insertions(+), 34 deletions(-) create mode 100644 sql/updates/9854_01_mangos_spell_bonus_data.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index d695c6bdf..a0879664c 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -24,7 +24,7 @@ CREATE TABLE `db_version` ( `version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL, `cache_id` int(10) default '0', - `required_9826_01_mangos_spell_script_target` bit(1) default NULL + `required_9854_01_mangos_spell_bonus_data` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- diff --git a/sql/updates/9854_01_mangos_spell_bonus_data.sql b/sql/updates/9854_01_mangos_spell_bonus_data.sql new file mode 100644 index 000000000..fc5786a9b --- /dev/null +++ b/sql/updates/9854_01_mangos_spell_bonus_data.sql @@ -0,0 +1,2 @@ +ALTER TABLE db_version CHANGE COLUMN required_9826_01_mangos_spell_script_target required_9854_01_mangos_spell_bonus_data bit; + diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index 3ad678e55..6da2e96e3 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -57,6 +57,7 @@ pkgdata_DATA = \ 9803_01_mangos_spell_bonus_data.sql \ 9826_01_mangos_spell_script_target.sql \ 9849_01_characters_saved_variables.sql \ + 9854_01_mangos_spell_bonus_data.sql \ README ## Additional files to include when running 'make dist' @@ -94,4 +95,5 @@ EXTRA_DIST = \ 9803_01_mangos_spell_bonus_data.sql \ 9826_01_mangos_spell_script_target.sql \ 9849_01_characters_saved_variables.sql \ + 9854_01_mangos_spell_bonus_data.sql \ README diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index aebaf8a42..fa3aaf57e 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -4791,8 +4791,9 @@ void Aura::HandlePeriodicHeal(bool apply, bool /*Real*/) if (m_spellProto->SpellIconID == 329 && m_spellProto->SpellVisual[0] == 7625) { int32 ap = int32 (0.22f * caster->GetTotalAttackPowerValue(BASE_ATTACK)); - int32 holy = caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellProto)) - + m_target->SpellBaseDamageBonusTaken(GetSpellSchoolMask(m_spellProto)); + int32 holy = caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellProto)); + if (holy < 0) + holy = 0; holy = int32(holy * 377 / 1000); m_modifier.m_amount += ap > holy ? ap : holy; } @@ -4960,8 +4961,9 @@ void Aura::HandlePeriodicDamage(bool apply, bool Real) { // AP * 0.025 + SPH * 0.013 bonus per tick float ap = caster->GetTotalAttackPowerValue(BASE_ATTACK); - int32 holy = caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellProto)) + - GetTarget()->SpellBaseDamageBonusTaken(GetSpellSchoolMask(m_spellProto)); + int32 holy = caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellProto)); + if (holy < 0) + holy = 0; m_modifier.m_amount += int32(GetStackAmount()) * (int32(ap * 0.025f) + int32(holy * 13 / 1000)); return; } diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 038f2e73c..da1fd9874 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -699,8 +699,9 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) if (m_spellInfo->Id == 20187) { float ap = m_caster->GetTotalAttackPowerValue(BASE_ATTACK); - int32 holy = m_caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellInfo)) + - unitTarget->SpellBaseDamageBonusTaken(GetSpellSchoolMask(m_spellInfo)); + int32 holy = m_caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellInfo)); + if (holy < 0) + holy = 0; damage += int32(ap * 0.2f) + int32(holy * 32 / 100); } // Judgement of Vengeance/Corruption ${1+0.22*$SPH+0.14*$AP} + 10% for each application of Holy Vengeance/Blood Corruption on the target @@ -715,8 +716,9 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) } float ap = m_caster->GetTotalAttackPowerValue(BASE_ATTACK); - int32 holy = m_caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellInfo)) + - unitTarget->SpellBaseDamageBonusTaken(GetSpellSchoolMask(m_spellInfo)); + int32 holy = m_caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellInfo)); + if (holy < 0) + holy = 0; damage+=int32(ap * 0.14f) + int32(holy * 22 / 100); // Get stack of Holy Vengeance on the target added by caster uint32 stacks = 0; @@ -737,16 +739,18 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) else if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000004000)) { float ap = m_caster->GetTotalAttackPowerValue(BASE_ATTACK); - int32 holy = m_caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellInfo)) + - unitTarget->SpellBaseDamageBonusTaken(GetSpellSchoolMask(m_spellInfo)); + int32 holy = m_caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellInfo)); + if (holy < 0) + holy = 0; damage += int32(ap * 0.07f) + int32(holy * 7 / 100); } // Hammer of Wrath ($m1+0.15*$SPH+0.15*$AP) - ranged type sdb future fix else if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000008000000000)) { float ap = m_caster->GetTotalAttackPowerValue(BASE_ATTACK); - int32 holy = m_caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellInfo)) + - unitTarget->SpellBaseDamageBonusTaken(GetSpellSchoolMask(m_spellInfo)); + int32 holy = m_caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellInfo)); + if (holy < 0) + holy = 0; damage += int32(ap * 0.15f) + int32(holy * 15 / 100); } // Hammer of the Righteous @@ -3054,8 +3058,9 @@ void Spell::EffectHeal(SpellEffectIndex /*eff_idx*/) if (m_spellInfo->Id == 20167) { float ap = caster->GetTotalAttackPowerValue(BASE_ATTACK); - int32 holy = caster->SpellBaseHealingBonusDone(GetSpellSchoolMask(m_spellInfo)) + - unitTarget->SpellBaseHealingBonusTaken(GetSpellSchoolMask(m_spellInfo)); + int32 holy = caster->SpellBaseHealingBonusDone(GetSpellSchoolMask(m_spellInfo)); + if (holy < 0) + holy = 0; addhealth += int32(ap * 0.15) + int32(holy * 15 / 100); } // Vessel of the Naaru (Vial of the Sunwell trinket) @@ -3114,14 +3119,7 @@ void Spell::EffectHeal(SpellEffectIndex /*eff_idx*/) addhealth += tickheal * tickcount; } - else - { - addhealth = caster->SpellHealingBonusDone(unitTarget, m_spellInfo, addhealth, HEAL); - addhealth = unitTarget->SpellHealingBonusTaken(caster, m_spellInfo, addhealth, HEAL); - } - - m_healing += addhealth; - + // Chain Healing if (m_spellInfo->SpellFamilyName == SPELLFAMILY_SHAMAN && m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000000100)) { @@ -3131,9 +3129,14 @@ void Spell::EffectHeal(SpellEffectIndex /*eff_idx*/) Aura* riptide = unitTarget->GetAura(SPELL_AURA_PERIODIC_HEAL, SPELLFAMILY_SHAMAN, 0, 0x00000010, caster->GetGUID()); if (!riptide) return; - m_healing += m_healing/4; + addhealth += addhealth/4; unitTarget->RemoveAura(riptide); } + + addhealth = caster->SpellHealingBonusDone(unitTarget, m_spellInfo, addhealth, HEAL); + addhealth = unitTarget->SpellHealingBonusTaken(caster, m_spellInfo, addhealth, HEAL); + + m_healing += addhealth; } } @@ -3147,8 +3150,9 @@ void Spell::EffectHealPct(SpellEffectIndex /*eff_idx*/) return; uint32 addhealth = unitTarget->GetMaxHealth() * damage / 100; - if (Player* modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DAMAGE, addhealth, this); + + addhealth = caster->SpellHealingBonusDone(unitTarget, m_spellInfo, addhealth, HEAL); + addhealth = unitTarget->SpellHealingBonusTaken(caster, m_spellInfo, addhealth, HEAL); int32 gain = caster->DealHeal(unitTarget, addhealth, m_spellInfo); unitTarget->getHostileRefManager().threatAssist(m_caster, float(gain) * 0.5f, m_spellInfo); @@ -3197,7 +3201,6 @@ void Spell::EffectHealthLeech(SpellEffectIndex eff_idx) int32 heal = int32(damage*multiplier); if (m_caster->isAlive()) { - heal = m_caster->SpellHealingBonusDone(m_caster, m_spellInfo, heal, HEAL); heal = m_caster->SpellHealingBonusTaken(m_caster, m_spellInfo, heal, HEAL); m_caster->DealHeal(m_caster, heal, m_spellInfo); @@ -5021,8 +5024,9 @@ void Spell::EffectWeaponDmg(SpellEffectIndex eff_idx) if(m_spellInfo->SpellFamilyFlags & UI64LIT(0x00020000000000)) { float ap = m_caster->GetTotalAttackPowerValue(BASE_ATTACK); - int32 holy = m_caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellInfo)) + - unitTarget->SpellBaseDamageBonusTaken(GetSpellSchoolMask(m_spellInfo)); + int32 holy = m_caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellInfo)); + if (holy < 0) + holy = 0; spell_bonus += int32(ap * 0.08f) + int32(holy * 13 / 100); } break; diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 98a55c2b2..f028171af 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -6282,8 +6282,9 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu { triggered_spell_id = 25742; float ap = GetTotalAttackPowerValue(BASE_ATTACK); - int32 holy = SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_HOLY) + - pVictim->SpellBaseDamageBonusTaken(SPELL_SCHOOL_MASK_HOLY); + int32 holy = SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_HOLY); + if (holy < 0) + holy = 0; basepoints[0] = GetAttackTime(BASE_ATTACK) * int32(ap*0.022f + 0.044f * holy) / 1000; break; } @@ -9307,7 +9308,7 @@ uint32 Unit::SpellDamageBonusTaken(Unit *pCaster, SpellEntry const *spellProto, TakenTotal+= int32(TakenAdvertisedBenefit * (CastingTime / 3500.0f) * DotFactor * LvlPenalty); } - float tmpDamage = (pdamage + TakenTotal * int32(stack)) * TakenTotalMod; + float tmpDamage = (int32(pdamage) + TakenTotal * int32(stack)) * TakenTotalMod; return tmpDamage > 0 ? uint32(tmpDamage) : 0; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 93a5fd239..335599b7a 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9853" + #define REVISION_NR "9854" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index d184f4b20..ba8bbf791 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -1,6 +1,6 @@ #ifndef __REVISION_SQL_H__ #define __REVISION_SQL_H__ #define REVISION_DB_CHARACTERS "required_9849_01_characters_saved_variables" - #define REVISION_DB_MANGOS "required_9826_01_mangos_spell_script_target" + #define REVISION_DB_MANGOS "required_9854_01_mangos_spell_bonus_data" #define REVISION_DB_REALMD "required_9748_01_realmd_realmlist" #endif // __REVISION_SQL_H__