Core/Spells: Implemented SPELL_EFFECT_TELEPORT_WITH_SPELL_VISUAL_KIT_LOADING_SCREEN
Port From (https://github.com/TrinityCore/TrinityCore/commit/49eb3cf8fea8e5eab0c102c2bfb27fad763ba07e)
This commit is contained in:
@@ -778,6 +778,24 @@ namespace Game.Networking.Packets
|
||||
public bool MountedVisual;
|
||||
}
|
||||
|
||||
class SpellVisualLoadScreen : ServerPacket
|
||||
{
|
||||
public int SpellVisualKitID;
|
||||
public int Delay;
|
||||
|
||||
public SpellVisualLoadScreen(int spellVisualKitId, int delay) : base(ServerOpcodes.SpellVisualLoadScreen, ConnectionType.Instance)
|
||||
{
|
||||
SpellVisualKitID = spellVisualKitId;
|
||||
Delay = delay;
|
||||
}
|
||||
|
||||
public override void Write()
|
||||
{
|
||||
_worldPacket.WriteInt32(SpellVisualKitID);
|
||||
_worldPacket.WriteInt32(Delay);
|
||||
}
|
||||
}
|
||||
|
||||
public class CancelCast : ClientPacket
|
||||
{
|
||||
public CancelCast(WorldPacket packet) : base(packet) { }
|
||||
|
||||
@@ -827,7 +827,7 @@ namespace Game.Spells
|
||||
if (st != null)
|
||||
{
|
||||
// @todo fix this check
|
||||
if (m_spellInfo.HasEffect(SpellEffectName.TeleportUnits) || m_spellInfo.HasEffect(SpellEffectName.Bind))
|
||||
if (m_spellInfo.HasEffect(SpellEffectName.TeleportUnits) || m_spellInfo.HasEffect(SpellEffectName.TeleportWithSpellVisualKitLoadingScreen) || m_spellInfo.HasEffect(SpellEffectName.Bind))
|
||||
dest = new SpellDestination(st.target_X, st.target_Y, st.target_Z, st.target_Orientation, st.target_mapId);
|
||||
else if (st.target_mapId == m_caster.GetMapId())
|
||||
dest = new SpellDestination(st.target_X, st.target_Y, st.target_Z, st.target_Orientation);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
using Framework.Constants;
|
||||
using Framework.Dynamic;
|
||||
using Framework.GameMath;
|
||||
using Game.BattleGrounds;
|
||||
using Game.BattlePets;
|
||||
@@ -712,6 +713,40 @@ namespace Game.Spells
|
||||
}
|
||||
}
|
||||
|
||||
[SpellEffectHandler(SpellEffectName.TeleportWithSpellVisualKitLoadingScreen)]
|
||||
void EffectTeleportUnitsWithVisualLoadingScreen()
|
||||
{
|
||||
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
|
||||
return;
|
||||
|
||||
if (!unitTarget)
|
||||
return;
|
||||
|
||||
// If not exist data for dest location - return
|
||||
if (!m_targets.HasDst())
|
||||
{
|
||||
Log.outError(LogFilter.Spells, $"Spell::EffectTeleportUnitsWithVisualLoadingScreen - does not have a destination for spellId {m_spellInfo.Id}.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Init dest coordinates
|
||||
WorldLocation targetDest = new WorldLocation(destTarget);
|
||||
if (targetDest.GetMapId() == 0xFFFFFFFF)
|
||||
targetDest.SetMapId(unitTarget.GetMapId());
|
||||
|
||||
if (targetDest.GetOrientation() == 0 && m_targets.GetUnitTarget())
|
||||
targetDest.SetOrientation(m_targets.GetUnitTarget().GetOrientation());
|
||||
|
||||
if (effectInfo.MiscValueB != 0)
|
||||
{
|
||||
Player playerTarget = unitTarget.ToPlayer();
|
||||
if (playerTarget != null)
|
||||
playerTarget.SendPacket(new SpellVisualLoadScreen(effectInfo.MiscValueB, effectInfo.MiscValue));
|
||||
}
|
||||
|
||||
unitTarget.m_Events.AddEventAtOffset(new DelayedSpellTeleportEvent(unitTarget, targetDest, unitTarget == m_caster ? TeleportToOptions.Spell : 0, m_spellInfo.Id), TimeSpan.FromMilliseconds(effectInfo.MiscValue));
|
||||
}
|
||||
|
||||
[SpellEffectHandler(SpellEffectName.ApplyAura)]
|
||||
[SpellEffectHandler(SpellEffectName.ApplyAuraOnPet)]
|
||||
void EffectApplyAura()
|
||||
@@ -5814,4 +5849,36 @@ namespace Game.Spells
|
||||
int _chance;
|
||||
byte _charges;
|
||||
}
|
||||
|
||||
class DelayedSpellTeleportEvent : BasicEvent
|
||||
{
|
||||
Unit _target;
|
||||
WorldLocation _targetDest;
|
||||
TeleportToOptions _options;
|
||||
uint _spellId;
|
||||
|
||||
public DelayedSpellTeleportEvent(Unit target, WorldLocation targetDest, TeleportToOptions options, uint spellId)
|
||||
{
|
||||
_target = target;
|
||||
_targetDest = targetDest;
|
||||
_options = options;
|
||||
_spellId = spellId;
|
||||
}
|
||||
|
||||
public override bool Execute(ulong e_time, uint p_time)
|
||||
{
|
||||
if (_targetDest.GetMapId() == _target.GetMapId())
|
||||
_target.NearTeleportTo(_targetDest, (_options & TeleportToOptions.Spell) != 0);
|
||||
else
|
||||
{
|
||||
Player player = _target.ToPlayer();
|
||||
if (player != null)
|
||||
player.TeleportTo(_targetDest, _options);
|
||||
else
|
||||
Log.outError(LogFilter.Spells, $"Spell::EffectTeleportUnitsWithVisualLoadingScreen - spellId {_spellId} attempted to teleport creature to a different map.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user