AI: return back after pursuit

0.6.3
Andrei Kortunov 7 years ago
parent 3d0631cfcc
commit 74a2cbe696

@ -308,6 +308,29 @@ void AiSequence::stack (const AiPackage& package, const MWWorld::Ptr& actor, boo
if (isActualAiPackage(package.getTypeId()))
stopCombat();
// we should return a wandering actor back after combat or pursuit
// the same thing for actors without AI packages
int currentTypeId = getTypeId();
int newTypeId = package.getTypeId();
if (currentTypeId <= MWMechanics::AiPackage::TypeIdWander
&& (newTypeId <= MWMechanics::AiPackage::TypeIdCombat
|| newTypeId == MWMechanics::AiPackage::TypeIdPursue))
{
osg::Vec3f dest;
if (currentTypeId == MWMechanics::AiPackage::TypeIdWander)
{
AiPackage* activePackage = getActivePackage();
dest = activePackage->getDestination(actor);
}
else
{
dest = actor.getRefData().getPosition().asVec3();
}
MWMechanics::AiTravel travelPackage(dest.x(), dest.y(), dest.z(), true);
stack(travelPackage, actor, false);
}
// remove previous packages if required
if (cancelOther && package.shouldCancelPreviousAi())
{

@ -1604,26 +1604,6 @@ namespace MWMechanics
if (aiSequence.isInCombat(target))
return;
// we should return a wandering actor back after combat
// the same thing for actors without AI packages
if (aiSequence.getTypeId() <= MWMechanics::AiPackage::TypeIdWander)
{
int typeId = aiSequence.getTypeId();
osg::Vec3f dest;
if (typeId == MWMechanics::AiPackage::TypeIdNone)
{
dest = ptr.getRefData().getPosition().asVec3();
}
else if (typeId == MWMechanics::AiPackage::TypeIdWander)
{
AiPackage* activePackage = aiSequence.getActivePackage();
dest = activePackage->getDestination(ptr);
}
MWMechanics::AiTravel travelPackage(dest.x(), dest.y(), dest.z(), true);
aiSequence.stack(travelPackage, ptr, false);
}
aiSequence.stack(MWMechanics::AiCombat(target), ptr);
if (target == getPlayer())
{

Loading…
Cancel
Save