(feat/Encounter): Implement Encounter Trigger/Load Options via DBM, also fire ENCOUNTER_START/END and DBM Callback Events for Custom Triggers (#73)

This commit is contained in:
NoM0Re
2025-10-04 23:39:33 +02:00
committed by GitHub
parent 517f15c7bd
commit 6c6cb73fdd
10 changed files with 2143 additions and 8 deletions
+40
View File
@@ -1612,6 +1612,7 @@ function GenericTrigger.Add(data, region)
watched_trigger_events[id] = nil
local warnAboutCLEUEvents = false
local warnEncounterEvent = false
for triggernum, triggerData in ipairs(data.triggers) do
local trigger, untrigger = triggerData.trigger, triggerData.untrigger
@@ -1653,6 +1654,8 @@ function GenericTrigger.Add(data, region)
if not(Private.subevent_actual_prefix_types[trigger.subeventPrefix]) then
trigger.subeventSuffix = "";
end
elseif (trigger.event == "Encounter Events") and not WeakAuras.IsDBMRegistered() then
warnEncounterEvent = true
end
prototype = event_prototypes[trigger.event]
@@ -1902,6 +1905,13 @@ function GenericTrigger.Add(data, region)
else
Private.AuraWarnings.UpdateWarning(data.uid, "spammy_event_warning")
end
if warnEncounterEvent then
Private.AuraWarnings.UpdateWarning(data.uid, "dbm_required_for_encounter_events", "error",
L["|cFFFF0000Encounter Trigger requires Deadly Boss Mods (DBM) to be installed and up to date.|r"])
else
Private.AuraWarnings.UpdateWarning(data.uid, "dbm_required_for_encounter_events")
end
end
do
@@ -3905,6 +3915,36 @@ Private.LibGroupTalentsWrapper.Register(function(unit)
WeakAuras.ScanEvents("UNIT_SPEC_CHANGED_" .. unit, unit)
end)
if WeakAuras.IsDBMRegistered() then
function Private.DBMEncounterEvents(event, mod, ...)
local encounterID, encounterName, difficultyID, groupSize =
0, "", DBM:GetCurrentDifficulty(), DBM:GetGroupSize()
if type(mod) == "table" then
encounterID = mod.encounterId or encounterID
encounterName = mod.combatInfo and mod.combatInfo.name or encounterName
end
-- Fire DBM Callback Events too, because we have them anyway registered.
WeakAuras.ScanEvents(event, mod, ...)
if event == "DBM_Pull" then
-- ENCOUNTER_START: encounterID, encounterName, difficultyID, groupSize
Private.ScanForLoads(nil, "ENCOUNTER_START", encounterID, encounterName, difficultyID, groupSize)
WeakAuras.ScanEvents("ENCOUNTER_START", encounterID, encounterName, difficultyID, groupSize)
else
local success = (event == "DBM_Kill") and 1 or 0
-- ENCOUNTER_END: encounterID, encounterName, difficultyID, groupSize, success
Private.ScanForLoads(nil, "ENCOUNTER_END", encounterID, encounterName, difficultyID, groupSize, success)
WeakAuras.ScanEvents("ENCOUNTER_END", encounterID, encounterName, difficultyID, groupSize, success)
end
end
for _, event in ipairs({"DBM_Pull", "DBM_Kill", "DBM_Wipe"}) do
DBM:RegisterCallback(event, Private.DBMEncounterEvents)
end
end
do
local scheduled_scans = {};