Core/PacketIO: Implemented CMSG_UPDATE_AREA_TRIGGER_VISUAL

This commit is contained in:
Shauren
2025-06-05 12:31:33 +02:00
parent 8d3b81d499
commit b88f4b7f4f
7 changed files with 61 additions and 13 deletions

View File

@@ -161,13 +161,12 @@ bool AreaTrigger::Create(AreaTriggerCreatePropertiesId areaTriggerCreateProperti
spellForVisuals = sSpellMgr->GetSpellInfo(*GetCreateProperties()->SpellForVisuals, DIFFICULTY_NONE);
if (spellForVisuals)
spellVisual.SpellXSpellVisualID = spellForVisuals->GetSpellXSpellVisualId();
spellVisual.SpellXSpellVisualID = caster ? caster->GetCastSpellXSpellVisualId(spellForVisuals) : spellForVisuals->GetSpellXSpellVisualId();
}
if (spellForVisuals)
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::SpellForVisuals), spellForVisuals->Id);
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::SpellVisual).ModifyValue(&UF::SpellCastVisual::SpellXSpellVisualID), spellVisual.SpellXSpellVisualID);
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::SpellVisual).ModifyValue(&UF::SpellCastVisual::ScriptVisualID), spellVisual.ScriptVisualID);
SetSpellVisual(spellVisual);
if (!IsStaticSpawn())
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::TimeToTargetScale), GetCreateProperties()->TimeToTargetScale != 0 ? GetCreateProperties()->TimeToTargetScale : *m_areaTriggerData->Duration);
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::BoundsRadius2D), GetCreateProperties()->Shape.GetMaxSearchRadius());
@@ -433,6 +432,14 @@ void AreaTrigger::ClearOverrideMoveCurve()
ClearScaleCurve(m_values.ModifyValue(&AreaTrigger::m_areaTriggerData).ModifyValue(&UF::AreaTriggerData::OverrideMoveCurveZ));
}
void AreaTrigger::SetSpellVisual(SpellCastVisual const& visual)
{
auto spellVisualMutator = m_values.ModifyValue(&AreaTrigger::m_areaTriggerData).ModifyValue(&UF::AreaTriggerData::SpellVisual);
SetUpdateFieldValue(spellVisualMutator.ModifyValue(&UF::SpellCastVisual::SpellXSpellVisualID), visual.SpellXSpellVisualID);
SetUpdateFieldValue(spellVisualMutator.ModifyValue(&UF::SpellCastVisual::ScriptVisualID), visual.ScriptVisualID);
}
void AreaTrigger::SetDuration(int32 newDuration)
{
_duration = newDuration;
@@ -1066,17 +1073,16 @@ void AreaTrigger::InitSplineOffsets(std::vector<Position> const& offsets, Option
// This is needed to rotate the spline, following caster orientation
std::vector<G3D::Vector3> rotatedPoints;
rotatedPoints.reserve(offsets.size());
for (Position const& offset : offsets)
rotatedPoints.resize(offsets.size());
for (std::size_t i = 0; i < offsets.size(); ++i)
{
float x = GetPositionX() + (offset.GetPositionX() * angleCos - offset.GetPositionY() * angleSin);
float y = GetPositionY() + (offset.GetPositionY() * angleCos + offset.GetPositionX() * angleSin);
float z = GetPositionZ();
Position const& offset = offsets[i];
rotatedPoints[i].x = GetPositionX() + (offset.GetPositionX() * angleCos - offset.GetPositionY() * angleSin);
rotatedPoints[i].y = GetPositionY() + (offset.GetPositionY() * angleCos + offset.GetPositionX() * angleSin);
rotatedPoints[i].z = GetPositionZ();
UpdateAllowedPositionZ(x, y, z);
z += offset.GetPositionZ();
rotatedPoints.emplace_back(x, y, z);
UpdateAllowedPositionZ(rotatedPoints[i].x, rotatedPoints[i].y, rotatedPoints[i].z);
rotatedPoints[i].z += offset.GetPositionZ();
}
InitSplines(rotatedPoints, overrideSpeed);

View File

@@ -129,6 +129,8 @@ class TC_GAME_API AreaTrigger final : public WorldObject, public GridObject<Area
uint32 GetTimeToTargetPos() const { return m_areaTriggerData->TimeToTargetPos; }
void SetTimeToTargetPos(uint32 timeToTargetPos) { SetUpdateFieldValue(m_values.ModifyValue(&AreaTrigger::m_areaTriggerData).ModifyValue(&UF::AreaTriggerData::TimeToTargetPos), timeToTargetPos); }
void SetSpellVisual(SpellCastVisual const& visual);
int32 GetDuration() const { return _duration; }
int32 GetTotalDuration() const { return _totalDuration; }
void SetDuration(int32 newDuration);

View File

@@ -16,6 +16,8 @@
*/
#include "WorldSession.h"
#include "AreaTrigger.h"
#include "AreaTriggerPackets.h"
#include "CollectionMgr.h"
#include "Common.h"
#include "DatabaseEnv.h"
@@ -607,6 +609,22 @@ void WorldSession::HandleUpdateAuraVisual(WorldPackets::Spells::UpdateAuraVisual
_player->SetChannelVisual({ .SpellXSpellVisualID = spellXspellVisualId });
}
void WorldSession::HandleUpdateAreaTriggerVisual(WorldPackets::AreaTrigger::UpdateAreaTriggerVisual const& updateAreaTriggerVisual)
{
AreaTrigger* target = ObjectAccessor::GetAreaTrigger(*_player, updateAreaTriggerVisual.TargetGUID);
if (!target)
return;
if (target->GetCasterGuid() != _player->GetGUID())
return;
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(target->m_areaTriggerData->SpellForVisuals, _player->GetMap()->GetDifficultyID());
if (!spellInfo)
return;
target->SetSpellVisual({ .SpellXSpellVisualID = _player->GetCastSpellXSpellVisualId(spellInfo) });
}
void WorldSession::HandleKeyboundOverride(WorldPackets::Spells::KeyboundOverride& keyboundOverride)
{
Player* player = GetPlayer();

View File

@@ -113,4 +113,11 @@ WorldPacket const* AreaTriggerPlaySpellVisual::Write()
return &_worldPacket;
}
void UpdateAreaTriggerVisual::Read()
{
_worldPacket >> SpellID;
_worldPacket >> Visual;
_worldPacket >> TargetGUID;
}
}

View File

@@ -20,6 +20,7 @@
#include "Packet.h"
#include "AreaTriggerTemplate.h"
#include "CombatLogPacketsCommon.h"
#include "ObjectGuid.h"
#include "Optional.h"
@@ -102,6 +103,18 @@ namespace WorldPackets
uint32 SpellVisualID = 0;
};
class UpdateAreaTriggerVisual final : public ClientPacket
{
public:
explicit UpdateAreaTriggerVisual(WorldPacket&& packet) : ClientPacket(CMSG_UPDATE_AREA_TRIGGER_VISUAL, std::move(packet)) { }
void Read() override;
int32 SpellID = 0;
Spells::SpellCastVisual Visual;
ObjectGuid TargetGUID;
};
void WriteAreaTriggerSpline(ByteBuffer& data, uint32 timeToTarget, uint32 elapsedTimeForMovement, ::Movement::Spline<float> const& areaTriggerSpline);
ByteBuffer& operator<<(ByteBuffer& data, AreaTriggerOrbitInfo const& areaTriggerCircularMovement);
}

View File

@@ -1009,7 +1009,7 @@ void OpcodeTable::InitializeClientOpcodes()
DEFINE_HANDLER(CMSG_UPDATE_AADC_STATUS, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleChatUpdateAADCStatus);
DEFINE_HANDLER(CMSG_UPDATE_ACCOUNT_BANK_TAB_SETTINGS, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::Handle_NULL);
DEFINE_HANDLER(CMSG_UPDATE_ACCOUNT_DATA, STATUS_AUTHED, PROCESS_THREADUNSAFE, &WorldSession::HandleUpdateAccountData);
DEFINE_HANDLER(CMSG_UPDATE_AREA_TRIGGER_VISUAL, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL);
DEFINE_HANDLER(CMSG_UPDATE_AREA_TRIGGER_VISUAL, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleUpdateAreaTriggerVisual);
DEFINE_HANDLER(CMSG_UPDATE_CLIENT_SETTINGS, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL);
DEFINE_HANDLER(CMSG_UPDATE_CRAFTING_NPC_RECIPES, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL);
DEFINE_HANDLER(CMSG_UPDATE_MISSILE_TRAJECTORY, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleUpdateMissileTrajectory);

View File

@@ -121,6 +121,7 @@ namespace WorldPackets
namespace AreaTrigger
{
class AreaTrigger;
class UpdateAreaTriggerVisual;
}
namespace Artifact
@@ -1312,6 +1313,7 @@ class TC_GAME_API WorldSession
void HandleSetContactNotesOpcode(WorldPackets::Social::SetContactNotes& packet);
void HandleAreaTriggerOpcode(WorldPackets::AreaTrigger::AreaTrigger& packet);
void HandleUpdateAreaTriggerVisual(WorldPackets::AreaTrigger::UpdateAreaTriggerVisual const& updateAreaTriggerVisual);
void HandleSetFactionAtWar(WorldPackets::Character::SetFactionAtWar& packet);
void HandleSetFactionNotAtWar(WorldPackets::Character::SetFactionNotAtWar& packet);