-------------------------------------------------- -- If you're reading this I want you to know some things. -- -- 1) I'm a spacing freak -- 2) I like commenting things -- 3) If you use any portion of this addon please give credit -- 4) I code because I love it -- 5) LOL@YOU for looking at the SRC -- 6) Coded, Tested, and Released on Destromath(US) -- 7) Jinivus (matts.toilet.is@gmail.com) Created the original Wintergrasper. Thanks! -------------------------------------------------- -- Load the Global settings for the ADDON WGSettings = {} -- Loading local settings local WG_NAME = "Wintergrasper Advanced" local WG_VERSION = GetAddOnMetadata("Wintergrasper_Advanced","Version") local WG_DATA_VERSION = GetAddOnMetadata("Wintergrasper_Advanced","X-Version") -- Database Version local UpdateInterval = 1 local playerName = UnitName("player") local currentServer = GetRealmName() local WGTimeSaved = 0 local WG_RELEASETYPE = "RELEASE" -- NIGHTLY/RELEASE -- Create the SCT Frame for the messages to display local frame=CreateFrame('MessageFrame', 'WG_SCTFRAME', UIParent) frame:SetWidth(UIParent:GetWidth()) frame:SetWidth(600) frame:SetHeight(60) frame:SetFrameStrata('HIGH') frame:SetTimeVisible(8) frame:SetFadeDuration(0.4) frame:SetPoint('CENTER', 0, 180) frame:SetFontObject(GameFontNormalLarge) frame:Show(); -- OnLoad function function WG_OnLoad() this:RegisterEvent("VARIABLES_LOADED"); this:RegisterEvent("PLAYER_ENTERING_WORLD"); this:RegisterEvent("PLAYER_LOGIN"); this:RegisterEvent("PLAYER_LOGOUT"); this:RegisterEvent("UPDATE_WORLD_STATES"); this:RegisterEvent("GOSSIP_SHOW"); this:RegisterEvent("CHAT_MSG_CHANNEL"); this:RegisterEvent("CHAT_MSG_WHISPER"); this:RegisterEvent("CHAT_MSG_YELL"); this:RegisterEvent("CHAT_MSG_SAY"); this:RegisterEvent("CHAT_MSG_GUILD"); this:RegisterEvent("CHAT_MSG_PARTY"); this:RegisterEvent("CHAT_MSG_ADDON"); this:RegisterEvent("PARTY_MEMBERS_CHANGED"); this:RegisterEvent("CHAT_MSG_CHANNEL_NOTICE"); this:RegisterEvent("CHAT_MSG_MONSTER_YELL"); SLASH_WG1 = "/wg"; SlashCmdList["WG"] = WG_SlashCommand; if( DEFAULT_CHAT_FRAME ) then DEFAULT_CHAT_FRAME:AddMessage("|c0000FF00"..WG_NAME.." v"..WG_VERSION..":|r |c00FFFFFFLOADED (/wg)|r"); end end -- OnEvent Function function WG_OnEvent(event, arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9) WGMapName = (select(1,GetMapInfo())) if (event == "VARIABLES_LOADED") then --Loads defauls on firstrun or update if(WGSettings.FirstLoad == nil or WGSettings.FirstLoad < WG_DATA_VERSION)then WG_OptionsFrame_SetDefaults(); end if(WGSettings.showWindow)then WG_Window:Show(); else WG_Window:Hide(); end WG_Window:SetUserPlaced(true); end if (event=="PLAYER_ENTERING_WORLD")then --Minimap Button Info local info = { icon = "Interface\\Icons\\INV_Jewelry_Ring_66", position = 0, drag = "CIRCLE", left = function() if(WGSettings.SyncMode)then if(GetCurrentMapContinent() == 4)then WGAskChannel() if(WGTimeTillString ~= nil)then WGChannelTell(WGTimeTillString) end if(UnitIsDeadOrGhost("player") ~= 1)then WG_ControlCheck() end else WGAskChannel() end else if(GetCurrentMapContinent() == 4)then WGTimeTillString = WGConvertTime(GetWintergraspWaitTime()) if(UnitIsDeadOrGhost("player") ~= 1)then WG_ControlCheck() end else print(WGNoSync) end end end, right = function() if(WG_Window:IsShown())then WG_Window:Hide() else WG_Window:Show() end end, tooltip = tooltiptext, enabled = "ON", } --Minimap Button Creation MyMinimapButton:Create("Wintergrasper_Advanced",WGSettings,info) -- Loader for Options with LDB Installed if(WGSettings.enableMMB) then Wintergrasper_AdvancedMinimapButton:Show(); else Wintergrasper_AdvancedMinimapButton:Hide(); end -- End those Options if (GetCurrentMapContinent() == 4)then if(WGMapName ~= "LakeWintergrasp" and UnitIsDeadOrGhost("player") ~= 1)then WG_ControlCheck() end WGTimeTillString = WGConvertTime(GetWintergraspWaitTime()) else if(WGTimeTillString == nil)then WG_WindowMessage:SetText("|cffFFCC00 "..WGNA.."|r") end end end if(event=="CHAT_MSG_CHANNEL_NOTICE")then if(WGSettings.SyncMode)then if(arg9=="WG")then if(GetCurrentMapContinent() == 4)then if(WGTimeTillString ~= nil)then WGChannelTell(WGTimeTillString) end else WGAskChannel(); end else WGOnLoad() end end if(WGowner == nil and UnitIsDeadOrGhost("player") ~= 1)then WG_ControlCheck() end timethatloggedin = time()+10 end if(event=="PLAYER_LOGIN")then UIDropDownMenu_Initialize(WGDropDownMenu, WGDropDownMenu_Initialize, "MENU"); -- Options Text Loader WG_OptionsInitialize() mYell = 0; UpdateReminderShown = false timethatloggedin = time()+10 end if(event=="PLAYER_LOGOUT")then end if(event == "UPDATE_WORLD_STATES")then if(WGMapName == "LakeWintergrasp") then if(select(3,GetWorldStateUIInfo(8)) ~= NIL)then WGTimeTillString = (select(3,GetWorldStateUIInfo(8)):match("%d+......")) end -- WG_ControlCheck() end end if event == "GOSSIP_SHOW" then if (UnitName("target") == BMNameA or UnitName("target") == BMNameH) and GetGossipText():match("%d:%d%d:%d%d") then WGTimeTillString = string.split(";",GetGossipText():match("%d+......")) WGChannelTell(WGTimeTillString) elseif (UnitName("target") == BMNameA or UnitName("target") == BMNameH) and not GetGossipText():match("%d:%d%d:%d%d") then if(WGTimeTillString == nil)then WG_WindowMessage:SetText("|cffFFCC000:00:00") end end end if(event == "CHAT_MSG_CHANNEL")then WGChanFunction(arg1,arg2,arg9) WGAutoInviteGen(arg1,arg2,arg9) end if(event == "CHAT_MSG_GUILD")then WGChanFunction2(arg1,arg2) end if(event == "CHAT_MSG_PARTY")then WGChanFunction2(arg1,arg2) end if(event == "CHAT_MSG_YELL")then WGAutoInviteGen2(arg1,arg2) end if(event == "CHAT_MSG_SAY")then WGAutoInviteSay(arg1,arg2) end if (event == "CHAT_MSG_WHISPER") then WGWhisperInvite(arg1,arg2) end if(event == "CHAT_MSG_ADDON")then if(arg1 == "WGA")then WGUpdateCheck(arg2) end end if (event == "PARTY_MEMBERS_CHANGED") then if ( OkToInviteCommon("") and UnitInRaid("player") == nil ) then -- IsRaidLeader() returns true if your leader of a group (if not in a raid only?) or a raid -- IsRaidOfficer() only returns true if your an assist in a raid if (IsRaidLeader() or IsRaidOfficer()) then ConvertToRaid(); WGRaidFull = 0 end end if(WG_RELEASETYPE == "RELEASE")then WG_announceVersion() end end if (event == "CHAT_MSG_MONSTER_YELL")then if (arg2 == BMNameA or arg2 == BMNameH) and string.find(arg1, " 15") and mYell == 0 then if (WGSettings.SCTDisplay) and not (WGMapName == "LakeWintergrasp")then WG_SCTFRAME:AddMessage(""..factionicon..""..WGWarn1, 0.7, 0.7, 1); WGTimeTillString = "0:14:59" WGPlaySound() mYell = 1; WGTimeSaved = time() end WGChannelTell(WGTimeTillString) elseif(arg2 == BMNameH or arg2 == BMNameA) and string.find(arg1, " 5") and mYell == 0 then if (WGSettings.SCTDisplay) and not (WGMapName == "LakeWintergrasp")then WG_SCTFRAME:AddMessage(""..factionicon..""..WGWarn2, 0.7, 0.7, 1); WGTimeTillString = "0:04:59" WGPlaySound() mYell = 1; WGTimeSaved = time() end WGChannelTell(WGTimeTillString) end end end function WGUpdateCheck(version) if(version > WG_VERSION and UpdateReminderShown == false)then if(WGSettings.showReminder)then WG_UpdateReminder(version) end end end -- Menu Function function WG_SlashCommand() if(WG_OptionsFrame:IsShown())then WG_OptionsFrame:Hide() else WG_OptionsFrame:Show() end end -- Time Creation functions (by Jini) function WGMakeSeconds(WGGiven) WGHours = WGTimeHours(WGGiven) WGMinutes = WGTimeMinutes(WGGiven) WGSeconds = WGTimeSeconds(WGGiven) WGSeconds = tonumber(WGSeconds) WGMinutes = tonumber(WGMinutes) WGHours = tonumber(WGHours) if(WGHours==nil)then WGHours=0 end if(WGMinutes==nil)then WGMinutes=0 end if(WGSeconds==nil)then WGSeconds=0 end if (WGHours == nil)then if(WGMinutes == nil)then WGTimeInSeconds = WGSeconds else WGTimeInSeconds = (WGMinutes*60)+WGSeconds end else WGTimeInSeconds = (WGHours*3600)+(WGMinutes*60)+WGSeconds end WGMakeTimeFromSeconds(WGTimeInSeconds) return WGTimeInSeconds end function WGTimeHours(WGGiven) WGtempHourss = WGGiven:match(".") WGtempHours = WGtempHourss:match(".") return WGtempHours end function WGTimeMinutes(WGGiven) WGtempMinutes = WGGiven:match("%d%d") return WGtempMinutes end function WGTimeSeconds(WGGiven) WGtempSeconds = WGGiven:gsub(".","",5) return WGtempSeconds end function WGMakeTimeFromSeconds(WGGiven) -- Seconds to mm:ss string if((math.floor(WGGiven % 60)) < 10)then WGFinalTime = "0"..tostring(math.floor(WGGiven % 60)).."" else WGFinalTime = tostring(math.floor(WGGiven % 60)).."" end if WGGiven >= 60 then WGGiven = WGGiven / 60 if((math.floor(WGGiven % 60)) < 10)then WGFinalTime = "0"..tostring(math.floor(WGGiven % 60))..':'..WGFinalTime else WGFinalTime = tostring(math.floor(WGGiven % 60))..':'..WGFinalTime end if WGGiven >= 60 then WGGiven = WGGiven / 60 WGFinalTime = tostring(math.floor(WGGiven % 24))..':'..WGFinalTime if WGGiven >= 24 then WGGiven = WGGiven / 24 WGFinalTime = tostring(math.floor(WGGiven))..'d'..WGFinalTime end else WGFinalTime = '0:'..WGFinalTime end else WGFinalTime = '0:00:'..WGFinalTime end --Jini return WGFinalTime end -- OnUpdate Function function WG_OnUpdate(elapsed) local CurrentTime = GetTime() if (DelayTime == nil)then DelayTime = GetTime() end if(WGTimeSaved ~= nil)then if(mYell == 1 and (WGTimeSaved > time()+60 or WGTimeSaved == nil))then mYell = 0; end end if(WGRaidFull == 1 and WGRaidFullTime > time()+1800)then WGRaidFull = 0 end if (WGTimeTillString == "0:00:00")then WGCheckTimeSCT(); WGTimeTillString = nil WGowner = nil end if(WGMapName == "LakeWintergrasp")then if (WGTimeTillString == "2:29:50")then if(WGSettings.autoLeave)then LeaveParty() end WG_ControlCheck() end end if(GetCurrentMapContinent() == 4)then if(GetWintergraspWaitTime() == nil)then WGowner = "InProgress" if(WGTimeTillString == nil)then WG_WindowMessage:SetText("|cffFFCC00"..WGSTARTED.."|r") if(IsAddOnLoaded("Wintergrasper_Advanced_LDB") ~= nil)then WGbroker.text = "|cffFFCC00"..WGSTARTED.."|r" end end end end if(timethatloggedin > time())then if(GetCurrentMapContinent() == 4)then WG_ControlCheck() end end if (WGTimeTillString ~= nil)then if(IsAddOnLoaded("Wintergrasper_Advanced_LDB") ~= nil)then WGbroker.text = WGTimeTillString end WGCountdown = WGMakeSeconds(WGTimeTillString) if (CurrentTime >= DelayTime) then DelayTime = CurrentTime + UpdateInterval WGCountdown = WGCountdown - UpdateInterval WGTimeTillString = WGMakeTimeFromSeconds(WGCountdown) WGUpdateTime(WGTimeTillString) end end WGCheckTimeSCT() WG_SetFactionTexture() end -- Sync functions function WGOnLoad() RemoveChatWindowChannel(1, "WG") JoinTemporaryChannel("WG") end function WGUpdateTime(WGGiven) WGMapName = (select(1,GetMapInfo())) WG_WindowMessage:SetText(WGGiven) end function WGChannelTell(WGGiven) if(WGSettings.SyncMode)then WGOnLoad() if(WGowner~=nil)then SendChatMessage(""..WGGiven.." "..WGowner.."", "CHANNEL", nil, GetChannelName("WG")) else SendChatMessage(WGGiven, "CHANNEL",nil,GetChannelName("WG")) end end end function WGAskChannel() WGOnLoad(); if(GetCurrentMapContinent() == 4)then if(GetWintergraspWaitTime() == nil)then WGIsOnSCTAnnouncement() else WGTimeTillString = WGConvertTime(GetWintergraspWaitTime()) end else SendChatMessage("ReSync","CHANNEL",nil,GetChannelName("WG")); end end function WGChanFunction(msg,name,channel) WGMapName = (select(1,GetMapInfo())) if((channel == "Trade - City" or channel == "General - Dalaran" or channel == "LocalDefense - Dalaran" or channel == "Guild") and WGSettings.autoReplyTime)then if(string.find(msg, WG_AR_MAIN) and (string.find(msg,WG_AR_INCLUDE1) or string.find(msg,WG_AR_INCLUDE2)) and name ~= playerName)then WGAnnounce_REPLY(name) end end -- "string.find(msg,"2:29:50")" is a fix for the loop bug introduced in 1.50 -- and should be removed sometime down the road. if not (channel == "WG")then return end if(WGMapName ~= "LakeWintergrasp")then if(name ~= playerName)then if(string.match(msg,"Horde"))then WGowner = "Horde" elseif(string.match(msg,"Alliance"))then WGowner = "Alliance" elseif(string.match(msg,"InProgress"))then WGowner = "InProgress" --WG_Window2:Show() end if(string.find(msg,"ReSync") and WGTimeTillString ~= nil)then WGChannelTell(WGTimeTillString) elseif(string.match(msg,"%d:%d%d:%d%d"))then if not(string.find(msg,"2:29:50"))then WGTimeTillString = string.match(msg,"%d:%d%d:%d%d"); end end end end end function WGChanFunction2(msg,name) if(WGSettings.autoReplyTime)then if(string.find(msg, WG_AR_MAIN) and (string.find(msg,WG_AR_INCLUDE1) or string.find(msg,WG_AR_INCLUDE2)) and name ~= playerName)then WGAnnounce_REPLY(name) end end end -- SCT functions function WGCheckTimeSCT() WGMapName = (select(1,GetMapInfo())) if((GetWintergraspWaitTime() ~= nil and GetCurrentMapContinent() == 4)) or (GetCurrentMapContinent() ~= 4)then if (WGSettings.SCTDisplay) and not (WGMapName == "LakeWintergrasp")then if (WGTimeTillString == "0:15:00")then WG_SCTFRAME:AddMessage(""..factionicon..""..WGWarn1, 0.7, 0.7, 1); WGTimeTillString = "0:14:59" WGPlaySound() elseif (WGTimeTillString == "0:05:00")then WG_SCTFRAME:AddMessage(""..factionicon..""..WGWarn2, 0.7, 0.7, 1); WGTimeTillString = "0:04:59" WGPlaySound() elseif (WGTimeTillString == "0:00:00")then WG_SCTFRAME:AddMessage(""..factionicon..""..WGWarn4, 0.7, 0.7, 1); WGPlaySound() end end end end function WGPlaySound() if(WGSettings.soundCheck)then if(WGSettings.CustomSoundSet)then PlaySoundFile("Interface\\AddOns\\Wintergrasper_Advanced\\Sounds\\alert.mp3") else PlaySoundFile("Sound\\Spells\\Blade_of_Azzinoth_Impact.wav") end end end function WGIsOnSCTAnnouncement() if(WGSettings.SCTDisplay)then WG_SCTFRAME:AddMessage(""..'\124TInterface\\AddOns\\Wintergrasper_Advanced\\Icons\\PvP-FFA.blp:40\124t '..""..WGWarn3, 0.7, 0.7, 1); WGPlaySound() end end -- autoInvite functions -- -- IN_RANGE_OF_NPC_AND_NPC_TARGETED -- -- Check to be sure NPC is in range, it must be targeted -- to do so. -- function InRangeOfNPCAndNPCTargeted() -- Get Unit name of our current target local WGTname = UnitName("target"); -- return false if nothing is targeted if( WGTname == nil ) then return false end if ( ( WGTname == BMNameA -- if name == alliance npc or -- or WGTname == BMNameH -- if name == horde npc ) and -- Are we close enough to WG NPC to interact with them via Trade -- Trade is biggest distance that is allowed with this check distance -- method. 28 yards is big enough for a large distance around the npc -- enough for the whole horde room, need someone to check ally room -- use either of the scripts at end of function to check it (CheckInteractDistance("target", 1) == 1) ) then return true else return false end end -- /run print( InRangeOfNPCAndNPCTargeted() ) -- /run if (InRangeOfNPCAndNPCTargeted())then print("In range") else print("Out of range") end -- -- OK_TO_INVITE_COMMON -- Check to see if the potential raid leader (or raid leader/officer) -- is in a valid place to invite -- that wintergrasp is near to starting (or is in progress) -- and has auto invite setting checked for this addon -- -- also checks channel person requesting invite is requesting from -- why? Shouldn't this just be appropriate if the raid inviter is -- in the proper locality? -- function OkToInviteCommon(channel) WGMapName = (select(1,GetMapInfo())) if( WGSettings.autoInvite and ( (WGMapName == "LakeWintergrasp") or ( WGMapName == "Dalaran" and InRangeOfNPCAndNPCTargeted() and ( channel == "Trade - City" or channel == "General - Dalaran" or channel == "LocalDefense - Dalaran" or channel == "Guild" or channel == "" -- since some functions don't get the channel and we want it to pass the test ) ) ) and ( GetWintergraspWaitTime() == nil or (GetWintergraspWaitTime() < 1800) -- 30 minutes of seconds ) ) then return true end return false end -- -- IS_VALID_MESSAGE -- -- Check message to be sure it has valid invite tokens -- Ignore messages from people that are already in raid -- and are not wanting to join our raid -- function IsValidMessage(message) message=string.lower(message) if -- check to see if we should ignore this message ( string.find(message, "pst") -- and ignore others spamming "pst inv for wg." or string.find(message, "pts") -- cause some people want to type it that way instead of pst or string.find(message, "whisper") -- ignore whisper me for invite... or string.find(message, "guild") -- ignore people spamming guild macros with the word invite in it or (UnitInRaid(sender) == 1) -- ignore messages from those already in the raid ) then return false end if ( string.find(message, WGINVLONG) or string.find(message, WGINVSHORT) ) then return true end return false end -- -- PARSE_MESSAGE -- Check the string for "inv" or "invite" -- function ParseMessage(message,sender) if( IsValidMessage(message) ) then if(playerName ~= sender)then InviteUnit(sender); end end end -- -- IS_RAID_AND_ARE_WE_A_LEADER_AND_NOT_FULL -- -- I think the name of this function is pretty -- self explanitory -- function IsRaidAndAreWeALeaderAndNotFull() if ( GetNumRaidMembers() < 40 and ( IsRaidLeader() or IsRaidOfficer() ) and GetNumRaidMembers() > 0 ) then return true end return false end -- -- PARSE_RAID -- -- If Raid isn't full and Inviter has permissions to invite -- then invite the requester -- -- Returns true that invite was sent or false otherwise -- function ParseRaid(message,sender) if( IsRaidAndAreWeALeaderAndNotFull() ) then ParseMessage(message,sender) return true end return false end -- -- PARSE_RAID_CREATE_IF_NONE -- -- If Raid isn't full and Inviter has permissions to invite -- then invite the requester -- -- If inviter isn't in a raid then create one -- function ParseRaidCreateIfNone(message,sender) if ( not (ParseRaid(message,sender) ) and -- if we don't have a raid yet, start one GetNumRaidMembers() == 0 ) then ParseMessage(message,sender); -- ConvertToRaid() is called in event PARTY_MEMBERS_CHANGED end end -- -- PARSE_RAID_FULL -- -- Check to see if raid is now full, if it is -- set appropriate flags -- function ParseRaidFull(messageFromSender, messageReplyRaidFull, sender) if ( GetNumRaidMembers() >= 40 and ( IsRaidLeader() or IsRaidOfficer() ) and WGRaidFull == 0 ) then -- sending to first person who jams up on a full raid -- suggesting that they start a new raid if( IsValidMessage(messageFromSender) ) then --- Check that message is valid so we don't just send this to anyone who communicates --- on any channel with any message SendChatMessage(messageReplyRaidFull,"WHISPER",nil,sender); WGRaidFull = 1 WGRaidFullTime = time() end end end function WGWhisperInvite(message,sender) message=string.lower(message) if(string.find(message,WG_AR_WHISPER) and WGSettings.autoReplyTime)then WGAnnounce_REPLY(sender) end if( OkToInviteCommon("") ) then ParseRaidCreateIfNone(message,sender) ParseRaidFull(message, "[WGA] "..WGGroupFull.."",sender) end end function WGAutoInviteGen(message,sender, channel) if( OkToInviteCommon(channel) ) then if( not ParseRaid(message,sender) ) then ParseRaidFull(message, WGGroupFull,sender) end end end function WGAutoInviteGen2(message,sender) if( OkToInviteCommon("") ) then ParseRaid(message,sender) ParseRaidFull(message, "[WGA] "..WGGroupFull.."",sender) end end function WGAutoInviteSay(message,sender) if( OkToInviteCommon("") ) then ParseRaidCreateIfNone(message,sender) ParseRaidFull(message, "[WGA] "..WGGroupFull.."",sender) end end function WGConvertTime(value) if(value~=nil)then local hours = floor(value / 3600) local minutes = value - (hours * 3600) minutescorrupt = floor(minutes / 60) if(minutescorrupt < 10)then minutesfixed = "0"..minutescorrupt.."" else minutesfixed = minutescorrupt end local seconds = floor(value - ((hours * 3600) + (minutescorrupt * 60))) if(seconds < 10)then secondsfixed = "0"..seconds.."" else secondsfixed = seconds end if (hours > 0) then return hours..":"..minutesfixed..":"..secondsfixed elseif (minutescorrupt > 0) then return "0:"..minutesfixed..":"..secondsfixed else return "0:00:"..secondsfixed end else WGIsOnSCTAnnouncement() end end -- Dropdown Menu for Announce function WG_OnMouseUp(self, button) if ( button == "RightButton" or ( button == "LeftButton" and IsShiftKeyDown() ) ) then ToggleDropDownMenu(1, nil, WGDropDownMenu, "cursor"); PlaySound("UChatScrollButton"); end end function WGDropDownMenu_Initialize() local info; info = {}; info.text = WGAnnounceText; info.isTitle = 1; info.notCheckable = 1; UIDropDownMenu_AddButton(info); info = {}; info.text = WGASAYTXT; info.func = WGAnnounce_SAY; info.notCheckable = 1; UIDropDownMenu_AddButton(info); info = {}; info.text = WGAGUILDTXT; info.func = WGAnnounce_GUILD; info.notCheckable = 1; UIDropDownMenu_AddButton(info); info = {}; info.text = WGATRADETXT; info.func = WGAnnounce_TRADE; info.notCheckable = 1; UIDropDownMenu_AddButton(info); info = {}; info.text = WGARAIDTXT; info.func = WGAnnounce_RAID; info.notCheckable = 1; UIDropDownMenu_AddButton(info); end -- -- PST_FOR_INVITE_MESSAGE -- -- Check to be sure we can invite -- if so, pass back message to send -- function PSTForInviteMessage() local text = ""; if ( OkToInviteCommon("") and IsRaidAndAreWeALeaderAndNotFull() ) then text = "PST with 'inv' for an invite."; end return text; end -- -- WG_ANNOUNCE -- -- Send appropriate chat spam depending on what faction -- player is in and what faction owns wintergrasp -- function WGAnnounce(chatType, language, channel, tackOnMessage) local addon = "[WGA]"; if(WGTimeTillString ~= nil)then if(UnitFactionGroup("player") == "Horde")then if(WGowner == "Horde")then SendChatMessage(addon.." "..WGBegin2.." "..WGTimeTillString.."", chatType, language, channel); elseif(WGowner == "Alliance")then SendChatMessage(addon.." "..WGBegin1.." "..WGTimeTillString.."", chatType, language, channel); elseif(WGowner == "InProgress")then SendChatMessage(addon.." "..WGWarn3.."", chatType, language, channel); else SendChatMessage(addon.." "..WGBegin.." "..WGTimeTillString.."", chatType, language, channel); end elseif(UnitFactionGroup("player") == "Alliance")then if(WGowner == "Horde")then SendChatMessage(addon.." "..WGBegin1.." "..WGTimeTillString.."", chatType, language, channel); elseif(WGowner == "Alliance")then SendChatMessage(addon.." "..WGBegin2.." "..WGTimeTillString.."", chatType, language, channel); elseif(WGowner == "InProgress")then SendChatMessage(addon.." "..WGWarn3.."", chatType, language, channel); else SendChatMessage(addon.." "..WGBegin.." "..WGTimeTillString.."", chatType, language, channel); end end -- Add text after time message if requested if( string.len(tackOnMessage) > 0 ) then SendChatMessage(addon.." "..tackOnMessage, chatType, language, channel); end end end function WGAnnounce_SAY() WGAnnounce("SAY", nil, nil, ""); end function WGAnnounce_REPLY(P) WGAnnounce("WHISPER", nil, P, ""); end function WGAnnounce_GUILD() WGAnnounce("GUILD", nil, nil, PSTForInviteMessage()); end function WGAnnounce_TRADE() WGAnnounce("CHANNEL", nil, GetChannelName(WGTrade), PSTForInviteMessage()); end function WGAnnounce_RAID() WGAnnounce("RAID", nil, nil, ""); end function WGAnnounce_GENERAL() WGAnnounce("CHANNEL", nil, GetChannelName("General"), ""); end function WGAnnounce_LOCALDEFENSE() WGAnnounce("CHANNEL", nil, GetChannelName("LocalDefense"), ""); end function WG_ControlCheck() if(GetCurrentMapContinent() == 4)then if(WGMapName == "LakeWintergrasp")then if(GetWintergraspWaitTime()~=nil)then if(select(2,GetWorldStateUIInfo(7)) == 1)then WGowner = "Horde" elseif(select(2,GetWorldStateUIInfo(6)) == 1)then WGowner = "Alliance" end else WGowner = "InProgress" end else if(GetWintergraspWaitTime()~=nil)then if(UnitBuff("player",WGBUFFNAME))then if(UnitFactionGroup("player") == "Horde")then WGowner = "Horde" elseif(UnitFactionGroup("player") == "Alliance")then WGowner = "Alliance" end else if(UnitFactionGroup("player") == "Horde")then WGowner = "Alliance" else WGowner = "Horde" end end else WGowner = "InProgress" end end else WGowner = 0 end WG_SetFactionTexture() end function WG_SetFactionTexture() if(WGowner == "Horde")then WG_WindowToken:SetTexture("Interface\\AddOns\\Wintergrasper_Advanced\\Icons\\PvPHorde.blp") factionicon='\124TInterface\\AddOns\\Wintergrasper_Advanced\\Icons\\PvPHorde.blp:32\124t ' if(IsAddOnLoaded("Wintergrasper_Advanced_LDB") ~= nil)then WGbroker.icon = "Interface\\AddOns\\Wintergrasper_Advanced\\Icons\\PvPHorde.blp" end elseif(WGowner == "Alliance")then WG_WindowToken:SetTexture("Interface\\AddOns\\Wintergrasper_Advanced\\Icons\\PvPAlliance.blp") factionicon='\124TInterface\\AddOns\\Wintergrasper_Advanced\\Icons\\PvPAlliance.blp:32\124t ' if(IsAddOnLoaded("Wintergrasper_Advanced_LDB") ~= nil)then WGbroker.icon = "Interface\\AddOns\\Wintergrasper_Advanced\\Icons\\PvPAlliance.blp" end elseif(WGowner == "InProgress")then WG_WindowToken:SetTexture("Interface\\AddOns\\Wintergrasper_Advanced\\Icons\\PvP-FFA.blp") factionicon='\124TInterface\\AddOns\\Wintergrasper_Advanced\\Icons\\PvP-FFA.blp:40\124t ' if(IsAddOnLoaded("Wintergrasper_Advanced_LDB") ~= nil)then WGbroker.icon = "Interface\\AddOns\\Wintergrasper_Advanced\\Icons\\PvP-FFA.blp" end else WG_WindowToken:SetTexture("Interface\\AddOns\\Wintergrasper_Advanced\\Icons\\QuestionMark.tga") factionicon='\124TInterface\\AddOns\\Wintergrasper_Advanced\\Icons\\QuestionMark.tga:20\124t ' if(IsAddOnLoaded("Wintergrasper_Advanced_LDB") ~= nil)then WGbroker.icon = "Interface\\AddOns\\Wintergrasper_Advanced\\Icons\\QuestionMark.tga" end end end -- TestFunction function WG_UpdateReminder(newVersion) UpdateReminderShown = true local frame = CreateFrame("Frame", nil, UIParent) frame:SetFrameStrata("DIALOG") frame:SetWidth(430) frame:SetHeight(90) frame:SetPoint("CENTER", 0, 200) frame:SetBackdrop({ bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", tile = true, tileSize = 32, edgeSize = 32, insets = {left = 8, right = 8, top = 8, bottom = 8}, }) local fontstring = frame:CreateFontString(nil, "ARTWORK", "GameFontNormal") fontstring:SetWidth(410) fontstring:SetHeight(0) fontstring:SetPoint("TOP", 0, -16) fontstring:SetText(NVTXT:format(newVersion)) local editBox = CreateFrame("EditBox", nil, frame) do local editBoxLeft = editBox:CreateTexture(nil, "BACKGROUND") local editBoxRight = editBox:CreateTexture(nil, "BACKGROUND") local editBoxMiddle = editBox:CreateTexture(nil, "BACKGROUND") editBoxLeft:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Left") editBoxLeft:SetHeight(32) editBoxLeft:SetWidth(32) editBoxLeft:SetPoint("LEFT", -14, 0) editBoxLeft:SetTexCoord(0, 0.125, 0, 1) editBoxRight:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Right") editBoxRight:SetHeight(32) editBoxRight:SetWidth(32) editBoxRight:SetPoint("RIGHT", 6, 0) editBoxRight:SetTexCoord(0.875, 1, 0, 1) editBoxMiddle:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Right") editBoxMiddle:SetHeight(32) editBoxMiddle:SetWidth(1) editBoxMiddle:SetPoint("LEFT", editBoxLeft, "RIGHT") editBoxMiddle:SetPoint("RIGHT", editBoxRight, "LEFT") editBoxMiddle:SetTexCoord(0, 0.9375, 0, 1) end editBox:SetHeight(32) editBox:SetWidth(280) editBox:SetPoint("TOP", fontstring, "BOTTOM", -40, -9) editBox:SetFontObject("GameFontHighlight") editBox:SetTextInsets(0, 0, 0, 1) editBox:SetFocus() editBox:SetText("http://wga.hostcell.net/") editBox:HighlightText() editBox:SetScript("OnHide", function(self) if ChatFrameEditBox:IsVisible() then ChatFrameEditBox:SetFocus() end end) editBox:SetScript("OnTextChanged", function(self) editBox:SetText("http://wga.hostcell.net/") editBox:HighlightText() end) local button = CreateFrame("Button", nil, frame) button:SetHeight(24) button:SetWidth(75) button:SetPoint("CENTER", 150, -8) button:SetNormalFontObject("GameFontNormal") button:SetHighlightFontObject("GameFontHighlight") button:SetNormalTexture(button:CreateTexture(nil, nil, "UIPanelButtonUpTexture")) button:SetPushedTexture(button:CreateTexture(nil, nil, "UIPanelButtonDownTexture")) button:SetHighlightTexture(button:CreateTexture(nil, nil, "UIPanelButtonHighlightTexture")) button:SetText(BUTTONTXT1) button:SetScript("OnClick", function(self) frame:Hide() end) end function WG_announceVersion() SendAddonMessage( "WGA", WG_VERSION, "RAID" ); SendAddonMessage( "WGA", WG_VERSION, "PARTY" ); -- SendAddonMessage( "WGA", WG_VERSION, "GUILD" ); end function WGDropDownMenu_Cancel() PlaySound("UChatScrollButton"); end