Core/Spells: Implemented spell target type 142

Port From (https://github.com/TrinityCore/TrinityCore/commit/3790c1e3dad36727279b22a33eea8e27418c4283)
This commit is contained in:
hondacrx
2023-05-30 05:18:29 -04:00
parent 11575d6d39
commit 77febfdee5
4 changed files with 48 additions and 3 deletions
+39
View File
@@ -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);