@ -1,6 +1,5 @@
# include "aiescort.hpp"
# include "character.hpp"
# include "movement.hpp"
# include "../mwworld/class.hpp"
@ -10,16 +9,12 @@
# include "../mwbase/environment.hpp"
# include "../mwbase/mechanicsmanager.hpp"
# include <boost/graph/astar_search.hpp>
# include <boost/graph/adjacency_list.hpp>
# include "boost/tuple/tuple.hpp"
namespace
{
float sgn ( float a )
{
if ( a > 0 ) return 1. ;
else return - 1. ;
if ( a > 0 ) return 1. 0 ;
else return - 1. 0 ;
}
}
@ -77,11 +72,8 @@ bool MWMechanics::AiEscort::execute (const MWWorld::Ptr& actor)
{
MWWorld : : TimeStamp current = MWBase : : Environment : : get ( ) . getWorld ( ) - > getTimeStamp ( ) ;
unsigned int currentSecond = ( ( current . getHour ( ) - int ( current . getHour ( ) ) ) * 100 ) ;
std : : cout < < " AiEscort: " < < currentSecond < < " time: " < < currentSecond - mStartingSecond < < std : : endl ;
if ( currentSecond - mStartingSecond > = mDuration )
{
return true ;
}
}
ESM : : Position pos = actor . getRefData ( ) . getPosition ( ) ;
@ -91,28 +83,28 @@ bool MWMechanics::AiEscort::execute (const MWWorld::Ptr& actor)
MWBase : : Environment : : get ( ) . getWorld ( ) - > getStore ( ) . get < ESM : : Pathgrid > ( ) . search ( * actor . getCell ( ) - > mCell ) ;
if ( actor . getCell ( ) - > mCell - > mData . mX ! = player . getCell ( ) - > mCell - > mData . mX )
if ( actor . getCell ( ) - > mCell - > mData . mX ! = player . getCell ( ) - > mCell - > mData . mX )
{
int sideX = sgn ( actor . getCell ( ) - > mCell - > mData . mX - player . getCell ( ) - > mCell - > mData . mX ) ;
// Check if actor is near the border of an inactive cell. If so, disable AiEscort.
// FIXME: This *should* pause the AiEscort package instead of terminating it.
if ( sideX * ( pos . pos [ 0 ] - actor . getCell ( ) - > mCell - > mData . mX * ESM : : Land : : REAL_SIZE ) > sideX * ( ESM : : Land : : REAL_SIZE / 2. - 200 ) )
{
int sideX = sgn ( actor . getCell ( ) - > mCell - > mData . mX - player . getCell ( ) - > mCell - > mData . mX ) ;
// Check if actor is near the border of an inactive cell. If so, disable AiEscort.
// FIXME: This *should* pause the AiEscort package instead of terminating it.
if ( sideX * ( pos . pos [ 0 ] - actor . getCell ( ) - > mCell - > mData . mX * ESM : : Land : : REAL_SIZE ) > sideX * ( ESM : : Land : : REAL_SIZE / 2. - 200 ) )
{
MWWorld : : Class : : get ( actor ) . getMovementSettings ( actor ) . mPosition [ 1 ] = 0 ;
return true ;
}
MWWorld : : Class : : get ( actor ) . getMovementSettings ( actor ) . mPosition [ 1 ] = 0 ;
return true ;
}
if ( actor . getCell ( ) - > mCell - > mData . mY ! = player . getCell ( ) - > mCell - > mData . mY )
}
if ( actor . getCell ( ) - > mCell - > mData . mY ! = player . getCell ( ) - > mCell - > mData . mY )
{
int sideY = sgn ( actor . getCell ( ) - > mCell - > mData . mY - player . getCell ( ) - > mCell - > mData . mY ) ;
// Check if actor is near the border of an inactive cell. If so, disable AiEscort.
// FIXME: This *should* pause the AiEscort package instead of terminating it.
if ( sideY * ( pos . pos [ 1 ] - actor . getCell ( ) - > mCell - > mData . mY * ESM : : Land : : REAL_SIZE ) > sideY * ( ESM : : Land : : REAL_SIZE / 2. - 200 ) )
{
int sideY = sgn ( actor . getCell ( ) - > mCell - > mData . mY - player . getCell ( ) - > mCell - > mData . mY ) ;
// Check if actor is near the border of an inactive cell. If so, disable AiEscort.
// FIXME: This *should* pause the AiEscort package instead of terminating it.
if ( sideY * ( pos . pos [ 1 ] - actor . getCell ( ) - > mCell - > mData . mY * ESM : : Land : : REAL_SIZE ) > sideY * ( ESM : : Land : : REAL_SIZE / 2. - 200 ) )
{
MWWorld : : Class : : get ( actor ) . getMovementSettings ( actor ) . mPosition [ 1 ] = 0 ;
return true ;
}
MWWorld : : Class : : get ( actor ) . getMovementSettings ( actor ) . mPosition [ 1 ] = 0 ;
return true ;
}
}
if ( ! mPathFinder . isPathConstructed ( ) | | cellChange )