Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added addon message for SMSG_SPELL_FAILED_OTHER #305

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions HermesProxy/World/Client/PacketHandlers/SpellHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,15 @@ void HandleSpellFailedOther(WorldPacket packet)
spell2.SpellXSpellVisualID = spellVisual;
spell2.Reason = reason;
SendPacketToClient(spell2);

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:{casterUnitGUID},{spellId}", language, playerGuid, "", playerGuid, "", "", ChatFlags.None, "HermesProxySMSG");
SendPacketToClient(chat);
}
}

[PacketHandler(Opcode.SMSG_SPELL_START)]
Expand Down Expand Up @@ -434,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);
Expand Down
17 changes: 17 additions & 0 deletions HermesProxy/World/WowGuid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,23 @@ public override ulong GetCounter()
return Low & 0xFFFFFFFFFF; // CreationBits
}

public string? ToUnitGUID()
{
string lowHex = Low.ToString("X16");
HighGuidType highType = GetHighType();
switch (highType)
{
case HighGuidType.Player:
return $"{highType}-{GetRealmId()}-{lowHex.Substring(lowHex.Length - 8)}";
case HighGuidType.Creature:
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;
}
}

public override string ToString()
{
if (Low == 0 && High == 0)
Expand Down