aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Object
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2021-12-12 19:34:00 +0100
committerShauren <shauren.trinity@gmail.com>2021-12-12 19:34:00 +0100
commit54f607641ac9008a588b8ff635a9ed7ee7a5f976 (patch)
tree6f0e74cf00153fa23fb34a0b6d73a743bbbc92e9 /src/server/game/Entities/Object
parentf61de627e5c367b9716b39c89e374322deb6b255 (diff)
Core/Spells: Moved SpellVisual functions from Unit to WorldObject
Diffstat (limited to 'src/server/game/Entities/Object')
-rw-r--r--src/server/game/Entities/Object/Object.cpp112
-rw-r--r--src/server/game/Entities/Object/Object.h11
2 files changed, 123 insertions, 0 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index e2c6d6a224c..4e1ea49930a 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -41,6 +41,7 @@
#include "ReputationMgr.h"
#include "SpellAuraEffects.h"
#include "SpellMgr.h"
+#include "SpellPackets.h"
#include "TemporarySummon.h"
#include "Totem.h"
#include "Transport.h"
@@ -2609,6 +2610,117 @@ SpellCastResult WorldObject::CastSpell(CastSpellTargetArg const& targets, uint32
return spell->prepare(*targets.Targets, args.TriggeringAura);
}
+void WorldObject::SendPlaySpellVisual(WorldObject* target, uint32 spellVisualId, uint16 missReason, uint16 reflectStatus, float travelSpeed, bool speedAsTime /*= false*/)
+{
+ WorldPackets::Spells::PlaySpellVisual playSpellVisual;
+ playSpellVisual.Source = GetGUID();
+ playSpellVisual.Target = target->GetGUID();
+ playSpellVisual.TargetPosition = target->GetPosition();
+ playSpellVisual.SpellVisualID = spellVisualId;
+ playSpellVisual.TravelSpeed = travelSpeed;
+ playSpellVisual.MissReason = missReason;
+ playSpellVisual.ReflectStatus = reflectStatus;
+ playSpellVisual.SpeedAsTime = speedAsTime;
+ SendMessageToSet(playSpellVisual.Write(), true);
+}
+
+void WorldObject::SendPlaySpellVisual(Position const& targetPosition, float launchDelay, uint32 spellVisualId, uint16 missReason, uint16 reflectStatus, float travelSpeed, bool speedAsTime /*= false*/)
+{
+ WorldPackets::Spells::PlaySpellVisual playSpellVisual;
+ playSpellVisual.Source = GetGUID();
+ playSpellVisual.TargetPosition = targetPosition;
+ playSpellVisual.LaunchDelay = launchDelay;
+ playSpellVisual.SpellVisualID = spellVisualId;
+ playSpellVisual.TravelSpeed = travelSpeed;
+ playSpellVisual.MissReason = missReason;
+ playSpellVisual.ReflectStatus = reflectStatus;
+ playSpellVisual.SpeedAsTime = speedAsTime;
+ SendMessageToSet(playSpellVisual.Write(), true);
+}
+
+void WorldObject::SendCancelSpellVisual(uint32 id)
+{
+ WorldPackets::Spells::CancelSpellVisual cancelSpellVisual;
+ cancelSpellVisual.Source = GetGUID();
+ cancelSpellVisual.SpellVisualID = id;
+ SendMessageToSet(cancelSpellVisual.Write(), true);
+}
+
+void WorldObject::SendPlayOrphanSpellVisual(ObjectGuid const& target, uint32 spellVisualId, float travelSpeed, bool speedAsTime /*= false*/, bool withSourceOrientation /*= false*/)
+{
+ WorldPackets::Spells::PlayOrphanSpellVisual playOrphanSpellVisual;
+ playOrphanSpellVisual.SourceLocation = GetPosition();
+ if (withSourceOrientation)
+ {
+ if (IsGameObject())
+ {
+ QuaternionData rotation = ToGameObject()->GetWorldRotation();
+ rotation.toEulerAnglesZYX(playOrphanSpellVisual.SourceRotation.Pos.m_positionZ,
+ playOrphanSpellVisual.SourceRotation.Pos.m_positionY,
+ playOrphanSpellVisual.SourceRotation.Pos.m_positionX);
+ }
+ else
+ playOrphanSpellVisual.SourceRotation = Position(0.0f, 0.0f, GetOrientation());
+ }
+
+ playOrphanSpellVisual.Target = target; // exclusive with TargetLocation
+ playOrphanSpellVisual.SpellVisualID = spellVisualId;
+ playOrphanSpellVisual.TravelSpeed = travelSpeed;
+ playOrphanSpellVisual.SpeedAsTime = speedAsTime;
+ playOrphanSpellVisual.LaunchDelay = 0.0f;
+ SendMessageToSet(playOrphanSpellVisual.Write(), true);
+}
+
+void WorldObject::SendPlayOrphanSpellVisual(Position const& targetLocation, uint32 spellVisualId, float travelSpeed, bool speedAsTime /*= false*/, bool withSourceOrientation /*= false*/)
+{
+ WorldPackets::Spells::PlayOrphanSpellVisual playOrphanSpellVisual;
+ playOrphanSpellVisual.SourceLocation = GetPosition();
+ if (withSourceOrientation)
+ {
+ if (IsGameObject())
+ {
+ QuaternionData rotation = ToGameObject()->GetWorldRotation();
+ rotation.toEulerAnglesZYX(playOrphanSpellVisual.SourceRotation.Pos.m_positionZ,
+ playOrphanSpellVisual.SourceRotation.Pos.m_positionY,
+ playOrphanSpellVisual.SourceRotation.Pos.m_positionX);
+ }
+ else
+ playOrphanSpellVisual.SourceRotation = Position(0.0f, 0.0f, GetOrientation());
+ }
+
+ playOrphanSpellVisual.TargetLocation = targetLocation; // exclusive with Target
+ playOrphanSpellVisual.SpellVisualID = spellVisualId;
+ playOrphanSpellVisual.TravelSpeed = travelSpeed;
+ playOrphanSpellVisual.SpeedAsTime = speedAsTime;
+ playOrphanSpellVisual.LaunchDelay = 0.0f;
+ SendMessageToSet(playOrphanSpellVisual.Write(), true);
+}
+
+void WorldObject::SendCancelOrphanSpellVisual(uint32 id)
+{
+ WorldPackets::Spells::CancelOrphanSpellVisual cancelOrphanSpellVisual;
+ cancelOrphanSpellVisual.SpellVisualID = id;
+ SendMessageToSet(cancelOrphanSpellVisual.Write(), true);
+}
+
+void WorldObject::SendPlaySpellVisualKit(uint32 id, uint32 type, uint32 duration) const
+{
+ WorldPackets::Spells::PlaySpellVisualKit playSpellVisualKit;
+ playSpellVisualKit.Unit = GetGUID();
+ playSpellVisualKit.KitRecID = id;
+ playSpellVisualKit.KitType = type;
+ playSpellVisualKit.Duration = duration;
+ SendMessageToSet(playSpellVisualKit.Write(), true);
+}
+
+void WorldObject::SendCancelSpellVisualKit(uint32 id)
+{
+ WorldPackets::Spells::CancelSpellVisualKit cancelSpellVisualKit;
+ cancelSpellVisualKit.Source = GetGUID();
+ cancelSpellVisualKit.SpellVisualKitID = id;
+ SendMessageToSet(cancelSpellVisualKit.Write(), true);
+}
+
// function based on function Unit::CanAttack from 13850 client
bool WorldObject::IsValidAttackTarget(WorldObject const* target, SpellInfo const* bySpell /*= nullptr*/) const
{
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index df65dc7665c..2138d83bc78 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -624,6 +624,17 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
// CastSpell's third arg can be a variety of things - check out CastSpellExtraArgs' constructors!
SpellCastResult CastSpell(CastSpellTargetArg const& targets, uint32 spellId, CastSpellExtraArgs const& args = { });
+ void SendPlayOrphanSpellVisual(ObjectGuid const& target, uint32 spellVisualId, float travelSpeed, bool speedAsTime = false, bool withSourceOrientation = false);
+ void SendPlayOrphanSpellVisual(Position const& targetLocation, uint32 spellVisualId, float travelSpeed, bool speedAsTime = false, bool withSourceOrientation = false);
+ void SendCancelOrphanSpellVisual(uint32 id);
+
+ void SendPlaySpellVisual(WorldObject* target, uint32 spellVisualId, uint16 missReason, uint16 reflectStatus, float travelSpeed, bool speedAsTime = false);
+ void SendPlaySpellVisual(Position const& targetPosition, float o, uint32 spellVisualId, uint16 missReason, uint16 reflectStatus, float travelSpeed, bool speedAsTime = false);
+ void SendCancelSpellVisual(uint32 id);
+
+ void SendPlaySpellVisualKit(uint32 id, uint32 type, uint32 duration) const;
+ void SendCancelSpellVisualKit(uint32 id);
+
bool IsValidAttackTarget(WorldObject const* target, SpellInfo const* bySpell = nullptr) const;
bool IsValidAssistTarget(WorldObject const* target, SpellInfo const* bySpell = nullptr) const;