From e58df484a2dcba671a1aa7c1bc5588172480932d Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 4 Dec 2008 05:53:02 +0300 Subject: [PATCH] Implement aura use in new version of racial trait 20550. Add unit stat mods for rune/runic powers. Last change will also prevent corruption armor and holy resistence values. --- src/game/SpellAuras.cpp | 20 ++++++++++++++------ src/game/SpellAuras.h | 1 + src/game/StatSystem.cpp | 1 + src/game/Unit.cpp | 23 +++++++++++------------ src/game/Unit.h | 6 ++++-- 5 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index f427fb422..1c7403246 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -332,7 +332,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]= &Aura::HandleNULL, //279 &Aura::HandleNULL, //280 ignore armor? &Aura::HandleNULL, //281 increase honor gain? - &Aura::HandleNULL, //282 + &Aura::HandleAuraIncreaseBaseHealthPercent, //282 SPELL_AURA_INCREASE_BASE_HEALTH_PERCENT &Aura::HandleNULL //283 SPD/heal from AP? }; @@ -4718,24 +4718,32 @@ void Aura::HandleAuraModIncreaseEnergy(bool apply, bool Real) if(int32(powerType) != m_modifier.m_miscvalue) return; - m_target->HandleStatModifier(UnitMods(UNIT_MOD_POWER_START + powerType), TOTAL_VALUE, float(m_modifier.m_amount), apply); + UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType); + + m_target->HandleStatModifier(unitMod, TOTAL_VALUE, float(m_modifier.m_amount), apply); } -void Aura::HandleAuraModIncreaseEnergyPercent(bool apply, bool Real) +void Aura::HandleAuraModIncreaseEnergyPercent(bool apply, bool /*Real*/) { Powers powerType = m_target->getPowerType(); if(int32(powerType) != m_modifier.m_miscvalue) return; - m_target->HandleStatModifier(UnitMods(UNIT_MOD_POWER_START + powerType), TOTAL_PCT, float(m_modifier.m_amount), apply); + UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType); + + m_target->HandleStatModifier(unitMod, TOTAL_PCT, float(m_modifier.m_amount), apply); } -void Aura::HandleAuraModIncreaseHealthPercent(bool apply, bool Real) +void Aura::HandleAuraModIncreaseHealthPercent(bool apply, bool /*Real*/) { - //m_target->ApplyMaxHealthPercentMod(m_modifier.m_amount,apply); m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_PCT, float(m_modifier.m_amount), apply); } +void Aura::HandleAuraIncreaseBaseHealthPercent(bool apply, bool /*Real*/) +{ + m_target->HandleStatModifier(UNIT_MOD_HEALTH, BASE_PCT, float(m_modifier.m_amount), apply); +} + /********************************/ /*** FIGHT ***/ /********************************/ diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h index 6df6e7a10..0a3fbd3d9 100644 --- a/src/game/SpellAuras.h +++ b/src/game/SpellAuras.h @@ -209,6 +209,7 @@ class MANGOS_DLL_SPEC Aura void HandleManaShield(bool apply, bool Real); void HandleArenaPreparation(bool apply, bool Real); void HandleAuraConvertRune(bool apply, bool Real); + void HandleAuraIncreaseBaseHealthPercent(bool Apply, bool Real); virtual ~Aura(); diff --git a/src/game/StatSystem.cpp b/src/game/StatSystem.cpp index 828c7fbe0..f7aadca8b 100644 --- a/src/game/StatSystem.cpp +++ b/src/game/StatSystem.cpp @@ -849,6 +849,7 @@ void Pet::UpdateMaxHealth() void Pet::UpdateMaxPower(Powers power) { UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power); + float addValue = (power == POWER_MANA) ? GetStat(STAT_INTELLECT) - GetCreateStat(STAT_INTELLECT) : 0.0f; float value = GetModifierValue(unitMod, BASE_VALUE) + GetCreatePowers(power); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 95b4cee7c..30cf08c76 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -9514,7 +9514,9 @@ bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, f case UNIT_MOD_RAGE: case UNIT_MOD_FOCUS: case UNIT_MOD_ENERGY: - case UNIT_MOD_HAPPINESS: UpdateMaxPower(GetPowerTypeByAuraGroup(unitMod)); break; + case UNIT_MOD_HAPPINESS: + case UNIT_MOD_RUNE: + case UNIT_MOD_RUNIC_POWER: UpdateMaxPower(GetPowerTypeByAuraGroup(unitMod)); break; case UNIT_MOD_RESISTANCE_HOLY: case UNIT_MOD_RESISTANCE_FIRE: @@ -9627,21 +9629,18 @@ Stats Unit::GetStatByAuraGroup(UnitMods unitMod) const Powers Unit::GetPowerTypeByAuraGroup(UnitMods unitMod) const { - Powers power = POWER_MANA; - switch(unitMod) { - case UNIT_MOD_MANA: power = POWER_MANA; break; - case UNIT_MOD_RAGE: power = POWER_RAGE; break; - case UNIT_MOD_FOCUS: power = POWER_FOCUS; break; - case UNIT_MOD_ENERGY: power = POWER_ENERGY; break; - case UNIT_MOD_HAPPINESS: power = POWER_HAPPINESS; break; - - default: - break; + case UNIT_MOD_MANA: return POWER_MANA; + case UNIT_MOD_RAGE: return POWER_RAGE; + case UNIT_MOD_FOCUS: return POWER_FOCUS; + case UNIT_MOD_ENERGY: return POWER_ENERGY; + case UNIT_MOD_HAPPINESS: return POWER_HAPPINESS; + case UNIT_MOD_RUNE: return POWER_RUNE; + case UNIT_MOD_RUNIC_POWER:return POWER_RUNIC_POWER; } - return power; + return POWER_MANA; } float Unit::GetTotalAttackPowerValue(WeaponAttackType attType) const diff --git a/src/game/Unit.h b/src/game/Unit.h index 63cfd77da..365e50554 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -301,11 +301,13 @@ enum UnitMods UNIT_MOD_STAT_INTELLECT, UNIT_MOD_STAT_SPIRIT, UNIT_MOD_HEALTH, - UNIT_MOD_MANA, // UNIT_MOD_MANA..UNIT_MOD_HAPPINESS must be in existed order, it's accessed by index values of Powers enum. + UNIT_MOD_MANA, // UNIT_MOD_MANA..UNIT_MOD_RUNIC_POWER must be in existed order, it's accessed by index values of Powers enum. UNIT_MOD_RAGE, UNIT_MOD_FOCUS, UNIT_MOD_ENERGY, UNIT_MOD_HAPPINESS, + UNIT_MOD_RUNE, + UNIT_MOD_RUNIC_POWER, UNIT_MOD_ARMOR, // UNIT_MOD_ARMOR..UNIT_MOD_RESISTANCE_ARCANE must be in existed order, it's accessed by index values of SpellSchools enum. UNIT_MOD_RESISTANCE_HOLY, UNIT_MOD_RESISTANCE_FIRE, @@ -325,7 +327,7 @@ enum UnitMods UNIT_MOD_RESISTANCE_START = UNIT_MOD_ARMOR, UNIT_MOD_RESISTANCE_END = UNIT_MOD_RESISTANCE_ARCANE + 1, UNIT_MOD_POWER_START = UNIT_MOD_MANA, - UNIT_MOD_POWER_END = UNIT_MOD_HAPPINESS + 1 + UNIT_MOD_POWER_END = UNIT_MOD_RUNIC_POWER + 1 }; enum BaseModGroup