mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Terminate AI packages when target is disabled or deleted (Fixes #1910)
This commit is contained in:
parent
1270dada34
commit
233e221de2
@ -28,7 +28,10 @@ bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor,float duration)
|
||||
|
||||
actor.getClass().getCreatureStats(actor).setDrawState(DrawState_Nothing);
|
||||
|
||||
if(target == MWWorld::Ptr())
|
||||
if(target == MWWorld::Ptr() ||
|
||||
!target.getRefData().getCount() || !target.getRefData().isEnabled() // Really we should be checking whether the target is currently registered
|
||||
// with the MechanicsManager
|
||||
)
|
||||
return true; //Target doesn't exist
|
||||
|
||||
//Set the target desition from the actor
|
||||
|
@ -180,7 +180,9 @@ namespace MWMechanics
|
||||
if (target.isEmpty())
|
||||
return false;
|
||||
|
||||
if(target.getClass().getCreatureStats(target).isDead())
|
||||
if(!target.getRefData().getCount() || !target.getRefData().isEnabled() // Really we should be checking whether the target is currently registered
|
||||
// with the MechanicsManager
|
||||
|| target.getClass().getCreatureStats(target).isDead())
|
||||
return true;
|
||||
|
||||
const MWWorld::Class& actorClass = actor.getClass();
|
||||
|
@ -45,7 +45,9 @@ bool MWMechanics::AiFollow::execute (const MWWorld::Ptr& actor,float duration)
|
||||
{
|
||||
MWWorld::Ptr target = getTarget();
|
||||
|
||||
if (target.isEmpty())
|
||||
if (target.isEmpty() || !target.getRefData().getCount() || !target.getRefData().isEnabled() // Really we should be checking whether the target is currently registered
|
||||
// with the MechanicsManager
|
||||
)
|
||||
return true; //Target doesn't exist
|
||||
|
||||
// Only the player can be actively followed. AiFollow packages with targets other than the player
|
||||
|
@ -38,7 +38,9 @@ bool AiPursue::execute (const MWWorld::Ptr& actor, float duration)
|
||||
ESM::Position pos = actor.getRefData().getPosition(); //position of the actor
|
||||
const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtrViaActorId(mTargetActorId); //The target to follow
|
||||
|
||||
if(target == MWWorld::Ptr())
|
||||
if(target == MWWorld::Ptr() || !target.getRefData().getCount() || !target.getRefData().isEnabled() // Really we should be checking whether the target is currently registered
|
||||
// with the MechanicsManager
|
||||
)
|
||||
return true; //Target doesn't exist
|
||||
|
||||
if(target.getClass().getCreatureStats(target).isDead())
|
||||
|
Loading…
x
Reference in New Issue
Block a user