aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/SpellEffects.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2021-10-13 11:49:30 +0200
committerShauren <shauren.trinity@gmail.com>2021-10-13 11:49:30 +0200
commit49eb3cf8fea8e5eab0c102c2bfb27fad763ba07e (patch)
treee0291a574b51edac70e34227028dbcf01e0bb8ee /src/server/game/Spells/SpellEffects.cpp
parent322a71dfb284b62b376e15a2f4dc3ecc89cb5b81 (diff)
Core/Spells: Implemented SPELL_EFFECT_TELEPORT_WITH_SPELL_VISUAL_KIT_LOADING_SCREEN
Diffstat (limited to 'src/server/game/Spells/SpellEffects.cpp')
-rw-r--r--src/server/game/Spells/SpellEffects.cpp58
1 files changed, 57 insertions, 1 deletions
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 584508dc595..7f5c679c7a4 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -96,7 +96,7 @@ NonDefaultConstructible<SpellEffectHandlerFn> SpellEffectHandlers[TOTAL_SPELL_EF
&Spell::EffectNULL, // 12 SPELL_EFFECT_PORTAL
&Spell::EffectTeleportToReturnPoint, // 13 SPELL_EFFECT_TELEPORT_TO_RETURN_POINT
&Spell::EffectNULL, // 14 SPELL_EFFECT_INCREASE_CURRENCY_CAP
- &Spell::EffectNULL, // 15 SPELL_EFFECT_TELEPORT_WITH_SPELL_VISUAL_KIT_LOADING_SCREEN
+ &Spell::EffectTeleportUnitsWithVisualLoadingScreen, // 15 SPELL_EFFECT_TELEPORT_WITH_SPELL_VISUAL_KIT_LOADING_SCREEN
&Spell::EffectQuestComplete, // 16 SPELL_EFFECT_QUEST_COMPLETE
&Spell::EffectWeaponDmg, // 17 SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL
&Spell::EffectResurrect, // 18 SPELL_EFFECT_RESURRECT
@@ -1037,6 +1037,62 @@ void Spell::EffectTeleportUnits()
}
}
+class DelayedSpellTeleportEvent : public BasicEvent
+{
+public:
+ explicit DelayedSpellTeleportEvent(Unit* target, WorldLocation const& targetDest, uint32 options, uint32 spellId)
+ : _target(target), _targetDest(targetDest), _options(options), _spellId(spellId){ }
+
+ bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) override
+ {
+ if (_targetDest.GetMapId() == _target->GetMapId())
+ _target->NearTeleportTo(_targetDest, (_options & TELE_TO_SPELL) != 0);
+ else if (Player* player = _target->ToPlayer())
+ player->TeleportTo(_targetDest, _options);
+ else
+ TC_LOG_ERROR("spells", "Spell::EffectTeleportUnitsWithVisualLoadingScreen - spellId %u attempted to teleport creature to a different map.", _spellId);
+
+ return true;
+ }
+
+private:
+ Unit* _target;
+ WorldLocation _targetDest;
+ uint32 _options;
+ uint32 _spellId;
+};
+
+void Spell::EffectTeleportUnitsWithVisualLoadingScreen()
+{
+ if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
+ return;
+
+ if (!unitTarget)
+ return;
+
+ // If not exist data for dest location - return
+ if (!m_targets.HasDst())
+ {
+ TC_LOG_ERROR("spells", "Spell::EffectTeleportUnitsWithVisualLoadingScreen - does not have a destination for spellId %u.", m_spellInfo->Id);
+ return;
+ }
+
+ // Init dest coordinates
+ WorldLocation targetDest(*destTarget);
+ if (targetDest.GetMapId() == MAPID_INVALID)
+ targetDest.m_mapId = unitTarget->GetMapId();
+
+ if (!targetDest.GetOrientation() && m_targets.GetUnitTarget())
+ targetDest.SetOrientation(m_targets.GetUnitTarget()->GetOrientation());
+
+ if (effectInfo->MiscValueB)
+ if (Player* playerTarget = unitTarget->ToPlayer())
+ playerTarget->SendDirectMessage(WorldPackets::Spells::SpellVisualLoadScreen(effectInfo->MiscValueB, effectInfo->MiscValue).Write());
+
+ unitTarget->m_Events.AddEventAtOffset(new DelayedSpellTeleportEvent(unitTarget, targetDest, unitTarget == m_caster ? TELE_TO_SPELL : 0, m_spellInfo->Id),
+ Milliseconds(effectInfo->MiscValue));
+}
+
void Spell::EffectApplyAura()
{
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)