diff options
author | Shauren <shauren.trinity@gmail.com> | 2021-10-13 11:49:30 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-10-13 11:49:30 +0200 |
commit | 49eb3cf8fea8e5eab0c102c2bfb27fad763ba07e (patch) | |
tree | e0291a574b51edac70e34227028dbcf01e0bb8ee /src | |
parent | 322a71dfb284b62b376e15a2f4dc3ecc89cb5b81 (diff) |
Core/Spells: Implemented SPELL_EFFECT_TELEPORT_WITH_SPELL_VISUAL_KIT_LOADING_SCREEN
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Server/Packets/SpellPackets.cpp | 8 | ||||
-rw-r--r-- | src/server/game/Server/Packets/SpellPackets.h | 12 | ||||
-rw-r--r-- | src/server/game/Server/Protocol/Opcodes.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.h | 1 | ||||
-rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 58 | ||||
-rw-r--r-- | src/server/game/Spells/SpellMgr.cpp | 8 |
7 files changed, 84 insertions, 7 deletions
diff --git a/src/server/game/Server/Packets/SpellPackets.cpp b/src/server/game/Server/Packets/SpellPackets.cpp index 52b5056310d..4a4b9a8623f 100644 --- a/src/server/game/Server/Packets/SpellPackets.cpp +++ b/src/server/game/Server/Packets/SpellPackets.cpp @@ -792,6 +792,14 @@ WorldPacket const* WorldPackets::Spells::PlaySpellVisualKit::Write() return &_worldPacket; } +WorldPacket const* WorldPackets::Spells::SpellVisualLoadScreen::Write() +{ + _worldPacket << int32(SpellVisualKitID); + _worldPacket << int32(Delay); + + return &_worldPacket; +} + void WorldPackets::Spells::CancelCast::Read() { _worldPacket >> CastID; diff --git a/src/server/game/Server/Packets/SpellPackets.h b/src/server/game/Server/Packets/SpellPackets.h index 22b23c388da..349e62473dc 100644 --- a/src/server/game/Server/Packets/SpellPackets.h +++ b/src/server/game/Server/Packets/SpellPackets.h @@ -770,6 +770,18 @@ namespace WorldPackets bool MountedVisual = false; }; + class SpellVisualLoadScreen final : public ServerPacket + { + public: + SpellVisualLoadScreen(int32 spellVisualKitId, int32 delay) : ServerPacket(SMSG_SPELL_VISUAL_LOAD_SCREEN, 4 + 4), + SpellVisualKitID(spellVisualKitId), Delay(delay) { } + + WorldPacket const* Write() override; + + int32 SpellVisualKitID = 0; + int32 Delay = 0; + }; + class CancelCast final : public ClientPacket { public: diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index 1fd3c2b0acf..73ed0d7f593 100644 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -1937,7 +1937,7 @@ void OpcodeTable::Initialize() DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELL_PERIODIC_AURA_LOG, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELL_PREPARE, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELL_START, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELL_VISUAL_LOAD_SCREEN, STATUS_UNHANDLED, CONNECTION_TYPE_INSTANCE); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELL_VISUAL_LOAD_SCREEN, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPLASH_SCREEN_SHOW_LATEST, STATUS_UNHANDLED, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPIRIT_HEALER_CONFIRM, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_STAND_STATE_UPDATE, STATUS_NEVER, CONNECTION_TYPE_REALM); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index dac726f2c56..f7dbd915d07 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -1302,7 +1302,7 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffectInfo const& spellEffectIn if (SpellTargetPosition const* st = sSpellMgr->GetSpellTargetPosition(m_spellInfo->Id, spellEffectInfo.EffectIndex)) { /// @todo fix this check - if (m_spellInfo->HasEffect(SPELL_EFFECT_TELEPORT_UNITS) || m_spellInfo->HasEffect(SPELL_EFFECT_BIND)) + if (m_spellInfo->HasEffect(SPELL_EFFECT_TELEPORT_UNITS) || m_spellInfo->HasEffect(SPELL_EFFECT_TELEPORT_WITH_SPELL_VISUAL_KIT_LOADING_SCREEN) || m_spellInfo->HasEffect(SPELL_EFFECT_BIND)) dest = SpellDestination(st->target_X, st->target_Y, st->target_Z, st->target_Orientation, (int32)st->target_mapId); else if (st->target_mapId == m_caster->GetMapId()) dest = SpellDestination(st->target_X, st->target_Y, st->target_Z, st->target_Orientation); diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index f80df3dad8b..903930d58cd 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -247,6 +247,7 @@ class TC_GAME_API Spell void EffectInstaKill(); void EffectDummy(); void EffectTeleportUnits(); + void EffectTeleportUnitsWithVisualLoadingScreen(); void EffectApplyAura(); void EffectSendEvent(); void EffectPowerBurn(); 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) diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index c0261282783..07f3ce24714 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -1191,13 +1191,13 @@ void SpellMgr::LoadSpellTargetPositions() MapEntry const* mapEntry = sMapStore.LookupEntry(st.target_mapId); if (!mapEntry) { - TC_LOG_ERROR("sql.sql", "Spell (Id: %u, EffectIndex: %u) is using a non-existant MapID (ID: %u).", spellId, effIndex, st.target_mapId); + TC_LOG_ERROR("sql.sql", "Spell (Id: %u, EffectIndex: %u) is using a non-existant MapID (ID: %u).", spellId, uint32(effIndex), st.target_mapId); continue; } if (st.target_X == 0 && st.target_Y == 0 && st.target_Z == 0) { - TC_LOG_ERROR("sql.sql", "Spell (Id: %u, EffectIndex: %u): target coordinates not provided.", spellId, effIndex); + TC_LOG_ERROR("sql.sql", "Spell (Id: %u, EffectIndex: %u): target coordinates not provided.", spellId, uint32(effIndex)); continue; } @@ -1210,7 +1210,7 @@ void SpellMgr::LoadSpellTargetPositions() if (effIndex >= spellInfo->GetEffects().size()) { - TC_LOG_ERROR("sql.sql", "Spell (Id: %u, EffectIndex: %u) listed in `spell_target_position` does not have an effect at index %u.", spellId, effIndex, effIndex); + TC_LOG_ERROR("sql.sql", "Spell (Id: %u, EffectIndex: %u) listed in `spell_target_position` does not have an effect at index %u.", spellId, uint32(effIndex), uint32(effIndex)); continue; } @@ -1228,7 +1228,7 @@ void SpellMgr::LoadSpellTargetPositions() } else { - TC_LOG_ERROR("sql.sql", "Spell (Id: %u, effIndex: %u) listed in `spell_target_position` does not have a target TARGET_DEST_DB (17).", spellId, effIndex); + TC_LOG_ERROR("sql.sql", "Spell (Id: %u, effIndex: %u) listed in `spell_target_position` does not have a target TARGET_DEST_DB (17).", spellId, uint32(effIndex)); continue; } |