refactor: split very long statements [skip ci]
This commit is contained in:
parent
6c7f232d8d
commit
f9aa608a6a
6 changed files with 38 additions and 8 deletions
|
|
@ -2411,7 +2411,9 @@ bool Bot::reactOnEnemy () {
|
|||
|
||||
bool Bot::lastEnemyShootable () {
|
||||
// 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 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
|
||||
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;
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 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;
|
||||
m_aimLastError += Vector (rg (-aimError.x, aimError.x), rg (-aimError.y, aimError.y), rg (-aimError.z, aimError.z));
|
||||
|
|
|
|||
|
|
@ -243,7 +243,9 @@ void BotConfig::loadChatterConfig () {
|
|||
MemFile file {};
|
||||
|
||||
// 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 ();
|
||||
|
||||
struct EventMap {
|
||||
|
|
|
|||
|
|
@ -2384,7 +2384,12 @@ void BotGraph::frame () {
|
|||
message.assignf (" %s node:\n"
|
||||
" Node %d of %d, Radius: %.1f, Light: %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;
|
||||
};
|
||||
|
||||
|
|
@ -2410,7 +2415,12 @@ void BotGraph::frame () {
|
|||
String practiceText {};
|
||||
practiceText.assignf (" Node practice data (index / damage):\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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1329,7 +1329,8 @@ void Bot::throwSmoke_ () {
|
|||
void Bot::doublejump_ () {
|
||||
if (!util.isAlive (m_doubleJumpEntity)
|
||||
|| (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 ();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -586,7 +586,12 @@ void Bot::setAimDirection () {
|
|||
}
|
||||
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);
|
||||
|
||||
if (graph.exists (dangerIndex)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue