From 31e0a1f476d353abe3173820764cd57b3af7a7c1 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Fri, 24 Dec 2021 20:50:24 -0500 Subject: [PATCH] Core/Spells: Moved SpellVisual functions from Unit to WorldObject Port From (https://github.com/TrinityCore/TrinityCore/commit/54f607641ac9008a588b8ff635a9ed7ee7a5f976) --- Source/Game/Entities/Object/WorldObject.cs | 114 ++++++++++++++++++++- Source/Game/Entities/Unit/Unit.cs | 89 ---------------- Source/Scripts/Spells/Warrior.cs | 2 +- 3 files changed, 114 insertions(+), 91 deletions(-) diff --git a/Source/Game/Entities/Object/WorldObject.cs b/Source/Game/Entities/Object/WorldObject.cs index 449884deb..e4285d7dc 100644 --- a/Source/Game/Entities/Object/WorldObject.cs +++ b/Source/Game/Entities/Object/WorldObject.cs @@ -2221,7 +2221,7 @@ namespace Game.Entities } } } - + return CastSpell(targets, spellId, args); } @@ -2232,6 +2232,118 @@ namespace Game.Entities CastSpell(targets, spellId, args); } + public void SendPlaySpellVisual(WorldObject target, uint spellVisualId, ushort missReason, ushort reflectStatus, float travelSpeed, bool speedAsTime = false) + { + PlaySpellVisual playSpellVisual = new(); + 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, true); + } + + public void SendPlaySpellVisual(Position targetPosition, float launchDelay, uint spellVisualId, ushort missReason, ushort reflectStatus, float travelSpeed, bool speedAsTime = false) + { + PlaySpellVisual playSpellVisual = new(); + 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, true); + } + + void SendCancelSpellVisual(uint id) + { + CancelSpellVisual cancelSpellVisual = new(); + cancelSpellVisual.Source = GetGUID(); + cancelSpellVisual.SpellVisualID = id; + SendMessageToSet(cancelSpellVisual, true); + } + + void SendPlayOrphanSpellVisual(ObjectGuid target, uint spellVisualId, float travelSpeed, bool speedAsTime = false, bool withSourceOrientation = false) + { + PlayOrphanSpellVisual playOrphanSpellVisual = new(); + playOrphanSpellVisual.SourceLocation = GetPosition(); + if (withSourceOrientation) + { + if (IsGameObject()) + { + var rotation = ToGameObject().GetWorldRotation(); + rotation.toEulerAnglesZYX(out playOrphanSpellVisual.SourceRotation.Z, + out playOrphanSpellVisual.SourceRotation.Y, + out playOrphanSpellVisual.SourceRotation.X); + } + else + playOrphanSpellVisual.SourceRotation = new 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, true); + } + + void SendPlayOrphanSpellVisual(Position targetLocation, uint spellVisualId, float travelSpeed, bool speedAsTime = false, bool withSourceOrientation = false) + { + PlayOrphanSpellVisual playOrphanSpellVisual = new(); + playOrphanSpellVisual.SourceLocation = GetPosition(); + if (withSourceOrientation) + { + if (IsGameObject()) + { + var rotation = ToGameObject().GetWorldRotation(); + rotation.toEulerAnglesZYX(out playOrphanSpellVisual.SourceRotation.Z, + out playOrphanSpellVisual.SourceRotation.Y, + out playOrphanSpellVisual.SourceRotation.X); + } + else + playOrphanSpellVisual.SourceRotation = new 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, true); + } + + void SendCancelOrphanSpellVisual(uint id) + { + CancelOrphanSpellVisual cancelOrphanSpellVisual = new(); + cancelOrphanSpellVisual.SpellVisualID = id; + SendMessageToSet(cancelOrphanSpellVisual, true); + } + + public void SendPlaySpellVisualKit(uint id, uint type, uint duration) + { + PlaySpellVisualKit playSpellVisualKit = new(); + playSpellVisualKit.Unit = GetGUID(); + playSpellVisualKit.KitRecID = id; + playSpellVisualKit.KitType = type; + playSpellVisualKit.Duration = duration; + SendMessageToSet(playSpellVisualKit, true); + } + + void SendCancelSpellVisualKit(uint id) + { + CancelSpellVisualKit cancelSpellVisualKit = new(); + cancelSpellVisualKit.Source = GetGUID(); + cancelSpellVisualKit.SpellVisualKitID = id; + SendMessageToSet(cancelSpellVisualKit, true); + } + + // function based on function Unit::CanAttack from 13850 client public bool IsValidAttackTarget(WorldObject target, SpellInfo bySpell = null) { diff --git a/Source/Game/Entities/Unit/Unit.cs b/Source/Game/Entities/Unit/Unit.cs index 10cd08480..c4f8e2328 100644 --- a/Source/Game/Entities/Unit/Unit.cs +++ b/Source/Game/Entities/Unit/Unit.cs @@ -1042,95 +1042,6 @@ namespace Game.Entities } } - void SendCancelOrphanSpellVisual(uint id) - { - CancelOrphanSpellVisual cancelOrphanSpellVisual = new(); - cancelOrphanSpellVisual.SpellVisualID = id; - SendMessageToSet(cancelOrphanSpellVisual, true); - } - - void SendPlayOrphanSpellVisual(ObjectGuid target, uint spellVisualId, float travelSpeed, bool speedAsTime = false, bool withSourceOrientation = false) - { - PlayOrphanSpellVisual playOrphanSpellVisual = new(); - playOrphanSpellVisual.SourceLocation = GetPosition(); - if (withSourceOrientation) - playOrphanSpellVisual.SourceRotation = new Vector3(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, true); - } - - void SendPlayOrphanSpellVisual(Vector3 targetLocation, uint spellVisualId, float travelSpeed, bool speedAsTime = false, bool withSourceOrientation = false) - { - PlayOrphanSpellVisual playOrphanSpellVisual = new(); - playOrphanSpellVisual.SourceLocation = GetPosition(); - if (withSourceOrientation) - playOrphanSpellVisual.SourceRotation = new Vector3(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, true); - } - - void SendCancelSpellVisual(uint id) - { - CancelSpellVisual cancelSpellVisual = new(); - cancelSpellVisual.Source = GetGUID(); - cancelSpellVisual.SpellVisualID = id; - SendMessageToSet(cancelSpellVisual, true); - } - - public void SendPlaySpellVisual(Unit target, uint spellVisualId, uint missReason, uint reflectStatus, float travelSpeed, bool speedAsTime = false) - { - PlaySpellVisual playSpellVisual = new(); - playSpellVisual.Source = GetGUID(); - playSpellVisual.Target = target.GetGUID(); - playSpellVisual.TargetPosition = target.GetPosition(); - playSpellVisual.SpellVisualID = spellVisualId; - playSpellVisual.TravelSpeed = travelSpeed; - playSpellVisual.MissReason = (ushort)missReason; - playSpellVisual.ReflectStatus = (ushort)reflectStatus; - playSpellVisual.SpeedAsTime = speedAsTime; - SendMessageToSet(playSpellVisual, true); - } - - public void SendPlaySpellVisual(Vector3 targetPosition, float launchDelay, uint spellVisualId, uint missReason, uint reflectStatus, float travelSpeed, bool speedAsTime = false) - { - PlaySpellVisual playSpellVisual = new(); - playSpellVisual.Source = GetGUID(); - playSpellVisual.TargetPosition = targetPosition; - playSpellVisual.LaunchDelay = launchDelay; - playSpellVisual.SpellVisualID = spellVisualId; - playSpellVisual.TravelSpeed = travelSpeed; - playSpellVisual.MissReason = (ushort)missReason; - playSpellVisual.ReflectStatus = (ushort)reflectStatus; - playSpellVisual.SpeedAsTime = speedAsTime; - SendMessageToSet(playSpellVisual, true); - } - - void SendCancelSpellVisualKit(uint id) - { - CancelSpellVisualKit cancelSpellVisualKit = new(); - cancelSpellVisualKit.Source = GetGUID(); - cancelSpellVisualKit.SpellVisualKitID = id; - SendMessageToSet(cancelSpellVisualKit, true); - } - - public void SendPlaySpellVisualKit(uint id, uint type, uint duration) - { - PlaySpellVisualKit playSpellVisualKit = new(); - playSpellVisualKit.Unit = GetGUID(); - playSpellVisualKit.KitRecID = id; - playSpellVisualKit.KitType = type; - playSpellVisualKit.Duration = duration; - SendMessageToSet(playSpellVisualKit, true); - } - void CancelSpellMissiles(uint spellId, bool reverseMissile = false) { bool hasMissile = false; diff --git a/Source/Scripts/Spells/Warrior.cs b/Source/Scripts/Spells/Warrior.cs index cc8c5ea85..00f9a1ec8 100644 --- a/Source/Scripts/Spells/Warrior.cs +++ b/Source/Scripts/Spells/Warrior.cs @@ -120,7 +120,7 @@ namespace Scripts.Spells.Warrior { int timeOffset = (int)(6 * i * aurEff.GetPeriod() / 25); Vector4 loc = GetTarget().MoveSpline.ComputePosition(timeOffset); - GetTarget().SendPlaySpellVisual(new Vector3(loc.X, loc.Y, loc.Z), 0.0f, Misc.SpellVisualBlazingCharge, 0, 0, 1.0f, true); + GetTarget().SendPlaySpellVisual(new Position(loc.X, loc.Y, loc.Z), 0.0f, Misc.SpellVisualBlazingCharge, 0, 0, 1.0f, true); } } }