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
This commit is contained in:
parent
722e4eda93
commit
29c00565dc
31 changed files with 1395 additions and 1305 deletions
34
inc/config.h
34
inc/config.h
|
|
@ -32,9 +32,9 @@ class BotConfig final : public Singleton <BotConfig> {
|
|||
public:
|
||||
struct DifficultyData {
|
||||
float reaction[2] {};
|
||||
int32 headshotPct {};
|
||||
int32 seenThruPct {};
|
||||
int32 hearThruPct {};
|
||||
int32_t headshotPct {};
|
||||
int32_t seenThruPct {};
|
||||
int32_t hearThruPct {};
|
||||
};
|
||||
|
||||
private:
|
||||
|
|
@ -49,16 +49,16 @@ private:
|
|||
StringArray m_logos {};
|
||||
StringArray m_avatars {};
|
||||
|
||||
HashMap <uint32, String, Hash <int32>> m_language {};
|
||||
HashMap <int32, DifficultyData> m_difficulty {};
|
||||
HashMap <uint32_t, String, Hash <int32_t>> m_language {};
|
||||
HashMap <int32_t, DifficultyData> m_difficulty {};
|
||||
HashMap <String, String> m_custom {};
|
||||
|
||||
// default tables for personality weapon preferences, overridden by weapon.cfg
|
||||
SmallArray <int32> m_normalWeaponPrefs = { 0, 2, 1, 4, 5, 6, 3, 12, 10, 24, 25, 13, 11, 8, 7, 22, 23, 18, 21, 17, 19, 15, 17, 9, 14, 16 };
|
||||
SmallArray <int32> m_rusherWeaponPrefs = { 0, 2, 1, 4, 5, 6, 3, 24, 19, 22, 23, 20, 21, 10, 12, 13, 7, 8, 11, 9, 18, 17, 19, 25, 15, 16 };
|
||||
SmallArray <int32> m_carefulWeaponPrefs = { 0, 2, 1, 4, 25, 6, 3, 7, 8, 12, 10, 13, 11, 9, 24, 18, 14, 17, 16, 15, 19, 20, 21, 22, 23, 5 };
|
||||
SmallArray <int32> m_botBuyEconomyTable = { 1900, 2100, 2100, 4000, 6000, 7000, 16000, 1200, 800, 1000, 3000 };
|
||||
SmallArray <int32> m_grenadeBuyPrecent = { 95, 85, 60 };
|
||||
SmallArray <int32_t> m_normalWeaponPrefs = { 0, 2, 1, 4, 5, 6, 3, 12, 10, 24, 25, 13, 11, 8, 7, 22, 23, 18, 21, 17, 19, 15, 17, 9, 14, 16 };
|
||||
SmallArray <int32_t> m_rusherWeaponPrefs = { 0, 2, 1, 4, 5, 6, 3, 24, 19, 22, 23, 20, 21, 10, 12, 13, 7, 8, 11, 9, 18, 17, 19, 25, 15, 16 };
|
||||
SmallArray <int32_t> m_carefulWeaponPrefs = { 0, 2, 1, 4, 25, 6, 3, 7, 8, 12, 10, 13, 11, 9, 24, 18, 14, 17, 16, 15, 19, 20, 21, 22, 23, 5 };
|
||||
SmallArray <int32_t> m_botBuyEconomyTable = { 1900, 2100, 2100, 4000, 6000, 7000, 16000, 1200, 800, 1000, 3000 };
|
||||
SmallArray <int32_t> m_grenadeBuyPrecent = { 95, 85, 60 };
|
||||
|
||||
public:
|
||||
BotConfig ();
|
||||
|
|
@ -138,7 +138,7 @@ private:
|
|||
};
|
||||
|
||||
// hash the lang string, only the letters
|
||||
uint32 hashLangString (StringRef str);
|
||||
uint32_t hashLangString (StringRef str);
|
||||
|
||||
public:
|
||||
|
||||
|
|
@ -188,7 +188,7 @@ public:
|
|||
}
|
||||
|
||||
// get's weapons type by id
|
||||
int32 getWeaponType (int id) const {
|
||||
int32_t getWeaponType (int id) const {
|
||||
for (const auto &weapon : m_weapons) {
|
||||
if (weapon.id == id) {
|
||||
return weapon.type;
|
||||
|
|
@ -198,7 +198,7 @@ public:
|
|||
}
|
||||
|
||||
// get's weapon preferences for personality
|
||||
int32 *getWeaponPrefs (int personality) const {
|
||||
int32_t *getWeaponPrefs (int personality) const {
|
||||
switch (personality) {
|
||||
case Personality::Normal:
|
||||
default:
|
||||
|
|
@ -213,7 +213,7 @@ public:
|
|||
}
|
||||
|
||||
// get's the difficulty level tweaks
|
||||
DifficultyData *getDifficultyTweaks (int32 level) {
|
||||
DifficultyData *getDifficultyTweaks (int32_t level) {
|
||||
if (level < Difficulty::Noob || level > Difficulty::Expert) {
|
||||
return &m_difficulty[Difficulty::Expert];
|
||||
}
|
||||
|
|
@ -221,7 +221,7 @@ public:
|
|||
}
|
||||
|
||||
// get economics value
|
||||
int32 *getEconLimit () {
|
||||
int32_t *getEconLimit () {
|
||||
return m_botBuyEconomyTable.data ();
|
||||
}
|
||||
|
||||
|
|
@ -239,8 +239,8 @@ public:
|
|||
}
|
||||
|
||||
// get's random logo index
|
||||
int32 getRandomLogoIndex () const {
|
||||
return static_cast <int32> (m_logos.index (m_logos.random ()));
|
||||
int32_t getRandomLogoIndex () const {
|
||||
return static_cast <int32_t> (m_logos.index (m_logos.random ()));
|
||||
}
|
||||
|
||||
// get random name by index
|
||||
|
|
|
|||
|
|
@ -52,13 +52,13 @@ public:
|
|||
|
||||
// queued text message to prevent overflow with rapid output
|
||||
struct PrintQueue {
|
||||
int32 destination {};
|
||||
int32_t destination {};
|
||||
String text;
|
||||
|
||||
public:
|
||||
explicit PrintQueue () = default;
|
||||
|
||||
PrintQueue (int32 destination, StringRef text) : destination (destination), text (text)
|
||||
PrintQueue (int32_t destination, StringRef text) : destination (destination), text (text)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
|
|||
36
inc/engine.h
36
inc/engine.h
|
|
@ -75,14 +75,14 @@ struct ConVarReg {
|
|||
float initial, min, max;
|
||||
bool missing;
|
||||
bool bounded;
|
||||
int32 type;
|
||||
int32_t type;
|
||||
};
|
||||
|
||||
// entity prototype
|
||||
using EntityFunction = void (*) (entvars_t *);
|
||||
|
||||
// rehlds has this fixed, but original hlds doesn't allocate string space passed to precache* argument, so game will crash when unloading module using metamod
|
||||
class EngineWrap final : public DenyCopying {
|
||||
class EngineWrap final {
|
||||
public:
|
||||
EngineWrap () = default;
|
||||
~EngineWrap () = default;
|
||||
|
|
@ -93,11 +93,11 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
int32 precacheModel (const char *model) const {
|
||||
int32_t precacheModel (const char *model) const {
|
||||
return engfuncs.pfnPrecacheModel (allocStr (model));
|
||||
}
|
||||
|
||||
int32 precacheSound (const char *sound) const {
|
||||
int32_t precacheSound (const char *sound) const {
|
||||
return engfuncs.pfnPrecacheSound (allocStr (sound));
|
||||
}
|
||||
|
||||
|
|
@ -182,7 +182,7 @@ public:
|
|||
void prepareBotArgs (edict_t *ent, String str);
|
||||
|
||||
// adds cvar to registration stack
|
||||
void addNewCvar (const char *name, const char *value, const char *info, bool bounded, float min, float max, int32 varType, bool missingAction, const char *regval, class ConVar *self);
|
||||
void addNewCvar (const char *name, const char *value, const char *info, bool bounded, float min, float max, int32_t varType, bool missingAction, const char *regval, class ConVar *self);
|
||||
|
||||
// check the cvar bounds
|
||||
void checkCvarsBounds ();
|
||||
|
|
@ -240,7 +240,7 @@ public:
|
|||
}
|
||||
|
||||
// gets custom engine argv for client command
|
||||
const char *botArgv (int32 index) const {
|
||||
const char *botArgv (int32_t index) const {
|
||||
if (static_cast <size_t> (index) >= m_botArgs.length ()) {
|
||||
return "";
|
||||
}
|
||||
|
|
@ -248,8 +248,8 @@ public:
|
|||
}
|
||||
|
||||
// gets custom engine argc for client command
|
||||
int32 botArgc () const {
|
||||
return m_botArgs.length <int32> ();
|
||||
int32_t botArgc () const {
|
||||
return m_botArgs.length <int32_t> ();
|
||||
}
|
||||
|
||||
// gets edict pointer out of entity index
|
||||
|
|
@ -314,10 +314,10 @@ public:
|
|||
void setPlayerStartDrawModels ();
|
||||
|
||||
// check the engine visibility wrapper
|
||||
bool checkVisibility (edict_t *ent, uint8 *set);
|
||||
bool checkVisibility (edict_t *ent, uint8_t *set);
|
||||
|
||||
// get pvs/pas visibility set
|
||||
uint8 *getVisibilitySet (Bot *bot, bool pvs);
|
||||
uint8_t *getVisibilitySet (Bot *bot, bool pvs);
|
||||
|
||||
// what kind of game engine / game dll / mod / tool we're running ?
|
||||
bool is (const int type) const {
|
||||
|
|
@ -409,11 +409,11 @@ public:
|
|||
~ConVar () = default;
|
||||
|
||||
public:
|
||||
ConVar (const char *name, const char *initval, int32 type = Var::NoServer, bool regMissing = false, const char *regVal = nullptr) : ptr (nullptr) {
|
||||
ConVar (const char *name, const char *initval, int32_t type = Var::NoServer, bool regMissing = false, const char *regVal = nullptr) : ptr (nullptr) {
|
||||
Game::instance ().addNewCvar (name, initval, "", false, 0.0f, 0.0f, type, regMissing, regVal, this);
|
||||
}
|
||||
|
||||
ConVar (const char *name, const char *initval, const char *info, bool bounded = true, float min = 0.0f, float max = 1.0f, int32 type = Var::NoServer, bool regMissing = false, const char *regVal = nullptr) : ptr (nullptr) {
|
||||
ConVar (const char *name, const char *initval, const char *info, bool bounded = true, float min = 0.0f, float max = 1.0f, int32_t type = Var::NoServer, bool regMissing = false, const char *regVal = nullptr) : ptr (nullptr) {
|
||||
Game::instance ().addNewCvar (name, initval, info, bounded, min, max, type, regMissing, regVal, this);
|
||||
}
|
||||
|
||||
|
|
@ -505,8 +505,8 @@ public:
|
|||
}
|
||||
|
||||
public:
|
||||
static inline uint16 fu16 (float value, float scale) {
|
||||
return cr::clamp <uint16> (static_cast <uint16> (value * cr::bit (static_cast <short> (scale))), 0, USHRT_MAX);
|
||||
static inline uint16_t fu16 (float value, float scale) {
|
||||
return cr::clamp <uint16_t> (static_cast <uint16_t> (value * cr::bit (static_cast <short> (scale))), 0, USHRT_MAX);
|
||||
}
|
||||
|
||||
static inline short fs16 (float value, float scale) {
|
||||
|
|
@ -517,7 +517,7 @@ public:
|
|||
class LightMeasure final : public Singleton <LightMeasure> {
|
||||
private:
|
||||
lightstyle_t m_lightstyle[MAX_LIGHTSTYLES] {};
|
||||
uint32 m_lightstyleValue[MAX_LIGHTSTYLEVALUE] {};
|
||||
uint32_t m_lightstyleValue[MAX_LIGHTSTYLEVALUE] {};
|
||||
bool m_doAnimation = false;
|
||||
|
||||
Color m_point;
|
||||
|
|
@ -563,11 +563,11 @@ public:
|
|||
|
||||
// simple handler for parsing and rewriting queries (fake queries)
|
||||
class QueryBuffer {
|
||||
SmallArray <uint8> m_buffer {};
|
||||
SmallArray <uint8_t> m_buffer {};
|
||||
size_t m_cursor {};
|
||||
|
||||
public:
|
||||
QueryBuffer (const uint8 *msg, size_t length, size_t shift) : m_cursor (0) {
|
||||
QueryBuffer (const uint8_t *msg, size_t length, size_t shift) : m_cursor (0) {
|
||||
m_buffer.insert (0, msg, length);
|
||||
m_cursor += shift;
|
||||
}
|
||||
|
|
@ -630,7 +630,7 @@ public:
|
|||
}
|
||||
|
||||
public:
|
||||
Twin <const uint8 *, size_t> data () {
|
||||
Twin <const uint8_t *, size_t> data () {
|
||||
return { m_buffer.data (), m_buffer.length () };
|
||||
}
|
||||
};
|
||||
|
|
|
|||
76
inc/graph.h
76
inc/graph.h
|
|
@ -25,7 +25,7 @@ CR_DECLARE_SCOPED_ENUM (NodeFlag,
|
|||
)
|
||||
|
||||
// defines for node connection flags field (16 bits are available)
|
||||
CR_DECLARE_SCOPED_ENUM_TYPE (PathFlag, uint16,
|
||||
CR_DECLARE_SCOPED_ENUM_TYPE (PathFlag, uint16_t,
|
||||
Jump = cr::bit (0) // must jump for this connection
|
||||
)
|
||||
|
||||
|
|
@ -112,59 +112,59 @@ struct Route {
|
|||
|
||||
// general stprage header information structure
|
||||
struct StorageHeader {
|
||||
int32 magic;
|
||||
int32 version;
|
||||
int32 options;
|
||||
int32 length;
|
||||
int32 compressed;
|
||||
int32 uncompressed;
|
||||
int32_t magic;
|
||||
int32_t version;
|
||||
int32_t options;
|
||||
int32_t length;
|
||||
int32_t compressed;
|
||||
int32_t uncompressed;
|
||||
};
|
||||
|
||||
// extension header for graph information
|
||||
struct ExtenHeader {
|
||||
char author[32]; // original author of graph
|
||||
int32 mapSize; // bsp size for checksumming map consistency
|
||||
int32_t mapSize; // bsp size for checksumming map consistency
|
||||
char modified[32]; // by whom modified
|
||||
};
|
||||
|
||||
// general waypoint header information structure
|
||||
struct PODGraphHeader {
|
||||
char header[8];
|
||||
int32 fileVersion;
|
||||
int32 pointNumber;
|
||||
int32_t fileVersion;
|
||||
int32_t pointNumber;
|
||||
char mapName[32];
|
||||
char author[32];
|
||||
};
|
||||
|
||||
// floyd-warshall matrices
|
||||
struct Matrix {
|
||||
int16 dist;
|
||||
int16 index;
|
||||
int16_t dist;
|
||||
int16_t index;
|
||||
};
|
||||
|
||||
// experience data hold in memory while playing
|
||||
struct Practice {
|
||||
int16 damage[kGameTeamNum];
|
||||
int16 index[kGameTeamNum];
|
||||
int16 value[kGameTeamNum];
|
||||
int16_t damage[kGameTeamNum];
|
||||
int16_t index[kGameTeamNum];
|
||||
int16_t value[kGameTeamNum];
|
||||
};
|
||||
|
||||
// defines linked waypoints
|
||||
struct PathLink {
|
||||
Vector velocity;
|
||||
int32 distance;
|
||||
uint16 flags;
|
||||
int16 index;
|
||||
int32_t distance;
|
||||
uint16_t flags;
|
||||
int16_t index;
|
||||
};
|
||||
|
||||
// defines visibility count
|
||||
struct PathVis {
|
||||
uint16 stand, crouch;
|
||||
uint16_t stand, crouch;
|
||||
};
|
||||
|
||||
// define graph path structure for yapb
|
||||
struct Path {
|
||||
int32 number, flags;
|
||||
int32_t number, flags;
|
||||
Vector origin, start, end;
|
||||
float radius, light, display;
|
||||
PathLink links[kMaxNodeLinks];
|
||||
|
|
@ -173,13 +173,13 @@ struct Path {
|
|||
|
||||
// define waypoint structure for podbot (will convert on load)
|
||||
struct PODPath {
|
||||
int32 number, flags;
|
||||
int32_t number, flags;
|
||||
Vector origin;
|
||||
float radius, csx, csy, cex, cey;
|
||||
int16 index[kMaxNodeLinks];
|
||||
uint16 conflags[kMaxNodeLinks];
|
||||
int16_t index[kMaxNodeLinks];
|
||||
uint16_t conflags[kMaxNodeLinks];
|
||||
Vector velocity[kMaxNodeLinks];
|
||||
int32 distance[kMaxNodeLinks];
|
||||
int32_t distance[kMaxNodeLinks];
|
||||
PathVis vis;
|
||||
};
|
||||
|
||||
|
|
@ -189,26 +189,26 @@ private:
|
|||
size_t m_cursor {};
|
||||
size_t m_length {};
|
||||
|
||||
UniquePtr <int32[]> m_path {};
|
||||
UniquePtr <int32_t[]> m_path {};
|
||||
|
||||
public:
|
||||
explicit PathWalk () = default;
|
||||
~PathWalk () = default;
|
||||
|
||||
public:
|
||||
int32 &next () {
|
||||
int32_t &next () {
|
||||
return at (1);
|
||||
}
|
||||
|
||||
int32 &first () {
|
||||
int32_t &first () {
|
||||
return at (0);
|
||||
}
|
||||
|
||||
int32 &last () {
|
||||
int32_t &last () {
|
||||
return at (length () - 1);
|
||||
}
|
||||
|
||||
int32 &at (size_t index) {
|
||||
int32_t &at (size_t index) {
|
||||
return m_path[m_cursor + index];
|
||||
}
|
||||
|
||||
|
|
@ -237,7 +237,7 @@ public:
|
|||
return !length ();
|
||||
}
|
||||
|
||||
void add (int32 node) {
|
||||
void add (int32_t node) {
|
||||
m_path[m_length++] = node;
|
||||
}
|
||||
|
||||
|
|
@ -249,7 +249,7 @@ public:
|
|||
}
|
||||
|
||||
void init (size_t length) {
|
||||
m_path = cr::makeUnique <int32 []> (length);
|
||||
m_path = cr::makeUnique <int32_t []> (length);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -297,11 +297,11 @@ private:
|
|||
IntArray m_rescuePoints {};
|
||||
IntArray m_visitedGoals {};
|
||||
|
||||
SmallArray <int32> m_buckets[kMaxBucketsInsidePos][kMaxBucketsInsidePos][kMaxBucketsInsidePos];
|
||||
SmallArray <int32_t> m_buckets[kMaxBucketsInsidePos][kMaxBucketsInsidePos][kMaxBucketsInsidePos];
|
||||
SmallArray <Matrix> m_matrix {};
|
||||
SmallArray <Practice> m_practice {};
|
||||
SmallArray <Path> m_paths {};
|
||||
SmallArray <uint8> m_vistable {};
|
||||
SmallArray <uint8_t> m_vistable {};
|
||||
|
||||
String m_graphAuthor {};
|
||||
String m_graphModified {};
|
||||
|
|
@ -346,7 +346,7 @@ public:
|
|||
bool canDownload ();
|
||||
|
||||
template <typename U> bool saveStorage (StringRef ext, StringRef name, StorageOption options, StorageVersion version, const SmallArray <U> &data, ExtenHeader *exten);
|
||||
template <typename U> bool loadStorage (StringRef ext, StringRef name, StorageOption options, StorageVersion version, SmallArray <U> &data, ExtenHeader *exten, int32 *outOptions);
|
||||
template <typename U> bool loadStorage (StringRef ext, StringRef name, StorageOption options, StorageVersion version, SmallArray <U> &data, ExtenHeader *exten, int32_t *outOptions);
|
||||
template <typename ...Args> bool raiseLoadingError (bool isGraph, MemFile &file, const char *fmt, Args &&...args);
|
||||
|
||||
void saveOldFormat ();
|
||||
|
|
@ -396,7 +396,7 @@ public:
|
|||
|
||||
Bucket locateBucket (const Vector &pos);
|
||||
IntArray searchRadius (float radius, const Vector &origin, int maxCount = -1);
|
||||
const SmallArray <int32> &getNodesInBucket (const Vector &pos);
|
||||
const SmallArray <int32_t> &getNodesInBucket (const Vector &pos);
|
||||
|
||||
public:
|
||||
size_t getMaxRouteLength () const {
|
||||
|
|
@ -446,12 +446,12 @@ public:
|
|||
|
||||
// check nodes range
|
||||
bool exists (int index) const {
|
||||
return index >= 0 && index < static_cast <int> (m_paths.length ());
|
||||
return index >= 0 && index < length ();
|
||||
}
|
||||
|
||||
// get real nodes num
|
||||
int32 length () const {
|
||||
return m_paths.length <int32> ();
|
||||
int32_t length () const {
|
||||
return m_paths.length <int32_t> ();
|
||||
}
|
||||
|
||||
// check if has editor
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ private:
|
|||
|
||||
public:
|
||||
float MaxView = 4096.0f;
|
||||
float MinView = 5.0f;
|
||||
float MinView = 2.0f;
|
||||
|
||||
public:
|
||||
float farHeight; // height of the far frustum
|
||||
|
|
@ -108,6 +108,7 @@ public:
|
|||
|
||||
int getHumansCount (bool ignoreSpectators = false);
|
||||
int getAliveHumansCount ();
|
||||
int getPlayerPriority (edict_t *ent);
|
||||
|
||||
float getConnectTime (StringRef name, float original);
|
||||
float getAverageTeamKPD (bool calcForBots);
|
||||
|
|
@ -174,12 +175,12 @@ public:
|
|||
return m_economicsGood[team];
|
||||
}
|
||||
|
||||
int32 getLastWinner () const {
|
||||
int32_t getLastWinner () const {
|
||||
return m_lastWinner;
|
||||
}
|
||||
|
||||
int32 getBotCount () {
|
||||
return m_bots.length <int32> ();
|
||||
int32_t getBotCount () {
|
||||
return m_bots.length <int32_t> ();
|
||||
}
|
||||
|
||||
// get the list of filters
|
||||
|
|
|
|||
|
|
@ -65,27 +65,27 @@ CR_DECLARE_SCOPED_ENUM (StatusIconCache,
|
|||
class MessageDispatcher final : public Singleton <MessageDispatcher> {
|
||||
private:
|
||||
using MsgFunc = void (MessageDispatcher::*) ();
|
||||
using MsgHash = Hash <int32>;
|
||||
using MsgHash = Hash <int32_t>;
|
||||
|
||||
private:
|
||||
struct Args {
|
||||
union {
|
||||
float float_;
|
||||
int32 long_;
|
||||
int32_t long_;
|
||||
const char *chars_;
|
||||
};
|
||||
|
||||
public:
|
||||
Args (float value) : float_ (value) { }
|
||||
Args (int32 value) : long_ (value) { }
|
||||
Args (int32_t value) : long_ (value) { }
|
||||
Args (const char *value) : chars_ (value) { }
|
||||
};
|
||||
|
||||
private:
|
||||
HashMap <String, int32> m_textMsgCache {}; // cache strings for faster access for textmsg
|
||||
HashMap <String, int32> m_showMenuCache {}; // cache for the showmenu message
|
||||
HashMap <String, int32> m_statusIconCache {}; // cache for status icon message
|
||||
HashMap <String, int32> m_teamInfoCache {}; // cache for teaminfo message
|
||||
HashMap <String, int32_t> m_textMsgCache {}; // cache strings for faster access for textmsg
|
||||
HashMap <String, int32_t> m_showMenuCache {}; // cache for the showmenu message
|
||||
HashMap <String, int32_t> m_statusIconCache {}; // cache for status icon message
|
||||
HashMap <String, int32_t> m_teamInfoCache {}; // cache for teaminfo message
|
||||
|
||||
private:
|
||||
Bot *m_bot {}; // owner of a message
|
||||
|
|
@ -94,9 +94,9 @@ private:
|
|||
SmallArray <Args> m_args {}; // args collected from write* functions
|
||||
|
||||
HashMap <String, NetMsg> m_wanted {}; // wanted messages
|
||||
HashMap <int32, NetMsg> m_reverseMap {}; // maps engine message id to our message id
|
||||
HashMap <int32_t, NetMsg> m_reverseMap {}; // maps engine message id to our message id
|
||||
|
||||
HashMap <NetMsg, int32, MsgHash> m_maps {}; // maps our message to id to engine message id
|
||||
HashMap <NetMsg, int32_t, MsgHash> m_maps {}; // maps our message to id to engine message id
|
||||
HashMap <NetMsg, MsgFunc, MsgHash> m_handlers {}; // maps our message id to handler function
|
||||
|
||||
private:
|
||||
|
|
@ -122,17 +122,17 @@ private:
|
|||
void netMsgScoreAttrib ();
|
||||
|
||||
private:
|
||||
Bot *pickBot (int32 index);
|
||||
Bot *pickBot (int32_t index);
|
||||
|
||||
public:
|
||||
MessageDispatcher ();
|
||||
~MessageDispatcher () = default;
|
||||
|
||||
public:
|
||||
int32 add (StringRef name, int32 id);
|
||||
int32 id (NetMsg msg);
|
||||
int32_t add (StringRef name, int32_t id);
|
||||
int32_t id (NetMsg msg);
|
||||
|
||||
void start (edict_t *ent, int32 type);
|
||||
void start (edict_t *ent, int32_t type);
|
||||
void stop ();
|
||||
void ensureMessages ();
|
||||
|
||||
|
|
|
|||
40
inc/sounds.h
Normal file
40
inc/sounds.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
//
|
||||
// YaPB - Counter-Strike Bot based on PODBot by Markus Klinge.
|
||||
// Copyright © 2004-2023 YaPB Project <yapb@jeefo.net>.
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
// noise types
|
||||
CR_DECLARE_SCOPED_ENUM (Noise,
|
||||
NeedHandle = cr::bit (0),
|
||||
HitFall = cr::bit (1),
|
||||
Pickup = cr::bit (2),
|
||||
Zoom = cr::bit (3),
|
||||
Ammo = cr::bit (4),
|
||||
Hostage = cr::bit (5),
|
||||
Broke = cr::bit (6),
|
||||
Door = cr::bit (7),
|
||||
Defuse = cr::bit (8)
|
||||
)
|
||||
|
||||
class BotSounds final : public Singleton <BotSounds> {
|
||||
private:
|
||||
HashMap <String, int32_t> m_noiseCache {};
|
||||
|
||||
public:
|
||||
BotSounds ();
|
||||
~BotSounds () = default;
|
||||
|
||||
public:
|
||||
// attaches sound to client struct
|
||||
void listenNoise (edict_t *ent, StringRef sample, float volume);
|
||||
|
||||
// simulate sound for players
|
||||
void simulateNoise (int playerIndex);
|
||||
};
|
||||
|
||||
// explose global
|
||||
CR_EXPOSE_GLOBAL_SINGLETON (BotSounds, sounds);
|
||||
|
|
@ -7,18 +7,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
// noise types
|
||||
CR_DECLARE_SCOPED_ENUM (Noise,
|
||||
NeedHandle = cr::bit (0),
|
||||
HitFall = cr::bit (1),
|
||||
Pickup = cr::bit (2),
|
||||
Zoom = cr::bit (3),
|
||||
Ammo = cr::bit (4),
|
||||
Hostage = cr::bit (5),
|
||||
Broke = cr::bit (6),
|
||||
Door = cr::bit (7)
|
||||
)
|
||||
|
||||
class BotSupport final : public Singleton <BotSupport> {
|
||||
private:
|
||||
bool m_needToSendWelcome {};
|
||||
|
|
@ -28,8 +16,7 @@ private:
|
|||
SmallArray <Client> m_clients {};
|
||||
SmallArray <Twin <String, String>> m_tags {};
|
||||
|
||||
HashMap <int32, String> m_weaponAlias {};
|
||||
HashMap <String, int32> m_noiseCache {};
|
||||
HashMap <int32_t, String> m_weaponAlias {};
|
||||
Detour <decltype (sendto)> m_sendToDetour { "ws2_32.dll", "sendto", sendto };
|
||||
|
||||
public:
|
||||
|
|
@ -41,7 +28,7 @@ public:
|
|||
void checkWelcome ();
|
||||
|
||||
// converts weapon id to alias name
|
||||
StringRef weaponIdToAlias (int32 id);
|
||||
StringRef weaponIdToAlias (int32_t id);
|
||||
|
||||
// check if origin is visible from the entity side
|
||||
bool isVisible (const Vector &origin, edict_t *ent);
|
||||
|
|
@ -73,12 +60,6 @@ public:
|
|||
// tracing decals for bots spraying logos
|
||||
void traceDecals (entvars_t *pev, TraceResult *trace, int logotypeIndex);
|
||||
|
||||
// attaches sound to client struct
|
||||
void listenNoise (edict_t *ent, StringRef sample, float volume);
|
||||
|
||||
// simulate sound for players
|
||||
void simulateNoise (int playerIndex);
|
||||
|
||||
// update stats on clients
|
||||
void updateClients ();
|
||||
|
||||
|
|
@ -153,7 +134,7 @@ public:
|
|||
}
|
||||
|
||||
public:
|
||||
static int32 CR_STDCALL sendTo (int socket, const void *message, size_t length, int flags, const struct sockaddr *dest, int destLength);
|
||||
static int32_t CR_STDCALL sendTo (int socket, const void *message, size_t length, int flags, const struct sockaddr *dest, int destLength);
|
||||
};
|
||||
|
||||
// explose global
|
||||
|
|
|
|||
75
inc/yapb.h
75
inc/yapb.h
|
|
@ -46,6 +46,7 @@ CR_DECLARE_SCOPED_ENUM (Task,
|
|||
Hide,
|
||||
Blind,
|
||||
Spraypaint,
|
||||
Max
|
||||
)
|
||||
|
||||
// bot menu ids
|
||||
|
|
@ -349,7 +350,7 @@ CR_DECLARE_SCOPED_ENUM (Reload,
|
|||
)
|
||||
|
||||
// collision probes
|
||||
CR_DECLARE_SCOPED_ENUM (CollisionProbe, uint32,
|
||||
CR_DECLARE_SCOPED_ENUM (CollisionProbe, uint32_t,
|
||||
Jump = cr::bit (0), // probe jump when colliding
|
||||
Duck = cr::bit (1), // probe duck when colliding
|
||||
Strafe = cr::bit (2) // probe strafing when colliding
|
||||
|
|
@ -367,7 +368,7 @@ CR_DECLARE_SCOPED_ENUM (BotMsg,
|
|||
)
|
||||
|
||||
// sensing states
|
||||
CR_DECLARE_SCOPED_ENUM_TYPE (Sense, uint32,
|
||||
CR_DECLARE_SCOPED_ENUM_TYPE (Sense, uint32_t,
|
||||
SeeingEnemy = cr::bit (0), // seeing an enemy
|
||||
HearingEnemy = cr::bit (1), // hearing an enemy
|
||||
SuspectEnemy = cr::bit (2), // suspect enemy behind obstacle
|
||||
|
|
@ -378,7 +379,7 @@ CR_DECLARE_SCOPED_ENUM_TYPE (Sense, uint32,
|
|||
)
|
||||
|
||||
// positions to aim at
|
||||
CR_DECLARE_SCOPED_ENUM_TYPE (AimFlags, uint32,
|
||||
CR_DECLARE_SCOPED_ENUM_TYPE (AimFlags, uint32_t,
|
||||
Nav = cr::bit (0), // aim at nav point
|
||||
Camp = cr::bit (1), // aim at camp vector
|
||||
PredictPath = cr::bit (2), // aim at predicted path
|
||||
|
|
@ -445,11 +446,11 @@ namespace TaskPri {
|
|||
// storage file magic
|
||||
constexpr char kPodbotMagic[8] = "PODWAY!";
|
||||
|
||||
constexpr int32 kStorageMagic = 0x59415042; // storage magic for yapb-data files
|
||||
constexpr int32 kStorageMagicUB = 0x544f4255; //support also the fork format (merged back into yapb)
|
||||
constexpr int32_t kStorageMagic = 0x59415042; // storage magic for yapb-data files
|
||||
constexpr int32_t kStorageMagicUB = 0x544f4255; //support also the fork format (merged back into yapb)
|
||||
|
||||
constexpr float kInfiniteDistance = 9999999.0f;
|
||||
constexpr float kGrenadeCheckTime = 2.15f;
|
||||
constexpr float kGrenadeCheckTime = 0.6f;
|
||||
constexpr float kSprayDistance = 260.0f;
|
||||
constexpr float kDoubleSprayDistance = kSprayDistance * 2;
|
||||
constexpr float kMaxChatterRepeatInterval = 99.0f;
|
||||
|
|
@ -610,12 +611,12 @@ public:
|
|||
friend class BotManager;
|
||||
|
||||
private:
|
||||
uint32 m_states {}; // sensing bitstates
|
||||
uint32 m_collideMoves[kMaxCollideMoves] {}; // sorted array of movements
|
||||
uint32 m_collisionProbeBits {}; // bits of possible collision moves
|
||||
uint32 m_collStateIndex {}; // index into collide moves
|
||||
uint32 m_aimFlags {}; // aiming conditions
|
||||
uint32 m_currentTravelFlags {}; // connection flags like jumping
|
||||
uint32_t m_states {}; // sensing bitstates
|
||||
uint32_t m_collideMoves[kMaxCollideMoves] {}; // sorted array of movements
|
||||
uint32_t m_collisionProbeBits {}; // bits of possible collision moves
|
||||
uint32_t m_collStateIndex {}; // index into collide moves
|
||||
uint32_t m_aimFlags {}; // aiming conditions
|
||||
uint32_t m_currentTravelFlags {}; // connection flags like jumping
|
||||
|
||||
int m_traceSkip[TraceChannel::Num] {}; // trace need to be skipped?
|
||||
int m_messageQueue[32] {}; // stack for messages
|
||||
|
|
@ -688,6 +689,7 @@ private:
|
|||
float m_playServerTime {}; // time bot spent in the game
|
||||
float m_changeViewTime {}; // timestamp to change look at while at freezetime
|
||||
float m_breakableTime {}; // breakeble acquired time
|
||||
float m_jumpDistance {}; // last jump distance
|
||||
|
||||
bool m_moveToGoal {}; // bot currently moving to goal??
|
||||
bool m_isStuck {}; // bot is stuck
|
||||
|
|
@ -706,6 +708,7 @@ private:
|
|||
bool m_checkTerrain {}; // check for terrain
|
||||
bool m_moveToC4 {}; // ct is moving to bomb
|
||||
bool m_grenadeRequested {}; // bot requested change to grenade
|
||||
bool m_needToSendWelcomeChat {}; // bot needs to greet people on server?
|
||||
|
||||
Pickup m_pickupType {}; // type of entity which needs to be used/picked up
|
||||
PathWalk m_pathWalk {}; // pointer to current node from path
|
||||
|
|
@ -713,7 +716,7 @@ private:
|
|||
Fight m_fightStyle {}; // combat style to use
|
||||
CollisionState m_collisionState {}; // collision State
|
||||
FindPath m_pathType {}; // which pathfinder to use
|
||||
uint8 m_enemyParts {}; // visibility flags
|
||||
uint8_t m_enemyParts {}; // visibility flags
|
||||
TraceResult m_lastTrace[TraceChannel::Num] {}; // last trace result
|
||||
|
||||
edict_t *m_pickupItem {}; // pointer to entity of item to use/pickup
|
||||
|
|
@ -723,6 +726,7 @@ private:
|
|||
edict_t *m_lastBreakable {}; // last acquired breakable
|
||||
edict_t *m_targetEntity {}; // the entity that the bot is trying to reach
|
||||
edict_t *m_avoidGrenade {}; // pointer to grenade entity to avoid
|
||||
edict_t *m_hindrance {}; // the hidrance
|
||||
|
||||
Vector m_liftTravelPos {}; // lift travel position
|
||||
Vector m_moveAngles {}; // bot move angles
|
||||
|
|
@ -744,7 +748,7 @@ private:
|
|||
Array <edict_t *> m_ignoredBreakable {}; // list of ignored breakables
|
||||
Array <edict_t *> m_hostages {}; // pointer to used hostage entities
|
||||
Array <Route> m_routes {}; // pointer
|
||||
Array <int32> m_goalHistory {}; // history of selected goals
|
||||
Array <int32_t> m_nodeHistory {}; // history of selected goals
|
||||
|
||||
BinaryHeap <RouteTwin> m_routeQue {};
|
||||
Path *m_path {}; // pointer to the current path node
|
||||
|
|
@ -753,7 +757,7 @@ private:
|
|||
|
||||
private:
|
||||
int pickBestWeapon (int *vec, int count, int moneySave);
|
||||
int findCampingDirection ();
|
||||
int getRandomCampDir ();
|
||||
int findAimingNode (const Vector &to, int &pathLength);
|
||||
int findNearestNode ();
|
||||
int findBombNode ();
|
||||
|
|
@ -766,12 +770,12 @@ private:
|
|||
int bestSecondaryCarried ();
|
||||
int bestGrenadeCarried ();
|
||||
int bestWeaponCarried ();
|
||||
int changePointIndex (int index);
|
||||
int changeNodeIndex (int index);
|
||||
int numEnemiesNear (const Vector &origin, float radius);
|
||||
int numFriendsNear (const Vector &origin, float radius);
|
||||
|
||||
float getBombTimeleft ();
|
||||
float getReachTime ();
|
||||
float getEstimatedNodeReachTime ();
|
||||
float isInFOV (const Vector &dest);
|
||||
float getShiftSpeed ();
|
||||
float getEnemyBodyOffsetCorrection (float distance);
|
||||
|
|
@ -795,7 +799,6 @@ private:
|
|||
bool isInViewCone (const Vector &origin);
|
||||
bool checkBodyParts (edict_t *target);
|
||||
bool seesEnemy (edict_t *player, bool ignoreFOV = false);
|
||||
bool doPlayerAvoidance (const Vector &normal);
|
||||
bool hasActiveGoal ();
|
||||
bool advanceMovement ();
|
||||
bool isBombDefusing (const Vector &bombOrigin);
|
||||
|
|
@ -828,6 +831,8 @@ private:
|
|||
bool updateLiftStates ();
|
||||
bool canRunHeavyWeight ();
|
||||
|
||||
void doPlayerAvoidance (const Vector &normal);
|
||||
void selectCampButtons (int index);
|
||||
void markStale ();
|
||||
void instantChatter (int type);
|
||||
void update ();
|
||||
|
|
@ -851,10 +856,10 @@ private:
|
|||
void updateHearing ();
|
||||
void postprocessGoals (const IntArray &goals, int result[]);
|
||||
void updatePickups ();
|
||||
void ensureEntitiesClear ();
|
||||
void checkTerrain (float movedDistance, const Vector &dirNormal);
|
||||
void checkDarkness ();
|
||||
void checkParachute ();
|
||||
void getCampDirection (Vector *dest);
|
||||
void updatePracticeValue (int damage);
|
||||
void updatePracticeDamage (edict_t *attacker, int damage);
|
||||
void findShortestPath (int srcIndex, int destIndex);
|
||||
|
|
@ -880,13 +885,15 @@ private:
|
|||
void focusEnemy ();
|
||||
void selectBestWeapon ();
|
||||
void selectSecondary ();
|
||||
void selectWeaponByName (StringRef name);
|
||||
void selectWeaponById (int id);
|
||||
void selectWeaponByIndex (int index);
|
||||
|
||||
void completeTask ();
|
||||
void tasks ();
|
||||
void executeTasks ();
|
||||
void trackEnemies ();
|
||||
void choiceFreezetimeEntity ();
|
||||
void logicDuringFreezetime ();
|
||||
void translateInput ();
|
||||
void moveToGoal ();
|
||||
|
||||
void normal_ ();
|
||||
void spraypaint_ ();
|
||||
|
|
@ -911,15 +918,16 @@ private:
|
|||
|
||||
edict_t *lookupButton (const char *target);
|
||||
edict_t *lookupBreakable ();
|
||||
edict_t *correctGrenadeVelocity (const char *model);
|
||||
edict_t *setCorrectGrenadeVelocity (const char *model);
|
||||
|
||||
const Vector &getEnemyBodyOffset ();
|
||||
Vector calcThrow (const Vector &start, const Vector &stop);
|
||||
Vector calcToss (const Vector &start, const Vector &stop);
|
||||
Vector isBombAudible ();
|
||||
Vector getBodyOffsetError (float distance);
|
||||
Vector getCampDirection (const Vector &dest);
|
||||
|
||||
uint8 computeMsec ();
|
||||
uint8_t computeMsec ();
|
||||
|
||||
private:
|
||||
bool isOnLadder () const {
|
||||
|
|
@ -927,7 +935,7 @@ private:
|
|||
}
|
||||
|
||||
bool isOnFloor () const {
|
||||
return (pev->flags & (FL_ONGROUND | FL_PARTIALGROUND)) != 0;
|
||||
return !!(pev->flags & (FL_ONGROUND | FL_PARTIALGROUND));
|
||||
}
|
||||
|
||||
bool isInWater () const {
|
||||
|
|
@ -938,6 +946,10 @@ private:
|
|||
return (m_pathFlags & NodeFlag::Narrow);
|
||||
}
|
||||
|
||||
void dropCurrentWeapon () {
|
||||
issueCommand ("drop");
|
||||
}
|
||||
|
||||
public:
|
||||
entvars_t *pev {};
|
||||
|
||||
|
|
@ -1044,7 +1056,7 @@ public:
|
|||
BurstMode m_weaponBurstMode {}; // bot using burst mode? (famas/glock18, but also silencer mode)
|
||||
Personality m_personality {}; // bots type
|
||||
Array <BotTask> m_tasks {};
|
||||
Deque <int32> m_msgQueue {};
|
||||
Deque <int32_t> m_msgQueue {};
|
||||
|
||||
public:
|
||||
Bot (edict_t *bot, int difficulty, int personality, int team, int skin);
|
||||
|
|
@ -1097,7 +1109,7 @@ public:
|
|||
bool hasSecondaryWeapon ();
|
||||
bool hasShield ();
|
||||
bool isShieldDrawn ();
|
||||
bool findBestNearestNode ();
|
||||
bool findNextBestNode ();
|
||||
bool seesEntity (const Vector &dest, bool fromBody = false);
|
||||
bool canSkipNextTrace (TraceChannel channel);
|
||||
|
||||
|
|
@ -1105,7 +1117,6 @@ public:
|
|||
int getAmmo (int id);
|
||||
int getNearestToPlantedBomb ();
|
||||
|
||||
float getFrameInterval ();
|
||||
float getConnectionTime ();
|
||||
BotTask *getTask ();
|
||||
|
||||
|
|
@ -1114,7 +1125,9 @@ public:
|
|||
return m_ammoInClip[m_currentWeapon];
|
||||
}
|
||||
|
||||
bool isLowOnAmmo (const int index, const float factor) const;
|
||||
bool isDucking () const {
|
||||
return !!(pev->flags & FL_DUCKING);
|
||||
}
|
||||
|
||||
Vector getCenter () const {
|
||||
return (pev->absmax + pev->absmin) * 0.5;
|
||||
|
|
@ -1157,6 +1170,9 @@ public:
|
|||
return m_lastTrace[channel];
|
||||
}
|
||||
|
||||
// is low on admmo on index?
|
||||
bool isLowOnAmmo (const int index, const float factor) const;
|
||||
|
||||
// prints debug message
|
||||
template <typename ...Args> void debugMsg (const char *fmt, Args &&...args) {
|
||||
debugMsgInternal (strings.format (fmt, cr::forward <Args> (args)...));
|
||||
|
|
@ -1168,6 +1184,7 @@ public:
|
|||
|
||||
#include "config.h"
|
||||
#include "support.h"
|
||||
#include "sounds.h"
|
||||
#include "message.h"
|
||||
#include "engine.h"
|
||||
#include "manager.h"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue