mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 21:40:03 +00:00
check position to stop AIFollow
This commit is contained in:
parent
ccf07f9406
commit
051d7141be
@ -27,17 +27,19 @@ MWMechanics::AiFollow *MWMechanics::AiFollow::clone() const
|
|||||||
mStuckTimer = mStuckTimer + duration;
|
mStuckTimer = mStuckTimer + duration;
|
||||||
mTotalTime = mTotalTime + duration;
|
mTotalTime = mTotalTime + duration;
|
||||||
|
|
||||||
if(mTotalTime > mDuration) return true;
|
ESM::Position pos = actor.getRefData().getPosition();
|
||||||
|
|
||||||
|
if(mTotalTime > mDuration ||
|
||||||
|
(pos.pos[0]-mX)*(pos.pos[0]-mX) +
|
||||||
|
(pos.pos[1]-mY)*(pos.pos[1]-mY) +
|
||||||
|
(pos.pos[2]-mZ)*(pos.pos[2]-mZ) < 100*100)
|
||||||
|
return true;
|
||||||
|
|
||||||
ESM::Pathgrid::Point dest;
|
ESM::Pathgrid::Point dest;
|
||||||
dest.mX = target.getRefData().getPosition().pos[0];
|
dest.mX = target.getRefData().getPosition().pos[0];
|
||||||
dest.mY = target.getRefData().getPosition().pos[1];
|
dest.mY = target.getRefData().getPosition().pos[1];
|
||||||
dest.mZ = target.getRefData().getPosition().pos[2];
|
dest.mZ = target.getRefData().getPosition().pos[2];
|
||||||
|
|
||||||
//std::cout << dest.mX;
|
|
||||||
|
|
||||||
ESM::Position pos = actor.getRefData().getPosition();
|
|
||||||
|
|
||||||
if(mTimer > 0.25)
|
if(mTimer > 0.25)
|
||||||
{
|
{
|
||||||
if(!mPathFinder.getPath().empty())
|
if(!mPathFinder.getPath().empty())
|
||||||
@ -63,7 +65,6 @@ MWMechanics::AiFollow *MWMechanics::AiFollow::clone() const
|
|||||||
+(mStuckPos.pos[2] - pos.pos[2])*(mStuckPos.pos[2] - pos.pos[2])
|
+(mStuckPos.pos[2] - pos.pos[2])*(mStuckPos.pos[2] - pos.pos[2])
|
||||||
< 100) //NPC is stuck
|
< 100) //NPC is stuck
|
||||||
{
|
{
|
||||||
std::cout << "stck\n";
|
|
||||||
ESM::Pathgrid::Point start;
|
ESM::Pathgrid::Point start;
|
||||||
start.mX = pos.pos[0];
|
start.mX = pos.pos[0];
|
||||||
start.mY = pos.pos[1];
|
start.mY = pos.pos[1];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user