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, Unk115 = 115,
Unk116 = 116, Unk116 = 116,
Unk117 = 117, Unk117 = 117,
Unk118 = 118, UnitTargetAllyOrRaid = 118, // If target is in your party or raid, all party and raid members will be affected
Unk119 = 119, CorpseSrcAreaRaid = 119,
Unk120 = 120, UnitCasterAndSummons = 120,
Unk121 = 121, Unk121 = 121,
Unk122 = 122, UnitAreaThreatList = 122, // any unit on threat list
Unk123 = 123, UnitAreaTapList = 123,
Unk124 = 124, Unk124 = 124,
Unk125 = 125, DestCasterGround = 125,
Unk126 = 126, Unk126 = 126,
Unk127 = 127, Unk127 = 127,
Unk128 = 128, Unk128 = 128,
ConeEntry129 = 129, ConeEntry129 = 129,
Unk130 = 130, Unk130 = 130,
Unk131 = 131, DestSummoner = 131,
Unk132 = 132, DestTargetAlly = 132,
Unk133 = 133, Unk133 = 133,
Unk134 = 134, Unk134 = 134,
Unk135 = 135, Unk135 = 135,
@@ -2513,7 +2513,10 @@ namespace Framework.Constants
Party, Party,
Raid, Raid,
RaidClass, RaidClass,
Passenger Passenger,
Summoned,
Threat,
Tap
} }
public enum SpellTargetDirectionTypes public enum SpellTargetDirectionTypes
+85 -8
View File
@@ -661,7 +661,7 @@ namespace Game.Spells
GridMapTypeMask containerTypeMask = GetSearcherTypeMask(objectType, condList); GridMapTypeMask containerTypeMask = GetSearcherTypeMask(objectType, condList);
if (containerTypeMask != 0) 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); var searcher = new WorldObjectListSearcher(m_caster, targets, spellCone, containerTypeMask);
SearchTargets(searcher, containerTypeMask, m_caster, m_caster.GetPosition(), radius); SearchTargets(searcher, containerTypeMask, m_caster, m_caster.GetPosition(), radius);
@@ -720,7 +720,7 @@ namespace Game.Spells
if (referer == null) if (referer == null)
return; return;
Position center = null; Position center;
switch (targetType.GetReferenceType()) switch (targetType.GetReferenceType())
{ {
case SpellTargetReferenceTypes.Src: case SpellTargetReferenceTypes.Src:
@@ -743,6 +743,52 @@ namespace Game.Spells
if (effect == null) if (effect == null)
return; 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; float radius = effect.CalcRadius(m_caster) * m_spellValue.RadiusMod;
SearchAreaTargets(targets, radius, center, referer, targetType.GetObjectType(), targetType.GetCheckType(), effect.ImplicitTargetConditions); 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()); dest = new SpellDestination(x, y, liquidLevel, m_caster.GetOrientation());
break; 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: default:
SpellEffectInfo effect = m_spellInfo.GetEffect(effIndex); SpellEffectInfo effect = m_spellInfo.GetEffect(effIndex);
if (effect != null) if (effect != null)
@@ -888,6 +946,7 @@ namespace Game.Spells
{ {
case Targets.DestTargetEnemy: case Targets.DestTargetEnemy:
case Targets.DestAny: case Targets.DestAny:
case Targets.DestTargetAlly:
break; break;
default: default:
SpellEffectInfo effect = m_spellInfo.GetEffect(effIndex); SpellEffectInfo effect = m_spellInfo.GetEffect(effIndex);
@@ -7635,8 +7694,7 @@ namespace Game.Spells
public class WorldObjectSpellTargetCheck : ICheck<WorldObject> public class WorldObjectSpellTargetCheck : ICheck<WorldObject>
{ {
public WorldObjectSpellTargetCheck(Unit caster, Unit referer, SpellInfo spellInfo, public WorldObjectSpellTargetCheck(Unit caster, Unit referer, SpellInfo spellInfo, SpellTargetCheckTypes selectionType, List<Condition> condList)
SpellTargetCheckTypes selectionType, List<Condition> condList)
{ {
_caster = caster; _caster = caster;
_referer = referer; _referer = referer;
@@ -7654,6 +7712,7 @@ namespace Game.Spells
{ {
if (_spellInfo.CheckTarget(_caster, obj, true) != SpellCastResult.SpellCastOk) if (_spellInfo.CheckTarget(_caster, obj, true) != SpellCastResult.SpellCastOk)
return false; return false;
Unit unitTarget = obj.ToUnit(); Unit unitTarget = obj.ToUnit();
Corpse corpseTarget = obj.ToCorpse(); Corpse corpseTarget = obj.ToCorpse();
if (corpseTarget != null) if (corpseTarget != null)
@@ -7665,6 +7724,7 @@ namespace Game.Spells
else else
return false; return false;
} }
if (unitTarget != null) if (unitTarget != null)
{ {
switch (_targetSelectionType) switch (_targetSelectionType)
@@ -7700,6 +7760,22 @@ namespace Game.Spells
if (!_referer.IsInRaidWith(unitTarget)) if (!_referer.IsInRaidWith(unitTarget))
return false; return false;
break; 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: default:
break; break;
} }
@@ -7722,8 +7798,7 @@ namespace Game.Spells
{ {
float _range; float _range;
Position _position; Position _position;
public WorldObjectSpellNearbyTargetCheck(float range, Unit caster, SpellInfo spellInfo, public WorldObjectSpellNearbyTargetCheck(float range, Unit caster, SpellInfo spellInfo, SpellTargetCheckTypes selectionType, List<Condition> condList)
SpellTargetCheckTypes selectionType, List<Condition> condList)
: base(caster, caster, spellInfo, selectionType, condList) : base(caster, caster, spellInfo, selectionType, condList)
{ {
_range = range; _range = range;
@@ -7776,10 +7851,11 @@ namespace Game.Spells
public class WorldObjectSpellConeTargetCheck : WorldObjectSpellAreaTargetCheck 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) : base(range, caster.GetPosition(), caster, caster, spellInfo, selectionType, condList)
{ {
_coneAngle = coneAngle; _coneAngle = coneAngle;
_lineWidth = lineWidth;
} }
public override bool Invoke(WorldObject target) public override bool Invoke(WorldObject target)
@@ -7791,7 +7867,7 @@ namespace Game.Spells
} }
else if (_spellInfo.HasAttribute(SpellCustomAttributes.ConeLine)) else if (_spellInfo.HasAttribute(SpellCustomAttributes.ConeLine))
{ {
if (!_caster.HasInLine(target, target.GetCombatReach(), _caster.GetCombatReach())) if (!_caster.HasInLine(target, target.GetCombatReach(), _lineWidth))
return false; return false;
} }
else else
@@ -7806,6 +7882,7 @@ namespace Game.Spells
} }
float _coneAngle; float _coneAngle;
float _lineWidth;
} }
public class WorldObjectSpellTrajTargetCheck : WorldObjectSpellTargetCheck 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), // 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), // 116
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 117 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), // 118 TARGET_UNIT_TARGET_ALLY_OR_RAID
new StaticData(SpellTargetObjectTypes.Unit, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Area, SpellTargetCheckTypes.Raid, SpellTargetDirectionTypes.None), // 119 new StaticData(SpellTargetObjectTypes.Corpse, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Area, SpellTargetCheckTypes.Raid, SpellTargetDirectionTypes.None), // 119 TARGET_CORPSE_SRC_AREA_RAID
new StaticData(SpellTargetObjectTypes.Unit, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Area, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 120 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.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.Unit, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Area, SpellTargetCheckTypes.Threat, SpellTargetDirectionTypes.None), // 122 TARGET_UNIT_AREA_THREAT_LIST
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 123 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), // 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), // 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), // 127
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 128 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.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), // 130
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 131 new StaticData(SpellTargetObjectTypes.Dest, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Default, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 131 TARGET_DEST_SUMMONER
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 132 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), // 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), // 134
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 135 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)) if (talentSpells.Contains(spellInfo.Id))
spellInfo.AttributesCu |= SpellCustomAttributes.IsTalent; spellInfo.AttributesCu |= SpellCustomAttributes.IsTalent;
if (MathFunctions.fuzzyNe(spellInfo.Width, 0.0f))
spellInfo.AttributesCu |= SpellCustomAttributes.ConeLine;
switch (spellInfo.SpellFamilyName) switch (spellInfo.SpellFamilyName)
{ {
case SpellFamilyNames.Warrior: case SpellFamilyNames.Warrior: