nav: rusher bots does not care any danger (idea from pbmm) nav: some changes in collision motion

This commit is contained in:
commandcobra7 2024-02-04 15:32:13 +03:00 committed by GitHub
commit eea78ac031
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 113 additions and 205 deletions

View file

@ -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);