combat: increase check-wall distance when attacking enemies (ref #620)

This commit is contained in:
jeefo 2025-02-15 21:47:05 +03:00
commit 9fe9e08dfa
No known key found for this signature in database
GPG key ID: D696786B81B667C8
3 changed files with 14 additions and 11 deletions

View file

@ -402,9 +402,9 @@ private:
bool canStrafeRight (TraceResult *tr);
bool isBlockedLeft ();
bool isBlockedRight ();
bool checkWallOnLeft ();
bool checkWallOnRight ();
bool checkWallOnBehind ();
bool checkWallOnLeft (float distance = 40.0f);
bool checkWallOnRight (float distance = 40.0f);
bool checkWallOnBehind (float distance = 40.0f);
bool updateNavigation ();
bool isEnemyThreat ();
bool isWeaponRestricted (int wid);

View file

@ -1547,8 +1547,8 @@ void Bot::attackMovement () {
m_strafeSetTime = strafeUpdateTime ();
}
const bool wallOnRight = checkWallOnRight ();
const bool wallOnLeft = checkWallOnLeft ();
const bool wallOnRight = checkWallOnRight (72.0f);
const bool wallOnLeft = checkWallOnLeft (72.0f);
if (m_dodgeStrafeDir == Dodge::Left) {
if (!wallOnLeft) {
@ -1584,7 +1584,10 @@ void Bot::attackMovement () {
// do not move if inside "corridor"
if (wallOnRight && wallOnLeft) {
m_strafeSpeed = 0.0f;
m_moveSpeed = 0.0f;
m_strafeSetTime = game.time () + 3.0f;
m_dodgeStrafeDir = Dodge::None;
}
// we're setting strafe speed regardless of move angles, so not resetting forward move here cause bots to behave strange

View file

@ -3091,9 +3091,9 @@ bool Bot::isBlockedRight () {
return false;
}
bool Bot::checkWallOnLeft () {
bool Bot::checkWallOnLeft (float distance) {
TraceResult tr {};
game.testLine (pev->origin, pev->origin - pev->angles.right () * 40.0f, TraceIgnore::Monsters, ent (), &tr);
game.testLine (pev->origin, pev->origin - pev->angles.right () * distance, TraceIgnore::Monsters, ent (), &tr);
// check if the trace hit something...
if (tr.flFraction < 1.0f) {
@ -3102,11 +3102,11 @@ bool Bot::checkWallOnLeft () {
return false;
}
bool Bot::checkWallOnRight () {
bool Bot::checkWallOnRight (float distance) {
TraceResult tr {};
// do a trace to the right...
game.testLine (pev->origin, pev->origin + pev->angles.right () * 40.0f, TraceIgnore::Monsters, ent (), &tr);
game.testLine (pev->origin, pev->origin + pev->angles.right () * distance, TraceIgnore::Monsters, ent (), &tr);
// check if the trace hit something...
if (tr.flFraction < 1.0f) {
@ -3115,11 +3115,11 @@ bool Bot::checkWallOnRight () {
return false;
}
bool Bot::checkWallOnBehind () {
bool Bot::checkWallOnBehind (float distance) {
TraceResult tr {};
// do a trace to the right...
game.testLine (pev->origin, pev->origin - pev->angles.forward () * 40.0f, TraceIgnore::Monsters, ent (), &tr);
game.testLine (pev->origin, pev->origin - pev->angles.forward () * distance, TraceIgnore::Monsters, ent (), &tr);
// check if the trace hit something...
if (tr.flFraction < 1.0f) {