Originally Posted by SDPhantom
PS: You should still filter enemy casts unless you want to be spammed about party members healing you. Also consider breaking the loop when you find a match or ideally check the unit's casting info to see if they're casting the same spell. Otherwise it'll spam you with every unit targeting you, even those not casting.
|
Yes, this is how I would filter it
Lua Code:
local f = CreateFrame("Frame")
function f:OnEvent(event, timestamp, subevent, _, sourceGUID, sourceName, sourceFlags, _, destGUID, destName, _, _, spellID, spellName)
if subevent == "SPELL_CAST_START" then
for _, v in pairs(C_NamePlate.GetNamePlates()) do
if UnitGUID(v.namePlateUnitToken) == sourceGUID then
-- source is targeting player, source is hostile
if UnitIsUnit(v.namePlateUnitToken.."target", "player") and bit.band(sourceFlags, COMBATLOG_OBJECT_REACTION_HOSTILE) > 0 then
print( format("%s is casting %s on me", sourceName, GetSpellLink(spellID)) )
end
break
end
end
end
end
f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
f:SetScript("OnEvent", f.OnEvent)
Originally Posted by SDPhantom
Something like this would work much better without involving the NamePlate API. NamePlates may still need to be enabled, but it'll run more efficient and allows you to add more units. You also can prioritize which groups of units are checked first by rearranging their order.
|
That works too, but I'm not sure how much more efficient it is
Since nameplates get recycled/removed you have to check all 40 nameplate unit ids, instead of getting the actives ones through the NamePlate API
Code:
/run for i = 1, 40 do print("nameplate"..i, UnitName("nameplate"..i)) end
Lua Code:
"nameplate1", "Blamedatank", "Outland"
"nameplate2", "Pluex", "Outland"
"nameplate3", "Thomas Miller", nil
"nameplate4", "Maawi", "Outland"
"nameplate5", "Stormwind City Guard", nil
"nameplate6", "Edna Mullby", nil
"nameplate7", nil, nil
"nameplate8", "Dankzter", "Outland"
"nameplate9", nil, nil
"nameplate10", nil, nil
"nameplate11", "Renato Gallina", nil
"nameplate12", nil, nil
"nameplate13", "Stephanie Turner", nil
"nameplate14", nil, nil
"nameplate15", "Stormwind City Patroller", nil
"nameplate16", nil, nil
"nameplate17", nil, nil
"nameplate18", "Blackfirez", "DunModr"
"nameplate19", nil, nil
"nameplate20", "Stormwind City Guard", nil
"nameplate21", "\195\146\195\164k", "Outland"
"nameplate22", nil, nil
"nameplate23", "Thurman Mullby", nil
"nameplate24", nil, nil
"nameplate25", "Varcher", "Stormscale"
"nameplate26", nil, nil
"nameplate27", nil, nil
"nameplate28", nil, nil
"nameplate29", "Bay\195\184n\195\170ta", "Outland"
"nameplate30", nil, nil
"nameplate31", nil, nil
"nameplate32", nil, nil
"nameplate33", nil, nil
"nameplate34", nil, nil
"nameplate35", nil, nil
"nameplate36", "Elling Trias", nil
"nameplate37", nil, nil
"nameplate38", "Jusraalin", "Outland"
"nameplate39", nil, nil
"nameplate40", "Golden King", nil