Core/Entities: cleanup of weapon damage

Port From (https://github.com/TrinityCore/TrinityCore/commit/bf7a624a344f86101b346bc74acd93a017cf3581)
This commit is contained in:
hondacrx
2021-09-09 13:49:46 -04:00
parent 56a90ee5ca
commit 30bd4aa6b1
2 changed files with 14 additions and 18 deletions
+4 -4
View File
@@ -1868,13 +1868,15 @@ namespace Game.Entities
{
if (slot < InventorySlots.BagEnd)
{
ItemTemplate pProto = pItem.GetTemplate();
// item set bonuses applied only at equip and removed at unequip, and still active for broken items
ItemTemplate pProto = pItem.GetTemplate();
if (pProto != null && pProto.GetItemSet() != 0)
Item.RemoveItemsSetItem(this, pProto);
// remove here before _ApplyItemMods (for example to register correct damages of unequipped weapon)
m_items[slot] = null;
_ApplyItemMods(pItem, slot, false, update);
pItem.RemoveItemFlag2(ItemFieldFlags2.Equipped);
// remove item dependent auras and casts (only weapon and armor slots)
@@ -1896,7 +1898,6 @@ namespace Game.Entities
}
}
m_items[slot] = null;
SetInvSlot(slot, ObjectGuid.Empty);
if (slot < EquipmentSlot.End)
@@ -3593,7 +3594,6 @@ namespace Game.Entities
if (ratingMult != null)
combatRatingMultiplier = CliDB.GetIlvlStatMultiplier(ratingMult, proto.GetInventoryType());
// req. check at equip, but allow use for extended range if range limit max level, set proper level
for (byte i = 0; i < ItemConst.MaxStats; ++i)
{
int statType = item.GetItemStatType(i);
+10 -14
View File
@@ -1711,39 +1711,38 @@ namespace Game.Spells
Unit target = aurApp.GetTarget();
//Prevent handling aura twice
AuraType type = GetAuraType();
//Prevent handling aura twice
if (apply ? target.GetAuraEffectsByType(type).Count > 1 : target.HasAuraType(type))
return;
Action<Unit> flagAddFn = null;
Action<Unit> flagRemoveFn = null;
Action<Unit> flagChangeFunc = null;
byte slot;
WeaponAttackType attType;
switch (type)
{
case AuraType.ModDisarm:
if (apply)
flagAddFn = unit => { unit.AddUnitFlag(UnitFlags.Disarmed); };
flagChangeFunc = unit => { unit.AddUnitFlag(UnitFlags.Disarmed); };
else
flagRemoveFn = unit => { unit.RemoveUnitFlag(UnitFlags.Disarmed); };
flagChangeFunc = unit => { unit.RemoveUnitFlag(UnitFlags.Disarmed); };
slot = EquipmentSlot.MainHand;
attType = WeaponAttackType.BaseAttack;
break;
case AuraType.ModDisarmOffhand:
if (apply)
flagAddFn = unit => { unit.AddUnitFlag2(UnitFlags2.DisarmOffhand); };
flagChangeFunc = unit => { unit.AddUnitFlag2(UnitFlags2.DisarmOffhand); };
else
flagRemoveFn = unit => { unit.RemoveUnitFlag2(UnitFlags2.DisarmOffhand); };
flagChangeFunc = unit => { unit.RemoveUnitFlag2(UnitFlags2.DisarmOffhand); };
slot = EquipmentSlot.OffHand;
attType = WeaponAttackType.OffAttack;
break;
case AuraType.ModDisarmRanged:
if (apply)
flagAddFn = unit => { unit.AddUnitFlag2(UnitFlags2.DisarmRanged); };
flagChangeFunc = unit => { unit.AddUnitFlag2(UnitFlags2.DisarmRanged); };
else
flagRemoveFn = unit => { unit.RemoveUnitFlag2(UnitFlags2.DisarmRanged); };
flagChangeFunc = unit => { unit.RemoveUnitFlag2(UnitFlags2.DisarmRanged); };
slot = EquipmentSlot.MainHand;
attType = WeaponAttackType.RangedAttack;
break;
@@ -1751,8 +1750,8 @@ namespace Game.Spells
return;
}
// if disarm aura is to be removed, remove the flag first to reapply damage/aura mods
flagRemoveFn?.Invoke(target);
// set/remove flag before weapon bonuses so it's properly reflected in CanUseAttackType
flagChangeFunc?.Invoke(target);
// Handle damage modification, shapeshifted druids are not affected
if (target.IsTypeId(TypeId.Player) && !target.IsInFeralForm())
@@ -1774,9 +1773,6 @@ namespace Game.Spells
}
}
// if disarm effects should be applied, wait to set flag until damage mods are unapplied
flagAddFn?.Invoke(target);
if (target.IsTypeId(TypeId.Unit) && target.ToCreature().GetCurrentEquipmentId() != 0)
target.UpdateDamagePhysical(attType);
}