Compare with Previous | Blame | View Log
-- The Ultimate Warcraft Battlecry Generator -- =========================================== -- Version : 1.0.66 -- Author : Nuchaleft (NytewolfAU2k7 on Curse) -- Email : nwcreations@gmail.com -- Create Date : 10/07/2008 01:11:43 PM WAST (GMT+8:00) -- Update : 28/08/2010 04:59 PM WAST (GMT+8:00) -- =========================================== UltimateWarcraftBattlecryGenerator = LibStub("AceAddon-3.0"):NewAddon("UltimateWarcraftBattlecryGenerator", "AceConsole-3.0", "AceEvent-3.0", "AceSerializer-3.0") local L = LibStub('AceLocale-3.0'):GetLocale('UltimateWarcraftBattlecryGenerator') if UltimateWarcraftBattlecryGenerator.version == "wowi:revision" then UltimateWarcraftBattlecryGenerator.version = "SVN"; end; -- Declare our Generator Variables local n_idx_a = 0; --Alliance Cry Index local n_idx_h = 0; --Horde Cry Index local n_idx_u = 0; --Unaligned Cry Index local s_bcgsay1 = ""; --ally say var local s_bcgsay2 = ""; --pond scum say var local s_bcgsay3 = ""; --evil say var local s_final = ""; local s_channel = ""; --Channel Name -- Current BCG VERSION local MY_BCG_VER_MAJOR='1'; local MY_BCG_VER_MINOR='0'; local MY_BCG_VER_REV='66'; -- ON LOAD EVENT function UltimateWarcraftBattlecryGenerator:OnInitialize() self.frames = {} self:BCG_GlobalChatCommands(); --BCG -- Bug #23 workaround if UWBG_Prefs.bcg_hideframe==nil then UWBG_Prefs.bcg_hideframe=0; end; if UWBG_Prefs.bcg_allpossible==nil then UWBG_Prefs.bcg_allpossible=0; end; -- Load main frame. self:BCG_CreateMainFrame(); lblBCGTitle:SetText(BCG_PrintVersion2()); -- Identify us, should only show full list the 'first' time our addon is loaded. -- subsequent launches show short list. if UWBG_Prefs.bcg_first_run == 0 or UWBG_Prefs.bcg_first_run == nil then BCG_SendMsg("|cff999999 Ultimate Warcraft Battlecry Generator is Loaded\n"); BCG_SendMsg("|cff999999 Version " .. MY_BCG_VER_MAJOR .. "." .. MY_BCG_VER_MINOR .. "." .. MY_BCG_VER_REV .. " for WoW Patch 3.3+\n"); BCG_SendMsg("|cff6666ff Type /bcg or /uwbcg for options\n"); UWBG_Prefs.bcg_first_run=1; else BCG_SendMsg("|cff999999 Loaded UWBCG v" .. MY_BCG_VER_MAJOR .. "." .. MY_BCG_VER_MINOR .. "." .. MY_BCG_VER_REV .. " for WoW Patch 3.3+\n"); UWBG_Prefs.bcg_first_run=1; end end -- Sends a message to default chat frame. function BCG_SendMsg(msg) if( DEFAULT_CHAT_FRAME ) then DEFAULT_CHAT_FRAME:AddMessage(msg); end; end; -- Show how to use the addon. function UltimateWarcraftBattlecryGenerator:BCG_ShowCommands() BCG_SendMsg("|cff6666ff Usage:\n"); BCG_SendMsg("|cff999999 /bcg show OR /bcg hide Open Panel"); BCG_SendMsg("|cff999999 /bcg cfg OR /bcg options Open Options Panel"); BCG_SendMsg("|cff999999 /bcg y (Yell)"); BCG_SendMsg("|cff999999 /bcg s (Say)"); BCG_SendMsg("|cff999999 /bcg p (Party)"); BCG_SendMsg("|cff999999 /bcg g (Guild)"); BCG_SendMsg("|cff999999 /bcg r (Raid)"); BCG_SendMsg("|cff999999 /bcg bg (Battleground)"); end function UltimateWarcraftBattlecryGenerator:BCG_GlobalChatCommands() -- Register the slash commands self:RegisterChatCommand('bcg', 'BCG_HandleSlashCommands'); self:RegisterChatCommand('uwbcg', 'BCG_HandleSlashCommands'); end; function UltimateWarcraftBattlecryGenerator:BCG_HandleSlashCommands(cmd) cmd = cmd and cmd:lower() or '' if cmd == 's' or cmd == 'say' then MakeOneUp("s",UWBG_Prefs.bcg_allpossible); SendChatMessage(s_final, "SAY", nil); elseif cmd == 'y' then MakeOneUp("y",UWBG_Prefs.bcg_allpossible); SendChatMessage(s_final, "YELL", nil); elseif cmd == 'p' then MakeOneUp("s",UWBG_Prefs.bcg_allpossible); SendChatMessage(s_final, "PARTY", nil); elseif cmd == 'g' then MakeOneUp("s",UWBG_Prefs.bcg_allpossible); SendChatMessage(s_final, "GUILD", nil); elseif cmd == 'r' then MakeOneUp("s",UWBG_Prefs.bcg_allpossible); SendChatMessage(s_final, "RAID", nil); elseif cmd == 'bg' then MakeOneUp("s",UWBG_Prefs.bcg_allpossible); SendChatMessage(s_final, "BATTLEGROUND", nil); elseif cmd == 'ver' then self:BCG_PrintVersion(); elseif cmd == 'show' then if bcg_frame:IsVisible() == true then bcg_frame:Hide(); else bcg_frame:Show(); end; elseif cmd == 'hide' then if bcg_frame:IsVisible() == false then bcg_frame:Show(); else bcg_frame:Hide(); end; elseif cmd == 'cfg' then self:BCG_ShowOptions(); elseif cmd == '?' or cmd == 'help' then self:BCG_ShowCommands(); else if not self:ShowOptions() then self:BCG_ShowCommands(); end end end; function UltimateWarcraftBattlecryGenerator:BCG_PrintVersion() BCG_SendMsg("|cff999999 Loaded UWBCG v" .. MY_BCG_VER_MAJOR .. "." .. MY_BCG_VER_MINOR .. "." .. MY_BCG_VER_REV .. " for WoW Patch 3.3+\n"); end; function BCG_PrintVersion2() return "" .. MY_BCG_VER_MAJOR .. "." .. MY_BCG_VER_MINOR .. "." .. MY_BCG_VER_REV; end; function UltimateWarcraftBattlecryGenerator:BCG_ShowOptions() BCG_SendMsg("UWBCG Test: Opening options panel to category."); InterfaceOptionsFrame_OpenToCategory("UWBCG v" .. BCG_PrintVersion2()); end; function UltimateWarcraftBattlecryGenerator:BCG_CreateMainFrame() if UWBG_Prefs.bcg_hideframe==0 and frmBCG:IsVisible()==false then frmBCG:Show(); UWBG_Prefs.bcg_hideframe=1; else frmBCG:Hide(); UWBG_Prefs.bcg_hideframe=0; end; end; -- Just in case the previous did not work. function UltimateWarcraftBattlecryGenerator:OnEnable() -- Workaround, for an issue with slash commands -- and the allpossible prefix config. if UWBG_Prefs.bcg_allpossible == nil then UWBG_Prefs.bcg_allpossible=0; end; end; -- GENERATE A FACTION-SPECIFIC BATTLECRY! function GenerateFactionBattlecry(ransom_msg,channel) local pc_faction = UnitFactionGroup("player"); if (pc_faction == "Alliance") then --DEFAULT_CHAT_FRAME:AddMessage("UWBCG Test: I am Alliance.");--Test message if UnitName("target") == nil then --Do we have no target? SendChatMessage(GetRandomArgument("DIE! Feel the wrath of the " .. ransom_msg .. "!","Light BURN you!", "For the " .. ransom_msg .. "!","All who betray the " .. ransom_msg .. " shall be punished!","I smite thee, In the name of the " .. ransom_msg .. "!","DIE! Your evil shall never triumph!","Your evil ends here!", "We Fight!", "DIE! Your evil shall be purged!", "You DARE face me?","The Light shall never fade!", "You will face justice!","There can only be 1000!","There can only be over 9000!","For Cenarius!","For Stormwind!","For Ironforge!","For Darnassus!","For Gnomeregan!","By the power of " .. ransom_msg .. "!"), channel); else SendChatMessage(GetRandomArgument("DIE, %t! Feel the wrath of the " .. ransom_msg .. "!","Light BURN you, %t!", "For the " .. ransom_msg .. "!","All who betray the light shall be punished!","I smite thee, %t, In the name of the " .. ransom_msg .. "!","DIE, %t! Your evil shall never triumph!","Your evil ends here, %t!", "DIE! %t! Your evil shall be purged!", "You DARE face me?","The Light shall never fade!", "You will face justice!","There can only be 1000!","There can only be over 9000!","For Cenarius!","For the Warchief!","For Stormwind!","For Ironforge!","For Darnassus!","For Gnomeregan!","By the power of " .. ransom_msg .. "!"), channel); end; elseif (pc_faction == "Horde") then --DEFAULT_CHAT_FRAME:AddMessage("UWBCG Test: I am Horde.");--Test message if UnitName("target") == nil then --Do we have no target? SendChatMessage(GetRandomArgument("DIE! Feel the wrath of the " .. ransom_msg .. "!","Light BURN you!", "For the " .. ransom_msg .. "!","All who betray the light shall be punished!","Your blood shall be mine!","DIE! Your evil shall never triumph!","Your evil ends here!", "DIE! Your evil shall be purged!", "You DARE face me?","The Light shall never fade!", "You will bring me great honor!","There can only be 1000!","There can only be over 9000!","For the Warchief!","For Ogrimmar!","For Undercity!","For Silvermoon City!","For Quel'Thalas!"), channel); else SendChatMessage(GetRandomArgument("DIE, %t! Feel the wrath of the " .. ransom_msg .. "!","Light BURN you, %t!", "For the " .. ransom_msg .. "!","All who betray the light shall be punished!","%t! Your blood shall be mine!","DIE, %t! Your evil shall never triumph!","Your evil ends here, %t!", "DIE! %t! Your evil shall be purged!", "You DARE face me?","The Light shall never fade!", "You will bring me great honor!","There can only be 1000!","There can only be over 9000!","For the Warchief!","For Ogrimmar!","For Undercity!","For Silvermoon City!","For Quel'Thalas!"), channel); end; end; end; -- GENERATE A NON FACTION-SPECIFIC BATTLECRY! function GenerateBattlecry(ransom_msg,channel) if UnitName("target") == nil then --Do we have no target? SendChatMessage(GetRandomArgument("DIE! Feel the wrath of the " .. ransom_msg .. "!","Light BURN you!", "For the " .. ransom_msg .. "!","All who betray the " .. ransom_msg .. " shall be punished!","I smite thee, In the name of the " .. ransom_msg .. "!","DIE! Your evil shall never triumph!","Your evil ends here!", "We Fight!", "DIE! Your evil shall be purged!", "You DARE face me?","The Light shall never fade!", "You will face justice!","There can only be 1000!","There can only be over 9000!","For Cenarius!","For <Insert Battlecry here!>","For Ironforge!","For Darnassus!","For Gnomeregan!","By the power of " .. ransom_msg .. "!"), channel); else SendChatMessage(GetRandomArgument("DIE, %t! Feel the wrath of the " .. ransom_msg .. "!","Light BURN you, %t!", "For the " .. ransom_msg .. "!","Just so you know, %t, All who betray the light shall be punished!","I smite thee, %t, In the name of the " .. ransom_msg .. "!","DIE, %t! Your evil shall never triumph!","Your evil ends here, %t!", "DIE! %t! Your evil shall be purged!", "You DARE face me? %t?","The Light shall never fade, %t!", "You will face justice, %t!","%t, There can only be 1000!","There can only be over 9000!","For Cenarius!","For the Warchief!","For Stormwind!","For Ironforge!","For Darnassus!","For Gnomeregan!","By the power of " .. ransom_msg .. "!"), channel); end; end; function GenerateFactionBattlecryANT(ransom_msg) return GetRandomArgument("DIE! Feel the wrath of the " .. ransom_msg .. "!","Light BURN you!", "For the " .. ransom_msg .. "!","All who betray the " .. ransom_msg .. " shall be punished!","I smite thee, In the name of the " .. ransom_msg .. "!","DIE! Your evil shall never triumph!","Your evil ends here!", "We Fight!", "DIE! Your evil shall be purged!", "You DARE face me?","The Light shall never fade!", "You will face justice!","There can only be 1000!","There can only be over 9000!","For Cenarius!","For Stormwind!","For Ironforge!","For Darnassus!","For Gnomeregan!"); end; function GenerateFactionBattlecryAT(ransom_msg) return GetRandomArgument("DIE, %t! Feel the wrath of the " .. ransom_msg .. "!","Light BURN you, %t!", "For the " .. ransom_msg .. "!","All who betray the light shall be punished!","I smite thee, %t, In the name of the " .. ransom_msg .. "!","DIE, %t! Your evil shall never triumph!","Your evil ends here, %t!", "DIE! %t! Your evil shall be purged!", "You DARE face me?","The Light shall never fade!", "You will face justice!","There can only be 1000!","There can only be over 9000!","For Cenarius!","For the Warchief!","For Stormwind!","For Ironforge!","For Darnassus!","For Gnomeregan!"); end; function GenerateFactionBattlecryHNT(ransom_msg) return GetRandomArgument("DIE! Feel the wrath of the " .. ransom_msg .. "!","Light BURN you!", "For the " .. ransom_msg .. "!","All who betray the light shall be punished!","Your blood shall be mine!","DIE! Your evil shall never triumph!","Your evil ends here!", "DIE! Your evil shall be purged!", "You DARE face me?","The Light shall never fade!", "You will bring me great honor!","There can only be 1000!","There can only be over 9000!","For the Warchief!","For Ogrimmar!","For Undercity!","For Silvermoon City!","For Quel'Thalas!"); end; function GenerateFactionBattlecryHT(ransom_msg) return GetRandomArgument("DIE, %t! Feel the wrath of the " .. ransom_msg .. "!","Light BURN you, %t!", "For the " .. ransom_msg .. "!","All who betray the light shall be punished!","%t! Your blood shall be mine!","DIE, %t! Your evil shall never triumph!","Your evil ends here, %t!", "DIE! %t! Your evil shall be purged!", "You DARE face me?","The Light shall never fade!", "You will bring me great honor!","There can only be 1000!","There can only be over 9000!","For the Warchief!","For Ogrimmar!","For Undercity!","For Silvermoon City!","For Quel'Thalas!"); end; -- Hide this addon from view. function btnClose_Click() frmBCG:Hide(); UWBG_Prefs.bcg_hideframe=1; end; -- Show usage, This will use the new method. -- This is provided for backwards compatability. function btnUsage_Click() self:BCG_ShowCommands(); end; -- SAY BCG function BCG_SAY_BATTLECRY() -- fetch an array/table n_say1 = table.getn( PossSuff1 ); n_say2 = table.getn( PossSuff2 ); n_say3 = table.getn( PossSuff3 ); -- Randomize n_idx_a = math.random( n_say1 ); n_idx_h = math.random( n_say2 ); n_idx_u = math.random( n_say3 ); -- populate s_bcgsay1 with a random value. s_bcgsay1 = PossSuff1[n_idx_a]; -- populate s_bcgsay2 with a random value. s_bcgsay2 = PossSuff2[n_idx_h]; -- populate s_bcgsay3 with a random value. s_bcgsay3 = PossSuff3[n_idx_u]; if f_ignore == 0 or f_ignore == nil then local pc_faction = UnitFactionGroup("player"); if (pc_faction == "Alliance") then GenerateFactionBattlecry(s_bcgsay1, "SAY"); elseif (pc_faction == "Horde") then GenerateFactionBattlecry(s_bcgsay2, "SAY"); end; elseif f_ignore == 1 then GenerateBattlecry(s_bcgsay3); end; end; -- YELL BCG function BCG_YELL_BATTLECRY() -- fetch an array/table n_say1 = table.getn( PossSuff1 ); n_say2 = table.getn( PossSuff2 ); n_say3 = table.getn( PossSuff3 ); -- Randomize n_idx_a = math.random( n_say1 ); n_idx_h = math.random( n_say2 ); n_idx_u = math.random( n_say3 ); -- populate s_bcgsay1 with a random value. s_bcgsay1 = PossSuff1[n_idx_a]; -- populate s_bcgsay2 with a random value. s_bcgsay2 = PossSuff2[n_idx_h]; -- populate s_bcgsay3 with a random value. s_bcgsay3 = PossSuff3[n_idx_u]; if f_ignore == 0 or f_ignore == nil then local pc_faction = UnitFactionGroup("player"); if (pc_faction == "Alliance") then GenerateFactionBattlecry(s_bcgsay1, "YELL"); elseif (pc_faction == "Horde") then GenerateFactionBattlecry(s_bcgsay2, "YELL"); end; elseif f_ignore == 1 then GenerateBattlecry(s_bcgsay3); end; end; -- PARTY BCG function BCG_PARTY_BATTLECRY() -- fetch an array/table n_say1 = table.getn( PossSuff1 ); n_say2 = table.getn( PossSuff2 ); n_say3 = table.getn( PossSuff3 ); -- Randomize n_idx_a = math.random( n_say1 ); n_idx_h = math.random( n_say2 ); n_idx_u = math.random( n_say3 ); -- populate s_bcgsay1 with a random value. s_bcgsay1 = PossSuff1[n_idx_a]; -- populate s_bcgsay2 with a random value. s_bcgsay2 = PossSuff2[n_idx_h]; -- populate s_bcgsay3 with a random value. s_bcgsay3 = PossSuff3[n_idx_u]; if f_ignore == 0 or f_ignore == nil then local pc_faction = UnitFactionGroup("player"); if (pc_faction == "Alliance") then GenerateFactionBattlecry(s_bcgsay1, "PARTY"); elseif (pc_faction == "Horde") then GenerateFactionBattlecry(s_bcgsay2, "PARTY"); end; elseif f_ignore == 1 then GenerateBattlecry(s_bcgsay3); end; end; -- RAID BCG function BCG_RAID_BATTLECRY() -- fetch an array/table n_say1 = table.getn( PossSuff1 ); n_say2 = table.getn( PossSuff2 ); n_say3 = table.getn( PossSuff3 ); -- Randomize n_idx_a = math.random( n_say1 ); n_idx_h = math.random( n_say2 ); n_idx_u = math.random( n_say3 ); -- populate s_bcgsay1 with a random value. s_bcgsay1 = PossSuff1[n_idx_a]; -- populate s_bcgsay2 with a random value. s_bcgsay2 = PossSuff2[n_idx_h]; -- populate s_bcgsay3 with a random value. s_bcgsay3 = PossSuff3[n_idx_u]; if f_ignore == 0 or f_ignore == nil then local pc_faction = UnitFactionGroup("player"); if (pc_faction == "Alliance") then GenerateFactionBattlecry(s_bcgsay1, "RAID"); elseif (pc_faction == "Horde") then GenerateFactionBattlecry(s_bcgsay2, "RAID"); end; elseif f_ignore == 1 then GenerateBattlecry(s_bcgsay3); end; end; -- BATTLEGROUND BCG function BCG_BATTLEGROUND_BATTLECRY() -- fetch an array/table n_say1 = table.getn( PossSuff1 ); n_say2 = table.getn( PossSuff2 ); n_say3 = table.getn( PossSuff3 ); -- Randomize n_idx_a = math.random( n_say1 ); n_idx_h = math.random( n_say2 ); n_idx_u = math.random( n_say3 ); -- populate s_bcgsay1 with a random value. s_bcgsay1 = PossSuff1[n_idx_a]; -- populate s_bcgsay2 with a random value. s_bcgsay2 = PossSuff2[n_idx_h]; -- populate s_bcgsay3 with a random value. s_bcgsay3 = PossSuff3[n_idx_u]; if f_ignore == 0 or f_ignore == nil then local pc_faction = UnitFactionGroup("player"); if (pc_faction == "Alliance") then GenerateFactionBattlecry(s_bcgsay1, "BATTLEGROUND"); elseif (pc_faction == "Horde") then GenerateFactionBattlecry(s_bcgsay2, "BATTLEGROUND"); end; elseif f_ignore == 1 then GenerateBattlecry(s_bcgsay3); end; end; -- Makes up a battlecry. -- WhatKind: The kind of battlecry to make, -- this is the tone of voice, Y for yell, S for normal tone. -- f_ignore: set to true to ignore faction battle -- cry restrictions. Old alpha mode. Can be set via options function MakeOneUp(WhatKind,f_ignore) -- fetch an array/table n_say1 = table.getn( PossSuff1 ); n_say2 = table.getn( PossSuff2 ); n_say3 = table.getn( PossSuff3 ); -- Randomize n_idx_a = math.random( n_say1 ); n_idx_h = math.random( n_say2 ); n_idx_u = math.random( n_say3 ); -- populate s_bcgsay1 with a random value. s_bcgsay1 = PossSuff1[n_idx_a]; -- populate s_bcgsay2 with a random value. s_bcgsay2 = PossSuff2[n_idx_h]; -- populate s_bcgsay3 with a random value. s_bcgsay3 = PossSuff3[n_idx_u]; if UnitName("target") == nil then if (WhatKind == "s") then if f_ignore == 0 or f_ignore == nil then local pc_faction = UnitFactionGroup("player"); if (pc_faction == "Alliance") then s_final = GenerateFactionBattlecryANT(s_bcgsay1); elseif (pc_faction == "Horde") then s_final = GenerateFactionBattlecryHNT(s_bcgsay2); end; elseif f_ignore == 1 then s_final = GenerateBattlecry(s_bcgsay3); end; elseif (WhatKind == "y") then if f_ignore == 0 or f_ignore == nil then local pc_faction = UnitFactionGroup("player"); if (pc_faction == "Alliance") then s_final = GenerateFactionBattlecryANT(s_bcgsay1); elseif (pc_faction == "Horde") then s_final = GenerateFactionBattlecryHNT(s_bcgsay2); end; elseif f_ignore == 1 then s_final = GenerateBattlecry(s_bcgsay3); end; end; else if (WhatKind == "s") then if f_ignore == 0 or f_ignore == nil then local pc_faction = UnitFactionGroup("player"); if (pc_faction == "Alliance") then s_final = GenerateFactionBattlecryAT(s_bcgsay1); elseif (pc_faction == "Horde") then s_final = GenerateFactionBattlecryHT(s_bcgsay2); end; elseif f_ignore == 1 then s_final = GenerateBattlecry(s_bcgsay3); end; elseif (WhatKind == "y") then if f_ignore == 0 or f_ignore == nil then local pc_faction = UnitFactionGroup("player"); if (pc_faction == "Alliance") then s_final = GenerateFactionBattlecryAT(s_bcgsay1); elseif (pc_faction == "Horde") then s_final = GenerateFactionBattlecryHT(s_bcgsay2); end; elseif f_ignore == 1 then s_final = GenerateBattlecry(s_bcgsay3); end; end; end; end;