Make Follow Great Again!

This commit is contained in:
Liru Færs
2020-01-07 17:40:43 -05:00
parent 50eb21ce23
commit 33feeb0a01

View File

@@ -1690,7 +1690,7 @@ void LLAgent::startFollowPilot(const LLUUID &leader_id, BOOL allow_flying, F32 s
}
startAutoPilotGlobal(object->getPositionGlobal(),
std::string(), // behavior_name
"Follow", // behavior_name
NULL, // target_rotation
NULL, // finish_callback
NULL, // callback_data
@@ -1707,6 +1707,9 @@ void LLAgent::stopAutoPilot(BOOL user_cancel)
{
if (mAutoPilot)
{
if (!user_cancel && mAutoPilotBehaviorName == "Follow")
return; // Follow means actually follow
mAutoPilot = FALSE;
if (mAutoPilotUseRotation && !user_cancel)
{
@@ -1751,20 +1754,24 @@ void LLAgent::autoPilot(F32 *delta_yaw)
{
if (mAutoPilot)
{
if (!mLeaderID.isNull())
bool follow = !mLeaderID.isNull(); //mAutoPilotBehaviorName == "Follow";
if (follow)
{
LLViewerObject* object = gObjectList.findObject(mLeaderID);
if (!object)
if (!object)
{
mAutoPilotBehaviorName.clear(); // Nothing left to follow pilot
stopAutoPilot();
return;
}
mAutoPilotTargetGlobal = object->getPositionGlobal();
if (const auto& av = object->asAvatar()) // Fly if avatar target is flying
setFlying(av->mInAir);
}
if (!isAgentAvatarValid()) return;
if (gAgentAvatarp->mInAir && mAutoPilotAllowFlying)
if (!follow && gAgentAvatarp->mInAir && mAutoPilotAllowFlying)
{
setFlying(TRUE);
}
@@ -1776,7 +1783,7 @@ void LLAgent::autoPilot(F32 *delta_yaw)
F32 target_dist = direction.magVec();
if (target_dist >= mAutoPilotTargetDist)
if (!follow && target_dist >= mAutoPilotTargetDist)
{
mAutoPilotNoProgressFrameCount++;
if (mAutoPilotNoProgressFrameCount > AUTOPILOT_MAX_TIME_NO_PROGRESS * gFPSClamped)