mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-03 14:45:37 +00:00
Make actor flee from a combat when cannot reach a target
This commit is contained in:
parent
c33b2e0100
commit
becccf3b5e
1 changed files with 19 additions and 0 deletions
|
@ -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…
Reference in a new issue