Fix AdventureBot group preparation, public portals and flight recovery
Add preparation outings and equipment checks with a five-minute return to the meeting point. Correct static portal visitor casting and level conditions, with native interaction diagnostics. Recover suspended flying mounts, walk to verified takeoff sites, and validate landing and return volumes. Include SQL migrations, targeted regression tests and live validation checkpoints.
This commit is contained in:
1 parent
2841ee973b
commit
54d77d1e4d
60 files changed
+1607
-33
No files matched your search
@@ -53,6 +53,15 @@ namespace
|
||||
float x, y, z;
|
||||
return map->isInLineOfSight(player->GetPhaseShift(), a.X, a.Y, a.Z, b.X, b.Y, b.Z, LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags(0)) && ! map->getObjectHitPos(player->GetPhaseShift(), a.X, a.Y, a.Z, b.X, b.Y, b.Z, x, y, z, 0);
|
||||
}
|
||||
bool OpenColumn(Player* player,float x,float y,Surface const& surface,float height=15)
|
||||
{
|
||||
if(!surface.Valid)return false;
|
||||
float top=std::min(surface.Ceiling-5,surface.Ground+height);
|
||||
if(top<surface.Ground+5.8f)return false;
|
||||
for(auto offset:std::array<Point,5>{{{0,0,0},{2,0,0},{-2,0,0},{0,2,0},{0,-2,0}}})
|
||||
if(!ClearRay(player,{x+offset.X,y+offset.Y,surface.Ground+0.8f},{x+offset.X,y+offset.Y,top}))return false;
|
||||
return true;
|
||||
}
|
||||
char const * StateName(ClientlessFlightState state)
|
||||
{
|
||||
switch (state)
|
||||
@@ -158,6 +167,7 @@ ClientlessFlightStatus const * ClientlessFlightMgr::GetStatus(uint32 guid) const
|
||||
void ClientlessFlightMgr::Clear(uint32 guid)
|
||||
{
|
||||
auto it=_records.find(guid);
|
||||
if(it!=_records.end() && it->second.ApproachingDeparture)sClientlessTravelMgr->CancelTravel(guid);
|
||||
if(it!=_records.end() && it->second.Status.State!=ClientlessFlightState::Arrived)it->second.Published->Aborted=true;
|
||||
_records.erase(guid);
|
||||
}
|
||||
@@ -305,15 +315,26 @@ bool ClientlessFlightMgr::Begin(Player * player, Position const & target, std::s
|
||||
roll -= candidate.second;
|
||||
}
|
||||
Record record;
|
||||
auto previous=_records.find(player->GetGUID().GetCounter());
|
||||
if(previous!=_records.end() && previous->second.ApproachingDeparture)
|
||||
record.Published=previous->second.Published;
|
||||
record.Status.MapId = player->GetMapId();
|
||||
record.Status.Target = target;
|
||||
record.Start.Relocate(player);
|
||||
record.LastPosition.Relocate(player);
|
||||
record.Settings.Clearance = std::clamp(sConfigMgr->GetFloatDefault("Clientless.Flight.Clearance", 60), 20.0f, 200.0f);
|
||||
auto origin = Sample(player, record, player->GetPositionX(), player->GetPositionY());
|
||||
if (! origin.Valid || std::fabs(origin.Ground - player->GetPositionZ()) > 3)
|
||||
uint32 existingMount=0;
|
||||
if(player->IsMounted() && player->CanFly())
|
||||
for(auto const& candidate:candidates)if(player->HasAura(candidate.first)){existingMount=candidate.first;break;}
|
||||
bool const airborne=existingMount && origin.Valid && player->GetPositionZ()>=origin.Ground+0.7f &&
|
||||
player->GetPositionZ()+5<=origin.Ceiling && ClearRay(player,PointOf(*player),{player->GetPositionX(),player->GetPositionY(),player->GetPositionZ()+5});
|
||||
float const feet=player->GetMap()->GetHeight(player->GetPhaseShift(),player->GetPositionX(),player->GetPositionY(),player->GetPositionZ()+2,true,6);
|
||||
if (!origin.Valid || (!airborne && (std::fabs(origin.Ground-player->GetPositionZ())>3 || std::fabs(feet-player->GetPositionZ())>3)))
|
||||
{
|
||||
error = "unknown flight bounds or no safe ground departure";
|
||||
if(origin.Valid && std::isfinite(feet) && feet>INVALID_HEIGHT+1 && std::fabs(feet-player->GetPositionZ())<=3 && ApproachDeparture(player,record,following))return true;
|
||||
error = "departure-unavailable: no supported open takeoff point";
|
||||
TC_LOG_WARN("server.adventurebot.navigation","FLIGHT_DEPARTURE_REJECT guid=%u z=%.3f surface=%.3f feet=%.3f valid=%u mounted=%u canFly=%u",player->GetGUID().GetCounter(),player->GetPositionZ(),origin.Ground,feet,origin.Valid?1:0,player->IsMounted()?1:0,player->CanFly()?1:0);
|
||||
return false;
|
||||
}
|
||||
bool foundLanding = false;
|
||||
@@ -338,12 +359,7 @@ bool ClientlessFlightMgr::Begin(Player * player, Position const & target, std::s
|
||||
float solid = player->GetMap()->GetHeight(player->GetPhaseShift(), x, y, MAX_HEIGHT, true, MAX_HEIGHT);
|
||||
if (landing.Ground > solid + 0.7f) continue;
|
||||
// water is no solid touchdown
|
||||
Point bottom
|
||||
{
|
||||
x, y, landing.Ground + 1
|
||||
}, top = bottom;
|
||||
top.Z += record.Settings.Clearance;
|
||||
if (! ClearRay(player, bottom, top)) continue;
|
||||
if(!OpenColumn(player,x,y,landing,record.Settings.Clearance))continue;
|
||||
Position candidate;
|
||||
candidate.Relocate(x, y, landing.Ground, target.GetOrientation());
|
||||
if (radius > 0 || std::fabs(landing.Ground - target.GetPositionZ()) > 0.7f)
|
||||
@@ -364,8 +380,11 @@ bool ClientlessFlightMgr::Begin(Player * player, Position const & target, std::s
|
||||
}
|
||||
sClientlessTravelMgr->CancelTravel(player->GetGUID().GetCounter());
|
||||
player->StopMoving();
|
||||
sClientlessLuaEngine->DismountGroundMount(player, "free-flight-takeoff");
|
||||
player->RemoveAurasByType(SPELL_AURA_MOUNTED);
|
||||
if(!airborne)
|
||||
{
|
||||
sClientlessLuaEngine->DismountGroundMount(player, "free-flight-takeoff");
|
||||
player->RemoveAurasByType(SPELL_AURA_MOUNTED);
|
||||
}
|
||||
record.Status.State = ClientlessFlightState::Mounting;
|
||||
record.Status.MountSpell = spell;
|
||||
record.Status.Detail = "waiting for native flying mount";
|
||||
@@ -382,6 +401,17 @@ bool ClientlessFlightMgr::Begin(Player * player, Position const & target, std::s
|
||||
TC_LOG_INFO("server.adventurebot.navigation","FLIGHT_SHARED_TRAIL guid=%u leader=%u",player->GetGUID().GetCounter(),group->GetLeaderGUID().GetCounter());
|
||||
}
|
||||
}
|
||||
if(airborne)
|
||||
{
|
||||
// A resumed hover is not a supported return/landing point. Use the
|
||||
// verified ground below it only when the full descent column is clear.
|
||||
FindReturnLanding(player,record);
|
||||
record.Status.MountSpell=existingMount;record.Status.State=ClientlessFlightState::Flying;
|
||||
record.Memory.Departed=player->GetPositionZ()-origin.Ground>record.Settings.Safety;
|
||||
player->AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
|
||||
TC_LOG_INFO("server.adventurebot.navigation","FLIGHT_RESUME_AIRBORNE guid=%u ground=%.3f z=%.3f",player->GetGUID().GetCounter(),origin.Ground,player->GetPositionZ());
|
||||
_records[player->GetGUID().GetCounter()]=std::move(record);return true;
|
||||
}
|
||||
_records[player->GetGUID().GetCounter()] = std::move(record);
|
||||
if (player->CastSpell(player, spell, false) != SPELL_CAST_OK)
|
||||
{
|
||||
@@ -393,8 +423,61 @@ bool ClientlessFlightMgr::Begin(Player * player, Position const & target, std::s
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ClientlessFlightMgr::FindReturnLanding(Player* player,Record& record)
|
||||
{
|
||||
auto sample=[&](float x,float y){return Sample(player,record,x,y);};
|
||||
auto ray=[&](Point const& a,Point const& b){return ClearRay(player,a,b);};
|
||||
Point current=PointOf(*player);
|
||||
for(float radius:{0.0f,8.0f,16.0f,24.0f,40.0f})for(unsigned i=0;i<(radius==0?1u:8u);++i)
|
||||
{
|
||||
float angle=float(i)*0.785398163f;
|
||||
float x=current.X+radius*std::cos(angle),y=current.Y+radius*std::sin(angle);
|
||||
auto surface=sample(x,y);Point goal{x,y,surface.Ground};
|
||||
if(!surface.Valid || Distance(current,goal)>80 || !OpenColumn(player,x,y,surface))continue;
|
||||
Position candidate;candidate.Relocate(x,y,surface.Ground,player->GetOrientation());
|
||||
if(!sAdventureAreaMgr->AllowsSegment(player,player->GetMapId(),*player,candidate) ||
|
||||
!Corridor(current,goal,goal,record.Settings,sample,ray,false))continue;
|
||||
record.Start=candidate;
|
||||
TC_LOG_INFO("server.adventurebot.navigation","FLIGHT_RETURN_LANDING guid=%u target=(%.3f %.3f %.3f)",player->GetGUID().GetCounter(),x,y,surface.Ground);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ClientlessFlightMgr::ApproachDeparture(Player* player, Record& record, bool following)
|
||||
{
|
||||
// Only called after a real support surface was confirmed at the feet.
|
||||
// Walk out from under the upper floor; never raise the player through it.
|
||||
float heading=std::atan2(record.Status.Target.GetPositionY()-player->GetPositionY(),record.Status.Target.GetPositionX()-player->GetPositionX());
|
||||
for(float radius:{8.0f,16.0f,24.0f,40.0f})for(float turn:{0.0f,0.785398f,-0.785398f,1.570796f,-1.570796f,2.356194f,-2.356194f,3.141593f})
|
||||
{
|
||||
float x=player->GetPositionX()+radius*std::cos(heading+turn),y=player->GetPositionY()+radius*std::sin(heading+turn);
|
||||
auto surface=Sample(player,record,x,y);
|
||||
if(!surface.Valid)continue;
|
||||
Position point;point.Relocate(x,y,surface.Ground,player->GetOrientation());
|
||||
if(!sAdventureAreaMgr->AllowsSegment(player,player->GetMapId(),*player,point))continue;
|
||||
if(!OpenColumn(player,x,y,surface))continue;
|
||||
ClientlessPathDiagnostics path;
|
||||
if(!sClientlessTravelMgr->AnalyzePath(player,point,path) || !path.Calculated || !path.Complete || path.Suspicious ||
|
||||
path.FinalDistance>1.5f || path.PathLength>80 || path.MaxSegmentLength>8 || path.MaxZDelta>4)continue;
|
||||
if(!sClientlessTravelMgr->StartTravel(player,point,false))continue;
|
||||
record.ApproachingDeparture=true;record.Departure=point;
|
||||
record.Status.State=ClientlessFlightState::Mounting;record.Status.FollowingPlayer=following;
|
||||
record.Status.Detail="walking to an open takeoff point";
|
||||
TC_LOG_INFO("server.adventurebot.navigation","FLIGHT_DEPARTURE_WALK guid=%u destination=(%.3f %.3f %.3f) path=%.2f",player->GetGUID().GetCounter(),x,y,surface.Ground,path.PathLength);
|
||||
_records[player->GetGUID().GetCounter()]=std::move(record);return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClientlessFlightMgr::Fail(Player * player, Record & record, std::string const & reason)
|
||||
{
|
||||
if(record.ApproachingDeparture)
|
||||
{
|
||||
sClientlessTravelMgr->CancelTravel(player->GetGUID().GetCounter());record.ApproachingDeparture=false;
|
||||
// No mount cast has started while walking; do not interrupt a combat spell.
|
||||
record.Status.State=ClientlessFlightState::Failed;
|
||||
}
|
||||
record.Published->Aborted=true;
|
||||
record.Status.FollowingPlayer=false;
|
||||
player->StopMoving();
|
||||
@@ -429,7 +512,9 @@ bool ClientlessFlightMgr::Advance(Player * player, Record & record, bool handoff
|
||||
if (Horizontal(current, goal) < 1.5f && std::fabs(current.Z - goal.Z) < 0.7f)
|
||||
{
|
||||
auto floor = sample(current.X, current.Y);
|
||||
if (! floor.Valid || std::fabs(current.Z - floor.Ground) > 0.7f)
|
||||
float feet=player->GetMap()->GetHeight(player->GetPhaseShift(),current.X,current.Y,current.Z+2,true,6);
|
||||
if (!floor.Valid || !std::isfinite(feet) || feet<=INVALID_HEIGHT+1 || std::fabs(current.Z-feet)>0.7f ||
|
||||
!ClearRay(player,{current.X,current.Y,current.Z+0.8f},{current.X,current.Y,current.Z+4.5f}))
|
||||
{
|
||||
Fail(player, record, "touchdown ground not confirmed");
|
||||
return false;
|
||||
@@ -518,6 +603,20 @@ void ClientlessFlightMgr::Update(uint32 diff)
|
||||
Fail(player, record, "flight player/map state changed");
|
||||
continue;
|
||||
}
|
||||
if(record.ApproachingDeparture)
|
||||
{
|
||||
auto travel=sClientlessTravelMgr->GetStatus(guid);
|
||||
if(player->IsInCombat() || record.Elapsed>120000 || !travel ||
|
||||
(travel->State!=ClientlessTravelState::Moving && travel->State!=ClientlessTravelState::Arrived))
|
||||
{Fail(player,record,"departure-unavailable: ground approach interrupted");continue;}
|
||||
if(travel->State==ClientlessTravelState::Moving)continue;
|
||||
if(player->GetExactDist(record.Departure)>2)
|
||||
{Fail(player,record,"departure-unavailable: takeoff point not reached");continue;}
|
||||
auto target=record.Status.Target;bool following=record.Status.FollowingPlayer;std::string error;
|
||||
// Begin replaces this record on success; do not access old fields afterwards.
|
||||
if(!Begin(player,target,error,following))Fail(player,record,error);
|
||||
continue;
|
||||
}
|
||||
// Count actual motion, not overlapping issued spline lengths.
|
||||
record.Status.Travelled += Distance(PointOf(record.LastPosition), PointOf(*player));
|
||||
record.LastPosition.Relocate(player);
|
||||
@@ -618,6 +717,13 @@ bool ClientlessFlightMgr::Command(ChatHandler * handler, char const * args)
|
||||
Record probe;
|
||||
auto surface = Sample(player, probe, x, y);
|
||||
handler->PSendSysMessage("Flight surface map=%u x=%.3f y=%.3f valid=%u ground=%.3f ceiling=%.3f", player->GetMapId(), x, y, surface.Valid ? 1u : 0u, surface.Ground, surface.Ceiling);
|
||||
auto map=player->GetMap();
|
||||
float feet=map->GetHeight(player->GetPhaseShift(),x,y,player->GetPositionZ()+2.0f,true,6.0f);
|
||||
LiquidData liquid{};
|
||||
auto liquidStatus=map->GetLiquidStatus(player->GetPhaseShift(),x,y,player->GetPositionZ(),map_liquidHeaderTypeFlags::AllLiquids,&liquid,player->GetCollisionHeight());
|
||||
handler->PSendSysMessage("Flight departure guid=%u position=(%.3f %.3f %.3f) nearFeet=%.3f rawWater=%.3f liquidStatus=%u liquidLevel=%.3f mounted=%u canFly=%u flying=%u falling=%u",
|
||||
guid,player->GetPositionX(),player->GetPositionY(),player->GetPositionZ(),feet,map->GetWaterLevel(player->GetPhaseShift(),x,y),uint32(liquidStatus),liquid.level,
|
||||
player->IsMounted()?1:0,player->CanFly()?1:0,player->IsFlying()?1:0,player->IsFalling()?1:0);
|
||||
return true;
|
||||
}
|
||||
if (op == "test_node")
|
||||
|
||||
Reference in new issue
Block a user