1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 22:23:51 +00:00

Unreachable enemies combat AI fix (Fixes #2271)

This commit is contained in:
scrawl 2015-02-14 16:51:54 +01:00
parent 37a85e31d6
commit 81925645a3

View file

@ -207,16 +207,6 @@ namespace MWMechanics
const MWWorld::Class& actorClass = actor.getClass(); const MWWorld::Class& actorClass = actor.getClass();
MWBase::World* world = MWBase::Environment::get().getWorld(); MWBase::World* world = MWBase::Environment::get().getWorld();
// can't fight if attacker can't go where target is. E.g. A fish can't attack person on land.
if (!actorClass.isNpc() && !MWMechanics::isEnvironmentCompatible(actor, target))
{
actorClass.getCreatureStats(actor).setAttackingOrSpell(false);
return true;
}
//Update every frame //Update every frame
bool& combatMove = storage.mCombatMove; bool& combatMove = storage.mCombatMove;
@ -476,6 +466,19 @@ namespace MWMechanics
// for distant combat we should know if target is in LOS even if distToTarget < rangeAttack // for distant combat we should know if target is in LOS even if distToTarget < rangeAttack
bool inLOS = distantCombat ? world->getLOS(actor, target) : true; bool inLOS = distantCombat ? world->getLOS(actor, target) : true;
// can't fight if attacker can't go where target is. E.g. A fish can't attack person on land.
if (distToTarget >= rangeAttack
&& !actorClass.isNpc() && !MWMechanics::isEnvironmentCompatible(actor, target))
{
// TODO: start fleeing?
movement.mPosition[0] = 0;
movement.mPosition[1] = 0;
movement.mPosition[2] = 0;
readyToAttack = false;
actorClass.getCreatureStats(actor).setAttackingOrSpell(false);
return false;
}
// (within attack dist) || (not quite attack dist while following) // (within attack dist) || (not quite attack dist while following)
if(inLOS && (distToTarget < rangeAttack || (distToTarget <= rangeFollow && followTarget && !isStuck))) if(inLOS && (distToTarget < rangeAttack || (distToTarget <= rangeFollow && followTarget && !isStuck)))
{ {