Improve AdventureBot instance and flight navigation
This commit is contained in:
1 parent
be049baacc
commit
3c361e435a
14 files changed
+525
-63
No files matched your search
@@ -66,6 +66,18 @@ namespace
|
||||
if(!ClearRay(player,{x+offset.X,y+offset.Y,surface.Ground+0.8f},{x+offset.X,y+offset.Y,top}))return false;
|
||||
return true;
|
||||
}
|
||||
bool OpenColumnFrom(Player* player,float x,float y,float z,float height)
|
||||
{
|
||||
// A height query from MAX_HEIGHT can legitimately return a bridge,
|
||||
// tree canopy or other collision surface far above the player. Such a
|
||||
// surface is useful as an obstacle, but it is not the player's support
|
||||
// floor. Test the actual take-off column from the player's feet.
|
||||
if (!std::isfinite(z) || height < 5.0f) 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,z+0.8f},
|
||||
{x+offset.X,y+offset.Y,z+height})) return false;
|
||||
return true;
|
||||
}
|
||||
char const * StateName(ClientlessFlightState state)
|
||||
{
|
||||
switch (state)
|
||||
@@ -398,13 +410,30 @@ bool ClientlessFlightMgr::Begin(Player * player, Position const & target, std::s
|
||||
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::isfinite(feet) || feet<=INVALID_HEIGHT+1 || std::fabs(origin.Ground-player->GetPositionZ())>3 || std::fabs(feet-player->GetPositionZ())>3)))
|
||||
bool const localSupport=std::isfinite(feet) && feet>INVALID_HEIGHT+1 &&
|
||||
std::fabs(feet-player->GetPositionZ())<=3;
|
||||
bool const overheadSurface=origin.Valid && origin.Ground>player->GetPositionZ()+3;
|
||||
bool const openFromFeet=overheadSurface && OpenColumnFrom(player,player->GetPositionX(),
|
||||
player->GetPositionY(),player->GetPositionZ(),
|
||||
std::min(record.Settings.Clearance,origin.Ground-player->GetPositionZ()-1.0f));
|
||||
// Not falling/in water was verified above. If the global height sample
|
||||
// selected a remote surface above us, a clear local vertical column is a
|
||||
// valid departure even though that remote surface cannot be our floor.
|
||||
bool const supportedDeparture=localSupport || openFromFeet;
|
||||
if (!origin.Valid || (!airborne && !supportedDeparture))
|
||||
{
|
||||
if(std::isfinite(feet) && feet>INVALID_HEIGHT+1 && std::fabs(feet-player->GetPositionZ())<=3 && ApproachDeparture(player,record,following))return true;
|
||||
if(localSupport && 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);
|
||||
TC_LOG_WARN("server.adventurebot.navigation","FLIGHT_DEPARTURE_REJECT guid=%u z=%.3f surface=%.3f feet=%.3f valid=%u localSupport=%u overhead=%u openFromFeet=%u mounted=%u canFly=%u",
|
||||
player->GetGUID().GetCounter(),player->GetPositionZ(),origin.Ground,feet,
|
||||
origin.Valid?1:0,localSupport?1:0,overheadSurface?1:0,openFromFeet?1:0,
|
||||
player->IsMounted()?1:0,player->CanFly()?1:0);
|
||||
return false;
|
||||
}
|
||||
if(openFromFeet)
|
||||
ClientlessTravelTelemetry::Note(player,"flight-departure-overhead-surface",
|
||||
"z="+std::to_string(player->GetPositionZ())+" surface="+std::to_string(origin.Ground)+
|
||||
" feet="+std::to_string(feet));
|
||||
bool foundLanding = false;
|
||||
std::array<uint32,5> landingRejected{}; // surface, water, column, MMAP, area
|
||||
auto landingSummary=[&]()
|
||||
|
||||
Reference in new issue
Block a user