diff options
author | ariel- <ariel-@users.noreply.github.com> | 2018-03-14 03:40:20 -0300 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-09-06 20:54:19 +0200 |
commit | bf7a624a344f86101b346bc74acd93a017cf3581 (patch) | |
tree | 49ea8fe519c6620f194cce18fe93bd3ae27cb3d1 /src | |
parent | b3162e1fb5c200c59058884e76f6318d19c00f07 (diff) |
Core/Entities: cleanup of weapon damage
- AP multiplier wasn't correctly reflected after unequipping a weapon
- Correctly set base damages at unequip
Closes #21610
(cherry picked from commit 8cf7eda8c12f8fd5c64245cb24c102c62967a030)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 9 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.cpp | 28 |
2 files changed, 15 insertions, 22 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index bd783df2295..1e681ee82a2 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -7528,7 +7528,6 @@ void Player::_ApplyItemBonuses(Item* item, uint8 slot, bool apply) if (GtCombatRatingsMultByILvl const* ratingMult = sCombatRatingsMultByILvlGameTable.GetRow(itemLevel)) combatRatingMultiplier = GetIlvlStatMultiplier(ratingMult, proto->GetInventoryType()); - // req. check at equip, but allow use for extended range if range limit max level, set proper level for (uint8 i = 0; i < MAX_ITEM_PROTO_STATS; ++i) { int32 statType = item->GetItemStatType(i); @@ -12555,12 +12554,13 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update) { if (slot < INVENTORY_SLOT_BAG_END) { - ItemTemplate const* pProto = pItem->GetTemplate(); // item set bonuses applied only at equip and removed at unequip, and still active for broken items - - if (pProto && pProto->GetItemSet()) + ItemTemplate const* pProto = ASSERT_NOTNULL(pItem->GetTemplate()); + if (pProto->GetItemSet()) RemoveItemsSetItem(this, pProto); + // remove here before _ApplyItemMods (for example to register correct damages of unequipped weapon) + m_items[slot] = nullptr; _ApplyItemMods(pItem, slot, false, update); pItem->RemoveItemFlag2(ITEM_FIELD_FLAG2_EQUIPPED); @@ -12585,7 +12585,6 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update) } } - m_items[slot] = nullptr; SetInvSlot(slot, ObjectGuid::Empty); if (slot < EQUIPMENT_SLOT_END) diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index cf4cb47a925..d44c339e5ce 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -2162,14 +2162,12 @@ void AuraEffect::HandleAuraModDisarm(AuraApplication const* aurApp, uint8 mode, Unit* target = aurApp->GetTarget(); + //Prevent handling aura twice AuraType type = GetAuraType(); - - // Prevent handling aura twice if (apply ? target->GetAuraEffectsByType(type).size() > 1 : target->HasAuraType(type)) return; - void(*flagAddFn)(Unit* u) = nullptr; - void(*flagRemoveFn)(Unit* u) = nullptr; + void(*flagChangeFunc)(Unit* u) = nullptr; uint32 slot; WeaponAttackType attType; @@ -2177,25 +2175,25 @@ void AuraEffect::HandleAuraModDisarm(AuraApplication const* aurApp, uint8 mode, { case SPELL_AURA_MOD_DISARM: if (apply) - flagAddFn = [](Unit* u) { u->AddUnitFlag(UNIT_FLAG_DISARMED); }; + flagChangeFunc = [](Unit* u) { u->AddUnitFlag(UNIT_FLAG_DISARMED); }; else - flagRemoveFn = [](Unit* u) { u->RemoveUnitFlag(UNIT_FLAG_DISARMED); }; + flagChangeFunc = [](Unit* u) { u->RemoveUnitFlag(UNIT_FLAG_DISARMED); }; slot = EQUIPMENT_SLOT_MAINHAND; attType = BASE_ATTACK; break; case SPELL_AURA_MOD_DISARM_OFFHAND: if (apply) - flagAddFn = [](Unit* u) { u->AddUnitFlag2(UNIT_FLAG2_DISARM_OFFHAND); }; + flagChangeFunc = [](Unit* u) { u->AddUnitFlag2(UNIT_FLAG2_DISARM_OFFHAND); }; else - flagRemoveFn = [](Unit* u) { u->RemoveUnitFlag2(UNIT_FLAG2_DISARM_OFFHAND); }; + flagChangeFunc = [](Unit* u) { u->RemoveUnitFlag2(UNIT_FLAG2_DISARM_OFFHAND); }; slot = EQUIPMENT_SLOT_OFFHAND; attType = OFF_ATTACK; break; case SPELL_AURA_MOD_DISARM_RANGED: if (apply) - flagAddFn = [](Unit* u) { u->AddUnitFlag2(UNIT_FLAG2_DISARM_RANGED); }; + flagChangeFunc = [](Unit* u) { u->AddUnitFlag2(UNIT_FLAG2_DISARM_RANGED); }; else - flagRemoveFn = [](Unit* u) { u->RemoveUnitFlag2(UNIT_FLAG2_DISARM_RANGED); }; + flagChangeFunc = [](Unit* u) { u->RemoveUnitFlag2(UNIT_FLAG2_DISARM_RANGED); }; slot = EQUIPMENT_SLOT_MAINHAND; attType = RANGED_ATTACK; break; @@ -2203,9 +2201,9 @@ void AuraEffect::HandleAuraModDisarm(AuraApplication const* aurApp, uint8 mode, return; } - // if disarm aura is to be removed, remove the flag first to reapply damage/aura mods - if (flagRemoveFn) - flagRemoveFn(target); + // set/remove flag before weapon bonuses so it's properly reflected in CanUseAttackType + if (flagChangeFunc) + flagChangeFunc(target); // Handle damage modification, shapeshifted druids are not affected if (target->GetTypeId() == TYPEID_PLAYER && !target->IsInFeralForm()) @@ -2225,10 +2223,6 @@ void AuraEffect::HandleAuraModDisarm(AuraApplication const* aurApp, uint8 mode, } } - // if disarm effects should be applied, wait to set flag until damage mods are unapplied - if (flagAddFn) - flagAddFn(target); - if (target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->GetCurrentEquipmentId()) target->UpdateDamagePhysical(attType); } |