ThreatClassic2

ThreatClassic2

9M Downloads

[REQ] Another aggro warning type option

anzz1 opened this issue ยท 1 comments

commented

Please add another type of aggro warning as an option, one which follows the blizzard convention as detailed here : https://wowpedia.fandom.com/wiki/API_UnitThreatSituation

UNIT_THREAT_LIST_UPDATE event is fired by source and thus requires the unit token to be available (target, nameplateX, etc.).
UNIT_THREAT_SITUATION_UPDATE event is fired by target (player, partyX, etc.) and thus does not need the source unit token to be available.

And by omitting the source from UnitThreatSituation, you can get the moment of aggro irregardless whether the source unit token is available so it's always consistent. You can't get the detailed data this way but for the aggro warning is more intuitive this way in my opinion. It is also very simple to implement.

Example code:

AggroWarningSound = {
  ["enabled"] = true,
  ["ingrouponly"] = true
}
local last_status = 0

local f = CreateFrame("Frame")
f:SetScript("OnEvent", function(self, event, ...)
  if (not AggroWarningSound.enabled or (AggroWarningSound.ingrouponly and not IsInGroup())) then
    return
  end
  local status = UnitThreatSituation("player") or 0
  if (status > last_status) then
    PlaySoundFile("sound/spells/seepinggaseous_fel_nova.ogg")
  end
  last_status = status
end)
f:RegisterUnitEvent("UNIT_THREAT_SITUATION_UPDATE", "player")
commented

Sounds good. I'll see if I can implement this with the next release.