From 4164384b72298158d02c00d70b54b2768924ecad Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sun, 21 Jun 2020 14:33:32 -0400 Subject: [PATCH] Core/Spells: Implemented new target types Port From (https://github.com/TrinityCore/TrinityCore/commit/fce9fca9002e5bfc99990b9108aa56447e5001bd) --- .../Framework/Constants/Spells/SpellConst.cs | 21 +++-- Source/Game/Spells/Spell.cs | 93 +++++++++++++++++-- Source/Game/Spells/SpellInfo.cs | 16 ++-- Source/Game/Spells/SpellManager.cs | 3 + 4 files changed, 108 insertions(+), 25 deletions(-) diff --git a/Source/Framework/Constants/Spells/SpellConst.cs b/Source/Framework/Constants/Spells/SpellConst.cs index f5fc2c116..7efc333f4 100644 --- a/Source/Framework/Constants/Spells/SpellConst.cs +++ b/Source/Framework/Constants/Spells/SpellConst.cs @@ -2432,21 +2432,21 @@ namespace Framework.Constants Unk115 = 115, Unk116 = 116, Unk117 = 117, - Unk118 = 118, - Unk119 = 119, - Unk120 = 120, + UnitTargetAllyOrRaid = 118, // If target is in your party or raid, all party and raid members will be affected + CorpseSrcAreaRaid = 119, + UnitCasterAndSummons = 120, Unk121 = 121, - Unk122 = 122, - Unk123 = 123, + UnitAreaThreatList = 122, // any unit on threat list + UnitAreaTapList = 123, Unk124 = 124, - Unk125 = 125, + DestCasterGround = 125, Unk126 = 126, Unk127 = 127, Unk128 = 128, ConeEntry129 = 129, Unk130 = 130, - Unk131 = 131, - Unk132 = 132, + DestSummoner = 131, + DestTargetAlly = 132, Unk133 = 133, Unk134 = 134, Unk135 = 135, @@ -2513,7 +2513,10 @@ namespace Framework.Constants Party, Raid, RaidClass, - Passenger + Passenger, + Summoned, + Threat, + Tap } public enum SpellTargetDirectionTypes diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 8cd7bfafb..189cd1985 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -661,7 +661,7 @@ namespace Game.Spells GridMapTypeMask containerTypeMask = GetSearcherTypeMask(objectType, condList); if (containerTypeMask != 0) { - var spellCone = new WorldObjectSpellConeTargetCheck(MathFunctions.DegToRad(m_spellInfo.ConeAngle), radius, m_caster, m_spellInfo, selectionType, condList); + var spellCone = new WorldObjectSpellConeTargetCheck(MathFunctions.DegToRad(m_spellInfo.ConeAngle), m_spellInfo.Width != 0 ? m_spellInfo.Width : m_caster.GetCombatReach(), radius, m_caster, m_spellInfo, selectionType, condList); var searcher = new WorldObjectListSearcher(m_caster, targets, spellCone, containerTypeMask); SearchTargets(searcher, containerTypeMask, m_caster, m_caster.GetPosition(), radius); @@ -720,7 +720,7 @@ namespace Game.Spells if (referer == null) return; - Position center = null; + Position center; switch (targetType.GetReferenceType()) { case SpellTargetReferenceTypes.Src: @@ -743,6 +743,52 @@ namespace Game.Spells if (effect == null) return; + switch (targetType.GetTarget()) + { + case Targets.UnitTargetAllyOrRaid: + Unit targetedUnit = m_targets.GetUnitTarget(); + if (targetedUnit != null) + { + if (!m_caster.IsInRaidWith(targetedUnit)) + { + targets.Add(m_targets.GetUnitTarget()); + + CallScriptObjectAreaTargetSelectHandlers(targets, effIndex, targetType); + + if (!targets.Empty()) + { + // Other special target selection goes here + uint maxTargets = m_spellValue.MaxAffectedTargets; + if (maxTargets != 0) + targets.RandomResize(maxTargets); + + foreach (WorldObject target in targets) + { + Unit unit = target.ToUnit(); + if (unit != null) + AddUnitTarget(unit, effMask, false, true, center); + else + { + GameObject gObjTarget = target.ToGameObject(); + if (gObjTarget != null) + AddGOTarget(gObjTarget, effMask); + } + } + } + + return; + } + + center = targetedUnit; + } + break; + case Targets.UnitCasterAndSummons: + targets.Add(m_caster); + break; + default: + break; + } + float radius = effect.CalcRadius(m_caster) * m_spellValue.RadiusMod; SearchAreaTargets(targets, radius, center, referer, targetType.GetObjectType(), targetType.GetCheckType(), effect.ImplicitTargetConditions); @@ -833,6 +879,18 @@ namespace Game.Spells dest = new SpellDestination(x, y, liquidLevel, m_caster.GetOrientation()); break; } + case Targets.DestCasterGround: + m_caster.UpdateAllowedPositionZ(dest.Position.GetPositionX(), dest.Position.GetPositionY(), ref dest.Position.posZ); + break; + case Targets.DestSummoner: + TempSummon casterSummon = m_caster.ToTempSummon(); + if (casterSummon != null) + { + Unit summoner = casterSummon.GetSummoner(); + if (summoner != null) + dest = new SpellDestination(summoner); + } + break; default: SpellEffectInfo effect = m_spellInfo.GetEffect(effIndex); if (effect != null) @@ -888,6 +946,7 @@ namespace Game.Spells { case Targets.DestTargetEnemy: case Targets.DestAny: + case Targets.DestTargetAlly: break; default: SpellEffectInfo effect = m_spellInfo.GetEffect(effIndex); @@ -7635,8 +7694,7 @@ namespace Game.Spells public class WorldObjectSpellTargetCheck : ICheck { - public WorldObjectSpellTargetCheck(Unit caster, Unit referer, SpellInfo spellInfo, - SpellTargetCheckTypes selectionType, List condList) + public WorldObjectSpellTargetCheck(Unit caster, Unit referer, SpellInfo spellInfo, SpellTargetCheckTypes selectionType, List condList) { _caster = caster; _referer = referer; @@ -7654,6 +7712,7 @@ namespace Game.Spells { if (_spellInfo.CheckTarget(_caster, obj, true) != SpellCastResult.SpellCastOk) return false; + Unit unitTarget = obj.ToUnit(); Corpse corpseTarget = obj.ToCorpse(); if (corpseTarget != null) @@ -7665,6 +7724,7 @@ namespace Game.Spells else return false; } + if (unitTarget != null) { switch (_targetSelectionType) @@ -7700,6 +7760,22 @@ namespace Game.Spells if (!_referer.IsInRaidWith(unitTarget)) return false; break; + case SpellTargetCheckTypes.Summoned: + if (!unitTarget.IsSummon()) + return false; + if (unitTarget.ToTempSummon().GetSummonerGUID() != _caster.GetGUID()) + return false; + break; + case SpellTargetCheckTypes.Threat: + if (_referer.GetThreatManager().GetThreat(unitTarget, true) <= 0.0f) + return false; + break; + case SpellTargetCheckTypes.Tap: + if (_referer.GetTypeId() != TypeId.Unit || unitTarget.GetTypeId() != TypeId.Player) + return false; + if (!_referer.ToCreature().IsTappedBy(unitTarget.ToPlayer())) + return false; + break; default: break; } @@ -7722,8 +7798,7 @@ namespace Game.Spells { float _range; Position _position; - public WorldObjectSpellNearbyTargetCheck(float range, Unit caster, SpellInfo spellInfo, - SpellTargetCheckTypes selectionType, List condList) + public WorldObjectSpellNearbyTargetCheck(float range, Unit caster, SpellInfo spellInfo, SpellTargetCheckTypes selectionType, List condList) : base(caster, caster, spellInfo, selectionType, condList) { _range = range; @@ -7776,10 +7851,11 @@ namespace Game.Spells public class WorldObjectSpellConeTargetCheck : WorldObjectSpellAreaTargetCheck { - public WorldObjectSpellConeTargetCheck(float coneAngle, float range, Unit caster, SpellInfo spellInfo, SpellTargetCheckTypes selectionType, List condList) + public WorldObjectSpellConeTargetCheck(float coneAngle, float lineWidth, float range, Unit caster, SpellInfo spellInfo, SpellTargetCheckTypes selectionType, List condList) : base(range, caster.GetPosition(), caster, caster, spellInfo, selectionType, condList) { _coneAngle = coneAngle; + _lineWidth = lineWidth; } public override bool Invoke(WorldObject target) @@ -7791,7 +7867,7 @@ namespace Game.Spells } else if (_spellInfo.HasAttribute(SpellCustomAttributes.ConeLine)) { - if (!_caster.HasInLine(target, target.GetCombatReach(), _caster.GetCombatReach())) + if (!_caster.HasInLine(target, target.GetCombatReach(), _lineWidth)) return false; } else @@ -7806,6 +7882,7 @@ namespace Game.Spells } float _coneAngle; + float _lineWidth; } public class WorldObjectSpellTrajTargetCheck : WorldObjectSpellTargetCheck diff --git a/Source/Game/Spells/SpellInfo.cs b/Source/Game/Spells/SpellInfo.cs index cdc7064e5..9865fff96 100644 --- a/Source/Game/Spells/SpellInfo.cs +++ b/Source/Game/Spells/SpellInfo.cs @@ -4679,21 +4679,21 @@ namespace Game.Spells new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 115 new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 116 new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 117 - new StaticData(SpellTargetObjectTypes.Unit, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Area, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 118 - new StaticData(SpellTargetObjectTypes.Unit, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Area, SpellTargetCheckTypes.Raid, SpellTargetDirectionTypes.None), // 119 - new StaticData(SpellTargetObjectTypes.Unit, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Area, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 120 + new StaticData(SpellTargetObjectTypes.Unit, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Area, SpellTargetCheckTypes.Raid, SpellTargetDirectionTypes.None), // 118 TARGET_UNIT_TARGET_ALLY_OR_RAID + new StaticData(SpellTargetObjectTypes.Corpse, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Area, SpellTargetCheckTypes.Raid, SpellTargetDirectionTypes.None), // 119 TARGET_CORPSE_SRC_AREA_RAID + new StaticData(SpellTargetObjectTypes.Unit, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Area, SpellTargetCheckTypes.Summoned, SpellTargetDirectionTypes.None), // 120 TARGET_UNIT_SELF_AND_SUMMONS new StaticData(SpellTargetObjectTypes.Unit, SpellTargetReferenceTypes.Target, SpellTargetSelectionCategories.Default, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 121 - new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 122 - new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 123 + new StaticData(SpellTargetObjectTypes.Unit, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Area, SpellTargetCheckTypes.Threat, SpellTargetDirectionTypes.None), // 122 TARGET_UNIT_AREA_THREAT_LIST + new StaticData(SpellTargetObjectTypes.Unit, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Area, SpellTargetCheckTypes.Tap, SpellTargetDirectionTypes.None), // 123 TARGET_UNIT_AREA_TAP_LIST new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 124 - new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 125 + new StaticData(SpellTargetObjectTypes.Dest, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Default, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 125 TARGET_DEST_CASTER_GROUND new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 126 new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 127 new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 128 new StaticData(SpellTargetObjectTypes.Unit, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Cone, SpellTargetCheckTypes.Entry, SpellTargetDirectionTypes.Front), // 129 new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 130 - new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 131 - new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 132 + new StaticData(SpellTargetObjectTypes.Dest, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Default, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 131 TARGET_DEST_SUMMONER + new StaticData(SpellTargetObjectTypes.Dest, SpellTargetReferenceTypes.Target, SpellTargetSelectionCategories.Default, SpellTargetCheckTypes.Ally, SpellTargetDirectionTypes.None), // 132 TARGET_DEST_TARGET_ALLY new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 133 new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 134 new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 135 diff --git a/Source/Game/Spells/SpellManager.cs b/Source/Game/Spells/SpellManager.cs index a076cfa06..ee3d47500 100644 --- a/Source/Game/Spells/SpellManager.cs +++ b/Source/Game/Spells/SpellManager.cs @@ -2596,6 +2596,9 @@ namespace Game.Entities if (talentSpells.Contains(spellInfo.Id)) spellInfo.AttributesCu |= SpellCustomAttributes.IsTalent; + if (MathFunctions.fuzzyNe(spellInfo.Width, 0.0f)) + spellInfo.AttributesCu |= SpellCustomAttributes.ConeLine; + switch (spellInfo.SpellFamilyName) { case SpellFamilyNames.Warrior: