From 9c5330fd999d46ed32cbc5a9bd51abf524caddd3 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 9 May 2022 13:03:59 -0400 Subject: [PATCH] Core/Spells: Implement spell attribute SPELL_ATTR3_NO_DURABILITY_LOSS Port From (https://github.com/TrinityCore/TrinityCore/commit/f205a89c86f64bab531a611aa89766aad1c27e83) --- Source/Framework/Constants/Spells/SpellConst.cs | 2 +- Source/Game/Entities/Unit/Unit.cs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/Framework/Constants/Spells/SpellConst.cs b/Source/Framework/Constants/Spells/SpellConst.cs index 8f2fab150..78b61fbb2 100644 --- a/Source/Framework/Constants/Spells/SpellConst.cs +++ b/Source/Framework/Constants/Spells/SpellConst.cs @@ -1683,7 +1683,7 @@ namespace Framework.Constants Unk2 = 0x04, // 2 BlockableSpell = 0x08, // 3 Only Dmg Class Melee In 3.1.3 IgnoreResurrectionTimer = 0x10, // 4 You Don'T Have To Wait To Be Resurrected With These Spells - Unk5 = 0x20, // 5 + NoDurabilityLoss = 0x20, // 5 No Durability Loss Unk6 = 0x40, // 6 StackForDiffCasters = 0x80, // 7 Separate Stack For Every Caster OnlyTargetPlayers = 0x100, // 8 Can Only Target Players diff --git a/Source/Game/Entities/Unit/Unit.cs b/Source/Game/Entities/Unit/Unit.cs index b358c0c91..3e6f63031 100644 --- a/Source/Game/Entities/Unit/Unit.cs +++ b/Source/Game/Entities/Unit/Unit.cs @@ -2585,6 +2585,9 @@ namespace Game.Entities } } + if (spellProto != null && spellProto.HasAttribute(SpellAttr3.NoDurabilityLoss)) + durabilityLoss = false; + if (killed) Kill(attacker, victim, durabilityLoss, skipSettingDeathState); else @@ -2609,7 +2612,7 @@ namespace Game.Entities else // victim is a player { // random durability for items (HIT TAKEN) - if (WorldConfig.GetFloatValue(WorldCfg.RateDurabilityLossDamage) > RandomHelper.randChance()) + if (durabilityLoss && WorldConfig.GetFloatValue(WorldCfg.RateDurabilityLossDamage) > RandomHelper.randChance()) { byte slot = (byte)RandomHelper.IRand(0, EquipmentSlot.End - 1); victim.ToPlayer().DurabilityPointLossForEquipSlot(slot); @@ -2619,7 +2622,7 @@ namespace Game.Entities if (attacker != null && attacker.IsPlayer()) { // random durability for items (HIT DONE) - if (RandomHelper.randChance(WorldConfig.GetFloatValue(WorldCfg.RateDurabilityLossDamage))) + if (durabilityLoss && RandomHelper.randChance(WorldConfig.GetFloatValue(WorldCfg.RateDurabilityLossDamage))) { byte slot = (byte)RandomHelper.IRand(0, EquipmentSlot.End - 1); attacker.ToPlayer().DurabilityPointLossForEquipSlot(slot);