diff --git a/FreshShit/RaiderlosSA/event.lua b/FreshShit/RaiderlosSA/event.lua index 56e3c7e..d970b2b 100644 --- a/FreshShit/RaiderlosSA/event.lua +++ b/FreshShit/RaiderlosSA/event.lua @@ -1,10 +1,17 @@ --- COMBAT_LOG_EVENT_UNFILTERED ---@param e string ---@param ... any -function(e, ...) +function(allstates, e, ...) local subevent, err = CLEUParser.GetSubevent(...) if err then return end local spellId, err = CLEUParser.GetSpellId(...) if err then return end - print(EventMap[subevent][spellId]) + + local eventMap = EventMap[subevent] + if eventMap == nil then return end + local alert = eventMap[spellId] + if alert == nil then return end + + alert:Trigger(allstates, ...) + return true end diff --git a/FreshShit/RaiderlosSA/event2.lua b/FreshShit/RaiderlosSA/event2.lua new file mode 100644 index 0000000..a2636a0 --- /dev/null +++ b/FreshShit/RaiderlosSA/event2.lua @@ -0,0 +1,11 @@ +-- TICKER_100 +function() + GUIDUnitMap = {} + for i = 1, 40 do + local unit = string.format("nameplate%d", i) + local GUID = UnitGUID(unit) + if GUID then + GUIDUnitMap[GUID] = unit + end + end +end \ No newline at end of file diff --git a/FreshShit/RaiderlosSA/init.lua b/FreshShit/RaiderlosSA/init.lua index e454029..4b48cd1 100644 --- a/FreshShit/RaiderlosSA/init.lua +++ b/FreshShit/RaiderlosSA/init.lua @@ -1036,48 +1036,60 @@ CLEUParser = { end, } -local function varargToString(...) - local output = {} - for i = 1, select("#", ...) do - table.insert(output, tostring(select(i, ...))) - end - return table.concat(output, ", ") -end - --- C:\Users\Administrator\Seafile\Backup-WoW\Ruski\WTF\Account\phatphuckdave\SavedVariables\WeakAuras.lua --- /dump WeakAurasSaved.Cyka.CLEUExample -if not WeakAurasSaved then WeakAurasSaved = {} end -if not WeakAurasSaved.Cyka then WeakAurasSaved.Cyka = {} end -if not WeakAurasSaved.Cyka.CLEUExample then WeakAurasSaved.Cyka.CLEUExample = {} end ----@param spellName string ----@param spellId number ----@param subevent string ----@param ... any -aura_env.LogSpell = function(spellName, spellId, subevent, ...) - local slug = string.format("%d-%s", spellId, subevent) - if not WeakAurasSaved.Cyka.CLEUExample[slug] then - WeakAurasSaved.Cyka.CLEUExample[slug] = varargToString(spellName, spellId, subevent, ...) - end -end +GUIDUnitMap = {} local SoundFileRoot = "Interface\\Sounds\\spellAlert\\" +local PlayerName = UnitName("player") ----@class SpellAlert +---@param guid string +---@return string, nil|string +local function GetUnitFromGuid(guid) + local unit = GUIDUnitMap[guid] + if unit == nil then return "", "Unit not found" end + return unit, nil +end + +---@param guid string +---@return {name: string, target: string, startms: number, endms: number, spellid: number}, nil|string +local function GetCastInfoForGuid(guid) + local retval = { + name = "", + target = "", + startms = 0, + endms = 0, + spellid = 0 + } + + local unit, err = GetUnitFromGuid(guid) + if err then return retval, err end + local name, _, _, startTimeMS, endTimeMS, _, _, _, spellId = UnitCastingInfo(unit) + if name == nil then return retval, "Unit is not casting" end + retval.name = name + retval.startms = startTimeMS + retval.endms = endTimeMS + retval.spellid = spellId + retval.target = UnitName(string.format("%starget", unit)) + + return retval, nil +end + +---@class Alert ---@field id number ---@field soundFile string ---@field events table ---@field instruction string ---@field afflictedInstruction string -SpellAlert = { +---@field iterator number +Alert = { ---@param id number ---@param name string ---@param events table ---@param instruction string ---@param afflictedInstruction string - ---@return SpellAlert + ---@return Alert new = function(id, name, events, instruction, afflictedInstruction) local self = setmetatable({}, { - __index = SpellAlert + __index = Alert }) self.id = id name = string.gsub(name, " ", "_") @@ -1089,38 +1101,88 @@ SpellAlert = { end self.instruction = instruction self.afflictedInstruction = afflictedInstruction + self.iterator = 0 return self + end, + + ---@param self Alert + ---@param allstates allstates + ---@param ... any + Trigger = function(self, allstates, ...) + -- We trust that the event is valid + local spellname, err = CLEUParser.GetSpellName(...) + if err then return end + -- SPELL_CAST_START does NOT have the destination info + -- What we'll have to do is keep a map of unit guids to units + -- In other words - 10 times per second scan all the nameplates and create a map + -- On SPELL_CAST_START get the srcGUID, index the map, get the unit, run UnitCastingInfo(unit), get the target + -- It's fried af but it will probably work + -- With only 40 nameplates it shouldn't be a big deal + local target, err = CLEUParser.GetDestGUID(...) + if target == "" then + local src, err = CLEUParser.GetSourceGUID(...) + if err == nil then + local castInfo, err = GetCastInfoForGuid(src) + if err then print(err) end + if err == nil then + target = castInfo.target + end + end + end + + local displayText = self.instruction + if err == nil and target == PlayerName then + displayText = self.afflictedInstruction + end + + ---@type state + local state = { + show = true, + changed = true, + progressType = "timed", + expireTime = GetTime() + 3, + duration = 3, + autoHide = true, + name = displayText, + target = target, + } + DevTools_Dump(state) + + allstates[string.format("%d-%d", self.id, self.iterator)] = state + self.iterator = self.iterator + 1 end } local alerts = { + -- Debug + Alert.new(5176, "Solar Wrath", { "SPELL_CAST_START" }, "Solar Wrath", "Solar Wrath on you!"), -- Garothi - SpellAlert.new(244410, "Decimation", { "SPELL_CAST_SUCCESS" }, "", "Move"), - SpellAlert.new(246220, "Fel Bombardment", { "SPELL_CAST_SUCCESS" }, "", "Move"), - SpellAlert.new(244969, "Eradication", { "SPELL_CAST_START" }, "Run away", ""), - SpellAlert.new(244106, "Carnage", { "SPELL_CAST_START" }, "Tank the boss", ""), + Alert.new(244410, "Decimation", { "SPELL_CAST_SUCCESS" }, "", "Move"), + Alert.new(246220, "Fel Bombardment", { "SPELL_CAST_SUCCESS" }, "", "Move"), + Alert.new(244969, "Eradication", { "SPELL_CAST_START" }, "Run away", ""), + Alert.new(244106, "Carnage", { "SPELL_CAST_START" }, "Tank the boss", ""), -- Felhounds - SpellAlert.new(244086, "Molten Touch", { "SPELL_CAST_SUCCESS" }, "", "Run away"), - SpellAlert.new(244768, "Desolate Gaze", { "SPELL_AURA_APPLIED" }, "", "Move away"), - SpellAlert.new(244057, "Enflame Corruption", { "SPELL_CAST_START", "SPELL_AURA_APPLIED" }, "Spread", "Spread!!"), - SpellAlert.new(244131, "Consuming Sphere", { "SPELL_AURA_APPLIED" }, "Move", ""), - SpellAlert.new(244056, "Siphon Corruption", { "SPELL_CAST_START", "SPELL_AURA_APPLIED" }, "Stack", "Stack!!"), + Alert.new(244086, "Molten Touch", { "SPELL_CAST_SUCCESS" }, "", "Run away"), + Alert.new(244768, "Desolate Gaze", { "SPELL_AURA_APPLIED" }, "", "Move away"), + Alert.new(244057, "Enflame Corruption", { "SPELL_CAST_START", "SPELL_AURA_APPLIED" }, "Spread", "Spread!!"), + Alert.new(244131, "Consuming Sphere", { "SPELL_AURA_APPLIED" }, "Move", ""), + Alert.new(244056, "Siphon Corruption", { "SPELL_CAST_START", "SPELL_AURA_APPLIED" }, "Stack", "Stack!!"), -- Antoran High Command -- SpellAlert.new(245161, "Entropic Mine"), -- Need more info -- SpellAlert.new(245546, "Summon Reinforcements"), -- Need more info -- Portal Keeper Hasabel - SpellAlert.new(244016, "Reality Tear", { "SPELL_CAST_SUCCESS" }, "", ""), - SpellAlert.new(243983, "Collapsing World", { "SPELL_CAST_SUCCESS" }, "Dodge", ""), - SpellAlert.new(244000, "Felstorm Barrage", { "SPELL_CAST_START" }, "Dodge", ""), + Alert.new(244016, "Reality Tear", { "SPELL_CAST_SUCCESS" }, "", ""), + Alert.new(243983, "Collapsing World", { "SPELL_CAST_SUCCESS" }, "Dodge", ""), + Alert.new(244000, "Felstorm Barrage", { "SPELL_CAST_START" }, "Dodge", ""), -- Imonar -- SpellAlert.new(247552, "Sleep Canister"), -- Need more info - SpellAlert.new(247367, "Shock Lance", { "SPELL_CAST_SUCCESS" }, "", ""), - SpellAlert.new(248068, "Empowered Pulse Grenade", { "SPELL_CAST_SUCCESS" }, "", ""), -- Need more info - SpellAlert.new(247376, "Pulse Grenade", { "SPELL_CAST_SUCCESS" }, "", ""), -- Need more info - SpellAlert.new(247716, "Charged Blasts", { "SPELL_AURA_APPLIED" }, "", "Move!!"), - SpellAlert.new(247687, "Sever", { "SPELL_CAST_SUCCESS" }, "", ""), - SpellAlert.new(248070, "Empowered Shrapnel Blast", { "SPELL_CAST_START" }, "Mines", ""), - SpellAlert.new(250255, "Empowered Shock Lance", { "SPELL_CAST_START" }, "", ""), + Alert.new(247367, "Shock Lance", { "SPELL_CAST_SUCCESS" }, "", ""), + Alert.new(248068, "Empowered Pulse Grenade", { "SPELL_CAST_SUCCESS" }, "", ""), -- Need more info + Alert.new(247376, "Pulse Grenade", { "SPELL_CAST_SUCCESS" }, "", ""), -- Need more info + Alert.new(247716, "Charged Blasts", { "SPELL_AURA_APPLIED" }, "", "Move!!"), + Alert.new(247687, "Sever", { "SPELL_CAST_SUCCESS" }, "", ""), + Alert.new(248070, "Empowered Shrapnel Blast", { "SPELL_CAST_START" }, "Mines", ""), + Alert.new(250255, "Empowered Shock Lance", { "SPELL_CAST_START" }, "", ""), -- Kin'garoth -- SpellAlert.new(254919, "Forging Strike"), -- SpellAlert.new(254926, "Reverberating Strike"), @@ -1328,6 +1390,7 @@ local alerts = { -- SpellAlert.new(228837, "Bellowing Roar"), } +---@type table> EventMap = {} for _, alert in ipairs(alerts) do for event, _ in pairs(alert.events) do @@ -1336,4 +1399,4 @@ for _, alert in ipairs(alerts) do end EventMap[event][alert.id] = alert end -end \ No newline at end of file +end