Core/Auras: Rewritten conditionally applying SPELL_AURA_MOD_WEAPON_CR…
…IT_PERCENT, SPELL_AURA_MOD_DAMAGE_DONE and SPELL_AURA_MOD_DAMAGE_PERCENT_DONE auras * Now the entire aura is removed when changing equipment * All aura types can now depend on equipped items
This commit is contained in:
1 parent
0ca62b97e0
commit
c0ba6c2dfe
8 files changed
+133
-285
No files matched your search
@@ -7684,11 +7684,9 @@ void Player::_ApplyItemMods(Item* item, uint8 slot, bool apply)
|
||||
if (proto->Socket[0].Color) //only (un)equipping of items with sockets can influence metagems, so no need to waste time with normal items
|
||||
CorrectMetaGemEnchants(slot, apply);
|
||||
|
||||
if (attacktype < MAX_ATTACK)
|
||||
_ApplyWeaponDependentAuraMods(item, WeaponAttackType(attacktype), apply);
|
||||
|
||||
_ApplyItemBonuses(proto, slot, apply);
|
||||
ApplyItemEquipSpell(item, apply);
|
||||
ApplyItemDependentAuras(item, apply);
|
||||
ApplyEnchantment(item, apply);
|
||||
|
||||
TC_LOG_DEBUG("entities.player.items", "Player::_ApplyItemMods: completed");
|
||||
@@ -8006,86 +8004,26 @@ void Player::_ApplyWeaponDamage(uint8 slot, ItemTemplate const* proto, ScalingSt
|
||||
UpdateDamagePhysical(attType);
|
||||
}
|
||||
|
||||
void Player::_ApplyWeaponDependentAuraMods(Item* item, WeaponAttackType attackType, bool apply)
|
||||
void Player::ApplyItemDependentAuras(Item* item, bool apply)
|
||||
{
|
||||
AuraEffectList const& auraCritList = GetAuraEffectsByType(SPELL_AURA_MOD_WEAPON_CRIT_PERCENT);
|
||||
for (AuraEffectList::const_iterator itr = auraCritList.begin(); itr != auraCritList.end(); ++itr)
|
||||
_ApplyWeaponDependentAuraCritMod(item, attackType, *itr, apply);
|
||||
|
||||
AuraEffectList const& auraDamageFlatList = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE);
|
||||
for (AuraEffectList::const_iterator itr = auraDamageFlatList.begin(); itr != auraDamageFlatList.end(); ++itr)
|
||||
_ApplyWeaponDependentAuraDamageMod(item, attackType, *itr, apply);
|
||||
|
||||
AuraEffectList const& auraDamagePctList = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
|
||||
for (AuraEffectList::const_iterator itr = auraDamagePctList.begin(); itr != auraDamagePctList.end(); ++itr)
|
||||
_ApplyWeaponDependentAuraDamageMod(item, attackType, *itr, apply);
|
||||
}
|
||||
|
||||
void Player::_ApplyWeaponDependentAuraCritMod(Item* item, WeaponAttackType attackType, AuraEffect const* aura, bool apply)
|
||||
{
|
||||
// don't apply mod if item is broken or cannot be used
|
||||
if (item->IsBroken() || !CanUseAttackType(attackType))
|
||||
return;
|
||||
|
||||
// generic not weapon specific case processes in aura code
|
||||
if (aura->GetSpellInfo()->EquippedItemClass == -1)
|
||||
return;
|
||||
|
||||
BaseModGroup mod;
|
||||
switch (attackType)
|
||||
if (apply)
|
||||
{
|
||||
case BASE_ATTACK: mod = CRIT_PERCENTAGE; break;
|
||||
case OFF_ATTACK: mod = OFFHAND_CRIT_PERCENTAGE;break;
|
||||
case RANGED_ATTACK: mod = RANGED_CRIT_PERCENTAGE; break;
|
||||
default: return;
|
||||
}
|
||||
|
||||
if (item->IsFitToSpellRequirements(aura->GetSpellInfo()))
|
||||
HandleBaseModValue(mod, FLAT_MOD, float (aura->GetAmount()), apply);
|
||||
}
|
||||
|
||||
void Player::_ApplyWeaponDependentAuraDamageMod(Item* item, WeaponAttackType attackType, AuraEffect const* aura, bool apply)
|
||||
{
|
||||
// don't apply mod if item is broken or cannot be used
|
||||
if (item->IsBroken() || !CanUseAttackType(attackType))
|
||||
return;
|
||||
|
||||
// ignore spell mods for not wands
|
||||
if ((aura->GetMiscValue() & SPELL_SCHOOL_MASK_MAGIC) && (!(getClassMask() & CLASSMASK_WAND_USERS)))
|
||||
return;
|
||||
|
||||
// generic not weapon specific case processes in AuraEffect handler
|
||||
if (aura->GetSpellInfo()->EquippedItemClass == -1)
|
||||
return;
|
||||
|
||||
UnitMods unitMod;
|
||||
switch (attackType)
|
||||
{
|
||||
case BASE_ATTACK: unitMod = UNIT_MOD_DAMAGE_MAINHAND; break;
|
||||
case OFF_ATTACK: unitMod = UNIT_MOD_DAMAGE_OFFHAND; break;
|
||||
case RANGED_ATTACK: unitMod = UNIT_MOD_DAMAGE_RANGED; break;
|
||||
default: return;
|
||||
}
|
||||
|
||||
UnitModifierType unitModType;
|
||||
switch (aura->GetAuraType())
|
||||
{
|
||||
case SPELL_AURA_MOD_DAMAGE_DONE: unitModType = TOTAL_VALUE; break;
|
||||
case SPELL_AURA_MOD_DAMAGE_PERCENT_DONE: unitModType = TOTAL_PCT; break;
|
||||
default: return;
|
||||
}
|
||||
|
||||
if (item->IsFitToSpellRequirements(aura->GetSpellInfo()))
|
||||
{
|
||||
HandleStatModifier(unitMod, unitModType, float(aura->GetAmount()), apply);
|
||||
if (unitModType == TOTAL_VALUE)
|
||||
PlayerSpellMap const& spells = GetSpellMap();
|
||||
for (auto itr = spells.begin(); itr != spells.end(); ++itr)
|
||||
{
|
||||
if (aura->GetAmount() > 0)
|
||||
ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS, aura->GetAmount(), apply);
|
||||
else
|
||||
ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG, aura->GetAmount(), apply);
|
||||
if (itr->second->state == PLAYERSPELL_REMOVED || itr->second->disabled)
|
||||
continue;
|
||||
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first);
|
||||
if (!spellInfo || !spellInfo->IsPassive() || spellInfo->EquippedItemClass < 0)
|
||||
continue;
|
||||
|
||||
if (!HasAura(itr->first) && HasItemFitToSpellRequirements(spellInfo))
|
||||
AddAura(itr->first, this); // no SMSG_SPELL_GO in sniff found
|
||||
}
|
||||
}
|
||||
else
|
||||
+ RemoveItemDependentAurasAndCasts(item);
|
||||
}
|
||||
|
||||
void Player::ApplyItemEquipSpell(Item* item, bool apply, bool form_change)
|
||||
@@ -8452,10 +8390,7 @@ void Player::_RemoveAllItemMods()
|
||||
if (!proto)
|
||||
continue;
|
||||
|
||||
uint32 attacktype = Player::GetAttackBySlot(i);
|
||||
if (attacktype < MAX_ATTACK)
|
||||
_ApplyWeaponDependentAuraMods(m_items[i], WeaponAttackType(attacktype), false);
|
||||
|
||||
ApplyItemDependentAuras(m_items[i], false);
|
||||
_ApplyItemBonuses(proto, i, false);
|
||||
}
|
||||
}
|
||||
@@ -8479,9 +8414,8 @@ void Player::_ApplyAllItemMods()
|
||||
continue;
|
||||
|
||||
uint32 attacktype = Player::GetAttackBySlot(i);
|
||||
if (attacktype < MAX_ATTACK)
|
||||
_ApplyWeaponDependentAuraMods(m_items[i], WeaponAttackType(attacktype), true);
|
||||
|
||||
ApplyItemDependentAuras(m_items[i], true);
|
||||
_ApplyItemBonuses(proto, i, true);
|
||||
}
|
||||
}
|
||||
@@ -12078,9 +12012,6 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update)
|
||||
// remove item dependent auras and casts (only weapon and armor slots)
|
||||
if (slot < EQUIPMENT_SLOT_END)
|
||||
{
|
||||
if (update)
|
||||
RemoveItemDependentAurasAndCasts(pItem);
|
||||
|
||||
// remove held enchantments, update expertise
|
||||
if (slot == EQUIPMENT_SLOT_MAINHAND)
|
||||
{
|
||||
@@ -12231,9 +12162,6 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update)
|
||||
|
||||
if (slot < EQUIPMENT_SLOT_END)
|
||||
{
|
||||
// remove item dependent auras and casts (only weapon and armor slots)
|
||||
RemoveItemDependentAurasAndCasts(pItem);
|
||||
|
||||
// update expertise and armor penetration - passive auras may need it
|
||||
switch (slot)
|
||||
{
|
||||
@@ -24202,9 +24130,9 @@ void Player::RemoveItemDependentAurasAndCasts(Item* pItem)
|
||||
{
|
||||
Aura* aura = itr->second;
|
||||
|
||||
// skip passive (passive item dependent spells work in another way) and not self applied auras
|
||||
// skip not self applied auras
|
||||
SpellInfo const* spellInfo = aura->GetSpellInfo();
|
||||
if (aura->IsPassive() || aura->GetCasterGUID() != GetGUID())
|
||||
if (aura->GetCasterGUID() != GetGUID())
|
||||
{
|
||||
++itr;
|
||||
continue;
|
||||
|
||||
Reference in new issue
Block a user