Batch authoritative snapshots and bound rejected retreat fallback

This commit is contained in:
Codex
2026-09-25 09:24:51 +08:00
parent d573ae2345
commit 9d1575b8c6
6 changed files with 81 additions and 5 deletions
+18 -1
View File
@@ -102,7 +102,13 @@ local function sample()
local now=os.time();refresh(now);restoreExpiredHolds(now)
for _,p in pairs(GetPlayersInWorld() or {}) do
local previous=observed[p:GetGUIDLow()]
if previous then outcome(p,previous,now) end
if previous then
if previous.nativeFleeUntil and now>=previous.nativeFleeUntil then
if p:GetMovementType()==9 or p:GetMovementType()==13 then p:MoveExpire() end
previous.nativeFleeUntil=nil
end
outcome(p,previous,now)
end
if managed(p) then
local id=p:GetGUIDLow();local ai=p:GetBotAI();local r=observed[id] or {};observed[id]=r
local previousAction,previousAt=r.action,r.actionAt or 0
@@ -174,6 +180,17 @@ local function sample()
r.dangerAt=now;r.retreatAt=now;r.action='retreat requested';r.actionAt=now
if p:IsCasting() then p:StopSpellCast() end
r.accepted=ai:DoSpecificAction('flee',true)
-- The bot action may reject fleeing when its target/context is missing.
-- Bound a native pathfinding attempt; never teleport or clear combat/threat.
if not r.accepted and not p:IsMoving() and now-(r.nativeFleeAt or 0)>=30 then
local threat=enemy
if not threat then for _,attacker in pairs(p:GetAttackers()) do threat=attacker;break end end
if threat then
p:AttackStop();p:MoveFleeing(threat,8000)
r.nativeFleeAt=now;r.nativeFleeUntil=now+8
audit(p,'retreat-path-request','Playerbot flee rejected; bounded native flee path requested')
end
end
audit(p,'retreat-request', 'accepted='..tostring(r.accepted)..'; hp='..math.floor(hp)..'; dangerous='..tostring(overmatched)..'; attackers='..attackers..'; nearbySupport='..support)
if not r.retreat then r.retreat={at=now,map=p:GetMapId(),x=p:GetX(),y=p:GetY()} end
elseif avoid and now-(r.avoidAt or 0)>=8 then