From cbc2597adb72fdb01a1abcadc868a666eb6380c0 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 6 May 2020 17:26:03 -0400 Subject: [PATCH] Core/Spells: implement SMSG_MOUNT_RESULT and use it for transformed mounting cases Port From (https://github.com/TrinityCore/TrinityCore/commit/fb0d2ed2b96c314ea144b3524195ae96878e0079) --- .../Framework/Constants/Spells/SpellConst.cs | 15 +++++++++++++ Source/Game/Network/Packets/SpellPackets.cs | 12 ++++++++++ Source/Game/Spells/Spell.cs | 22 ++++++++++++++++++- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/Source/Framework/Constants/Spells/SpellConst.cs b/Source/Framework/Constants/Spells/SpellConst.cs index 977429b0e..dce16c78d 100644 --- a/Source/Framework/Constants/Spells/SpellConst.cs +++ b/Source/Framework/Constants/Spells/SpellConst.cs @@ -2557,4 +2557,19 @@ namespace Framework.Constants WhiteHit = 0x01, // enchant shall only proc off white hits (not abilities) Limit60 = 0x02 // enchant effects shall be reduced past lvl 60 } + + public enum MountResult + { + InvalidMountee = 0, + TooFarAway = 1, + AlreadyMounted = 2, + NotMountable = 3, + NotYourPet = 4, + Other = 5, + Looting = 6, + RaceCantMount = 7, + Shapeshifted = 8, + ForcedDismount = 9, + Ok = 10 // never sent + } } diff --git a/Source/Game/Network/Packets/SpellPackets.cs b/Source/Game/Network/Packets/SpellPackets.cs index 77719e2d3..24e3538b9 100644 --- a/Source/Game/Network/Packets/SpellPackets.cs +++ b/Source/Game/Network/Packets/SpellPackets.cs @@ -1107,6 +1107,18 @@ namespace Game.Network.Packets uint LoadingScreenID; } + class MountResultPacket : ServerPacket + { + public MountResult() : base(ServerOpcodes.MountResult, ConnectionType.Instance) { } + + public override void Write() + { + _worldPacket.WriteUInt32(Result); + } + + public uint Result; + } + //Structs public struct SpellLogPowerData { diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index abcf2c8a2..ff9e87de6 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -3465,6 +3465,23 @@ namespace Game.Spells caster.SendPacket(packet); } + void SendMountResult(MountResult result) + { + if (result == MountResult.Ok) + return; + + if (!m_caster.IsPlayer()) + return; + + Player caster = m_caster.ToPlayer(); + if (caster.IsLoading()) // don't send mount results at loading time + return; + + MountResultPacket packet = new MountResultPacket(); + packet.Result = (uint)result; + caster.SendPacket(packet); + } + void SendSpellStart() { if (!IsNeedSendToClient()) @@ -5264,7 +5281,10 @@ namespace Game.Spells return SpellCastResult.NoMountsAllowed; if (m_caster.IsInDisallowedMountForm()) - return SpellCastResult.NotShapeshift; + { + SendMountResult(MountResult.Shapeshifted); // mount result gets sent before the cast result + return SpellCastResult.DontReport; + } break; }