nav: rusher bots does not care any danger (idea from pbmm) nav: some changes in collision motion
This commit is contained in:
parent
9e48175e67
commit
eea78ac031
4 changed files with 113 additions and 205 deletions
|
|
@ -277,6 +277,66 @@ void Bot::checkDarkness () {
|
|||
m_checkDarkTime = game.time () + rg.get (2.0f, 4.0f);
|
||||
}
|
||||
|
||||
void Bot::changePitch (float speed) {
|
||||
// this function turns a bot towards its ideal_pitch
|
||||
|
||||
const float idealPitch = cr::wrapAngle (pev->idealpitch);
|
||||
const float curent = cr::wrapAngle (pev->v_angle.x);
|
||||
|
||||
// turn from the current v_angle pitch to the idealpitch by selecting
|
||||
// the quickest way to turn to face that direction
|
||||
|
||||
// find the difference in the curent and ideal angle
|
||||
float normalizePitch = cr::wrapAngle (idealPitch - curent);
|
||||
|
||||
if (normalizePitch > 0.0f) {
|
||||
if (normalizePitch > speed) {
|
||||
normalizePitch = speed;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (normalizePitch < -speed) {
|
||||
normalizePitch = -speed;
|
||||
}
|
||||
}
|
||||
pev->v_angle.x = cr::wrapAngle (curent + normalizePitch);
|
||||
|
||||
if (pev->v_angle.x > 89.9f) {
|
||||
pev->v_angle.x = 89.9f;
|
||||
}
|
||||
|
||||
if (pev->v_angle.x < -89.9f) {
|
||||
pev->v_angle.x = -89.9f;
|
||||
}
|
||||
pev->angles.x = -pev->v_angle.x / 3;
|
||||
}
|
||||
|
||||
void Bot::changeYaw (float speed) {
|
||||
// this function turns a bot towards its ideal_yaw
|
||||
|
||||
const float idealPitch = cr::wrapAngle (pev->ideal_yaw);
|
||||
const float curent = cr::wrapAngle (pev->v_angle.y);
|
||||
|
||||
// turn from the current v_angle yaw to the ideal_yaw by selecting
|
||||
// the quickest way to turn to face that direction
|
||||
|
||||
// find the difference in the curent and ideal angle
|
||||
float normalizePitch = cr::wrapAngle (idealPitch - curent);
|
||||
|
||||
if (normalizePitch > 0.0f) {
|
||||
if (normalizePitch > speed) {
|
||||
normalizePitch = speed;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (normalizePitch < -speed) {
|
||||
normalizePitch = -speed;
|
||||
}
|
||||
}
|
||||
pev->v_angle.y = cr::wrapAngle (curent + normalizePitch);
|
||||
pev->angles.y = pev->v_angle.y;
|
||||
}
|
||||
|
||||
void Bot::updateBodyAngles () {
|
||||
// set the body angles to point the gun correctly
|
||||
pev->angles.x = -pev->v_angle.x * (1.0f / 3.0f);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue