** Total Edit **
Alright, well I managed to get SteveC's CBaseEntity trick to work with my bots and got my bots to follow me whilst they look in the same direction (they don't look at me to follow me).
I have an example movie of a bot doing this here:
http://rcbot.bots-united.com/downloa...er/botmove.zip
The movement is actually the same as HL1 but the QAngles were between 0 and 360 instead of -180 and 180, which was confusing me.
PHP Code:
void CBot :: doMove ()
{
// Temporary measure to make bot follow me when i make listen serevr
setMoveTo(CBotGlobals::entityOrigin(INDEXENT(1)));
if ( moveToIsValid () )
{
float flMove = 0.0;
float flSide = 0.0;
m_fIdealMoveSpeed = 320;
// fAngle is got from world realting to bots origin, not angles
float fAngle = CBotGlobals::yawAngleFromEdict(m_pEdict,m_vMoveTo);
// fl Move is percentage (0 to 1) of forward speed,
// flSide is percentage (0 to 1) of side speed.
float radians = fAngle * 3.141592f / 180.0f; // degrees to radians
flMove = cos(radians);
flSide = sin(radians);
m_fForwardSpeed = m_fIdealMoveSpeed * flMove;
// dont want this to override strafe speed if we're trying
// to strafe to avoid a wall for instance.
if ( m_fStrafeTime < engine->Time() )
{
// side speed
m_fSideSpeed = m_fIdealMoveSpeed * flSide;
}
// moving less than 1.0 units/sec? just stop to
// save bot jerking around..
if ( fabs(m_fForwardSpeed) < 1.0 )
m_fForwardSpeed = 0.0;
if ( fabs(m_fSideSpeed) < 1.0 )
m_fSideSpeed = 0.0;
}
else
{
m_fForwardSpeed = 0;
// bots side move speed
m_fSideSpeed = 0;
// bots upward move speed (e.g in water)
m_fUpSpeed = 0;
}
}
To get the angle, here is the code i used:
PHP Code:
float CBotGlobals :: yawAngleFromEdict (edict_t *pEntity,Vector vOrigin)
{
float fAngle;
QAngle qBotAngles = entityEyeAngles(pEntity);
QAngle qAngles;
Vector vAngles;
vAngles = vOrigin - entityOrigin(pEntity);
// Just get the angles from world
VectorAngles(vAngles,qAngles);
// NEED to put 0-360 angles from -180 to 180 to get negative and positive values
fixFloatAngle(&qBotAngles.y);
//fAngle = qAngles.y; // world angles
fAngle = qBotAngles.y - qAngles.y;
fixFloatAngle(&fAngle);
return fAngle;
}
you NEED CBaseEntity to get eye angles
PHP Code:
QAngle CBotGlobals :: entityEyeAngles ( edict_t *pEntity )
{
CBaseEntity *pBaseEntity = CBaseEntity::Instance(pEntity);
return pBaseEntity->EyeAngles();
}