Let me help you a bit:
in bot.cpp, there is the cBot class written. In the function cBot::Aim() the bot aims at a vector given as argument in that function. Now, we look where Aim() is called...
hence! it is called in the function below, called AimAtEnemy()
at the bottom of AimAtEnemy you see Aim() being called. The function AimAtEnemy looks like this:
Code:
/******************************************************************************
Function purpose: Aims at enemy, only when valid. Based upon skill how it 'aims'
******************************************************************************/
void cBot::AimAtEnemy ()
{
// No (valid) enem pointer? -> bail out
if (pBotEnemy == NULL)
return;
Vector vVecEnd = pBotEnemy->v.origin + pBotEnemy->v.view_ofs;
// We cannot see our enemy? -> bail out
if ((f_blinded_time > gpGlobals->time) ||
(!(FInViewCone (&vVecEnd, pEdict) && FVisible (vVecEnd, pEdict))))
{
Aim(v_enemy);
return;
}
// ------------------------ we can see enemy -------------------------
Vector vTarget;
float fDistance;
float fScale = 0.0;
// Distance to enemy
fDistance = (pBotEnemy->v.origin - pEdict->v.origin).Length ();
// Scale this
fScale = fDistance / 2500;
if (fScale > 0.9)
fScale = 0.9;
// Super skill requires little differentation
if (bot_skill == 0)
fScale = 0.05;
if (CarryWeaponType () == SNIPER)
fScale = 0.01;
// Set target here
vTarget = pBotEnemy->v.origin;
if (bot_skill <= 1)
vTarget = pBotEnemy->v.origin + pBotEnemy->v.view_ofs + Vector (0, 0, -16);
else if (bot_skill > 1 && bot_skill < 4)
vTarget = pBotEnemy->v.origin + pBotEnemy->v.view_ofs * RANDOM_FLOAT (0.5, 1.1);
else if (bot_skill > 3 && bot_skill < 5)
vTarget = pBotEnemy->v.origin;
else if (bot_skill > 4)
vTarget = pBotEnemy->v.origin + Vector (0, 0, -32);
// Based uppon how far, we make this fuzzy
float fDx, fDy, fDz;
fDx = fDy = fDz = 0.0;
// Equals SKILL
fDx = fDy = fDz = (bot_skill * fScale);
vTarget = vTarget + Vector (RANDOM_FLOAT (-fDx, fDx), RANDOM_FLOAT (-fDy, fDy), RANDOM_FLOAT (-fDz, fDz));
// Add Offset
fDx = fpXOffset;
fDy = fpYOffset;
fDz = fpZOffset;
// Set extra offset
vTarget = vTarget + Vector (RANDOM_FLOAT (-fDx, fDx), RANDOM_FLOAT (-fDy, fDy), RANDOM_FLOAT (-fDz, fDz));
// When holding a grenade, do this aiming.
if (current_weapon.iId == CS_WEAPON_HEGRENADE
|| current_weapon.iId == CS_WEAPON_FLASHBANG)
{
vTarget = vTarget + Vector (0, 0, 50);
}
Aim (vTarget); // Aim
}