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)
, mDuration(duration)
, mRemainingDuration(static_cast<float>(duration))
, mCellX(std::numeric_limits<int>::max())
, mCellY(std::numeric_limits<int>::max())
{
mTargetActorRefId = actorId;
}
@ -45,8 +43,6 @@ namespace MWMechanics
, mZ(z)
, mDuration(duration)
, mRemainingDuration(static_cast<float>(duration))
, mCellX(std::numeric_limits<int>::max())
, mCellY(std::numeric_limits<int>::max())
{
mTargetActorRefId = actorId;
}
@ -59,8 +55,6 @@ namespace MWMechanics
, mZ(escort->mData.mZ)
, mDuration(escort->mData.mDuration)
, mRemainingDuration(escort->mRemainingDuration)
, mCellX(std::numeric_limits<int>::max())
, mCellY(std::numeric_limits<int>::max())
{
mTargetActorRefId = escort->mTargetId;
mTargetActorId = escort->mTargetActorId;
@ -96,6 +90,19 @@ namespace MWMechanics
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);
if (pathTo(actor, dest, duration, characterController.getSupportedMovementDirections(), maxHalfExtent))
{

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

@ -467,7 +467,7 @@ namespace MWMechanics
{
ESM::AITarget data = esmPackage.mTarget;
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)
{
@ -484,7 +484,7 @@ namespace MWMechanics
{
ESM::AITarget data = esmPackage.mTarget;
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);

Loading…
Cancel
Save