/PartyHardy
local version = 0.15 |
local version = 0.17 |
if not PartyHardyDB then PartyHardyDB = {} end |
if not PartyHardyDB.whitelist then PartyHardyDB.whitelist = { [string.lower(UnitName("player"))] = true, } end |
StaticPopupDialogs["PARTYHARDY_NAMEADD"] = { |
text = "Write the name to add:", |
button1 = TEXT(ACCEPT), |
button2 = TEXT(CANCEL), |
OnAccept = function(self) |
local name = _G[self:GetName().."EditBox"]:GetText() |
PartyHardyDB.whitelist[string.lower(name)] = true |
ChatFrame1:AddMessage("|cFFFF9900PartyHardy: "..string.lower(name).." added to trusted list.") |
StaticPopup_Hide("PARTYHARDY_NAMEADD") |
end, |
timeout = 0, |
whileDead = true, |
hideOnEscape = true, |
preferredIndex = 3, -- avoid some UI taint, see http://www.wowace.com/announcements/how-to-avoid-some-ui-taint/ |
OnShow = function (self,data) |
self.editBox:SetText("Player") |
self.editBox:SetFocus(); |
self.editBox:HighlightText(); |
end, |
hasEditBox = 1, |
maxLetters = 31, |
editBoxWidth = 350, |
exclusive = 1, |
EditBoxOnEnterPressed = function(self) |
local parent = self:GetParent(); |
local name = parent.editBox:GetText(); |
PartyHardyDB.whitelist[string.lower(name)] = true |
ChatFrame1:AddMessage("|cFFFF9900PartyHardy: "..string.lower(name).." added to trusted list.") |
StaticPopup_Hide("PARTYHARDY_NAMEADD") |
end, |
EditBoxOnEscapePressed = function() |
StaticPopup_Hide("PARTYHARDY_NAMEADD") |
end, |
} |
local XPtable,orange,follow,faction,previouscommand,celestial = {},"|cFFFF9900" |
--[[ |
mikmaMF = CreateFrame("MessageFrame", nil, UIParent) |
mikmaMF:SetSize(500, height) |
mikmaMF:SetPoint("BOTTOMLEFT", ChatFrame1, "TOPLEFT", 0, 10) |
mikmaMF:SetInsertMode("TOP") |
mikmaMF:SetJustifyH("LEFT") |
mikmaMF:SetFrameStrata("HIGH") |
mikmaMF:SetTimeVisible(60) |
mikmaMF:SetFadeDuration(10) |
mikmaMF:SetFont(STANDARD_TEXT_FONT, 15, "OUTLINE") |
--mikmaMF.background = mikmaMF:CreateTexture(nil,"BACKGROUND") |
--mikmaMF.background:SetAllPoints() |
--mikmaMF.background:SetTexture(0,0,0,0.5) |
]] |
local PartyHardy = CreateFrame("Frame") |
PartyHardy:RegisterEvent("CHAT_MSG_PARTY") |
PartyHardy:RegisterEvent("CHAT_MSG_PARTY_LEADER") |
PartyHardy:RegisterEvent("PARTY_INVITE_REQUEST") |
PartyHardy:RegisterEvent("PLAYER_ENTERING_WORLD") |
--PartyHardy:RegisterEvent("CHAT_MSG_BN_WHISPER") -- todo? |
PartyHardy:RegisterEvent("CHAT_MSG_ADDON") |
--PartyHardy:RegisterEvent("CHAT_MSG_BN_WHISPER") -- todo? |
PartyHardy:RegisterEvent("PLAYER_XP_UPDATE") |
PartyHardy:SetScript("OnEvent", function(self, event, ...) |
if self[event] then return self[event](self, event, ...) end |
text = "", |
}) |
local function RandomMount() |
if #PartyHardyDB.FlyingMounts > 0 and IsFlyableArea() then |
CallCompanion("MOUNT",PartyHardyDB.FlyingMounts[random(1,#PartyHardyDB.FlyingMounts)]) |
elseif #PartyHardyDB.LandMounts > 0 then |
CallCompanion("MOUNT",PartyHardyDB.LandMounts[random(1,#PartyHardyDB.LandMounts)]) |
else |
SendChatMessage("No mounts detected!", "PARTY", faction) |
end |
end |
local function GetXP() |
if UnitLevel("player") < MAX_PLAYER_LEVEL_TABLE[GetAccountExpansionLevel()] then |
local level = UnitLevel("player")+1 |
local function PartyCommands(self,msg,name) |
local msg = string.lower(msg) |
local name = string.lower(name) |
local name = strsplit("-", name) |
local a, b = strsplit(" ", msg, 2) |
if a == "!follow" and name ~= string.lower(UnitName("player")) and not UnitCastingInfo("player") then |
if not PartyHardyDB.follow and PartyHardyDB.whitelist[name] then |
SendChatMessage("Can't follow "..name..". Out of range.", "PARTY", faction) |
end |
else |
SendChatMessage("Already following "..PartyHardyDB[follow]..".", "PARTY", faction) |
SendChatMessage("Already following "..PartyHardyDB["follow"]..".", "PARTY", faction) |
end |
elseif a == "!followreset" and UnitIsGroupLeader(UnitName("player")) and PartyHardyDB.whitelist[name] then |
PartyHardyDB.follow = nil |
SendChatMessage(GetSpellLink(PartyHardyDB.land).." failed, in combat.", "PARTY", faction) |
PartyHardy:RegisterEvent("PLAYER_REGEN_ENABLED") |
else |
RandomMount() |
C_MountJournal.Summon(0) |
end |
elseif a == "!cele" and PartyHardyDB.whitelist[name] and not IsMounted() and not UnitCastingInfo("player") then |
if InCombatLockdown() then |
local healer = LFDQueueFrameRoleButtonHealer.checkButton:GetChecked() |
local dps = LFDQueueFrameRoleButtonDPS.checkButton:GetChecked() |
if checkvisible and (tank or healer or dps) then |
--LFDRoleCheckPopupAccept_OnClick() |
LFDQueueFrameFindGroupButton:Click() |
LFDRoleCheckPopupAccept_OnClick() |
end |
if QuestFrame:IsVisible() then |
QuestFrameAcceptButton:Click() |
if TradeFrame:IsVisible() then |
TradeFrameTradeButton:Click() |
end |
if RaidFinderFrame:IsVisible() then |
RaidFinderFrameFindRaidButton:Click() |
end |
if LFDRoleCheckPopup and LFDRoleCheckPopup:IsVisible() then |
LFDRoleCheckPopupAcceptButton:Click() |
end |
elseif a == "!version" then |
SendChatMessage("PartyHardy v"..version, "PARTY", faction) |
elseif a == "tnl?" then |
local function EndFollow(timed) |
if PartyHardyDB.follow then |
if timed then |
SendAddonMessage("PARTYHARDY","FOLLOWSTOPSTUCK,TEMP", "WHISPER", PartyHardyDB.follow) |
SendAddonMessage("PARTYHARDY","FOLLOWSTOPSTUCK", "WHISPER", PartyHardyDB.follow) |
else |
SendAddonMessage("PARTYHARDY","FOLLOWSTOP,TEMP", "WHISPER", PartyHardyDB.follow) |
SendAddonMessage("PARTYHARDY","FOLLOWSTOP", "WHISPER", PartyHardyDB.follow) |
end |
PartyHardy:UnregisterEvent("AUTOFOLLOW_END") |
PartyHardyDB.follow = nil |
PartyHardy:RegisterEvent("AUTOFOLLOW_END") |
end |
--[[ |
AutoFollowStatus:SetScript("OnShow", function() |
if AutoFollowStatus.unit then |
follow = string.lower(AutoFollowStatus.unit) |
--if PartyHardyDB.whitelist[follow] then |
SendAddonMessage("PARTYHARDY","FOLLOWSTART", "WHISPER", follow) |
--end |
end |
end) |
]] |
AutoFollowStatus:SetScript("OnHide", function() |
EndFollow(true) |
end) |
faction = UnitFactionGroup("player") == "Horde" and "Orcish" or "Common" |
if UnitInParty("player") then SendAddonMessage("PARTYHARDY","LEVELREQUEST","PARTY") end |
PartyHardy.DO.text = GetXP() |
PartyHardyDB.LandMounts = {} |
PartyHardyDB.FlyingMounts = {} |
local count = GetNumCompanions("MOUNT") |
for i=1,count do |
local creatureID, creatureName, spellID, icon, active, mountFlags = GetCompanionInfo("MOUNT", i) |
if creatureID == 40625 then celestial = i end |
if bit.band(mountFlags,0x02) == 0x02 then |
table.insert(PartyHardyDB.FlyingMounts,i) |
elseif bit.band(mountFlags,0x01) == 0x01 then |
table.insert(PartyHardyDB.LandMounts,i) |
end |
end |
end |
function PartyHardy:CHAT_MSG_ADDON(self,prefix,message,channel,name) |
SendAddonMessage("PARTYHARDY", "LEVELBROADCAST,"..GetXP(), "PARTY") |
elseif info1 == "LEVELBROADCAST" and name ~= UnitName("player") then |
XPtable[name] = info2 |
--printMF() |
elseif info1 == "LEVELWHISPERREQUEST" then |
SendAddonMessage("PARTYHARDY", "LEVELWHISPERBROADCAST,"..GetXP(), "WHISPER", name) |
elseif info1 == "LEVELWHISPERBROADCAST" then |
end |
end |
function printMF() |
for k,v in pairs(XPtable) do |
local k = strsplit("-", k) |
if UnitInParty(k) then |
mikmaMF:AddMessage(k.." - "..v) |
end |
end |
end |
function PartyHardy:PLAYER_XP_UPDATE() |
if UnitInParty("player") then SendAddonMessage("PARTYHARDY", "LEVELBROADCAST,"..GetXP(), "PARTY") end |
PartyHardy.DO.text = GetXP() |
--printMF() |
end |
function PartyHardy.DO.OnEnter(self) |
SlashCmdList["PartyHardy"] = function(msg) |
local a, b = strsplit(" ", msg, 2); |
if a == "add" then |
if #b < 13 then |
PartyHardyDB.whitelist[string.lower(b)] = true |
ChatFrame1:AddMessage(orange.."PartyHardy: "..b.." added to trusted list.") |
end |
StaticPopup_Show("PARTYHARDY_NAMEADD") |
elseif a == "del" then |
if #b < 13 then |
PartyHardyDB.whitelist[string.lower(b)] = nil |
ChatFrame1:AddMessage(orange.."PartyHardy: "..b.." removed from trusted list.") |
end |
elseif a == "land" then |
if #b > 12 then |
PartyHardyDB.land = b:match('spell:(%d+)') |
ChatFrame1:AddMessage(orange.."PartyHardy: "..b..orange.." added as land mount.") |
end |
elseif a == "fly" then |
if #b > 12 then |
PartyHardyDB.fly = b:match('spell:(%d+)') |
ChatFrame1:AddMessage(orange.."PartyHardy: "..b..orange.." added as flying mount.") |
end |
else ChatFrame1:AddMessage(orange.."PartyHardy accepts these commands: 'add <name>', 'del <name>', 'land [normal mount]', 'fly [flying mount]'.") end |
end |
## Interface: 30300 |
## Interface: 60000 |
## Title: PartyHardy |
## Notes: Party with closest friends! |
## Author: Mikma |