/
## Interface: 70000 |
## Title: sCompanions |
## Author: Seerah |
## Version: 2.0.3 |
## Version: 2.0.4 |
## Notes: Divides up your mounts into 2 categories based on land/air, to randomly pick from via a macro. Also provides a random pet macro. |
## OptionalDeps: LibPetJournal-2.0 |
local LPJ = LibStub("LibPetJournal-2.0") |
local f = CreateFrame("Frame") |
local _,mount |
local _, mount |
local CMJ = C_MountJournal |
local CPJ = C_PetJournal |
local wipe = wipe |
local tinsert = tinsert |
local math_random = math.random |
--local numMounts = CMJ.GetNumMounts() --the game won't add new mounts during a session |
end) |
function sCompanions.MountUp(pool) |
if #pool >= 1 then |
local id = pool[math.random(#pool)] |
local name, isUsable |
name, _, _, _, isUsable = CMJ.GetMountInfoByID(id) |
function sCompanions.MountUp(pool, compType) |
local numAttempts, canMount = 0, true |
local numMounts = #pool |
if numMounts >= 1 then |
local id = pool[math_random(numMounts)] |
--local name, isUsable |
local name, _, _, _, isUsable = CMJ.GetMountInfoByID(id) |
while ignore[name] or not isUsable do |
--if not isUsable then print(name) end |
id = pool[math.random(#pool)] |
id = pool[math_random(numMounts)] |
name, _, _, _, isUsable = CMJ.GetMountInfoByID(id) |
numAttempts = numAttempts + 1 |
if numAttempts > numMounts then |
canMount = false |
break |
end |
end |
CMJ.SummonByID(id) |
if canMount then |
CMJ.SummonByID(id) |
else |
print("|cff86b850sCompanions:|r No usable "..compType.." mounts to choose from.") |
end |
else |
print("|cff86b850sCompanions:|r No "..compType.." mounts to choose from.") |
end |
function sCompanions.CallPet(pool) |
local numpets = #pool |
if numpets >= 1 then |
local id = pool[math.random(numpets)] |
local id = pool[math_random(numpets)] |
local _,_,_,_,_,_,name = CPJ.GetPetInfoByPetID(id) |
while ignore[name] or CPJ.GetSummonedPetGUID() == id do |
id = math.random(pool) |
id = math_random(pool) |
_,_,_,_,_,_,name = CPJ.GetPetInfoByPetGUID(id) |
end |
CPJ.SummonPetByGUID(id) |
elseif IsFalling() then |
UIErrorsFrame:AddMessage(ERR_NOT_WHILE_FALLING, 1.0, 0.1, 0.1, 1.0) |
else |
sCompanions.MountUp(pool) |
sCompanions.MountUp(pool, compType) |
end |
end |
elseif compType == "pet" then |