fix: bots at difficulty 0 unable to do anything useful
fix: lang configs unable to parse last translated line (fixes #340) fix: last enemy isn't cleared instantly with dead entity anymore fix: bot weakness in pistol rounds analyzer: improved optimization of useless nodes linkage: make inability to call gamedll player( non-fatal linkage: fixed bot boot on WON engines pre 2000 builds (support for beta 6.5 restored) cvars: added suupport to revert all cvars to defaults via 'yb cvars defaults' cvars: added cv_preferred_personality to select bot default personality refactor: use single function to send hud messages over the bot code bot: added random original podbot welcome message to preserve origins of this bot conf: shuffle bot names and chatter items on conflig load conf: simplified a bit chatter.cfg syntax (old syntax still works build: added support for building with CMake (thanks @Velaron) refactor: rall the memory hooks moved into their one cpp file
This commit is contained in:
parent
01046f7c9a
commit
bf91ef2831
35 changed files with 1256 additions and 734 deletions
|
|
@ -52,6 +52,9 @@ private:
|
|||
// cleanup bad nodes
|
||||
void cleanup ();
|
||||
|
||||
// show overlay message about analyzing
|
||||
void displayOverlayMessage ();
|
||||
|
||||
public:
|
||||
|
||||
// node should be created as crouch
|
||||
|
|
|
|||
64
inc/chatlib.h
Normal file
64
inc/chatlib.h
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
//
|
||||
// YaPB, based on PODBot by Markus Klinge ("CountFloyd").
|
||||
// Copyright © YaPB Project Developers <yapb@jeefo.net>.
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
// links keywords and replies together
|
||||
struct ChatKeywords {
|
||||
StringArray keywords;
|
||||
StringArray replies;
|
||||
StringArray usedReplies;
|
||||
|
||||
public:
|
||||
ChatKeywords () = default;
|
||||
|
||||
ChatKeywords (const StringArray &keywords, const StringArray &replies) {
|
||||
this->keywords.clear ();
|
||||
this->replies.clear ();
|
||||
this->usedReplies.clear ();
|
||||
|
||||
this->keywords.insert (0, keywords);
|
||||
this->replies.insert (0, replies);
|
||||
}
|
||||
};
|
||||
|
||||
// define chatting collection structure
|
||||
struct ChatCollection {
|
||||
int chatProbability {};
|
||||
float chatDelay {};
|
||||
float timeNextChat {};
|
||||
int entityIndex {};
|
||||
String sayText {};
|
||||
StringArray lastUsedSentences {};
|
||||
};
|
||||
|
||||
|
||||
// bot's chat manager
|
||||
class BotChatManager : public Singleton <BotChatManager> {
|
||||
private:
|
||||
SmallArray <Twin <String, String>> m_clanTags {}; // strippable clan tags
|
||||
|
||||
public:
|
||||
BotChatManager ();
|
||||
~BotChatManager () = default;
|
||||
|
||||
public:
|
||||
// chat helper to strip the clantags out of the string
|
||||
void stripTags (String &line);
|
||||
|
||||
// chat helper to make player name more human-like
|
||||
void humanizePlayerName (String &playerName);
|
||||
|
||||
// chat helper to add errors to the bot chat string
|
||||
void addChatErrors (String &line);
|
||||
|
||||
// chat helper to find keywords for given string
|
||||
bool checkKeywords (StringRef line, String &reply);
|
||||
};
|
||||
|
||||
// expose global
|
||||
CR_EXPOSE_GLOBAL_SINGLETON (BotChatManager, chatlib);
|
||||
|
|
@ -249,7 +249,7 @@ public:
|
|||
}
|
||||
|
||||
// get random name by index
|
||||
StringRef getRandomLogoName (int index) {
|
||||
StringRef getLogoName (int index) {
|
||||
return m_logos[index];
|
||||
}
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ public:
|
|||
if (m_custom.exists (name)) {
|
||||
return m_custom[name];
|
||||
}
|
||||
SimpleLogger::instance ().error ("Trying to fetch unknown custom variable: %s", name);
|
||||
logger.error ("Trying to fetch unknown custom variable: %s", name);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,6 @@ private:
|
|||
int menuKickPage4 (int item);
|
||||
|
||||
private:
|
||||
void enableDrawModels (bool enable);
|
||||
void createMenus ();
|
||||
|
||||
public:
|
||||
|
|
@ -166,6 +165,7 @@ public:
|
|||
void assignAdminRights (edict_t *ent, char *infobuffer);
|
||||
void maintainAdminRights ();
|
||||
void flushPrintQueue ();
|
||||
void enableDrawModels (bool enable);
|
||||
|
||||
public:
|
||||
void setFromConsole (bool console) {
|
||||
|
|
|
|||
201
inc/engine.h
201
inc/engine.h
|
|
@ -46,7 +46,8 @@ CR_DECLARE_SCOPED_ENUM (GameFlags,
|
|||
ReGameDLL = cr::bit (9), // server dll is a regamedll
|
||||
HasFakePings = cr::bit (10), // on that game version we can fake bots pings
|
||||
HasBotVoice = cr::bit (11), // on that game version we can use chatter
|
||||
AnniversaryHL25 = cr::bit (12) // half-life 25th anniversary engine
|
||||
AnniversaryHL25 = cr::bit (12), // half-life 25th anniversary engine
|
||||
Xash3DLegacy = cr::bit (13) // old xash3d-branch
|
||||
)
|
||||
|
||||
// defines map type
|
||||
|
|
@ -83,7 +84,7 @@ struct ConVarReg {
|
|||
};
|
||||
|
||||
// entity prototype
|
||||
using EntityFunction = void (*) (entvars_t *);
|
||||
using EntityProto = 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 {
|
||||
|
|
@ -128,6 +129,7 @@ private:
|
|||
Array <edict_t *> m_breakables {};
|
||||
SmallArray <ConVarReg> m_cvars {};
|
||||
SharedLibrary m_gameLib {};
|
||||
SharedLibrary m_engineLib {};
|
||||
EngineWrap m_engineWrap {};
|
||||
|
||||
bool m_precached {};
|
||||
|
|
@ -343,6 +345,11 @@ public:
|
|||
return m_gameLib;
|
||||
}
|
||||
|
||||
// get loaded engine lib
|
||||
const SharedLibrary &elib () {
|
||||
return m_engineLib;
|
||||
}
|
||||
|
||||
// get registered cvars list
|
||||
const SmallArray <ConVarReg> &getCvars () {
|
||||
return m_cvars;
|
||||
|
|
@ -369,6 +376,9 @@ public:
|
|||
// helper to sending the server message
|
||||
void sendServerMessage (StringRef message);
|
||||
|
||||
// helper for sending hud messages to client
|
||||
void sendHudMessage (edict_t *ent, const hudtextparms_t &htp, StringRef message);
|
||||
|
||||
// send server command
|
||||
template <typename ...Args> void serverCommand (const char *fmt, Args &&...args) {
|
||||
engfuncs.pfnServerCommand (strings.concat (strings.format (fmt, cr::forward <Args> (args)...), "\n", StringBuffer::StaticBufferSize));
|
||||
|
|
@ -459,6 +469,7 @@ public:
|
|||
Game::instance ().addNewCvar (name_.chars (), initval, info, bounded, min, max, type, regMissing, regVal, this);
|
||||
}
|
||||
|
||||
public:
|
||||
template <typename U> constexpr U get () const {
|
||||
if constexpr (cr::is_same <U, float>::value) {
|
||||
return ptr->value;
|
||||
|
|
@ -467,25 +478,41 @@ public:
|
|||
return ptr->value > 0.0f;
|
||||
}
|
||||
else if constexpr (cr::is_same <U, int>::value) {
|
||||
return static_cast <int> (ptr->value);
|
||||
return static_cast <U> (ptr->value);
|
||||
}
|
||||
else if constexpr (cr::is_same <U, StringRef>::value) {
|
||||
return ptr->string;
|
||||
}
|
||||
assert ("!Invalid type requested.");
|
||||
}
|
||||
|
||||
public:
|
||||
operator bool () const {
|
||||
return bool_ ();
|
||||
}
|
||||
|
||||
operator float () const {
|
||||
return float_ ();
|
||||
}
|
||||
|
||||
operator StringRef () {
|
||||
return str ();
|
||||
}
|
||||
|
||||
public:
|
||||
bool bool_ () const {
|
||||
return ptr->value > 0.0f;
|
||||
return get <bool> ();
|
||||
}
|
||||
|
||||
int int_ () const {
|
||||
return static_cast <int> (ptr->value);
|
||||
return get <int> ();
|
||||
}
|
||||
|
||||
float float_ () const {
|
||||
return ptr->value;
|
||||
return get <float> ();
|
||||
}
|
||||
|
||||
StringRef str () const {
|
||||
return ptr->string;
|
||||
return get <StringRef> ();
|
||||
}
|
||||
|
||||
StringRef name () const {
|
||||
|
|
@ -626,164 +653,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
// simple handler for parsing and rewriting queries (fake queries)
|
||||
class QueryBuffer {
|
||||
SmallArray <uint8_t> m_buffer {};
|
||||
size_t m_cursor {};
|
||||
|
||||
public:
|
||||
QueryBuffer (const uint8_t *msg, size_t length, size_t shift) : m_cursor (0) {
|
||||
m_buffer.insert (0, msg, length);
|
||||
m_cursor += shift;
|
||||
}
|
||||
|
||||
public:
|
||||
template <typename T> T read () {
|
||||
T result {};
|
||||
constexpr auto size = sizeof (T);
|
||||
|
||||
if (m_cursor + size > m_buffer.length ()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy (&result, m_buffer.data () + m_cursor, size);
|
||||
m_cursor += size;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// must be called right after read
|
||||
template <typename T> void write (T value) {
|
||||
constexpr auto size = sizeof (value);
|
||||
memcpy (m_buffer.data () + m_cursor - size, &value, size);
|
||||
}
|
||||
|
||||
template <typename T> void skip () {
|
||||
constexpr auto size = sizeof (T);
|
||||
|
||||
if (m_cursor + size > m_buffer.length ()) {
|
||||
return;
|
||||
}
|
||||
m_cursor += size;
|
||||
}
|
||||
|
||||
void skipString () {
|
||||
if (m_buffer.length () < m_cursor) {
|
||||
return;
|
||||
}
|
||||
for (; m_cursor < m_buffer.length () && m_buffer[m_cursor] != kNullChar; ++m_cursor) { }
|
||||
++m_cursor;
|
||||
}
|
||||
|
||||
|
||||
String readString () {
|
||||
if (m_buffer.length () < m_cursor) {
|
||||
return "";
|
||||
}
|
||||
String out;
|
||||
|
||||
for (; m_cursor < m_buffer.length () && m_buffer[m_cursor] != kNullChar; ++m_cursor) {
|
||||
out += m_buffer[m_cursor];
|
||||
}
|
||||
++m_cursor;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
void shiftToEnd () {
|
||||
m_cursor = m_buffer.length ();
|
||||
}
|
||||
|
||||
public:
|
||||
Twin <const uint8_t *, size_t> data () {
|
||||
return { m_buffer.data (), m_buffer.length () };
|
||||
}
|
||||
};
|
||||
|
||||
class EntityLinkage : public Singleton <EntityLinkage> {
|
||||
private:
|
||||
#if defined (CR_WINDOWS)
|
||||
# define DLSYM_FUNCTION GetProcAddress
|
||||
# define DLCLOSE_FUNCTION FreeLibrary
|
||||
# define DLSYM_RETURN SharedLibrary::Handle
|
||||
# define DLSYM_HANDLE HMODULE
|
||||
#else
|
||||
# define DLSYM_FUNCTION dlsym
|
||||
# define DLCLOSE_FUNCTION dlclose
|
||||
# define DLSYM_RETURN SharedLibrary::Handle
|
||||
# define DLSYM_HANDLE SharedLibrary::Handle
|
||||
#endif
|
||||
|
||||
private:
|
||||
bool m_paused { false };
|
||||
|
||||
Detour <decltype (DLSYM_FUNCTION)> m_dlsym;
|
||||
Detour <decltype (DLCLOSE_FUNCTION)> m_dlclose;
|
||||
HashMap <StringRef, SharedLibrary::Func> m_exports;
|
||||
|
||||
SharedLibrary m_self;
|
||||
|
||||
public:
|
||||
EntityLinkage () = default;
|
||||
|
||||
public:
|
||||
void initialize ();
|
||||
SharedLibrary::Func lookup (SharedLibrary::Handle module, const char *function);
|
||||
|
||||
int close (DLSYM_HANDLE module) {
|
||||
if (m_self.handle () == module) {
|
||||
disable ();
|
||||
return m_dlclose (module);
|
||||
}
|
||||
return m_dlclose (module);
|
||||
}
|
||||
|
||||
public:
|
||||
void callPlayerFunction (edict_t *ent);
|
||||
|
||||
public:
|
||||
void enable () {
|
||||
if (m_dlsym.detoured ()) {
|
||||
return;
|
||||
}
|
||||
m_dlsym.detour ();
|
||||
}
|
||||
|
||||
void disable () {
|
||||
if (!m_dlsym.detoured ()) {
|
||||
return;
|
||||
}
|
||||
m_dlsym.restore ();
|
||||
}
|
||||
|
||||
void setPaused (bool what) {
|
||||
m_paused = what;
|
||||
}
|
||||
|
||||
bool isPaused () const {
|
||||
return m_paused;
|
||||
}
|
||||
|
||||
public:
|
||||
static SharedLibrary::Func CR_STDCALL lookupHandler (SharedLibrary::Handle module, const char *function) {
|
||||
return EntityLinkage::instance ().lookup (module, function);
|
||||
}
|
||||
|
||||
static int CR_STDCALL closeHandler (DLSYM_HANDLE module) {
|
||||
return EntityLinkage::instance ().close (module);
|
||||
}
|
||||
|
||||
public:
|
||||
void flush () {
|
||||
m_exports.clear ();
|
||||
}
|
||||
|
||||
bool needsBypass () const {
|
||||
return !plat.win && !Game::instance ().isDedicated ();
|
||||
}
|
||||
};
|
||||
|
||||
// expose globals
|
||||
CR_EXPOSE_GLOBAL_SINGLETON (Game, game);
|
||||
CR_EXPOSE_GLOBAL_SINGLETON (LightMeasure, illum);
|
||||
CR_EXPOSE_GLOBAL_SINGLETON (EntityLinkage, ents);
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ public:
|
|||
int getForAnalyzer (const Vector &origin, const float maxRange);
|
||||
int getNearest (const Vector &origin, const float range = kInfiniteDistance, int flags = -1);
|
||||
int getNearestNoBuckets (const Vector &origin, const float range = kInfiniteDistance, int flags = -1);
|
||||
int getEditorNearest ();
|
||||
int getEditorNearest (const float maxRange = 50.0f);
|
||||
int clearConnections (int index);
|
||||
int getBspSize ();
|
||||
int locateBucket (const Vector &pos);
|
||||
|
|
@ -302,8 +302,8 @@ public:
|
|||
}
|
||||
|
||||
// check nodes range
|
||||
bool exists (int index) const {
|
||||
return index >= 0 && index < length ();
|
||||
template <typename U> bool exists (U index) const {
|
||||
return index >= 0 && index < static_cast <U> (length ());
|
||||
}
|
||||
|
||||
// get real nodes num
|
||||
|
|
|
|||
193
inc/hooks.h
Normal file
193
inc/hooks.h
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
//
|
||||
// YaPB, based on PODBot by Markus Klinge ("CountFloyd").
|
||||
// Copyright © YaPB Project Developers <yapb@jeefo.net>.
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
// simple handler for parsing and rewriting queries (fake queries)
|
||||
class QueryBuffer {
|
||||
SmallArray <uint8_t> m_buffer {};
|
||||
size_t m_cursor {};
|
||||
|
||||
public:
|
||||
QueryBuffer (const uint8_t *msg, size_t length, size_t shift) : m_cursor (0) {
|
||||
m_buffer.insert (0, msg, length);
|
||||
m_cursor += shift;
|
||||
}
|
||||
|
||||
public:
|
||||
template <typename T> T read () {
|
||||
T result {};
|
||||
constexpr auto size = sizeof (T);
|
||||
|
||||
if (m_cursor + size > m_buffer.length ()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy (&result, m_buffer.data () + m_cursor, size);
|
||||
m_cursor += size;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// must be called right after read
|
||||
template <typename T> void write (T value) {
|
||||
constexpr auto size = sizeof (value);
|
||||
memcpy (m_buffer.data () + m_cursor - size, &value, size);
|
||||
}
|
||||
|
||||
template <typename T> void skip () {
|
||||
constexpr auto size = sizeof (T);
|
||||
|
||||
if (m_cursor + size > m_buffer.length ()) {
|
||||
return;
|
||||
}
|
||||
m_cursor += size;
|
||||
}
|
||||
|
||||
void skipString () {
|
||||
if (m_buffer.length () < m_cursor) {
|
||||
return;
|
||||
}
|
||||
for (; m_cursor < m_buffer.length () && m_buffer[m_cursor] != kNullChar; ++m_cursor) {}
|
||||
++m_cursor;
|
||||
}
|
||||
|
||||
|
||||
String readString () {
|
||||
if (m_buffer.length () < m_cursor) {
|
||||
return "";
|
||||
}
|
||||
String out;
|
||||
|
||||
for (; m_cursor < m_buffer.length () && m_buffer[m_cursor] != kNullChar; ++m_cursor) {
|
||||
out += m_buffer[m_cursor];
|
||||
}
|
||||
++m_cursor;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
void shiftToEnd () {
|
||||
m_cursor = m_buffer.length ();
|
||||
}
|
||||
|
||||
public:
|
||||
Twin <const uint8_t *, size_t> data () {
|
||||
return { m_buffer.data (), m_buffer.length () };
|
||||
}
|
||||
};
|
||||
|
||||
// used for response with fake timestamps and bots count in server responses
|
||||
class ServerQueryHook : public Singleton <ServerQueryHook> {
|
||||
private:
|
||||
using SendToProto = decltype (sendto);
|
||||
|
||||
private:
|
||||
Detour <SendToProto> m_sendToDetour { };
|
||||
|
||||
public:
|
||||
ServerQueryHook () = default;
|
||||
~ServerQueryHook () = default;
|
||||
|
||||
public:
|
||||
// initialzie and install hook
|
||||
void init ();
|
||||
|
||||
public:
|
||||
// disables send hook
|
||||
bool disable () {
|
||||
return m_sendToDetour.restore ();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// used for transit calls between game dll and engine without all needed functions on bot side
|
||||
class DynamicLinkerHook : public Singleton <DynamicLinkerHook> {
|
||||
private:
|
||||
#if defined (CR_WINDOWS)
|
||||
# define DLSYM_FUNCTION GetProcAddress
|
||||
# define DLCLOSE_FUNCTION FreeLibrary
|
||||
#else
|
||||
# define DLSYM_FUNCTION dlsym
|
||||
# define DLCLOSE_FUNCTION dlclose
|
||||
#endif
|
||||
|
||||
private:
|
||||
using DlsymProto = SharedLibrary::Func CR_STDCALL (SharedLibrary::Handle, const char *);
|
||||
using DlcloseProto = int CR_STDCALL (SharedLibrary::Handle);
|
||||
|
||||
private:
|
||||
bool m_paused { false };
|
||||
|
||||
Detour <DlsymProto> m_dlsym;
|
||||
Detour <DlcloseProto> m_dlclose;
|
||||
HashMap <StringRef, SharedLibrary::Func> m_exports;
|
||||
|
||||
SharedLibrary m_self;
|
||||
|
||||
public:
|
||||
DynamicLinkerHook () = default;
|
||||
~DynamicLinkerHook () = default;
|
||||
|
||||
public:
|
||||
void initialize ();
|
||||
bool needsBypass () const;
|
||||
|
||||
SharedLibrary::Func lookup (SharedLibrary::Handle module, const char *function);
|
||||
|
||||
decltype (auto) close (SharedLibrary::Handle module) {
|
||||
if (m_self.handle () == module) {
|
||||
disable ();
|
||||
return m_dlclose (module);
|
||||
}
|
||||
return m_dlclose (module);
|
||||
}
|
||||
|
||||
public:
|
||||
bool callPlayerFunction (edict_t *ent);
|
||||
|
||||
public:
|
||||
void enable () {
|
||||
if (m_dlsym.detoured ()) {
|
||||
return;
|
||||
}
|
||||
m_dlsym.detour ();
|
||||
}
|
||||
|
||||
void disable () {
|
||||
if (!m_dlsym.detoured ()) {
|
||||
return;
|
||||
}
|
||||
m_dlsym.restore ();
|
||||
}
|
||||
|
||||
void setPaused (bool what) {
|
||||
m_paused = what;
|
||||
}
|
||||
|
||||
bool isPaused () const {
|
||||
return m_paused;
|
||||
}
|
||||
|
||||
public:
|
||||
static SharedLibrary::Func CR_STDCALL lookupHandler (SharedLibrary::Handle module, const char *function) {
|
||||
return instance ().lookup (module, function);
|
||||
}
|
||||
|
||||
static int CR_STDCALL closeHandler (SharedLibrary::Handle module) {
|
||||
return instance ().close (module);
|
||||
}
|
||||
|
||||
public:
|
||||
void flush () {
|
||||
m_exports.clear ();
|
||||
}
|
||||
};
|
||||
|
||||
// expose global
|
||||
CR_EXPOSE_GLOBAL_SINGLETON (DynamicLinkerHook, entlink);
|
||||
CR_EXPOSE_GLOBAL_SINGLETON (ServerQueryHook, fakequeries);
|
||||
|
|
@ -111,9 +111,6 @@ private:
|
|||
// clears the currently built route
|
||||
void clearRoute ();
|
||||
|
||||
// can the node can be skipped?
|
||||
bool cantSkipNode (const int a, const int b);
|
||||
|
||||
// do a post-smoothing after a* finished constructing path
|
||||
void postSmooth (NodeAdderFn onAddedNode);
|
||||
|
||||
|
|
@ -156,6 +153,10 @@ public:
|
|||
size_t getMaxLength () const {
|
||||
return m_length / 2;
|
||||
}
|
||||
|
||||
public:
|
||||
// can the node can be skipped?
|
||||
static bool cantSkipNode (const int a, const int b, bool skipVisCheck = false);
|
||||
};
|
||||
|
||||
// floyd-warshall shortest path algorithm
|
||||
|
|
|
|||
|
|
@ -17,10 +17,8 @@ private:
|
|||
|
||||
StringArray m_sentences {};
|
||||
SmallArray <Client> m_clients {};
|
||||
SmallArray <Twin <String, String>> m_tags {};
|
||||
|
||||
HashMap <int32_t, String> m_weaponAlias {};
|
||||
Detour <decltype (sendto)> m_sendToDetour { };
|
||||
|
||||
public:
|
||||
BotSupport ();
|
||||
|
|
@ -67,23 +65,11 @@ public:
|
|||
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 traceDecals (entvars_t *pev, TraceResult *trace, int logotypeIndex);
|
||||
void decalTrace (entvars_t *pev, TraceResult *trace, int logotypeIndex);
|
||||
|
||||
// update stats on clients
|
||||
void updateClients ();
|
||||
|
||||
// chat helper to strip the clantags out of the string
|
||||
void stripTags (String &line);
|
||||
|
||||
// chat helper to make player name more human-like
|
||||
void humanizePlayerName (String &playerName);
|
||||
|
||||
// chat helper to add errors to the bot chat string
|
||||
void addChatErrors (String &line);
|
||||
|
||||
// chat helper to find keywords for given string
|
||||
bool checkKeywords (StringRef line, String &reply);
|
||||
|
||||
// generates ping bitmask for SVC_PINGS message
|
||||
int getPingBitmask (edict_t *ent, int loss, int ping);
|
||||
|
||||
|
|
@ -96,9 +82,6 @@ public:
|
|||
// send modified pings to all the clients
|
||||
void emitPings (edict_t *to);
|
||||
|
||||
// installs the sendto function interception
|
||||
void installSendTo ();
|
||||
|
||||
// checks if same model omitting the models directory
|
||||
bool isModel (const edict_t *ent, StringRef model);
|
||||
|
||||
|
|
@ -113,6 +96,7 @@ public:
|
|||
// re-show welcome after changelevel ?
|
||||
void setNeedForWelcome (bool need) {
|
||||
m_needToSendWelcome = need;
|
||||
m_welcomeReceiveTime = -1.0f;
|
||||
}
|
||||
|
||||
// get array of clients
|
||||
|
|
@ -130,11 +114,6 @@ public:
|
|||
return m_clients[index];
|
||||
}
|
||||
|
||||
// disables send hook
|
||||
bool disableSendTo () {
|
||||
return m_sendToDetour.restore ();
|
||||
}
|
||||
|
||||
// gets the shooting cone deviation
|
||||
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
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
// generated by meson build system
|
||||
// generated by meson/cmake build system
|
||||
#ifndef MODULE_BUILD_HASH
|
||||
# define MODULE_COMMIT_COUNT "@count@"
|
||||
# define MODULE_COMMIT_HASH "@hash@"
|
||||
# define MODULE_AUTHOR @author@
|
||||
# define MODULE_MACHINE "@machine@"
|
||||
# define MODULE_COMPILER "@compiler@"
|
||||
# define MODULE_VERSION "@version@"
|
||||
# define MODULE_VERSION_FILE @winver@,@count@
|
||||
# define MODULE_BUILD_ID "@count@:@hash@"
|
||||
# define MODULE_COMMIT_COUNT "@BUILD_COUNT@"
|
||||
# define MODULE_COMMIT_HASH "@BUILD_HASH@"
|
||||
# define MODULE_AUTHOR @BUILD_AUTHOR@
|
||||
# define MODULE_MACHINE "@BUILD_MACHINE@"
|
||||
# define MODULE_COMPILER "@BUILD_COMPILER@"
|
||||
# define MODULE_VERSION "@BUILD_VERSION@"
|
||||
# define MODULE_VERSION_FILE @BUILD_WINVER@,@BUILD_COUNT@
|
||||
# define MODULE_BUILD_ID "@BUILD_COUNT@:@BUILD_HASH@"
|
||||
#endif
|
||||
|
|
|
|||
31
inc/yapb.h
31
inc/yapb.h
|
|
@ -19,25 +19,7 @@ using namespace cr;
|
|||
#include <product.h>
|
||||
#include <module.h>
|
||||
#include <constant.h>
|
||||
|
||||
// links keywords and replies together
|
||||
struct ChatKeywords {
|
||||
StringArray keywords;
|
||||
StringArray replies;
|
||||
StringArray usedReplies;
|
||||
|
||||
public:
|
||||
ChatKeywords () = default;
|
||||
|
||||
ChatKeywords (const StringArray &keywords, const StringArray &replies) {
|
||||
this->keywords.clear ();
|
||||
this->replies.clear ();
|
||||
this->usedReplies.clear ();
|
||||
|
||||
this->keywords.insert (0, keywords);
|
||||
this->replies.insert (0, replies);
|
||||
}
|
||||
};
|
||||
#include <chatlib.h>
|
||||
|
||||
// tasks definition
|
||||
struct BotTask {
|
||||
|
|
@ -127,16 +109,6 @@ struct Client {
|
|||
ClientNoise noise;
|
||||
};
|
||||
|
||||
// define chatting collection structure
|
||||
struct ChatCollection {
|
||||
int chatProbability {};
|
||||
float chatDelay {};
|
||||
float timeNextChat {};
|
||||
int entityIndex {};
|
||||
String sayText {};
|
||||
StringArray lastUsedSentences {};
|
||||
};
|
||||
|
||||
// include bot graph stuff
|
||||
#include <graph.h>
|
||||
#include <vision.h>
|
||||
|
|
@ -855,6 +827,7 @@ private:
|
|||
|
||||
#include "config.h"
|
||||
#include "support.h"
|
||||
#include "hooks.h"
|
||||
#include "sounds.h"
|
||||
#include "message.h"
|
||||
#include "engine.h"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue