Merge branch 'endoftheearth' into 'master'

Don't try to escort to nowhere

See merge request OpenMW/openmw!3603
macos_ci_fix
Alexei Kotov 1 year ago
commit 9873ab25df

@ -30,8 +30,6 @@ namespace MWMechanics
, mZ(z) , mZ(z)
, mDuration(duration) , mDuration(duration)
, mRemainingDuration(static_cast<float>(duration)) , mRemainingDuration(static_cast<float>(duration))
, mCellX(std::numeric_limits<int>::max())
, mCellY(std::numeric_limits<int>::max())
{ {
mTargetActorRefId = actorId; mTargetActorRefId = actorId;
} }
@ -45,8 +43,6 @@ namespace MWMechanics
, mZ(z) , mZ(z)
, mDuration(duration) , mDuration(duration)
, mRemainingDuration(static_cast<float>(duration)) , mRemainingDuration(static_cast<float>(duration))
, mCellX(std::numeric_limits<int>::max())
, mCellY(std::numeric_limits<int>::max())
{ {
mTargetActorRefId = actorId; mTargetActorRefId = actorId;
} }
@ -59,8 +55,6 @@ namespace MWMechanics
, mZ(escort->mData.mZ) , mZ(escort->mData.mZ)
, mDuration(escort->mData.mDuration) , mDuration(escort->mData.mDuration)
, mRemainingDuration(escort->mRemainingDuration) , mRemainingDuration(escort->mRemainingDuration)
, mCellX(std::numeric_limits<int>::max())
, mCellY(std::numeric_limits<int>::max())
{ {
mTargetActorRefId = escort->mTargetId; mTargetActorRefId = escort->mTargetId;
mTargetActorId = escort->mTargetActorId; mTargetActorId = escort->mTargetActorId;
@ -96,6 +90,19 @@ namespace MWMechanics
if ((leaderPos - followerPos).length2() <= mMaxDist * mMaxDist) if ((leaderPos - followerPos).length2() <= mMaxDist * mMaxDist)
{ {
// TESCS allows the creation of Escort packages without a specific destination
constexpr float nowhere = std::numeric_limits<float>::max();
if (mX == nowhere || mY == nowhere)
return true;
if (mZ == nowhere)
{
if (mCellId.empty()
&& ESM::positionToExteriorCellLocation(mX, mY)
== actor.getCell()->getCell()->getExteriorCellLocation())
return false;
return true;
}
const osg::Vec3f dest(mX, mY, mZ); const osg::Vec3f dest(mX, mY, mZ);
if (pathTo(actor, dest, duration, characterController.getSupportedMovementDirections(), maxHalfExtent)) if (pathTo(actor, dest, duration, characterController.getSupportedMovementDirections(), maxHalfExtent))
{ {

@ -59,9 +59,6 @@ namespace MWMechanics
float mMaxDist = 450; float mMaxDist = 450;
const float mDuration; // In hours const float mDuration; // In hours
float mRemainingDuration; // In hours float mRemainingDuration; // In hours
const int mCellX;
const int mCellY;
}; };
} }
#endif #endif

@ -467,7 +467,7 @@ namespace MWMechanics
{ {
ESM::AITarget data = esmPackage.mTarget; ESM::AITarget data = esmPackage.mTarget;
package = std::make_unique<MWMechanics::AiEscort>(ESM::RefId::stringRefId(data.mId.toStringView()), package = std::make_unique<MWMechanics::AiEscort>(ESM::RefId::stringRefId(data.mId.toStringView()),
data.mDuration, data.mX, data.mY, data.mZ, data.mShouldRepeat != 0); esmPackage.mCellName, data.mDuration, data.mX, data.mY, data.mZ, data.mShouldRepeat != 0);
} }
else if (esmPackage.mType == ESM::AI_Travel) else if (esmPackage.mType == ESM::AI_Travel)
{ {
@ -484,7 +484,7 @@ namespace MWMechanics
{ {
ESM::AITarget data = esmPackage.mTarget; ESM::AITarget data = esmPackage.mTarget;
package = std::make_unique<MWMechanics::AiFollow>(ESM::RefId::stringRefId(data.mId.toStringView()), package = std::make_unique<MWMechanics::AiFollow>(ESM::RefId::stringRefId(data.mId.toStringView()),
data.mDuration, data.mX, data.mY, data.mZ, data.mShouldRepeat != 0); esmPackage.mCellName, data.mDuration, data.mX, data.mY, data.mZ, data.mShouldRepeat != 0);
} }
onPackageAdded(*package); onPackageAdded(*package);

Loading…
Cancel
Save