Core/Spells Implement targets 133, 134, 135 : TARGET_UNIT_LINE_CASTER_TO_DEST_***

Port From (https://github.com/TrinityCore/TrinityCore/commit/fb6761c273d518eae6bab72fc9c2a2b6f93eec83)
This commit is contained in:
hondacrx
2021-08-15 09:05:23 -04:00
parent 66280abe58
commit c3367b7508
7 changed files with 1654 additions and 1544 deletions
@@ -2661,9 +2661,9 @@ namespace Framework.Constants
Unk130 = 130,
DestSummoner = 131,
DestTargetAlly = 132,
Unk133 = 133,
Unk134 = 134,
Unk135 = 135,
UnitLineCasterToDestAlly = 133,
UnitLineCasterToDestEnemy = 134,
UnitLineCasterToDest = 135,
Unk136 = 136,
Unk137 = 137,
Unk138 = 138,
@@ -2690,7 +2690,8 @@ namespace Framework.Constants
Nearby,
Cone,
Area,
Traj
Traj,
Line
}
public enum SpellTargetReferenceTypes
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -286,7 +286,7 @@ namespace Game.Entities
return IsInDist2d(center, radius) && Math.Abs(verticalDelta) <= height;
}
public bool HasInArc(float arc, Position obj, float border = 2.0f)
public bool HasInArc(float arc, Position obj, float border = 2.0f, float? orientation = null)
{
// always have self in arc
if (obj == this)
@@ -296,7 +296,7 @@ namespace Game.Entities
arc = NormalizeOrientation(arc);
float angle = GetAngle(obj);
angle -= GetOrientation();
angle -= orientation.HasValue ? orientation.Value : GetOrientation();
// move angle to range -pi ... +pi
angle = NormalizeOrientation(angle);
@@ -308,13 +308,13 @@ namespace Game.Entities
return ((angle >= lborder) && (angle <= rborder));
}
public bool HasInLine(Position pos, float objSize, float width)
public bool HasInLine(Position pos, float objSize, float width, float? orientation = null)
{
if (!HasInArc(MathFunctions.PI, pos))
if (!HasInArc(MathFunctions.PI, pos, 2.0f, orientation))
return false;
width += objSize;
float angle = GetRelativeAngle(pos);
float angle = GetAngle(pos) - (orientation.HasValue ? orientation.Value : GetOrientation());
return Math.Abs(Math.Sin(angle)) * GetExactDist2d(pos.GetPositionX(), pos.GetPositionY()) < width;
}
+1
View File
@@ -288,6 +288,7 @@ namespace Game.Scripting
return true;
case SpellTargetSelectionCategories.Cone: // AREA
case SpellTargetSelectionCategories.Area: // AREA
case SpellTargetSelectionCategories.Line: // AREA
return _area;
case SpellTargetSelectionCategories.Default:
switch (targetInfo.GetObjectType())
+103
View File
@@ -337,6 +337,7 @@ namespace Game.Spells
case SpellTargetSelectionCategories.Nearby:
case SpellTargetSelectionCategories.Cone:
case SpellTargetSelectionCategories.Area:
case SpellTargetSelectionCategories.Line:
// targets for effect already selected
if (Convert.ToBoolean(effectMask & processedEffectMask))
return;
@@ -386,6 +387,9 @@ namespace Game.Spells
SelectImplicitTrajTargets(effIndex, targetType);
break;
case SpellTargetSelectionCategories.Line:
SelectImplicitLineTargets(effIndex, targetType, effectMask);
break;
case SpellTargetSelectionCategories.Default:
switch (targetType.GetObjectType())
{
@@ -1238,6 +1242,76 @@ namespace Game.Spells
veh.SetLastShootPos(m_targets.GetDstPos());
}
void SelectImplicitLineTargets(uint effIndex, SpellImplicitTargetInfo targetType, uint effMask)
{
List<WorldObject> targets = new();
SpellTargetObjectTypes objectType = targetType.GetObjectType();
SpellTargetCheckTypes selectionType = targetType.GetCheckType();
SpellEffectInfo effect = m_spellInfo.GetEffect(effIndex);
if (effect == null)
return;
Position dst;
switch (targetType.GetReferenceType())
{
case SpellTargetReferenceTypes.Src:
dst = m_targets.GetSrcPos();
break;
case SpellTargetReferenceTypes.Dest:
dst = m_targets.GetDstPos();
break;
case SpellTargetReferenceTypes.Caster:
dst = m_caster;
break;
case SpellTargetReferenceTypes.Target:
dst = m_targets.GetUnitTarget();
break;
default:
Cypher.Assert(false, "Spell.SelectImplicitLineTargets: received not implemented target reference type");
return;
}
var condList = effect.ImplicitTargetConditions;
float radius = effect.CalcRadius(m_caster) * m_spellValue.RadiusMod;
GridMapTypeMask containerTypeMask = GetSearcherTypeMask(objectType, condList);
if (containerTypeMask != 0)
{
WorldObjectSpellLineTargetCheck check = new(m_caster, dst, m_spellInfo.Width != 0 ? m_spellInfo.Width : m_caster.GetCombatReach(), radius, m_caster, m_spellInfo, selectionType, condList, objectType);
WorldObjectListSearcher searcher = new(m_caster, targets, check, containerTypeMask);
SearchTargets(searcher, containerTypeMask, m_caster, m_caster, radius);
CallScriptObjectAreaTargetSelectHandlers(targets, effIndex, targetType);
if (!targets.Empty())
{
// Other special target selection goes here
uint maxTargets = m_spellValue.MaxAffectedTargets;
if (maxTargets != 0)
{
if (maxTargets < targets.Count)
{
targets.Sort(new ObjectDistanceOrderPred(m_caster));
targets.Resize(maxTargets);
}
}
foreach (var obj in targets)
{
Unit unit = obj.ToUnit();
if (unit != null)
AddUnitTarget(unit, effMask, false);
else
{
GameObject gObjTarget = obj.ToGameObject();
if (gObjTarget != null)
AddGOTarget(gObjTarget, effMask);
}
}
}
}
}
void SelectEffectTypeImplicitTargets(uint effIndex)
{
// special case for SPELL_EFFECT_SUMMON_RAF_FRIEND and SPELL_EFFECT_SUMMON_PLAYER
@@ -7956,6 +8030,7 @@ namespace Game.Spells
{
float _range;
Position _position;
public WorldObjectSpellNearbyTargetCheck(float range, Unit caster, SpellInfo spellInfo, SpellTargetCheckTypes selectionType, List<Condition> condList, SpellTargetObjectTypes objectType)
: base(caster, caster, spellInfo, selectionType, condList, objectType)
{
@@ -7979,6 +8054,7 @@ namespace Game.Spells
{
float _range;
Position _position;
public WorldObjectSpellAreaTargetCheck(float range, Position position, Unit caster, Unit referer, SpellInfo spellInfo, SpellTargetCheckTypes selectionType, List<Condition> condList, SpellTargetObjectTypes objectType)
: base(caster, referer, spellInfo, selectionType, condList, objectType)
{
@@ -8068,6 +8144,33 @@ namespace Game.Spells
}
}
public class WorldObjectSpellLineTargetCheck : WorldObjectSpellAreaTargetCheck
{
Position _srcPosition;
Position _dstPosition;
float _lineWidth;
public WorldObjectSpellLineTargetCheck(Position srcPosition, Position dstPosition, float lineWidth, float range, Unit caster, SpellInfo spellInfo, SpellTargetCheckTypes selectionType, List<Condition> condList, SpellTargetObjectTypes objectType)
: base(range, caster, caster, caster, spellInfo, selectionType, condList, objectType)
{
_srcPosition = srcPosition;
_dstPosition = dstPosition;
_lineWidth = lineWidth;
}
public override bool Invoke(WorldObject target)
{
float angle = _caster.GetOrientation();
if (_srcPosition != _dstPosition)
angle = _srcPosition.GetAngle(_dstPosition);
if (!_caster.HasInLine(target, target.GetCombatReach(), _lineWidth, angle))
return false;
return base.Invoke(target);
}
}
public class SpellEvent : BasicEvent
{
public SpellEvent(Spell spell)
File diff suppressed because it is too large Load Diff
+3
View File
@@ -3630,6 +3630,9 @@ namespace Game.Entities
if (spellInfo.ActiveIconFileDataId == 135754) // flight
spellInfo.Attributes |= SpellAttr0.Passive;
if (spellInfo.IsSingleTarget())
spellInfo.MaxAffectedTargets = 1;
}
SummonPropertiesRecord properties = CliDB.SummonPropertiesStorage.LookupByKey(121);