combat: only move back if there's no wall behind the bot
This commit is contained in:
parent
d121f2a163
commit
587064e897
3 changed files with 25 additions and 5 deletions
|
|
@ -400,6 +400,7 @@ private:
|
||||||
bool isBlockedRight ();
|
bool isBlockedRight ();
|
||||||
bool checkWallOnLeft ();
|
bool checkWallOnLeft ();
|
||||||
bool checkWallOnRight ();
|
bool checkWallOnRight ();
|
||||||
|
bool checkWallOnBehind ();
|
||||||
bool updateNavigation ();
|
bool updateNavigation ();
|
||||||
bool isEnemyThreat ();
|
bool isEnemyThreat ();
|
||||||
bool isWeaponRestricted (int wid);
|
bool isWeaponRestricted (int wid);
|
||||||
|
|
|
||||||
|
|
@ -1314,8 +1314,14 @@ void Bot::attackMovement () {
|
||||||
|
|
||||||
// only take cover when bomb is not planted and enemy can see the bot or the bot is VIP
|
// only take cover when bomb is not planted and enemy can see the bot or the bot is VIP
|
||||||
if (!game.is (GameFlags::CSDM)) {
|
if (!game.is (GameFlags::CSDM)) {
|
||||||
if (m_retreatTime < game.time () && (m_states & Sense::SeeingEnemy) && approach < 30 && !bots.isBombPlanted () && (isInViewCone (m_enemy->v.origin) || m_isVIP)) {
|
if ((m_states & Sense::SeeingEnemy) && approach < 30 && !bots.isBombPlanted () && (isInViewCone (m_enemy->v.origin) || m_isVIP)) {
|
||||||
startTask (Task::SeekCover, TaskPri::SeekCover, kInvalidNodeIndex, 0.0f, true);
|
if (m_retreatTime < game.time ()) {
|
||||||
|
startTask (Task::SeekCover, TaskPri::SeekCover, kInvalidNodeIndex, 0.0f, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!checkWallOnBehind ()) {
|
||||||
|
m_moveSpeed = -pev->maxspeed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (approach < 50) {
|
else if (approach < 50) {
|
||||||
m_moveSpeed = 0.0f;
|
m_moveSpeed = 0.0f;
|
||||||
|
|
|
||||||
|
|
@ -658,7 +658,7 @@ void Bot::checkTerrain (float movedDistance, const Vector &dirNormal) {
|
||||||
dirLeft = true;
|
dirLeft = true;
|
||||||
}
|
}
|
||||||
const auto &testDir = m_moveSpeed > 0.0f ? forward : -forward;
|
const auto &testDir = m_moveSpeed > 0.0f ? forward : -forward;
|
||||||
constexpr float kBlockDistance = 42.0f;
|
constexpr float kBlockDistance = 52.0f;
|
||||||
|
|
||||||
// now check which side is blocked
|
// now check which side is blocked
|
||||||
src = pev->origin + right * kBlockDistance;
|
src = pev->origin + right * kBlockDistance;
|
||||||
|
|
@ -2987,7 +2987,7 @@ bool Bot::isBlockedRight () {
|
||||||
|
|
||||||
bool Bot::checkWallOnLeft () {
|
bool Bot::checkWallOnLeft () {
|
||||||
TraceResult tr {};
|
TraceResult tr {};
|
||||||
game.testLine (pev->origin, pev->origin - pev->angles.right () * 42.0f, TraceIgnore::Monsters, ent (), &tr);
|
game.testLine (pev->origin, pev->origin - pev->angles.right () * 52.0f, TraceIgnore::Monsters, ent (), &tr);
|
||||||
|
|
||||||
// check if the trace hit something...
|
// check if the trace hit something...
|
||||||
if (tr.flFraction < 1.0f) {
|
if (tr.flFraction < 1.0f) {
|
||||||
|
|
@ -3000,7 +3000,20 @@ bool Bot::checkWallOnRight () {
|
||||||
TraceResult tr {};
|
TraceResult tr {};
|
||||||
|
|
||||||
// do a trace to the right...
|
// do a trace to the right...
|
||||||
game.testLine (pev->origin, pev->origin + pev->angles.right () * 42.0f, TraceIgnore::Monsters, ent (), &tr);
|
game.testLine (pev->origin, pev->origin + pev->angles.right () * 52.0f, TraceIgnore::Monsters, ent (), &tr);
|
||||||
|
|
||||||
|
// check if the trace hit something...
|
||||||
|
if (tr.flFraction < 1.0f) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bot::checkWallOnBehind () {
|
||||||
|
TraceResult tr {};
|
||||||
|
|
||||||
|
// do a trace to the right...
|
||||||
|
game.testLine (pev->origin, pev->origin - pev->angles.forward () * 52.0f, TraceIgnore::Monsters, ent (), &tr);
|
||||||
|
|
||||||
// check if the trace hit something...
|
// check if the trace hit something...
|
||||||
if (tr.flFraction < 1.0f) {
|
if (tr.flFraction < 1.0f) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue