From 196059b1f35a7e1c2867adbc0ca639e2c5aa4815 Mon Sep 17 00:00:00 2001 From: Ryan Hunter Date: Sat, 29 Jan 2022 16:57:00 +0000 Subject: [PATCH] Increased rotate speed and reduced team report spam --- bot.h | 4 +- bot_combat.cpp | 2 +- bot_job_functions.cpp | 14 ++--- bot_job_think.cpp | 97 ++++++++++++++++---------------- bot_navigate.cpp | 128 +++++++++++++++++++++--------------------- bot_start.cpp | 8 +-- changelog.txt | 10 +++- dll.cpp | 24 ++++---- engine.cpp | 2 +- util.cpp | 16 +++--- waypoint.cpp | 50 ++++++++--------- 11 files changed, 181 insertions(+), 174 deletions(-) diff --git a/bot.h b/bot.h index f05d2951..02206408 100644 --- a/bot.h +++ b/bot.h @@ -79,8 +79,8 @@ template void bzero(U *ptr, size_t len) noexcept { } } -#define BOT_PITCH_SPEED 20 -#define BOT_YAW_SPEED 20 +#define BOT_PITCH_SPEED 30 +#define BOT_YAW_SPEED 30 #define RESPAWN_IDLE 1 #define RESPAWN_NEED_TO_RESPAWN 2 diff --git a/bot_combat.cpp b/bot_combat.cpp index 7bcc18d5..bca07836 100644 --- a/bot_combat.cpp +++ b/bot_combat.cpp @@ -737,7 +737,7 @@ static edict_t *BotFindEnemy(bot_t *pBot) { player_is_ally = false; // is team play enabled? - if (is_team_play > 0.0) { + if (is_team_play > 0) { player_team = UTIL_GetTeam(pPlayer); // don't target your teammates... diff --git a/bot_job_functions.cpp b/bot_job_functions.cpp index 73ae05da..f59a5db6 100644 --- a/bot_job_functions.cpp +++ b/bot_job_functions.cpp @@ -172,7 +172,7 @@ int JobGetUnstuck(bot_t *pBot) { UTIL_TraceLine(pBot->pEdict->v.origin, v_forwards, dont_ignore_monsters, pBot->pEdict->v.pContainingEntity, &tr); // if the new view angle is clear or a blockage is not too near - if (tr.flFraction >= 1.0 || !VectorsNearerThan(pBot->pEdict->v.origin, tr.vecEndPos, 80)) { + if (tr.flFraction >= 1 || !VectorsNearerThan(pBot->pEdict->v.origin, tr.vecEndPos, 80)) { job_ptr->origin = tr.vecEndPos; // remember where to go job_ptr->phase = 1; job_ptr->phase_timer = pBot->f_think_time + random_float(1.0, 3.0); @@ -202,7 +202,7 @@ int JobGetUnstuck(bot_t *pBot) { pBot->pEdict->v.button |= IN_JUMP; // wandered long enough? - if (job_ptr->phase_timer < pBot->f_think_time || (pBot->pEdict->v.origin - job_ptr->origin).Length2D() < 20.0) { + if (job_ptr->phase_timer < pBot->f_think_time || (pBot->pEdict->v.origin - job_ptr->origin).Length2D() < 20) { BlacklistJob(pBot, job_get_unstuck, 1.0); // don't get caught in a loop return JOB_TERMINATED; } @@ -302,7 +302,7 @@ int JobReport(bot_t *pBot) { job_ptr->phase = 1; // create a delay so the bot can "type" - job_ptr->phase_timer = pBot->f_think_time + random_float(2.0, 5.0); + job_ptr->phase_timer = pBot->f_think_time + random_float(5.0, 10.0); } } @@ -1285,7 +1285,7 @@ int JobBuffAlly(bot_t *pBot) { // if the patient is moving about then heal them to full health only const float patientVelocity = job_ptr->player->v.velocity.Length(); - if (patientVelocity > 50.0 && job_ptr->player->v.health >= job_ptr->player->v.max_health) + if (patientVelocity > 50 && job_ptr->player->v.health >= job_ptr->player->v.max_health) return JOB_TERMINATED; } @@ -1302,7 +1302,7 @@ int JobBuffAlly(bot_t *pBot) { if (job_ptr->phase == 1) { // go for the ally if they are near and visible const float allyDistance = (pBot->pEdict->v.origin - job_ptr->player->v.origin).Length(); - if (allyDistance < 500.1 && FVisible(job_ptr->player->v.origin + job_ptr->player->v.view_ofs, pBot->pEdict)) { + if (allyDistance < 500 && FVisible(job_ptr->player->v.origin + job_ptr->player->v.view_ofs, pBot->pEdict)) { job_ptr->phase = 2; return JOB_UNDERWAY; } @@ -1339,7 +1339,7 @@ int JobBuffAlly(bot_t *pBot) { // go back to looking for the patient if they disappear from view const float allyDistance = (pBot->pEdict->v.origin - job_ptr->player->v.origin).Length(); - if (allyDistance >= 500.1 || !FVisible(job_ptr->player->v.origin + job_ptr->player->v.view_ofs, pBot->pEdict)) { + if (allyDistance >= 500 || !FVisible(job_ptr->player->v.origin + job_ptr->player->v.view_ofs, pBot->pEdict)) { job_ptr->phase = 0; return JOB_UNDERWAY; } @@ -1902,7 +1902,7 @@ int JobSnipe(bot_t *pBot) { const int nextWP = WaypointRouteFromTo(pBot->current_wp, job_ptr->waypoint, pBot->current_team); // near enough to the waypoint the bot can walk to it whilst charging the rifle? - if (pBot->pEdict->v.flags & FL_ONGROUND && (pBot->current_wp == job_ptr->waypoint || nextWP == job_ptr->waypoint) && zDiff > -45.1 && zDiff < 15.0 // walkable step height(hopefully) + if (pBot->pEdict->v.flags & FL_ONGROUND && (pBot->current_wp == job_ptr->waypoint || nextWP == job_ptr->waypoint) && zDiff > -45 && zDiff < 15 // walkable step height(hopefully) && VectorsNearerThan(waypoints[job_ptr->waypoint].origin, pBot->pEdict->v.origin, 200.0) && FVisible(waypoints[job_ptr->waypoint].origin, pBot->pEdict)) { // minimum time to charge rifle based on skill level // (skills 4 - 5 shouldn't pre-charge) diff --git a/bot_job_think.cpp b/bot_job_think.cpp index c2c40354..bab8cac7 100644 --- a/bot_job_think.cpp +++ b/bot_job_think.cpp @@ -123,50 +123,50 @@ static jobFunctions_struct jf[job_type_total] = { // list of essential data for all known job types // these must be in the right order for each job to run properly job_list_struct jl[job_type_total] = { //Only handles 32 not 45? [APG]RoboCop[CL] - {PRIORITY_MAXIMUM, {job_get_unstuck}}, - {800, {job_capture_flag}}, + {PRIORITY_MAXIMUM, {job_capture_flag}}, + {800, {job_get_unstuck}}, {790, {job_maintain_object}}, {780, {job_push_button}}, {770, {job_build_sentry}}, - {760, {job_drown_recover}}, {750, {job_pickup_flag}}, - {740, {job_bin_grenade}}, - {730, {job_avoid_area_damage}}, - {720, {job_concussion_jump}}, - {710, {job_get_flag}}, - {700, {job_spot_stimulus}}, - {690, {job_build_teleport}}, - {680, {job_use_teleport}}, - {670, {job_defend_flag}}, - {650, {job_pursue_enemy}}, - {640, {job_get_ammo}}, - {630, {job_disguise}}, - {620, {job_buff_ally}}, - {610, {job_escort_ally}}, - {600, {job_investigate_area}}, - {590, {job_attack_breakable}}, - {580, {job_report}}, - {570, {job_seek_backup}}, - {560, {job_snipe}}, - {520, {job_build_dispenser}}, - {510, {job_infected_attack}}, - {500, {job_seek_waypoint}}, - {490, {job_pickup_item}}, - {480, {job_call_medic}}, // this should be a higher priority than job_get_health - {470, {job_get_health}}, - {460, {job_get_armor}}, // Bots appear to maybe not go beyond this line as the max is 32 tasks and could be out of range? [APG]RoboCop[CL] - {450, {job_attack_teleport}}, - {430, {job_pipetrap}}, + {720, {job_drown_recover}}, + {710, {job_bin_grenade}}, + {700, {job_avoid_area_damage}}, + {680, {job_get_flag}}, + {660, {job_concussion_jump}}, + {650, {job_spot_stimulus}}, + {640, {job_build_teleport}}, + {630, {job_use_teleport}}, + {620, {job_attack_breakable}}, + {610, {job_build_dispenser}}, + {600, {job_defend_flag}}, + {590, {job_snipe}}, + {580, {job_buff_ally}}, + {570, {job_disguise}}, + {560, {job_pursue_enemy}}, + {550, {job_escort_ally}}, + {540, {job_investigate_area}}, + {530, {job_infected_attack}}, + {520, {job_report}}, + {510, {job_get_ammo}}, + {500, {job_get_armor}}, + {490, {job_seek_backup}}, + {480, {job_pickup_item}}, + {470, {job_call_medic}}, // this should be a higher priority than job_get_health + {460, {job_get_health}}, + {450, {job_avoid_enemy}}, // Bots appear to maybe not go beyond this line as the max is 32 tasks and could be out of range? [APG]RoboCop[CL] + {440, {job_seek_waypoint}}, + {430, {job_attack_teleport}}, + {420, {job_pipetrap}}, {410, {job_detpack_waypoint}}, {400, {job_chat}}, - {380, {job_rocket_jump}}, // Reduced RJ until fix is provided [APG]RoboCop[CL] - {350, {job_harrass_defense}}, - {300, {job_avoid_enemy}}, + {350, {job_rocket_jump}}, // Reduced RJ until fix is provided [APG]RoboCop[CL] + {300, {job_harrass_defense}}, {250, {job_guard_waypoint}}, {220, {job_melee_warrior}}, - {210, {job_patrol_home}}, - {200, {job_graffiti_artist}}, - {190, {job_feign_ambush}}, + {200, {job_patrol_home}}, + {150, {job_graffiti_artist}}, + {100, {job_feign_ambush}}, {0, {job_roam}}, }; @@ -434,7 +434,7 @@ void BotRunJobs(bot_t *pBot) { // abort if no jobs were found in the buffer if (pBot->jobType[pBot->currentJob] == job_none) { // if the buffer is completely empty, add JOB_ROAM as a backup - if (pBot->f_killed_time + 3.0 < pBot->f_think_time) { + if (pBot->f_killed_time + 3 < pBot->f_think_time) { job_struct *newJob = InitialiseNewJob(pBot, job_roam); if (newJob != nullptr) SubmitNewJob(pBot, job_roam, newJob); @@ -500,7 +500,7 @@ void BotJobThink(bot_t *pBot) { } // need armor(e.g. just spawned)? - if ((PlayerArmorPercent(pBot->pEdict) < pBot->trait.health || pBot->f_killed_time + 3.1 > pBot->f_think_time) && pBot->f_periodicAlert3 < pBot->f_think_time && random_float(1, 1000) > 600) { + if ((PlayerArmorPercent(pBot->pEdict) < pBot->trait.health || pBot->f_killed_time + 3 > pBot->f_think_time) && pBot->f_periodicAlert3 < pBot->f_think_time && random_float(1, 1000) > 600) { newJob = InitialiseNewJob(pBot, job_get_armor); if (newJob != nullptr) { newJob->waypoint = WaypointFindNearestGoal(pBot->current_wp, pBot->current_team, 3000, W_FL_ARMOR); @@ -526,14 +526,14 @@ void BotJobThink(bot_t *pBot) { } // call for a medic? - if (pBot->pEdict->v.playerclass != TFC_CLASS_MEDIC && PlayerHealthPercent(pBot->pEdict) < pBot->trait.health && pBot->enemy.f_lastSeen + 3.0 < pBot->f_think_time) { + if (pBot->pEdict->v.playerclass != TFC_CLASS_MEDIC && PlayerHealthPercent(pBot->pEdict) < pBot->trait.health && pBot->enemy.f_lastSeen + 3 < pBot->f_think_time) { // just call if the bot isn't going anywhere if (pBot->current_wp == pBot->goto_wp) { if (pBot->currentJob > -1 && pBot->jobType[pBot->currentJob] != job_get_health && FriendlyClassTotal(pBot->pEdict, TFC_CLASS_MEDIC, false) > 0 && random_long(0, 1000) < 200) FakeClientCommand(pBot->pEdict, "saveme", nullptr, nullptr); } // if the bot saw a medic recently make it a job to call and wait for them - else if (pBot->f_alliedMedicSeenTime + 5.0 > pBot->f_think_time && (newJob = InitialiseNewJob(pBot, job_call_medic)) != nullptr) { + else if (pBot->f_alliedMedicSeenTime + 5 > pBot->f_think_time && (newJob = InitialiseNewJob(pBot, job_call_medic)) != nullptr) { const int healthJobIndex = BufferedJobIndex(pBot, job_get_health); // if infected or not going for health already call the seen medic @@ -555,7 +555,7 @@ void BotJobThink(bot_t *pBot) { pBot->f_humour_time = pBot->f_think_time + random_float(60.0, 180.0); // no mucking about if enemies were recently seen or the bot spawned recently - if (pBot->enemy.f_lastSeen + 40.0 < pBot->f_think_time && pBot->f_killed_time + 40.0 < pBot->f_think_time && BufferedJobIndex(pBot, job_melee_warrior) == -1 && BufferedJobIndex(pBot, job_graffiti_artist) == -1 && + if (pBot->enemy.f_lastSeen + 40 < pBot->f_think_time && pBot->f_killed_time + 40 < pBot->f_think_time && BufferedJobIndex(pBot, job_melee_warrior) == -1 && BufferedJobIndex(pBot, job_graffiti_artist) == -1 && random_long(1, 200) < pBot->trait.humour) { // take your pick of fun things to do if (random_long(1, 1000) > 400) { @@ -575,7 +575,8 @@ void BotJobThink(bot_t *pBot) { case TFC_CLASS_CIVILIAN: break; case TFC_CLASS_SCOUT: - // FakeClientCommand(pBot->pEdict, "slot3", nullptr, nullptr); + //pBot->f_think_time = 0.5f; + //FakeClientCommand(pBot->pEdict, "slot3", nullptr, nullptr); break; case TFC_CLASS_SNIPER: // go snipe @@ -606,12 +607,14 @@ void BotJobThink(bot_t *pBot) { case TFC_CLASS_PYRO: break; case TFC_CLASS_MEDIC: - // FakeClientCommand(pBot->pEdict, "slot3", nullptr, nullptr); + //pBot->f_think_time = 0.5f; + //FakeClientCommand(pBot->pEdict, "slot3", nullptr, nullptr); break; case TFC_CLASS_SPY: - // FakeClientCommand(pBot->pEdict, "slot1", nullptr, nullptr); + //pBot->f_think_time = 0.5f; + //FakeClientCommand(pBot->pEdict, "slot1", nullptr, nullptr); // time for a disguise? - if (pBot->enemy.f_lastSeen + 2.0 < pBot->f_think_time) { + if (pBot->enemy.f_lastSeen + 2 < pBot->f_think_time) { if (pBot->current_team == UTIL_GetTeamColor(pBot->pEdict)) { newJob = InitialiseNewJob(pBot, job_disguise); if (newJob != nullptr && SubmitNewJob(pBot, job_disguise, newJob) == true) @@ -628,7 +631,7 @@ void BotJobThink(bot_t *pBot) { pBot->f_spyFeignAmbushTime = pBot->f_think_time + random_float(12.0, 24.0); newJob = InitialiseNewJob(pBot, job_feign_ambush); - if (newJob != nullptr && pBot->enemy.f_lastSeen + 3.0 < pBot->f_think_time && pBot->current_wp > -1 && spawnAreaWP[pBot->current_team] > -1 && spawnAreaWP[pBot->current_team] < num_waypoints) { + if (newJob != nullptr && pBot->enemy.f_lastSeen + 3 < pBot->f_think_time && pBot->current_wp > -1 && spawnAreaWP[pBot->current_team] > -1 && spawnAreaWP[pBot->current_team] < num_waypoints) { const int homeDistance = WaypointDistanceFromTo(spawnAreaWP[pBot->current_team], pBot->current_wp, pBot->current_team); // if the bot has left respawn behind and the area is suitable start a @@ -641,7 +644,7 @@ void BotJobThink(bot_t *pBot) { break; case TFC_CLASS_ENGINEER: BotEngineerThink(pBot); - // FakeClientCommand(pBot->pEdict, "slot1", nullptr, nullptr); + FakeClientCommand(pBot->pEdict, "slot1", nullptr, nullptr); break; default: break; diff --git a/bot_navigate.cpp b/bot_navigate.cpp index 61b3cdde..7d38ed23 100644 --- a/bot_navigate.cpp +++ b/bot_navigate.cpp @@ -145,14 +145,14 @@ void BotFindCurrentWaypoint(bot_t *pBot) { // if the waypoint is above the bot only remember it in case no // other waypoint could be found(higher waypoints may be unreachable) - if (pBot->pEdict->v.origin.z + 50.0 < waypoints[index].origin.z) { + if (pBot->pEdict->v.origin.z + 50 < waypoints[index].origin.z) { if (runnerUp == -1 && distance_squared < 640000.0) // 800 * 800 = 640000 { // check if the waypoint is visible to the bot UTIL_TraceLine(pBot->pEdict->v.origin, waypoints[index].origin, dont_ignore_monsters, pBot->pEdict->v.pContainingEntity, &tr); // it is visible, so store it - if (tr.flFraction >= 1.0) + if (tr.flFraction >= 1) runnerUp = index; } @@ -165,7 +165,7 @@ void BotFindCurrentWaypoint(bot_t *pBot) { UTIL_TraceLine(pBot->pEdict->v.origin, waypoints[index].origin, dont_ignore_monsters, pBot->pEdict->v.pContainingEntity, &tr); // it is visible, so store it - if (tr.flFraction >= 1.0) { + if (tr.flFraction >= 1) { min_index = index; min_distance_squared = distance_squared; } @@ -181,7 +181,7 @@ void BotFindCurrentWaypoint(bot_t *pBot) { pBot->f_current_wp_deadline = pBot->f_think_time + BOT_WP_DEADLINE; // if the bot just spawned make sure it has a current waypoint - if (pBot->current_wp != -1 && pBot->f_killed_time + 4.0 > pBot->f_think_time) { + if (pBot->current_wp != -1 && pBot->f_killed_time + 4 > pBot->f_think_time) { BotUpdateHomeInfo(pBot); // if the bot just spawned, report where // WaypointDrawBeam(INDEXENT(1), pBot->pEdict->v.origin + Vector(0, 0, 70), @@ -383,7 +383,7 @@ void BotNavigateWaypointless(bot_t *pBot) { const float botVelocity = pBot->pEdict->v.velocity.Length(); // is the bot getting stuck? - if (botVelocity < 50.0) { + if (botVelocity < 50) { const int jumpResult = BotShouldJumpOver(pBot); if (jumpResult == 2) // can the bot jump onto something? { @@ -452,9 +452,9 @@ bool BotNavigateWaypoints(bot_t *pBot, bool navByStrafe) { pBot->f_side_speed = 0.0; // is it time to consider taking some kind of route shortcut? - if (pBot->f_shortcutCheckTime < pBot->f_think_time || pBot->f_shortcutCheckTime - 60.0 > pBot->f_think_time) // sanity check + if (pBot->f_shortcutCheckTime < pBot->f_think_time || pBot->f_shortcutCheckTime - 60 > pBot->f_think_time) // sanity check { - pBot->f_shortcutCheckTime = pBot->f_think_time + 1.0; + pBot->f_shortcutCheckTime = pBot->f_think_time + 1; if (BotFindTeleportShortCut(pBot) == false && pBot->bot_skill < 4) { if (pBot->pEdict->v.playerclass == TFC_CLASS_MEDIC || pBot->pEdict->v.playerclass == TFC_CLASS_SCOUT) @@ -488,7 +488,7 @@ bool BotNavigateWaypoints(bot_t *pBot, bool navByStrafe) { // is the bot the nearest to the waypoint it's been so far? // (add 1.0 because we want to see sizeable, significant progress) - if (waypointDistance + 1.0 < pBot->f_progressToWaypoint) { + if (waypointDistance + 1 < pBot->f_progressToWaypoint) { pBot->f_progressToWaypoint = waypointDistance; // no problem - so reset this @@ -508,12 +508,12 @@ bool BotNavigateWaypoints(bot_t *pBot, bool navByStrafe) { if (!botIsSniping && pBot->f_navProblemStartTime > 0.1 && pBot->f_navProblemStartTime + 0.5 < pBot->f_think_time) { // face the waypoint when navigation is getting hindered // and it's been going on for too long - if (pBot->enemy.ptr == nullptr || pBot->f_navProblemStartTime + 4.0 < pBot->f_think_time) + if (pBot->enemy.ptr == nullptr || pBot->f_navProblemStartTime + 4 < pBot->f_think_time) navByStrafe = false; // buoyed by water, or on a ladder? if ((pBot->pEdict->v.waterlevel > WL_FEET_IN_WATER && !(pBot->pEdict->v.flags & FL_ONGROUND)) || pBot->pEdict->v.movetype == MOVETYPE_FLY) { - if (pBot->f_navProblemStartTime + 2.0 < pBot->f_think_time) { + if (pBot->f_navProblemStartTime + 2 < pBot->f_think_time) { job_struct *newJob = InitialiseNewJob(pBot, job_get_unstuck); if (newJob != nullptr) SubmitNewJob(pBot, job_get_unstuck, newJob); @@ -523,7 +523,7 @@ bool BotNavigateWaypoints(bot_t *pBot, bool navByStrafe) { // if the bot is airborne, duck(useful if jumping onto something) if (!(pBot->pEdict->v.flags & FL_ONGROUND)) { // in case the bot forgets it is duck-jumping - if (pBot->pEdict->v.velocity.z > 0.0) + if (pBot->pEdict->v.velocity.z > 0) pBot->f_duck_time = pBot->f_think_time + 0.3; } else // not airborne - time to try and get around an obstruction { @@ -545,7 +545,7 @@ bool BotNavigateWaypoints(bot_t *pBot, bool navByStrafe) { else if (jumpResult == 1 // 1 = blocked by something || duckResult == 1) { // try to get unstuck, but not too soon - if (pBot->f_navProblemStartTime + 2.0 < pBot->f_think_time) { + if (pBot->f_navProblemStartTime + 2 < pBot->f_think_time) { job_struct *newJob = InitialiseNewJob(pBot, job_get_unstuck); if (newJob != nullptr) SubmitNewJob(pBot, job_get_unstuck, newJob); @@ -580,11 +580,11 @@ bool BotNavigateWaypoints(bot_t *pBot, bool navByStrafe) { { // we don't know what's stalling the bot, but we can try a // few simple tricks(if the bots been stalled for 2 seconds or more) - if (pBot->f_navProblemStartTime + 2.0 < pBot->f_think_time) { + if (pBot->f_navProblemStartTime + 2 < pBot->f_think_time) { // if the bot is directly below it's current waypoint and not on a ladder // then assume the bot doesn't know it's fallen off and fix it - if (pBot->pEdict->v.flags & FL_ONGROUND && pBot->pEdict->v.waterlevel != WL_HEAD_IN_WATER && !(waypoints[pBot->current_wp].flags & W_FL_LIFT) && pBot->pEdict->v.origin.z + 60.0 < waypoints[pBot->current_wp].origin.z && - (pBot->pEdict->v.origin - waypoints[pBot->current_wp].origin).Length2D() < 15.0) { + if (pBot->pEdict->v.flags & FL_ONGROUND && pBot->pEdict->v.waterlevel != WL_HEAD_IN_WATER && !(waypoints[pBot->current_wp].flags & W_FL_LIFT) && pBot->pEdict->v.origin.z + 60 < waypoints[pBot->current_wp].origin.z && + (pBot->pEdict->v.origin - waypoints[pBot->current_wp].origin).Length2D() < 15) { // UTIL_HostSay(pBot->pEdict, 0, "fixed running vertically!"); ////DebugMessageOfDoom! BotFindCurrentWaypoint(pBot); @@ -592,8 +592,8 @@ bool BotNavigateWaypoints(bot_t *pBot, bool navByStrafe) { } // slow down for a couple of seconds(see if that helps) - if (pBot->enemy.ptr == nullptr && pBot->f_navProblemStartTime + 4.0 > pBot->f_think_time) - pBot->f_move_speed = pBot->f_max_speed / 2.0; + if (pBot->enemy.ptr == nullptr && pBot->f_navProblemStartTime + 4 > pBot->f_think_time) + pBot->f_move_speed = pBot->f_max_speed / 2; // some maps(e.g. hunted) have undetectable obstacles // jumping and/or ducking can overcome some of those @@ -622,9 +622,9 @@ bool BotNavigateWaypoints(bot_t *pBot, bool navByStrafe) { if (navByStrafe == false) { // slow the bot down as it approaches the final waypoint on it's route if (pBot->current_wp == pBot->goto_wp) { - if (current_wp_distance < 70.0) + if (current_wp_distance < 70) pBot->f_move_speed = pBot->f_max_speed / 4; - else if (current_wp_distance < 130.0) + else if (current_wp_distance < 130) pBot->f_move_speed = pBot->f_max_speed / 2; } @@ -707,7 +707,7 @@ bool BotHeadTowardWaypoint(bot_t *pBot, bool &r_navByStrafe) { if (r_navByStrafe == true && (waypoints[pBot->current_wp].flags & W_FL_LADDER || pBot->pEdict->v.movetype == MOVETYPE_FLY)) { if (pBot->enemy.ptr == nullptr) r_navByStrafe = false; - else if (pBot->f_navProblemStartTime > 0.1 && pBot->f_navProblemStartTime + 4.0 < pBot->f_think_time) + else if (pBot->f_navProblemStartTime > 0.1 && pBot->f_navProblemStartTime + 4 < pBot->f_think_time) r_navByStrafe = false; } @@ -735,13 +735,13 @@ bool BotHeadTowardWaypoint(bot_t *pBot, bool &r_navByStrafe) { const Vector offset = waypoints[pBot->current_wp].origin - pBot->pEdict->v.origin; Vector vang = UTIL_VecToAngles(offset); vang.y -= pBot->pEdict->v.v_angle.y; - vang.y = 360.0 - vang.y; + vang.y = 360 - vang.y; // wrap Y if need be if (vang.y < 0.0) - vang.y += 360.0; - else if (vang.y > 360.0) - vang.y -= 360.0; + vang.y += 360; + else if (vang.y > 360) + vang.y -= 360; /* // debug stuff char msg[96]; @@ -750,22 +750,22 @@ bool BotHeadTowardWaypoint(bot_t *pBot, bool &r_navByStrafe) { UTIL_HostSay(pBot->pEdict, 0, msg); //DebugMessageOfDoom!*/ // is the waypoint ahead? - if (vang.y > 275.0 || vang.y < 85.0) { + if (vang.y > 275 || vang.y < 85) { // do nothing, leave the bots forward speed as it is } // if the waypoint is behind, go backwards - else if (vang.y > 95.0 && vang.y < 265.0) + else if (vang.y > 95 && vang.y < 265) pBot->f_move_speed = -pBot->f_move_speed; else pBot->f_move_speed = 0.0; // waypoint is not ahead or behind // if the waypoint is on the left, sidestep left - if (vang.y > 185.0 && vang.y < 355.0) { + if (vang.y > 185 && vang.y < 355) { pBot->side_direction = SIDE_DIRECTION_LEFT; pBot->f_side_speed = -pBot->f_max_speed; } // if the waypoint is on the right, sidestep right - else if (vang.y > 5.0 && vang.y < 175.0) { + else if (vang.y > 5 && vang.y < 175) { pBot->side_direction = SIDE_DIRECTION_RIGHT; pBot->f_side_speed = pBot->f_max_speed; } else @@ -775,7 +775,7 @@ bool BotHeadTowardWaypoint(bot_t *pBot, bool &r_navByStrafe) { if (pBot->pEdict->v.waterlevel == WL_HEAD_IN_WATER || (pBot->pEdict->v.waterlevel == WL_WAIST_IN_WATER // on the surface && !(pBot->pEdict->v.flags & FL_ONGROUND))) { // swim up if below the waypoint - if (pBot->pEdict->v.origin.z < waypoints[pBot->current_wp].origin.z - 5.0) { + if (pBot->pEdict->v.origin.z < waypoints[pBot->current_wp].origin.z - 5) { // WaypointDrawBeam(INDEXENT(1), pBot->pEdict->v.origin + pBot->pEdict->v.view_ofs, // pBot->pEdict->v.origin + Vector(0, 0, 100.0), // 10, 2, 250, 250, 50, 200, 10); @@ -784,7 +784,7 @@ bool BotHeadTowardWaypoint(bot_t *pBot, bool &r_navByStrafe) { } // swim down if above the waypoint - else if (pBot->pEdict->v.origin.z > waypoints[pBot->current_wp].origin.z + 5.0) { + else if (pBot->pEdict->v.origin.z > waypoints[pBot->current_wp].origin.z + 5) { // WaypointDrawBeam(INDEXENT(1), pBot->pEdict->v.origin + pBot->pEdict->v.view_ofs, // pBot->pEdict->v.origin + Vector(0, 0, 100.0), // 10, 2, 250, 250, 250, 200, 10); @@ -855,11 +855,11 @@ static bool BotUpdateRoute(bot_t *pBot) { if (pBot->pEdict->v.movetype == MOVETYPE_FLY) { // if the bot is on a ladder make sure it is just above the waypoint needed_distance = 20.0; // got to be near when on a ladder - if (pBot->pEdict->v.origin.z < waypoints[new_current_wp].origin.z || pBot->pEdict->v.origin.z > waypoints[new_current_wp].origin.z + 10.0) + if (pBot->pEdict->v.origin.z < waypoints[new_current_wp].origin.z || pBot->pEdict->v.origin.z > waypoints[new_current_wp].origin.z + 10) heightCheck = false; } else if (waypoints[new_current_wp].flags & W_FL_JUMP) { // gotta be similar height or higher than jump waypoint - if (pBot->pEdict->v.origin.z < waypoints[new_current_wp].origin.z - 15.0 || pBot->pEdict->v.flags & FL_ONGROUND) + if (pBot->pEdict->v.origin.z < waypoints[new_current_wp].origin.z - 15 || pBot->pEdict->v.flags & FL_ONGROUND) heightCheck = false; needed_distance = 80.0; } else if (waypoints[new_current_wp].flags & W_FL_LIFT) @@ -875,14 +875,14 @@ static bool BotUpdateRoute(bot_t *pBot) { waypointTouched = true; } // this check can solve waypoint circling problems - else if (dist < 100.0 && pBot->f_navProblemStartTime > 0.1 && pBot->f_navProblemStartTime + 0.5 < pBot->f_think_time) { + else if (dist < 100 && pBot->f_navProblemStartTime > 0.1 && pBot->f_navProblemStartTime + 0.5 < pBot->f_think_time) { if (nextWP != -1 && nextWP != pBot->goto_wp) { const auto pathDistance = static_cast(WaypointDistanceFromTo(new_current_wp, nextWP, pBot->current_team)); const float distToNext = (waypoints[nextWP].origin - pBot->pEdict->v.origin).Length(); // see if the bot is near enough to the next waypoint despite // not touching the current waypoint - if (distToNext < pathDistance && dist + distToNext < pathDistance + 50.0) { + if (distToNext < pathDistance && dist + distToNext < pathDistance + 50) { // WaypointDrawBeam(INDEXENT(1), pBot->pEdict->v.origin, // pBot->pEdict->v.origin + Vector(0, 0, 100.0), // 10, 2, 250, 250, 250, 200, 10); @@ -944,7 +944,7 @@ static void BotHandleLadderTraffic(bot_t *pBot) { UTIL_TraceLine(pBot->pEdict->v.origin, pBot->pEdict->v.origin - Vector(0, 0, 120.0), dont_ignore_monsters, pBot->pEdict->v.pContainingEntity, &tr); // see if we detected a player below - if (tr.flFraction < 1.0 && tr.pHit != nullptr) { + if (tr.flFraction < 1 && tr.pHit != nullptr) { // search the world for players... for (int i = 1; i <= gpGlobals->maxClients; i++) { edict_t *pPlayer = INDEXENT(i); @@ -987,13 +987,13 @@ void BotUseLift(bot_t *pBot) { return;*/ // stop and wait when in line with the lift waypoint - if (distanceWP2D < 25.0) + if (distanceWP2D < 25) pBot->f_pause_time = pBot->f_think_time + 0.2; return; } else // current waypoint is a lift waypoint, as is the next waypoint on the route { // is the lift waypoint roughly the same altitude as the bot? - if (waypoints[pBot->current_wp].origin.z < pBot->pEdict->v.origin.z + 36.0 && waypoints[pBot->current_wp].origin.z > pBot->pEdict->v.origin.z - 36.0) { + if (waypoints[pBot->current_wp].origin.z < pBot->pEdict->v.origin.z + 36 && waypoints[pBot->current_wp].origin.z > pBot->pEdict->v.origin.z - 36) { bool liftReady = false; // traceline a short distance up from the waypoint to make sure @@ -1082,7 +1082,7 @@ static int BotShouldJumpOver(const bot_t *pBot) { // set how far apart the left and right scans will be, // decide randomly so that we increase the bots chances of detecting // a jumpable obstacle - const float aperture = 5.0 * static_cast(random_long(1, 3)); + const float aperture = 5 * static_cast(random_long(1, 3)); Vector v_source; @@ -1107,7 +1107,7 @@ static int BotShouldJumpOver(const bot_t *pBot) { UTIL_TraceLine(v_source, v_dest, dont_ignore_monsters, pBot->pEdict->v.pContainingEntity, &tr); // obstructed by something? - if (tr.flFraction < 1.0) { + if (tr.flFraction < 1) { // show where the traceline hit // WaypointDrawBeam(INDEXENT(1), v_source, v_dest, 10, 2, 250, 250, 250, 200, 10); @@ -1128,11 +1128,11 @@ static int BotShouldJumpOver(const bot_t *pBot) { // WaypointDrawBeam(INDEXENT(1), v_source, v_dest, 10, 2, 250, 250, 250, 200, 10); // if there is line of sight report that the bot can try jumping here - if (tr.flFraction >= 1.0) + if (tr.flFraction >= 1) return 2; // did the traceline go further then it did when traced from lower down the body? // if so then there appears to be some kind of ledge here - else if ((v_source - tr.vecEndPos).Length2D() > shinObstacleDistance + 1.0) + else if ((v_source - tr.vecEndPos).Length2D() > shinObstacleDistance + 1) return 2; else obstacleFound = true; @@ -1155,7 +1155,7 @@ static int BotShouldJumpOver(const bot_t *pBot) { UTIL_TraceLine(v_source, v_dest, dont_ignore_monsters, pBot->pEdict->v.pContainingEntity, &tr); // obstructed by something? - if (tr.flFraction < 1.0) { + if (tr.flFraction < 1) { // show where the traceline hit // WaypointDrawBeam(INDEXENT(1), v_source, v_dest, 10, 2, 250, 250, 250, 200, 10); @@ -1176,11 +1176,11 @@ static int BotShouldJumpOver(const bot_t *pBot) { // WaypointDrawBeam(INDEXENT(1), v_source, v_dest, 10, 2, 250, 250, 250, 200, 10); // if there is line of sight report that the bot can try jumping here - if (tr.flFraction >= 1.0) + if (tr.flFraction >= 1) return 2; // did the traceline go further then it did when traced from lower down the body? // if so then there appears to be some kind of ledge here - else if ((v_source - tr.vecEndPos).Length2D() > shinObstacleDistance + 1.0) + else if ((v_source - tr.vecEndPos).Length2D() > shinObstacleDistance + 1) return 2; else obstacleFound = true; @@ -1223,7 +1223,7 @@ static int BotShouldDuckUnder(const bot_t *pBot) { // WaypointDrawBeam(INDEXENT(1), v_source, v_dest, 10, 2, 50, 50, 250, 200, 10); // obstructed by something? - if (tr.flFraction < 1.0) { + if (tr.flFraction < 1) { // get the distance of the obstacle from the bots head const float headObstacleDistance = (v_source - tr.vecEndPos).Length(); @@ -1237,11 +1237,11 @@ static int BotShouldDuckUnder(const bot_t *pBot) { // WaypointDrawBeam(INDEXENT(1), v_source, v_dest, 10, 2, 50, 50, 250, 200, 10); // if there is line of sight report that the bot can try ducking here - if (tr.flFraction >= 1.0) + if (tr.flFraction >= 1) return 2; // did the traceline go further then it did when traced from the head? // if so then ducking may help - else if ((v_source - tr.vecEndPos).Length() > headObstacleDistance + 1.0) + else if ((v_source - tr.vecEndPos).Length() > headObstacleDistance + 1) return 2; else obstacleFound = true; @@ -1263,7 +1263,7 @@ static int BotShouldDuckUnder(const bot_t *pBot) { // WaypointDrawBeam(INDEXENT(1), v_source, v_dest, 10, 2, 50, 50, 250, 200, 10); // obstructed by something? - if (tr.flFraction < 1.0) { + if (tr.flFraction < 1) { // get the distance of the obstacle from the bots head const float headObstacleDistance = (v_source - tr.vecEndPos).Length(); @@ -1277,11 +1277,11 @@ static int BotShouldDuckUnder(const bot_t *pBot) { // WaypointDrawBeam(INDEXENT(1), v_source, v_dest, 10, 2, 50, 50, 250, 200, 10); // if there is line of sight report that the bot can try ducking here - if (tr.flFraction >= 1.0) + if (tr.flFraction >= 1) return 2; // did the traceline go further then it did when traced from the head? // if so then ducking may help - else if ((v_source - tr.vecEndPos).Length() > headObstacleDistance + 1.0) + else if ((v_source - tr.vecEndPos).Length() > headObstacleDistance + 1) return 2; else obstacleFound = true; @@ -1303,9 +1303,9 @@ static bool BotFallenOffCheck(bot_t *const pBot) { // fix going to wrong waypoint if falling, could help with rocket jumping :D // 87.0 = bot's standing origin(37) plus maximum jump height(48 - 50) - if (pBot->pEdict->v.velocity.z < -200.0 && pBot->pEdict->v.waterlevel != WL_HEAD_IN_WATER && !(waypoints[pBot->current_wp].flags & W_FL_LADDER) && waypoints[pBot->current_wp].origin.z > pBot->pEdict->v.absmin.z + 87.0) { + if (pBot->pEdict->v.velocity.z < -200 && pBot->pEdict->v.waterlevel != WL_HEAD_IN_WATER && !(waypoints[pBot->current_wp].flags & W_FL_LADDER) && waypoints[pBot->current_wp].origin.z > pBot->pEdict->v.absmin.z + 87) { // waypoints with an origin higher than this should be considered unreachable - const float heightThreshold = waypoints[pBot->current_wp].origin.z - 10.0; + const float heightThreshold = waypoints[pBot->current_wp].origin.z - 10; // look for a waypoint that is connected directly to the bots // current waypoint and that is reachable @@ -1375,13 +1375,13 @@ bool BotCheckWallOnLeft(const bot_t *pBot) { Vector v_left = pBot->pEdict->v.origin + gpGlobals->v_right * -40; // lower v_left to height of a low wall - v_left.z = pBot->pEdict->v.absmin.z + 17.0; + v_left.z = pBot->pEdict->v.absmin.z + 17; TraceResult tr; UTIL_TraceLine(pBot->pEdict->v.origin, v_left, dont_ignore_monsters, pBot->pEdict->v.pContainingEntity, &tr); // check if the trace hit something... - if (tr.flFraction < 1.0) { + if (tr.flFraction < 1) { // WaypointDrawBeam(INDEXENT(1), pBot->pEdict->v.origin, // v_left, 10, 2, 250, 50, 50, 200, 10); @@ -1400,13 +1400,13 @@ bool BotCheckWallOnRight(const bot_t *pBot) { Vector v_right = pBot->pEdict->v.origin + gpGlobals->v_right * 40.0; // lower v_right to height of a low wall - v_right.z = pBot->pEdict->v.absmin.z + 17.0; + v_right.z = pBot->pEdict->v.absmin.z + 17; TraceResult tr; UTIL_TraceLine(pBot->pEdict->v.origin, v_right, dont_ignore_monsters, pBot->pEdict->v.pContainingEntity, &tr); // check if the trace hit something... - if (tr.flFraction < 1.0) { + if (tr.flFraction < 1) { // WaypointDrawBeam(INDEXENT(1), pBot->pEdict->v.origin, // v_right, 10, 2, 250, 50, 50, 200, 10); @@ -1645,7 +1645,7 @@ bool BotPathCheck(const int sourceWP, const int destWP) { UTIL_TraceLine(waypoints[sourceWP].origin, waypoints[destWP].origin, ignore_monsters, nullptr, &tr); // if line of sight is not blocked - if (tr.flFraction >= 1.0) + if (tr.flFraction >= 1) return true; return false; @@ -1903,7 +1903,7 @@ int BotFindRetreatPoint(bot_t *const pBot, const int min_dist, const Vector &r_t // is this waypoint hidden by scenery? // if so immediately accept this waypoint as the best candidate - if (tr.flFraction < 1.0) + if (tr.flFraction < 1) break; } } @@ -2292,10 +2292,10 @@ static void BotCheckForRocketJump(bot_t *pBot) { // is this RJ waypoints height reachable with a rocket jump? // on a server with 800 gravity rocket jumps can reach a height of about 440 - if (zDiff > 54.0 && zDiff < maxJumpHeight) { + if (zDiff > 54 && zDiff < maxJumpHeight) { const float distance2D = (pBot->pEdict->v.origin - waypoints[RJPoints[i][RJ_WP_INDEX]].origin).Length2D(); - if (distance2D > 150.0 // don't want RJ points that are too close + if (distance2D > 150 // don't want RJ points that are too close && distance2D < closest2D) { closest2D = distance2D; closestRJ = RJPoints[i][RJ_WP_INDEX]; @@ -2329,14 +2329,14 @@ static void BotCheckForRocketJump(bot_t *pBot) { zDiff = waypoints[closestRJ].origin.z - pBot->pEdict->v.origin.z; UTIL_TraceLine(pBot->pEdict->v.origin + pBot->pEdict->v.view_ofs, pBot->pEdict->v.origin + Vector(0.0, 0.0, zDiff), ignore_monsters, pBot->pEdict->v.pContainingEntity, &result); - if (result.flFraction < 1.0) + if (result.flFraction < 1) return; // can't see it // Check visibility from a point in the air above the bot to the RJ waypoint // this improves the bots ability to properly detect RJ waypoints UTIL_TraceLine(pBot->pEdict->v.origin + Vector(0.0, 0.0, zDiff), waypoints[closestRJ].origin, ignore_monsters, pBot->pEdict->v.pContainingEntity, &result); - if (result.flFraction < 1.0) + if (result.flFraction < 1) return; // can't see it else { // debug stuff @@ -2440,7 +2440,7 @@ static void BotCheckForConcJump(bot_t *pBot) { // is this RJ waypoints height reachable with a concussion jump? // on a server with 800 gravity concussion jumps can reach a height of about 490 - if (zDiff > 54.0 && zDiff < 450.0) { + if (zDiff > 54 && zDiff < 450) { const float distance2D = (waypoints[endWP].origin - waypoints[RJPoints[i][RJ_WP_INDEX]].origin).Length2D(); if (distance2D < closest2D) { @@ -2473,7 +2473,7 @@ static void BotCheckForConcJump(bot_t *pBot) { zDiff = waypoints[closestJumpWP].origin.z - waypoints[endWP].origin.z; UTIL_TraceLine(waypoints[endWP].origin + pBot->pEdict->v.view_ofs, waypoints[endWP].origin + Vector(0.0, 0.0, zDiff), ignore_monsters, pBot->pEdict->v.pContainingEntity, &result); - if (result.flFraction < 1.0) + if (result.flFraction < 1) return; // can't see it // Check visibility from a point in the air above the bot to the RJ waypoint diff --git a/bot_start.cpp b/bot_start.cpp index cf38cd53..5b74d4e6 100644 --- a/bot_start.cpp +++ b/bot_start.cpp @@ -54,8 +54,8 @@ void BotStartGame(bot_t *pBot) { edict_t *pEdict = pBot->pEdict; if (mod_id == TFC_DLL) { - if (pBot->create_time > gpGlobals->time + 1.0 || pBot->create_time + 3.0 <= gpGlobals->time) - pBot->create_time = gpGlobals->time + 1.0; + if (pBot->create_time > gpGlobals->time + 1 || pBot->create_time + 3 <= gpGlobals->time) + pBot->create_time = gpGlobals->time + 1; if (pBot->create_time > gpGlobals->time && pBot->create_time - 0.5 < gpGlobals->time) { if (!spawn_check_crash) { @@ -80,14 +80,14 @@ void BotStartGame(bot_t *pBot) { } // force team selection - if (pBot->create_time + 1.0 <= gpGlobals->time) + if (pBot->create_time + 1 <= gpGlobals->time) pBot->start_action = MSG_TFC_TEAM_SELECT; if (pBot->create_time + 1.5 <= gpGlobals->time) pBot->start_action = MSG_TFC_CLASS_SELECT; // if we dont start after 2, sort other stuff - if (pBot->create_time + 2.0 <= gpGlobals->time) + if (pBot->create_time + 2 <= gpGlobals->time) pBot->not_started = false; // handle Team Fortress Classic stuff here... diff --git a/changelog.txt b/changelog.txt index 76ed46e4..96e89343 100644 --- a/changelog.txt +++ b/changelog.txt @@ -13,15 +13,17 @@ Updated by RoboCop - Added area for bots to report Sentry Built in dustbowl hut entry in CP1 +- Added more delay for bots to Team Report to prevent annoying chat flooding + - Increased priority for bots to steal flags -- Optimised pathway for shutdown2 and dustbowl +- Optimised pathway for 2fort, shutdown2, rock2, well and dustbowl - Repaired rock2 waypoints and the rock2 variants by allowing bots to cap properly -- Reduced the likelihood for blue bots to go in wrong way after capping CP2 +- Reduced the likelihood for blue bots to go in wrong way after capping CP2 in dustbowl -- Improve bot's visual on locating stray ammo bags +- Improved bot's visual on locating stray ammo bags - Reverted waypoint max Reachable Range @@ -29,6 +31,8 @@ TODO List:- >> Fix bot_chat cvars +>> Train spies to not flag hold and aim properly to destroy SG Turrets + >> Allow bots to toss grenades at a higher angle and low range as their target aim is too short >> Find a way to allow bot_job_think.cpp task priorities work properly (45 jobs in total too much?) diff --git a/dll.cpp b/dll.cpp index a442096b..d15c3cd0 100644 --- a/dll.cpp +++ b/dll.cpp @@ -903,7 +903,7 @@ int DispatchSpawn(edict_t *pent) { prev_num_bots = num_bots; num_bots = 0; - bot_check_time = gpGlobals->time + 30.0; + bot_check_time = gpGlobals->time + 30; } } @@ -987,7 +987,7 @@ void DispatchThink(edict_t *pent) { tr.pHit = nullptr; UTIL_TraceLine(pent->v.euser1->v.origin + pent->v.euser1->v.view_ofs, pBot->enemy.ptr->v.origin + Vector(xx, yy, zz), dont_ignore_monsters, dont_ignore_glass, pent->v.euser1, &tr); - if (tr.pHit == pBot->enemy.ptr || tr.flFraction == 1.0) + if (tr.pHit == pBot->enemy.ptr || tr.flFraction == 1) player_vis[scanpos] = true; else player_vis[scanpos] = false; @@ -1265,7 +1265,7 @@ BOOL ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress if (welcome_index == -1) welcome_index = i; // don't try to add bots for 30 seconds, give client time to get added - bot_check_time = gpGlobals->time + 30.0; + bot_check_time = gpGlobals->time + 30; // save the edict of the first player to join this server... if (first_player == nullptr) first_player = pEntity; @@ -1416,7 +1416,7 @@ void ClientCommand(edict_t *pEntity) { strcpy(c, "-1"); BotCreate(pEntity, arg1, c, arg3, arg4); } - bot_check_time = gpGlobals->time + 5.0; + bot_check_time = gpGlobals->time + 5; if (mr_meta) RETURN_META(MRES_SUPERCEDE); return; @@ -2432,11 +2432,11 @@ void StartFrame() { // v7 last frame timing bots[index].respawn_state = RESPAWN_NEED_TO_RESPAWN; count++; } // check for any bots that were very recently kicked... - if (bots[index].f_kick_time + 5.0 > previous_time) { + if (bots[index].f_kick_time + 5 > previous_time) { bots[index].respawn_state = RESPAWN_NEED_TO_RESPAWN; count++; } else - bots[index].f_kick_time = 0.0; // reset to prevent false spawns later + bots[index].f_kick_time = 0; // reset to prevent false spawns later } // set the respawn time if (IS_DEDICATED_SERVER()) respawn_time = gpGlobals->time + 10; @@ -2478,7 +2478,7 @@ void StartFrame() { // v7 last frame timing } } } // are we currently respawning bots and is it time to spawn one yet? - if (respawn_time > 1.0 && respawn_time <= gpGlobals->time) { + if (respawn_time > 1 && respawn_time <= gpGlobals->time) { int index1 = 0; // Not wanted? [APG]RoboCop[CL] // find bot needing to be respawned... while (index1 < 32 && bots[index1].respawn_state != RESPAWN_NEED_TO_RESPAWN) @@ -2586,7 +2586,7 @@ void StartFrame() { // v7 last frame timing if (first_player != nullptr) { if (IsAlive(first_player)) { spawn_time_reset = true; - if (respawn_time >= 1.0) + if (respawn_time >= 1) respawn_time = min(respawn_time, gpGlobals->time + 1.0f); if (bot_cfg_pause_time >= 1) bot_cfg_pause_time = min(bot_cfg_pause_time, gpGlobals->time + 1.0f); @@ -2603,7 +2603,7 @@ void StartFrame() { // v7 last frame timing } } // if time to check for server commands then do so... if (check_server_cmd <= gpGlobals->time && IS_DEDICATED_SERVER()) { - check_server_cmd = gpGlobals->time + 1.0; + check_server_cmd = gpGlobals->time + 1; auto cvar_bot = const_cast(CVAR_GET_STRING("bot")); if (cvar_bot && cvar_bot[0]) { char cmd_line[80]; @@ -2638,7 +2638,7 @@ void StartFrame() { // v7 last frame timing } if (strcmp(cmd, "addbot") == 0) { BotCreate(nullptr, arg1, arg2, arg3, arg4); - bot_check_time = gpGlobals->time + 5.0; + bot_check_time = gpGlobals->time + 5; } else if (strcmp(cmd, "min_bots") == 0) { changeBotSetting("min_bots", &min_bots, arg1, -1, 31, SETTING_SOURCE_SERVER_COMMAND); } else if (strcmp(cmd, "max_bots") == 0) { @@ -5206,7 +5206,7 @@ static void ProcessBotCfgFile() { if (strcmp(cmd, "bot_create_interval") == 0) { bot_create_interval = static_cast(atoi(arg1)); - if (bot_create_interval < 1.0 || bot_create_interval > 8.0) + if (bot_create_interval < 1 || bot_create_interval > 8) bot_create_interval = 3.0; if (IS_DEDICATED_SERVER()) @@ -5524,7 +5524,7 @@ static void DisplayBotInfo() { sprintf(msg, "--* foxbot v%d.%d *--\n", VER_MAJOR, VER_MINOR); ALERT(at_console, msg); - strncat(msg2, msg, 511 - strlen(msg2)); + strncat(msg2, msg, 512 - strlen(msg2)); sprintf(msg, "\n--FoxBot info--\n"); ALERT(at_console, msg); strncat(msg2, msg, 511 - strlen(msg2)); diff --git a/engine.cpp b/engine.cpp index 1bb32c84..64b2069c 100644 --- a/engine.cpp +++ b/engine.cpp @@ -186,7 +186,7 @@ void pfnSetOrigin(edict_t *e, const float *rgflOrigin) { // clear up current wpt for (int bot_index = 0; bot_index < 32; bot_index++) { // only consider existing bots that haven't died very recently - if (bots[bot_index].pEdict == e && bots[bot_index].is_used && bots[bot_index].f_killed_time + 3.0 < gpGlobals->time) { + if (bots[bot_index].pEdict == e && bots[bot_index].is_used && bots[bot_index].f_killed_time + 3 < gpGlobals->time) { // see if a teleporter pad moved the bot const edict_t *teleExit = BotEntityAtPoint("building_teleporter", bots[bot_index].pEdict->v.origin, 90.0); diff --git a/util.cpp b/util.cpp index 03a44452..d7ffe220 100644 --- a/util.cpp +++ b/util.cpp @@ -476,7 +476,7 @@ bool BotCanSeeOrigin(const bot_t *pBot, const Vector &r_dest) { UTIL_TraceLine(pBot->pEdict->v.origin + pBot->pEdict->v.view_ofs, r_dest, ignore_monsters, pBot->pEdict->v.pContainingEntity, &tr); // check if line of sight to the object is not blocked - if (tr.flFraction >= 1.0) + if (tr.flFraction >= 1) return true; return false; @@ -491,18 +491,18 @@ int BotInFieldOfView(const bot_t *pBot, const Vector &dest) { Vector entity_angles = UTIL_VecToAngles(dest); // make yaw angle 0 to 360 degrees if negative... - if (entity_angles.y < 0.0) - entity_angles.y += 360.0; + if (entity_angles.y < 0) + entity_angles.y += 360; // get bot's current view angle... float view_angle = pBot->pEdict->v.v_angle.y; // make view angle 0 to 360 degrees if negative... - if (view_angle < 0.0) - view_angle += 360.0; + if (view_angle < 0) + view_angle += 360; // rsm - START angle bug fix - int angle = abs(static_cast(view_angle) - static_cast(entity_angles.y)); + int angle = std::abs(static_cast(view_angle) - static_cast(entity_angles.y)); if (angle > 180) angle = 360 - angle; @@ -527,7 +527,7 @@ bool FVisible(const Vector &r_vecOrigin, edict_t *pEdict) { // was ignore glass UTIL_TraceLine(vecLookerOrigin, r_vecOrigin, ignore_monsters, dont_ignore_glass, pEdict, &tr); - if (tr.flFraction < 1.0) + if (tr.flFraction < 1) return false; // Line of sight is not established else return true; // line of sight is valid. @@ -560,7 +560,7 @@ bool UTIL_FootstepsHeard(const edict_t *pEdict, edict_t *pPlayer) { if (footstep_sounds_on == true) { // check if this player is near enough and moving fast enough on // the ground to make sounds - if (pPlayer->v.flags & FL_ONGROUND && VectorsNearerThan(pPlayer->v.origin, pEdict->v.origin, 600.0) && pPlayer->v.velocity.Length2D() > 220.0) { + if (pPlayer->v.flags & FL_ONGROUND && VectorsNearerThan(pPlayer->v.origin, pEdict->v.origin, 600.0) && pPlayer->v.velocity.Length2D() > 220) { return true; } } diff --git a/waypoint.cpp b/waypoint.cpp index d3ce9862..2c66337a 100644 --- a/waypoint.cpp +++ b/waypoint.cpp @@ -444,7 +444,7 @@ int WaypointFindNearest_E(const edict_t *pEntity, const float range, const int t // (even behind head)... UTIL_TraceLine(pEntity->v.origin + pEntity->v.view_ofs, waypoints[i].origin, ignore_monsters, pEntity->v.pContainingEntity, &tr); - if (tr.flFraction >= 1.0) { + if (tr.flFraction >= 1) { min_index = i; min_distance_squared = distance_squared; } @@ -523,7 +523,7 @@ int WaypointFindNearest_S(const Vector &v_src, edict_t *pEntity, const float ran UTIL_TraceLine(waypoints[index].origin, v_src, ignore_monsters, nullptr, &tr); // it is visible, so store it - if (tr.flFraction >= 1.0) { + if (tr.flFraction >= 1) { min_index = index; min_distance_squared = distance_squared; } @@ -573,7 +573,7 @@ int WaypointFindInRange(const Vector &v_src, const float min_range, const float UTIL_TraceLine(waypoints[i].origin, v_src, ignore_monsters, nullptr, &tr); // if the source is visible from this waypoint - if (tr.flFraction >= 1.0) { + if (tr.flFraction >= 1) { // a cool laser effect (for debugging purposes) // WaypointDrawBeam(INDEXENT(1), waypoints[i].origin, // v_src, 10, 2, 50, 250, 50, 200, 10); @@ -836,7 +836,7 @@ int WaypointFindRandomGoal_R(const Vector &v_src, const bool checkVisibility, co if (checkVisibility) UTIL_TraceLine(v_src, waypoints[index].origin, ignore_monsters, nullptr, &tr); - if (!checkVisibility || tr.flFraction >= 1.0) { + if (!checkVisibility || tr.flFraction >= 1) { indexes[count] = index; ++count; @@ -925,7 +925,7 @@ bool DetpackClearIsBlocked(const int index) { ++path_total; UTIL_TraceLine(waypoints[index].origin, waypoints[p->index[i]].origin, ignore_monsters, nullptr, &tr); - if (tr.flFraction < 1.0) + if (tr.flFraction < 1) return true; // a path is blocked by something } } @@ -956,7 +956,7 @@ bool DetpackSealIsClear(const int index) { if (p->index[i] != -1) { UTIL_TraceLine(waypoints[index].origin, waypoints[p->index[i]].origin, ignore_monsters, nullptr, &tr); - if (tr.flFraction < 1.0) + if (tr.flFraction < 1) return false; // a path is blocked by something } } @@ -1321,7 +1321,7 @@ static bool WaypointDeleteAimArtifact(const edict_t *pEntity) { // if there is line of sight from this waypoint to the // aim waypoint - if (tr.flFraction >= 1.0) { + if (tr.flFraction >= 1) { waypoint_is_artifact = false; // draw a beam to the nearest waypoint found to show @@ -1873,7 +1873,7 @@ bool WaypointReachable(Vector v_src, Vector v_dest, const edict_t *pEntity) { // if waypoint is visible from current position // (even behind head)... - if (tr.flFraction >= 1.0) { + if (tr.flFraction >= 1) { // check for special case of both waypoints being underwater... if (POINT_CONTENTS(v_src) == CONTENTS_WATER && POINT_CONTENTS(v_dest) == CONTENTS_WATER) return true; @@ -1881,7 +1881,7 @@ bool WaypointReachable(Vector v_src, Vector v_dest, const edict_t *pEntity) { // check for special case of waypoint being suspended in mid-air... // is dest waypoint higher than src? (45 is max jump height) - if (v_dest.z > v_src.z + 45.0) { + if (v_dest.z > v_src.z + 45) { const Vector &v_new_src = v_dest; Vector v_new_dest = v_dest; @@ -1891,7 +1891,7 @@ bool WaypointReachable(Vector v_src, Vector v_dest, const edict_t *pEntity) { // check if we didn't hit anything, // if not then it's in mid-air - if (tr.flFraction >= 1.0) { + if (tr.flFraction >= 1) { return false; // can't reach this one } } @@ -1903,28 +1903,28 @@ bool WaypointReachable(Vector v_src, Vector v_dest, const edict_t *pEntity) { Vector v_check = v_src; Vector v_down = v_src; - v_down.z = v_down.z - 1000.0; // straight down 1000 units + v_down.z = v_down.z - 1000; // straight down 1000 units UTIL_TraceLine(v_check, v_down, ignore_monsters, pEntity->v.pContainingEntity, &tr); - float last_height = tr.flFraction * 1000.0; // height from ground + float last_height = tr.flFraction * 1000; // height from ground distance = (v_dest - v_check).Length(); // distance from goal - while (distance > 10.0) { + while (distance > 10) { // move 10 units closer to the goal... v_check = v_check + v_direction * 10.0; v_down = v_check; - v_down.z = v_down.z - 1000.0; // straight down 1000 units + v_down.z = v_down.z - 1000; // straight down 1000 units UTIL_TraceLine(v_check, v_down, ignore_monsters, pEntity->v.pContainingEntity, &tr); - const float curr_height = tr.flFraction * 1000.0; // height from ground + const float curr_height = tr.flFraction * 1000; // height from ground // is the difference in the last height and the current // height higher that the jump height? - if (last_height - curr_height > 45.0) { + if (last_height - curr_height > 45) { // can't get there from here... return false; } @@ -2403,7 +2403,7 @@ void WaypointThink(edict_t *pEntity) { MESSAGE_END(); // draw 2 crossed lines to create a blockage symbol - if (wp_display_time[i] + 1.0 < gpGlobals->time) { + if (wp_display_time[i] + 1 < gpGlobals->time) { Vector beam_start = waypoints[i].origin + Vector(20, 0, 20); Vector beam_end = waypoints[i].origin - Vector(20, 0, 0) - Vector(0, 0, 20); WaypointDrawBeam(pEntity, beam_start, beam_end, 10, 2, 250, 0, 250, 200, 10); @@ -2437,7 +2437,7 @@ void WaypointThink(edict_t *pEntity) { WRITE_BYTE(128); MESSAGE_END(); } - if (flags & W_FL_PATHCHECK && wp_display_time[i] + 1.0 < gpGlobals->time) { + if (flags & W_FL_PATHCHECK && wp_display_time[i] + 1 < gpGlobals->time) { // draw 2 crossed lines to create a signpost symbol // near the top of the waypoint Vector beam_start = waypoints[i].origin + Vector(15, 0, 25); @@ -2647,7 +2647,7 @@ void WaypointThink(edict_t *pEntity) { min_distance = distance; } - if (wp_display_time[i] + 1.0 < gpGlobals->time) { + if (wp_display_time[i] + 1 < gpGlobals->time) { if (waypoints[i].flags & W_FL_CROUCH) { start = waypoints[i].origin - Vector(0, 0, 17); end = start + Vector(0, 0, 34); @@ -2812,7 +2812,7 @@ void WaypointThink(edict_t *pEntity) { // min_distance = distance; // } - if (a_display_time[i] + 1.0 < gpGlobals->time) { + if (a_display_time[i] + 1 < gpGlobals->time) { start = areas[i].a - Vector(0, 0, 34); end = start + Vector(0, 0, 68); // draw a red waypoint @@ -2833,7 +2833,7 @@ void WaypointThink(edict_t *pEntity) { // min_distance = distance; // } - if (a_display_time[i] + 1.0 < gpGlobals->time) { + if (a_display_time[i] + 1 < gpGlobals->time) { start = areas[i].b - Vector(0, 0, 34); end = start + Vector(0, 0, 68); // draw a red waypoint @@ -2854,7 +2854,7 @@ void WaypointThink(edict_t *pEntity) { // min_distance = distance; // } - if (a_display_time[i] + 1.0 < gpGlobals->time) { + if (a_display_time[i] + 1 < gpGlobals->time) { start = areas[i].c - Vector(0, 0, 34); end = start + Vector(0, 0, 68); // draw a red waypoint @@ -2875,7 +2875,7 @@ void WaypointThink(edict_t *pEntity) { // min_distance = distance; // } - if (a_display_time[i] + 1.0 < gpGlobals->time) { + if (a_display_time[i] + 1 < gpGlobals->time) { start = areas[i].d - Vector(0, 0, 34); end = start + Vector(0, 0, 68); // draw a red waypoint @@ -2887,7 +2887,7 @@ void WaypointThink(edict_t *pEntity) { } // connect the dots :) - if (a_display_time[i] + 1.0 < gpGlobals->time && timr) { + if (a_display_time[i] + 1 < gpGlobals->time && timr) { int g = 0; // if(AreaInside(pEntity,i)) g=64; if (AreaInsideClosest(pEntity) == i) { @@ -3749,7 +3749,7 @@ int AreaDefPointFindNearest(const edict_t *pEntity, const float range, const int // (even behind head)... UTIL_TraceLine(pEntity->v.origin + pEntity->v.view_ofs, o, ignore_monsters, pEntity->v.pContainingEntity, &tr); - if (tr.flFraction >= 1.0) { + if (tr.flFraction >= 1) { min_index = i; min_distance = distance; }