aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2015-06-12 00:11:12 +0200
committerShauren <shauren.trinity@gmail.com>2015-06-12 00:11:12 +0200
commit733456ef311f4a13afd8d78ce2430ea5a6abeea9 (patch)
tree25e631277046c793b5be874bc95707f0db6b2f00 /src
parent32b954923a99edaf640ed258a1fce1f347f59883 (diff)
Core/Auras: Implemented SPELL_AURA_OVERRIDE_ATTACK_POWER_BY_SP_PCT
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Unit/StatSystem.cpp23
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp15
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.h1
3 files changed, 37 insertions, 2 deletions
diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp
index 91f2d8ba52a..7cc25c5a5a1 100644
--- a/src/server/game/Entities/Unit/StatSystem.cpp
+++ b/src/server/game/Entities/Unit/StatSystem.cpp
@@ -163,6 +163,9 @@ void Player::ApplySpellPowerBonus(int32 amount, bool apply)
ApplyModUInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS, amount, apply);
for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, amount, apply);
+
+ if (HasAuraType(SPELL_AURA_OVERRIDE_ATTACK_POWER_BY_SP_PCT))
+ UpdateAttackPowerAndDamage();
}
void Player::UpdateSpellDamageAndHealingBonus()
@@ -174,6 +177,9 @@ void Player::UpdateSpellDamageAndHealingBonus()
// Get damage bonus for all schools
for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
SetStatInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i, SpellBaseDamageBonusDone(SpellSchoolMask(1 << i)));
+
+ if (HasAuraType(SPELL_AURA_OVERRIDE_ATTACK_POWER_BY_SP_PCT))
+ UpdateAttackPowerAndDamage();
}
bool Player::UpdateAllStats()
@@ -301,13 +307,17 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
UnitMods unitMod = ranged ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER;
uint16 index = UNIT_FIELD_ATTACK_POWER;
+ uint16 index_mod = UNIT_FIELD_ATTACK_POWER_MOD_POS;
+ uint16 index_mult = UNIT_FIELD_ATTACK_POWER_MULTIPLIER;
if (ranged)
{
index = UNIT_FIELD_RANGED_ATTACK_POWER;
+ index_mod = UNIT_FIELD_RANGED_ATTACK_POWER_MOD_POS;
+ index_mult = UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER;
val2 = (level + std::max(GetStat(STAT_AGILITY), 0.0f)) * entry->RangedAttackPowerPerAgility;
}
- else
+ else if (!HasAuraType(SPELL_AURA_OVERRIDE_ATTACK_POWER_BY_SP_PCT))
{
float strengthValue = std::max(GetStat(STAT_STRENGTH) * entry->AttackPowerPerStrength, 0.0f);
float agilityValue = std::max(GetStat(STAT_AGILITY) * entry->AttackPowerPerAgility, 0.0f);
@@ -319,11 +329,20 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
val2 = strengthValue + agilityValue;
}
+ else
+ {
+ int32 minSpellPower = GetInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS);
+ for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
+ minSpellPower = std::min(minSpellPower, GetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i));
+
+ val2 = CalculatePct(float(minSpellPower), GetFloatValue(PLAYER_FIELD_OVERRIDE_AP_BY_SPELL_POWER_PERCENT));
+ }
SetModifierValue(unitMod, BASE_VALUE, val2);
float base_attPower = GetModifierValue(unitMod, BASE_VALUE) * GetModifierValue(unitMod, BASE_PCT);
float attPowerMod = GetModifierValue(unitMod, TOTAL_VALUE);
+ float attPowerMultiplier = GetModifierValue(unitMod, TOTAL_PCT) - 1.0f;
//add dynamic flat mods
if (!ranged)
@@ -335,6 +354,8 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
}
SetInt32Value(index, (uint32)base_attPower); //UNIT_FIELD_(RANGED)_ATTACK_POWER field
+ SetInt32Value(index_mod, (uint32)attPowerMod); //UNIT_FIELD_(RANGED)_ATTACK_POWER_MOD_POS field
+ SetFloatValue(index_mult, attPowerMultiplier); //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field
Pet* pet = GetPet(); //update pet's AP
Guardian* guardian = GetGuardianPet();
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index b3a04347aec..b5f154e6fe1 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -464,7 +464,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleNULL, //401
&AuraEffect::HandleNULL, //402
&AuraEffect::HandleNULL, //403
- &AuraEffect::HandleNULL, //404 SPELL_AURA_OVERRIDE_ATTACK_POWER_BY_SP_PCT
+ &AuraEffect::HandleOverrideAttackPowerBySpellPower, //404 SPELL_AURA_OVERRIDE_ATTACK_POWER_BY_SP_PCT
&AuraEffect::HandleNULL, //405
&AuraEffect::HandleNULL, //406
&AuraEffect::HandleNULL, //407 SPELL_AURA_MOD_FEAR_2
@@ -4022,6 +4022,19 @@ void AuraEffect::HandleOverrideSpellPowerByAttackPower(AuraApplication const* au
target->UpdateSpellDamageAndHealingBonus();
}
+void AuraEffect::HandleOverrideAttackPowerBySpellPower(AuraApplication const* aurApp, uint8 mode, bool apply) const
+{
+ if (!(mode & (AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK | AURA_EFFECT_HANDLE_STAT)))
+ return;
+
+ Player* target = aurApp->GetTarget()->ToPlayer();
+ if (!target)
+ return;
+
+ target->ApplyModSignedFloatValue(PLAYER_FIELD_OVERRIDE_AP_BY_SPELL_POWER_PERCENT, float(m_amount), apply);
+ target->UpdateAttackPowerAndDamage();
+}
+
/********************************/
/*** HEAL & ENERGIZE ***/
/********************************/
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h
index ecb1f4abab1..91cf75dbe87 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.h
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.h
@@ -236,6 +236,7 @@ class AuraEffect
void HandleAuraModExpertise(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleModStatBonusPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleOverrideSpellPowerByAttackPower(AuraApplication const* aurApp, uint8 mode, bool apply) const;
+ void HandleOverrideAttackPowerBySpellPower(AuraApplication const* aurApp, uint8 mode, bool apply) const;
// heal and energize
void HandleModPowerRegen(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleModPowerRegenPCT(AuraApplication const* aurApp, uint8 mode, bool apply) const;