Core/Spells: Implemented SPELL_EFFECT_TELEPORT_WITH_SPELL_VISUAL_KIT_LOADING_SCREEN

This commit is contained in:
Shauren
2021-10-13 11:49:30 +02:00
parent 322a71dfb2
commit 49eb3cf8fe
7 changed files with 84 additions and 7 deletions

View File

@@ -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;

View File

@@ -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:

View File

@@ -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);

View File

@@ -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);

View File

@@ -247,6 +247,7 @@ class TC_GAME_API Spell
void EffectInstaKill();
void EffectDummy();
void EffectTeleportUnits();
void EffectTeleportUnitsWithVisualLoadingScreen();
void EffectApplyAura();
void EffectSendEvent();
void EffectPowerBurn();

View File

@@ -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)

View File

@@ -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;
}