chatter: do not respect timers while discconnecting bot (ref #424 )

combat: tweaked combat behavior a little (do not use strafe in narrow places)
This commit is contained in:
jeefo 2023-04-03 11:55:01 +03:00
commit 38f2716edb
No known key found for this signature in database
GPG key ID: 927BCA0779BEA8ED
4 changed files with 20 additions and 13 deletions

View file

@ -1061,7 +1061,7 @@ public:
void pushMsgQueue (int message); void pushMsgQueue (int message);
void prepareChatMessage (StringRef message); void prepareChatMessage (StringRef message);
void checkForChat (); void checkForChat ();
void showChaterIcon (bool show); void showChaterIcon (bool show, bool disconnect = false);
void clearSearchNodes (); void clearSearchNodes ();
void checkBreakable (edict_t *touch); void checkBreakable (edict_t *touch);
void checkBreakablesAround (); void checkBreakablesAround ();

View file

@ -945,7 +945,7 @@ void Bot::getCampDirection (Vector *dest) {
} }
} }
void Bot::showChaterIcon (bool show) { void Bot::showChaterIcon (bool show, bool disconnect) {
// this function depending on show boolen, shows/remove chatter, icon, on the head of bot. // this function depending on show boolen, shows/remove chatter, icon, on the head of bot.
if (!game.is (GameFlags::HasBotVoice) || cv_radio_mode.int_ () != 2) { if (!game.is (GameFlags::HasBotVoice) || cv_radio_mode.int_ () != 2) {
@ -959,12 +959,15 @@ void Bot::showChaterIcon (bool show) {
}; };
int ownIndex = index (); int ownIndex = index ();
// do not respect timers while disconnecting bot
for (auto &client : util.getClients ()) { for (auto &client : util.getClients ()) {
if (!(client.flags & ClientFlags::Used) || (client.ent->v.flags & FL_FAKECLIENT) || client.team != m_team) { if (!(client.flags & ClientFlags::Used) || (client.ent->v.flags & FL_FAKECLIENT) || client.team != m_team) {
continue; continue;
} }
if (!show && (client.iconFlags[ownIndex] & ClientFlags::Icon) && client.iconTimestamp[ownIndex] < game.time ()) { // do not respect timers while disconnecting bot
if (!show && (client.iconFlags[ownIndex] & ClientFlags::Icon) && (disconnect || client.iconTimestamp[ownIndex] < game.time ())) {
sendBotVoice (false, client.ent, entindex ()); sendBotVoice (false, client.ent, entindex ());
client.iconTimestamp[ownIndex] = 0.0f; client.iconTimestamp[ownIndex] = 0.0f;

View file

@ -1163,7 +1163,7 @@ void Bot::attackMovement () {
if (m_lastFightStyleCheck + 3.0f < game.time ()) { if (m_lastFightStyleCheck + 3.0f < game.time ()) {
int rand = rg.get (1, 100); int rand = rg.get (1, 100);
if (distance < 768.0f) { if (distance < 500.0f) {
m_fightStyle = Fight::Strafe; m_fightStyle = Fight::Strafe;
} }
else if (distance < 1024.0f) { else if (distance < 1024.0f) {
@ -1175,7 +1175,7 @@ void Bot::attackMovement () {
} }
} }
else { else {
if (rand < (usesSubmachine () ? 80 : 93)) { if (rand < (usesSubmachine () ? 80 : 90)) {
m_fightStyle = Fight::Stay; m_fightStyle = Fight::Stay;
} }
else { else {
@ -1185,7 +1185,7 @@ void Bot::attackMovement () {
m_lastFightStyleCheck = game.time (); m_lastFightStyleCheck = game.time ();
} }
} }
else { else if (rg.get (0, 100) < (isInNarrowPlace () ? 25 : 100)) {
m_fightStyle = Fight::Strafe; m_fightStyle = Fight::Strafe;
} }
@ -1210,7 +1210,7 @@ void Bot::attackMovement () {
if (rg.chance (30)) { if (rg.chance (30)) {
m_combatStrafeDir = (m_combatStrafeDir == Dodge::Left ? Dodge::Right : Dodge::Left); m_combatStrafeDir = (m_combatStrafeDir == Dodge::Left ? Dodge::Right : Dodge::Left);
} }
m_strafeSetTime = game.time () + rg.get (1.3f, 3.0f); m_strafeSetTime = game.time () + rg.get (1.0f, 3.0f);
} }
if (m_combatStrafeDir == Dodge::Right) { if (m_combatStrafeDir == Dodge::Right) {
@ -1219,7 +1219,7 @@ void Bot::attackMovement () {
} }
else { else {
m_combatStrafeDir = Dodge::Left; m_combatStrafeDir = Dodge::Left;
m_strafeSetTime = game.time () + rg.get (1.2f, 1.5f); m_strafeSetTime = game.time () + rg.get (1.0f, 1.5f);
} }
} }
else { else {
@ -1228,7 +1228,7 @@ void Bot::attackMovement () {
} }
else { else {
m_combatStrafeDir = Dodge::Right; m_combatStrafeDir = Dodge::Right;
m_strafeSetTime = game.time () + rg.get (1.2f, 1.5f); m_strafeSetTime = game.time () + rg.get (1.0f, 1.5f);
} }
} }
@ -1236,7 +1236,7 @@ void Bot::attackMovement () {
pev->button |= IN_JUMP; pev->button |= IN_JUMP;
} }
} }
else if (m_fightStyle == Fight::Stay) { else {
if ((m_enemyParts & (Visibility::Head | Visibility::Body)) && getCurrentTaskId () != Task::SeekCover && getCurrentTaskId () != Task::Hunt) { if ((m_enemyParts & (Visibility::Head | Visibility::Body)) && getCurrentTaskId () != Task::SeekCover && getCurrentTaskId () != Task::Hunt) {
int enemyNearestIndex = graph.getNearest (m_enemy->v.origin); int enemyNearestIndex = graph.getNearest (m_enemy->v.origin);
@ -1252,7 +1252,7 @@ void Bot::attackMovement () {
if (m_difficulty >= Difficulty::Hard && isOnFloor () && (m_duckTime < game.time ())) { if (m_difficulty >= Difficulty::Hard && isOnFloor () && (m_duckTime < game.time ())) {
if (distance < 768.0f) { if (distance < 768.0f) {
if (rg.get (0, 1000) < 10 && pev->velocity.length2d () > 150.0f && isInViewCone (m_enemy->v.origin)) { if (rg.get (0, 1000) < rg.get (5, 10) && pev->velocity.length2d () > 150.0f && isInViewCone (m_enemy->v.origin)) {
pev->button |= IN_JUMP; pev->button |= IN_JUMP;
} }
} }
@ -1262,7 +1262,11 @@ void Bot::attackMovement () {
Vector right, forward; Vector right, forward;
pev->v_angle.angleVectors (&forward, &right, nullptr); pev->v_angle.angleVectors (&forward, &right, nullptr);
if (isDeadlyMove (pev->origin + (forward * m_moveSpeed * 0.2f) + (right * m_strafeSpeed * 0.2f) + (pev->velocity * getFrameInterval ()))) { const auto &front = right * m_moveSpeed * 0.2f;
const auto &side = right * m_strafeSpeed * 0.2f;
const auto &spot = pev->origin + front + side + pev->velocity * getFrameInterval ();
if (isDeadlyMove (spot)) {
m_strafeSpeed = -m_strafeSpeed; m_strafeSpeed = -m_strafeSpeed;
m_moveSpeed = -m_moveSpeed; m_moveSpeed = -m_moveSpeed;

View file

@ -1488,7 +1488,7 @@ void Bot::kick () {
} }
void Bot::markStale () { void Bot::markStale () {
showChaterIcon (false); showChaterIcon (false, true);
// clear the bot name // clear the bot name
conf.clearUsedName (this); conf.clearUsedName (this);