mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-03 22:45:35 +00:00
Fixed AiPursue by fixing underlying issue is Pathto()
This commit is contained in:
parent
2425d2c2ab
commit
d2aada95b4
4 changed files with 6 additions and 7 deletions
|
@ -37,7 +37,6 @@ bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor,float duration)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pathTo(actor, dest, duration); //Go to the destination
|
pathTo(actor, dest, duration); //Go to the destination
|
||||||
actor.getClass().getMovementSettings(actor).mPosition[1] = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -22,7 +22,7 @@ bool MWMechanics::AiAvoidDoor::execute (const MWWorld::Ptr& actor,float duration
|
||||||
{
|
{
|
||||||
|
|
||||||
ESM::Position pos = actor.getRefData().getPosition();
|
ESM::Position pos = actor.getRefData().getPosition();
|
||||||
if(mDuration = 1) //If it just started, get the actor position as the stuck detection thing
|
if(mDuration == 1) //If it just started, get the actor position as the stuck detection thing
|
||||||
mLastPos = pos;
|
mLastPos = pos;
|
||||||
|
|
||||||
mDuration -= duration; //Update timer
|
mDuration -= duration; //Update timer
|
||||||
|
|
|
@ -58,12 +58,11 @@ bool MWMechanics::AiFollow::execute (const MWWorld::Ptr& actor,float duration)
|
||||||
//Set the target desition from the actor
|
//Set the target desition from the actor
|
||||||
ESM::Pathgrid::Point dest = target.getRefData().getPosition().pos;
|
ESM::Pathgrid::Point dest = target.getRefData().getPosition().pos;
|
||||||
|
|
||||||
pathTo(actor, dest, duration); //Go to the destination
|
|
||||||
|
|
||||||
if(distance(dest, pos.pos[0], pos.pos[1], pos.pos[2]) < 100) //Stop when you get close
|
if(distance(dest, pos.pos[0], pos.pos[1], pos.pos[2]) < 100) //Stop when you get close
|
||||||
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
|
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
|
||||||
else
|
else {
|
||||||
actor.getClass().getMovementSettings(actor).mPosition[1] = 1;
|
pathTo(actor, dest, duration); //Go to the destination
|
||||||
|
}
|
||||||
|
|
||||||
//Check if you're far away
|
//Check if you're far away
|
||||||
if(distance(dest, pos.pos[0], pos.pos[1], pos.pos[2]) > 1000)
|
if(distance(dest, pos.pos[0], pos.pos[1], pos.pos[2]) > 1000)
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
MWMechanics::AiPackage::~AiPackage() {}
|
MWMechanics::AiPackage::~AiPackage() {}
|
||||||
|
|
||||||
MWMechanics::AiPackage::AiPackage() : mLastDoorChecked(MWWorld::Ptr()), mTimer(0), mStuckTimer(0) {
|
MWMechanics::AiPackage::AiPackage() : mLastDoorChecked(MWWorld::Ptr()), mTimer(.26), mStuckTimer(0) { //mTimer starts at .26 to force initial pathbuild
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +118,7 @@ bool MWMechanics::AiPackage::pathTo(const MWWorld::Ptr& actor, ESM::Pathgrid::Po
|
||||||
mStuckTimer = 0;
|
mStuckTimer = 0;
|
||||||
mStuckPos = pos;
|
mStuckPos = pos;
|
||||||
mLastDoorChecked = MWWorld::Ptr(); //Resets it, in case he gets stuck behind the door again
|
mLastDoorChecked = MWWorld::Ptr(); //Resets it, in case he gets stuck behind the door again
|
||||||
|
actor.getClass().getMovementSettings(actor).mPosition[1] = 1; //Just run forward
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in a new issue