2004-05-28 04:57:50 +02:00
|
|
|
// Entity state-machine processing code.
|
|
|
|
|
2004-06-03 20:38:14 +02:00
|
|
|
#include "precompiled.h"
|
|
|
|
|
2004-05-28 04:57:50 +02:00
|
|
|
#include "Entity.h"
|
|
|
|
#include "Model.h"
|
|
|
|
|
|
|
|
#include "Collision.h"
|
2004-05-29 05:32:33 +02:00
|
|
|
#include "PathfindEngine.h"
|
2004-07-23 12:56:52 +02:00
|
|
|
#include "Terrain.h"
|
|
|
|
|
2004-07-31 17:57:18 +02:00
|
|
|
#include "Game.h"
|
2004-05-28 04:57:50 +02:00
|
|
|
|
2004-11-11 08:09:32 +01:00
|
|
|
enum EGotoSituation
|
|
|
|
{
|
|
|
|
NORMAL = 0,
|
|
|
|
ALREADY_AT_DESTINATION,
|
|
|
|
REACHED_DESTINATION,
|
|
|
|
COLLISION_WITH_DESTINATION,
|
|
|
|
COLLISION_NEAR_DESTINATION,
|
|
|
|
COLLISION_OVERLAPPING_OBJECTS,
|
|
|
|
COLLISION_OTHER,
|
|
|
|
WOULD_LEAVE_MAP
|
|
|
|
};
|
|
|
|
|
|
|
|
// Does all the shared processing for line-of-sight gotos
|
|
|
|
|
|
|
|
EGotoSituation CEntity::processGotoHelper( CEntityOrder* current, size_t timestep_millis, HEntity& collide )
|
2004-05-28 04:57:50 +02:00
|
|
|
{
|
2004-07-27 23:00:53 +02:00
|
|
|
float timestep=timestep_millis/1000.0f;
|
|
|
|
|
2004-05-28 04:57:50 +02:00
|
|
|
CVector2D delta;
|
|
|
|
delta.x = (float)current->m_data[0].location.x - m_position.X;
|
|
|
|
delta.y = (float)current->m_data[0].location.y - m_position.Z;
|
|
|
|
|
2004-05-29 05:32:33 +02:00
|
|
|
float len = delta.length();
|
|
|
|
|
2004-06-11 00:24:03 +02:00
|
|
|
if( len < 0.1f )
|
2004-11-11 08:09:32 +01:00
|
|
|
return( ALREADY_AT_DESTINATION );
|
2004-06-09 19:56:03 +02:00
|
|
|
|
2004-06-03 04:20:48 +02:00
|
|
|
// Curve smoothing.
|
|
|
|
// Here there be trig.
|
|
|
|
|
2004-08-03 01:14:54 +02:00
|
|
|
float scale = m_speed * timestep;
|
|
|
|
|
|
|
|
// Note: Easy optimization: flag somewhere that this unit
|
|
|
|
// is already pointing the right way, and don't do this
|
|
|
|
// trig every time.
|
|
|
|
|
|
|
|
m_targetorientation = atan2( delta.x, delta.y );
|
|
|
|
|
|
|
|
float deltatheta = m_targetorientation - (float)m_orientation;
|
|
|
|
while( deltatheta > PI ) deltatheta -= 2 * PI;
|
|
|
|
while( deltatheta < -PI ) deltatheta += 2 * PI;
|
|
|
|
|
|
|
|
if( fabs( deltatheta ) > 0.01f )
|
2004-06-03 04:20:48 +02:00
|
|
|
{
|
2004-08-03 01:14:54 +02:00
|
|
|
float maxTurningSpeed = ( m_speed / m_turningRadius ) * timestep;
|
|
|
|
if( deltatheta > 0 )
|
|
|
|
{
|
|
|
|
m_orientation = m_orientation + MIN( deltatheta, maxTurningSpeed );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_orientation = m_orientation + MAX( deltatheta, -maxTurningSpeed );
|
|
|
|
|
|
|
|
m_ahead.x = sin( m_orientation );
|
|
|
|
m_ahead.y = cos( m_orientation );
|
|
|
|
|
2004-06-03 04:20:48 +02:00
|
|
|
// We can only really attempt to smooth paths the pathfinder
|
|
|
|
// has flagged for us. If the turning-radius calculations are
|
|
|
|
// applied to other types of waypoint, wierdness happens.
|
|
|
|
// Things like an entity trying to walk to a point inside
|
|
|
|
// his turning radius (which he can't do directly, so he'll
|
|
|
|
// orbit the point indefinately), or just massive deviations
|
|
|
|
// making the paths we calculate useless.
|
|
|
|
// It's also painful trying to watch two entities resolve their
|
|
|
|
// collision when they're both bound by turning constraints.
|
2004-08-03 01:14:54 +02:00
|
|
|
|
|
|
|
// So, as a compromise for the look of the thing, we'll just turn in
|
|
|
|
// place until we're looking the right way. At least, that's what
|
|
|
|
// seems logical. But in most cases that looks worse. So actually,
|
|
|
|
// let's not.
|
2004-11-11 08:09:32 +01:00
|
|
|
|
2004-08-03 01:14:54 +02:00
|
|
|
if( current->m_type != CEntityOrder::ORDER_GOTO_SMOOTHED )
|
|
|
|
m_orientation = m_targetorientation;
|
|
|
|
|
2004-06-03 04:20:48 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-08-03 01:14:54 +02:00
|
|
|
m_ahead = delta / len;
|
|
|
|
m_orientation = m_targetorientation;
|
2004-06-03 04:20:48 +02:00
|
|
|
}
|
|
|
|
|
2004-05-28 04:57:50 +02:00
|
|
|
if( m_bounds->m_type == CBoundingObject::BOUND_OABB )
|
|
|
|
((CBoundingBox*)m_bounds)->setOrientation( m_ahead );
|
|
|
|
|
2004-11-11 08:09:32 +01:00
|
|
|
EGotoSituation rc = NORMAL;
|
|
|
|
|
2004-05-28 04:57:50 +02:00
|
|
|
if( scale > len )
|
2004-11-11 08:09:32 +01:00
|
|
|
{
|
2004-05-28 04:57:50 +02:00
|
|
|
scale = len;
|
2004-11-11 08:09:32 +01:00
|
|
|
rc = REACHED_DESTINATION;
|
|
|
|
}
|
2004-05-28 04:57:50 +02:00
|
|
|
|
|
|
|
delta = m_ahead * scale;
|
|
|
|
|
2004-07-23 12:56:52 +02:00
|
|
|
// What would happen if we moved forward a little?
|
|
|
|
|
2004-05-28 04:57:50 +02:00
|
|
|
m_position.X += delta.x;
|
|
|
|
m_position.Z += delta.y;
|
2004-07-23 12:56:52 +02:00
|
|
|
|
2004-05-28 04:57:50 +02:00
|
|
|
m_bounds->setPosition( m_position.X, m_position.Z );
|
|
|
|
|
2004-11-11 08:09:32 +01:00
|
|
|
collide = getCollisionObject( this );
|
2004-05-28 04:57:50 +02:00
|
|
|
|
|
|
|
if( collide )
|
|
|
|
{
|
2004-07-23 12:56:52 +02:00
|
|
|
// We'd hit something. Let's not.
|
2004-05-28 04:57:50 +02:00
|
|
|
m_position.X -= delta.x;
|
|
|
|
m_position.Z -= delta.y;
|
2004-07-23 12:56:52 +02:00
|
|
|
m_bounds->m_pos -= delta;
|
2004-05-28 04:57:50 +02:00
|
|
|
|
2004-07-23 12:56:52 +02:00
|
|
|
// Is it too late to avoid the collision?
|
2004-05-28 04:57:50 +02:00
|
|
|
|
|
|
|
if( collide->m_bounds->intersects( m_bounds ) )
|
|
|
|
{
|
2004-07-23 12:56:52 +02:00
|
|
|
// Yes. Oh dear. That can't be good.
|
2004-07-22 18:18:12 +02:00
|
|
|
// This really shouldn't happen in the current build.
|
|
|
|
|
2004-07-23 12:56:52 +02:00
|
|
|
assert( false && "Overlapping objects" );
|
|
|
|
|
|
|
|
// Erm... do nothing?
|
|
|
|
|
2004-11-11 08:09:32 +01:00
|
|
|
return( COLLISION_OVERLAPPING_OBJECTS );
|
2004-07-23 12:56:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// No. Is our destination within the obstacle?
|
|
|
|
if( collide->m_bounds->contains( current->m_data[0].location ) )
|
2004-11-11 08:09:32 +01:00
|
|
|
return( COLLISION_WITH_DESTINATION );
|
|
|
|
|
2004-07-23 12:56:52 +02:00
|
|
|
// No. Are we nearing our destination, do we wish to stop there, and is it obstructed?
|
|
|
|
|
|
|
|
if( ( m_orderQueue.size() == 1 ) && ( len <= 10.0f ) )
|
|
|
|
{
|
|
|
|
CBoundingCircle destinationObs( current->m_data[0].location.x, current->m_data[0].location.y, m_bounds->m_radius );
|
|
|
|
if( getCollisionObject( &destinationObs ) )
|
|
|
|
{
|
|
|
|
// Yes. (Chances are a bunch of units were tasked to the same destination)
|
2004-11-11 08:09:32 +01:00
|
|
|
return( COLLISION_NEAR_DESTINATION );
|
2004-07-23 12:56:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-11 08:09:32 +01:00
|
|
|
// No?
|
|
|
|
return( COLLISION_OTHER );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Will we step off the map?
|
|
|
|
if( !g_Game->GetWorld()->GetTerrain()->isOnMap( m_position.X, m_position.Z ) )
|
|
|
|
{
|
|
|
|
// Yes. That's not a particularly good idea, either.
|
|
|
|
|
|
|
|
m_position.X -= delta.x;
|
|
|
|
m_position.Z -= delta.y;
|
|
|
|
m_bounds->setPosition( m_position.X, m_position.Z );
|
|
|
|
|
|
|
|
// All things being equal, we should only get here while on a collision path
|
|
|
|
// (No destination should be off the map)
|
|
|
|
|
|
|
|
return( WOULD_LEAVE_MAP );
|
|
|
|
}
|
|
|
|
|
|
|
|
// No. I suppose it's OK to go there, then. *disappointed*
|
|
|
|
|
|
|
|
return( rc );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CEntity::processGotoNoPathing( CEntityOrder* current, size_t timestep_millis )
|
|
|
|
{
|
|
|
|
HEntity collide;
|
|
|
|
switch( processGotoHelper( current, timestep_millis, collide ) )
|
|
|
|
{
|
|
|
|
case ALREADY_AT_DESTINATION:
|
|
|
|
// If on a collision path; decide where to go next. Otherwise, proceed to the next waypoint.
|
|
|
|
if( current->m_type == CEntityOrder::ORDER_GOTO_COLLISION )
|
|
|
|
{
|
|
|
|
repath();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_orderQueue.pop_front();
|
|
|
|
return( false );
|
|
|
|
case COLLISION_OVERLAPPING_OBJECTS:
|
|
|
|
return( false );
|
|
|
|
case COLLISION_WITH_DESTINATION:
|
|
|
|
// We're here...
|
|
|
|
m_orderQueue.pop_front();
|
|
|
|
return( false );
|
|
|
|
case COLLISION_NEAR_DESTINATION:
|
|
|
|
{
|
|
|
|
// Here's a wierd idea: (I hope it works)
|
|
|
|
// Spiral round the destination until a free point is found.
|
|
|
|
CBoundingCircle destinationObs( current->m_data[0].location.x, current->m_data[0].location.y, m_bounds->m_radius );
|
|
|
|
|
|
|
|
float interval = destinationObs.m_radius;
|
|
|
|
float r = interval, theta = 0.0f, delta;
|
|
|
|
float _x = current->m_data[0].location.x, _y = current->m_data[0].location.y;
|
|
|
|
|
|
|
|
while( true )
|
|
|
|
{
|
|
|
|
delta = interval / r;
|
|
|
|
theta += delta;
|
|
|
|
r += ( interval * delta ) / ( 2 * PI );
|
|
|
|
destinationObs.setPosition( _x + r * cosf( theta ), _y + r * sinf( theta ) );
|
|
|
|
if( !getCollisionObject( &destinationObs ) ) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reset our destination
|
|
|
|
current->m_data[0].location.x = _x + r * cosf( theta );
|
|
|
|
current->m_data[0].location.y = _y + r * sinf( theta );
|
|
|
|
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
case COLLISION_OTHER:
|
|
|
|
{
|
|
|
|
// Path around it.
|
2004-05-28 04:57:50 +02:00
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
CEntityOrder avoidance;
|
|
|
|
avoidance.m_type = CEntityOrder::ORDER_GOTO_COLLISION;
|
|
|
|
CVector2D right;
|
|
|
|
right.x = m_ahead.y; right.y = -m_ahead.x;
|
|
|
|
CVector2D avoidancePosition;
|
|
|
|
|
2004-07-23 12:56:52 +02:00
|
|
|
// Which is the shortest diversion, going left or right?
|
|
|
|
// (Weight a little towards the right, to stop both units dodging the same way)
|
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
if( ( collide->m_bounds->m_pos - m_bounds->m_pos ).dot( right ) < 1 )
|
|
|
|
{
|
|
|
|
// Turn right.
|
|
|
|
avoidancePosition = collide->m_bounds->m_pos + right * ( collide->m_bounds->m_radius + m_bounds->m_radius * 2.5f );
|
2004-05-28 04:57:50 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-07-20 21:30:35 +02:00
|
|
|
// Turn left.
|
|
|
|
avoidancePosition = collide->m_bounds->m_pos - right * ( collide->m_bounds->m_radius + m_bounds->m_radius * 2.5f );
|
|
|
|
}
|
2004-06-03 04:20:48 +02:00
|
|
|
|
2004-07-23 12:56:52 +02:00
|
|
|
// Create a short path representing this detour
|
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
avoidance.m_data[0].location = avoidancePosition;
|
|
|
|
if( current->m_type == CEntityOrder::ORDER_GOTO_COLLISION )
|
|
|
|
m_orderQueue.pop_front();
|
|
|
|
m_orderQueue.push_front( avoidance );
|
|
|
|
return( false );
|
2004-11-11 08:09:32 +01:00
|
|
|
}
|
|
|
|
case WOULD_LEAVE_MAP:
|
|
|
|
// Just stop here, repath if necessary.
|
|
|
|
m_orderQueue.pop_front();
|
|
|
|
return( false );
|
|
|
|
default:
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CEntity::processAttackMelee( CEntityOrder* current, size_t timestep_millis )
|
|
|
|
{
|
|
|
|
m_orderQueue.pop_front();
|
|
|
|
|
|
|
|
if( !current->m_data[0].entity || !current->m_data[0].entity->m_extant )
|
|
|
|
return( false );
|
|
|
|
|
|
|
|
current->m_data[0].location = current->m_data[0].entity->m_position;
|
2004-06-03 04:20:48 +02:00
|
|
|
|
2004-11-11 08:09:32 +01:00
|
|
|
if( ( current->m_data[0].location - m_position ).length() < m_meleeRange )
|
|
|
|
{
|
|
|
|
current->m_type = CEntityOrder::ORDER_ATTACK_MELEE_NOPATHING;
|
|
|
|
return( true );
|
2004-05-28 04:57:50 +02:00
|
|
|
}
|
|
|
|
|
2004-11-11 08:09:32 +01:00
|
|
|
if( m_transition )
|
2004-07-23 12:56:52 +02:00
|
|
|
{
|
2004-11-11 08:09:32 +01:00
|
|
|
m_actor->GetModel()->SetAnimation( m_actor->GetObject()->m_WalkAnim );
|
|
|
|
// Animation desync
|
|
|
|
m_actor->GetModel()->Update( ( rand() * 1000.0f ) / 1000.0f );
|
|
|
|
}
|
2004-07-23 12:56:52 +02:00
|
|
|
|
2004-11-11 08:09:32 +01:00
|
|
|
// The pathfinder will push its result back into this unit's queue.
|
2004-07-23 12:56:52 +02:00
|
|
|
|
2004-11-11 08:09:32 +01:00
|
|
|
g_Pathfinder.requestMeleeAttackPath( me, current->m_data[0].entity );
|
|
|
|
|
|
|
|
return( true );
|
|
|
|
}
|
2004-07-23 12:56:52 +02:00
|
|
|
|
2004-11-11 08:09:32 +01:00
|
|
|
bool CEntity::processAttackMeleeNoPathing( CEntityOrder* current, size_t timestep_millis )
|
|
|
|
{
|
|
|
|
// Target's dead? Then our work here is done.
|
|
|
|
if( !current->m_data[0].entity || !current->m_data[0].entity->m_extant )
|
|
|
|
{
|
2004-07-23 12:56:52 +02:00
|
|
|
m_orderQueue.pop_front();
|
2004-11-11 08:09:32 +01:00
|
|
|
return( false );
|
2004-07-23 12:56:52 +02:00
|
|
|
}
|
|
|
|
|
2004-11-11 08:09:32 +01:00
|
|
|
// Still playing attack animation? Suspend processing.
|
|
|
|
if( m_actor->GetModel()->GetAnimation() == m_actor->GetObject()->m_MeleeAnim )
|
|
|
|
return( false );
|
|
|
|
|
|
|
|
// Just transitioned? No animation? (=> melee just finished) Play walk.
|
|
|
|
if( m_transition || !m_actor->GetModel()->GetAnimation() )
|
|
|
|
m_actor->GetModel()->SetAnimation( m_actor->GetObject()->m_WalkAnim );
|
|
|
|
|
|
|
|
CVector2D delta = current->m_data[0].entity->m_position - m_position;
|
|
|
|
|
|
|
|
float adjRange = m_meleeRange + m_bounds->m_radius + current->m_data[0].entity->m_bounds->m_radius;
|
|
|
|
float adjMinRange = m_meleeRangeMin + m_bounds->m_radius + current->m_data[0].entity->m_bounds->m_radius;
|
|
|
|
|
|
|
|
if( delta.within( adjMinRange ) )
|
|
|
|
{
|
|
|
|
// Too close... do nothing.
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !delta.within( adjRange ) )
|
|
|
|
{
|
|
|
|
// Too far away at the moment, chase after the target...
|
|
|
|
// We're aiming to end up at a location just inside our maximum range
|
|
|
|
// (is this good enough?)
|
|
|
|
|
|
|
|
delta = delta.normalize() * ( adjRange - m_bounds->m_radius );
|
|
|
|
|
|
|
|
current->m_data[0].location = (CVector2D)current->m_data[0].entity->m_position - delta;
|
|
|
|
|
|
|
|
HEntity collide;
|
|
|
|
switch( processGotoHelper( current, timestep_millis, collide ) )
|
|
|
|
{
|
|
|
|
case ALREADY_AT_DESTINATION:
|
|
|
|
case REACHED_DESTINATION:
|
|
|
|
case COLLISION_WITH_DESTINATION:
|
|
|
|
// Not too far any more...
|
|
|
|
break;
|
|
|
|
case NORMAL:
|
|
|
|
// May or may not be close enough, check...
|
|
|
|
// (Assuming the delta above will never take us within minimum range)
|
|
|
|
delta = current->m_data[0].entity->m_position - m_position;
|
|
|
|
if( delta.within( adjRange ) )
|
|
|
|
break;
|
|
|
|
// Otherwise, continue chasing
|
|
|
|
return( false );
|
|
|
|
default:
|
|
|
|
// Path around it.
|
|
|
|
|
|
|
|
CEntityOrder avoidance;
|
|
|
|
avoidance.m_type = CEntityOrder::ORDER_GOTO_COLLISION;
|
|
|
|
CVector2D right;
|
|
|
|
right.x = m_ahead.y; right.y = -m_ahead.x;
|
|
|
|
CVector2D avoidancePosition;
|
|
|
|
|
|
|
|
// Which is the shortest diversion, going left or right?
|
|
|
|
// (Weight a little towards the right, to stop both units dodging the same way)
|
|
|
|
|
|
|
|
if( ( collide->m_bounds->m_pos - m_bounds->m_pos ).dot( right ) < 1 )
|
|
|
|
{
|
|
|
|
// Turn right.
|
|
|
|
avoidancePosition = collide->m_bounds->m_pos + right * ( collide->m_bounds->m_radius + m_bounds->m_radius * 2.5f );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Turn left.
|
|
|
|
avoidancePosition = collide->m_bounds->m_pos - right * ( collide->m_bounds->m_radius + m_bounds->m_radius * 2.5f );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a short path representing this detour
|
|
|
|
|
|
|
|
avoidance.m_data[0].location = avoidancePosition;
|
|
|
|
if( current->m_type == CEntityOrder::ORDER_GOTO_COLLISION )
|
|
|
|
m_orderQueue.pop_front();
|
|
|
|
m_orderQueue.push_front( avoidance );
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Close enough, but turn to face them.
|
|
|
|
m_orientation = atan2( delta.x, delta.y );
|
|
|
|
m_ahead = delta.normalize();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now we've got this far:
|
|
|
|
// Pointy end goes into the other man...
|
|
|
|
|
|
|
|
CEventAttack AttackEvent( current->m_data[0].entity );
|
|
|
|
|
|
|
|
if( DispatchEvent( &AttackEvent ) )
|
|
|
|
m_actor->GetModel()->SetAnimation( m_actor->GetObject()->m_MeleeAnim, true );
|
2004-07-23 12:56:52 +02:00
|
|
|
|
2004-05-28 04:57:50 +02:00
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
bool CEntity::processGoto( CEntityOrder* current, size_t timestep_millis )
|
2004-05-28 04:57:50 +02:00
|
|
|
{
|
2004-07-27 23:00:53 +02:00
|
|
|
float timestep=timestep_millis/1000.0f;
|
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
CVector2D pos( m_position.X, m_position.Z );
|
2004-05-29 05:32:33 +02:00
|
|
|
CVector2D path_to = current->m_data[0].location;
|
2004-05-28 04:57:50 +02:00
|
|
|
m_orderQueue.pop_front();
|
2004-07-23 12:56:52 +02:00
|
|
|
|
|
|
|
// Let's just check we're going somewhere...
|
2004-07-20 21:30:35 +02:00
|
|
|
if( ( path_to - pos ).length() < 0.1f )
|
|
|
|
return( false );
|
2004-07-23 12:56:52 +02:00
|
|
|
|
2004-11-11 08:09:32 +01:00
|
|
|
if( m_transition )
|
2004-05-28 04:57:50 +02:00
|
|
|
{
|
2004-05-29 22:58:11 +02:00
|
|
|
m_actor->GetModel()->SetAnimation( m_actor->GetObject()->m_WalkAnim );
|
2004-11-11 08:09:32 +01:00
|
|
|
// Animation desync
|
2004-05-29 22:58:11 +02:00
|
|
|
m_actor->GetModel()->Update( ( rand() * 1000.0f ) / 1000.0f );
|
2004-05-28 04:57:50 +02:00
|
|
|
}
|
2004-07-23 12:56:52 +02:00
|
|
|
|
|
|
|
// The pathfinder will push its result back into this unit's queue.
|
|
|
|
|
2004-05-29 05:32:33 +02:00
|
|
|
g_Pathfinder.requestPath( me, path_to );
|
2004-08-03 01:14:54 +02:00
|
|
|
|
2004-05-28 04:57:50 +02:00
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
bool CEntity::processPatrol( CEntityOrder* current, size_t timestep_millis )
|
2004-05-28 04:57:50 +02:00
|
|
|
{
|
2004-07-27 23:00:53 +02:00
|
|
|
float timestep=timestep_millis/1000.0f;
|
|
|
|
|
2004-05-28 04:57:50 +02:00
|
|
|
CEntityOrder this_segment;
|
|
|
|
CEntityOrder repeat_patrol;
|
2004-07-23 12:56:52 +02:00
|
|
|
|
|
|
|
// Duplicate the patrol order, push one copy onto the start of our order queue
|
|
|
|
// (that's the path we'll be taking next) and one copy onto the end of the
|
|
|
|
// queue (to keep us patrolling)
|
|
|
|
|
2004-05-28 04:57:50 +02:00
|
|
|
this_segment.m_type = CEntityOrder::ORDER_GOTO;
|
|
|
|
this_segment.m_data[0] = current->m_data[0];
|
|
|
|
repeat_patrol.m_type = CEntityOrder::ORDER_PATROL;
|
|
|
|
repeat_patrol.m_data[0] = current->m_data[0];
|
|
|
|
m_orderQueue.pop_front();
|
|
|
|
m_orderQueue.push_front( this_segment );
|
|
|
|
m_orderQueue.push_back( repeat_patrol );
|
|
|
|
return( true );
|
2004-06-02 18:11:32 +02:00
|
|
|
}
|