Core/Spells: Implemented new target types

Port From (https://github.com/TrinityCore/TrinityCore/commit/fce9fca9002e5bfc99990b9108aa56447e5001bd)
This commit is contained in:
hondacrx
2020-06-21 14:33:32 -04:00
parent dc68794b32
commit 4164384b72
4 changed files with 108 additions and 25 deletions
@@ -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
+85 -8
View File
@@ -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<WorldObject>
{
public WorldObjectSpellTargetCheck(Unit caster, Unit referer, SpellInfo spellInfo,
SpellTargetCheckTypes selectionType, List<Condition> condList)
public WorldObjectSpellTargetCheck(Unit caster, Unit referer, SpellInfo spellInfo, SpellTargetCheckTypes selectionType, List<Condition> 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<Condition> condList)
public WorldObjectSpellNearbyTargetCheck(float range, Unit caster, SpellInfo spellInfo, SpellTargetCheckTypes selectionType, List<Condition> 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<Condition> condList)
public WorldObjectSpellConeTargetCheck(float coneAngle, float lineWidth, float range, Unit caster, SpellInfo spellInfo, SpellTargetCheckTypes selectionType, List<Condition> 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
+8 -8
View File
@@ -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
+3
View File
@@ -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: