diff --git a/Localization.lua b/Localization.lua index 2708a62..60d71e3 100644 --- a/Localization.lua +++ b/Localization.lua @@ -1,110 +1,106 @@ local _, namespace = ... -local L = setmetatable({}, { __index = function(t, k) - local v = tostring(k) - rawset(t, k, v) - return v -end }) +local L = setmetatable({}, { + __index = function(self, key) + if key ~= nil then + --@do-not-package@ + print(string.format('Missing translation for L["%s"]', key)) + --@end-do-not-package@ + rawset(self, key, tostring(key)) + end + return tostring(key) + end, +}) namespace.L = L -local LOCALE = GetLocale() - -if LOCALE == "enUS" then - -- The EU English game client also - -- uses the US English locale code. - L[" says: "] = " says: " - L["Ah, a death knight. Ya should come see MY death gate!"] = "Ah, a death knight. Ya should come see MY death gate!" - L["Ah, ya come ta spend some time with Bwonsamdi?"] = "Ah, ya come ta spend some time with Bwonsamdi?" - L["Are we done here? Stop! I have a Heroes of the Storm match coming up, okay? Thank you. Bye bye!"] = "Are we done here? Stop! I have a Heroes of the Storm match coming up, okay? Thank you. Bye bye!" - L["Awww, did ya lose your little shiny soulstone, eh?"] = "Awww, did ya lose your little shiny soulstone, eh?" - L["Be of you. Ain't nottin for ya here now."] = "Be of you. Ain't nottin for ya here now." - L["Bomberteam"] = "Bomberteam" - L["Burning lootin', bombin' shootin'"] = "Burning lootin', bombin' shootin'" - L["Bwonsamdi"] = "Bwonsamdi" - L["Dat blink didn't get ya very far, did it?"] = "Dat blink didn't get ya very far, did it?" - L["Don't ya go forgetten our deal now... if ya want to me favor."] = "Don't ya go forgetten our deal now... if ya want to me favor." - L["Gazlowe"] = "Gazlowe" - L["Hah! Ya didn't roll out of dat one."] = "Hah! Ya didn't roll out of dat one." - L["Haha, all dat armor didn't help ya much, did it?"] = "Haha, all dat armor didn't help ya much, did it?" - L["Hek hek hek hek hek hek hek hek"] = "Hek hek hek hek hek hek hek hek" - L["Hello, hello. You're gonna make a deal, eh?"] = "Hello, hello. You're gonna make a deal, eh?" - L["Hihihi! Now dat was an impressive death!"] = "Hihihi! Now dat was an impressive death!" - L["Hm... somebody likes to play dangerous games."] = "Hm... somebody likes to play dangerous games." - L["I see dead people. Yes, kinda my ting, you know."] = "I see dead people. Yes, kinda my ting, you know." - L["I tink ya followed da wrong light, mon."] = "I tink ya followed da wrong light, mon." - L["Jani"] = "Jani" - L["Let me guess... ya got in over ya head?"] = "Let me guess... ya got in over ya head?" - L["No, no, no, ya no good to me dead. I be able to return ya to life... for a price."] = "No, no, no, ya no good to me dead. I be able to return ya to life... for a price." - L["Oh, da spirits be with ya now, mon."] = "Oh, da spirits be with ya now, mon." - L["Oh, poor little thing, ya be needin' some help from old Bwonsamdi?"] = "Oh, poor little thing, ya be needin' some help from old Bwonsamdi?" - L["Oho... a priest! If ya ever consider a change of faith, be sure you let old Bwonsamdi know, you hear?"] = "Oho... a priest! If ya ever consider a change of faith, be sure you let old Bwonsamdi know, you hear?" - L["Run along, mon. Bwonsamdi be watchin you."] = "Run along, mon. Bwonsamdi be watchin you." - L["See ya soon. Real soon..."] = "See ya soon. Real soon..." - L["Silly saurid. Ya be dead again!"] = "Silly saurid. Ya be dead again!" - L["So... what brings you to visit lonely old Bwonsamdi?"] = "So... what brings you to visit lonely old Bwonsamdi?" - L["Someting about ya seem off... Ah, da stench of a demon hunter."] = "Someting about ya seem off... Ah, da stench of a demon hunter." - L["Sooner or later, everyone comes to me."] = "Sooner or later, everyone comes to me." - L["Tsk, tsk. I did not expect ta be seein' you here so soon."] = "Tsk, tsk. I did not expect ta be seein' you here so soon." - L["Well look at you! Da mighty hero... ha!"] = "Well look at you! Da mighty hero... ha!" - L["What ya be asking of death?"] = "What ya be asking of death?" - L["What you be doin' here, mon? It not your time to pass on... yet."] = "What you be doin' here, mon? It not your time to pass on... yet." - L["When ya gone, can I be havin' your stuff?"] = "When ya gone, can I be havin' your stuff?" - L["Ya be tryin' ta feign death, mon? Shame..."] = "Ya be tryin' ta feign death, mon? Shame..." - L["Ya can't be hidin' from Bwonsamdi, little ting."] = "Ya can't be hidin' from Bwonsamdi, little ting." - L["Ya lookin' a little toasty. You wanna drink? How about, uh... ZOMBIE!"] = "Ya lookin' a little toasty. You wanna drink? How about, uh... ZOMBIE!" - L["Ya not be dreaming now, mon."] = "Ya not be dreaming now, mon." - L["Ya tink I let ya die, while you still owe me?"] = "Ya tink I let ya die, while you still owe me?" - - return -end - -if LOCALE == "deDE" then - -- German translations go here - - return -end - -if LOCALE == "frFR" then - -- French translations go here - - return -end - -if LOCALE == "esES" or LOCALE == "esMX" then - -- Spanish translations go here - - return -end - -if LOCALE == "ptBR" then - -- Brazilian Portuguese translations go here - - -- Note that the EU Portuguese WoW client also - -- uses the Brazilian Portuguese locale code. - return -end - -if LOCALE == "ruRU" then - -- Russian translations go here - - return -end - -if LOCALE == "koKR" then - -- Korean translations go here - - return -end - -if LOCALE == "zhCN" then - -- Simplified Chinese translations go here - - return +-- The EU English game client also +-- uses the US English locale code. +L[" says: "] = true +L[" whispers: "] = true +L[" yells: "] = true +L["???"] = true +L["Ah, ya come ta spend some time with Bwonsamdi?"] = true +L["All who serve the aspects SHALL BURN!"] = true +L["Are we done here? Stop! I have a Heroes of the Storm match coming up, okay? Thank you. Bye bye!"] = true +L["Awww, did ya lose your little shiny soulstone, eh?"] = true +L["Be of you. Ain't nottin for ya here now."] = true +L["Begone worms!"] = true +L["Bomberteam"] = true +L["Burning lootin', bombin' shootin'"] = true +L["But you will not survive to witness this new age."] = true +L["Bwonsamdi"] = true +L["Dat blink didn't get ya very far, did it?"] = true +L["Don't ya go forgettin' our deal now... if ya want to keep me favor."] = true +L["Drogbar"] = true +L["Fyrakk"] = true +L["Gazlowe"] = true +L["HAHAHA!!"] = true +L["Hah! Ya didn't roll out of dat one."] = true +L["Haha! Fly away little dragons."] = true +L["Haha, all dat armor didn't help ya much, did it?"] = true +L["Hek hek hek hek hek hek hek hek"] = true +L["Hello, hello. You're gonna make a deal, eh?"] = true +L["Hihihi! Now dat was an impressive death!"] = true +L["Hm... somebody likes to play dangerous games."] = true +L["Huh? Drogbar smash!"] = true +L["I am eternal."] = true +L["I see dead people. Yes, kinda my ting, you know."] = true +L["I tink ya followed da wrong light, mon."] = true +L["Jani"] = true +L["Kindling for the fire!"] = true +L["Let devastation spread!"] = true +L["Let me guess... ya got in over ya head?"] = true +L["No, no, no, ya no good to me dead. I be able to return ya to life... for a price."] = true +L["Nothing will be left standing!"] = true +L["Oh, da spirits be with ya now, mon."] = true +L["Oh, poor little thing, ya be needin' some help from old Bwonsamdi?"] = true +L["Oho... a priest! If ya ever consider a change of faith, be sure you let old Bwonsamdi know, you hear?"] = true +L["Raszageth "] = true +L["Ruin! Ruin!"] = true +L["Run along, mon. Bwonsamdi be watchin you."] = true +L["See ya soon. Real soon..."] = true +L["Silly saurid. Ya be dead again!"] = true +L["So... what brings you to visit lonely old Bwonsamdi?"] = true +L["Someting about ya seem off... Ah, da stench of a demon hunter."] = true +L["Sooner or later, everyone comes to me."] = true +L["Tsk, tsk. I did not expect ta be seein' you here so soon."] = true +L["Weak playthings of the titans! Burn!"] = true +L["Well look at you! Da mighty hero... ha!"] = true +L["What ya be asking of death?"] = true +L["What you be doin' here, mon? It not your time to pass on... yet."] = true +L["When ya gone, can I be havin' your stuff?"] = true +L["Ya be tryin' ta feign death, mon? Shame..."] = true +L["Ya can't be hidin' from Bwonsamdi, little ting."] = true +L["Ya lookin' a little thirsty. You wanna drink? How about a ZOMBIE!"] = true +L["Ya not be dreaming now, mon."] = true +L["Ya tink I let ya die, while you still owe me?"] = true +L["You end now."] = true +L["Your end was inevitable."] = true + +local locale = GetLocale() +if locale == 'frFR' then + --@localization(locale="frFR", format="lua_additive_table", handle-unlocalized="blank")@ +elseif locale == 'deDE' then + --@localization(locale="deDE", format="lua_additive_table", handle-unlocalized="blank")@ +elseif locale == 'ruRU' then + --@localization(locale="ruRU", format="lua_additive_table", handle-unlocalized="blank")@ +elseif locale == 'esES' then + --@localization(locale="esES", format="lua_additive_table", handle-unlocalized="blank")@ +elseif locale == 'zhTW' then + --@localization(locale="zhTW", format="lua_additive_table", handle-unlocalized="blank")@ +elseif locale == 'zhCN' then + --@localization(locale="zhCN", format="lua_additive_table", handle-unlocalized="blank")@ +elseif locale == 'koKR' then + --@localization(locale="koKR", format="lua_additive_table", handle-unlocalized="blank")@ +elseif locale == 'ptBR' then + --@localization(locale="ptBR", format="lua_additive_table", handle-unlocalized="blank")@ +elseif locale == 'itIT' then + --@localization(locale="itIT", format="lua_additive_table", handle-unlocalized="blank")@ end -if LOCALE == "zhTW" then - -- Traditional Chinese translations go here - - return +for k, v in pairs(L) do + if v == true then + L[k] = k + end end diff --git a/main.lua b/main.lua index b11ee79..7544f95 100644 --- a/main.lua +++ b/main.lua @@ -4,84 +4,435 @@ local L = namespace.L local f = CreateFrame("FRAME"); f:RegisterEvent("PLAYER_DEAD"); -local randomLineNumber = 0 -local _, playerclass = UnitClass("player") - -local voicelines = {} -voicelines[1] = {94633, L["What you be doin' here, mon? It not your time to pass on... yet."]} -voicelines[2] = {98420, L["No, no, no, ya no good to me dead. I be able to return ya to life... for a price."]} -voicelines[3] = {98423, L["Well look at you! Da mighty hero... ha!"]} -voicelines[4] = {98424, L["So... what brings you to visit lonely old Bwonsamdi?"]} -voicelines[5] = {98426, L["Hello, hello. You're gonna make a deal, eh?"]} -voicelines[6] = {98428, L["Hm... somebody likes to play dangerous games."]} -voicelines[7] = {98429, L["I see dead people. Yes, kinda my ting, you know."]} -voicelines[8] = {98430, L["Ya lookin' a little toasty. You wanna drink? How about, uh... ZOMBIE!"]} -voicelines[9] = {98431, L["Sooner or later, everyone comes to me."]} -voicelines[10] = {98433, L["See ya soon. Real soon..."]} -voicelines[11] = {109290, L["Run along, mon. Bwonsamdi be watchin you."]} -voicelines[12] = {113239, L["Be of you. Ain't nottin for ya here now."]} -voicelines[13] = {109293, L["Let me guess... ya got in over ya head?"]} -voicelines[14] = {109294, L["Tsk, tsk. I did not expect ta be seein' you here so soon."]} -voicelines[15] = {109295, L["Oh, poor little thing, ya be needin' some help from old Bwonsamdi?"]} -voicelines[16] = {109296, L["Hihihi! Now dat was an impressive death!"]} -voicelines[17] = {109297, L["Ah, ya come ta spend some time with Bwonsamdi?"]} -voicelines[18] = {98425, L["What ya be asking of death?"]} - -local special_voicelines = {} --19 -special_voicelines[1] = {109291, L["Ya tink I let ya die, while you still owe me?"]} -special_voicelines[2] = {98421, L["Don't ya go forgetten our deal now... if ya want to me favor."]} - -local class_voicelines = {} --20 -class_voicelines["DEMONHUNTER"] = {109299, L["Someting about ya seem off... Ah, da stench of a demon hunter."] } -class_voicelines["DEATHKNIGHT"] = {109298, L["Ah, a death knight. Ya should come see MY death gate!"] } -class_voicelines["PRIEST"] = {98414, L["Oho... a priest! If ya ever consider a change of faith, be sure you let old Bwonsamdi know, you hear?"] } -class_voicelines["DRUID"] = {109300, L["Ya not be dreaming now, mon."] } -class_voicelines["HUNTER"] = {109301, L["Ya be tryin' ta feign death, mon? Shame..."] } -class_voicelines["MAGE"] = {109302, L["Dat blink didn't get ya very far, did it?"] } -class_voicelines["MONK"] = {109303, L["Hah! Ya didn't roll out of dat one."] } -class_voicelines["PALADIN"] = {109304, L["I tink ya followed da wrong light, mon."] } -class_voicelines["ROGUE"] = {109305, L["Ya can't be hidin' from Bwonsamdi, little ting."] } -class_voicelines["SHAMAN"] = {109306, L["Oh, da spirits be with ya now, mon."] } -class_voicelines["WARLOCK"] = {109307, L["Awww, did ya lose your little shiny soulstone, eh?"] } -class_voicelines["WARRIOR"] = {109308, L["Haha, all dat armor didn't help ya much, did it?"] } - -local easteregg_voicelines = {} --21 -easteregg_voicelines[1] = {44497, L["Are we done here? Stop! I have a Heroes of the Storm match coming up, okay? Thank you. Bye bye!"], L["Gazlowe"]} -easteregg_voicelines[2] = {6254, L["Burning lootin', bombin' shootin'"], L["Bomberteam"]} -easteregg_voicelines[3] = {105675, L["Hek hek hek hek hek hek hek hek"], L["Jani"]} -easteregg_voicelines[4] = {105677, L["Silly saurid. Ya be dead again!"], L["Jani"]} -easteregg_voicelines[5] = {105683, L["When ya gone, can I be havin' your stuff?"], L["Jani"]} - -function character_says_loud(character, id, string) - print ("|cFFFFFF9F"..character..L[" says: "] ..string.."|r") - PlaySound(id, "Dialog") +local voicelines = { + -- bwonsamdi + { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 94633, + text = "What you be doin' here, mon? It not your time to pass on... yet." + }, + { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 98420, + text = "No, no, no, ya no good to me dead. I be able to return ya to life... for a price." + }, + { weight = 10, character = "Bwonsamdi", type = "say", id = 98423, text = "Well look at you! Da mighty hero... ha!" }, + { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 98424, + text = "So... what brings you to visit lonely old Bwonsamdi?" + }, + { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 98426, + text = "Hello, hello. You're gonna make a deal, eh?" + }, + { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 98428, + text = "Hm... somebody likes to play dangerous games." + }, + { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 98429, + text = "I see dead people. Yes, kinda my ting, you know." + }, + { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 98430, + text = "Ya lookin' a little thirsty. You wanna drink? How about a ZOMBIE!" + }, + { weight = 10, character = "Bwonsamdi", type = "say", id = 98431, text = "Sooner or later, everyone comes to me." }, + { weight = 10, character = "Bwonsamdi", type = "say", id = 98433, text = "See ya soon. Real soon..." }, + { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 109290, + text = "Run along, mon. Bwonsamdi be watchin you." + }, + { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 113239, + text = "Be of you. Ain't nottin for ya here now." + }, + { weight = 10, character = "Bwonsamdi", type = "say", id = 109293, text = "Let me guess... ya got in over ya head?" }, + { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 109294, + text = "Tsk, tsk. I did not expect ta be seein' you here so soon." + }, + { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 109295, + text = "Oh, poor little thing, ya be needin' some help from old Bwonsamdi?" + }, + { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 109296, + text = "Hihihi! Now dat was an impressive death!" + }, + { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 109297, + text = "Ah, ya come ta spend some time with Bwonsamdi?" + }, + { weight = 10, character = "Bwonsamdi", type = "say", id = 98425, text = "What ya be asking of death?" }, + -- eastereggs + { + weight = 1, + character = "Gazlowe", + type = "say", + id = 44497, + text = + "Are we done here? Stop! I have a Heroes of the Storm match coming up, okay? Thank you. Bye bye!" + }, + { weight = 1, character = "Bomberteam", type = "say", id = 6254, text = "Burning lootin', bombin' shootin'" }, + { weight = 1, character = "Jani", type = "say", id = 105675, text = "Hek hek hek hek hek hek hek hek" }, + { weight = 1, character = "Jani", type = "say", id = 105677, text = "Silly saurid. Ya be dead again!" }, + { + weight = 1, + character = "Jani", + type = "say", + id = 105683, + text = + "When ya gone, can I be havin' your stuff?" + }, + { weight = 1, character = "Drogbar", type = "yell", id = 224969, text = "Huh? Drogbar smash!" }, + -- CANT BE PLAYED: { weight = 1, character = "???", type = "whisper", id = 222701, text = "I am eternal." }, + -- CANT BE PLAYED: { weight = 1, character = "???", type = "whisper", id = 222703, text = "You end now." }, + -- dragons + -- CANT BE PLAYED: { weight = 10, character = "Fyrakk", type = "yell", id = 222092, text = "Kindling for the fire!" }, + -- CANT BE PLAYED: { weight = 10, character = "Fyrakk", type = "yell", id = 222091, text = "All who serve the aspects SHALL BURN!" }, + -- CANT BE PLAYED: { weight = 10, character = "Fyrakk", type = "say", id = 222492, text = "HAHAHA!!" }, + { weight = 10, character = "Fyrakk", type = "say", id = 222437, text = "Haha! Fly away little dragons." }, + { weight = 10, character = "Fyrakk", type = "say", id = 222586, text = "Begone worms!" }, + { weight = 10, character = "Fyrakk", type = "yell", id = 222497, text = "Weak playthings of the titans! Burn!" }, + -- CANT BE PLAYED: { weight = 10, character = "Raszageth", type = "yell", id = 202099, text = "Your end was inevitable." }, + -- CANT BE PLAYED: { weight = 10, character = "Raszageth", type = "yell", id = 202015, text = "Ruin! Ruin!" }, + -- CANT BE PLAYED: { weight = 10, character = "Raszageth", type = "yell", id = 202014, text = "Nothing will be left standing!" }, + -- CANT BE PLAYED: { weight = 10, character = "Raszageth", type = "yell", id = 202010, text = "Let devastation spread!" }, + -- CANT BE PLAYED: { weight = 10, character = "Raszageth", type = "yell", id = 202024, text = "But you will not survive to witness this new age." }, + + -- ??? TODO: figure out characters & implement later, probably to spoilery right now + --{ weight = 5, character = "???", type = "say", id = 222351, text = "You have come so far, my child." }, + --{ weight = 5, character = "???", type = "say", id = 222350, text = "Together... always." }, + --{ weight = 5, character = "???", type = "say", id = 221958, text = "You cannot go. I am not ready." }, +} + +-- add Quest specific voicelines +if C_QuestLog.IsQuestFlaggedCompleted(47250) then + voicelines[#voicelines + 1] = { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 109291, + text = "Ya tink I let ya die, while you still owe me?" + } + voicelines[#voicelines + 1] = { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 98421, + text = "Don't ya go forgettin' our deal now... if ya want to keep me favor." + } end -function dealTheDice() - randomLineNumber = math.random(1, 21) - if randomLineNumber > 0 and randomLineNumber < 19 then - character_says_loud(L["Bwonsamdi"], voicelines[randomLineNumber][1], voicelines[randomLineNumber][2]) - elseif randomLineNumber == 19 then - if C_QuestLog.IsQuestFlaggedCompleted(47250) then - randomLineNumber = math.random(1, 2) - character_says_loud(L["Bwonsamdi"], special_voicelines[randomLineNumber][1], special_voicelines[randomLineNumber][2]) - else - dealTheDice() - end - elseif randomLineNumber == 20 then - character_says_loud(L["Bwonsamdi"], class_voicelines[playerclass][1], class_voicelines[playerclass][2]) - elseif randomLineNumber == 21 then - randomLineNumber = math.random(1, 10) - if randomLineNumber <= #easteregg_voicelines then - character_says_loud(easteregg_voicelines[randomLineNumber][3], easteregg_voicelines[randomLineNumber][1], easteregg_voicelines[randomLineNumber][2]) - else - dealTheDice() +-- add Class specific voicelines +local function add_class_voicelines(playerclass) + if playerclass == nil then + local _, playerclass = UnitClass("player") + end + if playerclass == "WARRIOR" then + voicelines[#voicelines + 1] = { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 109308, + text = "Haha, all dat armor didn't help ya much, did it?" + } + elseif playerclass == "PALADIN" then + voicelines[#voicelines + 1] = { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 109304, + text = "I tink ya followed da wrong light, mon." + } + elseif playerclass == "HUNTER" then + voicelines[#voicelines + 1] = { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 109301, + text = "Ya be tryin' ta feign death, mon? Shame..." + } + elseif playerclass == "ROGUE" then + voicelines[#voicelines + 1] = { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 109305, + text = "Ya can't be hidin' from Bwonsamdi, little ting." + } + elseif playerclass == "PRIEST" then + voicelines[#voicelines + 1] = { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 98414, + text = "Oho... a priest! If ya ever consider a change of faith, be sure you let old Bwonsamdi know, you hear?" + } + elseif playerclass == "DEATHKNIGHT" then + voicelines[#voicelines + 1] = { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 109298, + text = "Ah, a death knight. Ya should come see MY death gate!" + } + elseif playerclass == "SHAMAN" then + voicelines[#voicelines + 1] = { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 109306, + text = "Oh, da spirits be with ya now, mon." + } + elseif playerclass == "MAGE" then + voicelines[#voicelines + 1] = { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 109302, + text = "Dat blink didn't get ya very far, did it?" + } + elseif playerclass == "WARLOCK" then + voicelines[#voicelines + 1] = { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 109307, + text = "Awww, did ya lose your little shiny soulstone, eh?" + } + elseif playerclass == "MONK" then + voicelines[#voicelines + 1] = { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 109303, + text = "Hah! Ya didn't roll out of dat one." + } + elseif playerclass == "DRUID" then + voicelines[#voicelines + 1] = { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 109300, + text = "Ya not be dreaming now, mon." + } + elseif playerclass == "DEMONHUNTER" then + voicelines[#voicelines + 1] = { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 109299, + text = "Someting about ya seem off... Ah, da stench of a demon hunter." + } + end +end +add_class_voicelines(nil) + + +-- actual code & calculations +local function calculateTotalWeight(table) + local totalWeight = 0 + for _, element in ipairs(table) do + totalWeight = totalWeight + element.weight + end + return totalWeight +end + +local lastExecutionTime = 0 +local totalWeight = calculateTotalWeight(voicelines) + +local function play_voiceline(character, yell_or_say, id, string) + if yell_or_say == "say" then + print("|cFFFFFF9F" .. L[character] .. L[" says: "] .. L[string] .. "|r") + PlaySound(id, "Dialog") + elseif yell_or_say == "yell" then + print("|cFFFF3F40" .. L[character] .. L[" yells: "] .. L[string] .. "|r") + PlaySound(id, "Dialog") + elseif yell_or_say == "whisper" then + print("|cFFC0C0C0" .. L[character] .. L[" whispers: "] .. L[string] .. "|r") + PlaySound(id, "Dialog") + end +end + +local function randomWeightedElement(voice_table, totalWeight) + -- Generate a random number within the total weight range + local randomValue = math.random() * totalWeight + + -- Iterate over the elements and select the one based on the cumulative weight + local cumulativeWeight = 0 + for _, element in ipairs(voice_table) do + cumulativeWeight = cumulativeWeight + element.weight + if randomValue <= cumulativeWeight then + return element end end + + -- In case of an empty table or unexpected conditions, return nil + return nil +end + +local function play_random_voiceline() + -- Only run this function every 3 seconds at most + local timeElapsed = GetTime() - lastExecutionTime + -- Check if the time elapsed is less than 5 seconds + if timeElapsed < 3 then + --@do-not-package@ + print("Bwonsamdi: Called too soon.") + --@end-do-not-package@ + -- Discard the function call + return + end + -- Update last execution time + lastExecutionTime = GetTime() + + -- Get a random voiceline + local random_voiceline = randomWeightedElement(voicelines, totalWeight) + if random_voiceline == nil then + return + end + play_voiceline(random_voiceline.character, random_voiceline.type, random_voiceline.id, random_voiceline.text) end f:SetScript("OnEvent", function(self, event, ...) if event == "PLAYER_DEAD" then - dealTheDice() -end + play_random_voiceline() + end end) + + +--@do-not-package@ + +-- THE FOLLOWING IS SHITTY CODE FOR DEVELOPMENT PURPOSES ONLY ^^' +-- IT SHOULD NOT BE INCLUDED IN THE RELEASE VERSION + +-- Function to open the translation dialog +local function openTranslationDialog(missingTranslations) + -- Create a custom dialog frame + StaticPopupDialogs["MISSING_TRANSLATIONS_DIALOG"] = { + text = "Missing Translations", + button1 = "Close", + hasEditBox = true, + editBoxWidth = 350, + editBoxHeight = 200, + timeout = 0, + whileDead = true, + hideOnEscape = true, + preferredIndex = 3, + OnShow = function(self) + -- Set the text of the edit box to the missing translations + self.editBox:SetText(missingTranslations) + self.editBox:SetFocus() + self.editBox:HighlightText() + end, + OnHide = function(self) + self.editBox:SetText("") -- Clear the text when closing the dialog + end, + } + + -- Show the custom dialog + StaticPopup_Show("MISSING_TRANSLATIONS_DIALOG") +end + +-- Function to handle the slash command +local function Bwonsamdi_HandleSlashCommand(msg) + if msg == "translations" then + add_class_voicelines("WARRIOR") + add_class_voicelines("PALADIN") + add_class_voicelines("HUNTER") + add_class_voicelines("ROGUE") + add_class_voicelines("PRIEST") + add_class_voicelines("SHAMAN") + add_class_voicelines("MAGE") + add_class_voicelines("WARLOCK") + add_class_voicelines("MONK") + add_class_voicelines("DRUID") + add_class_voicelines("DEMONHUNTER") + voicelines[#voicelines + 1] = { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 109291, + text = "Ya tink I let ya die, while you still owe me?" + } + voicelines[#voicelines + 1] = { + weight = 10, + character = "Bwonsamdi", + type = "say", + id = 98421, + text = "Don't ya go forgettin' our deal now... if ya want to keep me favor." + } + local Translations = {} + table.insert(Translations, "L[\" whispers: \"] = true") + table.insert(Translations, "L[\" says: \"] = true") + table.insert(Translations, "L[\" yells: \"] = true") + for _, element in ipairs(voicelines) do + table.insert(Translations, "L[\"" .. element.character .. "\"] = true") + table.insert(Translations, "L[\"" .. element.text .. "\"] = true") + end + + local set = {} + local deduplicatedTranslations = {} + for _, value in ipairs(Translations) do + if not set[value] then + table.insert(deduplicatedTranslations, value) + set[value] = true + end + end + + table.sort(deduplicatedTranslations) + + openTranslationDialog(table.concat(deduplicatedTranslations, "\n")) + elseif msg == "test" then + play_random_voiceline() + else + print("Bwonsamdi: Slash commands:") + print("Bwonsamdi: /bwonsamdi translations - Open the translation dialog") + print("Bwonsamdi: /bwonsamdi test - Play a random voiceline") + end +end + +-- Register the slash command handler +SlashCmdList["BWONSAMDI"] = Bwonsamdi_HandleSlashCommand +SLASH_BWONSAMDI1 = "/bwonsamdi" + +print("Bwonsamdi: loaded!") +--@end-do-not-package@