Skip to content
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
238 changes: 238 additions & 0 deletions Core/MultiBotComm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ local function ensureBridgeState()
state.botSkills = state.botSkills or {}
state.botSkillSeq = state.botSkillSeq or 0
state.botSkillActive = state.botSkillActive or nil
state.botReputations = state.botReputations or {}
state.botReputationSeq = state.botReputationSeq or 0
state.botReputationActive = state.botReputationActive or nil
state.botEmblems = state.botEmblems or {}
state.botEmblemMoney = state.botEmblemMoney or {}
state.botEmblemSeq = state.botEmblemSeq or 0
state.botEmblemActive = state.botEmblemActive or nil
state.professionRecipes = state.professionRecipes or {}
state.professionRecipeSeq = state.professionRecipeSeq or 0
state.professionRecipeActive = state.professionRecipeActive or nil
Expand Down Expand Up @@ -657,6 +664,57 @@ function Comm.RequestBotSkills(name)
return true
end

function Comm.RequestBotReputations(name)
local state = ensureBridgeState()
name = trim(name)
if name == "" or not state.connected then
return false
end

state.botReputationSeq = (tonumber(state.botReputationSeq) or 0) + 1
local token = tostring(math.floor(safeNow() * 1000)) .. "-rep-" .. tostring(state.botReputationSeq)
state.botReputationActive = {
botName = name,
botNameKey = string.lower(name),
token = token,
startedAt = safeNow(),
items = {},
}

if not Comm.Send("GET", "BOT_REPUTATIONS~" .. name .. "~" .. token) then
state.botReputationActive = nil
return false
end

return true
end

function Comm.RequestBotEmblems(name)
local state = ensureBridgeState()
name = trim(name)
if name == "" or not state.connected then
return false
end

state.botEmblemSeq = (tonumber(state.botEmblemSeq) or 0) + 1
local token = tostring(math.floor(safeNow() * 1000)) .. "-emblem-" .. tostring(state.botEmblemSeq)
state.botEmblemActive = {
botName = name,
botNameKey = string.lower(name),
token = token,
startedAt = safeNow(),
items = {},
money = nil,
}

if not Comm.Send("GET", "BOT_EMBLEMS~" .. name .. "~" .. token) then
state.botEmblemActive = nil
return false
end

return true
end

function Comm.RequestProfessionRecipes(name, skillId)
local state = ensureBridgeState()
name = trim(name)
Expand Down Expand Up @@ -754,6 +812,8 @@ function Comm.MarkDisconnected(reason)
state.inventoryItemActions = {}
state.spellbookActive = nil
state.botSkillActive = nil
state.botReputationActive = nil
state.botEmblemActive = nil
state.professionRecipeActive = nil
state.professionRecipeCrafts = {}
state.outfitActive = nil
Expand Down Expand Up @@ -1824,6 +1884,42 @@ local function getActiveBotSkillRequest(botName, token)
return active
end

local function getActiveBotReputationRequest(botName, token)
local state = ensureBridgeState()
local active = state.botReputationActive
if type(active) ~= "table" then
return nil
end

if botName and botName ~= "" and string.lower(trim(botName)) ~= trim(active.botNameKey or "") then
return nil
end

if token and token ~= "" and tostring(token) ~= tostring(active.token or "") then
return nil
end

return active
end

local function getActiveBotEmblemRequest(botName, token)
local state = ensureBridgeState()
local active = state.botEmblemActive
if type(active) ~= "table" then
return nil
end

if botName and botName ~= "" and string.lower(trim(botName)) ~= trim(active.botNameKey or "") then
return nil
end

if token and token ~= "" and tostring(token) ~= tostring(active.token or "") then
return nil
end

return active
end

local function getActiveProfessionRecipeRequest(botName, token, skillId)
local state = ensureBridgeState()
local active = state.professionRecipeActive
Expand Down Expand Up @@ -2478,6 +2574,143 @@ function Comm.HandleAddonMessage(prefix, message, distribution, sender)
return true
end

if opcode == "BOT_REPUTATIONS_BEGIN" then
local botName, token = splitOnce(payload or "", "~")
botName = trim(urlDecodeField(botName))
token = trim(token)
state.connected = true
state.lastError = nil

local active = getActiveBotReputationRequest(botName, token)
if active then
active.items = {}
end

return true
end

if opcode == "BOT_REPUTATION_ITEM" then
local botName, rest = splitOnce(payload or "", "~")
local token, rest2 = splitOnce(rest or "", "~")
local factionId, rest3 = splitOnce(rest2 or "", "~")
local factionName, rest4 = splitOnce(rest3 or "", "~")
local rank, rest5 = splitOnce(rest4 or "", "~")
local value, maxValue = splitOnce(rest5 or "", "~")

botName = trim(urlDecodeField(botName))
token = trim(token)
state.connected = true
state.lastError = nil

local active = getActiveBotReputationRequest(botName, token)
if active then
table.insert(active.items, {
factionId = tonumber(factionId or "0") or 0,
name = trim(urlDecodeField(factionName)),
rank = tonumber(rank or "0") or 0,
value = tonumber(value or "0") or 0,
max = tonumber(maxValue or "0") or 0,
})
end

return true
end

if opcode == "BOT_REPUTATIONS_END" then
local botName, token = splitOnce(payload or "", "~")
botName = trim(urlDecodeField(botName))
token = trim(token)
state.connected = true
state.lastError = nil

local active = getActiveBotReputationRequest(botName, token)
if active then
local key = string.lower(botName)
state.botReputations[key] = active.items or {}
if MultiBot.OnBridgeBotReputations then
MultiBot.OnBridgeBotReputations(botName, state.botReputations[key], token)
end
state.botReputationActive = nil
end

return true
end

if opcode == "BOT_EMBLEMS_BEGIN" then
local botName, token = splitOnce(payload or "", "~")
botName = trim(urlDecodeField(botName))
token = trim(token)
state.connected = true
state.lastError = nil

local active = getActiveBotEmblemRequest(botName, token)
if active then
active.items = {}
active.money = nil
end

return true
end

if opcode == "BOT_EMBLEM_ITEM" then
local botName, rest = splitOnce(payload or "", "~")
local token, rest2 = splitOnce(rest or "", "~")
local itemId, count = splitOnce(rest2 or "", "~")

botName = trim(urlDecodeField(botName))
token = trim(token)
state.connected = true
state.lastError = nil

local active = getActiveBotEmblemRequest(botName, token)
if active then
table.insert(active.items, {
itemId = tonumber(itemId or "0") or 0,
count = tonumber(count or "0") or 0,
})
end

return true
end

if opcode == "BOT_EMBLEMS_MONEY" then
local botName, rest = splitOnce(payload or "", "~")
local token, money = splitOnce(rest or "", "~")

botName = trim(urlDecodeField(botName))
token = trim(token)
state.connected = true
state.lastError = nil

local active = getActiveBotEmblemRequest(botName, token)
if active then
active.money = tonumber(money or "0") or 0
end

return true
end

if opcode == "BOT_EMBLEMS_END" then
local botName, token = splitOnce(payload or "", "~")
botName = trim(urlDecodeField(botName))
token = trim(token)
state.connected = true
state.lastError = nil

local active = getActiveBotEmblemRequest(botName, token)
if active then
local key = string.lower(botName)
state.botEmblems[key] = active.items or {}
state.botEmblemMoney[key] = active.money
if MultiBot.OnBridgeBotEmblems then
MultiBot.OnBridgeBotEmblems(botName, state.botEmblems[key], token, state.botEmblemMoney[key])
end
state.botEmblemActive = nil
end

return true
end

if opcode == "PROFESSION_RECIPES_BEGIN" then
local botName, rest = splitOnce(payload or "", "~")
local token, skillId = splitOnce(rest or "", "~")
Expand Down Expand Up @@ -2680,6 +2913,11 @@ function Comm.OnPlayerEnteringWorld()
state.spellbookActive = nil
state.botSkills = {}
state.botSkillActive = nil
state.botReputations = {}
state.botReputationActive = nil
state.botEmblems = {}
state.botEmblemMoney = {}
state.botEmblemActive = nil
state.professionRecipes = {}
state.professionRecipeActive = nil
state.professionRecipeCrafts = {}
Expand Down
9 changes: 9 additions & 0 deletions Locales/MultiBotAceLocale-deDE.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,17 @@ local deDEValues = {
["profession.recipes.craft.reason.LOST_CONTROL"] = "Der Bot kann gerade nicht handeln.",
["profession.recipes.craft.reason.CHANNELING"] = "Der Bot kanalisiert bereits einen Zauber.",
["profession.recipes.craft.reason.cast_code"] = "Der Server hat den Zauber abgelehnt (Code %s).",
["character.tab.skills"] = "Fertigkeiten",
["character.tab.reputations"] = "Ruf",
["character.tab.emblems"] = "Abzeichen",
["character.skills.count"] = "Fertigkeit(en)",
["character.skills.loading"] = "Wird geladen...",
["character.reputations.count"] = "Rufstufe(n)",
["character.reputations.loading"] = "Wird geladen...",
["character.reputations.empty"] = "Kein Ruf verfügbar.",
["character.emblems.count"] = "Abzeichen",
["character.emblems.loading"] = "Wird geladen...",
["character.emblems.empty"] = "Keine Abzeichen.",
["character.skills.category.class"] = "Klassenfertigkeiten",
["character.skills.category.profession"] = "Berufe",
["character.skills.category.secondary"] = "Sekundäre Berufe",
Expand Down
10 changes: 10 additions & 0 deletions Locales/MultiBotAceLocale-enGB.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,18 @@ local enGBValues = {
["profession.recipes.craft.reason.LOST_CONTROL"] = "The bot cannot act right now.",
["profession.recipes.craft.reason.CHANNELING"] = "The bot is already channeling a spell.",
["profession.recipes.craft.reason.cast_code"] = "The server refused the cast (code %s).",
["character.tab.skills"] = "Skills",
["character.tab.reputations"] = "Reputations",
["character.tab.emblems"] = "Emblems",
["character.skills.count"] = "skill(s)",
["character.skills.loading"] = "Loading...",
["character.reputations.count"] = "reputation(s)",
["character.reputations.loading"] = "Loading...",
["character.reputations.empty"] = "No reputations.",
["character.emblems.count"] = "emblem(s)",
["character.emblems.loading"] = "Loading...",
["character.emblems.empty"] = "No emblems.",
["character.skills.loading"] = "Loading...",
["character.skills.category.class"] = "Class Skills",
["character.skills.category.profession"] = "Professions",
["character.skills.category.secondary"] = "Secondary Professions",
Expand Down
9 changes: 9 additions & 0 deletions Locales/MultiBotAceLocale-enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,17 @@ local enUSValues = {
["profession.recipes.craft.reason.LOST_CONTROL"] = "The bot cannot act right now.",
["profession.recipes.craft.reason.CHANNELING"] = "The bot is already channeling a spell.",
["profession.recipes.craft.reason.cast_code"] = "The server refused the cast (code %s).",
["character.tab.skills"] = "Skills",
["character.tab.reputations"] = "Reputations",
["character.tab.emblems"] = "Emblems",
["character.skills.count"] = "skill(s)",
["character.skills.loading"] = "Loading...",
["character.reputations.count"] = "reputation(s)",
["character.reputations.loading"] = "Loading...",
["character.reputations.empty"] = "No reputations.",
["character.emblems.count"] = "emblem(s)",
["character.emblems.loading"] = "Loading...",
["character.emblems.empty"] = "No emblems.",
["character.skills.category.class"] = "Class Skills",
["character.skills.category.profession"] = "Professions",
["character.skills.category.secondary"] = "Secondary Professions",
Expand Down
9 changes: 9 additions & 0 deletions Locales/MultiBotAceLocale-esES.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,17 @@ local esESValues = {
["profession.recipes.craft.reason.LOST_CONTROL"] = "El bot no puede actuar ahora.",
["profession.recipes.craft.reason.CHANNELING"] = "El bot ya está canalizando un hechizo.",
["profession.recipes.craft.reason.cast_code"] = "El servidor rechazó el lanzamiento (código %s).",
["character.tab.skills"] = "Habilidades",
["character.tab.reputations"] = "Reputaciones",
["character.tab.emblems"] = "Emblemas",
["character.skills.count"] = "habilidad(es)",
["character.skills.loading"] = "Cargando...",
["character.reputations.count"] = "reputación(es)",
["character.reputations.loading"] = "Cargando...",
["character.reputations.empty"] = "Sin reputaciones.",
["character.emblems.count"] = "emblema(s)",
["character.emblems.loading"] = "Cargando...",
["character.emblems.empty"] = "Sin emblemas.",
["character.skills.category.class"] = "Habilidades de clase",
["character.skills.category.profession"] = "Profesiones",
["character.skills.category.secondary"] = "Profesiones secundarias",
Expand Down
9 changes: 9 additions & 0 deletions Locales/MultiBotAceLocale-frFR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,17 @@ local frFRValues = {
["profession.recipes.craft.reason.LOST_CONTROL"] = "Le bot ne peut pas agir maintenant.",
["profession.recipes.craft.reason.CHANNELING"] = "Le bot canalise déjà un sort.",
["profession.recipes.craft.reason.cast_code"] = "Le serveur a refusé le cast (code %s).",
["character.tab.skills"] = "Compétences",
["character.tab.reputations"] = "Réputations",
["character.tab.emblems"] = "Monaies",
["character.skills.count"] = "compétence(s)",
["character.skills.loading"] = "Chargement...",
["character.reputations.count"] = "réputation(s)",
["character.reputations.loading"] = "Chargement...",
["character.reputations.empty"] = "Aucune réputation.",
["character.emblems.count"] = "emblème(s)",
["character.emblems.loading"] = "Chargement...",
["character.emblems.empty"] = "Aucun emblème.",
["character.skills.category.class"] = "Compétences de classe",
["character.skills.category.profession"] = "Métiers",
["character.skills.category.secondary"] = "Métiers secondaires",
Expand Down
9 changes: 9 additions & 0 deletions Locales/MultiBotAceLocale-koKR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,17 @@ local koKRValues = {
["profession.recipes.craft.reason.LOST_CONTROL"] = "봇이 지금 행동할 수 없습니다.",
["profession.recipes.craft.reason.CHANNELING"] = "봇이 이미 주문을 시전 중입니다.",
["profession.recipes.craft.reason.cast_code"] = "서버가 시전을 거부했습니다(코드 %s).",
["character.tab.skills"] = "기술",
["character.tab.reputations"] = "평판",
["character.tab.emblems"] = "엠블렘",
["character.skills.count"] = "기술",
["character.skills.loading"] = "불러오는 중...",
["character.reputations.count"] = "평판",
["character.reputations.loading"] = "불러오는 중...",
["character.reputations.empty"] = "평판이 없습니다.",
["character.emblems.count"] = "엠블렘",
["character.emblems.loading"] = "불러오는 중...",
["character.emblems.empty"] = "엠블렘이 없습니다.",
["character.skills.category.class"] = "직업 기술",
["character.skills.category.profession"] = "전문 기술",
["character.skills.category.secondary"] = "보조 기술",
Expand Down
Loading
Loading