2019-08-12 14:16:28 +03:00
|
|
|
//
|
2023-05-24 23:41:23 +03:00
|
|
|
// YaPB, based on PODBot by Markus Klinge ("CountFloyd").
|
|
|
|
|
// Copyright © YaPB Project Developers <yapb@jeefo.net>.
|
2019-08-12 14:16:28 +03:00
|
|
|
//
|
2020-11-03 08:57:12 +03:00
|
|
|
// SPDX-License-Identifier: MIT
|
2019-08-12 14:16:28 +03:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2020-06-12 18:52:38 +03:00
|
|
|
class BotSupport final : public Singleton <BotSupport> {
|
2023-05-06 20:14:03 +03:00
|
|
|
private:
|
|
|
|
|
mutable Mutex m_cs {};
|
|
|
|
|
|
2019-08-12 14:16:28 +03:00
|
|
|
private:
|
2023-04-02 12:17:12 +03:00
|
|
|
bool m_needToSendWelcome {};
|
|
|
|
|
float m_welcomeReceiveTime {};
|
2019-08-12 14:16:28 +03:00
|
|
|
|
2023-04-02 12:17:12 +03:00
|
|
|
StringArray m_sentences {};
|
|
|
|
|
SmallArray <Client> m_clients {};
|
2019-08-12 14:16:28 +03:00
|
|
|
|
aim: verify camp angles from nav data before using them
aim: tweaked a bit grenade handling, so bots should use them more
aim: reduce time between selecting grenade and throwing it away
aim: removed hacks in look angles code, due to removing yb_whoose_your_daddy cvar
aim: use direct enemy origin from visibility check, and not re-calculate it
aim: update enemy prediction, so it now depends on frame interval for a bot
aim: additional height offset are tweaked, and now used only for difficulty 4
nav: tweaked a bit player avoidance code, and it's not preventing bot from checking terrain
nav: do not check banned nodes, when bucket sizes re too low
nav: cover nodes are now selected depending on total bots on server
nav: let bot enter pause task after long jump
nav: extend velocity by a little for a jump, like it was in first versions of bot
nav: stuck checking is now taken in account lower minimal speed if bot is ducking
fix: navigation reachability timers, so bots will have correct current node index while camping
fix: bots are unable to finish pickup or destroy breakable task, if target is not reachable
fix: cover nodes are now calculated as they should
fix: manual calling bots add_[t/ct] now ignores yb_join_team cvar
bot: tweaked a little difficulty levels, so level 4 is now nightmare level, and 3 is very heard
bot: minor refactoring and moving functions to correct source file
bot: add yb_economics_disrespect_percent, so bots can ignore economics and buy more different guns
bot: add yb_check_darkness that allows to disable darkness checks for bot, thus disallowing usage of flashlight
bot: camp buttons are now lightly depends on bot health
chat: welcome chat message from bots is now sent during first freeze time period
crlib: switch over to stdint.h and remove crlib-own types
crlib: fixed alignment in sse code
2023-04-07 14:46:49 +03:00
|
|
|
HashMap <int32_t, String> m_weaponAlias {};
|
2019-08-12 14:16:28 +03:00
|
|
|
|
|
|
|
|
public:
|
2020-06-12 18:52:38 +03:00
|
|
|
BotSupport ();
|
|
|
|
|
~BotSupport () = default;
|
2019-08-12 14:16:28 +03:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// need to send welcome message ?
|
|
|
|
|
void checkWelcome ();
|
|
|
|
|
|
2019-09-14 23:13:55 +03:00
|
|
|
// converts weapon id to alias name
|
aim: verify camp angles from nav data before using them
aim: tweaked a bit grenade handling, so bots should use them more
aim: reduce time between selecting grenade and throwing it away
aim: removed hacks in look angles code, due to removing yb_whoose_your_daddy cvar
aim: use direct enemy origin from visibility check, and not re-calculate it
aim: update enemy prediction, so it now depends on frame interval for a bot
aim: additional height offset are tweaked, and now used only for difficulty 4
nav: tweaked a bit player avoidance code, and it's not preventing bot from checking terrain
nav: do not check banned nodes, when bucket sizes re too low
nav: cover nodes are now selected depending on total bots on server
nav: let bot enter pause task after long jump
nav: extend velocity by a little for a jump, like it was in first versions of bot
nav: stuck checking is now taken in account lower minimal speed if bot is ducking
fix: navigation reachability timers, so bots will have correct current node index while camping
fix: bots are unable to finish pickup or destroy breakable task, if target is not reachable
fix: cover nodes are now calculated as they should
fix: manual calling bots add_[t/ct] now ignores yb_join_team cvar
bot: tweaked a little difficulty levels, so level 4 is now nightmare level, and 3 is very heard
bot: minor refactoring and moving functions to correct source file
bot: add yb_economics_disrespect_percent, so bots can ignore economics and buy more different guns
bot: add yb_check_darkness that allows to disable darkness checks for bot, thus disallowing usage of flashlight
bot: camp buttons are now lightly depends on bot health
chat: welcome chat message from bots is now sent during first freeze time period
crlib: switch over to stdint.h and remove crlib-own types
crlib: fixed alignment in sse code
2023-04-07 14:46:49 +03:00
|
|
|
StringRef weaponIdToAlias (int32_t id);
|
2019-08-12 14:16:28 +03:00
|
|
|
|
|
|
|
|
// check if origin is visible from the entity side
|
|
|
|
|
bool isVisible (const Vector &origin, edict_t *ent);
|
|
|
|
|
|
|
|
|
|
// check if entity is alive
|
|
|
|
|
bool isAlive (edict_t *ent);
|
|
|
|
|
|
2023-05-12 22:12:22 +03:00
|
|
|
// checks if entity is fakeclient
|
2019-08-12 14:16:28 +03:00
|
|
|
bool isFakeClient (edict_t *ent);
|
|
|
|
|
|
2023-05-12 22:12:22 +03:00
|
|
|
// check if entity is a player
|
2019-08-12 14:16:28 +03:00
|
|
|
bool isPlayer (edict_t *ent);
|
|
|
|
|
|
2023-05-12 22:12:22 +03:00
|
|
|
// check if entity is a monster
|
2020-12-03 14:14:22 +02:00
|
|
|
bool isMonster (edict_t *ent);
|
|
|
|
|
|
2023-05-12 22:12:22 +03:00
|
|
|
// check if entity is a item
|
2020-12-03 14:14:22 +02:00
|
|
|
bool isItem (edict_t *ent);
|
|
|
|
|
|
2019-08-12 14:16:28 +03:00
|
|
|
// check if entity is a vip
|
|
|
|
|
bool isPlayerVIP (edict_t *ent);
|
|
|
|
|
|
2023-06-23 19:52:46 +03:00
|
|
|
// check if entity is a hostage entity
|
|
|
|
|
bool isHostageEntity (edict_t *ent);
|
|
|
|
|
|
2023-08-08 11:48:37 +03:00
|
|
|
// check if entity is a door entity
|
2023-06-24 02:36:51 +03:00
|
|
|
bool isDoorEntity (edict_t *ent);
|
|
|
|
|
|
|
|
|
|
// this function is checking that pointed by ent pointer obstacle, can be destroyed
|
|
|
|
|
bool isShootableBreakable (edict_t *ent);
|
|
|
|
|
|
2019-08-12 14:16:28 +03:00
|
|
|
// nearest player search helper
|
|
|
|
|
bool findNearestPlayer (void **holder, edict_t *to, float searchDistance = 4096.0, bool sameTeam = false, bool needBot = false, bool needAlive = false, bool needDrawn = false, bool needBotWithC4 = false);
|
|
|
|
|
|
|
|
|
|
// tracing decals for bots spraying logos
|
2024-01-19 00:03:45 +03:00
|
|
|
void decalTrace (entvars_t *pev, TraceResult *trace, int logotypeIndex);
|
2019-08-12 14:16:28 +03:00
|
|
|
|
|
|
|
|
// update stats on clients
|
|
|
|
|
void updateClients ();
|
|
|
|
|
|
|
|
|
|
// generates ping bitmask for SVC_PINGS message
|
|
|
|
|
int getPingBitmask (edict_t *ent, int loss, int ping);
|
|
|
|
|
|
2023-05-06 20:14:03 +03:00
|
|
|
// calculate our own pings for all the players
|
|
|
|
|
void syncCalculatePings ();
|
|
|
|
|
|
2019-08-12 14:16:28 +03:00
|
|
|
// calculate our own pings for all the players
|
|
|
|
|
void calculatePings ();
|
|
|
|
|
|
|
|
|
|
// send modified pings to all the clients
|
2021-09-16 20:11:57 +03:00
|
|
|
void emitPings (edict_t *to);
|
2019-08-12 14:16:28 +03:00
|
|
|
|
2023-05-12 22:12:22 +03:00
|
|
|
// checks if same model omitting the models directory
|
2020-12-15 15:28:58 +03:00
|
|
|
bool isModel (const edict_t *ent, StringRef model);
|
|
|
|
|
|
2022-01-16 01:14:11 +03:00
|
|
|
// get the current date and time as string
|
|
|
|
|
String getCurrentDateTime ();
|
|
|
|
|
|
2024-01-19 18:29:20 +03:00
|
|
|
// generates fake steam id from bot name
|
|
|
|
|
StringRef getFakeSteamId (edict_t *ent);
|
|
|
|
|
|
2023-08-22 09:45:29 +03:00
|
|
|
// get's the wave length
|
|
|
|
|
float getWaveLength (StringRef filename);
|
|
|
|
|
|
2019-08-12 14:16:28 +03:00
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// re-show welcome after changelevel ?
|
|
|
|
|
void setNeedForWelcome (bool need) {
|
|
|
|
|
m_needToSendWelcome = need;
|
2024-01-19 00:03:45 +03:00
|
|
|
m_welcomeReceiveTime = -1.0f;
|
2019-08-12 14:16:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// get array of clients
|
|
|
|
|
SmallArray <Client> &getClients () {
|
|
|
|
|
return m_clients;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// get clients as const-reference
|
|
|
|
|
const SmallArray <Client> &getClients () const {
|
|
|
|
|
return m_clients;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// get single client as ref
|
|
|
|
|
Client &getClient (const int index) {
|
|
|
|
|
return m_clients[index];
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 23:31:54 +03:00
|
|
|
// gets the shooting cone deviation
|
2023-08-08 11:48:37 +03:00
|
|
|
float getShootingCone (edict_t *ent, const Vector &pos) {
|
|
|
|
|
return ent->v.v_angle.forward () | (pos - (ent->v.origin + ent->v.view_ofs)).normalize (); // he's facing it, he meant it
|
2019-08-29 23:31:54 +03:00
|
|
|
}
|
|
|
|
|
|
2023-08-08 11:48:37 +03:00
|
|
|
// check if position is inside view cone of entity
|
|
|
|
|
bool isInViewCone (const Vector &pos, edict_t *ent) {
|
|
|
|
|
return getShootingCone (ent, pos) >= cr::cosf (cr::deg2rad ((ent->v.fov > 0 ? ent->v.fov : 90.0f) * 0.5f));
|
2019-08-29 23:31:54 +03:00
|
|
|
}
|
2019-08-12 14:16:28 +03:00
|
|
|
};
|
|
|
|
|
|
2023-05-12 22:12:22 +03:00
|
|
|
// expose global
|
2020-06-12 18:52:38 +03:00
|
|
|
CR_EXPOSE_GLOBAL_SINGLETON (BotSupport, util);
|