Retry native party invitations and remove verified dead memberships
Core tests / core (push) Successful in 1m0s
Core tests / core (push) Successful in 1m0s
This commit is contained in:
+3
-1
@@ -66,7 +66,9 @@ end
|
||||
local __ok,__result=pcall(function()
|
||||
${source}
|
||||
end)
|
||||
AzerothAIComplete(__command_id,__ok,__stringify(__result))
|
||||
if not (__ok and type(__result)=="table" and __result.azerothaiDeferred==true) then
|
||||
AzerothAIComplete(__command_id,__ok,__stringify(__result))
|
||||
end
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
+7
-3
@@ -60,14 +60,18 @@ export function partyDecision(a:Bot,b:Bot){
|
||||
return {accepted:willing(a,b)&&willing(b,a),reason:willing(a,b)&&willing(b,a)?danger?'Seeking safety together after recent danger; compatible faction, levels, and non-hostile companions.':'Both accepted: compatible levels, shared adventure interests, and no hostile bond.':'One character prefers to adventure alone or does not trust the other.'};
|
||||
}
|
||||
export function compileCommunityAction(kind:'party'|'leave'|'recruit',a:Bot,b?:Bot){
|
||||
if(kind==='party'){
|
||||
if(!b||!a.autonomy?.accountId||!b.autonomy?.accountId)throw new Error('Verified native accounts required');
|
||||
const identity=(p:Bot)=>`{name=${luaString(p.name)},guid=${p.autonomy!.characterGuid},account=${p.autonomy!.accountId}}`;
|
||||
return `if not AzerothAIQueueParty then error("Native invitation guard unavailable") end; return AzerothAIQueueParty(__command_id,${identity(a)},${identity(b)},${Math.floor(Date.now()/1000)+45})`;
|
||||
}
|
||||
const lines=[`local a=GetPlayerByName(${luaString(a.name)})`,`if not a or a:GetGUIDLow()~=${a.autonomy!.characterGuid} or not a:IsPlayerbot() or a:IsDead() or a:IsInCombat() or a:IsTaxi() or a:IsCasting() or a:GetBotAI():HasGameClientMaster() then error('Resident unavailable') end`];
|
||||
if(kind==='leave'){
|
||||
lines.push(`local g=a:GetGroup();if not g then return 'Already solo' end`,`if tostring(g:GetGUID())~=${luaString(a.world!.groupId)} then error('Party changed') end`,`if #g:GetMembers()~=g:GetMembersCount() then error('Party has offline members') end;for _,m in pairs(g:GetMembers()) do if not m:IsPlayerbot() or m:GetBotAI():HasGameClientMaster() then error('Human party is protected') end end`,`a:RemoveFromGroup()`,`if a:GetGroup() then error('Departure was not applied') end`);
|
||||
}else{
|
||||
if(!b)throw new Error('Peer required');
|
||||
lines.push(`local b=GetPlayerByName(${luaString(b.name)})`,`if not b or b:GetGUIDLow()~=${b.autonomy!.characterGuid} or not b:IsPlayerbot() or b:IsDead() or b:IsInCombat() or b:IsTaxi() or b:IsCasting() or b:GetBotAI():HasGameClientMaster() or a:GetTeam()~=b:GetTeam() or a:GetMapId()~=b:GetMapId() or a:GetPhaseMask()~=b:GetPhaseMask() or a:GetDistance(b)>35 then error('Peer unavailable nearby') end`);
|
||||
if(kind==='party')lines.push(`if math.abs(a:GetLevel()-b:GetLevel())>10 then error('Level mismatch') end`,`local g=a:GetGroup();if g and b:GetGroup()==g then return 'Already grouped' end`,`if b:GetGroup() then error('Peer already grouped') end`,`if g then if g:IsRaidGroup() or g:GetMembersCount()>=5 then error('Party full') end;if #g:GetMembers()~=g:GetMembersCount() then error('Party has offline members') end;for _,m in pairs(g:GetMembers()) do if not m:IsPlayerbot() or m:GetBotAI():HasGameClientMaster() then error('Human party is protected') end end;if not g:AddMember(b) then error('Party join failed') end else g=a:GroupCreate(b) end`,`if not g or b:GetGroup()~=g then error('Party membership was not applied') end`);
|
||||
else lines.push(`local g=a:GetGuild();if not g or a:GetGuildId()~=${a.world!.guildId} or a:GetGuildRank()~=0 then error('Guild leader unavailable') end`,`if b:GetGuildId()==a:GetGuildId() then return 'Already a member' end`,`if b:GetGuildId()~=0 then error('Already belongs to a guild') end`,`g:AddMember(b)`,`if b:GetGuildId()~=a:GetGuildId() then error('Guild admission failed') end`);
|
||||
lines.push(`local g=a:GetGuild();if not g or a:GetGuildId()~=${a.world!.guildId} or a:GetGuildRank()~=0 then error('Guild leader unavailable') end`,`if b:GetGuildId()==a:GetGuildId() then return 'Already a member' end`,`if b:GetGuildId()~=0 then error('Already belongs to a guild') end`,`g:AddMember(b)`,`if b:GetGuildId()~=a:GetGuildId() then error('Guild admission failed') end`);
|
||||
}
|
||||
lines.push('AzerothAIEmitSnapshots()','return "Confirmed '+kind+'"');return lines.join('; ');
|
||||
}
|
||||
@@ -97,7 +101,7 @@ export async function communityTick(store:StateStore,db:D1Database){
|
||||
await db.prepare("DELETE FROM community_actions WHERE status!='pending' AND created_at<?").bind(new Date(now-7*86400_000).toISOString()).run();
|
||||
const s=await store.load(),c=community(s),bots=s.bots.filter(b=>fresh(b)).sort((a,b)=>Number(recentDanger(b))-Number(recentDanger(a)));
|
||||
const recent=await db.prepare('SELECT a,b,created_at,status FROM community_actions WHERE created_at>?').bind(new Date(now-10*60_000).toISOString()).all<any>();
|
||||
const busy=new Set(recent.results.filter(r=>r.status==='pending'||now-Date.parse(r.created_at)<(r.status==='completed'?120_000:60_000)).flatMap(r=>[r.a,r.b]));
|
||||
const busy=new Set([...pending.results.flatMap(r=>[r.a,r.b]),...recent.results.filter(r=>r.status==='pending'||now-Date.parse(r.created_at)<(r.status==='completed'?120_000:60_000)).flatMap(r=>[r.a,r.b])]);
|
||||
for(const a of bots){
|
||||
if(busy.has(a.id))continue;
|
||||
// Leave only a bot-only party whose peers have moved away, never a human party.
|
||||
|
||||
Reference in New Issue
Block a user