Core/Spells: Implemented spell target type 142
Port From (https://github.com/TrinityCore/TrinityCore/commit/3790c1e3dad36727279b22a33eea8e27418c4283)
This commit is contained in:
@@ -2830,7 +2830,7 @@ namespace Framework.Constants
|
||||
Unk139 = 139,
|
||||
DestCasterClumpCentroid = 140, // NYI
|
||||
Unk141 = 141,
|
||||
Unk142 = 142,
|
||||
DestNearbyEntryOrDB = 142,
|
||||
Unk143 = 143,
|
||||
Unk144 = 144,
|
||||
Unk145 = 145,
|
||||
|
||||
@@ -631,6 +631,26 @@ namespace Game.Spells
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (targetType.GetTarget() == Targets.DestNearbyEntryOrDB)
|
||||
{
|
||||
SpellTargetPosition st = Global.SpellMgr.GetSpellTargetPosition(m_spellInfo.Id, spellEffectInfo.EffectIndex);
|
||||
if (st != null)
|
||||
{
|
||||
SpellDestination dest = new(m_caster);
|
||||
if (st.target_mapId == m_caster.GetMapId() && m_caster.IsInDist(st.target_X, st.target_Y, st.target_Z, range))
|
||||
dest = new SpellDestination(st.target_X, st.target_Y, st.target_Z, st.target_Orientation);
|
||||
else
|
||||
{
|
||||
float randomRadius1 = spellEffectInfo.CalcRadius(m_caster);
|
||||
if (randomRadius1 > 0.0f)
|
||||
m_caster.MovePositionToFirstCollision(dest.Position, randomRadius1, targetType.CalcDirectionAngle());
|
||||
}
|
||||
|
||||
CallScriptDestinationTargetSelectHandlers(ref dest, spellEffectInfo.EffectIndex, targetType);
|
||||
m_targets.SetDst(dest);
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -638,6 +658,22 @@ namespace Game.Spells
|
||||
}
|
||||
|
||||
WorldObject target = SearchNearbyTarget(range, targetType.GetObjectType(), targetType.GetCheckType(), condList);
|
||||
float randomRadius = 0.0f;
|
||||
switch (targetType.GetTarget())
|
||||
{
|
||||
case Targets.DestNearbyEntryOrDB:
|
||||
// if we are here then there was no db target
|
||||
if (target == null)
|
||||
{
|
||||
target = m_caster;
|
||||
// radius is only meant to be randomized when using caster fallback
|
||||
randomRadius = spellEffectInfo.CalcRadius(m_caster);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
Log.outDebug(LogFilter.Spells, "Spell.SelectImplicitNearbyTargets: cannot find nearby target for spell ID {0}, effect {1}", m_spellInfo.Id, spellEffectInfo.EffectIndex);
|
||||
@@ -695,6 +731,9 @@ namespace Game.Spells
|
||||
break;
|
||||
case SpellTargetObjectTypes.Dest:
|
||||
SpellDestination dest = new(target);
|
||||
if (randomRadius > 0.0f)
|
||||
target.MovePositionToFirstCollision(dest.Position, randomRadius, targetType.CalcDirectionAngle());
|
||||
|
||||
if (m_spellInfo.HasAttribute(SpellAttr4.UseFacingFromSpell))
|
||||
dest.Position.SetOrientation(spellEffectInfo.PositionFacing);
|
||||
|
||||
|
||||
@@ -5192,7 +5192,7 @@ namespace Game.Spells
|
||||
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 139
|
||||
new StaticData(SpellTargetObjectTypes.Dest, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 140 TARGET_DEST_CASTER_CLUMP_CENTROID
|
||||
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 141
|
||||
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 142
|
||||
new StaticData(SpellTargetObjectTypes.Dest, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Nearby, SpellTargetCheckTypes.Entry, SpellTargetDirectionTypes.FrontRight), // 142 TARGET_DEST_NEARBY_ENTRY_OR_DB
|
||||
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 143
|
||||
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 144
|
||||
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 145
|
||||
|
||||
@@ -1043,7 +1043,13 @@ namespace Game.Entities
|
||||
else
|
||||
st.target_Orientation = spellInfo.GetEffect(effIndex).PositionFacing;
|
||||
|
||||
if (spellInfo.GetEffect(effIndex).TargetA.GetTarget() == Targets.DestDb || spellInfo.GetEffect(effIndex).TargetB.GetTarget() == Targets.DestDb)
|
||||
bool hasTarget(Targets target)
|
||||
{
|
||||
SpellEffectInfo spellEffectInfo = spellInfo.GetEffect(effIndex);
|
||||
return spellEffectInfo.TargetA.GetTarget() == target || spellEffectInfo.TargetB.GetTarget() == target;
|
||||
}
|
||||
|
||||
if (hasTarget(Targets.DestDb) || hasTarget(Targets.DestNearbyEntryOrDB))
|
||||
{
|
||||
var key = new KeyValuePair<uint, uint>(spellId, effIndex);
|
||||
mSpellTargetPositions[key] = st;
|
||||
|
||||
Reference in New Issue
Block a user