Make actor flee from a combat when cannot reach a target

pull/593/head
elsid 4 years ago
parent c33b2e0100
commit becccf3b5e
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -262,6 +262,25 @@ namespace MWMechanics
// start new attack
storage.startAttackIfReady(actor, characterController, weapon, isRangedCombat);
}
else if (!isRangedCombat && !mPathFinder.isPathConstructed() && storage.mCurrentAction->isAttackingOrSpell())
{
const osg::Vec3f position = actor.getRefData().getPosition().asVec3();
const osg::Vec3f destination = target.getRefData().getPosition().asVec3();
const osg::Vec3f halfExtents = MWBase::Environment::get().getWorld()->getPathfindingHalfExtents(actor);
mPathFinder.buildPath(actor, position, destination, actor.getCell(), getPathGridGraph(actor.getCell()),
halfExtents, getNavigatorFlags(actor), getAreaCosts(actor));
if (!mPathFinder.isPathConstructed())
{
storage.stopAttack();
characterController.setAttackingOrSpell(false);
currentAction.reset(new ActionFlee());
actionCooldown = currentAction->getActionCooldown();
storage.startFleeing();
MWBase::Environment::get().getDialogueManager()->say(actor, "flee");
}
}
return false;
}

Loading…
Cancel
Save