refactor: split very long statements [skip ci]

This commit is contained in:
jeefo 2025-02-28 05:44:52 +03:00
commit f9aa608a6a
No known key found for this signature in database
GPG key ID: D696786B81B667C8
6 changed files with 38 additions and 8 deletions

View file

@ -2411,7 +2411,9 @@ bool Bot::reactOnEnemy () {
bool Bot::lastEnemyShootable () { bool Bot::lastEnemyShootable () {
// don't allow shooting through walls // don't allow shooting through walls
if (!(m_aimFlags & (AimFlags::LastEnemy | AimFlags::PredictPath)) || m_lastEnemyOrigin.empty () || game.isNullEntity (m_lastEnemy)) { if (!(m_aimFlags & (AimFlags::LastEnemy | AimFlags::PredictPath))
|| m_lastEnemyOrigin.empty ()
|| game.isNullEntity (m_lastEnemy)) {
return false; return false;
} }
return util.getConeDeviation (ent (), m_lastEnemyOrigin) >= 0.90f && isPenetrableObstacle (m_lastEnemyOrigin); return util.getConeDeviation (ent (), m_lastEnemyOrigin) >= 0.90f && isPenetrableObstacle (m_lastEnemyOrigin);
@ -2422,7 +2424,13 @@ void Bot::checkRadioQueue () {
// don't allow bot listen you if bot is busy // don't allow bot listen you if bot is busy
if (m_radioOrder != Radio::ReportInTeam && (getCurrentTaskId () == Task::DefuseBomb || getCurrentTaskId () == Task::PlantBomb || m_hasHostage || m_hasC4 || m_isCreature)) { if (m_radioOrder != Radio::ReportInTeam
&& (getCurrentTaskId () == Task::DefuseBomb
|| getCurrentTaskId () == Task::PlantBomb
|| m_hasHostage
|| m_hasC4
|| m_isCreature)) {
m_radioOrder = 0; m_radioOrder = 0;
return; return;
} }

View file

@ -666,7 +666,11 @@ Vector Bot::getBodyOffsetError (float distance) {
const float hitError = distance / (cr::clamp (static_cast <float> (m_difficulty), 1.0f, 4.0f) * 1280.0f); const float hitError = distance / (cr::clamp (static_cast <float> (m_difficulty), 1.0f, 4.0f) * 1280.0f);
const auto &maxs = m_enemy->v.maxs, &mins = m_enemy->v.mins; const auto &maxs = m_enemy->v.maxs, &mins = m_enemy->v.mins;
m_aimLastError = Vector (rg (mins.x * hitError, maxs.x * hitError), rg (mins.y * hitError, maxs.y * hitError), rg (mins.z * hitError * 0.5f, maxs.z * hitError * 0.5f)); m_aimLastError = Vector (
rg (mins.x * hitError, maxs.x * hitError),
rg (mins.y * hitError, maxs.y * hitError),
rg (mins.z * hitError * 0.5f, maxs.z * hitError * 0.5f)
);
const auto &aimError = conf.getDifficultyTweaks (m_difficulty)->aimError; const auto &aimError = conf.getDifficultyTweaks (m_difficulty)->aimError;
m_aimLastError += Vector (rg (-aimError.x, aimError.x), rg (-aimError.y, aimError.y), rg (-aimError.z, aimError.z)); m_aimLastError += Vector (rg (-aimError.x, aimError.x), rg (-aimError.y, aimError.y), rg (-aimError.z, aimError.z));

View file

@ -243,7 +243,9 @@ void BotConfig::loadChatterConfig () {
MemFile file {}; MemFile file {};
// chatter initialization // chatter initialization
if (game.is (GameFlags::HasBotVoice) && cv_radio_mode.as <int> () == 2 && openConfig ("chatter", "Couldn't open chatter system configuration", &file)) { if (game.is (GameFlags::HasBotVoice) && cv_radio_mode.as <int> () == 2
&& openConfig ("chatter", "Couldn't open chatter system configuration", &file)) {
m_chatter.clear (); m_chatter.clear ();
struct EventMap { struct EventMap {

View file

@ -2384,7 +2384,12 @@ void BotGraph::frame () {
message.assignf (" %s node:\n" message.assignf (" %s node:\n"
" Node %d of %d, Radius: %.1f, Light: %s\n" " Node %d of %d, Radius: %.1f, Light: %s\n"
" Flags: %s\n" " Flags: %s\n"
" Origin: (%.1f, %.1f, %.1f)\n", type, node, m_paths.length () - 1, p.radius, cr::fequal (p.light, kInvalidLightLevel) ? "Invalid" : strings.format ("%1.f", p.light), flags, p.origin.x, p.origin.y, p.origin.z); " Origin: (%.1f, %.1f, %.1f)\n",
type, node, m_paths.length () - 1, p.radius,
cr::fequal (p.light, kInvalidLightLevel) ? "Invalid" : strings.format ("%1.f", p.light),
flags, p.origin.x, p.origin.y, p.origin.z
);
return message; return message;
}; };
@ -2410,7 +2415,12 @@ void BotGraph::frame () {
String practiceText {}; String practiceText {};
practiceText.assignf (" Node practice data (index / damage):\n" practiceText.assignf (" Node practice data (index / damage):\n"
" CT: %d / %d\n" " CT: %d / %d\n"
" T: %d / %d\n\n", dangerIndexCT, dangerIndexCT != kInvalidNodeIndex ? practice.getDamage (Team::CT, nearestIndex, dangerIndexCT) : 0, dangerIndexT, dangerIndexT != kInvalidNodeIndex ? practice.getDamage (Team::Terrorist, nearestIndex, dangerIndexT) : 0); " T: %d / %d\n\n",
dangerIndexCT,
dangerIndexCT != kInvalidNodeIndex ? practice.getDamage (Team::CT, nearestIndex, dangerIndexCT) : 0,
dangerIndexT,
dangerIndexT != kInvalidNodeIndex ? practice.getDamage (Team::Terrorist, nearestIndex, dangerIndexT) : 0
);
sendHudMessage ({ 255, 255, 255 }, 0.0f, 0.16f, practiceText + timeMessage); sendHudMessage ({ 255, 255, 255 }, 0.0f, 0.16f, practiceText + timeMessage);
} }

View file

@ -1329,7 +1329,8 @@ void Bot::throwSmoke_ () {
void Bot::doublejump_ () { void Bot::doublejump_ () {
if (!util.isAlive (m_doubleJumpEntity) if (!util.isAlive (m_doubleJumpEntity)
|| (m_aimFlags & AimFlags::Enemy) || (m_aimFlags & AimFlags::Enemy)
|| (m_travelStartIndex != kInvalidNodeIndex && getTask ()->time + (graph.calculateTravelTime (pev->maxspeed, graph[m_travelStartIndex].origin, m_doubleJumpOrigin) + 11.0f) < game.time ())) { || (m_travelStartIndex != kInvalidNodeIndex
&& getTask ()->time + (graph.calculateTravelTime (pev->maxspeed, graph[m_travelStartIndex].origin, m_doubleJumpOrigin) + 11.0f) < game.time ())) {
resetDoubleJump (); resetDoubleJump ();
return; return;
} }

View file

@ -586,7 +586,12 @@ void Bot::setAimDirection () {
} }
const bool horizontalMovement = (m_pathFlags & NodeFlag::Ladder) || isOnLadder (); const bool horizontalMovement = (m_pathFlags & NodeFlag::Ladder) || isOnLadder ();
if (m_numEnemiesLeft > 0 && m_canChooseAimDirection && m_seeEnemyTime + 4.0f < game.time () && m_currentNodeIndex != kInvalidNodeIndex && !horizontalMovement) { if (m_numEnemiesLeft > 0
&& m_canChooseAimDirection
&& m_seeEnemyTime + 4.0f < game.time ()
&& m_currentNodeIndex != kInvalidNodeIndex
&& !horizontalMovement) {
const auto dangerIndex = practice.getIndex (m_team, m_currentNodeIndex, m_currentNodeIndex); const auto dangerIndex = practice.getIndex (m_team, m_currentNodeIndex, m_currentNodeIndex);
if (graph.exists (dangerIndex) if (graph.exists (dangerIndex)