yapb-noob-edition/inc/support.h

117 lines
3.2 KiB
C
Raw Normal View History

//
// YaPB, based on PODBot by Markus Klinge ("CountFloyd").
// Copyright © YaPB Project Developers <yapb@jeefo.net>.
//
// SPDX-License-Identifier: MIT
//
#pragma once
2020-06-12 18:52:38 +03:00
class BotSupport final : public Singleton <BotSupport> {
private:
bool m_needToSendWelcome {};
float m_welcomeReceiveTime {};
StringArray m_sentences {};
SmallArray <Client> m_clients {};
HashMap <int32_t, String> m_weaponAliases {};
public:
2020-06-12 18:52:38 +03:00
BotSupport ();
~BotSupport () = default;
public:
// need to send welcome message ?
void checkWelcome ();
// 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);
// 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);
// checks if entity is fakeclient
bool isFakeClient (edict_t *ent);
// check if entity is a player
bool isPlayer (edict_t *ent);
// check if entity is a monster
bool isMonster (edict_t *ent);
// check if entity is a item
bool isItem (edict_t *ent);
// check if entity is a vip
bool isPlayerVIP (edict_t *ent);
// check if entity is a hostage entity
bool isHostageEntity (edict_t *ent);
// check if entity is a door entity
bool isDoorEntity (edict_t *ent);
// this function is checking that pointed by ent pointer obstacle, can be destroyed
bool isBreakableEntity (edict_t *ent, bool initialSeed = false);
// 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
void decalTrace (entvars_t *pev, TraceResult *trace, int logotypeIndex);
// update stats on clients
void updateClients ();
// checks if same model omitting the models directory
bool isModel (const edict_t *ent, StringRef model);
// get the current date and time as string
String getCurrentDateTime ();
// generates fake steam id from bot name
StringRef getFakeSteamId (edict_t *ent);
// get's the wave length
float getWaveLength (StringRef filename);
public:
// re-show welcome after changelevel ?
void setNeedForWelcome (bool need) {
m_needToSendWelcome = need;
m_welcomeReceiveTime = -1.0f;
}
// 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];
}
// gets the shooting cone deviation
float getConeDeviation (edict_t *ent, const Vector &pos) const {
return ent->v.v_angle.forward () | (pos - (ent->v.origin + ent->v.view_ofs)).normalize (); // he's facing it, he meant it
}
// check if position is inside view cone of entity
bool isInViewCone (const Vector &pos, edict_t *ent) const {
return getConeDeviation (ent, pos) >= cr::cosf (cr::deg2rad ((ent->v.fov > 0 ? ent->v.fov : 90.0f) * 0.5f));
}
};
// expose global
2020-06-12 18:52:38 +03:00
CR_EXPOSE_GLOBAL_SINGLETON (BotSupport, util);