|
|
|
@ -212,7 +212,8 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MWMechanics::AiPackage* package = mPackages.front();
|
|
|
|
|
auto packageIt = mPackages.begin();
|
|
|
|
|
MWMechanics::AiPackage* package = *packageIt;
|
|
|
|
|
if (!package->alwaysActive() && outOfRange)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
@ -223,7 +224,7 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac
|
|
|
|
|
// if active package is combat one, choose nearest target
|
|
|
|
|
if (packageTypeId == AiPackage::TypeIdCombat)
|
|
|
|
|
{
|
|
|
|
|
std::list<AiPackage *>::iterator itActualCombat;
|
|
|
|
|
auto itActualCombat = mPackages.end();
|
|
|
|
|
|
|
|
|
|
float nearestDist = std::numeric_limits<float>::max();
|
|
|
|
|
osg::Vec3f vActorPos = actor.getRefData().getPosition().asVec3();
|
|
|
|
@ -265,16 +266,18 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!mPackages.empty())
|
|
|
|
|
{
|
|
|
|
|
if (nearestDist < std::numeric_limits<float>::max() && mPackages.begin() != itActualCombat)
|
|
|
|
|
{
|
|
|
|
|
// move combat package with nearest target to the front
|
|
|
|
|
mPackages.splice(mPackages.begin(), mPackages, itActualCombat);
|
|
|
|
|
}
|
|
|
|
|
assert(!mPackages.empty());
|
|
|
|
|
|
|
|
|
|
package = mPackages.front();
|
|
|
|
|
if (nearestDist < std::numeric_limits<float>::max() && mPackages.begin() != itActualCombat)
|
|
|
|
|
{
|
|
|
|
|
assert(itActualCombat != mPackages.end());
|
|
|
|
|
// move combat package with nearest target to the front
|
|
|
|
|
mPackages.splice(mPackages.begin(), mPackages, itActualCombat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
packageIt = mPackages.begin();
|
|
|
|
|
package = *packageIt;
|
|
|
|
|
packageTypeId = package->getTypeId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
@ -289,9 +292,7 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac
|
|
|
|
|
}
|
|
|
|
|
// To account for the rare case where AiPackage::execute() queued another AI package
|
|
|
|
|
// (e.g. AiPursue executing a dialogue script that uses startCombat)
|
|
|
|
|
std::list<MWMechanics::AiPackage*>::iterator toRemove =
|
|
|
|
|
std::find(mPackages.begin(), mPackages.end(), package);
|
|
|
|
|
mPackages.erase(toRemove);
|
|
|
|
|
mPackages.erase(packageIt);
|
|
|
|
|
delete package;
|
|
|
|
|
if (isActualAiPackage(packageTypeId))
|
|
|
|
|
mDone = true;
|
|
|
|
|