Core/Entities: cleanup of weapon damage
Port From (https://github.com/TrinityCore/TrinityCore/commit/bf7a624a344f86101b346bc74acd93a017cf3581)
This commit is contained in:
@@ -1868,13 +1868,15 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
if (slot < InventorySlots.BagEnd)
|
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
|
// 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)
|
if (pProto != null && pProto.GetItemSet() != 0)
|
||||||
Item.RemoveItemsSetItem(this, pProto);
|
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);
|
_ApplyItemMods(pItem, slot, false, update);
|
||||||
|
|
||||||
pItem.RemoveItemFlag2(ItemFieldFlags2.Equipped);
|
pItem.RemoveItemFlag2(ItemFieldFlags2.Equipped);
|
||||||
|
|
||||||
// remove item dependent auras and casts (only weapon and armor slots)
|
// 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);
|
SetInvSlot(slot, ObjectGuid.Empty);
|
||||||
|
|
||||||
if (slot < EquipmentSlot.End)
|
if (slot < EquipmentSlot.End)
|
||||||
@@ -3593,7 +3594,6 @@ namespace Game.Entities
|
|||||||
if (ratingMult != null)
|
if (ratingMult != null)
|
||||||
combatRatingMultiplier = CliDB.GetIlvlStatMultiplier(ratingMult, proto.GetInventoryType());
|
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)
|
for (byte i = 0; i < ItemConst.MaxStats; ++i)
|
||||||
{
|
{
|
||||||
int statType = item.GetItemStatType(i);
|
int statType = item.GetItemStatType(i);
|
||||||
|
|||||||
@@ -1711,39 +1711,38 @@ namespace Game.Spells
|
|||||||
|
|
||||||
Unit target = aurApp.GetTarget();
|
Unit target = aurApp.GetTarget();
|
||||||
|
|
||||||
|
//Prevent handling aura twice
|
||||||
AuraType type = GetAuraType();
|
AuraType type = GetAuraType();
|
||||||
|
|
||||||
//Prevent handling aura twice
|
|
||||||
if (apply ? target.GetAuraEffectsByType(type).Count > 1 : target.HasAuraType(type))
|
if (apply ? target.GetAuraEffectsByType(type).Count > 1 : target.HasAuraType(type))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Action<Unit> flagAddFn = null;
|
Action<Unit> flagChangeFunc = null;
|
||||||
Action<Unit> flagRemoveFn = null;
|
|
||||||
byte slot;
|
byte slot;
|
||||||
WeaponAttackType attType;
|
WeaponAttackType attType;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case AuraType.ModDisarm:
|
case AuraType.ModDisarm:
|
||||||
if (apply)
|
if (apply)
|
||||||
flagAddFn = unit => { unit.AddUnitFlag(UnitFlags.Disarmed); };
|
flagChangeFunc = unit => { unit.AddUnitFlag(UnitFlags.Disarmed); };
|
||||||
else
|
else
|
||||||
flagRemoveFn = unit => { unit.RemoveUnitFlag(UnitFlags.Disarmed); };
|
flagChangeFunc = unit => { unit.RemoveUnitFlag(UnitFlags.Disarmed); };
|
||||||
slot = EquipmentSlot.MainHand;
|
slot = EquipmentSlot.MainHand;
|
||||||
attType = WeaponAttackType.BaseAttack;
|
attType = WeaponAttackType.BaseAttack;
|
||||||
break;
|
break;
|
||||||
case AuraType.ModDisarmOffhand:
|
case AuraType.ModDisarmOffhand:
|
||||||
if (apply)
|
if (apply)
|
||||||
flagAddFn = unit => { unit.AddUnitFlag2(UnitFlags2.DisarmOffhand); };
|
flagChangeFunc = unit => { unit.AddUnitFlag2(UnitFlags2.DisarmOffhand); };
|
||||||
else
|
else
|
||||||
flagRemoveFn = unit => { unit.RemoveUnitFlag2(UnitFlags2.DisarmOffhand); };
|
flagChangeFunc = unit => { unit.RemoveUnitFlag2(UnitFlags2.DisarmOffhand); };
|
||||||
slot = EquipmentSlot.OffHand;
|
slot = EquipmentSlot.OffHand;
|
||||||
attType = WeaponAttackType.OffAttack;
|
attType = WeaponAttackType.OffAttack;
|
||||||
break;
|
break;
|
||||||
case AuraType.ModDisarmRanged:
|
case AuraType.ModDisarmRanged:
|
||||||
if (apply)
|
if (apply)
|
||||||
flagAddFn = unit => { unit.AddUnitFlag2(UnitFlags2.DisarmRanged); };
|
flagChangeFunc = unit => { unit.AddUnitFlag2(UnitFlags2.DisarmRanged); };
|
||||||
else
|
else
|
||||||
flagRemoveFn = unit => { unit.RemoveUnitFlag2(UnitFlags2.DisarmRanged); };
|
flagChangeFunc = unit => { unit.RemoveUnitFlag2(UnitFlags2.DisarmRanged); };
|
||||||
slot = EquipmentSlot.MainHand;
|
slot = EquipmentSlot.MainHand;
|
||||||
attType = WeaponAttackType.RangedAttack;
|
attType = WeaponAttackType.RangedAttack;
|
||||||
break;
|
break;
|
||||||
@@ -1751,8 +1750,8 @@ namespace Game.Spells
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if disarm aura is to be removed, remove the flag first to reapply damage/aura mods
|
// set/remove flag before weapon bonuses so it's properly reflected in CanUseAttackType
|
||||||
flagRemoveFn?.Invoke(target);
|
flagChangeFunc?.Invoke(target);
|
||||||
|
|
||||||
// Handle damage modification, shapeshifted druids are not affected
|
// Handle damage modification, shapeshifted druids are not affected
|
||||||
if (target.IsTypeId(TypeId.Player) && !target.IsInFeralForm())
|
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)
|
if (target.IsTypeId(TypeId.Unit) && target.ToCreature().GetCurrentEquipmentId() != 0)
|
||||||
target.UpdateDamagePhysical(attType);
|
target.UpdateDamagePhysical(attType);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user