fix: bot kick menu isn't functional
nav: probably fix for ladder climbing (ref #544 ref #319) bot: implemented [RSE] Neoptolemus's fix for msec calculation (round vs int cast)
This commit is contained in:
parent
4128b27cf4
commit
df9bc66023
6 changed files with 52 additions and 23 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit 721b245b0ed971b643f64ccb9366500df6e7895b
|
||||
Subproject commit 2d7a426b69102e3c6c07f2503240ed21f69c1143
|
||||
|
|
@ -561,9 +561,7 @@ private:
|
|||
}
|
||||
|
||||
// get run player move angles
|
||||
const Vector &getRpmAngles () {
|
||||
return getCurrentTaskId () == Task::Attack ? pev->v_angle : m_moveAngles;
|
||||
}
|
||||
const Vector &getRpmAngles ();
|
||||
|
||||
public:
|
||||
entvars_t *pev {};
|
||||
|
|
|
|||
|
|
@ -3713,12 +3713,6 @@ Vector Bot::isBombAudible () {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
uint8_t Bot::computeMsec () {
|
||||
// estimate msec to use for this command based on time passed from the previous command
|
||||
|
||||
return static_cast <uint8_t> (cr::min (static_cast <int32_t> ((game.time () - m_lastCommandTime) * 1000.0f), 255));
|
||||
}
|
||||
|
||||
bool Bot::canRunHeavyWeight () {
|
||||
constexpr auto interval = 1.0f / 10.0f;
|
||||
|
||||
|
|
@ -3730,6 +3724,21 @@ bool Bot::canRunHeavyWeight () {
|
|||
return false;
|
||||
}
|
||||
|
||||
uint8_t Bot::computeMsec () {
|
||||
// estimate msec to use for this command based on time passed from the previous command
|
||||
|
||||
return static_cast <uint8_t> (cr::min (static_cast <int32_t> (cr::roundf ((game.time () - m_lastCommandTime) * 1000.0f)), 255));
|
||||
}
|
||||
|
||||
const Vector &Bot::getRpmAngles () {
|
||||
// get angles to pass to run player move function
|
||||
|
||||
if ((m_pathFlags & NodeFlag::Ladder) || getCurrentTaskId () == Task::Attack) {
|
||||
return pev->v_angle;
|
||||
}
|
||||
return m_moveAngles;
|
||||
}
|
||||
|
||||
void Bot::runMovement () {
|
||||
// the purpose of this function is to compute, according to the specified computation
|
||||
// method, the msec value which will be passed as an argument of pfnRunPlayerMove. This
|
||||
|
|
|
|||
|
|
@ -2060,8 +2060,8 @@ void BotControl::kickBotByMenu (int page) {
|
|||
for (int i = menuKey; i < page * 8; ++i) {
|
||||
auto bot = bots[i];
|
||||
|
||||
// check for fakeclient bit, since we're clear it upon kick, but actual bot struct destroyed after client disconnected
|
||||
if (bot != nullptr && (bot->pev->flags & FL_FAKECLIENT)) {
|
||||
// check for dormant bit, since we're adds it upon kick, but actual bot struct destroyed after client disconnected
|
||||
if (bot != nullptr && !(bot->pev->flags & FL_DORMANT)) {
|
||||
menuKeys |= cr::bit (cr::abs (i - menuKey));
|
||||
menus.appendf ("%1.1d. %s%s\n", i - menuKey + 1, bot->pev->netname.chars (), bot->m_team == Team::CT ? " \\y(CT)\\w" : " \\r(T)\\w");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -944,12 +944,15 @@ bool Bot::updateNavigation () {
|
|||
}
|
||||
|
||||
if (m_pathFlags & NodeFlag::Ladder) {
|
||||
if (m_pathOrigin.z >= (pev->origin.z + 16.0f)) {
|
||||
const float ladderDistance = pev->origin.distance (m_pathOrigin);
|
||||
|
||||
if (m_pathOrigin.z >= pev->origin.z + 16.0f) {
|
||||
constexpr auto kLadderOffset = Vector (0.0f, 0.0f, 16.0f);
|
||||
|
||||
m_pathOrigin = m_path->origin + kLadderOffset;
|
||||
}
|
||||
else if (m_pathOrigin.z < pev->origin.z + 16.0f && !isOnLadder () && isOnFloor () && !isDucking ()) {
|
||||
m_moveSpeed = pev->origin.distance (m_pathOrigin);
|
||||
m_moveSpeed = ladderDistance;
|
||||
|
||||
if (m_moveSpeed < 150.0f) {
|
||||
m_moveSpeed = 150.0f;
|
||||
|
|
@ -958,6 +961,17 @@ bool Bot::updateNavigation () {
|
|||
m_moveSpeed = pev->maxspeed;
|
||||
}
|
||||
}
|
||||
const auto prevNodeIndex = m_previousNodes[0];
|
||||
|
||||
// do a precise movement when very near
|
||||
if (graph.exists (prevNodeIndex) && !(graph[prevNodeIndex].flags & NodeFlag::Ladder) && ladderDistance < 64.0f) {
|
||||
m_moveSpeed = pev->maxspeed * 0.4f;
|
||||
|
||||
// do not duck while not on ladder
|
||||
if (!isOnLadder ()) {
|
||||
pev->button &= ~IN_DUCK;
|
||||
}
|
||||
}
|
||||
|
||||
// special detection if someone is using the ladder (to prevent to have bots-towers on ladders)
|
||||
for (const auto &client : util.getClients ()) {
|
||||
|
|
@ -1059,15 +1073,21 @@ bool Bot::updateNavigation () {
|
|||
|
||||
++m_tryOpenDoor;
|
||||
|
||||
if (m_tryOpenDoor > 2 && util.isAlive (m_lastEnemy)) {
|
||||
if (isPenetrableObstacle (m_lastEnemy->v.origin) && !cv_ignore_enemies.bool_ ()) {
|
||||
if (m_tryOpenDoor > 2) {
|
||||
edict_t *nearest = nullptr;
|
||||
|
||||
// try to find nearest enemy (maybe behind a door)
|
||||
util.findNearestPlayer (reinterpret_cast <void **> (&nearest), ent (), 192.0f, false, false, true, true, false);
|
||||
|
||||
// check if enemy is penetrable
|
||||
if (util.isAlive (nearest) && isPenetrableObstacle (nearest->v.origin) && !cv_ignore_enemies.bool_ ()) {
|
||||
m_seeEnemyTime = game.time ();
|
||||
|
||||
m_states |= Sense::SeeingEnemy | Sense::SuspectEnemy;
|
||||
m_aimFlags |= AimFlags::Enemy;
|
||||
|
||||
m_enemy = m_lastEnemy;
|
||||
m_lastEnemyOrigin = m_lastEnemy->v.origin;
|
||||
m_enemy = nearest;
|
||||
m_lastEnemyOrigin = nearest->v.origin;
|
||||
|
||||
m_tryOpenDoor = 0;
|
||||
}
|
||||
|
|
@ -1098,7 +1118,7 @@ bool Bot::updateNavigation () {
|
|||
}
|
||||
}
|
||||
else if (isOnLadder () || (m_pathFlags & NodeFlag::Ladder)) {
|
||||
desiredDistanceSq = cr::sqrf (24.0f);
|
||||
desiredDistanceSq = cr::sqrf (14.0f);
|
||||
}
|
||||
else if (m_currentTravelFlags & PathFlag::Jump) {
|
||||
desiredDistanceSq = 0.0f;
|
||||
|
|
@ -1161,7 +1181,7 @@ bool Bot::updateNavigation () {
|
|||
else if (m_pathWalk.empty ()) {
|
||||
return false;
|
||||
}
|
||||
int taskTarget = getTask ()->data;
|
||||
const int taskTarget = getTask ()->data;
|
||||
|
||||
if (game.mapIs (MapFlags::Demolition)
|
||||
&& bots.isBombPlanted ()
|
||||
|
|
@ -2203,7 +2223,7 @@ bool Bot::selectBestNextNode () {
|
|||
}
|
||||
|
||||
bool Bot::advanceMovement () {
|
||||
// advances in our pathfinding list and sets the appropiate destination origins for this bot
|
||||
// advances in our pathfinding list and sets the appropriate destination origins for this bot
|
||||
|
||||
findValidNode (); // check if old nodes is still reliable
|
||||
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ void Bot::setAimDirection () {
|
|||
if (onLadder && m_pathWalk.hasNext ()) {
|
||||
const auto &nextPath = graph[m_pathWalk.next ()];
|
||||
|
||||
if ((nextPath.flags & NodeFlag::Ladder) && m_destOrigin.distanceSq (pev->origin) < cr::sqrf (120.0f) && nextPath.origin.z > m_pathOrigin.z + 30.0f) {
|
||||
if ((nextPath.flags & NodeFlag::Ladder) && m_destOrigin.distanceSq (pev->origin) < cr::sqrf (128.0f) && nextPath.origin.z > m_pathOrigin.z + 30.0f) {
|
||||
m_lookAt = nextPath.origin;
|
||||
}
|
||||
}
|
||||
|
|
@ -357,8 +357,10 @@ void Bot::changeYaw (float speed) {
|
|||
}
|
||||
|
||||
void Bot::updateBodyAngles () {
|
||||
constexpr float kValue = 1.0f / 3.0f;
|
||||
|
||||
// set the body angles to point the gun correctly
|
||||
pev->angles.x = -pev->v_angle.x * (1.0f / 3.0f);
|
||||
pev->angles.x = -pev->v_angle.x * kValue;
|
||||
pev->angles.y = pev->v_angle.y;
|
||||
|
||||
pev->angles.clampAngles ();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue