/PartyHardy
local version = 0.14 |
local version = 0.15 |
if not PartyHardyDB then PartyHardyDB = {} end |
if not PartyHardyDB.whitelist then PartyHardyDB.whitelist = { [string.lower(UnitName("player"))] = true, } end |
local XPtable,orange,follow = {},"|cFFFF9900" |
local XPtable,orange,follow,faction,previouscommand,celestial = {},"|cFFFF9900" |
local PartyHardy = CreateFrame("Frame") |
PartyHardy:RegisterEvent("CHAT_MSG_PARTY") |
PartyHardy:RegisterEvent("PARTY_INVITE_REQUEST") |
PartyHardy:RegisterEvent("PLAYER_ENTERING_WORLD") |
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 msg = string.lower(msg) |
local name = string.lower(name) |
local a, b = strsplit(" ", msg, 2) |
if a == "!follow" and name ~= UnitName("player") and not UnitCastingInfo("player") then |
PartyHardy:RegisterEvent("AUTOFOLLOW_BEGIN") |
if not follow then |
PartyHardy:RegisterEvent("AUTOFOLLOW_END") |
FollowUnit(name) |
if a == "!follow" and name ~= string.lower(UnitName("player")) and not UnitCastingInfo("player") then |
if not PartyHardyDB.follow and PartyHardyDB.whitelist[name] then |
if CheckInteractDistance(name, 4) == 1 then |
PartyHardy:RegisterEvent("AUTOFOLLOW_BEGIN") |
FollowUnit(name) |
else |
SendChatMessage("Can't follow "..name..". Out of range.", "PARTY", faction) |
end |
else |
SendChatMessage("Already following "..follow..".", "PARTY", (UnitFactionGroup("player") == "Horde" and "Orcish" or "Common")) |
SendChatMessage("Already following "..PartyHardyDB[follow]..".", "PARTY", faction) |
end |
elseif a == "!followreset" and IsPartyLeader() and PartyHardyDB.whitelist[name] then |
follow = nil |
SendChatMessage("follow has been reset.", "PARTY", (UnitFactionGroup("player") == "Horde" and "Orcish" or "Common")) |
elseif a == "!ffa" and IsPartyLeader() and PartyHardyDB.whitelist[name] then |
elseif a == "!followreset" and UnitIsGroupLeader(UnitName("player")) and PartyHardyDB.whitelist[name] then |
PartyHardyDB.follow = nil |
SendChatMessage("follow has been reset.", "PARTY", faction) |
elseif a == "!ffa" and UnitIsGroupLeader(UnitName("player")) and PartyHardyDB.whitelist[name] then |
SetLootMethod("freeforall") |
elseif a == "!gl" and IsPartyLeader() and PartyHardyDB.whitelist[name] then |
elseif a == "!gl" and UnitIsGroupLeader(UnitName("player")) and PartyHardyDB.whitelist[name] then |
SetLootMethod("group") |
elseif a == "!ml" and IsPartyLeader() and PartyHardyDB.whitelist[name] then |
elseif a == "!ml" and UnitIsGroupLeader(UnitName("player")) and PartyHardyDB.whitelist[name] then |
SetLootMethod("master", UnitName("player")) |
elseif a == "!pl" and PartyHardyDB.whitelist[name] then |
if b == "on" then |
SetOptOutOfLoot(1) |
SendChatMessage("Passing loot: Yes.", "PARTY", (UnitFactionGroup("player") == "Horde" and "Orcish" or "Common")) |
SendChatMessage("Passing loot: Yes.", "PARTY", faction) |
elseif b == "off" then |
SetOptOutOfLoot(nil) |
SendChatMessage("Passing loot: No.", "PARTY", (UnitFactionGroup("player") == "Horde" and "Orcish" or "Common")) |
SendChatMessage("Passing loot: No.", "PARTY", faction) |
end |
elseif a == "!leader" and IsPartyLeader() and PartyHardyDB.whitelist[name] then |
elseif a == "!leader" and UnitIsGroupLeader(UnitName("player")) and PartyHardyDB.whitelist[name] then |
PromoteToLeader(name) |
elseif a == "!invite" and IsPartyLeader() and PartyHardyDB.whitelist[name] then |
elseif a == "!invite" and UnitIsGroupLeader(UnitName("player")) and PartyHardyDB.whitelist[name] then |
InviteUnit(b); |
elseif a == "!land" and PartyHardyDB.land and PartyHardyDB.whitelist[name] and not IsMounted() and not UnitCastingInfo("player") then |
elseif a == "!mount" and PartyHardyDB.whitelist[name] and not IsMounted() and not UnitCastingInfo("player") then |
if InCombatLockdown() then |
SendChatMessage(GetSpellLink(PartyHardyDB.land).." failed, in combat.", "PARTY", (UnitFactionGroup("player") == "Horde" and "Orcish" or "Common")) |
previouscommand = "Your previous command was: !mount" |
SendChatMessage(GetSpellLink(PartyHardyDB.land).." failed, in combat.", "PARTY", faction) |
PartyHardy:RegisterEvent("PLAYER_REGEN_ENABLED") |
else |
for i=1,GetNumCompanions("mount") do |
if select(3,GetCompanionInfo("mount",i)) == tonumber(PartyHardyDB.land) then |
CallCompanion("mount",i) |
break |
end |
end |
RandomMount() |
end |
elseif a == "!fly" and PartyHardyDB.fly and PartyHardyDB.whitelist[name] and not IsMounted() and not UnitCastingInfo("player") then |
elseif a == "!cele" and PartyHardyDB.whitelist[name] and not IsMounted() and not UnitCastingInfo("player") then |
if InCombatLockdown() then |
SendChatMessage(GetSpellLink(PartyHardyDB.fly).." failed, in combat.", "PARTY", (UnitFactionGroup("player") == "Horde" and "Orcish" or "Common")) |
previouscommand = "Your previous command was: !mount" |
SendChatMessage(GetSpellLink(PartyHardyDB.land).." failed, in combat.", "PARTY", faction) |
PartyHardy:RegisterEvent("PLAYER_REGEN_ENABLED") |
else |
for i=1,GetNumCompanions("mount") do |
if select(3,GetCompanionInfo("mount",i)) == tonumber(PartyHardyDB.fly) then |
CallCompanion("mount",i) |
break |
end |
end |
CallCompanion("MOUNT",celestial) |
end |
elseif a == "!dismount" and PartyHardyDB.whitelist[name] and not IsFlying() then |
Dismount() |
end |
end |
end |
local visible |
local tank |
local healer |
local dps |
if LFDRoleCheckPopup:IsVisible() == 1 and (LFDQueueFrameRoleButtonTank.checkButton:GetChecked() == 1 or LFDQueueFrameRoleButtonHealer.checkButton:GetChecked() == 1 or LFDQueueFrameRoleButtonDPS.checkButton:GetChecked() == 1) then |
LFDRoleCheckPopupAccept_OnClick() |
local checkvisible = LFDRoleCheckPopup:IsVisible() |
local tank = LFDQueueFrameRoleButtonTank.checkButton:GetChecked() |
local healer = LFDQueueFrameRoleButtonHealer.checkButton:GetChecked() |
local dps = LFDQueueFrameRoleButtonDPS.checkButton:GetChecked() |
if checkvisible and (tank or healer or dps) then |
--LFDRoleCheckPopupAccept_OnClick() |
LFDQueueFrameFindGroupButton:Click() |
end |
if LFGDungeonReadyPopup:IsVisible() then -- <- LFGDungeonReadyPopup results error, how about this one? |
AcceptProposal() |
--StaticPopupSpecial_Hide(LFDDungeonReadyPopup) |
if QuestFrame:IsVisible() then |
QuestFrameAcceptButton:Click() |
end |
if TradeFrame:IsVisible() then |
TradeFrameTradeButton:Click() |
end |
elseif a == "!version" then |
SendChatMessage("PartyHardy v"..version, "PARTY", (UnitFactionGroup("player") == "Horde" and "Orcish" or "Common")) |
SendChatMessage("PartyHardy v"..version, "PARTY", faction) |
elseif a == "tnl?" then |
SendAddonMessage("PARTYHARDY","LEVELREQUEST,TEMP","PARTY") |
SendChatMessage(GetXP(), "PARTY", (UnitFactionGroup("player") == "Horde" and "Orcish" or "Common")) |
SendChatMessage(GetXP(), "PARTY", faction) |
end |
end |
end |
local function EndFollow(timed) |
if follow and PartyHardyDB.whitelist[follow] then |
SendAddonMessage("PARTYHARDY","FOLLOWSTOP,TEMP", "WHISPER", follow) |
if PartyHardyDB.follow then |
if timed then |
SendAddonMessage("PARTYHARDY","FOLLOWSTOPSTUCK,TEMP", "WHISPER", PartyHardyDB.follow) |
else |
SendAddonMessage("PARTYHARDY","FOLLOWSTOP,TEMP", "WHISPER", PartyHardyDB.follow) |
end |
PartyHardy:UnregisterEvent("AUTOFOLLOW_END") |
follow = nil |
PartyHardyDB.follow = nil |
end |
end |
EndFollow() |
end |
function PartyHardy:AUTOFOLLOW_BEGIN(self, name) |
PartyHardyDB.follow = name |
SendAddonMessage("PARTYHARDY","FOLLOWSTART", "WHISPER", name) |
PartyHardy:RegisterEvent("AUTOFOLLOW_END") |
end |
--[[ |
AutoFollowStatus:SetScript("OnShow", function() |
if AutoFollowStatus.unit then |
follow = string.lower(AutoFollowStatus.unit) |
SendAddonMessage("PARTYHARDY","FOLLOWSTART", "WHISPER", follow) |
--if PartyHardyDB.whitelist[follow] then |
SendAddonMessage("PARTYHARDY","FOLLOWSTART", "WHISPER", follow) |
--end |
end |
end) |
]] |
AutoFollowStatus:SetScript("OnHide", function() |
EndFollow() |
EndFollow(true) |
end) |
function PartyHardy:PLAYER_REGEN_ENABLED() |
PartyHardy:UnregisterEvent("PLAYER_REGEN_ENABLED") |
SendChatMessage("Combat ended.", "PARTY", (UnitFactionGroup("player") == "Horde" and "Orcish" or "Common")) |
SendChatMessage("Combat ended."..previouscommand and previouscommand or "", "PARTY", faction) |
previouscommand = nil |
end |
function PartyHardy:PLAYER_ENTERING_WORLD() |
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) |
ChatFrame1:AddMessage(orange.."PartyHardy: "..name.." is following you.") |
elseif info1 == "FOLLOWSTOP" then |
ChatFrame1:AddMessage(orange.."PartyHardy: "..name.." is no longer following you.") |
elseif info1 == "FOLLOWSTOPSTUCK" then |
ChatFrame1:AddMessage(orange.."PartyHardy: "..name.." is no longer following you. Maybe the character is stuck?") |
end |
end |
end |