Ground bot intentions in live game knowledge and verify outcomes
Core tests / core (push) Successful in 28s
Core tests / core (push) Successful in 28s
This commit is contained in:
@@ -142,6 +142,37 @@ local function nearby_bot_names(player)
|
||||
return table.concat(names,",")
|
||||
end
|
||||
|
||||
-- Read only server knowledge; cache static quest text and bound prompt size.
|
||||
local questKnowledge={}
|
||||
local function decision_knowledge(player,p)
|
||||
p.xp=player:GetXP()
|
||||
local quests={}
|
||||
for _,id in ipairs(p.quests) do
|
||||
if #quests>=8 then break end
|
||||
local q=questKnowledge[id]
|
||||
if not q then
|
||||
local row=WorldDBQuery('SELECT LogTitle,QuestLevel FROM quest_template WHERE ID='..id)
|
||||
q=row and {title=string.sub(row:GetString(0) or '',1,100),level=row:GetInt32(1)} or {title='Quest '..id,level=0}
|
||||
questKnowledge[id]=q
|
||||
end
|
||||
local ok,status=pcall(function() return player:GetQuestStatus(id) end)
|
||||
local label=ok and (status==1 and 'ready to turn in' or status==3 and 'in progress' or status==5 and 'failed' or 'status '..tostring(status)) or 'status unavailable'
|
||||
quests[#quests+1]=id..': '..q.title..' (level '..q.level..', '..label..')'
|
||||
end
|
||||
p.questBrief=table.concat(quests,'; ')
|
||||
local threats={}
|
||||
for _,enemy in pairs(player:GetUnfriendlyUnitsInRange(35) or {}) do
|
||||
if not enemy:IsDead() then threats[#threats+1]=enemy end
|
||||
end
|
||||
table.sort(threats,function(a,b)return player:GetDistance(a)<player:GetDistance(b) end)
|
||||
local descriptions={}
|
||||
for i=1,math.min(4,#threats) do
|
||||
local e=threats[i];local c=e:ToCreature()
|
||||
descriptions[#descriptions+1]=string.sub(e:GetName(),1,70)..' level '..e:GetLevel()..' at '..math.floor(player:GetDistance(e))..' yards'..(c and c:GetRank()>0 and ' (non-normal rank)' or '')
|
||||
end
|
||||
p.threatBrief=table.concat(descriptions,'; ')
|
||||
end
|
||||
|
||||
local function world_payload(player)
|
||||
local p=player_payload(player)
|
||||
local ai=player:IsPlayerbot() and player:GetBotAI() or nil
|
||||
@@ -162,6 +193,8 @@ local function world_payload(player)
|
||||
if AzerothAIExperienceSnapshot then for k,v in pairs(AzerothAIExperienceSnapshot(player)) do p[k]=v end end
|
||||
if AzerothAITrainingSnapshot then for k,v in pairs(AzerothAITrainingSnapshot(player)) do p[k]=v end end
|
||||
if AzerothAIReadinessSnapshot then for k,v in pairs(AzerothAIReadinessSnapshot(player)) do p[k]=v end end
|
||||
local ok,err=pcall(decision_knowledge,player,p)
|
||||
if not ok then p.questBrief=nil;p.threatBrief=nil end
|
||||
p.nearbyBots=nearby_bot_names(player)
|
||||
return p
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user