From 1dbb3330fc3a9a7733d0d26258b5bd60272266cb Mon Sep 17 00:00:00 2001 From: Zela Zrgn Date: Fri, 5 May 2023 14:47:10 -0400 Subject: [PATCH 1/3] SPELL_CAST_FAILED combat log event is not being triggered by SMSG_SPELL_FAILED_OTHER so added a addon message to send alongside --- .../World/Client/PacketHandlers/SpellHandler.cs | 9 +++++++++ HermesProxy/World/WowGuid.cs | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/HermesProxy/World/Client/PacketHandlers/SpellHandler.cs b/HermesProxy/World/Client/PacketHandlers/SpellHandler.cs index 667eb0a1..fcb8e0dc 100644 --- a/HermesProxy/World/Client/PacketHandlers/SpellHandler.cs +++ b/HermesProxy/World/Client/PacketHandlers/SpellHandler.cs @@ -334,6 +334,15 @@ void HandleSpellFailedOther(WorldPacket packet) spell2.SpellXSpellVisualID = spellVisual; spell2.Reason = reason; SendPacketToClient(spell2); + + string? guidString = casterUnit.ToUnitGUID(); + if (guidString != null) + { + uint language = (uint)Language.AddonBfA; + WowGuid128 playerGuid = GetSession().GameState.CurrentPlayerGuid; + ChatPkt chat = new ChatPkt(GetSession(), ChatMessageTypeModern.Addon, $"SMSG_SPELL_FAILED_OTHER-{guidString}", language, playerGuid, "", playerGuid, "", "", ChatFlags.None, "HermesProxySMSG"); + SendPacketToClient(chat); + } } [PacketHandler(Opcode.SMSG_SPELL_START)] diff --git a/HermesProxy/World/WowGuid.cs b/HermesProxy/World/WowGuid.cs index ced6a34c..69c9b2d3 100644 --- a/HermesProxy/World/WowGuid.cs +++ b/HermesProxy/World/WowGuid.cs @@ -331,6 +331,21 @@ public override ulong GetCounter() return Low & 0xFFFFFFFFFF; // CreationBits } + public string? ToUnitGUID() + { + string lowHex = Low.ToString("X16"); + switch (GetHighType()) + { + case HighGuidType.Player: + return $"Player-{GetRealmId()}-{lowHex.Substring(lowHex.Length - 8)}"; + case HighGuidType.Creature: + return $"Creature-{GetSubType()}-{GetRealmId()}-{GetServerId()}-{GetMapId()}-{GetEntry()}-{lowHex.Substring(lowHex.Length - 10)}"; + default: + Log.Print(LogType.Warn, "unsupported GUID type: ({GetHighType()})"); + return null; + } + } + public override string ToString() { if (Low == 0 && High == 0) From 5f609e3dd8b5bd67c314795a03f771a16425708d Mon Sep 17 00:00:00 2001 From: Zela Zrgn Date: Fri, 5 May 2023 20:32:17 -0400 Subject: [PATCH 2/3] UnitGUID now works for pets and cleaned up the HermesProxySMSG message format --- HermesProxy/World/Client/PacketHandlers/SpellHandler.cs | 6 +++--- HermesProxy/World/WowGuid.cs | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/HermesProxy/World/Client/PacketHandlers/SpellHandler.cs b/HermesProxy/World/Client/PacketHandlers/SpellHandler.cs index fcb8e0dc..40e86ec6 100644 --- a/HermesProxy/World/Client/PacketHandlers/SpellHandler.cs +++ b/HermesProxy/World/Client/PacketHandlers/SpellHandler.cs @@ -335,12 +335,12 @@ void HandleSpellFailedOther(WorldPacket packet) spell2.Reason = reason; SendPacketToClient(spell2); - string? guidString = casterUnit.ToUnitGUID(); - if (guidString != null) + string? casterUnitGUID = casterUnit.ToUnitGUID(); + if (casterUnitGUID != null) { uint language = (uint)Language.AddonBfA; WowGuid128 playerGuid = GetSession().GameState.CurrentPlayerGuid; - ChatPkt chat = new ChatPkt(GetSession(), ChatMessageTypeModern.Addon, $"SMSG_SPELL_FAILED_OTHER-{guidString}", language, playerGuid, "", playerGuid, "", "", ChatFlags.None, "HermesProxySMSG"); + ChatPkt chat = new ChatPkt(GetSession(), ChatMessageTypeModern.Addon, $"SMSG_SPELL_FAILED_OTHER:{casterUnitGUID},{spellId}", language, playerGuid, "", playerGuid, "", "", ChatFlags.None, "HermesProxySMSG"); SendPacketToClient(chat); } } diff --git a/HermesProxy/World/WowGuid.cs b/HermesProxy/World/WowGuid.cs index 69c9b2d3..7bd1d395 100644 --- a/HermesProxy/World/WowGuid.cs +++ b/HermesProxy/World/WowGuid.cs @@ -334,12 +334,14 @@ public override ulong GetCounter() public string? ToUnitGUID() { string lowHex = Low.ToString("X16"); - switch (GetHighType()) + HighGuidType highType = GetHighType(); + switch (highType) { case HighGuidType.Player: - return $"Player-{GetRealmId()}-{lowHex.Substring(lowHex.Length - 8)}"; + return $"{highType}-{GetRealmId()}-{lowHex.Substring(lowHex.Length - 8)}"; case HighGuidType.Creature: - return $"Creature-{GetSubType()}-{GetRealmId()}-{GetServerId()}-{GetMapId()}-{GetEntry()}-{lowHex.Substring(lowHex.Length - 10)}"; + case HighGuidType.Pet: + return $"{highType}-{GetSubType()}-{GetRealmId()}-{GetServerId()}-{GetMapId()}-{GetEntry()}-{lowHex.Substring(lowHex.Length - 10)}"; default: Log.Print(LogType.Warn, "unsupported GUID type: ({GetHighType()})"); return null; From 6b8fcd511f0d1a8fe4002f168b85869d8b20d59a Mon Sep 17 00:00:00 2001 From: Zela Zrgn Date: Sat, 6 May 2023 09:29:47 -0400 Subject: [PATCH 3/3] added workaround for missing SPELL_AURA_REFRESH --- .../World/Client/PacketHandlers/SpellHandler.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/HermesProxy/World/Client/PacketHandlers/SpellHandler.cs b/HermesProxy/World/Client/PacketHandlers/SpellHandler.cs index 40e86ec6..7fbb41ca 100644 --- a/HermesProxy/World/Client/PacketHandlers/SpellHandler.cs +++ b/HermesProxy/World/Client/PacketHandlers/SpellHandler.cs @@ -443,8 +443,19 @@ void HandleSpellGo(WorldPacket packet) } if (!spell.Cast.CasterUnit.IsEmpty() && GameData.AuraSpells.Contains((uint)spell.Cast.SpellID)) { + string? casterUnitGUID = spell.Cast.CasterUnit.ToUnitGUID(); foreach (WowGuid128 target in spell.Cast.HitTargets) + { GetSession().GameState.StoreLastAuraCasterOnTarget(target, (uint)spell.Cast.SpellID, spell.Cast.CasterUnit); + string? targetUnitGUID = target.ToUnitGUID(); + if (casterUnitGUID != null && targetUnitGUID != null) + { + uint language = (uint)Language.AddonBfA; + WowGuid128 playerGuid = GetSession().GameState.CurrentPlayerGuid; + ChatPkt chat = new ChatPkt(GetSession(), ChatMessageTypeModern.Addon, $"SMSG_SPELL_GO_AURA:{casterUnitGUID},{targetUnitGUID},{spell.Cast.SpellID}", language, playerGuid, "", playerGuid, "", "", ChatFlags.None, "HermesProxySMSG"); + SendPacketToClient(chat); + } + } } SendPacketToClient(spell);