WoWInterface SVN UltimateWarcraftBattlecryGenerator

[/] [trunk/] [BattleCryGen.lua] - Rev 52

Compare with Previous | Blame | View Log

-- The Ultimate Warcraft Battlecry Generator
-- ===========================================
-- Version     : 0.50
-- Author      : Nuchaleft (NytewolfAU2k7 on Curse)
-- Email       : nwcreations@gmail.com
-- Create Date : 10/07/2008 01:11:43 PM WAST (GMT+8:00)
-- Update      : 05/08/2010 02:26 AM WAST (GMT+8:00)
-- ===========================================

-- Declare our Generator Variables
local n_idx_a = 0; --Alliance Cry Index
local n_idx_h = 0; --Horde Cry Index
local s_bcgsay1 = ""; --ally say var
local s_bcgsay2 = ""; --pond scum say var
local s_final = "";
local s_bcgevilsay = ""; --evil say var
local s_channel = ""; --Channel Name

--UWBG_Prefs = {defchannel = "Say",
--allfaction = false,}

-- This function is run on pressing the Ok or Close Buttons.
--   Sets the Status of the Saved Variables to the new settings
function frmBCG_Close()
        --UWBG_Prefs[realm].Sold = SC_ChaChingGUIFrame_CBSold:GetChecked();
        --UWBG_Prefs[realm].Expired = SC_ChaChingGUIFrame_CBExpired:GetChecked();
        --UWBG_Prefs[realm].Outbid = SC_ChaChingGUIFrame_CBOutbid:GetChecked();
        --UWBG_Prefs[realm].Removed = SC_ChaChingGUIFrame_CBRemoved:GetChecked();
end


-- This function is run on pressing the Cancel Button or from the VARIABLES LOADED event function.
--   Sets the status of the Check Boxes to the Values of the Saved Variables.
function frmBCG_CancelOrLoad()
        --SC_ChaChingGUIFrame_CBSold:SetChecked(UWBG_Prefs[realm].Sold);
        --SC_ChaChingGUIFrame_CBExpired:SetChecked(UWBG_Prefs[realm].Expired);
        --SC_ChaChingGUIFrame_CBOutbid:SetChecked(UWBG_Prefs[realm].Outbid);
        --SC_ChaChingGUIFrame_CBRemoved:SetChecked(UWBG_Prefs[realm].Removed);
end


-- ON EVENT HANDLER... ERR... EVENT
function frmBCG_OnEvent()
    if (event == "VARIABLES_LOADED") then
        --UWBCG_LoadOptions(); -- Load Options, display error if unable
                frmBCG_CancelOrLoad();
    end
end;


-- UWBCG_LoadConfig
function UWBCG_LoadConfig()
        if (not IsAddOnLoaded("BattleCryGen_Config")) then
                EnableAddOn("BattleCryGen_Config")
                local ok, reason = LoadAddOn("BattleCryGen_Config")

                if (not ok) then
                        UWBCG_Msg("Failed to load BattleCryGen configuration settings ("..tostring(reason)..")")
                else
                        collectgarbage()
                end;
        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!"), 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!"), 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;

--Alliance NO TARGET SELECTED
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;

--Alliance TARGET SELECTED
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;

--Horde NO TARGET SELECTED
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;

--Horde TARGET SELECTED
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;


-- BEGIN SUFFIXES LISTINGS
-- Alliance Suffixes are first, followed by Horde, then misc
-- suffixes.

-- Possible Suffixes (Alliance)
PossSuff1 = {
      "Legion",
          "Scourge",
      "Alliance",
      "Ladies Undergarments",
      "Kaldorei",
          "Draenei",
          "Lost Ones",
      "Beer!",
          "Pie!",
      "Gilneas",
      "Lordaeron",
      "Worgen",
      "Ashen Verdict",
      "Naaru!",
      "Lich King!",
      "Old Gods!",
          "Warchief!",
      "Azshara!",
      "Grand Alliance!",
      "Holy Light!",
      "Ancients!",
      "King!",
      "Defilers!",
      "Argent Dawn",
      "Argent Crusade",
      "Kalu'ak",
      "Frenzyheart Tribe",
      "Oracles",
      "Wyrmrest Accord",
      "Kirin Tor",
      "Knights of the Ebon Blade",
      "Valiance Expedition",
      "Silver Covenant",
      "Explorers' League",
      "Silverwing Sentinels",
      "League of Arathor!",
      "Stormpike Guard!",
      "Zandalari!",
      "San'layn!",
      "Steamwheedle Cartel!",
      "Sha'tar!",
      "Ashtongue Deathsworn!",
      "Cenarion Expedition!",
      "Cenarion Circle",
      "Seer",
      "Thorium Brotherhood",
      "Wintersaber Trainers",
      "Violet Eye",
      "Silver Hand",
      "Black Dragonflight",
      "Green Dragonflight",
      "Red Dragonflight",
      "Bronze Dragonflight",
      "Infinite Dragonflight",
      "Scarlet Crusade",
      "Syndicate",
      "Zandalar Tribe",
      "Consortium!",
      "Mag'har!",
      "Aldor!",
      "Scryers!",
      "Shattered Sun Offensive!",
      "Sha'tari Skyguard!",
      "Gelkis Clan Centaur",
      "Hydraxian Waterlords",
      "Keepers of Time",
      "Magram Clan Centaur",
      "Warriors of the Night!",
      "Dichotomy of good and evil!",
          "love of Elune!",
      "Ironforge Dwarves",
      "Darnassian Elves",
      "Gnomeregan Exiles",
      "Murkblood",
      "Light!",
          "Illidari",
      "Frostsabers",
      "Kobolds",
      "fallen Titan, Sargares",
      "Old Ones",
      "Queldorei",
      "Yogg-Saron",
      "Ale!"
}

-- Possible Suffixes (Horde)
PossSuff2 = {
      "Legion",
      "Horde",
          "Scourge",
      "Tauren",
      "Taunka",
      "Ladies Undergarments",
      "Forsaken",
      "Sindorei",
      "Goblins",
      "Ashen Verdict",
      "Beer!",
          "Pie!",
      "Lich King!",
      "Old Gods!",
          "Warchief!",
      "Azshara!",
      "Holy Light!",
      "Warchief",
      "Defilers!",
      "Argent Dawn",
      "Argent Crusade",
      "Kalu'ak",
      "Frenzyheart Tribe",
      "Oracles",
      "Wyrmrest Accord",
      "Kirin Tor",
      "Knights of the Ebon Blade",
      "Silver Covenant",
      "Warsong Offensive",
      "Hand of Vengeance",
      "Silverwing Sentinels",
      "Taunka",
      "League of Arathor!",
      "Stormpike Guard!",
      "Zandalari!",
      "San'layn!",
      "Warsong Outriders!",
      "Frostwolf Clan!",
      "Steamwheedle Cartel!",
      "Sha'tar!",
      "Ashtongue Deathsworn!",
      "Cenarion Expedition!",
      "Cenarion Circle",
      "Seer",
      "Thorium Brotherhood",
      "Wintersaber Trainers",
      "Violet Eye",
      "Black Dragonflight",
      "Green Dragonflight",
      "Red Dragonflight",
      "Bronze Dragonflight",
      "Infinite Dragonflight",
      "Scarlet Crusade",
      "Syndicate",
      "Zandalar Tribe",
      "Consortium!",
      "Mag'har!",
      "Aldor!",
      "Scryers!",
      "Shattered Sun Offensive!",
      "Sha'tari Skyguard!",
      "Gelkis Clan Centaur",
      "Hydraxian Waterlords",
      "Keepers of Time",
      "Magram Clan Centaur",
      "Warriors of the Night!",
      "Dichotomy of good and evil!",
      "Murkblood",
      "Light!",
          "Illidari",
      "Kobolds",
      "fallen Titan, Sargares",
      "Old Ones",
      "Yogg-Saron",
      "Ale"
}

--Pre/Suffixes for evil people
EvilSuff={
      "Fel Horde",
      "Scourge",
      "Burning Legion",
      "Twilight's Hammer",
      "Deathwing",
}


-- END SUFFIXES LISTINGS

-- Print a message to the default chat frame
function UWBCG_Msg(msg)
    if( DEFAULT_CHAT_FRAME ) then
        DEFAULT_CHAT_FRAME:AddMessage(msg);
    end;
end;

function btnGenSay_Click()
    -- fetch an array/table
    n_say1 = table.getn( PossSuff1 );
    n_say2 = table.getn( PossSuff2 );
    -- Randomize
    n_idx_a = math.random( n_say1 );
    n_idx_h = math.random( n_say2 );
    -- 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];
    
    local pc_faction = UnitFactionGroup("player");
    if (pc_faction == "Alliance") then
        GenerateFactionBattlecry(s_bcgsay1, "SAY");
    elseif (pc_faction == "Horde") then
        GenerateFactionBattlecry(s_bcgsay2, "SAY");
    end;
end;

-- Options Button
function UWBCG_LoadOptionsDialog()
    if (BattleCryGen_Config) then
                BattleCryGen_Config:Show()
                BattleCryGen_Config:SetAlpha(0)
        end
end;

function MakeOneUp(WhatKind)
    -- fetch an array/table
    n_say1 = table.getn( PossSuff1 );
    n_say2 = table.getn( PossSuff2 );
    -- Randomize
    n_idx_a = math.random( n_say1 );
    n_idx_h = math.random( n_say2 );
    -- 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];
      
    if UnitName("target") == nil then
        if (WhatKind == "s") 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 (WhatKind == "y") 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;
        end;
    else
        if (WhatKind == "s") 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 (WhatKind == "y") 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;
        end;
    end;
end;


function cmdBCG(param1)

        local dummy1, dummy2, command, value = string.find(param1, "(%w+) (%w+)");

        if string.lower(param1) == "y" then param1 = "yell" end;
        if string.lower(param1) == "s" then param1 = "say" end;
    if string.lower(param1) == "p" then param1 = "party" end;
    if string.lower(param1) == "r" then param1 = "raid" end;
        --if string.lower(param1) == "bg" then param1 = "battleground" end;

        if (string.lower(param1) == "say") then
                MakeOneUp("s");
                SendChatMessage(s_final, param1, frmBCG.language);      
        elseif (string.lower(param1) == "yell") then
                MakeOneUp("y");
                SendChatMessage(s_final, param1, frmBCG.language);
        elseif (string.lower(param1) == "party") then
                MakeOneUp("p");
                SendChatMessage(s_final, param1, frmBCG.language);
        elseif (string.lower(param1) == "raid") then
                MakeOneUp("r");
                SendChatMessage(s_final, param1, frmBCG.language);
        elseif (string.lower(param1) == "cfg") then
                InterfaceOptionsFrame_OpenToCategory(panel);
        elseif (string.lower(param1) == "show") then
        if frmBCG:IsVisible() == true then
                frmBCG:Hide();
                else
                        frmBCG:Show();
        end;
        elseif (string.lower(param1) == "hide") then
        if frmBCG:IsVisible() == false then
                frmBCG:Show();
        else
            frmBCG:Hide();
        end;
        else
                btnUsage_Click();
        end;
end

-- Show how to use the addon.
function btnUsage_Click() 
    UWBCG_Msg("|cff6666ff Usage:\n");
    UWBCG_Msg("|cff999999   /bcg show                   Open Panel");
    UWBCG_Msg("|cff999999   /bcg cfg                    Open Options Panel");
    UWBCG_Msg("|cff999999   /bcg y                      (Yell)");
    UWBCG_Msg("|cff999999   /bcg s                      (Say)"); 
    UWBCG_Msg("|cff999999   /bcg p                      (Party)");
    UWBCG_Msg("|cff999999   /bcg r                      (Raid)");
    UWBCG_Msg("|cff999999   /bcg bg                     (Battleground)"); 
    UWBCG_Msg("|cff6666ff Enjoy the power!\n");
end

-- Hide this addon from view.
function btnClose_Click()
    frmBCG:Hide();
end

function frmBCG_Open()
    frmBCG:Show();
end

-- ON LOAD EVENT
function frmBCG_OnLoad(panel)
    -- Identify us.
        UWBCG_Msg("|cff999999 Ultimate Warcraft Battlecry Generator is Loaded\n");
    UWBCG_Msg("|cff999999 Version 0.50 for WoW Patch 3.3+\n");
        UWBCG_Msg("|cff6666ff Type /bcg for options\n");
    
    -- BEGIN LOCALISATION CODE
    
    btnOptions:SetText(UWBCG_Loc.TEXT_CFGBUTTON);
        btnGenSay:SetText(UWBCG_Loc.TEXT_GENBUTTON);
    
    -- BEGIN INTERFACE OPTIONS CODE
    
    UWBCG_LoadConfig(); -- Load configuration settings, display error if unable
    UWBCG_LoadOptionsDialog(); -- Load the actual options dialog
    
    -- END INTERFACE OPTIONS CODE
    
        SLASH_BCGEN1 = "/bcg";
        SlashCmdList["BCGEN"] = cmdBCG;
        frmBCG:RegisterEvent("VARIABLES_LOADED");
end

function cboGen_OnTextChanged()
    local s_ch = (getglobal("frmBCG".."cboGen".."Edit")):GetText();
    DEFAULT_CHAT_FRAME:AddMessage("UWBCG Test: Text Changed. ".."Channel:"..s_ch);
end
    

Compare with Previous | Blame