Improve free-flight recovery and fallback handling

This commit is contained in:
Nico committed 2026-11-01 01:20:33 +01:00
1 parent 7b4994400b
commit 856832e7bd
7 files changed
+109 -7

No files matched your search

+41 -3
View File
@@ -202,8 +202,13 @@ Surface ClientlessFlightMgr::Sample(Player * player, Record & record, float x, f
};
}
bool ClientlessFlightMgr::Start(Player* player,Position const& target,std::string& error)
{return Begin(player,target,error,false);}
bool ClientlessFlightMgr::Start(Player* player,Position const& target,std::string& error,bool actionOwned)
{
bool started=Begin(player,target,error,false);
if(started)
if(auto found=_records.find(player->GetGUID().GetCounter());found!=_records.end())found->second.ActionOwned=actionOwned;
return started;
}
bool ClientlessFlightMgr::PrepareFollowingMount(Player* player)
{
if(!Enabled(player) || !player->IsAlive() || player->IsInCombat() || player->IsBeingTeleported() ||
@@ -647,6 +652,18 @@ bool ClientlessFlightMgr::Advance(Player * player, Record & record, bool handoff
}
if (! next.Valid ||(! record.Returning && record.Status.Travelled > Distance(PointOf(record.Start), goal) * 2 + 500))
{
// A detached/pathological flight gets one fresh airborne plan. If the
// new corridor is still impossible, finish with a checked local
// touchdown so the ordinary behavior controller can plan from ground.
if(!record.Returning && record.DetachedRecoveryCount && FindReturnLanding(player,record))
{
record.Returning=true;
record.AbortReason="airborne recovery could not reach the original target";
record.Breadcrumbs.clear();
record.Memory={};record.Memory.Departed=true;
record.Status.Detail="airborne recovery landing";
return Advance(player,record);
}
Fail(player, record, "no safe bounded flight corridor; holding position mounted");
return false;
}
@@ -672,7 +689,11 @@ bool ClientlessFlightMgr::Advance(Player * player, Record & record, bool handoff
++ record.Status.Segments;
record.Status.Avoidances += next.Avoiding ? 1 : 0;
if (handoff) ++record.Status.Handoffs;
record.Status.Detail = next.Avoiding ? "obstacle avoidance" : next.Landing ? "landing approach" : next.Next.Z < current.Z - 0.25f ? "diagonal descent" : next.Next.Z > current.Z + 0.25f ? "diagonal climb" : "terrain-smoothed cruise";
bool const vertical=Horizontal(current,next.Next)<1.0f && std::fabs(next.Next.Z-current.Z)>1.0f;
record.Status.Detail = next.Avoiding ? "obstacle avoidance" : next.Landing && vertical ? "vertical landing fallback" :
next.Landing ? "landing approach" : vertical && next.Next.Z>current.Z ? "vertical takeoff fallback" :
vertical ? "vertical descent fallback" : next.Next.Z < current.Z - 0.25f ? "diagonal descent" :
next.Next.Z > current.Z + 0.25f ? "diagonal climb" : "terrain-smoothed cruise";
TC_LOG_INFO("server.adventurebot.navigation", "FLIGHT_SEGMENT guid=%u n=%u avoid=%u handoff=%u target=(%.2f %.2f %.2f) detail='%s'", player->GetGUID().GetCounter(), record.Status.Segments, next.Avoiding ? 1 : 0, handoff ? 1 : 0, next.Next.X, next.Next.Y, next.Next.Z, record.Status.Detail.c_str());
return true;
}
@@ -724,6 +745,23 @@ void ClientlessFlightMgr::Update(uint32 diff)
Fail(player, record, "flight permission lost or total timeout");
continue;
}
bool const ownerLost=record.ActionOwned && !sClientlessActionExecutorMgr->OwnsActiveFlight(guid);
bool const pathological=record.Status.Segments>=12 && record.Status.Avoidances*2>=record.Status.Segments;
if(!record.Returning && !record.Following && record.DetachedRecoveryCount==0 && (ownerLost || pathological))
{
++record.DetachedRecoveryCount;
if(ownerLost)record.ActionOwned=false;
player->StopMoving();record.Moving=false;record.SegmentElapsed=0;
record.Start.Relocate(player);record.LastPosition.Relocate(player);
record.Memory={};record.Breadcrumbs.clear();
record.Published=std::make_shared<ClientlessFlightPath::SharedTrail>();
record.Status.Detail=ownerLost?"replanning detached free flight":"replanning excessive obstacle avoidance";
ClientlessTravelTelemetry::Note(player,"flight-airborne-replan",record.Status.Detail);
TC_LOG_WARN("server.adventurebot.navigation","FLIGHT_AIRBORNE_REPLAN guid=%u ownerLost=%u segments=%u avoidances=%u target=(%.2f %.2f %.2f)",
guid,ownerLost?1:0,record.Status.Segments,record.Status.Avoidances,record.Status.Landing.GetPositionX(),record.Status.Landing.GetPositionY(),record.Status.Landing.GetPositionZ());
Advance(player,record);
continue;
}
if (record.CheckTimer > diff)
{
record.CheckTimer -= diff;