mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-26 11:52:32 +01:00
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 8cf7eda8c1)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user