From ae8abf20d826018e05df9b5198339819f05f2bba Mon Sep 17 00:00:00 2001 From: hondacrx Date: Thu, 17 Feb 2022 09:49:34 -0500 Subject: [PATCH] Core/Spells: Implemented target 115 TARGET_UNIT_SRC_AREA_FURTHEST_ENEMY Port From (https://github.com/TrinityCore/TrinityCore/commit/b50783ae80bdd6595c8a5f262171fdef5659da2d) --- Source/Framework/Constants/Spells/SpellConst.cs | 2 +- Source/Game/Spells/Spell.cs | 12 ++++++++++-- Source/Game/Spells/SpellInfo.cs | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Source/Framework/Constants/Spells/SpellConst.cs b/Source/Framework/Constants/Spells/SpellConst.cs index 3148c4e84..cbd305111 100644 --- a/Source/Framework/Constants/Spells/SpellConst.cs +++ b/Source/Framework/Constants/Spells/SpellConst.cs @@ -2689,7 +2689,7 @@ namespace Framework.Constants Unk112 = 112, Unk113 = 113, Unk114 = 114, - Unk115 = 115, + UnitSrcAreaFurthestEnemy = 115, UnitAndDestLastEnemy = 116, Unk117 = 117, UnitTargetAllyOrRaid = 118, // If target is in your party or raid, all party and raid members will be affected diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 62ad24329..51960095b 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -707,7 +707,7 @@ namespace Game.Spells void SelectImplicitAreaTargets(SpellEffectInfo spellEffectInfo, SpellImplicitTargetInfo targetType, uint effMask) { - WorldObject referer = null; + WorldObject referer; switch (targetType.GetReferenceType()) { case SpellTargetReferenceTypes.Src: @@ -808,12 +808,20 @@ namespace Game.Spells CallScriptObjectAreaTargetSelectHandlers(targets, spellEffectInfo.EffectIndex, targetType); + if (targetType.GetTarget() == Targets.UnitSrcAreaFurthestEnemy) + targets.Sort(new ObjectDistanceOrderPred(referer, false)); + if (!targets.Empty()) { // Other special target selection goes here uint maxTargets = m_spellValue.MaxAffectedTargets; if (maxTargets != 0) - targets.RandomResize(maxTargets); + { + if (targetType.GetTarget() != Targets.UnitSrcAreaFurthestEnemy) + targets.RandomResize(maxTargets); + else if (targets.Count > maxTargets) + targets.Resize(maxTargets); + } foreach (var obj in targets) { diff --git a/Source/Game/Spells/SpellInfo.cs b/Source/Game/Spells/SpellInfo.cs index d385c5612..6b826448d 100644 --- a/Source/Game/Spells/SpellInfo.cs +++ b/Source/Game/Spells/SpellInfo.cs @@ -5038,7 +5038,7 @@ namespace Game.Spells new StaticData(SpellTargetObjectTypes.Dest, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Default, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 112 new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 113 new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 114 - new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 115 + new StaticData(SpellTargetObjectTypes.Unit, SpellTargetReferenceTypes.Src, SpellTargetSelectionCategories.Area, SpellTargetCheckTypes.Enemy, SpellTargetDirectionTypes.None), // 115 TARGET_UNIT_SRC_AREA_FURTHEST_ENEMY new StaticData(SpellTargetObjectTypes.UnitAndDest, SpellTargetReferenceTypes.Last, SpellTargetSelectionCategories.Area, SpellTargetCheckTypes.Enemy, SpellTargetDirectionTypes.None), // 116 TARGET_UNIT_AND_DEST_LAST_ENEMY new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 117 new StaticData(SpellTargetObjectTypes.Unit, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Area, SpellTargetCheckTypes.Raid, SpellTargetDirectionTypes.None), // 118 TARGET_UNIT_TARGET_ALLY_OR_RAID