Use verified pathfinding retreat when bot flee is rejected
Core tests / core (push) Successful in 42s

This commit is contained in:
Codex
2026-09-25 09:25:33 +08:00
parent 9d1575b8c6
commit 20ccd0fced
2 changed files with 14 additions and 15 deletions
+10 -11
View File
@@ -102,13 +102,7 @@ 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
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 previous then 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
@@ -182,13 +176,18 @@ local function sample()
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
if not r.accepted and not p:IsMoving() and now-(r.nativeFleeAt or 0)>=15 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')
local dx,dy=p:GetX()-threat:GetX(),p:GetY()-threat:GetY()
local distance=math.sqrt(dx*dx+dy*dy)
if distance>0.1 then
p:AttackStop()
p:MoveTo(7822,p:GetX()+20*dx/distance,p:GetY()+20*dy/distance,p:GetZ(),true)
r.nativeFleeAt=now
audit(p,'retreat-path-request','Playerbot flee rejected; 20-yard path away from attacker requested')
end
end
end
audit(p,'retreat-request', 'accepted='..tostring(r.accepted)..'; hp='..math.floor(hp)..'; dangerous='..tostring(overmatched)..'; attackers='..attackers..'; nearbySupport='..support)