Add social feed, cooperative parties, guild goals, and operations recovery
This commit is contained in:
@@ -112,6 +112,9 @@ local function player_payload(player)
|
||||
raceName=player:GetRaceAsString() or tostring(player:GetRace()),
|
||||
className=player:GetClassAsString() or tostring(player:GetClass()),
|
||||
healthPct=player:GetHealthPct(),
|
||||
observedAt=os.time(),team=player:GetTeam(),x=player:GetX(),y=player:GetY(),
|
||||
guildId=player:GetGuildId(),guildName=player:GetGuildName() or "",guildRank=player:GetGuildRank(),
|
||||
inCombat=player:IsInCombat(),
|
||||
isBot=isBot
|
||||
}
|
||||
end
|
||||
@@ -138,11 +141,22 @@ local function nearby_bot_names(player)
|
||||
return table.concat(names,",")
|
||||
end
|
||||
|
||||
local function world_payload(player)
|
||||
local p=player_payload(player)
|
||||
local g=player:GetGroup()
|
||||
p.groupId=g and tostring(g:GetGUID()) or ""
|
||||
local members={}
|
||||
if g then for _,m in pairs(g:GetMembers()) do members[#members+1]=m:GetName() end end
|
||||
p.groupNames=table.concat(members,",")
|
||||
p.nearbyBots=nearby_bot_names(player)
|
||||
return p
|
||||
end
|
||||
|
||||
function AzerothAIEmitPlayerSnapshot(name)
|
||||
if not name or name == "" then return 0 end
|
||||
local ok,player=pcall(function() return GetPlayerByName(name) end)
|
||||
if not ok or not player or not is_playerbot(player) then return 0 end
|
||||
emit("player.snapshot",player_payload(player))
|
||||
emit("player.snapshot",world_payload(player))
|
||||
return 1
|
||||
end
|
||||
|
||||
@@ -219,7 +233,7 @@ function AzerothAIEmitSnapshots()
|
||||
end
|
||||
emit("player.snapshot",roster)
|
||||
for _,player in pairs(players) do
|
||||
if is_playerbot(player) then emit("player.snapshot",player_payload(player)) end
|
||||
if is_playerbot(player) then emit("player.snapshot",world_payload(player)) end
|
||||
end
|
||||
return emitted
|
||||
end
|
||||
@@ -382,3 +396,40 @@ end
|
||||
|
||||
emit("bridge.ready",{pollMs=POLL_MS,protectedCharacter=PROTECTED})
|
||||
PrintInfo("[AzerothAI] ALE bridge loaded; durable DB command polling every " .. tostring(POLL_MS) .. " ms")
|
||||
|
||||
local completedQuests={}
|
||||
local helpedAt={}
|
||||
local function cooperative_event(a,b,kind,key,quest)
|
||||
emit("player.snapshot",{cooperation=kind,evidenceId=key,characterGuid=a:GetGUIDLow(),peerGuid=b:GetGUIDLow(),observedAt=os.time(),questId=quest or 0})
|
||||
end
|
||||
RegisterPlayerEvent(54,function(event,player,quest)
|
||||
if not is_playerbot(player) then return end
|
||||
local q=quest:GetId()
|
||||
completedQuests[player:GetGUIDLow()..":"..q]=os.time()
|
||||
local g=player:GetGroup();if not g then return end
|
||||
for _,other in pairs(g:GetMembers()) do
|
||||
if other~=player and is_playerbot(other) and player:GetDistance(other)<=35 then
|
||||
local stamp=completedQuests[other:GetGUIDLow()..":"..q]
|
||||
if stamp and os.time()-stamp<300 then
|
||||
local a,b=player:GetGUIDLow(),other:GetGUIDLow()
|
||||
cooperative_event(player,other,"quest","quest:"..math.min(a,b)..":"..math.max(a,b)..":"..q..":"..math.floor(os.time()/86400),q)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
RegisterPlayerEvent(7,function(event,player,killed)
|
||||
if not is_playerbot(player) then return end
|
||||
local g=player:GetGroup();if not g then return end
|
||||
for _,other in pairs(g:GetMembers()) do
|
||||
if other~=player and is_playerbot(other) and not other:IsDead() and other:IsInCombat() and other:GetVictim() and other:GetVictim():GetGUID()==killed:GetGUID() and player:GetDistance(other)<=35 then
|
||||
local a,b=player:GetGUIDLow(),other:GetGUIDLow();local key=math.min(a,b)..":"..math.max(a,b)
|
||||
if os.time()-(helpedAt[key] or 0)>300 then
|
||||
helpedAt[key]=os.time();cooperative_event(player,other,"assist","assist:"..key..":"..os.time())
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
CreateLuaEvent(function()
|
||||
for k,t in pairs(completedQuests) do if os.time()-t>300 then completedQuests[k]=nil end end
|
||||
for k,t in pairs(helpedAt) do if os.time()-t>600 then helpedAt[k]=nil end end
|
||||
end,60000,0)
|
||||
|
||||
Reference in New Issue
Block a user