mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-29 09:32:45 +00:00
Use active package in predictAndAvoidCollisions
This commit is contained in:
parent
e75504637d
commit
1a41cefab3
@ -1234,8 +1234,8 @@ namespace MWMechanics
|
||||
const float maxTimeToCheck = 2.0f;
|
||||
static const bool giveWayWhenIdle = Settings::Manager::getBool("NPCs give way", "Game");
|
||||
|
||||
MWWorld::Ptr player = getPlayer();
|
||||
MWBase::World* world = MWBase::Environment::get().getWorld();
|
||||
const MWWorld::Ptr player = getPlayer();
|
||||
const MWBase::World* world = MWBase::Environment::get().getWorld();
|
||||
for(PtrActorMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter)
|
||||
{
|
||||
const MWWorld::Ptr& ptr = iter->first;
|
||||
@ -1260,23 +1260,26 @@ namespace MWMechanics
|
||||
bool shouldTurnToApproachingActor = !isMoving;
|
||||
MWWorld::Ptr currentTarget; // Combat or pursue target (NPCs should not avoid collision with their targets).
|
||||
const auto& aiSequence = ptr.getClass().getCreatureStats(ptr).getAiSequence();
|
||||
for (const auto& package : aiSequence)
|
||||
if (!aiSequence.isEmpty())
|
||||
{
|
||||
if (package->getTypeId() == AiPackageTypeId::Follow)
|
||||
shouldAvoidCollision = true;
|
||||
else if (package->getTypeId() == AiPackageTypeId::Wander && giveWayWhenIdle)
|
||||
const auto& package = aiSequence.getActivePackage();
|
||||
if (package.getTypeId() == AiPackageTypeId::Follow)
|
||||
{
|
||||
if (!static_cast<const AiWander*>(package.get())->isStationary())
|
||||
shouldAvoidCollision = true;
|
||||
}
|
||||
else if (package.getTypeId() == AiPackageTypeId::Wander && giveWayWhenIdle)
|
||||
{
|
||||
if (!static_cast<const AiWander&>(package).isStationary())
|
||||
shouldGiveWay = true;
|
||||
}
|
||||
else if (package->getTypeId() == AiPackageTypeId::Combat || package->getTypeId() == AiPackageTypeId::Pursue)
|
||||
else if (package.getTypeId() == AiPackageTypeId::Combat || package.getTypeId() == AiPackageTypeId::Pursue)
|
||||
{
|
||||
currentTarget = package->getTarget();
|
||||
currentTarget = package.getTarget();
|
||||
shouldAvoidCollision = isMoving;
|
||||
shouldTurnToApproachingActor = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!shouldAvoidCollision && !shouldGiveWay)
|
||||
continue;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user