Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 47 additions & 28 deletions Core/MultiBotHandler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -472,22 +472,31 @@ MultiBot:SetScript("OnEvent", function()
and MultiBot.frames["MultiBar"].frames["Units"]) then
-- UI pas encore prête : on re-propulse le même event vers NOTRE OnEvent
local saved_msg = arg1
local df = CreateFrame("Frame")
df.t = 0
df:SetScript("OnUpdate", function(self, elapsed)
self.t = self.t + elapsed
if self.t > 0.2 then
self:SetScript("OnUpdate", nil)
local onEvent = MultiBot:GetScript("OnEvent")
if onEvent then
-- Sauvegarde/restaure les globals d’événement
local _event, _arg1 = event, arg1
event, arg1 = "CHAT_MSG_SYSTEM", saved_msg
onEvent()
event, arg1 = _event, _arg1
end

local function ReDispatchRoster()
local onEvent = MultiBot:GetScript("OnEvent")
if onEvent then
-- Sauvegarde/restaure les globals d’événement
local _event, _arg1 = event, arg1
event, arg1 = "CHAT_MSG_SYSTEM", saved_msg
onEvent()
event, arg1 = _event, _arg1
end
end)
end

if type(TimerAfter) == "function" then
TimerAfter(0.2, ReDispatchRoster)
else
local df = CreateFrame("Frame")
df.t = 0
df:SetScript("OnUpdate", function(self, elapsed)
self.t = self.t + elapsed
if self.t > 0.2 then
self:SetScript("OnUpdate", nil)
ReDispatchRoster()
end
end)
end
return
end

Expand Down Expand Up @@ -560,7 +569,7 @@ MultiBot:SetScript("OnEvent", function()
-- Filtre de sécurité :
-- - pas de nom vide
-- - pas de classe inconnue => on évite les boutons Unknown
if botName ~= "" and botClass ~= "Unknown" then
if botName ~= "" and botClass and botClass ~= "Unknown" then
local botButton = MultiBot.addPlayer(botClass, botName).setDisable()

botButton.doRight = function(pButton)
Expand Down Expand Up @@ -628,12 +637,14 @@ MultiBot:SetScript("OnEvent", function()
end

-- MEMBERBOTS --
for i = 1, 50 do
--local tName, tRank, tIndex, tLevel, tClass = GetGuildRosterInfo(i)
--for i = 1, 50 do
local tGuildCount = 0
if type(GetNumGuildMembers) == "function" then
tGuildCount = select(1, GetNumGuildMembers()) or 0
end
local memberLoopMax = (tGuildCount > 0) and tGuildCount or 50

-- Ensure that the Counter is not bigger than the Amount of Members in Guildlist
--if(tName ~= nil and tLevel ~= nil and tClass ~= nil and tName ~= UnitName("player")) then
--local tMember = MultiBot.addMember(tClass, tLevel, tName).setDisable()
for i = 1, memberLoopMax do
local memberName, _, _, memberLevel, memberClass = GetGuildRosterInfo(i)

-- Ensure that the Counter is not bigger than the Amount of Members in Guildlist
Expand Down Expand Up @@ -661,13 +672,14 @@ MultiBot:SetScript("OnEvent", function()
end

-- FRIENDBOTS --
for i = 1, 50 do
--local tName, tLevel, tClass = GetFriendInfo(i)

-- Ensure that the Counter is not bigger than the Amount of Members in Friendlist
--if(tName ~= nil and tLevel ~= nil and tClass ~= nil and tName ~= UnitName("player")) then
--local tFriend = MultiBot.addFriend(tClass, tLevel, tName).setDisable()
--for i = 1, 50 do
local tFriendCount = 0
if type(GetNumFriends) == "function" then
tFriendCount = GetNumFriends() or 0
end
local friendLoopMax = (tFriendCount > 0) and tFriendCount or 50

for i = 1, friendLoopMax do
local friendName, friendLevel, friendClass = GetFriendInfo(i)

-- Ensure that the Counter is not bigger than the Amount of Members in Friendlist
Expand Down Expand Up @@ -1186,7 +1198,14 @@ MultiBot:SetScript("OnEvent", function()
local tLevel = ""
local tClass = ""

for i = 1, 50 do
--for i = 1, 50 do
local tFriendScanCount = 0
if type(GetNumFriends) == "function" then
tFriendScanCount = GetNumFriends() or 0
end
local friendScanMax = (tFriendScanCount > 0) and tFriendScanCount or 50

for i = 1, friendScanMax do
tName, tLevel, tClass = GetFriendInfo(i)
if(tName == arg2) then break end
if(tName == nil) then break end
Expand Down
82 changes: 76 additions & 6 deletions Core/MultiBotInit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,14 @@ tButton.roster = "players"
tButton.filter = "none"

tButton.doRight = function(pButton)
local isGuildRetry = pButton._guildRosterRetrying == true
pButton._guildRosterRetrying = false
local retryCount = tonumber(pButton._guildRosterRetryCount) or 0
if not isGuildRetry then
retryCount = 0
end
local needGuildRetry = false

--[[ -- MEMBERBOTS --

for i = 1, 50 do
Expand Down Expand Up @@ -761,6 +769,14 @@ tButton.doRight = function(pButton)
pButton.doLeft(pButton, pButton.roster, pButton.filter)]]--

-- Always refresh guild/friend rosters so their indexes stay in sync
local prevShowOffline = nil
if type(GetGuildRosterShowOffline) == "function" and type(SetGuildRosterShowOffline) == "function" then
prevShowOffline = GetGuildRosterShowOffline()
if prevShowOffline == false then
SetGuildRosterShowOffline(true)
end
end

if(type(GuildRoster) == "function") then GuildRoster() end
if(type(ShowFriends) == "function") then ShowFriends() end

Expand All @@ -771,10 +787,30 @@ tButton.doRight = function(pButton)
MultiBot.index.classes.friends = {}

-- MEMBERBOTS --
local tMaxMembers = type(GetNumGuildMembers) == "function" and GetNumGuildMembers() or 50
local inGuild = false
if type(IsInGuild) == "function" then
inGuild = IsInGuild()
elseif type(GetGuildInfo) == "function" then
inGuild = (GetGuildInfo("player") ~= nil)
end

local tMaxMembers = 0
if type(GetNumGuildMembers) == "function" then
tMaxMembers = select(1, GetNumGuildMembers()) or 0
end
tMaxMembers = tonumber(tMaxMembers) or 0
if tMaxMembers <= 0 then
tMaxMembers = 50
if inGuild then
needGuildRetry = true
end
end

local guildCount = 0
for i = 1, tMaxMembers do
local tName, _, _, tLevel, tClass = GetGuildRosterInfo(i)
if(tName ~= nil and tLevel ~= nil and tClass ~= nil and tName ~= UnitName("player")) then
guildCount = guildCount + 1
local tMember = MultiBot.addMember(tClass, tLevel, tName)
if(tMember.state == false) then
tMember.setDisable()
Expand All @@ -797,13 +833,43 @@ tButton.doRight = function(pButton)
pButton.setEnable()
end
end
elseif(tName == nil) then
elseif(tName == nil or tLevel == nil or tClass == nil) then
if inGuild and i < tMaxMembers then
needGuildRetry = true
end
break
end
end

if prevShowOffline == false and type(SetGuildRosterShowOffline) == "function" then
SetGuildRosterShowOffline(false)
end

if not isGuildRetry and inGuild and tMaxMembers == 50 and guildCount == 50 then
needGuildRetry = true
end

if (not isGuildRetry) and needGuildRetry and type(TimerAfter) == "function" and retryCount < 6 then
pButton._guildRosterRetryCount = retryCount + 1
pButton._guildRosterRetrying = true
TimerAfter(0.25, function()
if pButton and pButton.doRight then
pButton.doRight(pButton)
end
end)
else
pButton._guildRosterRetryCount = 0
end

-- FRIENDBOTS --
local tMaxFriends = type(GetNumFriends) == "function" and GetNumFriends() or 50
local tMaxFriends = 0
if type(GetNumFriends) == "function" then
tMaxFriends = GetNumFriends() or 0
end
tMaxFriends = tonumber(tMaxFriends) or 0
if tMaxFriends <= 0 then
tMaxFriends = 50
end
for i = 1, tMaxFriends do
local tName, tLevel, tClass = GetFriendInfo(i)
if(tName ~= nil and tLevel ~= nil and tClass ~= nil and tName ~= UnitName("player")) then
Expand All @@ -829,20 +895,22 @@ tButton.doRight = function(pButton)
pButton.setEnable()
end
end
elseif(tName == nil) then
break
--elseif(tName == nil) then
--break
elseif(tName == nil or tLevel == nil or tClass == nil) then
needGuildRetry = true
end
end

-- Roster requiring server feedback (players/actives/favorites)
if not isGuildRetry then
local tRoster = pButton.roster or "players"
if(tRoster == "players" or tRoster == "actives" or tRoster == "favorites") then
SendChatMessage(".playerbot bot list", "SAY")
if(tRoster == "favorites" and MultiBot.UpdateFavoritesIndex ~= nil) then
MultiBot.UpdateFavoritesIndex()
end
end

-- Pour les bots déjà groupés : relance un cycle "co ?" afin qu'ils renvoient leurs stratégies
local function RefreshStrategiesFor(name)
if not name or name == UnitName("player") then return end
Expand Down Expand Up @@ -890,6 +958,8 @@ tButton.doRight = function(pButton)
end
end

end

pButton.doLeft(pButton, pButton.roster, pButton.filter)

if type(TimerAfter) == "function" then
Expand Down
Loading