fix: logos config not initialized (resolves #691)

bot: make sure rescue zone icon blinking to consider bot reached rescue zone when escorting hostages (ref #688)
bot: remove hardcoded radio communication randoms, so they're now depends on bots personality
refactor: some refactoring of code
This commit is contained in:
jeefo 2025-05-07 13:07:40 +03:00
commit 6dfb09f110
No known key found for this signature in database
GPG key ID: D696786B81B667C8
26 changed files with 180 additions and 141 deletions

View file

@ -269,7 +269,7 @@ void GraphAnalyze::cleanup () {
}
}
void GraphAnalyze::displayOverlayMessage () {
void GraphAnalyze::displayOverlayMessage () const {
auto listenserverEdict = game.getLocalEntity ();
if (game.isNullEntity (listenserverEdict) || !m_isAnalyzing) {

View file

@ -856,7 +856,7 @@ Vector Bot::getCampDirection (const Vector &dest) {
return nullptr;
}
void Bot::showChatterIcon (bool show, bool disconnect) {
void Bot::showChatterIcon (bool show, bool disconnect) const {
// this function depending on show boolean, shows/remove chatter, icon, on the head of bot.
if (!game.is (GameFlags::HasBotVoice) || cv_radio_mode.as <int> () != 2) {
@ -894,7 +894,7 @@ void Bot::showChatterIcon (bool show, bool disconnect) {
}
}
void Bot::instantChatter (int type) {
void Bot::instantChatter (int type) const {
// this function sends instant chatter messages.
if (!game.is (GameFlags::HasBotVoice)
|| cv_radio_mode.as <int> () != 2
@ -1222,7 +1222,7 @@ bool Bot::canReplaceWeapon () {
return isWeaponRestricted (m_currentWeapon);
}
int Bot::pickBestWeapon (Array <int> &vec, int moneySave) {
int Bot::pickBestWeapon (Array <int> &vec, int moneySave) const {
// this function picks best available weapon from random choice with money save
if (vec.length () < 2) {
@ -1890,6 +1890,7 @@ void Bot::setConditions () {
if (m_agressionLevel > 1.0f) {
m_agressionLevel = 1.0f;
}
m_radioPercent = cr::min (m_radioPercent - rg (1, 5), 15);
if (rg.chance (10)) {
pushChatMessage (Chat::Kill);
@ -2450,7 +2451,7 @@ void Bot::checkRadioQueue () {
if (seesEntity (m_radioEntity->v.origin) || m_radioOrder == Radio::StickTogetherTeam) {
if (game.isNullEntity (m_targetEntity)
&& game.isNullEntity (m_enemy)
&& rg.chance (m_personality == Personality::Careful ? 80 : 20)) {
&& rg.chance (m_radioPercent)) {
int numFollowers = 0;
@ -2494,11 +2495,11 @@ void Bot::checkRadioQueue () {
}
}
}
else if (m_radioOrder != Chatter::GoingToPlantBomb && rg.chance (25)) {
else if (m_radioOrder != Chatter::GoingToPlantBomb && rg.chance (m_radioPercent)) {
pushRadioMessage (Radio::Negative);
}
}
else if (m_radioOrder != Chatter::GoingToPlantBomb && rg.chance (35)) {
else if (m_radioOrder != Chatter::GoingToPlantBomb && rg.chance (m_radioPercent)) {
pushRadioMessage (Radio::Negative);
}
}
@ -2530,7 +2531,7 @@ void Bot::checkRadioQueue () {
m_fearLevel = 0.0f;
}
if (rg.chance (45) && cv_radio_mode.as <int> () == 2) {
if (rg.chance (m_radioPercent) && cv_radio_mode.as <int> () == 2) {
pushChatterMessage (Chatter::OnMyWay);
}
else if (m_radioOrder == Radio::NeedBackup && cv_radio_mode.as <int> () != 2) {
@ -2538,7 +2539,7 @@ void Bot::checkRadioQueue () {
}
tryHeadTowardRadioMessage ();
}
else if (rg.chance (25)) {
else if (rg.chance (m_radioPercent)) {
pushRadioMessage (Radio::Negative);
}
}
@ -2559,7 +2560,7 @@ void Bot::checkRadioQueue () {
case Chatter::ScaredEmotion:
case Chatter::PinnedDown:
if (((game.isNullEntity (m_enemy) && seesEntity (m_radioEntity->v.origin)) || distanceSq < cr::sqrf (2048.0f) || !m_moveToC4)
&& rg.chance (50)
&& rg.chance (m_radioPercent)
&& m_seeEnemyTime + 4.0f < game.time ()) {
m_fearLevel -= 0.1f;
@ -2568,22 +2569,22 @@ void Bot::checkRadioQueue () {
m_fearLevel = 0.0f;
}
if (rg.chance (45) && cv_radio_mode.as <int> () == 2) {
if (rg.chance (m_radioPercent) && cv_radio_mode.as <int> () == 2) {
pushChatterMessage (Chatter::OnMyWay);
}
else if (m_radioOrder == Radio::NeedBackup && cv_radio_mode.as <int> () != 2 && rg.chance (50)) {
else if (m_radioOrder == Radio::NeedBackup && cv_radio_mode.as <int> () != 2 && rg.chance (m_radioPercent)) {
pushRadioMessage (Radio::RogerThat);
}
tryHeadTowardRadioMessage ();
}
else if (rg.chance (30) && m_radioOrder == Radio::NeedBackup) {
else if (rg.chance (m_radioPercent) && m_radioOrder == Radio::NeedBackup) {
pushRadioMessage (Radio::Negative);
}
break;
case Radio::GoGoGo:
if (m_radioEntity == m_targetEntity) {
if (rg.chance (45) && cv_radio_mode.as <int> () == 2) {
if (rg.chance (m_radioPercent) && cv_radio_mode.as <int> () == 2) {
pushRadioMessage (Radio::RogerThat);
}
else if (m_radioOrder == Radio::NeedBackup && cv_radio_mode.as <int> () != 2) {
@ -2622,7 +2623,7 @@ void Bot::checkRadioQueue () {
pushRadioMessage (Radio::RogerThat);
resetDoubleJump ();
}
else if (rg.chance (35)) {
else if (rg.chance (m_radioPercent)) {
pushRadioMessage (Radio::Negative);
}
break;
@ -2637,7 +2638,7 @@ void Bot::checkRadioQueue () {
m_targetEntity = nullptr;
startTask (Task::EscapeFromBomb, TaskPri::EscapeFromBomb, kInvalidNodeIndex, 0.0f, true);
}
else if (rg.chance (35)) {
else if (rg.chance (m_radioPercent)) {
pushRadioMessage (Radio::Negative);
}
break;
@ -2656,7 +2657,7 @@ void Bot::checkRadioQueue () {
break;
case Radio::StormTheFront:
if (((game.isNullEntity (m_enemy) && seesEntity (m_radioEntity->v.origin)) || distanceSq < cr::sqrf (1024.0f)) && rg.chance (50)) {
if (((game.isNullEntity (m_enemy) && seesEntity (m_radioEntity->v.origin)) || distanceSq < cr::sqrf (1024.0f)) && rg.chance (m_radioPercent)) {
pushRadioMessage (Radio::RogerThat);
// don't pause/camp anymore
@ -2738,7 +2739,7 @@ void Bot::checkRadioQueue () {
case Radio::ReportInTeam:
switch (getCurrentTaskId ()) {
case Task::Normal:
if (getTask ()->data != kInvalidNodeIndex && rg.chance (70)) {
if (getTask ()->data != kInvalidNodeIndex && rg.chance (m_radioPercent)) {
const auto &path = graph[getTask ()->data];
if (path.flags & NodeFlag::Goal) {
@ -2752,14 +2753,14 @@ void Bot::checkRadioQueue () {
else if (m_hasHostage) {
pushChatterMessage (Chatter::RescuingHostages);
}
else if ((path.flags & NodeFlag::Camp) && rg.chance (75)) {
else if ((path.flags & NodeFlag::Camp) && rg.chance (m_radioPercent)) {
pushChatterMessage (Chatter::GoingToCamp);
}
else if (m_states & Sense::HearingEnemy) {
pushChatterMessage (Chatter::HeardTheEnemy);
}
}
else if (rg.chance (30)) {
else if (rg.chance (m_radioPercent)) {
pushChatterMessage (Chatter::ReportingIn);
}
break;
@ -2771,7 +2772,7 @@ void Bot::checkRadioQueue () {
break;
case Task::Camp:
if (rg.chance (40)) {
if (rg.chance (m_radioPercent)) {
if (bots.isBombPlanted () && m_team == Team::Terrorist) {
pushChatterMessage (Chatter::GuardingPlantedC4);
}
@ -2828,7 +2829,7 @@ void Bot::checkRadioQueue () {
break;
default:
if (rg.chance (50)) {
if (rg.chance (m_radioPercent)) {
pushChatterMessage (Chatter::Nothing);
}
break;
@ -2942,7 +2943,7 @@ void Bot::tryHeadTowardRadioMessage () {
}
if ((util.isFakeClient (m_radioEntity)
&& rg.chance (25)
&& rg.chance (m_radioPercent)
&& m_personality == Personality::Normal) || !(m_radioEntity->v.flags & FL_FAKECLIENT)) {
if (tid == Task::Pause || tid == Task::Camp) {
@ -3657,6 +3658,9 @@ void Bot::takeDamage (edict_t *inflictor, int damage, int armor, int bits) {
pushChatterMessage (Chatter::FriendlyFire);
}
else {
// increase radio percent
m_radioPercent = cr::max (m_radioPercent + 1, 90);
// attacked by an enemy
if (m_healthValue > 60.0f) {
m_agressionLevel += 0.1f;
@ -3744,7 +3748,7 @@ void Bot::takeBlind (int alpha) {
}
}
void Bot::updatePracticeValue (int damage) {
void Bot::updatePracticeValue (int damage) const {
// gets called each time a bot gets damaged by some enemy. tries to achieve a statistic about most/less dangerous
// nodes for a destination goal used for pathfinding
@ -3960,7 +3964,7 @@ bool Bot::canRunHeavyWeight () {
return false;
}
uint8_t Bot::computeMsec () {
uint8_t Bot::computeMsec () const {
// 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_previousThinkTime) * 1000.0f)), 255));
@ -4248,7 +4252,7 @@ void Bot::selectCampButtons (int index) {
}
}
bool Bot::isBombDefusing (const Vector &bombOrigin) {
bool Bot::isBombDefusing (const Vector &bombOrigin) const {
// this function finds if somebody currently defusing the bomb.
if (!bots.isBombPlanted ()) {
@ -4354,7 +4358,7 @@ void Bot::refreshCreatureStatus (char *infobuffer) {
m_modelMask = modelTest.mask;
}
bool Bot::isCreature () {
bool Bot::isCreature () const {
// current creature models are: zombie, chicken
constexpr auto kModelMaskZombie = (('o' << 8) + 'z');
constexpr auto kModelMaskChicken = (('h' << 8) + 'c');

View file

@ -19,7 +19,7 @@ ConVar cv_aim_trace_consider_glass ("aim_trace_consider_glass", "0", "Bots will
ConVar mp_friendlyfire ("mp_friendlyfire", nullptr, Var::GameRef);
ConVar sv_gravity ("sv_gravity", nullptr, Var::GameRef);
int Bot::numFriendsNear (const Vector &origin, const float radius) {
int Bot::numFriendsNear (const Vector &origin, const float radius) const {
if (game.is (GameFlags::FreeForAll)) {
return 0; // no friends on free for all mode
}
@ -39,7 +39,7 @@ int Bot::numFriendsNear (const Vector &origin, const float radius) {
return count;
}
int Bot::numEnemiesNear (const Vector &origin, const float radius) {
int Bot::numEnemiesNear (const Vector &origin, const float radius) const {
if (game.is (GameFlags::FreeForAll)) {
return 0; // no enemies on free for all mode
}
@ -129,7 +129,7 @@ bool Bot::isEnemyNoTarget (edict_t *enemy) {
return !!(enemy->v.flags & FL_NOTARGET);
}
bool Bot::isEnemyInDarkArea (edict_t *enemy) {
bool Bot::isEnemyInDarkArea (edict_t *enemy) const {
if (!cv_check_darkness && game.isNullEntity (enemy)) {
return false;
}
@ -773,7 +773,7 @@ Vector Bot::getEnemyBodyOffset () {
return spot;
}
Vector Bot::getCustomHeight (float distance) {
Vector Bot::getCustomHeight (float distance) const {
enum DistanceIndex {
Long, Middle, Short
};
@ -808,7 +808,7 @@ Vector Bot::getCustomHeight (float distance) {
return { 0.0f, 0.0f, kOffsetRanges[m_weaponType][distanceIndex] };
}
bool Bot::isFriendInLineOfFire (float distance) {
bool Bot::isFriendInLineOfFire (float distance) const {
// bot can't hurt teammates, if friendly fire is not enabled...
if (!mp_friendlyfire || game.is (GameFlags::CSDM)) {
return false;
@ -868,7 +868,7 @@ bool Bot::isPenetrableObstacle (const Vector &dest) {
return isPenetrableObstacle2 (dest, penetratePower);
}
bool Bot::isPenetrableObstacle1 (const Vector &dest, int penetratePower) {
bool Bot::isPenetrableObstacle1 (const Vector &dest, int penetratePower) const {
TraceResult tr {};
float obstacleDistanceSq = 0.0f;
@ -906,7 +906,7 @@ bool Bot::isPenetrableObstacle1 (const Vector &dest, int penetratePower) {
return false;
}
bool Bot::isPenetrableObstacle2 (const Vector &dest, int) {
bool Bot::isPenetrableObstacle2 (const Vector &dest, int) const {
// this function returns if enemy can be shoot through some obstacle
const Vector &source = getEyesPos ();
@ -941,7 +941,7 @@ bool Bot::isPenetrableObstacle2 (const Vector &dest, int) {
return false;
}
bool Bot::isPenetrableObstacle3 (const Vector &dest, int penetratePower) {
bool Bot::isPenetrableObstacle3 (const Vector &dest, int penetratePower) const {
// this function returns if enemy can be shoot through some obstacle
TraceResult tr {};
@ -1659,13 +1659,13 @@ void Bot::attackMovement () {
ignoreCollision ();
}
bool Bot::hasPrimaryWeapon () {
bool Bot::hasPrimaryWeapon () const {
// this function returns returns true, if bot has a primary weapon
return (pev->weapons & kPrimaryWeaponMask) != 0;
}
bool Bot::hasSecondaryWeapon () {
bool Bot::hasSecondaryWeapon () const {
// this function returns returns true, if bot has a secondary weapon
return (pev->weapons & kSecondaryWeaponMask) != 0;
@ -1752,7 +1752,7 @@ int Bot::bestSecondaryCarried () {
return weaponIndex;
}
int Bot::bestGrenadeCarried () {
int Bot::bestGrenadeCarried () const {
if (pev->weapons & cr::bit (Weapon::Explosive)) {
return Weapon::Explosive;
}
@ -1792,7 +1792,7 @@ bool Bot::rateGroundWeapon (edict_t *ent) {
return groundIndex > hasWeapon;
}
bool Bot::hasAnyWeapons () {
bool Bot::hasAnyWeapons () const {
return !!(pev->weapons & (kPrimaryWeaponMask | kSecondaryWeaponMask));
}
@ -1902,7 +1902,7 @@ void Bot::selectSecondary () {
pev->weapons = oldWeapons;
}
int Bot::getBestOwnedWeapon () {
int Bot::getBestOwnedWeapon () const {
auto tab = conf.getRawWeapons ();
int weapons = pev->weapons;
@ -1921,7 +1921,7 @@ int Bot::getBestOwnedWeapon () {
return num;
}
int Bot::getBestOwnedPistol () {
int Bot::getBestOwnedPistol () const {
auto tab = conf.getRawWeapons ();
int weapons = pev->weapons;
@ -2111,7 +2111,7 @@ void Bot::checkReload () {
}
}
float Bot::calculateScaleFactor (edict_t *ent) {
float Bot::calculateScaleFactor (edict_t *ent) const {
Vector entSize = ent->v.maxs - ent->v.mins;
const float entArea = 2.0f * (entSize.x * entSize.y + entSize.y * entSize.z + entSize.x * entSize.z);
@ -2571,11 +2571,11 @@ bool Bot::isEnemyNoticeable (float range) {
return rg (0.0f, 100.0f) < noticeChance;
}
int Bot::getAmmo () {
int Bot::getAmmo () const {
return getAmmo (m_currentWeapon);
}
int Bot::getAmmo (int id) {
int Bot::getAmmo (int id) const {
const auto &prop = conf.getWeaponProp (id);
if (prop.ammo1 == -1 || prop.ammo1 > kMaxWeapons - 1) {

View file

@ -761,12 +761,13 @@ void BotConfig::loadLogosConfig () {
if (isCommentLine (line)) {
continue;
}
addLogoIndex (line);
addLogoIndex (line.trim ());
}
}
// use defaults
if (m_logosIndices.empty ()) {
game.print ("EMPTY!!!!!");
auto defaults = String { "{biohaz;{graf003;{graf004;{graf005;{lambda06;{target;{hand1;{spit2;{bloodhand6;{foot_l;{foot_r" }.split (";");
for (const auto &logo : defaults) {

View file

@ -17,7 +17,7 @@ int BotControl::cmdAddBot () {
// this is duplicate error as in main bot creation code, but not to be silent
if (!graph.length () || graph.hasChanged ()) {
ctrl.msg ("There is no graph found or graph is changed. Cannot create bot.");
msg ("There is no graph found or graph is changed. Cannot create bot.");
return BotCommandResult::Handled;
}
@ -91,7 +91,7 @@ int BotControl::cmdKillBots () {
bots.killAllBots (Team::Terrorist, silentKill);
}
else {
bots.killAllBots (-1, silentKill);
bots.killAllBots (Team::Invalid, silentKill);
}
return BotCommandResult::Handled;
}
@ -204,6 +204,9 @@ int BotControl::cmdCvars () {
auto match = arg <StringRef> (pattern);
// stop printing if executed once more
flushPrintQueue ();
// revert all the cvars to their default values
if (match == "defaults") {
msg ("Bots cvars has been reverted to their default values.");
@ -244,7 +247,7 @@ int BotControl::cmdCvars () {
cfg.puts ("// Configuration file for %s\n\n", product.name);
}
else {
ctrl.setRapidOutput (true);
setRapidOutput (true);
}
for (const auto &cvar : game.getCvars ()) {
@ -303,7 +306,7 @@ int BotControl::cmdCvars () {
msg (" ");
}
}
ctrl.setRapidOutput (false);
setRapidOutput (false);
if (isSave) {
if (!cfg) {
@ -2172,13 +2175,13 @@ void BotControl::maintainAdminRights () {
}
else if (password != engfuncs.pfnInfoKeyValue (engfuncs.pfnGetInfoKeyBuffer (ent), key.chars ())) {
client.flags &= ~ClientFlags::Admin;
ctrl.msg ("Player %s had lost remote access to %s.", ent->v.netname.chars (), product.name);
msg ("Player %s had lost remote access to %s.", ent->v.netname.chars (), product.name);
}
}
else if (!(client.flags & ClientFlags::Admin) && !key.empty () && !password.empty ()) {
if (password == engfuncs.pfnInfoKeyValue (engfuncs.pfnGetInfoKeyBuffer (ent), key.chars ())) {
client.flags |= ClientFlags::Admin;
ctrl.msg ("Player %s had gained full remote access to %s.", ent->v.netname.chars (), product.name);
msg ("Player %s had gained full remote access to %s.", ent->v.netname.chars (), product.name);
}
}
}

View file

@ -224,7 +224,7 @@ void Game::levelShutdown () {
}
void Game::drawLine (edict_t *ent, const Vector &start, const Vector &end, int width, int noise, const Color &color, int brightness, int speed, int life, DrawLine type) {
void Game::drawLine (edict_t *ent, const Vector &start, const Vector &end, int width, int noise, const Color &color, int brightness, int speed, int life, DrawLine type) const {
// this function draws a arrow visible from the client side of the player whose player entity
// is pointed to by ent, from the vector location start to the vector location end,
// which is supposed to last life tenths seconds, and having the color defined by RGB.
@ -410,7 +410,7 @@ bool Game::checkVisibility (edict_t *ent, uint8_t *set) {
return engfuncs.pfnCheckVisibility (ent, set) > 0;
}
uint8_t *Game::getVisibilitySet (Bot *bot, bool pvs) {
uint8_t *Game::getVisibilitySet (Bot *bot, bool pvs) const {
if (is (GameFlags::Xash3DLegacy)) {
return nullptr;
}
@ -545,7 +545,7 @@ void Game::prepareBotArgs (edict_t *ent, String str) {
m_botArgs.emplace (args.substr (quote, args.length () - 1).trim ("\"")); // add string with trimmed quotes
}
else {
for (auto arg : args.split (" ")) {
for (auto &&arg : args.split (" ")) {
m_botArgs.emplace (arg);
}
}
@ -560,7 +560,7 @@ void Game::prepareBotArgs (edict_t *ent, String str) {
};
if (str.find (';', 0) != String::InvalidIndex) {
for (auto part : str.split (";")) {
for (auto &&part : str.split (";")) {
parsePartArgs (part.trim ());
}
}
@ -1126,7 +1126,7 @@ void Game::searchEntities (StringRef field, StringRef value, EntitySearch functo
}
}
void Game::searchEntities (const Vector &position, float radius, EntitySearch functor) {
void Game::searchEntities (const Vector &position, float radius, EntitySearch functor) const {
edict_t *ent = nullptr;
const Vector &pos = position.empty () ? m_startEntity->v.origin : position;
@ -1145,7 +1145,7 @@ bool Game::hasEntityInGame (StringRef classname) {
return !isNullEntity (engfuncs.pfnFindEntityByString (nullptr, "classname", classname.chars ()));
}
void Game::printBotVersion () {
void Game::printBotVersion () const {
String gameVersionStr {};
StringArray botRuntimeFlags {};

View file

@ -1301,7 +1301,7 @@ void BotGraph::showFileInfo () {
msg (" bsp_size: %d", exten.mapSize);
}
void BotGraph::emitNotify (int32_t sound) {
void BotGraph::emitNotify (int32_t sound) const {
static HashMap <int32_t, String> notifySounds = {
{ NotifySound::Added, "weapons/xbow_hit1.wav" },
{ NotifySound::Change, "weapons/mine_activate.wav" },
@ -1559,7 +1559,7 @@ void BotGraph::initLightLevels () {
if (m_paths.empty () || m_lightChecked) {
return;
}
auto players = bots.countTeamPlayers ();
const auto &players = bots.countTeamPlayers ();
// do calculation if some-one is already playing on the server
if (!players.first && !players.second) {
@ -1953,7 +1953,7 @@ float BotGraph::calculateTravelTime (float maxSpeed, const Vector &src, const Ve
return origin.distance2d (src) / maxSpeed;
}
bool BotGraph::isNodeReacheableEx (const Vector &src, const Vector &destination, const float maxHeight) {
bool BotGraph::isNodeReacheableEx (const Vector &src, const Vector &destination, const float maxHeight) const {
TraceResult tr {};
float distanceSq = destination.distanceSq (src);
@ -2044,11 +2044,11 @@ bool BotGraph::isNodeReacheableEx (const Vector &src, const Vector &destination,
}
bool BotGraph::isNodeReacheable (const Vector &src, const Vector &destination) {
bool BotGraph::isNodeReacheable (const Vector &src, const Vector &destination) const {
return isNodeReacheableEx (src, destination, 45.0f);
}
bool BotGraph::isNodeReacheableWithJump (const Vector &src, const Vector &destination) {
bool BotGraph::isNodeReacheableWithJump (const Vector &src, const Vector &destination) const {
return isNodeReacheableEx (src, destination, cv_graph_analyze_max_jump_height.as <float> ());
}
@ -2872,7 +2872,7 @@ void BotGraph::unassignPath (int from, int to) {
m_hasChanged = true;
}
void BotGraph::convertFromPOD (Path &path, const PODPath &pod) {
void BotGraph::convertFromPOD (Path &path, const PODPath &pod) const {
path.number = pod.number;
path.flags = pod.flags;
path.origin = pod.origin;
@ -2916,7 +2916,7 @@ void BotGraph::convertToPOD (const Path &path, PODPath &pod) {
pod.vis.crouch = path.vis.crouch;
}
void BotGraph::convertCampDirection (Path &path) {
void BotGraph::convertCampDirection (Path &path) const {
// this function converts old vector based camp directions to angles, note that podbotmm graph
// are already saved with angles, and converting this stuff may result strange look directions.

View file

@ -102,7 +102,7 @@ void ServerQueryHook::init () {
}
}
SharedLibrary::Func DynamicLinkerHook::lookup (SharedLibrary::Handle module, const char *function) {
SharedLibrary::Func EntityLinkHook::lookupSymbol (SharedLibrary::Handle module, const char *function) {
static const auto &gamedll = game.lib ().handle ();
static const auto &self = m_self.handle ();
@ -148,7 +148,7 @@ SharedLibrary::Func DynamicLinkerHook::lookup (SharedLibrary::Handle module, con
return nullptr;
}
bool DynamicLinkerHook::callPlayerFunction (edict_t *ent) {
bool EntityLinkHook::callPlayerFunction (edict_t *ent) {
auto callPlayer = [&] () {
reinterpret_cast <EntityProto> (reinterpret_cast <void *> (m_exports["player"])) (&ent->v);
};
@ -169,11 +169,11 @@ bool DynamicLinkerHook::callPlayerFunction (edict_t *ent) {
return true;
}
bool DynamicLinkerHook::needsBypass () const {
bool EntityLinkHook::needsBypass () const {
return !plat.win && !game.isDedicated ();
}
void DynamicLinkerHook::initialize () {
void EntityLinkHook::initialize () {
#if defined(LINKENT_STATIC)
return;
#endif

View file

@ -669,7 +669,7 @@ void BotManager::killAllBots (int team, bool silent) {
// this function kills all bots on server (only this dll controlled bots)
for (const auto &bot : m_bots) {
if (team != -1 && game.getRealTeam (bot->ent ()) != team) {
if (team != Team::Invalid && game.getRealTeam (bot->ent ()) != team) {
continue;
}
bot->kill ();
@ -922,11 +922,14 @@ void BotManager::listBots () {
bot->index (),
bot->pev->netname.chars (),
bot->m_personality == Personality::Rusher ? "rusher" : bot->m_personality == Personality::Normal ? "normal" : "careful",
botTeam (bot->ent ()),
bot->m_difficulty,
static_cast <int> (bot->pev->frags),
bot->m_deathCount,
bot->m_isAlive ? "yes" : "no",
timelimitStr);
}
ctrl.msg ("%d bots", m_bots.length ());
@ -1123,7 +1126,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int skin) {
}
}
char reject[StringBuffer::StaticBufferSize] = { 0, };
char reject[128] = { 0, };
MDLL_ClientConnect (bot, bot->v.netname.chars (), strings.format ("127.0.0.%d", clientIndex + 100), reject);
if (!strings.isEmpty (reject)) {
@ -1569,6 +1572,7 @@ void Bot::newRound () {
m_hitboxEnumerator = cr::makeUnique <PlayerHitboxEnumerator> ();
}
}
showChatterIcon (false);
m_approachingLadderTimer.invalidate ();
m_forgetLastVictimTimer.invalidate ();
@ -1609,6 +1613,24 @@ void Bot::newRound () {
m_buyState = BuyState::PrimaryWeapon;
m_lastEquipTime = 0.0f;
// setup radio percent each round
const auto badMorale = m_fearLevel > m_agressionLevel ? rg.chance (75) : rg.chance (35);
switch (m_personality) {
case Personality::Normal:
default:
m_radioPercent = badMorale ? rg (50, 75) : rg (25, 50);
break;
case Personality::Rusher:
m_radioPercent = badMorale ? rg (35, 50) : rg (15, 35);
break;
case Personality::Careful:
m_radioPercent = badMorale ? rg (70, 90) : rg (50, 70);
break;
}
// if bot died, clear all weapon stuff and force buying again
if (!m_isAlive) {
clearAmmoInfo ();

View file

@ -282,8 +282,8 @@ int Bot::findGoalPost (int tactic, IntArray *defensive, IntArray *offensive) {
else if (tactic == GoalTactic::Offensive && !(*offensive).empty ()) { // offensive goal
postProcessGoals (*offensive, goalChoices);
}
else if (tactic == GoalTactic::Goal && !graph.m_goalPoints.empty ()) // map goal node
{
else if (tactic == GoalTactic::Goal && !graph.m_goalPoints.empty ()) { // map goal node
// force bomber to select closest goal, if round-start goal was reset by something
if (m_hasC4 && bots.getRoundStartTime () + 20.0f < game.time ()) {
float nearestDistanceSq = kInfiniteDistance;
@ -3421,7 +3421,7 @@ bool Bot::isReachableNode (int index) {
return tr.flFraction >= 1.0f;
}
bool Bot::isPreviousLadder () {
bool Bot::isPreviousLadder () const {
const auto prevNodeIndex = m_previousNodes[0];
// bot entered ladder path

View file

@ -395,7 +395,7 @@ bool FloydWarshallAlgo::load () {
return true;
}
void FloydWarshallAlgo::save () {
void FloydWarshallAlgo::save () const {
if (!m_length) {
return;
}
@ -448,7 +448,7 @@ bool DijkstraAlgo::find (int srcIndex, int destIndex, NodeAdderFn onAddedNode, i
m_distance[srcIndex] = 0;
while (!m_queue.empty ()) {
auto route = m_queue.pop ();
const auto &route = m_queue.pop ();
auto current = route.second;
// finished search

View file

@ -192,8 +192,9 @@ void Bot::normal_ () {
if (game.mapIs (MapFlags::HostageRescue)) {
// CT Bot has some hostages following?
if (m_team == Team::CT && m_hasHostage) {
// and reached a rescue point?
if (m_pathFlags & NodeFlag::Rescue) {
if (m_inRescueZone && (m_pathFlags & NodeFlag::Rescue)) {
m_hostages.clear ();
}
}

View file

@ -13,7 +13,7 @@ ConVar cv_whose_your_daddy ("whose_your_daddy", "0", "Enables or disables extra
// game console variables
ConVar mp_flashlight ("mp_flashlight", nullptr, Var::GameRef);
float Bot::isInFOV (const Vector &destination) {
float Bot::isInFOV (const Vector &destination) const {
const float entityAngle = cr::wrapAngle360 (destination.yaw ()); // find yaw angle from source to destination...
const float viewAngle = cr::wrapAngle360 (pev->v_angle.y); // get bot's current view angle...
@ -368,7 +368,7 @@ bool Frustum::isObjectInsidePlane (const Plane &plane, const Vector &center, flo
return isPointInsidePlane (top) || isPointInsidePlane (bottom);
}
void Frustum::calculate (Planes &planes, const Vector &viewAngle, const Vector &viewOffset) {
void Frustum::calculate (Planes &planes, const Vector &viewAngle, const Vector &viewOffset) const {
Vector forward {}, right {}, up {};
viewAngle.angleVectors (&forward, &right, &up);

View file

@ -179,7 +179,7 @@ void GraphVistable::load () {
}
}
void GraphVistable::save () {
void GraphVistable::save () const {
if (!graph.length () || graph.hasChanged () || m_rebuild) {
return;
}