Quantcast
Lua script help - WoWInterface
Thread Tools Display Modes
06-24-17, 07:56 AM   #1
thewtfman
A Murloc Raider
Join Date: Jun 2017
Posts: 4
Lua script help

So this is for BigWigs Respawn timer, the addon creates big wigs respawn timers when trash mobs die in raids, so i figured i could add normal mobs from other places aswell, and as you can see in the code ive added Jade ooze but my problem is that when i kill one the respawn timer does not pop up, i figured i had no clue what i was doing until another player came and killed a jade ooze and the respawn timer popped up. So my problem is, this works but only when other players kill something close to me, can someone make it work so that i can use it for personal farming.

Lua Code:
  1. ----------------------------------
  2. --      Locals                  --
  3. ----------------------------------
  4.  
  5. local name = "Respawn Timers"
  6. local L = AceLibrary("AceLocale-2.2"):new("BigWigs"..name)
  7.  
  8. -- packNumber is basically just a counter for the mob types, so that when one
  9. -- mob of a type dies, its counter is increased by 1 so that we have some way of
  10. -- telling mobs apart. It will never reset outside of a reload UI or relog.
  11. local packNumber = nil
  12.  
  13. -- We throttle the deaths of each mob type by 60 seconds by default, so that if
  14. -- 2 mobs of the same type die within 60 seconds of eachother, you'll only get 1
  15. -- respawn timer for them, that starts at the kill of the first one. This was
  16. -- added mostly for core hound packs in MC.
  17. local deathThrottle = nil
  18.  
  19. ----------------------------------
  20. --      Localization            --
  21. ----------------------------------
  22.  
  23. L:RegisterTranslations("enUS", function() return {
  24.     ["respawntimers"] = true,
  25.     ["Respawn Timers"] = true,
  26.     ["Respawn timer bars and warnings for trash mobs."] = true,
  27.     ["bars"] = true,
  28.     ["Bars"] = true,
  29.     ["Toggles showing bars for respawn times."] = true,
  30.     ["messages"] = true,
  31.     ["Messages"] = true,
  32.     ["Toggles showing messages for respawn times."] = true,
  33.  
  34.     ["%s %d respawns in %d sec"] = true,
  35.     ["%s %d respawned!"] = true,
  36.     ["Respawn: %s %d"] = true,
  37.  
  38.     -- Molten Core Triggers
  39.     ["Ancient Core Hound"] = true,
  40.     ["Lava Annihilator"] = true,
  41.     ["Lava Surger"] = true,
  42.     ["Firelord"] = true,
  43.     ["Firewalker"] = true, -- Lava Pack
  44.     ["%s collapses and begins to smolder."] = true, -- Hound Pack, emote.
  45.     -- Molten Core Messages
  46.     ["Corehound"] = true,
  47.     ["Annihilator"] = true,
  48.     ["Surger"] = true,
  49.     -- Firelord == Firelord.
  50.     ["Lavapack"] = true,
  51.     ["Houndpack"] = true,
  52.  
  53.     -- AQ Triggers
  54.     ["Obsidian Eradicator"] = true,
  55.     ["Anubisath Sentinel"] = true,
  56.     -- AQ Messages
  57.     ["Eradicator"] = true,
  58.     ["Sentinel"] = true,
  59.  
  60.     -- BWL Triggers
  61.     ["Death Talon Hatcher"] = true,
  62.     ["Blackwing Taskmaster"] = true,
  63.     -- BWL Messages
  64.     ["Death Talon"] = true,
  65.     ["Taskmaster"] = true,
  66.    
  67.         -- The Hinterlands Triggers
  68.     ["Jade Ooze"] = true,
  69.     -- The Hinterlands Messages
  70.     ["Ooze"] = true,
  71. } end )
  72.  
  73. L:RegisterTranslations("ruRU", function() return {
  74.     ["respawntimers"] = "respawntimers",
  75.     ["Respawn Timers"] = "Таймер появления",
  76.     ["Respawn timer bars and warnings for trash mobs."] = "Таймер появления и предупреждения для трэш мобов.",
  77.     ["bars"] = "bars",
  78.     ["Bars"] = "Полосы",
  79.     ["Toggles showing bars for respawn times."] = "Вкл/Выкл отображение полос для таймера появлений.",
  80.     ["messages"] = "messages",
  81.     ["Messages"] = "Сообщения",
  82.     ["Toggles showing messages for respawn times."] = "Вкл/Выкл отображение сообщений для таймера появлений.",
  83.  
  84.     ["%s %d respawns in %d sec"] = "%s %d респавн через %d сек.",
  85.     ["%s %d respawned!"] = "%s %d респавнится!",
  86.     ["Respawn: %s %d"] = "Респавн: %s %d",
  87.  
  88.     -- Molten Core Triggers
  89.     ["Ancient Core Hound"] = "Древняя гончая Недр",
  90.     ["Lava Annihilator"] = "Лавовый уничтожитель",
  91.     ["Lava Surger"] = "Лавовый волноплеск",
  92.     ["Firelord"] = "Повелитель огня",
  93.     ["Firewalker"] = "Огнеход", -- Lava Pack
  94.     ["%s collapses and begins to smolder."] = "%s collapses and begins to smolder.", -- Hound Pack, emote.
  95.     -- Molten Core Messages
  96.     ["Corehound"] = "ГончаяНедр",
  97.     ["Annihilator"] = "Уничтожитель",
  98.     ["Surger"] = "Волноплеск",
  99.     -- Firelord == Firelord.
  100.     ["Lavapack"] = "ЛавовыйПак",
  101.     ["Houndpack"] = "ПакГончей",
  102.  
  103.     -- AQ Triggers
  104.     ["Obsidian Eradicator"] = "Обсидиановый искоренитель",
  105.     ["Anubisath Sentinel"] = "Анубисат-часовой",
  106.     -- AQ Messages
  107.     ["Eradicator"] = "Искоренитель",
  108.     ["Sentinel"] = "Часовой",
  109.  
  110.     -- BWL Triggers
  111.     ["Death Talon Hatcher"] = "Гнездовая Когтя Смерти",
  112.     ["Blackwing Taskmaster"] = "Надсмотрщик из логова Крыла Тьмы",
  113.     -- BWL Messages
  114.     ["Death Talon"] = "Гнездовая",
  115.     ["Taskmaster"] = "Надсмотрщик",
  116. } end )
  117.  
  118. L:RegisterTranslations("deDE", function() return {
  119.     ["respawntimers"] = "respawntimers",
  120.     ["Respawn Timers"] = "Respawn Timer",
  121.     ["Respawn timer bars and warnings for trash mobs."] = "Respawn Timerbalken und Warnungen f\195\188r Trashmobs",
  122.     ["bars"] = "bars",
  123.     ["Bars"] = "Balken",
  124.     ["Toggles showing bars for respawn times."] = "Zeige Balken",
  125.     ["messages"] = "messages",
  126.     ["Messages"] = "Warnungen",
  127.     ["Toggles showing messages for respawn times."] = "Sende Warnungen",
  128.  
  129.     ["%s %d respawns in %d sec"] = "�%s %d respawnt in %d Sekunden",
  130.     ["%s %d respawned!"] = "%s %s respawnt",
  131.     ["Respawn: %s %d"] = "Respawn: %s %d",
  132.  
  133.     -- Molten Core Triggers
  134.     ["Ancient Core Hound"] = "Uralter Kernhund",
  135.     ["Lava Annihilator"] = "Lavavernichter",
  136.     ["Lava Surger"] = "Lavawoger",
  137.     ["Firelord"] = "Feuerlord",
  138.     ["Firewalker"] = "Feuerg\195\164nger", -- Lava Pack
  139.     ["%s collapses and begins to smolder."] = "%s bricht zusammen und beginnt zu glimmen.", -- Hound Pack, emote.
  140.     -- Molten Core Messages
  141.     ["Corehound"] =  "Kernhund",
  142.     ["Annihilator"] = "Vernichter",
  143.     ["Surger"] = "Woger",
  144.     -- Firelord == Firelord.
  145.     ["Lavapack"] = "Lavapack",
  146.     ["Houndpack"] = "Kernhundpack",
  147.  
  148.     -- AQ Triggers
  149.     ["Obsidian Eradicator"] = "Obsidianzerst\195\182rer",
  150.     ["Anubisath Sentinel"] = "W\195\164chter des Anubisath",
  151.     -- AQ Messages
  152.     ["Eradicator"] = "Zerst\195\182rer",
  153.     ["Sentinel"] = "W\195\164chter",
  154.  
  155.     -- BWL Triggers
  156.     ["Death Talon Hatcher"] = "Brutw\195\164chter der Todeskrallen",
  157.     ["Blackwing Taskmaster"] = "Zuchtmeister der Pechschwingen",
  158.     -- BWL Messages
  159.     ["Death Talon"] = "Brutw\195\164chter",
  160.     ["Taskmaster"] = "Zuchtmeister",
  161. } end )
  162.  
  163. -- The death table and emote table are basically the meat of this addon. The
  164. -- first string is what we search for in the responding chat event, the table
  165. -- that is attached to it is: 1. respawn time in seconds, 2. the bar text and
  166. -- message text for the respawn timer, 3. optional icon path for this timer.
  167. local deathTable = {
  168.     -- MC
  169.     [L["Ancient Core Hound"]] = {1080, L["Corehound"], nil},
  170.     [L["Lava Annihilator"]]   = {7200, L["Annihilator"], nil},
  171.     [L["Lava Surger"]]        = {1620, L["Surger"], nil},
  172.     [L["Firelord"]]           = {7200, L["Firelord"], nil},
  173.     [L["Firewalker"]]         = {7200, L["Lavapack"], nil},
  174.     -- AQ
  175.     [L["Obsidian Eradicator"]] = {1800, L["Eradicator"], nil},
  176.     [L["Anubisath Sentinel"]]  = {1800, L["Sentinel"], nil},
  177.     -- BWL
  178.     [L["Death Talon Hatcher"]]  = {720, L["Death Talon"], nil},
  179.     [L["Blackwing Taskmaster"]] = {720, L["Taskmaster"], nil},
  180.     -- The Hinterlands
  181.     [L["Jade Ooze"]] = {350, L["Ooze"], nil},
  182. }
  183. local emoteTable = {
  184.     -- MC
  185.     [L["%s collapses and begins to smolder."]] = {3600, L["Houndpack"], nil},
  186. }
  187.  
  188. ----------------------------------
  189. --  Addon Declaration           --
  190. ----------------------------------
  191.  
  192. BigWigsRespawnTimers = BigWigs:NewModule(name)
  193. BigWigsRespawnTimers.defaultDB = {
  194.     bars = true,
  195.     messages = true,
  196. }
  197.  
  198. BigWigsRespawnTimers.consoleCmd = L["respawntimers"]
  199. BigWigsRespawnTimers.consoleOptions = {
  200.     type = "group",
  201.     name = L["Respawn Timers"],
  202.     desc = L["Respawn timer bars and warnings for trash mobs."],
  203.     args   = {
  204.         [L["bars"]] = {
  205.             type = "toggle",
  206.             name = L["Bars"],
  207.             desc = L["Toggles showing bars for respawn times."],
  208.             get = function() return BigWigsRespawnTimers.db.profile.bars end,
  209.             set = function(v) BigWigsRespawnTimers.db.profile.bars = v end,
  210.         },
  211.         [L["messages"]] = {
  212.             type = "toggle",
  213.             name = L["Messages"],
  214.             desc = L["Toggles showing messages for respawn times."],
  215.             get = function() return BigWigsRespawnTimers.db.profile.messages end,
  216.             set = function(v) BigWigsRespawnTimers.db.profile.messages = v end,
  217.         },
  218.     }
  219. }
  220. BigWigsRespawnTimers.revision = tonumber(string.sub("$Revision: 17260 $", 12, -3))
  221. BigWigsRespawnTimers.external = true
  222.  
  223. ----------------------------------
  224. --      Initialization          --
  225. ----------------------------------
  226.  
  227. function BigWigsRespawnTimers:OnEnable()
  228.     packNumber = {}
  229.     deathThrottle = {}
  230.     self:RegisterEvent("CHAT_MSG_COMBAT_HOSTILE_DEATH")
  231.     self:RegisterEvent("CHAT_MSG_MONSTER_EMOTE")
  232. end
  233.  
  234. ----------------------------------
  235. --      Events                  --
  236. ----------------------------------
  237.  
  238. -- Basically just loop the corresponding mob table and check if the event
  239. -- arguments (death or emote) matches anything we've registered. If so, trigger
  240. -- a respawn timer.
  241.  
  242. function BigWigsRespawnTimers:CHAT_MSG_COMBAT_HOSTILE_DEATH(msg)
  243.     for key, table in pairs(deathTable) do
  244.         if msg == string.format(UNITDIESOTHER, key) then
  245.             self:StartRespawnTimer(table[2], table[1], table[3])
  246.             break
  247.         end
  248.     end
  249. end
  250.  
  251. function BigWigsRespawnTimers:CHAT_MSG_MONSTER_EMOTE(msg)
  252.     for key, table in pairs(emoteTable) do
  253.         if msg == key then
  254.             self:StartRespawnTimer(table[2], table[1], table[3])
  255.             break
  256.         end
  257.     end
  258. end
  259.  
  260. ----------------------------------
  261. --    Utility                   --
  262. ----------------------------------
  263.  
  264. function BigWigsRespawnTimers:StartRespawnTimer(message, timer, icon, throttle)
  265.     timer = tonumber(timer)
  266.     if timer == nil then return end
  267.  
  268.     -- Throttle deaths by 60 seconds.
  269.     if deathThrottle[message] and (deathThrottle[message] + 60) > GetTime() then return end
  270.     deathThrottle[message] = GetTime()
  271.  
  272.     -- Increment the pack counter after all arguments are checked and we're sure
  273.     -- to start a new respawn timer.
  274.     if not packNumber[message] then packNumber[message] = 0 end
  275.     local nextPack = packNumber[message] + 1
  276.     packNumber[message] = nextPack
  277.  
  278.     -- Make sure the user wants respawn messages.
  279.     if self.db.profile.messages then
  280.         self:ScheduleEvent("bwrt"..nextPack.."10secwarn", "BigWigs_Message", timer - 10, string.format(L["%s %d respawns in %d sec"], message, nextPack, 10), "Yellow")
  281.         self:ScheduleEvent("bwrt"..nextPack.."respawned", "BigWigs_Message", timer, string.format(L["%s %d respawned!"], message, nextPack), "Orange")
  282.     end
  283.  
  284.     -- Make sure the user wants respawn timer bars.
  285.     if self.db.profile.bars then
  286.         -- Default icon.
  287.         if not icon then icon = "Interface\\Icons\\INV_Misc_Head_Dragon_01" end
  288.         local text = string.format(L["Respawn: %s %d"], message, nextPack)
  289.         self:TriggerEvent("BigWigs_StartBar", self, text, timer, icon)
  290.         self:SetCandyBarOnClick("BigWigsBar "..text, function()
  291.             if IsControlKeyDown() then
  292.                 self:TriggerEvent("BigWigs_StopBar", self, text)
  293.                 self:CancelScheduledEvent("bwrt"..nextPack.."10secwarn")
  294.                 self:CancelScheduledEvent("bwrt"..nextPack.."respawned")
  295.             end
  296.         end)
  297.     end
  298. end
  Reply With Quote
06-24-17, 07:19 PM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,111
Why are you using Ace2, which is defunct and abandoned? Convert this to Ace3 as your first step.
  Reply With Quote
06-24-17, 07:44 PM   #3
briskman3000
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 74
I haven't seen a trash respawn timer from BigWigs since ... oh god I don't even remember when (tbc maybe?), and I've been using BigWigs as my bossmods since forever.

Last edited by briskman3000 : 06-24-17 at 07:47 PM.
  Reply With Quote
06-25-17, 02:32 AM   #4
thewtfman
A Murloc Raider
Join Date: Jun 2017
Posts: 4
I don't know how to convert it to ace3, and also i know its old and maybe trash but still. I just need to know the fact why this script only activates when nearby players kill a unit and not when I kill a unit, is there anything in this that you can see would be the reason for that. Would very much appreciate any form of help.
  Reply With Quote
06-25-17, 07:53 AM   #5
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Well the problem will be line 244:
Code:
if msg == string.format(UNITDIESOTHER, key) then
I don't know what UNITDIESOTHER is, but you'll want to replace it with something else.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
06-25-17, 10:23 AM   #6
thewtfman
A Murloc Raider
Join Date: Jun 2017
Posts: 4
thanks for the feedback, i was actually thinking about that too but not sure what to replace it with :P
  Reply With Quote
06-25-17, 02:59 PM   #7
Kakjens
A Cliff Giant
Join Date: Apr 2017
Posts: 75
Old info but might help.
Edit. Also, it seems that CHAT_MSG_COMBAT_HOSTILE_DEATH might be deprecated.

Last edited by Kakjens : 06-25-17 at 03:07 PM.
  Reply With Quote
06-26-17, 03:49 AM   #8
thewtfman
A Murloc Raider
Join Date: Jun 2017
Posts: 4
hmmmmm i cant seem to get it to work, ive thrown in everything just to see some sort of change but nothing different is happening.

Lua Code:
  1. ----------------------------------
  2. --      Locals                  --
  3. ----------------------------------
  4.  
  5. local name = "Respawn Timers"
  6. local L = AceLibrary("AceLocale-2.2"):new("BigWigs"..name)
  7.  
  8. -- packNumber is basically just a counter for the mob types, so that when one
  9. -- mob of a type dies, its counter is increased by 1 so that we have some way of
  10. -- telling mobs apart. It will never reset outside of a reload UI or relog.
  11. local packNumber = nil
  12.  
  13. -- We throttle the deaths of each mob type by 60 seconds by default, so that if
  14. -- 2 mobs of the same type die within 60 seconds of eachother, you'll only get 1
  15. -- respawn timer for them, that starts at the kill of the first one. This was
  16. -- added mostly for core hound packs in MC.
  17. local deathThrottle = nil
  18.  
  19. ----------------------------------
  20. --      Localization            --
  21. ----------------------------------
  22. L:RegisterTranslations("enUS", function() return {
  23.     ["respawntimers"] = true,
  24.     ["Respawn Timers"] = true,
  25.     ["Respawn timer bars and warnings for trash mobs."] = true,
  26.     ["bars"] = true,
  27.     ["Bars"] = true,
  28.     ["Toggles showing bars for respawn times."] = true,
  29.     ["messages"] = true,
  30.     ["Messages"] = true,
  31.     ["Toggles showing messages for respawn times."] = true,
  32.  
  33.     ["%s %d respawns in %d sec"] = true,
  34.     ["%s %d respawned!"] = true,
  35.     ["Respawn: %s %d"] = true,
  36.  
  37.     -- Molten Core Triggers
  38.     ["Ancient Core Hound"] = true,
  39.     ["Lava Annihilator"] = true,
  40.     ["Lava Surger"] = true,
  41.     ["Firelord"] = true,
  42.     ["Firewalker"] = true, -- Lava Pack
  43.     ["%s collapses and begins to smolder."] = true, -- Hound Pack, emote.
  44.     -- Molten Core Messages
  45.     ["Corehound"] = true,
  46.     ["Annihilator"] = true,
  47.     ["Surger"] = true,
  48.     -- Firelord == Firelord.
  49.     ["Lavapack"] = true,
  50.     ["Houndpack"] = true,
  51.  
  52.     -- AQ Triggers
  53.     ["Obsidian Eradicator"] = true,
  54.     ["Anubisath Sentinel"] = true,
  55.     -- AQ Messages
  56.     ["Eradicator"] = true,
  57.     ["Sentinel"] = true,
  58.  
  59.     -- BWL Triggers
  60.     ["Death Talon Hatcher"] = true,
  61.     ["Blackwing Taskmaster"] = true,
  62.     -- BWL Messages
  63.     ["Death Talon"] = true,
  64.     ["Taskmaster"] = true,
  65.  
  66.     -- The Hinterlands Triggers
  67.     ["Jade Ooze"] = true,
  68.     -- The Hinterlands Messages
  69.     ["Ooze"] = true,
  70. } end )
  71.  
  72. L:RegisterTranslations("deDE", function() return {
  73.     ["respawntimers"] = "respawntimers",
  74.     ["Respawn Timers"] = "Respawn Timer",
  75.     ["Respawn timer bars and warnings for trash mobs."] = "Respawn Timerbalken und Warnungen für Trashmobs",
  76.     ["bars"] = "bars",
  77.     ["Bars"] = "Balken",
  78.     ["Toggles showing bars for respawn times."] = "Zeige Balken",
  79.     ["messages"] = "messages",
  80.     ["Messages"] = "Warnungen",
  81.     ["Toggles showing messages for respawn times."] = "Sende Warnungen",
  82.  
  83.     ["%s %d respawns in %d sec"] = "%s %d respawnt in %d Sekunden",
  84.     ["%s %d respawned!"] = "%s %s respawnt",
  85.     ["Respawn: %s %d"] = "Respawn: %s %d",
  86.  
  87.     -- Molten Core Triggers
  88.     ["Ancient Core Hound"] = "Uralter Kernhund",
  89.     ["Lava Annihilator"] = "Lavavernichter",
  90.     ["Lava Surger"] = "Lavawoger",
  91.     ["Firelord"] = "Feuerlord",
  92.     ["Firewalker"] = "Feuergänger", -- Lava Pack
  93.     ["%s collapses and begins to smolder."] = "%s bricht zusammen und beginnt zu glimmen.", -- Hound Pack, emote.
  94.     -- Molten Core Messages
  95.     ["Corehound"] =  "Kernhund",
  96.     ["Annihilator"] = "Vernichter",
  97.     ["Surger"] = "Woger",
  98.     -- Firelord == Firelord.
  99.     ["Lavapack"] = "Lavapack",
  100.     ["Houndpack"] = "Kernhundpack",
  101.  
  102.     -- AQ Triggers
  103.     ["Obsidian Eradicator"] = "Obsidianzerstörer",
  104.     ["Anubisath Sentinel"] = "Wächter des Anubisath",
  105.     -- AQ Messages
  106.     ["Eradicator"] = "Zerstörer",
  107.     ["Sentinel"] = "Wächter",
  108.  
  109.     -- BWL Triggers
  110.     ["Death Talon Hatcher"] = "Brutwächter der Todeskrallen",
  111.     ["Blackwing Taskmaster"] = "Zuchtmeister der Pechschwingen",
  112.     -- BWL Messages
  113.     ["Death Talon"] = "Brutwächter",
  114.     ["Taskmaster"] = "Zuchtmeister",
  115. } end )
  116.  
  117. -- The death table and emote table are basically the meat of this addon. The
  118. -- first string is what we search for in the responding chat event, the table
  119. -- that is attached to it is: 1. respawn time in seconds, 2. the bar text and
  120. -- message text for the respawn timer, 3. optional icon path for this timer.
  121. local deathTable = {
  122.     -- MC
  123.     -- [L["Ancient Core Hound"]] = {1080, L["Corehound"], nil},
  124.     -- [L["Lava Annihilator"]]   = {7200, L["Annihilator"], nil},
  125.     -- [L["Lava Surger"]]        = {1620, L["Surger"], nil},
  126.     -- [L["Firelord"]]           = {7200, L["Firelord"], nil},
  127.     -- [L["Firewalker"]]         = {7200, L["Lavapack"], nil},
  128.     -- AQ
  129.     [L["Obsidian Eradicator"]] = {1800, L["Eradicator"], nil},
  130.     [L["Anubisath Sentinel"]]  = {1800, L["Sentinel"], nil},
  131.     -- BWL
  132.     [L["Death Talon Hatcher"]]  = {720, L["Death Talon"], nil},
  133.     [L["Blackwing Taskmaster"]] = {720, L["Taskmaster"], nil},
  134.     -- The Hinterlands
  135.     [L["Jade Ooze"]] = {350, L["Ooze"], nil},
  136. }
  137. local emoteTable = {
  138.     -- MC
  139.     [L["%s collapses and begins to smolder."]] = {3600, L["Houndpack"], nil},
  140. }
  141.  
  142. ----------------------------------
  143. --  Addon Declaration           --
  144. ----------------------------------
  145.  
  146. BigWigsRespawnTimers = BigWigs:NewModule(name)
  147. BigWigsRespawnTimers.defaultDB = {
  148.     bars = false,
  149.     messages = false,
  150. }
  151.  
  152. BigWigsRespawnTimers.consoleCmd = L["respawntimers"]
  153. BigWigsRespawnTimers.consoleOptions = {
  154.     type = "group",
  155.     name = L["Respawn Timers"],
  156.     desc = L["Respawn timer bars and warnings for trash mobs."],
  157.     args   = {
  158.         [L["bars"]] = {
  159.             type = "toggle",
  160.             name = L["Bars"],
  161.             desc = L["Toggles showing bars for respawn times."],
  162.             get = function() return BigWigsRespawnTimers.db.profile.bars end,
  163.             set = function(v) BigWigsRespawnTimers.db.profile.bars = v end,
  164.         },
  165.         [L["messages"]] = {
  166.             type = "toggle",
  167.             name = L["Messages"],
  168.             desc = L["Toggles showing messages for respawn times."],
  169.             get = function() return BigWigsRespawnTimers.db.profile.messages end,
  170.             set = function(v) BigWigsRespawnTimers.db.profile.messages = v end,
  171.         },
  172.     }
  173. }
  174. BigWigsRespawnTimers.revision = tonumber(string.sub("$Revision: 17260 $", 12, -3))
  175. BigWigsRespawnTimers.external = true
  176.  
  177. ----------------------------------
  178. --      Initialization          --
  179. ----------------------------------
  180.  
  181. function BigWigsRespawnTimers:OnEnable()
  182.     packNumber = {}
  183.     deathThrottle = {}
  184.     self:RegisterEvent("CHAT_MSG_COMBAT_HOSTILE_DEATH")
  185.     self:RegisterEvent("CHAT_MSG_MONSTER_EMOTE")
  186.     self:RegisterEvent("UNITDIESOTHER")
  187.     self:RegisterEvent("SELFKILLOTHER")
  188.     self:RegisterEvent("PARTYKILLOTHER")
  189.     self:RegisterEvent("UNITDESTROYEDOTHER")
  190. end
  191.  
  192. ----------------------------------
  193. --      Events                  --
  194. ----------------------------------
  195.  
  196. -- Basically just loop the corresponding mob table and check if the event
  197. -- arguments (death or emote) matches anything we've registered. If so, trigger
  198. -- a respawn timer.
  199.  
  200. function BigWigsRespawnTimers:CHAT_MSG_COMBAT_HOSTILE_DEATH(msg)
  201.     for key, table in pairs(deathTable) do
  202.         if msg == string.format(UNITSLAIN, key) then
  203.             self:StartRespawnTimer(table[2], table[1], table[3])
  204.             break
  205.         end
  206.     end
  207. end
  208. function BigWigsRespawnTimers:CHAT_MSG_COMBAT_HOSTILE_DEATH(msg)
  209.     for key, table in pairs(deathTable) do
  210.         if msg == string.format(SELFKILLOTHER, key) then
  211.             self:StartRespawnTimer(table[2], table[1], table[3])
  212.             break
  213.         end
  214.     end
  215. end
  216. function BigWigsRespawnTimers:CHAT_MSG_COMBAT_HOSTILE_DEATH(msg)
  217.     for key, table in pairs(deathTable) do
  218.         if msg == string.format(PARTYKILLOTHER, key) then
  219.             self:StartRespawnTimer(table[2], table[1], table[3])
  220.             break
  221.         end
  222.     end
  223. end
  224. function BigWigsRespawnTimers:CHAT_MSG_COMBAT_HOSTILE_DEATH(msg)
  225.     for key, table in pairs(deathTable) do
  226.         if msg == string.format(UNITDIESOTHER, key) then
  227.             self:StartRespawnTimer(table[2], table[1], table[3])
  228.             break
  229.         end
  230.     end
  231. end
  232. function BigWigsRespawnTimers:CHAT_MSG_COMBAT_HOSTILE_DEATH(msg)
  233.     for key, table in pairs(deathTable) do
  234.         if msg == string.format(UNITDIESSELF, key) then
  235.             self:StartRespawnTimer(table[2], table[1], table[3])
  236.             break
  237.         end
  238.     end
  239. end
  240. function BigWigsRespawnTimers:CHAT_MSG_COMBAT_HOSTILE_DEATH(msg)
  241.     for key, table in pairs(deathTable) do
  242.         if msg == string.format(UNITDIES, key) then
  243.             self:StartRespawnTimer(table[2], table[1], table[3])
  244.             break
  245.         end
  246.     end
  247. end
  248. local f = CreateFrame"Frame"
  249. f:RegisterEvent"CHAT_MSG_COMBAT_HOSTILE_DEATH"
  250. f:SetScript("OnEvent", function(this, msg)
  251.       local unit = msg:match"You have slain %s!"
  252.       if unit then self:StartRespawnTimer(table[2], table[1], table[3])
  253.             break
  254.         end
  255.     end
  256. end
  257. function BigWigsRespawnTimers:CHAT_MSG_COMBAT_HOSTILE_DEATH(msg)
  258.     for key, table in pairs(deathTable) do
  259.         if msg == msg:match"You have slain %s!" then
  260.             self:StartRespawnTimer(table[2], table[1], table[3])
  261.             break
  262.         end
  263.     end
  264. end
  265. function BigWigsRespawnTimers:CHAT_MSG_MONSTER_EMOTE(msg)
  266.     for key, table in pairs(emoteTable) do
  267.         if msg == key then
  268.             self:StartRespawnTimer(table[2], table[1], table[3])
  269.             break
  270.         end
  271.     end
  272. end
  273.  
  274. ----------------------------------
  275. --    Utility                   --
  276. ----------------------------------
  277.  
  278. function BigWigsRespawnTimers:StartRespawnTimer(message, timer, icon, throttle)
  279.     timer = tonumber(timer)
  280.     if timer == nil then return end
  281.  
  282.     -- Throttle deaths by 60 seconds.
  283.     if deathThrottle[message] and (deathThrottle[message] + 60) > GetTime() then return end
  284.     deathThrottle[message] = GetTime()
  285.  
  286.     -- Increment the pack counter after all arguments are checked and we're sure
  287.     -- to start a new respawn timer.
  288.     if not packNumber[message] then packNumber[message] = 0 end
  289.     local nextPack = packNumber[message] + 1
  290.     packNumber[message] = nextPack
  291.  
  292.     -- Make sure the user wants respawn messages.
  293.     if self.db.profile.messages then
  294.         self:ScheduleEvent("bwrt"..nextPack.."10secwarn", "BigWigs_Message", timer - 10, string.format(L["%s %d respawns in %d sec"], message, nextPack, 10), "Yellow")
  295.         self:ScheduleEvent("bwrt"..nextPack.."respawned", "BigWigs_Message", timer, string.format(L["%s %d respawned!"], message, nextPack), "Orange")
  296.     end
  297.  
  298.     -- Make sure the user wants respawn timer bars.
  299.     if self.db.profile.bars then
  300.         -- Default icon.
  301.         if not icon then icon = "Interface\\Icons\\INV_Misc_Head_Dragon_01" end
  302.         local text = string.format(L["Respawn: %s %d"], message, nextPack)
  303.         self:TriggerEvent("BigWigs_StartBar", self, text, timer, icon)
  304.         self:SetCandyBarOnClick("BigWigsBar "..text, function()
  305.             if IsControlKeyDown() then
  306.                 self:TriggerEvent("BigWigs_StopBar", self, text)
  307.                 self:CancelScheduledEvent("bwrt"..nextPack.."10secwarn")
  308.                 self:CancelScheduledEvent("bwrt"..nextPack.."respawned")
  309.             end
  310.         end)
  311.     end
  312. end


oh and it doesnt work with "You have slain (.*)!" either
  Reply With Quote
06-26-17, 05:29 AM   #9
Kakjens
A Cliff Giant
Join Date: Apr 2017
Posts: 75
For me it seems you are replacing
function BigWigsRespawnTimers:CHAT_MSG_COMBAT_HOSTILE_DEATH(msg)
several times. Those for loops should be inside one event. Or they were meant those registered but not used events?
It would be beneficial to have a debug printing that the event got triggered, as well as when match is found.
Edit. Are your locale deDE? In that case you might need to replace "You have slain (.*)!" with a German text.

Last edited by Kakjens : 06-26-17 at 05:32 AM.
  Reply With Quote
06-26-17, 08:39 AM   #10
Ketho
A Molten Giant
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 928
CHAT_MSG_COMBAT_HOSTILE_DEATH has been removed since patch 2.4.0 unless you are playing on a private server
  Reply With Quote
06-26-17, 10:19 AM   #11
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 427
Newly created user, using Ace 2, working with deprecated events. Time to get the pitchforks out.

4. Don't break WoW EULA or ToU. If you come here and post that you are selling your WoW account for real world money, offering or asking for power-levelling, in-game items or gold for real life cash, private servers or any other post that breaks WoW EULA or ToU, your post will be deleted and you will (at minimum) warned not to do it again. Repeated offenses will lead to banning from the site.
__________________
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Lua script help

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off