aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfunjoker <torti-esser@web.de>2018-04-28 21:58:25 +0200
committerShauren <shauren.trinity@gmail.com>2018-04-28 22:58:25 +0300
commit6a6374842428d6ef671d83547e8aa03d000a8249 (patch)
treed83a856ffa20adbb309e2bf2c4f8c0e1854c31aa /src
parent2d666810d2ce42dde819f3d027a8583fb94dacd2 (diff)
Core/Units: Implemented versatility (#21206)
* Base code taken from https://github.com/AshamaneProject/AshamaneCore
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Player/Player.cpp11
-rw-r--r--src/server/game/Entities/Player/Player.h2
-rw-r--r--src/server/game/Entities/Unit/StatSystem.cpp31
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp23
-rw-r--r--src/server/game/Spells/Auras/SpellAuraDefines.h2
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp26
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.h2
7 files changed, 92 insertions, 5 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 832fe63e578..c31a3ebd6a3 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -5139,8 +5139,13 @@ void Player::UpdateRating(CombatRating cr)
break;
case CR_PVP_POWER:
case CR_CLEAVE:
+ break;
case CR_VERSATILITY_DAMAGE_DONE:
+ UpdateVersatilityDamageDone();
+ break;
case CR_VERSATILITY_HEALING_DONE:
+ UpdateHealingDonePercentMod();
+ break;
case CR_VERSATILITY_DAMAGE_TAKEN:
case CR_UNUSED_12:
break;
@@ -14112,6 +14117,12 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool
ApplyRatingMod(CR_MASTERY, enchant_amount, apply);
TC_LOG_DEBUG("entities.player.items", "+ %u MASTERY", enchant_amount);
break;
+ case ITEM_MOD_VERSATILITY:
+ ApplyRatingMod(CR_VERSATILITY_DAMAGE_DONE, enchant_amount, apply);
+ ApplyRatingMod(CR_VERSATILITY_HEALING_DONE, enchant_amount, apply);
+ ApplyRatingMod(CR_VERSATILITY_DAMAGE_TAKEN, enchant_amount, apply);
+ TC_LOG_DEBUG("entities.player.items", "+ %u VERSATILITY", enchant_amount);
+ break;
default:
break;
}
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index b167ad36423..f5752bd450d 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1813,6 +1813,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void UpdateRating(CombatRating cr);
void UpdateAllRatings();
void UpdateMastery();
+ void UpdateVersatilityDamageDone();
+ void UpdateHealingDonePercentMod();
bool CanUseMastery() const;
void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) override;
diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp
index 0f1733bc72c..7e0d38c9875 100644
--- a/src/server/game/Entities/Unit/StatSystem.cpp
+++ b/src/server/game/Entities/Unit/StatSystem.cpp
@@ -443,6 +443,10 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bo
float weaponMinDamage = GetWeaponDamageRange(attType, MINDAMAGE);
float weaponMaxDamage = GetWeaponDamageRange(attType, MAXDAMAGE);
+ float versaDmgMod = 1.0f;
+
+ AddPct(versaDmgMod, GetRatingBonusValue(CR_VERSATILITY_DAMAGE_DONE) + float(GetTotalAuraModifier(SPELL_AURA_MOD_VERSATILITY)));
+
SpellShapeshiftFormEntry const* shapeshift = sSpellShapeshiftFormStore.LookupEntry(GetShapeshiftForm());
if (shapeshift && shapeshift->CombatRoundTime)
{
@@ -462,8 +466,8 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bo
weaponMaxDamage = BASE_MAXDAMAGE;
}
- minDamage = ((weaponMinDamage + baseValue) * basePct + totalValue) * totalPct;
- maxDamage = ((weaponMaxDamage + baseValue) * basePct + totalValue) * totalPct;
+ minDamage = ((weaponMinDamage + baseValue) * basePct + totalValue) * totalPct * versaDmgMod;
+ maxDamage = ((weaponMaxDamage + baseValue) * basePct + totalValue) * totalPct * versaDmgMod;
}
void Player::UpdateBlockPercentage()
@@ -572,6 +576,29 @@ void Player::UpdateMastery()
}
}
+void Player::UpdateVersatilityDamageDone()
+{
+ // No proof that CR_VERSATILITY_DAMAGE_DONE is allways = PLAYER_VERSATILITY
+ SetUInt32Value(PLAYER_VERSATILITY, GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + CR_VERSATILITY_DAMAGE_DONE));
+
+ if (getClass() == CLASS_HUNTER)
+ UpdateDamagePhysical(RANGED_ATTACK);
+ else
+ UpdateDamagePhysical(BASE_ATTACK);
+}
+
+void Player::UpdateHealingDonePercentMod()
+{
+ float value = 1.0f;
+
+ AddPct(value, GetRatingBonusValue(CR_VERSATILITY_HEALING_DONE) + GetTotalAuraModifier(SPELL_AURA_MOD_VERSATILITY));
+
+ for (AuraEffect const* auraEffect : GetAuraEffectsByType(SPELL_AURA_MOD_HEALING_DONE_PERCENT))
+ AddPct(value, auraEffect->GetAmount());
+
+ SetStatFloatValue(PLAYER_FIELD_MOD_HEALING_DONE_PCT, value);
+}
+
const float m_diminishing_k[MAX_CLASSES] =
{
0.9560f, // Warrior
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 1d54a154144..4bb997ef8e2 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -6505,6 +6505,10 @@ float Unit::SpellDamagePctDone(Unit* victim, SpellInfo const* spellProto, Damage
if (GetTypeId() == TYPEID_UNIT && !IsPet())
DoneTotalMod *= ToCreature()->GetSpellDamageMod(ToCreature()->GetCreatureTemplate()->rank);
+ // Versatility
+ if (Player* modOwner = GetSpellModOwner())
+ AddPct(DoneTotalMod, modOwner->GetRatingBonusValue(CR_VERSATILITY_DAMAGE_DONE) + modOwner->GetTotalAuraModifier(SPELL_AURA_MOD_VERSATILITY));
+
float maxModDamagePercentSchool = 0.0f;
if (GetTypeId() == TYPEID_PLAYER)
{
@@ -6587,6 +6591,14 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, ui
// get all auras from caster that allow the spell to ignore resistance (sanctified wrath)
TakenTotalCasterMod += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_IGNORE_TARGET_RESIST, spellProto->GetSchoolMask());
+ // Versatility
+ if (Player* modOwner = GetSpellModOwner())
+ {
+ // only 50% of SPELL_AURA_MOD_VERSATILITY for damage reduction
+ float versaBonus = modOwner->GetTotalAuraModifier(SPELL_AURA_MOD_VERSATILITY) / 2.0f;
+ AddPct(TakenTotalMod, -(modOwner->GetRatingBonusValue(CR_VERSATILITY_DAMAGE_TAKEN) + versaBonus));
+ }
+
// from positive and negative SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN
// multiplicative bonus, for example Dispersion + Shadowform (0.10*0.85=0.085)
TakenTotalMod *= GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, spellProto->GetSchoolMask());
@@ -6962,6 +6974,9 @@ float Unit::SpellHealingPctDone(Unit* /*victim*/, SpellInfo const* spellProto) c
if (spellProto->SpellFamilyName == SPELLFAMILY_POTION)
return 1.0f;
+ if (IsPlayer())
+ return GetFloatValue(PLAYER_FIELD_MOD_HEALING_DONE_PCT);
+
float DoneTotalMod = 1.0f;
// Healing done percent
@@ -7426,6 +7441,14 @@ uint32 Unit::MeleeDamageBonusTaken(Unit* attacker, uint32 pdamage, WeaponAttackT
else
TakenTotalMod *= GetTotalAuraMultiplier(SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT);
+ // Versatility
+ if (Player* modOwner = GetSpellModOwner())
+ {
+ // only 50% of SPELL_AURA_MOD_VERSATILITY for damage reduction
+ float versaBonus = modOwner->GetTotalAuraModifier(SPELL_AURA_MOD_VERSATILITY) / 2.0f;
+ AddPct(TakenTotalMod, -(modOwner->GetRatingBonusValue(CR_VERSATILITY_DAMAGE_TAKEN) + versaBonus));
+ }
+
float tmpDamage = 0.0f;
if (TakenTotalCasterMod)
diff --git a/src/server/game/Spells/Auras/SpellAuraDefines.h b/src/server/game/Spells/Auras/SpellAuraDefines.h
index 7c92e81872e..e146ed3996d 100644
--- a/src/server/game/Spells/Auras/SpellAuraDefines.h
+++ b/src/server/game/Spells/Auras/SpellAuraDefines.h
@@ -540,7 +540,7 @@ enum AuraType : uint32
SPELL_AURA_TRIGGER_SPELL_ON_HEALTH_PCT = 468, // Triggers spell when health goes above (MiscA = 0) or falls below (MiscA = 1) specified percent value (once, not every time condition has meet)
SPELL_AURA_SHOW_CONFIRMATION_PROMPT_WITH_DIFFICULTY = 469,
SPELL_AURA_470 = 470,
- SPELL_AURA_MOD_VERSATILITY = 471, // NYI
+ SPELL_AURA_MOD_VERSATILITY = 471,
SPELL_AURA_472 = 472,
SPELL_AURA_PREVENT_DURABILITY_LOSS_FROM_COMBAT = 473, // Prevents durability loss from dealing/taking damage
SPELL_AURA_474 = 474,
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index dfe5f801381..7ab1a4acd12 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -202,7 +202,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleAuraModIncreaseHealthPercent, //133 SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT
&AuraEffect::HandleAuraModRegenInterrupt, //134 SPELL_AURA_MOD_MANA_REGEN_INTERRUPT
&AuraEffect::HandleModHealingDone, //135 SPELL_AURA_MOD_HEALING_DONE
- &AuraEffect::HandleNoImmediateEffect, //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonus
+ &AuraEffect::HandleModHealingDonePct, //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT
&AuraEffect::HandleModTotalPercentStat, //137 SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE
&AuraEffect::HandleModMeleeSpeedPct, //138 SPELL_AURA_MOD_MELEE_HASTE
&AuraEffect::HandleForceReaction, //139 SPELL_AURA_FORCE_REACTION
@@ -537,7 +537,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleNULL, //468 SPELL_AURA_TRIGGER_SPELL_ON_HEALTH_PCT
&AuraEffect::HandleShowConfirmationPrompt, //469 SPELL_AURA_SHOW_CONFIRMATION_PROMPT_WITH_DIFFICULTY
&AuraEffect::HandleNULL, //470
- &AuraEffect::HandleNULL, //471 SPELL_AURA_MOD_VERSATILITY
+ &AuraEffect::HandleModVersatilityByPct, //471 SPELL_AURA_MOD_VERSATILITY
&AuraEffect::HandleNULL, //472
&AuraEffect::HandleNoImmediateEffect, //473 SPELL_AURA_PREVENT_DURABILITY_LOSS_FROM_COMBAT implemented in Player::DurabilityPointLossForEquipSlot
&AuraEffect::HandleNULL, //474
@@ -3447,6 +3447,15 @@ void AuraEffect::HandleModHealingDone(AuraApplication const* aurApp, uint8 mode,
target->ToPlayer()->UpdateSpellDamageAndHealingBonus();
}
+void AuraEffect::HandleModHealingDonePct(AuraApplication const* aurApp, uint8 mode, bool /*apply*/) const
+{
+ if (!(mode & (AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK | AURA_EFFECT_HANDLE_STAT)))
+ return;
+
+ if (Player* player = aurApp->GetTarget()->ToPlayer())
+ player->UpdateHealingDonePercentMod();
+}
+
void AuraEffect::HandleModTotalPercentStat(AuraApplication const* aurApp, uint8 mode, bool apply) const
{
if (!(mode & (AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK | AURA_EFFECT_HANDLE_STAT)))
@@ -3591,6 +3600,19 @@ void AuraEffect::HandleOverrideAttackPowerBySpellPower(AuraApplication const* au
target->UpdateAttackPowerAndDamage(true);
}
+void AuraEffect::HandleModVersatilityByPct(AuraApplication const* aurApp, uint8 mode, bool /*apply*/) const
+{
+ if (!(mode & (AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK | AURA_EFFECT_HANDLE_STAT)))
+ return;
+
+ if (Player* target = aurApp->GetTarget()->ToPlayer())
+ {
+ target->SetStatFloatValue(PLAYER_VERSATILITY_BONUS, target->GetTotalAuraModifier(SPELL_AURA_MOD_VERSATILITY));
+ target->UpdateHealingDonePercentMod();
+ target->UpdateVersatilityDamageDone();
+ }
+}
+
void AuraEffect::HandleAuraModMaxPower(AuraApplication const* aurApp, uint8 mode, bool apply) const
{
if (!(mode & (AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK | AURA_EFFECT_HANDLE_STAT)))
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h
index a19d7cb1033..3c113156329 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.h
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.h
@@ -230,12 +230,14 @@ class TC_GAME_API AuraEffect
void HandleModSpellDamagePercentFromAttackPower(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleModSpellHealingPercentFromAttackPower(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleModHealingDone(AuraApplication const* aurApp, uint8 mode, bool apply) const;
+ void HandleModHealingDonePct(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleModTotalPercentStat(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleAuraModResistenceOfStatPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const;
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;
+ void HandleModVersatilityByPct(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleAuraModMaxPower(AuraApplication const* aurApp, uint8 mode, bool apply) const;
// heal and energize
void HandleModPowerRegen(AuraApplication const* aurApp, uint8 mode, bool apply) const;