commit
ae0c8f110e
28 changed files with 3373 additions and 3159 deletions
93
.gitignore
vendored
93
.gitignore
vendored
|
|
@ -1,32 +1,33 @@
|
|||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# =========================
|
||||
# Operating System Files
|
||||
# =========================
|
||||
|
||||
# OSX
|
||||
# =========================
|
||||
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# =========================
|
||||
# Operating System Files
|
||||
# =========================
|
||||
|
||||
# OSX
|
||||
# =========================
|
||||
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must ends with two \r.
|
||||
Icon
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
|
@ -34,23 +35,27 @@ Icon
|
|||
# Files that might appear on external disk
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
|
||||
*.pdb
|
||||
*.asm
|
||||
*.tlog
|
||||
*.obj
|
||||
*.log
|
||||
*.manifest
|
||||
*.map
|
||||
*.res
|
||||
*.lib
|
||||
*.exp
|
||||
*.ilk
|
||||
*.opensdf
|
||||
*.dll
|
||||
*.sdf
|
||||
*.suo
|
||||
*.idb
|
||||
*.vspx
|
||||
project/yapb.vcxproj.user
|
||||
*.psess
|
||||
|
||||
*.pdb
|
||||
*.asm
|
||||
*.tlog
|
||||
*.obj
|
||||
*.log
|
||||
*.manifest
|
||||
*.map
|
||||
*.res
|
||||
*.lib
|
||||
*.exp
|
||||
*.ilk
|
||||
*.opensdf
|
||||
*.dll
|
||||
*.sdf
|
||||
*.suo
|
||||
*.idb
|
||||
*.vspx
|
||||
project/yapb.vcxproj.user
|
||||
*.psess
|
||||
*.opendb
|
||||
*.aps
|
||||
*.db
|
||||
*.enc
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ public:
|
|||
|
||||
memset (m_textBuffer, 0, sizeof (m_textBuffer));
|
||||
memset (m_right, 0, sizeof (m_right));
|
||||
memset (m_left, 0, sizeof (m_right));
|
||||
memset (m_left, 0, sizeof (m_left));
|
||||
memset (m_parent, 0, sizeof (m_parent));
|
||||
}
|
||||
|
||||
|
|
@ -355,4 +355,4 @@ public:
|
|||
static Compressor compressor = Compressor ();
|
||||
return compressor.InternalEncode (fileName, header, headerSize, buffer, bufferSize);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
316
include/core.h
316
include/core.h
|
|
@ -324,6 +324,22 @@ enum PickupType
|
|||
PICKUP_DEFUSEKIT
|
||||
};
|
||||
|
||||
// fight style type
|
||||
enum FightStyle
|
||||
{
|
||||
FIGHT_NONE,
|
||||
FIGHT_STRAFE,
|
||||
FIGHT_STAY
|
||||
};
|
||||
|
||||
// dodge type
|
||||
enum StrafeDir
|
||||
{
|
||||
STRAFE_DIR_NONE,
|
||||
STRAFE_DIR_LEFT,
|
||||
STRAFE_DIR_RIGHT
|
||||
};
|
||||
|
||||
// reload state
|
||||
enum ReloadState
|
||||
{
|
||||
|
|
@ -361,6 +377,15 @@ enum LiftState
|
|||
LIFT_LEAVING
|
||||
};
|
||||
|
||||
// wayponit auto-downloader
|
||||
enum WaypointDownloadError
|
||||
{
|
||||
WDE_SOCKET_ERROR,
|
||||
WDE_CONNECT_ERROR,
|
||||
WDE_NOTFOUND_ERROR,
|
||||
WDE_NOERROR
|
||||
};
|
||||
|
||||
// game start messages for counter-strike...
|
||||
enum GameStartMessage
|
||||
{
|
||||
|
|
@ -373,31 +398,6 @@ enum GameStartMessage
|
|||
GSM_SAY_TEAM = 10001
|
||||
};
|
||||
|
||||
// netmessage functions
|
||||
enum NetworkMessage
|
||||
{
|
||||
NETMSG_VGUI = 1,
|
||||
NETMSG_SHOWMENU = 2,
|
||||
NETMSG_WEAPONLIST = 3,
|
||||
NETMSG_CURWEAPON = 4,
|
||||
NETMSG_AMMOX = 5,
|
||||
NETMSG_AMMOPICKUP = 6,
|
||||
NETMSG_DAMAGE = 7,
|
||||
NETMSG_MONEY = 8,
|
||||
NETMSG_STATUSICON = 9,
|
||||
NETMSG_DEATH = 10,
|
||||
NETMSG_SCREENFADE = 11,
|
||||
NETMSG_HLTV = 12,
|
||||
NETMSG_TEXTMSG = 13,
|
||||
NETMSG_SCOREINFO = 14,
|
||||
NETMSG_BARTIME = 15,
|
||||
NETMSG_SENDAUDIO = 17,
|
||||
NETMSG_SAYTEXT = 18,
|
||||
NETMSG_BOTVOICE = 19,
|
||||
NETMSG_RESETHUD = 20,
|
||||
NETMSG_UNDEFINED = 0
|
||||
};
|
||||
|
||||
// sensing states
|
||||
enum SensingState
|
||||
{
|
||||
|
|
@ -469,7 +469,7 @@ enum WaypointFlag
|
|||
// defines for waypoint connection flags field (16 bits are available)
|
||||
enum PathFlag
|
||||
{
|
||||
PATHFLAG_JUMP = (1 << 0), // must jump for this connection
|
||||
PATHFLAG_JUMP = (1 << 0) // must jump for this connection
|
||||
};
|
||||
|
||||
// enum pathfind search type
|
||||
|
|
@ -526,6 +526,8 @@ const int MAX_WAYPOINTS = 1024;
|
|||
const int MAX_WEAPONS = 32;
|
||||
const int NUM_WEAPONS = 26;
|
||||
const int MAX_COLLIDE_MOVES = 3;
|
||||
const int MAX_ENGINE_PLAYERS = 32; // we can have 64 players with xash
|
||||
const int MAX_PRINT_BUFFER = 1024;
|
||||
|
||||
// weapon masks
|
||||
const int WEAPON_PRIMARY = ((1 << WEAPON_XM1014) | (1 <<WEAPON_M3) | (1 << WEAPON_MAC10) | (1 << WEAPON_UMP45) | (1 << WEAPON_MP5) | (1 << WEAPON_TMP) | (1 << WEAPON_P90) | (1 << WEAPON_AUG) | (1 << WEAPON_M4A1) | (1 << WEAPON_SG552) | (1 << WEAPON_AK47) | (1 << WEAPON_SCOUT) | (1 << WEAPON_SG550) | (1 << WEAPON_AWP) | (1 << WEAPON_G3SG1) | (1 << WEAPON_M249) | (1 << WEAPON_FAMAS) | (1 << WEAPON_GALIL));
|
||||
|
|
@ -556,24 +558,6 @@ struct TaskItem
|
|||
bool resume; // if task can be continued if interrupted
|
||||
};
|
||||
|
||||
// wave structure
|
||||
struct WavHeader
|
||||
{
|
||||
char riffChunkId[4];
|
||||
unsigned long packageSize;
|
||||
char chunkID[4];
|
||||
char formatChunkId[4];
|
||||
unsigned long formatChunkLength;
|
||||
unsigned short dummy;
|
||||
unsigned short channels;
|
||||
unsigned long sampleRate;
|
||||
unsigned long bytesPerSecond;
|
||||
unsigned short bytesPerSample;
|
||||
unsigned short bitsPerSample;
|
||||
char dataChunkId[4];
|
||||
unsigned long dataChunkLength;
|
||||
};
|
||||
|
||||
// botname structure definition
|
||||
struct BotName
|
||||
{
|
||||
|
|
@ -589,13 +573,6 @@ struct ChatterItem
|
|||
float repeatTime;
|
||||
};
|
||||
|
||||
// language config structure definition
|
||||
struct LanguageItem
|
||||
{
|
||||
const char *original; // original string
|
||||
const char *translated; // string to replace for
|
||||
};
|
||||
|
||||
struct WeaponSelect
|
||||
{
|
||||
int id; // the weapon id value
|
||||
|
|
@ -629,7 +606,7 @@ struct Client
|
|||
Vector soundPosition; // position sound was played
|
||||
|
||||
int team; // bot team
|
||||
int realTeam; // real bot team in free for all mode (csdm)
|
||||
int team2; // real bot team in free for all mode (csdm)
|
||||
int flags; // client flags
|
||||
|
||||
float hearingDistance; // distance this sound is heared
|
||||
|
|
@ -757,7 +734,7 @@ private:
|
|||
float m_blindRecognizeTime; // time to recognize enemy
|
||||
float m_itemCheckTime; // time next search for items needs to be done
|
||||
PickupType m_pickupType; // type of entity which needs to be used/picked up
|
||||
Vector m_breakable; // origin of breakable
|
||||
Vector m_breakableOrigin; // origin of breakable
|
||||
|
||||
edict_t *m_pickupItem; // pointer to entity of item to use/pickup
|
||||
edict_t *m_itemIgnore; // pointer to entity to ignore for pickup
|
||||
|
|
@ -815,7 +792,7 @@ private:
|
|||
bool m_wantsToFire; // bot needs consider firing
|
||||
float m_shootAtDeadTime; // time to shoot at dying players
|
||||
edict_t *m_avoidGrenade; // pointer to grenade entity to avoid
|
||||
char m_needAvoidGrenade; // which direction to strafe away
|
||||
int m_needAvoidGrenade; // which direction to strafe away
|
||||
|
||||
float m_followWaitTime; // wait to follow time
|
||||
edict_t *m_targetEntity; // the entity that the bot is trying to reach
|
||||
|
|
@ -844,8 +821,8 @@ private:
|
|||
bool m_checkWeaponSwitch; // is time to check weapon switch
|
||||
bool m_isUsingGrenade; // bot currently using grenade??
|
||||
|
||||
unsigned char m_combatStrafeDir; // direction to strafe
|
||||
unsigned char m_fightStyle; // combat style to use
|
||||
StrafeDir m_combatStrafeDir; // direction to strafe
|
||||
FightStyle m_fightStyle; // combat style to use
|
||||
float m_lastFightStyleCheck; // time checked style
|
||||
float m_strafeSetTime; // time strafe direction was set
|
||||
|
||||
|
|
@ -1070,6 +1047,7 @@ public:
|
|||
float m_spawnTime; // time this bot spawned
|
||||
float m_timeTeamOrder; // time of last radio command
|
||||
float m_timePeriodicUpdate; // time to per-second think
|
||||
float m_timeRepotingInDelay; // time to delay report-in
|
||||
|
||||
bool m_isVIP; // bot is vip?
|
||||
|
||||
|
|
@ -1184,7 +1162,7 @@ public:
|
|||
void Think (void);
|
||||
|
||||
/// the things that can be executed while skipping frames
|
||||
void ThinkDelayed (void);
|
||||
void ThinkFrame (void);
|
||||
|
||||
void DisplayDebugOverlay (void);
|
||||
void NewRound (void);
|
||||
|
|
@ -1208,7 +1186,7 @@ public:
|
|||
inline TaskID GetTaskId (void) { return GetTask ()->id; };
|
||||
|
||||
void TakeDamage (edict_t *inflictor, int damage, int armor, int bits);
|
||||
void TakeBlinded (const Vector &fade, int alpha);
|
||||
void TakeBlinded (int r, int g, int b, int alpha);
|
||||
|
||||
void DiscardWeaponForUser (edict_t *user, bool discardC4);
|
||||
|
||||
|
|
@ -1249,7 +1227,7 @@ class BotManager : public Singleton <BotManager>
|
|||
private:
|
||||
Array <CreateQueue> m_creationTab; // bot creation tab
|
||||
|
||||
Bot *m_bots[32]; // all available bots
|
||||
Bot *m_bots[MAX_ENGINE_PLAYERS]; // all available bots
|
||||
|
||||
float m_maintainTime; // time to maintain bot creation
|
||||
float m_quotaMaintainTime; // time to maintain bot quota
|
||||
|
|
@ -1259,8 +1237,8 @@ private:
|
|||
bool m_economicsGood[2]; // is team able to buy anything
|
||||
bool m_deathMsgSent; // for fakeping
|
||||
|
||||
Array <entity_t> m_activeGrenades; // holds currently active grenades in the map
|
||||
Array <entity_t> m_trackedPlayers; // holds array of connected players, and waits the player joins team
|
||||
Array <edict_t *> m_activeGrenades; // holds currently active grenades in the map
|
||||
Array <edict_t *> m_trackedPlayers; // holds array of connected players, and waits the player joins team
|
||||
|
||||
edict_t *m_killerEntity; // killer entity for bots
|
||||
|
||||
|
|
@ -1326,7 +1304,7 @@ public:
|
|||
|
||||
// grenades
|
||||
void UpdateActiveGrenades (void);
|
||||
const Array <entity_t> &GetActiveGrenades (void);
|
||||
const Array <edict_t *> &GetActiveGrenades (void);
|
||||
|
||||
inline bool HasActiveGrenades (void)
|
||||
{
|
||||
|
|
@ -1339,43 +1317,6 @@ public:
|
|||
void SendDeathMsgFix (void);
|
||||
};
|
||||
|
||||
// texts localizer
|
||||
class Localizer : public Singleton <Localizer>
|
||||
{
|
||||
public:
|
||||
Array <LanguageItem> m_langTab;
|
||||
|
||||
public:
|
||||
Localizer (void) { m_langTab.RemoveAll (); }
|
||||
~Localizer (void) { m_langTab.RemoveAll (); }
|
||||
|
||||
char *TranslateInput (const char *input);
|
||||
void Destroy (void);
|
||||
};
|
||||
|
||||
// netmessage handler class
|
||||
class NetworkMsg : public Singleton <NetworkMsg>
|
||||
{
|
||||
private:
|
||||
Bot *m_bot;
|
||||
int m_state;
|
||||
int m_message;
|
||||
int m_registerdMessages[NETMSG_RESETHUD + 1];
|
||||
|
||||
public:
|
||||
NetworkMsg (void);
|
||||
~NetworkMsg (void) { };
|
||||
|
||||
void Execute (void *p);
|
||||
inline void Reset (void) { m_message = NETMSG_UNDEFINED; m_state = 0; m_bot = NULL; };
|
||||
void HandleMessageIfRequired (int messageType, int requiredType);
|
||||
|
||||
inline void SetMessage (int message) { m_message = message; }
|
||||
inline void SetBot (Bot *bot) { m_bot = bot; }
|
||||
|
||||
inline int GetId (int messageType) { return m_registerdMessages[messageType]; }
|
||||
inline void SetId (int messageType, int messsageIdentifier) { m_registerdMessages[messageType] = messsageIdentifier; }
|
||||
};
|
||||
|
||||
// waypoint operation class
|
||||
class Waypoint : public Singleton <Waypoint>
|
||||
|
|
@ -1395,11 +1336,12 @@ private:
|
|||
Vector m_learnPosition;
|
||||
Vector m_foundBombOrigin;
|
||||
|
||||
int m_loadTries;
|
||||
int m_cacheWaypointIndex;
|
||||
int m_lastJumpWaypoint;
|
||||
int m_visibilityIndex;
|
||||
Vector m_lastWaypoint;
|
||||
byte m_visLUT[MAX_WAYPOINTS][MAX_WAYPOINTS / 4];
|
||||
unsigned char m_visLUT[MAX_WAYPOINTS][MAX_WAYPOINTS / 4];
|
||||
|
||||
float m_pathDisplayTime;
|
||||
float m_arrowDisplayTime;
|
||||
|
|
@ -1430,12 +1372,12 @@ public:
|
|||
void InitVisibilityTab (void);
|
||||
|
||||
void InitTypes (void);
|
||||
void AddPath (short int addIndex, short int pathIndex, float distance);
|
||||
void AddPath (int addIndex, int pathIndex, float distance);
|
||||
|
||||
int GetFacingIndex (void);
|
||||
int FindFarest (const Vector &origin, float maxDistance = 32.0);
|
||||
int FindNearest (const Vector &origin, float minDistance = 9999.0f, int flags = -1);
|
||||
void FindInRadius (Array <int> &radiusHolder, float radius, const Vector &origin, int maxCount = -1);
|
||||
void FindInRadius (Array <int> &holder, float radius, const Vector &origin, int maxCount = -1);
|
||||
|
||||
void Add (int flags, const Vector &waypointOrigin = Vector::GetZero ());
|
||||
void Delete (void);
|
||||
|
|
@ -1456,6 +1398,7 @@ public:
|
|||
|
||||
bool Load (void);
|
||||
void Save (void);
|
||||
void CleanupPathMemory (void);
|
||||
|
||||
bool Reachable (Bot *bot, int index);
|
||||
bool IsNodeReachable (const Vector &src, const Vector &destination);
|
||||
|
|
@ -1482,191 +1425,54 @@ public:
|
|||
void SetGoalVisited (int index);
|
||||
void ClearVisitedGoals (void);
|
||||
|
||||
inline const Vector &GetBombPosition (void)
|
||||
{
|
||||
return m_foundBombOrigin;
|
||||
}
|
||||
|
||||
void SetBombPosition (bool shouldReset = false);
|
||||
const char *GetDataDir (void);
|
||||
String CheckSubfolderFile (void);
|
||||
|
||||
// quick access
|
||||
inline Path *operator [] (int index)
|
||||
{
|
||||
extern int g_numWaypoints;
|
||||
|
||||
if (index < 0 || index >= g_numWaypoints)
|
||||
assert (0);
|
||||
|
||||
return GetPath (index);
|
||||
}
|
||||
};
|
||||
|
||||
// wayponit auto-downloader
|
||||
enum WaypointDownloadError
|
||||
{
|
||||
WDE_SOCKET_ERROR,
|
||||
WDE_CONNECT_ERROR,
|
||||
WDE_NOTFOUND_ERROR,
|
||||
WDE_NOERROR
|
||||
};
|
||||
|
||||
class WaypointDownloader
|
||||
{
|
||||
public:
|
||||
void SetBombPosition (bool shouldReset = false);
|
||||
inline const Vector &GetBombPosition (void) { return m_foundBombOrigin; }
|
||||
|
||||
// free's socket handle
|
||||
void FreeSocket (int sock);
|
||||
void CloseSocketHandle (int sock);
|
||||
|
||||
// do actually downloading of waypoint file
|
||||
WaypointDownloadError DoDownload (void);
|
||||
WaypointDownloadError RequestWaypoint (void);
|
||||
};
|
||||
|
||||
enum VarType
|
||||
{
|
||||
VT_NORMAL = 0,
|
||||
VT_READONLY,
|
||||
VT_PASSWORD,
|
||||
VT_NOSERVER,
|
||||
VT_NOREGISTER
|
||||
};
|
||||
#include <engine.h>
|
||||
|
||||
class ConVarWrapper : public Singleton <ConVarWrapper>
|
||||
{
|
||||
private:
|
||||
struct VarPair
|
||||
{
|
||||
VarType type;
|
||||
cvar_t reg;
|
||||
class ConVar *self;
|
||||
};
|
||||
Array <VarPair> m_regs;
|
||||
|
||||
public:
|
||||
void RegisterVariable (const char *variable, const char *value, VarType varType, ConVar *self);
|
||||
void PushRegisteredConVarsToEngine (bool gameVars = false);
|
||||
};
|
||||
|
||||
|
||||
// expose bot globals
|
||||
#define netmsg NetworkMsg::GetReference ()
|
||||
#define locale Localizer::GetReference ()
|
||||
#define convars ConVarWrapper::GetReference ()
|
||||
// expose bot super-globals
|
||||
#define waypoints Waypoint::GetReference ()
|
||||
#define engine Engine::GetReference ()
|
||||
#define bots BotManager::GetReference ()
|
||||
|
||||
// simplify access for console variables
|
||||
class ConVar
|
||||
{
|
||||
public:
|
||||
cvar_t *m_eptr;
|
||||
|
||||
public:
|
||||
ConVar (const char *name, const char *initval, VarType type = VT_NOSERVER)
|
||||
{
|
||||
m_eptr = NULL;
|
||||
|
||||
convars.RegisterVariable (name, initval, type, this);
|
||||
}
|
||||
|
||||
inline bool GetBool(void)
|
||||
{
|
||||
return m_eptr->value > 0.0f;
|
||||
}
|
||||
|
||||
inline int GetInt (void)
|
||||
{
|
||||
return static_cast <int> (m_eptr->value);
|
||||
}
|
||||
|
||||
inline int GetFlags (void)
|
||||
{
|
||||
return m_eptr->flags;
|
||||
}
|
||||
|
||||
inline float GetFloat (void)
|
||||
{
|
||||
return m_eptr->value;
|
||||
}
|
||||
|
||||
inline const char *GetString (void)
|
||||
{
|
||||
return m_eptr->string;
|
||||
}
|
||||
|
||||
inline const char *GetName (void)
|
||||
{
|
||||
return m_eptr->name;
|
||||
}
|
||||
|
||||
inline void SetFloat (float val)
|
||||
{
|
||||
g_engfuncs.pfnCVarSetFloat (m_eptr->name, val);
|
||||
}
|
||||
|
||||
inline void SetInt (int val)
|
||||
{
|
||||
SetFloat (static_cast <float> (val));
|
||||
}
|
||||
|
||||
inline void SetString (const char *val)
|
||||
{
|
||||
g_engfuncs.pfnCVarSetString (m_eptr->name, val);
|
||||
}
|
||||
};
|
||||
|
||||
// prototypes of bot functions...
|
||||
extern int GetWeaponReturn (bool isString, const char *weaponAlias, int weaponIndex = -1);
|
||||
|
||||
extern int GetWeaponPenetrationPower (int id);
|
||||
extern int GenerateBuildNumber (void);
|
||||
extern float GetShootingConeDeviation (edict_t *ent, Vector *position);
|
||||
extern float GetWaveLength (const char *fileName);
|
||||
|
||||
extern bool IsDedicatedServer (void);
|
||||
extern bool IsVisible (const Vector &origin, edict_t *ent);
|
||||
extern bool IsAlive (edict_t *ent);
|
||||
extern bool IsInViewCone (const Vector &origin, edict_t *ent);
|
||||
extern int GetWeaponPenetrationPower (int id);
|
||||
|
||||
extern bool IsValidBot (edict_t *ent);
|
||||
extern bool IsValidPlayer (edict_t *ent);
|
||||
extern bool IsPlayerVIP (edict_t *ent);
|
||||
extern bool OpenConfig (const char *fileName, const char *errorIfNotExists, File *outFile, bool languageDependant = false);
|
||||
extern bool OpenConfig (const char *fileName, const char *errorIfNotExists, MemoryFile *outFile, bool languageDependant = false);
|
||||
extern bool FindNearestPlayer (void **holder, edict_t *to, float searchDistance = 4096.0, bool sameTeam = false, bool needBot = false, bool needAlive = false, bool needDrawn = false);
|
||||
|
||||
extern const char *GetMapName (void);
|
||||
extern const char *GetWaypointDir (void);
|
||||
extern const char *GetModName (void);
|
||||
extern const char *GetField (const char *string, int fieldId, bool endLine = false);
|
||||
extern const char *FormatBuffer (const char *format, ...);
|
||||
|
||||
extern uint16 GenerateBuildNumber (void);
|
||||
extern Vector GetEntityOrigin (edict_t *ent);
|
||||
|
||||
extern void FreeLibraryMemory (void);
|
||||
extern void RoundInit (void);
|
||||
extern void FakeClientCommand (edict_t *fakeClient, const char *format, ...);
|
||||
extern void strtrim (char *string);
|
||||
extern void CreatePath (char *path);
|
||||
extern void ServerCommand (const char *format, ...);
|
||||
extern void RegisterCommand (const char *command, void funcPtr (void));
|
||||
extern void CheckWelcomeMessage (void);
|
||||
extern void DetectCSVersion (void);
|
||||
extern void PlaySound (edict_t *ent, const char *soundName);
|
||||
extern void ServerPrint (const char *format, ...);
|
||||
extern void ChartPrint (const char *format, ...);
|
||||
extern void CenterPrint (const char *format, ...);
|
||||
extern void ClientPrint (edict_t *ent, int dest, const char *format, ...);
|
||||
|
||||
extern void AddLogEntry (bool outputToConsole, int logLevel, const char *format, ...);
|
||||
extern void TraceLine (const Vector &start, const Vector &end, bool ignoreMonsters, bool ignoreGlass, edict_t *ignoreEntity, TraceResult *ptr);
|
||||
extern void TraceLine (const Vector &start, const Vector &end, bool ignoreMonsters, edict_t *ignoreEntity, TraceResult *ptr);
|
||||
extern void TraceHull (const Vector &start, const Vector &end, bool ignoreMonsters, int hullNumber, edict_t *ignoreEntity, TraceResult *ptr);
|
||||
extern void DrawLine (edict_t *ent, const Vector &start, const Vector &end, int width, int noise, int red, int green, int blue, int brightness, int speed, int life);
|
||||
extern void DrawArrow (edict_t *ent, const Vector &start, const Vector &end, int width, int noise, int red, int green, int blue, int brightness, int speed, int life);
|
||||
extern void DisplayMenuToClient (edict_t *ent, MenuText *menu);
|
||||
extern void DecalTrace (entvars_t *pev, TraceResult *trace, int logotypeIndex);
|
||||
extern void SoundAttachToClients (edict_t *ent, const char *sample, float volume);
|
||||
extern void SoundSimulateUpdate (int playerIndex);
|
||||
|
||||
extern const char *FormatBuffer (const char *format, ...);
|
||||
|
||||
// very global convars
|
||||
extern ConVar yb_jasonmode;
|
||||
extern ConVar yb_communication_type;
|
||||
|
|
@ -1679,5 +1485,5 @@ extern ConVar yb_ignore_enemies;
|
|||
|
||||
inline int Bot::GetIndex (void)
|
||||
{
|
||||
return IndexOfEntity (GetEntity ());
|
||||
}
|
||||
return engine.IndexOfEntity (GetEntity ());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
//
|
||||
//
|
||||
// Yet Another POD-Bot, based on PODBot by Markus Klinge ("CountFloyd").
|
||||
// Copyright (c) YaPB Development Team.
|
||||
//
|
||||
|
|
@ -21,6 +21,12 @@
|
|||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
//
|
||||
// Title: Utility Classes Header
|
||||
//
|
||||
|
|
@ -698,10 +704,10 @@ public:
|
|||
//
|
||||
// Function: BuildVectors
|
||||
//
|
||||
// Builds a 3D referential from a view angle, that is to say, the relative "forward", "right" and "upward" direction
|
||||
// that a player would have if he were facing this view angle. World angles are stored in Vector structs too, the
|
||||
// "x" component corresponding to the X angle (horizontal angle), and the "y" component corresponding to the Y angle
|
||||
// (vertical angle).
|
||||
// Builds a 3D referential from a view angle, that is to say, the relative "forward", "right" and "upward" direction
|
||||
// that a player would have if he were facing this view angle. World angles are stored in Vector structs too, the
|
||||
// "x" component corresponding to the X angle (horizontal angle), and the "y" component corresponding to the Y angle
|
||||
// (vertical angle).
|
||||
//
|
||||
// Parameters:
|
||||
// forward - Forward referential vector.
|
||||
|
|
@ -2297,7 +2303,7 @@ public:
|
|||
char buffer[1024];
|
||||
|
||||
va_start (ap, fmt);
|
||||
vsprintf (buffer, fmt, ap);
|
||||
vsnprintf (buffer, sizeof (buffer) - 1, fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
Append (buffer);
|
||||
|
|
@ -2368,7 +2374,7 @@ public:
|
|||
char buffer[1024];
|
||||
|
||||
va_start (ap, fmt);
|
||||
vsprintf (buffer, fmt, ap);
|
||||
vsnprintf (buffer, sizeof (buffer) - 1, fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
Assign (buffer);
|
||||
|
|
@ -2595,7 +2601,7 @@ public:
|
|||
holder[j++] = m_bufferPtr[i];
|
||||
|
||||
holder[j] = 0;
|
||||
result.Assign(holder);
|
||||
result.Assign (holder);
|
||||
|
||||
delete [] holder;
|
||||
return result;
|
||||
|
|
@ -3296,6 +3302,33 @@ public:
|
|||
|
||||
return Split (sep);
|
||||
}
|
||||
|
||||
public:
|
||||
//
|
||||
// Function: TrimExternalBuffer
|
||||
// Trims string from both sides.
|
||||
//
|
||||
// Returns:
|
||||
// None
|
||||
//
|
||||
static inline void TrimExternalBuffer (char *str)
|
||||
{
|
||||
int pos = 0;
|
||||
char *dest = str;
|
||||
|
||||
while (str[pos] <= ' ' && str[pos] > 0)
|
||||
pos++;
|
||||
|
||||
while (str[pos])
|
||||
{
|
||||
*(dest++) = str[pos];
|
||||
pos++;
|
||||
}
|
||||
*(dest--) = '\0';
|
||||
|
||||
while (dest >= str && *dest <= ' ' && *dest > 0)
|
||||
*(dest--) = '\0';
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
|
|
@ -3434,23 +3467,6 @@ public:
|
|||
return fgets (buffer, count, m_handle);
|
||||
}
|
||||
|
||||
//
|
||||
// Function: GetBuffer
|
||||
// Gets the line from file stream, and stores it inside string class.
|
||||
//
|
||||
// Parameters:
|
||||
// buffer - String buffer, that should receive line.
|
||||
// count - Max. size of buffer.
|
||||
//
|
||||
// Returns:
|
||||
// True if operation succeeded, false otherwise.
|
||||
//
|
||||
bool GetBuffer (String &buffer, int count)
|
||||
{
|
||||
assert (m_handle != NULL);
|
||||
return !String (fgets (buffer, count, m_handle)).IsEmpty ();
|
||||
}
|
||||
|
||||
//
|
||||
// Function: Printf
|
||||
// Puts formatted buffer, into stream.
|
||||
|
|
@ -3615,6 +3631,289 @@ public:
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void CreatePath (char *path)
|
||||
{
|
||||
for (char *ofs = path + 1; *ofs; ofs++)
|
||||
{
|
||||
if (*ofs == '/')
|
||||
{
|
||||
// create the directory
|
||||
*ofs = 0;
|
||||
#ifdef _WIN32
|
||||
_mkdir (path);
|
||||
#else
|
||||
mkdir (path, 0777);
|
||||
#endif
|
||||
*ofs = '/';
|
||||
}
|
||||
}
|
||||
#ifdef _WIN32
|
||||
_mkdir (path);
|
||||
#else
|
||||
mkdir (path, 0777);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class: MemoryFile
|
||||
// Simple Memory file wrapper class. (RO)
|
||||
//
|
||||
class MemoryFile
|
||||
{
|
||||
public:
|
||||
typedef unsigned char *(*MF_Loader) (const char *, int *);
|
||||
typedef void (*MF_Unloader) (unsigned char *);
|
||||
|
||||
public:
|
||||
static MF_Loader Loader;
|
||||
static MF_Unloader Unloader;
|
||||
|
||||
protected:
|
||||
int m_size;
|
||||
int m_pos;
|
||||
unsigned char *m_buffer;
|
||||
|
||||
//
|
||||
// Group: (Con/De)structors
|
||||
//
|
||||
public:
|
||||
|
||||
//
|
||||
// Function: File
|
||||
// Default file class, constructor.
|
||||
//
|
||||
MemoryFile (void)
|
||||
{
|
||||
m_size = 0;
|
||||
m_pos = 0;
|
||||
|
||||
m_buffer = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Function: File
|
||||
// Default file class, constructor, with file opening.
|
||||
//
|
||||
MemoryFile (const String &fileName)
|
||||
{
|
||||
m_size = 0;
|
||||
m_pos = 0;
|
||||
|
||||
m_buffer = NULL;
|
||||
|
||||
Open (fileName);
|
||||
}
|
||||
|
||||
//
|
||||
// Function: ~File
|
||||
// Default file class, destructor.
|
||||
//
|
||||
~MemoryFile (void)
|
||||
{
|
||||
Close ();
|
||||
}
|
||||
|
||||
//
|
||||
// Function: Open
|
||||
// Opens file and gets it's size.
|
||||
//
|
||||
// Parameters:
|
||||
// fileName - String containing file name.
|
||||
//
|
||||
// Returns:
|
||||
// True if operation succeeded, false otherwise.
|
||||
//
|
||||
bool Open (const char *fileName)
|
||||
{
|
||||
if (!Loader)
|
||||
return false;
|
||||
|
||||
m_size = 0;
|
||||
m_pos = 0;
|
||||
|
||||
m_buffer = Loader (fileName, &m_size);
|
||||
|
||||
if (m_buffer == NULL || m_size < 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// Function: Close
|
||||
// Closes file, and destroys STDIO file object.
|
||||
//
|
||||
void Close (void)
|
||||
{
|
||||
if (Unloader != NULL)
|
||||
Unloader (m_buffer);
|
||||
|
||||
m_size = 0;
|
||||
m_pos = 0;
|
||||
|
||||
m_buffer = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Function: GetChar
|
||||
// Pops one character from the file stream.
|
||||
//
|
||||
// Returns:
|
||||
// Popped from stream character
|
||||
//
|
||||
int GetChar (void)
|
||||
{
|
||||
if (m_buffer == NULL || m_pos >= m_size)
|
||||
return -1;
|
||||
|
||||
int readCh = m_buffer[m_pos];
|
||||
m_pos++;
|
||||
|
||||
return readCh;
|
||||
}
|
||||
|
||||
//
|
||||
// Function: GetBuffer
|
||||
// Gets the single line, from the non-binary stream.
|
||||
//
|
||||
// Parameters:
|
||||
// buffer - Pointer to buffer, that should receive string.
|
||||
// count - Max. size of buffer.
|
||||
//
|
||||
// Returns:
|
||||
// Pointer to string containing popped line.
|
||||
//
|
||||
char *GetBuffer (char *buffer, int count)
|
||||
{
|
||||
if (m_buffer == NULL || m_pos >= m_size)
|
||||
return NULL;
|
||||
|
||||
int start = m_pos;
|
||||
int end = m_size - 1;
|
||||
|
||||
if (m_size - m_pos > count - 1)
|
||||
end = m_pos + count - 1;
|
||||
|
||||
while (m_pos < end)
|
||||
{
|
||||
if (m_buffer[m_pos] == 0x0a)
|
||||
end = m_pos;
|
||||
|
||||
m_pos++;
|
||||
}
|
||||
|
||||
if (m_pos == start)
|
||||
return NULL;
|
||||
|
||||
int pos = start;
|
||||
|
||||
for (; pos <= end; pos++)
|
||||
buffer[pos - start] = m_buffer[pos];
|
||||
|
||||
if (buffer[pos - start - 2] == 0x0d)
|
||||
{
|
||||
buffer[pos - start - 2] = '\n';
|
||||
pos--;
|
||||
}
|
||||
|
||||
if (buffer[pos - start - 1] == 0x0d || buffer[pos - start - 1] == 0x0a)
|
||||
buffer[pos - start - 1] = '\n';
|
||||
|
||||
buffer[pos - start] = 0;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
//
|
||||
// Function: Read
|
||||
// Reads buffer from file stream in binary format.
|
||||
//
|
||||
// Parameters:
|
||||
// buffer - Holder for read buffer.
|
||||
// size - Size of the buffer to read.
|
||||
// count - Number of buffer chunks to read.
|
||||
//
|
||||
// Returns:
|
||||
// Number of bytes red from file.
|
||||
//
|
||||
int Read (void *buffer, int size, int count = 1)
|
||||
{
|
||||
if (!m_buffer|| m_pos >= m_size || buffer == NULL || !size || !count)
|
||||
return 0;
|
||||
|
||||
int blocksRead = min ((m_size - m_pos) / size, count) * size;
|
||||
|
||||
memcpy (buffer, &m_buffer[m_pos], blocksRead);
|
||||
m_pos += blocksRead;
|
||||
|
||||
return blocksRead;
|
||||
}
|
||||
|
||||
//
|
||||
// Function: Seek
|
||||
// Seeks file stream with specified parameters.
|
||||
//
|
||||
// Parameters:
|
||||
// offset - Offset where cursor should be set.
|
||||
// origin - Type of offset set.
|
||||
//
|
||||
// Returns:
|
||||
// True if operation success, false otherwise.
|
||||
//
|
||||
bool Seek (long offset, int origin)
|
||||
{
|
||||
if (m_buffer == NULL || m_pos >= m_size)
|
||||
return false;
|
||||
|
||||
if (origin == SEEK_SET)
|
||||
{
|
||||
if (offset >= m_size)
|
||||
return false;
|
||||
|
||||
m_pos = offset;
|
||||
}
|
||||
else if (origin == SEEK_END)
|
||||
{
|
||||
if (offset >= m_size)
|
||||
return false;
|
||||
|
||||
m_pos = m_size - offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_pos + offset >= m_size)
|
||||
return false;
|
||||
|
||||
m_pos += offset;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// Function: GetSize
|
||||
// Gets the file size of opened file stream.
|
||||
//
|
||||
// Returns:
|
||||
// Number of bytes in file.
|
||||
//
|
||||
int GetSize (void)
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
//
|
||||
// Function: IsValid
|
||||
// Checks whether file stream is valid.
|
||||
//
|
||||
// Returns:
|
||||
// True if file stream valid, false otherwise.
|
||||
//
|
||||
bool IsValid (void)
|
||||
{
|
||||
return m_buffer != NULL && m_size > 0;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
|
|
@ -3623,63 +3922,9 @@ public:
|
|||
//
|
||||
typedef Array <const String &> StrVec;
|
||||
|
||||
//
|
||||
// Class: Exception
|
||||
// Simple exception raiser.
|
||||
//
|
||||
class Exception
|
||||
{
|
||||
private:
|
||||
String m_exceptionText;
|
||||
String m_fileName;
|
||||
int m_line;
|
||||
|
||||
//
|
||||
// Group: (Con/De)structors
|
||||
//
|
||||
public:
|
||||
|
||||
//
|
||||
// Function: Exception
|
||||
// Default exception constructor.
|
||||
//
|
||||
// Parameters:
|
||||
// exceptionText - Text to throw.
|
||||
// fileName - Debug file name.
|
||||
// line - Debug line number.
|
||||
//
|
||||
Exception (String exceptionText, String fileName = "(no)", int line = -1) : m_exceptionText (exceptionText), m_fileName (fileName), m_line (line) { }
|
||||
|
||||
//
|
||||
// Function: ~Exception
|
||||
// Default exception destructor.
|
||||
//
|
||||
virtual ~Exception (void) { };
|
||||
|
||||
//
|
||||
// Group: Functions
|
||||
//
|
||||
public:
|
||||
|
||||
//
|
||||
// Function: GetDescription
|
||||
// Gets the description from throw object.
|
||||
//
|
||||
// Returns:
|
||||
// Exception text.
|
||||
//
|
||||
inline const String &GetDescription (void)
|
||||
{
|
||||
static String result;
|
||||
|
||||
if (m_fileName != "(no)" && m_line != -1)
|
||||
result.AssignFormat ("Exception: %s at %s:%i", m_exceptionText.GetBuffer (), m_fileName.GetBuffer (), m_line);
|
||||
else
|
||||
result = m_exceptionText;
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
#ifndef FORCEINLINE
|
||||
#define FORCEINLINE inline
|
||||
#endif
|
||||
|
||||
//
|
||||
// Class: Singleton
|
||||
|
|
@ -3704,6 +3949,10 @@ protected:
|
|||
//
|
||||
virtual ~Singleton (void) { }
|
||||
|
||||
private:
|
||||
Singleton (Singleton const &);
|
||||
void operator = (Singleton const &);
|
||||
|
||||
public:
|
||||
|
||||
//
|
||||
|
|
@ -3714,10 +3963,9 @@ public:
|
|||
// Object pointer.
|
||||
//
|
||||
//
|
||||
static inline T *GetObject (void)
|
||||
static FORCEINLINE T *GetObject (void)
|
||||
{
|
||||
static T reference;
|
||||
return &reference;
|
||||
return &GetReference ();
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -3728,7 +3976,7 @@ public:
|
|||
// Object reference.
|
||||
//
|
||||
//
|
||||
static inline T &GetReference (void)
|
||||
static FORCEINLINE T &GetReference (void)
|
||||
{
|
||||
static T reference;
|
||||
return reference;
|
||||
|
|
@ -3769,4 +4017,4 @@ public:
|
|||
//
|
||||
// Squared Length
|
||||
//
|
||||
#define GET_SQUARE(in) (in * in)
|
||||
#define GET_SQUARE(in) (in * in)
|
||||
|
|
|
|||
324
include/engine.h
Normal file
324
include/engine.h
Normal file
|
|
@ -0,0 +1,324 @@
|
|||
//
|
||||
// Yet Another POD-Bot, based on PODBot by Markus Klinge ("CountFloyd").
|
||||
// Copyright (c) YaPB Development Team.
|
||||
//
|
||||
// This software is licensed under the BSD-style license.
|
||||
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
||||
// http://yapb.jeefo.net/license
|
||||
//
|
||||
// Purpose: Engine & Game interfaces.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
// line draw
|
||||
enum DrawLineType
|
||||
{
|
||||
DRAW_SIMPLE,
|
||||
DRAW_ARROW,
|
||||
DRAW_NUM
|
||||
};
|
||||
|
||||
// trace ignore
|
||||
enum TraceIgnore
|
||||
{
|
||||
TRACE_IGNORE_NONE = 0,
|
||||
TRACE_IGNORE_GLASS = (1 << 0),
|
||||
TRACE_IGNORE_MONSTERS = (1 << 1),
|
||||
TRACE_IGNORE_EVERYTHING = TRACE_IGNORE_GLASS | TRACE_IGNORE_MONSTERS
|
||||
};
|
||||
|
||||
// variable type
|
||||
enum VarType
|
||||
{
|
||||
VT_NORMAL = 0,
|
||||
VT_READONLY,
|
||||
VT_PASSWORD,
|
||||
VT_NOSERVER,
|
||||
VT_NOREGISTER
|
||||
};
|
||||
|
||||
// netmessage functions
|
||||
enum NetMsgId
|
||||
{
|
||||
NETMSG_UNDEFINED = -1,
|
||||
NETMSG_VGUI = 1,
|
||||
NETMSG_SHOWMENU = 2,
|
||||
NETMSG_WEAPONLIST = 3,
|
||||
NETMSG_CURWEAPON = 4,
|
||||
NETMSG_AMMOX = 5,
|
||||
NETMSG_AMMOPICKUP = 6,
|
||||
NETMSG_DAMAGE = 7,
|
||||
NETMSG_MONEY = 8,
|
||||
NETMSG_STATUSICON = 9,
|
||||
NETMSG_DEATH = 10,
|
||||
NETMSG_SCREENFADE = 11,
|
||||
NETMSG_HLTV = 12,
|
||||
NETMSG_TEXTMSG = 13,
|
||||
NETMSG_SCOREINFO = 14,
|
||||
NETMSG_BARTIME = 15,
|
||||
NETMSG_SENDAUDIO = 17,
|
||||
NETMSG_SAYTEXT = 18,
|
||||
NETMSG_BOTVOICE = 19,
|
||||
NETMSG_NUM = 21
|
||||
};
|
||||
|
||||
// variable reg pair
|
||||
struct VarPair
|
||||
{
|
||||
VarType type;
|
||||
cvar_t reg;
|
||||
bool regMissing;
|
||||
class ConVar *self;
|
||||
};
|
||||
|
||||
// translation pair
|
||||
struct TranslatorPair
|
||||
{
|
||||
const char *original;
|
||||
const char *translated;
|
||||
};
|
||||
|
||||
// network message block
|
||||
struct MessageBlock
|
||||
{
|
||||
int bot;
|
||||
int state;
|
||||
int msg;
|
||||
int regMsgs[NETMSG_NUM];
|
||||
};
|
||||
|
||||
// provides utility functions to not call original engine (less call-cost)
|
||||
class Engine : public Singleton <Engine>
|
||||
{
|
||||
private:
|
||||
short m_drawModels[DRAW_NUM];
|
||||
|
||||
// bot client command
|
||||
bool m_isBotCommand;
|
||||
char m_arguments[256];
|
||||
int m_argumentCount;
|
||||
|
||||
edict_t *m_startEntity;
|
||||
edict_t *m_localEntity;
|
||||
|
||||
Array <VarPair> m_cvars;
|
||||
Array <TranslatorPair> m_language;
|
||||
|
||||
MessageBlock m_msgBlock;
|
||||
|
||||
public:
|
||||
Engine (void);
|
||||
|
||||
~Engine (void);
|
||||
|
||||
// public functions
|
||||
public:
|
||||
|
||||
// precaches internal stuff
|
||||
void Precache (edict_t *startEntity);
|
||||
|
||||
// prints data to servers console
|
||||
void Printf (const char *fmt, ...);
|
||||
|
||||
// prints chat message to all players
|
||||
void ChatPrintf (const char *fmt, ...);
|
||||
|
||||
// prints center message to all players
|
||||
void CenterPrintf (const char *fmt, ...);
|
||||
|
||||
// prints message to client console
|
||||
void ClientPrintf (edict_t *ent, const char *fmt, ...);
|
||||
|
||||
// display world line
|
||||
void DrawLine (edict_t *ent, const Vector &start, const Vector &end, int width, int noise, int red, int green, int blue, int brightness, int speed, int life, DrawLineType type = DRAW_SIMPLE);
|
||||
|
||||
// test line
|
||||
void TestLine (const Vector &start, const Vector &end, int ignoreFlags, edict_t *ignoreEntity, TraceResult *ptr);
|
||||
|
||||
// test line
|
||||
void TestHull (const Vector &start, const Vector &end, int ignoreFlags, int hullNumber, edict_t *ignoreEntity, TraceResult *ptr);
|
||||
|
||||
// get's the wave length
|
||||
float GetWaveLength (const char *fileName);
|
||||
|
||||
// we are on dedicated server ?
|
||||
bool IsDedicatedServer (void);
|
||||
|
||||
// get stripped down mod name
|
||||
const char *GetModName (void);
|
||||
|
||||
// get the valid mapname
|
||||
const char *GetMapName (void);
|
||||
|
||||
// get the "any" entity origin
|
||||
Vector GetAbsOrigin (edict_t *ent);
|
||||
|
||||
// send server command
|
||||
void IssueCmd (const char *fmt, ...);
|
||||
|
||||
// registers a server command
|
||||
void RegisterCmd (const char *command, void func (void));
|
||||
|
||||
// play's sound to client
|
||||
void EmitSound (edict_t *ent, const char *sound);
|
||||
|
||||
// sends bot command
|
||||
void IssueBotCommand (edict_t *ent, const char *fmt, ...);
|
||||
|
||||
// adds cvar to registration stack
|
||||
void PushVariableToStack (const char *variable, const char *value, VarType varType, bool regMissing, ConVar *self);
|
||||
|
||||
// sends local registration stack for engine registration
|
||||
void PushRegisteredConVarsToEngine (bool gameVars = false);
|
||||
|
||||
// translates bot message into needed language
|
||||
char *TraslateMessage (const char *input);
|
||||
|
||||
// cleanup translator resources
|
||||
void TerminateTranslator (void);
|
||||
|
||||
// do actual network message processing
|
||||
void ProcessMessageCapture (void *ptr);
|
||||
|
||||
// public inlines
|
||||
public:
|
||||
|
||||
// get the current time on server
|
||||
FORCEINLINE float Time (void)
|
||||
{
|
||||
return g_pGlobals->time;
|
||||
}
|
||||
|
||||
// get "maxplayers" limit on server
|
||||
FORCEINLINE int MaxClients (void)
|
||||
{
|
||||
return g_pGlobals->maxClients;
|
||||
}
|
||||
|
||||
// get the fakeclient command interface
|
||||
inline bool IsBotCommand (void)
|
||||
{
|
||||
return m_isBotCommand;
|
||||
}
|
||||
|
||||
// gets custom engine args for client command
|
||||
inline const char *GetOverrideArgs (void)
|
||||
{
|
||||
if (strncmp ("say ", m_arguments, 4) == 0)
|
||||
return &m_arguments[4];
|
||||
else if (strncmp ("say_team ", m_arguments, 9) == 0)
|
||||
return &m_arguments[9];
|
||||
|
||||
return m_arguments;
|
||||
}
|
||||
|
||||
// gets custom engine argv for client command
|
||||
inline const char *GetOverrideArgv (int num)
|
||||
{
|
||||
return ExtractSingleField (m_arguments, num, false);
|
||||
}
|
||||
|
||||
// gets custom engine argc for client command
|
||||
inline int GetOverrideArgc (void)
|
||||
{
|
||||
return m_argumentCount;
|
||||
}
|
||||
|
||||
// gets edict pointer out of entity index
|
||||
FORCEINLINE edict_t *EntityOfIndex (const int index)
|
||||
{
|
||||
return static_cast <edict_t *> (m_startEntity + index);
|
||||
};
|
||||
|
||||
// gets edict index out of it's pointer
|
||||
FORCEINLINE int IndexOfEntity (const edict_t *ent)
|
||||
{
|
||||
return static_cast <int> (ent - m_startEntity);
|
||||
};
|
||||
|
||||
// verify entity isn't null
|
||||
FORCEINLINE bool IsNullEntity (const edict_t *ent)
|
||||
{
|
||||
return !ent || !IndexOfEntity (ent);
|
||||
}
|
||||
|
||||
// gets the player team
|
||||
FORCEINLINE int GetTeam (edict_t *ent)
|
||||
{
|
||||
extern Client g_clients[MAX_ENGINE_PLAYERS];
|
||||
|
||||
#ifndef XASH_CSDM
|
||||
return g_clients[IndexOfEntity (ent) - 1].team;
|
||||
#else
|
||||
return g_clients[IndexOfEntity (ent) - 1].team = ent->v.team == 1 ? TERRORIST : CT;
|
||||
#endif
|
||||
}
|
||||
|
||||
// adds translation pair from config
|
||||
inline void PushTranslationPair (const TranslatorPair &lang)
|
||||
{
|
||||
m_language.Push (lang);
|
||||
}
|
||||
|
||||
// resets the message capture mechanism
|
||||
inline void ResetMessageCapture (void)
|
||||
{
|
||||
m_msgBlock.msg = NETMSG_UNDEFINED;
|
||||
m_msgBlock.state = 0;
|
||||
m_msgBlock.bot = 0;
|
||||
};
|
||||
|
||||
// sets the currently executed message
|
||||
inline void SetOngoingMessageId (int message)
|
||||
{
|
||||
m_msgBlock.msg = message;
|
||||
}
|
||||
|
||||
// set the bot entity that receive this message
|
||||
inline void SetOngoingMessageReceiver (int id)
|
||||
{
|
||||
m_msgBlock.bot = id;
|
||||
}
|
||||
|
||||
// find registered message id
|
||||
FORCEINLINE int FindMessageId (int type)
|
||||
{
|
||||
return m_msgBlock.regMsgs[type];
|
||||
}
|
||||
|
||||
// assigns message id for message type
|
||||
inline void AssignMessageId (int type, int id)
|
||||
{
|
||||
m_msgBlock.regMsgs[type] = id;
|
||||
}
|
||||
|
||||
// tries to set needed message id
|
||||
FORCEINLINE void TryCaptureMessage (int type, int msgId)
|
||||
{
|
||||
if (type == m_msgBlock.regMsgs[msgId])
|
||||
SetOngoingMessageId (msgId);
|
||||
}
|
||||
|
||||
// static utility functions
|
||||
public:
|
||||
static const char *ExtractSingleField (const char *string, int id, bool terminate);
|
||||
};
|
||||
|
||||
// simplify access for console variables
|
||||
class ConVar
|
||||
{
|
||||
public:
|
||||
cvar_t *m_eptr;
|
||||
|
||||
public:
|
||||
ConVar (const char *name, const char *initval, VarType type = VT_NOSERVER, bool regMissing = false);
|
||||
|
||||
FORCEINLINE bool GetBool (void) { return m_eptr->value > 0.0f; }
|
||||
FORCEINLINE int GetInt (void) { return static_cast <int> (m_eptr->value); }
|
||||
FORCEINLINE float GetFloat (void) { return m_eptr->value; }
|
||||
FORCEINLINE const char *GetString (void) { return m_eptr->string; }
|
||||
FORCEINLINE void SetFloat (float val) { m_eptr->value = val; }
|
||||
FORCEINLINE void SetInt (int val) { SetFloat (static_cast <float> (val)); }
|
||||
FORCEINLINE void SetString (const char *val) { g_engfuncs.pfnCvar_DirectSet (m_eptr, const_cast <char *> (val)); }
|
||||
};
|
||||
|
|
@ -678,7 +678,7 @@ enum
|
|||
kRenderTransTexture, // src*a+dest*(1-a)
|
||||
kRenderGlow, // src*a+dest -- No Z buffer checks
|
||||
kRenderTransAlpha, // src*srca+dest*(1-srca)
|
||||
kRenderTransAdd, // src*a+dest
|
||||
kRenderTransAdd // src*a+dest
|
||||
};
|
||||
|
||||
enum
|
||||
|
|
@ -703,7 +703,7 @@ enum
|
|||
kRenderFxDeadPlayer, // kRenderAmt is the player index
|
||||
kRenderFxExplode, // Scale up really big!
|
||||
kRenderFxGlowShell, // Glowing Shell
|
||||
kRenderFxClampMinScale, // Keep this sprite from getting very small (SPRITES only!)
|
||||
kRenderFxClampMinScale // Keep this sprite from getting very small (SPRITES only!)
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -69,20 +69,15 @@ typedef enum
|
|||
{
|
||||
print_console,
|
||||
print_center,
|
||||
print_chat,
|
||||
print_chat
|
||||
} PRINT_TYPE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
print_withtag = print_console | 0x3ff,
|
||||
} PRINT_TYPE_EX; // (dz): added for bots needs
|
||||
|
||||
// For integrity checking of content on clients
|
||||
typedef enum
|
||||
{
|
||||
force_exactfile, // File on client must exactly match server's file
|
||||
force_model_samebounds, // For model files only, the geometry must fit in the same bbox
|
||||
force_model_specifybounds, // For model files only, the geometry must fit in the specified bbox
|
||||
force_model_specifybounds // For model files only, the geometry must fit in the specified bbox
|
||||
} FORCE_TYPE;
|
||||
|
||||
// Returned by TraceLine
|
||||
|
|
@ -100,8 +95,6 @@ typedef struct
|
|||
int iHitgroup; // 0 == generic, non zero is specific body part
|
||||
} TraceResult;
|
||||
|
||||
typedef edict_t *entity_t;
|
||||
|
||||
typedef uint32 CRC32_t;
|
||||
|
||||
// Engine hands this to DLLs for functionality callbacks
|
||||
|
|
@ -149,7 +142,7 @@ typedef struct enginefuncs_s
|
|||
void (*pfnGetAimVector) (edict_t *ent, float speed, float *rgflReturn);
|
||||
void (*pfnServerCommand) (char *str);
|
||||
void (*pfnServerExecute) (void);
|
||||
void (*pfnClientCommand) (edict_t *ent, char *szFmt, ...);
|
||||
void (*pfnClientCommand) (edict_t *ent, char const *szFmt, ...);
|
||||
void (*pfnParticleEffect) (const float *org, const float *dir, float color, float count);
|
||||
void (*pfnLightStyle) (int style, char *val);
|
||||
int (*pfnDecalIndex) (const char *name);
|
||||
|
|
@ -203,7 +196,7 @@ typedef struct enginefuncs_s
|
|||
void (*pfnSetView) (const edict_t *client, const edict_t *pViewent);
|
||||
float (*pfnTime) (void);
|
||||
void (*pfnCrosshairAngle) (const edict_t *client, float pitch, float yaw);
|
||||
byte *(*pfnLoadFileForMe) (char *szFilename, int *pLength);
|
||||
byte *(*pfnLoadFileForMe) (char const *szFilename, int *pLength);
|
||||
void (*pfnFreeFile) (void *buffer);
|
||||
void (*pfnEndSection) (const char *pszSectionName); // trigger_endsection
|
||||
int (*pfnCompareFileTime) (char *filename1, char *filename2, int *compare);
|
||||
|
|
@ -215,9 +208,9 @@ typedef struct enginefuncs_s
|
|||
void (*pfnRunPlayerMove) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec);
|
||||
int (*pfnNumberOfEntities) (void);
|
||||
char *(*pfnGetInfoKeyBuffer) (edict_t *e); // passing in NULL gets the serverinfo
|
||||
char *(*pfnInfoKeyValue) (char *infobuffer, char *key);
|
||||
char *(*pfnInfoKeyValue) (char *infobuffer, char const *key);
|
||||
void (*pfnSetKeyValue) (char *infobuffer, char *key, char *value);
|
||||
void (*pfnSetClientKeyValue) (int clientIndex, char *infobuffer, char *key, char *value);
|
||||
void (*pfnSetClientKeyValue) (int clientIndex, char *infobuffer, char const *key, char const *value);
|
||||
int (*pfnIsMapValid) (char *szFilename);
|
||||
void (*pfnStaticDecal) (const float *origin, int decalIndex, int entityIndex, int modelIndex);
|
||||
int (*pfnPrecacheGeneric) (char *s);
|
||||
|
|
@ -246,7 +239,7 @@ typedef struct enginefuncs_s
|
|||
void (*pfnDeltaUnsetFieldByIndex) (struct delta_s *pFields, int fieldNumber);
|
||||
void (*pfnSetGroupMask) (int mask, int op);
|
||||
int (*pfnCreateInstancedBaseline) (int classname, struct entity_state_s *baseline);
|
||||
void (*pfnCvar_DirectSet) (struct cvar_s *var, char *value);
|
||||
void (*pfnCvar_DirectSet) (struct cvar_t *var, char *value);
|
||||
void (*pfnForceUnmodified) (FORCE_TYPE type, float *mins, float *maxs, const char *szFilename);
|
||||
void (*pfnGetPlayerStats) (const edict_t *client, int *ping, int *packet_loss);
|
||||
void (*pfnAddServerCommand) (char *cmd_name, void (*function) (void));
|
||||
|
|
@ -280,7 +273,7 @@ typedef struct enginefuncs_s
|
|||
typedef struct KeyValueData_s
|
||||
{
|
||||
char *szClassName; // in: entity classname
|
||||
char *szKeyName; // in: name of key
|
||||
char const *szKeyName; // in: name of key
|
||||
char *szValue; // in: value of key
|
||||
int32 fHandled; // out: DLL sets to true if key-value pair was understood
|
||||
} KeyValueData;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#define DEBUG 1
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable : 4244) // int or float down-conversion
|
||||
#pragma warning (disable : 4305) // int or float data truncation
|
||||
#pragma warning (disable : 4201) // nameless struct/union
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
#pragma warning (disable : 4702) // unreachable code
|
||||
#pragma warning (disable : 4706) // assignment within conditional expression
|
||||
|
||||
/* (dz): disable deprecation warnings concerning unsafe CRT functions */
|
||||
/* disable deprecation warnings concerning unsafe CRT functions */
|
||||
#if !defined _CRT_SECURE_NO_DEPRECATE
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -31,19 +31,19 @@ typedef enum
|
|||
PT_STARTUP,
|
||||
PT_CHANGELEVEL,
|
||||
PT_ANYTIME,
|
||||
PT_ANYPAUSE,
|
||||
PT_ANYPAUSE
|
||||
} PLUG_LOADTIME;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *ifvers;
|
||||
char *name;
|
||||
char *version;
|
||||
char *date;
|
||||
char *author;
|
||||
char *url;
|
||||
char *logtag;
|
||||
char const *ifvers;
|
||||
char const *name;
|
||||
char const *version;
|
||||
char const *date;
|
||||
char const *author;
|
||||
char const *url;
|
||||
char const *logtag;
|
||||
PLUG_LOADTIME loadable;
|
||||
PLUG_LOADTIME unloadable;
|
||||
} plugin_info_t;
|
||||
|
|
@ -64,7 +64,7 @@ typedef enum
|
|||
PNL_DELAYED,
|
||||
PNL_PLUGIN,
|
||||
PNL_PLG_FORCED,
|
||||
PNL_RELOAD,
|
||||
PNL_RELOAD
|
||||
} PL_UNLOAD_REASON;
|
||||
|
||||
typedef enum
|
||||
|
|
@ -73,7 +73,7 @@ typedef enum
|
|||
MRES_IGNORED,
|
||||
MRES_HANDLED,
|
||||
MRES_OVERRIDE,
|
||||
MRES_SUPERCEDE,
|
||||
MRES_SUPERCEDE
|
||||
} META_RES;
|
||||
|
||||
typedef struct meta_globals_s
|
||||
|
|
@ -121,7 +121,7 @@ typedef enum
|
|||
GINFO_GAMEDIR,
|
||||
GINFO_DLL_FULLPATH,
|
||||
GINFO_DLL_FILENAME,
|
||||
GINFO_REALDLL_FULLPATH,
|
||||
GINFO_REALDLL_FULLPATH
|
||||
} ginfo_t;
|
||||
|
||||
// Meta Utility Function table type.
|
||||
|
|
|
|||
|
|
@ -53,12 +53,6 @@ static inline edict_t *FIND_ENTITY_BY_TARGET (edict_t *entStart, const char *psz
|
|||
#define ClearBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) & ~(bits))
|
||||
#define FBitSet(flBitVector, bit) ((int)(flBitVector) & (bit))
|
||||
|
||||
// Pointer operators
|
||||
#define PTR_TO_BYTE(in) *(byte *) (in)
|
||||
#define PTR_TO_FLT(in) *(float *) (in)
|
||||
#define PTR_TO_INT(in) *(int *) (in)
|
||||
#define PTR_TO_STR(in) (char *) (in)
|
||||
|
||||
// Makes these more explicit, and easier to find
|
||||
#define FILE_GLOBAL static
|
||||
|
||||
|
|
@ -82,6 +76,7 @@ typedef int BOOL;
|
|||
//
|
||||
// Conversion among the three types of "entity", including identity-conversions.
|
||||
//
|
||||
#if 0
|
||||
static inline edict_t *ENT (const entvars_t *pev)
|
||||
{
|
||||
return pev->pContainingEntity;
|
||||
|
|
@ -131,12 +126,14 @@ static inline entvars_t *VARS (EOFFSET eoffset)
|
|||
{
|
||||
return VARS (ENT (eoffset));
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void MESSAGE_BEGIN (int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent)
|
||||
{
|
||||
(*g_engfuncs.pfnMessageBegin) (msg_dest, msg_type, pOrigin, ENT (ent));
|
||||
(*g_engfuncs.pfnMessageBegin) (msg_dest, msg_type, pOrigin, ent->pContainingEntity);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Testing the three types of "entity" for nullity
|
||||
#define eoNullEntity 0
|
||||
static inline BOOL FNullEnt (EOFFSET eoffset)
|
||||
|
|
@ -162,6 +159,7 @@ static inline BOOL FStringNull (int stingPtr)
|
|||
#define cchMapNameMost 32
|
||||
|
||||
#define SAFE_FUNCTION_CALL(pfn,args) try { pfn args; } catch (...) { }
|
||||
#endif
|
||||
|
||||
// Dot products for view cone checking
|
||||
#define VIEW_FIELD_FULL (float)-1.0 // +-180 degrees
|
||||
|
|
@ -176,7 +174,7 @@ static inline BOOL FStrEq (const char *sz1, const char *sz2)
|
|||
}
|
||||
static inline BOOL FClassnameIs (edict_t *pent, const char *szClassname)
|
||||
{
|
||||
return FStrEq (STRING (VARS (pent)->classname), szClassname);
|
||||
return FStrEq (STRING (pent->v.classname), szClassname);
|
||||
}
|
||||
static inline BOOL FClassnameIs (entvars_t *pev, const char *szClassname)
|
||||
{
|
||||
|
|
@ -207,8 +205,6 @@ typedef struct hudtextparms_s
|
|||
} hudtextparms_t;
|
||||
|
||||
|
||||
extern Vector GetEntityOrigin (entvars_t *pevBModel);
|
||||
|
||||
#define AMBIENT_SOUND_STATIC 0 // medium radius attenuation
|
||||
#define AMBIENT_SOUND_EVERYWHERE 1
|
||||
#define AMBIENT_SOUND_SMALLRADIUS 2
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ extern bool g_autoWaypoint;
|
|||
extern bool g_botsCanPause;
|
||||
extern bool g_editNoclip;
|
||||
extern bool g_isMetamod;
|
||||
extern bool g_isFakeCommand;
|
||||
extern bool g_sendAudioFinished;
|
||||
extern bool g_isCommencing;
|
||||
extern bool g_leaderChoosen[2];
|
||||
|
|
@ -39,7 +38,6 @@ extern float g_lastRadioTime[2];
|
|||
extern int g_mapType;
|
||||
extern int g_numWaypoints;
|
||||
extern int g_gameFlags;
|
||||
extern int g_fakeArgc;
|
||||
|
||||
extern int g_highestDamageCT;
|
||||
extern int g_highestDamageT;
|
||||
|
|
@ -50,15 +48,11 @@ extern int g_rusherWeaponPrefs[NUM_WEAPONS];
|
|||
extern int g_carefulWeaponPrefs[NUM_WEAPONS];
|
||||
extern int g_grenadeBuyPrecent[NUM_WEAPONS - 23];
|
||||
extern int g_botBuyEconomyTable[NUM_WEAPONS - 15];
|
||||
extern int g_radioSelect[32];
|
||||
extern int g_radioSelect[MAX_ENGINE_PLAYERS];
|
||||
extern int g_lastRadio[2];
|
||||
extern int g_storeAddbotVars[4];
|
||||
extern int *g_weaponPrefs[];
|
||||
|
||||
extern short g_modelIndexLaser;
|
||||
extern short g_modelIndexArrow;
|
||||
extern char g_fakeArgv[256];
|
||||
|
||||
extern Array <Array <String> > g_chatFactory;
|
||||
extern Array <Array <ChatterItem> > g_chatterFactory;
|
||||
extern Array <BotName> g_botNames;
|
||||
|
|
@ -68,14 +62,13 @@ extern RandomSequenceOfUnique Random;
|
|||
extern WeaponSelect g_weaponSelect[NUM_WEAPONS + 1];
|
||||
extern WeaponProperty g_weaponDefs[MAX_WEAPONS + 1];
|
||||
|
||||
extern Client g_clients[32];
|
||||
extern Client g_clients[MAX_ENGINE_PLAYERS];
|
||||
extern MenuText g_menus[21];
|
||||
extern TaskItem g_taskFilters[];
|
||||
|
||||
extern Experience *g_experienceData;
|
||||
|
||||
extern edict_t *g_hostEntity;
|
||||
extern edict_t *g_worldEntity;
|
||||
extern Library *g_gameLib;
|
||||
|
||||
extern gamefuncs_t g_functionTable;
|
||||
|
|
@ -91,42 +84,3 @@ static inline bool IsNullString (const char *input)
|
|||
|
||||
return *input == '\0';
|
||||
}
|
||||
|
||||
static inline float GetWorldTime (void)
|
||||
{
|
||||
return g_pGlobals->time;
|
||||
}
|
||||
|
||||
static inline int GetMaxClients (void)
|
||||
{
|
||||
return g_pGlobals->maxClients;
|
||||
}
|
||||
|
||||
static inline edict_t *EntityOfIndex (const int index)
|
||||
{
|
||||
return static_cast <edict_t *> (g_worldEntity + index);
|
||||
};
|
||||
|
||||
static inline int IndexOfEntity(const edict_t *ent)
|
||||
{
|
||||
return static_cast <int> (ent - g_worldEntity);
|
||||
};
|
||||
|
||||
static inline int EntOffsetOfEntity(const edict_t *ent)
|
||||
{
|
||||
return (char *) ent - (char *) g_worldEntity;
|
||||
}
|
||||
|
||||
static inline bool IsEntityNull (const edict_t *ent)
|
||||
{
|
||||
return !ent || !EntOffsetOfEntity (ent);
|
||||
}
|
||||
|
||||
static inline int GetTeam (edict_t *ent)
|
||||
{
|
||||
#ifndef XASH_CSDM
|
||||
return g_clients[IndexOfEntity (ent) - 1].team;
|
||||
#else
|
||||
return g_clients[IndexOfEntity (ent) - 1].team = ent->v.team == 1 ? TERRORIST : CT;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -21,15 +21,15 @@
|
|||
// detects the compiler
|
||||
#if defined (_MSC_VER)
|
||||
#define COMPILER_VISUALC _MSC_VER
|
||||
#elif defined (__MINGW32__)
|
||||
#define COMPILER_MINGW32 __MINGW32__
|
||||
#elif defined (__MINGW32_MAJOR_VERSION)
|
||||
#define COMPILER_MINGW32 __MINGW32_MAJOR_VERSION
|
||||
#endif
|
||||
|
||||
// configure export macros
|
||||
#if defined (COMPILER_VISUALC) || defined (COMPILER_MINGW32)
|
||||
#define export extern "C" __declspec (dllexport)
|
||||
#define SHARED_LIBRARAY_EXPORT extern "C" __declspec (dllexport)
|
||||
#elif defined (PLATFORM_LINUX) || defined (PLATFORM_OSX)
|
||||
#define export extern "C" __attribute__((visibility("default")))
|
||||
#define SHARED_LIBRARAY_EXPORT extern "C" __attribute__((visibility("default")))
|
||||
#else
|
||||
#error "Can't configure export macros. Compiler unrecognized."
|
||||
#endif
|
||||
|
|
@ -38,6 +38,7 @@
|
|||
#ifdef PLATFORM_WIN32
|
||||
|
||||
#include <direct.h>
|
||||
#include <string.h>
|
||||
|
||||
#define DLL_ENTRYPOINT int STDCALL DllMain (HINSTANCE, DWORD dwReason, LPVOID)
|
||||
#define DLL_DETACHING (dwReason == DLL_PROCESS_DETACH)
|
||||
|
|
@ -46,7 +47,7 @@
|
|||
#if defined (COMPILER_VISUALC)
|
||||
#define DLL_GIVEFNPTRSTODLL extern "C" void STDCALL
|
||||
#elif defined (COMPILER_MINGW32)
|
||||
#define DLL_GIVEFNPTRSTODLL export void STDCALL
|
||||
#define DLL_GIVEFNPTRSTODLL SHARED_LIBRARAY_EXPORT void STDCALL
|
||||
#endif
|
||||
|
||||
// specify export parameter
|
||||
|
|
@ -157,4 +158,4 @@ public:
|
|||
{
|
||||
return m_ptr != NULL;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,17 +11,17 @@
|
|||
|
||||
// general product information
|
||||
#define PRODUCT_NAME "Yet Another POD-Bot"
|
||||
#define PRODUCT_VERSION "2.7.2"
|
||||
#define PRODUCT_VERSION "2.73"
|
||||
#define PRODUCT_AUTHOR "YaPB Dev Team"
|
||||
#define PRODUCT_URL "https://yapb.jeefo.net"
|
||||
#define PRODUCT_EMAIL "dmitry@jeefo.net"
|
||||
#define PRODUCT_LOGTAG "YAPB"
|
||||
#define PRODUCT_DESCRIPTION PRODUCT_NAME " v" PRODUCT_VERSION " - The Counter-Strike Bot"
|
||||
#define PRODUCT_COPYRIGHT "Copyright © 2003-2016, by " PRODUCT_AUTHOR
|
||||
#define PRODUCT_COPYRIGHT "Copyright © 2003-2016, by " PRODUCT_AUTHOR
|
||||
#define PRODUCT_LEGAL "Half-Life, Counter-Strike, Counter-Strike: Condition Zero, Steam, Valve is a trademark of Valve Corporation"
|
||||
#define PRODUCT_ORIGINAL_NAME "yapb.dll"
|
||||
#define PRODUCT_INTERNAL_NAME "skybot"
|
||||
#define PRODUCT_VERSION_DWORD_INTERNAL 2,7,2
|
||||
#define PRODUCT_VERSION_DWORD_INTERNAL 2,73
|
||||
#define PRODUCT_VERSION_DWORD PRODUCT_VERSION_DWORD_INTERNAL,0
|
||||
#define PRODUCT_SUPPORT_VERSION "1.0 - CZ"
|
||||
#define PRODUCT_COMMENTS "http://github.com/jeefo/yapb/"
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ OBJECTS = $(SRC_DIR)/basecode.cpp \
|
|||
$(SRC_DIR)/chatlib.cpp \
|
||||
$(SRC_DIR)/combat.cpp \
|
||||
$(SRC_DIR)/globals.cpp \
|
||||
$(SRC_DIR)/engine.cpp \
|
||||
$(SRC_DIR)/interface.cpp \
|
||||
$(SRC_DIR)/navigate.cpp \
|
||||
$(SRC_DIR)/netmsg.cpp \
|
||||
$(SRC_DIR)/support.cpp \
|
||||
$(SRC_DIR)/waypoint.cpp \
|
||||
|
||||
C_OPT_FLAGS = -O3 -DNDEBUG=1 -fno-exceptions -fno-rtti -funroll-loops -fomit-frame-pointer -pipe
|
||||
C_OPT_FLAGS = -O3 -DNDEBUG=1 -fno-exceptions -fno-rtti -funroll-loops -fomit-frame-pointer -pipe -mtune=native
|
||||
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
|
||||
C_GCC4_FLAGS = -fvisibility=hidden
|
||||
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
|
||||
|
|
@ -47,13 +47,13 @@ ifeq "$(OS)" "Darwin"
|
|||
else
|
||||
LIB_EXT = so
|
||||
CFLAGS += -DLINUX -D_LINUX -DPOSIX
|
||||
LINK += -shared
|
||||
LINK += -shared -lsupc++
|
||||
endif
|
||||
|
||||
LINK += -m32 -lm -ldl
|
||||
|
||||
CFLAGS += -DHAVE_STDINT_H -D__extern_always_inline=inline -D_strdup=strdup -Dstricmp=strcasecmp -Dstrcmpi=strcasecmp -fno-strict-aliasing -m32 -Wall -Werror -Wno-uninitialized -Wno-unused -Wno-switch -Wno-c++11-compat-deprecated-writable-strings
|
||||
CPPFLAGS += -Wno-invalid-offsetof -fno-exceptions -fno-rtti
|
||||
CFLAGS += -DHAVE_STDINT_H -D__extern_always_inline=inline -D_strdup=strdup -Dstricmp=strcasecmp -Dstrcmpi=strcasecmp -fno-strict-aliasing -m32 -Wall -Werror -Wextra
|
||||
CPPFLAGS += -fno-exceptions -fno-rtti -fno-builtin
|
||||
|
||||
BINARY = $(PROJECT).$(LIB_EXT)
|
||||
|
||||
|
|
@ -72,30 +72,10 @@ endif
|
|||
IS_CLANG := $(shell $(CPP) --version | head -1 | grep clang > /dev/null && echo "1" || echo "0")
|
||||
|
||||
ifeq "$(IS_CLANG)" "1"
|
||||
CPP_MAJOR := $(shell $(CPP) --version | grep clang | sed "s/.*version \([0-9]\)*\.[0-9]*.*/\1/")
|
||||
CPP_MINOR := $(shell $(CPP) --version | grep clang | sed "s/.*version [0-9]*\.\([0-9]\)*.*/\1/")
|
||||
else
|
||||
CPP_MAJOR := $(shell $(CPP) -dumpversion >&1 | cut -b1)
|
||||
CPP_MINOR := $(shell $(CPP) -dumpversion >&1 | cut -b3)
|
||||
endif
|
||||
|
||||
# Clang || GCC >= 4
|
||||
ifeq "$(shell expr $(IS_CLANG) \| $(CPP_MAJOR) \>= 4)" "1"
|
||||
CFLAGS += $(C_GCC4_FLAGS)
|
||||
CPPFLAGS += $(CPP_GCC4_FLAGS)
|
||||
endif
|
||||
|
||||
ifeq "$(IS_CLANG)" "1"
|
||||
CFLAGS += -Wno-logical-op-parentheses
|
||||
else
|
||||
CFLAGS += -Wno-parentheses
|
||||
endif
|
||||
|
||||
# Clang >= 3 || GCC >= 4.7
|
||||
ifeq "$(shell expr $(IS_CLANG) \& $(CPP_MAJOR) \>= 3 \| $(CPP_MAJOR) \>= 4 \& $(CPP_MINOR) \>= 7)" "1"
|
||||
CFLAGS += -Wno-delete-non-virtual-dtor
|
||||
endif
|
||||
|
||||
# OS is Linux and not using clang
|
||||
ifeq "$(shell expr $(OS) \= Linux \& $(IS_CLANG) \= 0)" "1"
|
||||
LINK += -static-libgcc
|
||||
|
|
@ -142,3 +122,4 @@ default: all
|
|||
clean:
|
||||
rm -rf release
|
||||
rm -rf debug
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
<ClInclude Include="..\include\compress.h" />
|
||||
<ClInclude Include="..\include\core.h" />
|
||||
<ClInclude Include="..\include\corelib.h" />
|
||||
<ClInclude Include="..\include\engine.h" />
|
||||
<ClInclude Include="..\include\engine\archtypes.h" />
|
||||
<ClInclude Include="..\include\engine\const.h" />
|
||||
<ClInclude Include="..\include\engine\dllapi.h" />
|
||||
|
|
@ -33,12 +34,12 @@
|
|||
<ItemGroup>
|
||||
<ClCompile Include="..\source\basecode.cpp" />
|
||||
<ClCompile Include="..\source\combat.cpp" />
|
||||
<ClCompile Include="..\source\engine.cpp" />
|
||||
<ClCompile Include="..\source\manager.cpp" />
|
||||
<ClCompile Include="..\source\chatlib.cpp" />
|
||||
<ClCompile Include="..\source\globals.cpp" />
|
||||
<ClCompile Include="..\source\interface.cpp" />
|
||||
<ClCompile Include="..\source\navigate.cpp" />
|
||||
<ClCompile Include="..\source\netmsg.cpp" />
|
||||
<ClCompile Include="..\source\support.cpp" />
|
||||
<ClCompile Include="..\source\waypoint.cpp" />
|
||||
</ItemGroup>
|
||||
|
|
@ -54,13 +55,14 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140_xp</PlatformToolset>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140_xp</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
|
|
@ -111,9 +113,7 @@
|
|||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include\engine;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<PrecompiledHeader />
|
||||
<PrecompiledHeaderFile>core.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>.\debug\inf\yapb.pch</PrecompiledHeaderOutputFile>
|
||||
|
|
@ -128,7 +128,12 @@
|
|||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FloatingPointModel>Strict</FloatingPointModel>
|
||||
<StringPooling>true</StringPooling>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
|
@ -141,7 +146,6 @@
|
|||
<OutputFile>.\debug\yapb.dll</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<ProgramDatabaseFile>.\debug\inf\yapb.pdb</ProgramDatabaseFile>
|
||||
<GenerateMapFile>true</GenerateMapFile>
|
||||
<MapFileName>.\debug\inf\yapb.map</MapFileName>
|
||||
|
|
@ -149,11 +153,8 @@
|
|||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>false</OptimizeReferences>
|
||||
<EnableCOMDATFolding>false</EnableCOMDATFolding>
|
||||
<NoEntryPoint>false</NoEntryPoint>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention />
|
||||
<ImportLibrary>.\debug\inf\yapb.lib</ImportLibrary>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
</Link>
|
||||
|
|
@ -180,13 +181,13 @@
|
|||
</Midl>
|
||||
<ClCompile>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>false</IntrinsicFunctions>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
||||
<AdditionalIncludeDirectories>..\mmgr;..\include\engine;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NDEBUG;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>.\release\inf\yapb.pch</PrecompiledHeaderOutputFile>
|
||||
|
|
@ -209,6 +210,7 @@
|
|||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<StringPooling>true</StringPooling>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
|
|
|||
|
|
@ -39,9 +39,6 @@
|
|||
<ClInclude Include="..\include\engine\eiface.h">
|
||||
<Filter>include\engine</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\engine\enginecallback.h">
|
||||
<Filter>include\engine</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\engine\extdll.h">
|
||||
<Filter>include\engine</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -69,6 +66,12 @@
|
|||
<ClInclude Include="..\include\platform.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\engine.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\engine\enginecallback.h">
|
||||
<Filter>include\engine</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\source\chatlib.cpp">
|
||||
|
|
@ -83,9 +86,6 @@
|
|||
<ClCompile Include="..\source\navigate.cpp">
|
||||
<Filter>source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\source\netmsg.cpp">
|
||||
<Filter>source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\source\support.cpp">
|
||||
<Filter>source</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -101,6 +101,9 @@
|
|||
<ClCompile Include="..\source\combat.cpp">
|
||||
<Filter>source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\source\engine.cpp">
|
||||
<Filter>source</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="yapb.rc">
|
||||
|
|
|
|||
|
|
@ -22,13 +22,13 @@ LOCAL_SRC_FILES := \
|
|||
chatlib.cpp \
|
||||
combat.cpp \
|
||||
globals.cpp \
|
||||
engine.cpp \
|
||||
interface.cpp \
|
||||
navigate.cpp \
|
||||
netmsg.cpp \
|
||||
support.cpp \
|
||||
waypoint.cpp \
|
||||
|
||||
LOCAL_CFLAGS += -O2 -DLINUX -D_LINUX -DPOSIX -DHAVE_STDINT_H -D__extern_always_inline=inline -D_strdup=strdup -Dstricmp=strcasecmp -Dstrcmpi=strcasecmp -fno-strict-aliasing -Wall -Werror -Wno-uninitialized -Wno-unused -Wno-switch -Wno-c++11-compat-deprecated-writable-strings
|
||||
LOCAL_CPPFLAGS += -w -Wno-invalid-offsetof -fno-exceptions -fno-rtti
|
||||
LOCAL_CFLAGS += -O2 -DLINUX -D_LINUX -DPOSIX -DHAVE_STDINT_H -D__extern_always_inline=inline -D_strdup=strdup -Dstricmp=strcasecmp -Dstrcmpi=strcasecmp -fno-strict-aliasing -Wall -Werror
|
||||
LOCAL_CPPFLAGS += -w -fno-exceptions -fno-rtti
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -47,7 +47,7 @@ void StripTags (char *buffer)
|
|||
// have we stripped too much (all the stuff)?
|
||||
if (buffer[0] != '\0')
|
||||
{
|
||||
strtrim (buffer); // if so, string is just a tag
|
||||
String::TrimExternalBuffer (buffer); // if so, string is just a tag
|
||||
|
||||
int tagLength = 0;
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ void StripTags (char *buffer)
|
|||
}
|
||||
}
|
||||
}
|
||||
strtrim (buffer); // to finish, strip eventual blanks after and before the tag marks
|
||||
String::TrimExternalBuffer (buffer); // to finish, strip eventual blanks after and before the tag marks
|
||||
}
|
||||
|
||||
char *HumanizeName (char *name)
|
||||
|
|
@ -95,7 +95,7 @@ char *HumanizeName (char *name)
|
|||
if (Random.Long (1, 100) < 80)
|
||||
StripTags (outputName);
|
||||
else
|
||||
strtrim (outputName);
|
||||
String::TrimExternalBuffer (outputName);
|
||||
|
||||
// sometimes switch name to lower characters
|
||||
// note: since we're using russian names written in english, we reduce this shit to 6 percent
|
||||
|
|
@ -156,7 +156,7 @@ void Bot::PrepareChatMessage (char *text)
|
|||
if (!yb_chat.GetBool () || IsNullString (text))
|
||||
return;
|
||||
|
||||
#define ASSIGN_TALK_ENTITY() if (!IsEntityNull (talkEntity)) strncat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))), SIZEOF_CHAR (m_tempStrings))
|
||||
#define ASSIGN_TALK_ENTITY() if (!engine.IsNullEntity (talkEntity)) strncat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))), SIZEOF_CHAR (m_tempStrings))
|
||||
|
||||
memset (&m_tempStrings, 0, sizeof (m_tempStrings));
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ void Bot::PrepareChatMessage (char *text)
|
|||
int highestFrags = -9000; // just pick some start value
|
||||
int index = 0;
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (!(g_clients[i].flags & CF_USED) || g_clients[i].ent == GetEntity ())
|
||||
continue;
|
||||
|
|
@ -204,17 +204,17 @@ void Bot::PrepareChatMessage (char *text)
|
|||
}
|
||||
// mapname?
|
||||
else if (*pattern == 'm')
|
||||
strncat (m_tempStrings, GetMapName (), SIZEOF_CHAR (m_tempStrings));
|
||||
strncat (m_tempStrings, engine.GetMapName (), SIZEOF_CHAR (m_tempStrings));
|
||||
// roundtime?
|
||||
else if (*pattern == 'r')
|
||||
{
|
||||
int time = static_cast <int> (g_timeRoundEnd - GetWorldTime ());
|
||||
int time = static_cast <int> (g_timeRoundEnd - engine.Time ());
|
||||
strncat (m_tempStrings, FormatBuffer ("%02d:%02d", time / 60, time % 60), SIZEOF_CHAR (m_tempStrings));
|
||||
}
|
||||
// chat reply?
|
||||
else if (*pattern == 's')
|
||||
{
|
||||
talkEntity = EntityOfIndex (m_sayTextBuffer.entityIndex);
|
||||
talkEntity = engine.EntityOfIndex (m_sayTextBuffer.entityIndex);
|
||||
ASSIGN_TALK_ENTITY ();
|
||||
}
|
||||
// teammate alive?
|
||||
|
|
@ -222,7 +222,7 @@ void Bot::PrepareChatMessage (char *text)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < GetMaxClients (); i++)
|
||||
for (i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || g_clients[i].team != m_team || g_clients[i].ent == GetEntity ())
|
||||
continue;
|
||||
|
|
@ -230,9 +230,9 @@ void Bot::PrepareChatMessage (char *text)
|
|||
break;
|
||||
}
|
||||
|
||||
if (i < GetMaxClients ())
|
||||
if (i < engine.MaxClients ())
|
||||
{
|
||||
if (!IsEntityNull (pev->dmg_inflictor) && m_team == GetTeam (pev->dmg_inflictor))
|
||||
if (!engine.IsNullEntity (pev->dmg_inflictor) && m_team == engine.GetTeam (pev->dmg_inflictor))
|
||||
talkEntity = pev->dmg_inflictor;
|
||||
else
|
||||
talkEntity = g_clients[i].ent;
|
||||
|
|
@ -241,7 +241,7 @@ void Bot::PrepareChatMessage (char *text)
|
|||
}
|
||||
else // no teammates alive...
|
||||
{
|
||||
for (i = 0; i < GetMaxClients (); i++)
|
||||
for (i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (!(g_clients[i].flags & CF_USED) || g_clients[i].team != m_team || g_clients[i].ent == GetEntity ())
|
||||
continue;
|
||||
|
|
@ -249,7 +249,7 @@ void Bot::PrepareChatMessage (char *text)
|
|||
break;
|
||||
}
|
||||
|
||||
if (i < GetMaxClients ())
|
||||
if (i < engine.MaxClients ())
|
||||
{
|
||||
talkEntity = g_clients[i].ent;
|
||||
|
||||
|
|
@ -261,27 +261,27 @@ void Bot::PrepareChatMessage (char *text)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < GetMaxClients (); i++)
|
||||
for (i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || g_clients[i].team == m_team || g_clients[i].ent == GetEntity ())
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
if (i < GetMaxClients ())
|
||||
if (i < engine.MaxClients ())
|
||||
{
|
||||
talkEntity = g_clients[i].ent;
|
||||
ASSIGN_TALK_ENTITY ();
|
||||
}
|
||||
else // no teammates alive...
|
||||
{
|
||||
for (i = 0; i < GetMaxClients (); i++)
|
||||
for (i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (!(g_clients[i].flags & CF_USED) || g_clients[i].team == m_team || g_clients[i].ent == GetEntity ())
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
if (i < GetMaxClients ())
|
||||
if (i < engine.MaxClients ())
|
||||
{
|
||||
talkEntity = g_clients[i].ent;
|
||||
ASSIGN_TALK_ENTITY ();
|
||||
|
|
@ -290,14 +290,14 @@ void Bot::PrepareChatMessage (char *text)
|
|||
}
|
||||
else if (*pattern == 'd')
|
||||
{
|
||||
if (g_gameFlags == GAME_CZERO)
|
||||
if (g_gameFlags & GAME_CZERO)
|
||||
{
|
||||
if (Random.Long (1, 100) < 30)
|
||||
strcat (m_tempStrings, "CZ");
|
||||
else
|
||||
strcat (m_tempStrings, "Condition Zero");
|
||||
}
|
||||
else if (g_gameFlags == GAME_CSTRIKE16 || g_gameFlags == GAME_LEGACY)
|
||||
else if ((g_gameFlags & GAME_CSTRIKE16) || (g_gameFlags & GAME_LEGACY))
|
||||
{
|
||||
if (Random.Long (1, 100) < 30)
|
||||
strcat (m_tempStrings, "CS");
|
||||
|
|
@ -399,7 +399,7 @@ bool Bot::RepliesToPlayer (void)
|
|||
char text[256];
|
||||
|
||||
// check is time to chat is good
|
||||
if (m_sayTextBuffer.timeNextChat < GetWorldTime ())
|
||||
if (m_sayTextBuffer.timeNextChat < engine.Time ())
|
||||
{
|
||||
if (Random.Long (1, 100) < m_sayTextBuffer.chatProbability + Random.Long (2, 10) && ParseChat (reinterpret_cast <char *> (&text)))
|
||||
{
|
||||
|
|
@ -408,7 +408,7 @@ bool Bot::RepliesToPlayer (void)
|
|||
|
||||
m_sayTextBuffer.entityIndex = -1;
|
||||
m_sayTextBuffer.sayText[0] = 0x0;
|
||||
m_sayTextBuffer.timeNextChat = GetWorldTime () + m_sayTextBuffer.chatDelay;
|
||||
m_sayTextBuffer.timeNextChat = engine.Time () + m_sayTextBuffer.chatDelay;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -426,7 +426,7 @@ void Bot::SayText (const char *text)
|
|||
if (IsNullString (text))
|
||||
return;
|
||||
|
||||
FakeClientCommand (GetEntity (), "say \"%s\"", text);
|
||||
engine.IssueBotCommand (GetEntity (), "say \"%s\"", text);
|
||||
}
|
||||
|
||||
void Bot::TeamSayText (const char *text)
|
||||
|
|
@ -436,5 +436,5 @@ void Bot::TeamSayText (const char *text)
|
|||
if (IsNullString (text))
|
||||
return;
|
||||
|
||||
FakeClientCommand (GetEntity (), "say_team \"%s\"", text);
|
||||
engine.IssueBotCommand (GetEntity (), "say_team \"%s\"", text);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ int Bot::GetNearbyFriendsNearPosition(const Vector &origin, float radius)
|
|||
{
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || g_clients[i].team != m_team || g_clients[i].ent == GetEntity ())
|
||||
continue;
|
||||
|
|
@ -35,7 +35,7 @@ int Bot::GetNearbyEnemiesNearPosition(const Vector &origin, float radius)
|
|||
{
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || g_clients[i].team == m_team)
|
||||
continue;
|
||||
|
|
@ -48,7 +48,7 @@ int Bot::GetNearbyEnemiesNearPosition(const Vector &origin, float radius)
|
|||
|
||||
bool Bot::IsEnemyHiddenByRendering (edict_t *enemy)
|
||||
{
|
||||
if (IsEntityNull (enemy) || !yb_check_enemy_rendering.GetBool ())
|
||||
if (engine.IsNullEntity (enemy) || !yb_check_enemy_rendering.GetBool ())
|
||||
return false;
|
||||
|
||||
entvars_t &v = enemy->v;
|
||||
|
|
@ -107,7 +107,7 @@ bool Bot::CheckVisibility (edict_t *target, Vector *origin, byte *bodyPart)
|
|||
|
||||
*bodyPart = 0;
|
||||
|
||||
TraceLine (eyes, spot, true, true, pev->pContainingEntity, &result);
|
||||
engine.TestLine (eyes, spot, TRACE_IGNORE_EVERYTHING, pev->pContainingEntity, &result);
|
||||
|
||||
if (result.flFraction >= 1.0f)
|
||||
{
|
||||
|
|
@ -120,8 +120,7 @@ bool Bot::CheckVisibility (edict_t *target, Vector *origin, byte *bodyPart)
|
|||
|
||||
// check top of head
|
||||
spot = spot + Vector (0, 0, 25.0f);
|
||||
|
||||
TraceLine (eyes, spot, true, true, pev->pContainingEntity, &result);
|
||||
engine.TestLine (eyes, spot, TRACE_IGNORE_EVERYTHING, pev->pContainingEntity, &result);
|
||||
|
||||
if (result.flFraction >= 1.0f)
|
||||
{
|
||||
|
|
@ -143,7 +142,7 @@ bool Bot::CheckVisibility (edict_t *target, Vector *origin, byte *bodyPart)
|
|||
else
|
||||
spot.z = target->v.origin.z - standFeet;
|
||||
|
||||
TraceLine (eyes, spot, true, true, pev->pContainingEntity, &result);
|
||||
engine.TestLine (eyes, spot, TRACE_IGNORE_EVERYTHING, pev->pContainingEntity, &result);
|
||||
|
||||
if (result.flFraction >= 1.0f)
|
||||
{
|
||||
|
|
@ -159,7 +158,7 @@ bool Bot::CheckVisibility (edict_t *target, Vector *origin, byte *bodyPart)
|
|||
Vector perp (-dir.y, dir.x, 0.0f);
|
||||
spot = target->v.origin + Vector (perp.x * edgeOffset, perp.y * edgeOffset, 0);
|
||||
|
||||
TraceLine (eyes, spot, true, true, pev->pContainingEntity, &result);
|
||||
engine.TestLine (eyes, spot, TRACE_IGNORE_EVERYTHING, pev->pContainingEntity, &result);
|
||||
|
||||
if (result.flFraction >= 1.0f)
|
||||
{
|
||||
|
|
@ -170,7 +169,7 @@ bool Bot::CheckVisibility (edict_t *target, Vector *origin, byte *bodyPart)
|
|||
}
|
||||
spot = target->v.origin - Vector (perp.x * edgeOffset, perp.y * edgeOffset, 0);
|
||||
|
||||
TraceLine (eyes, spot, true, true, pev->pContainingEntity, &result);
|
||||
engine.TestLine (eyes, spot, TRACE_IGNORE_EVERYTHING, pev->pContainingEntity, &result);
|
||||
|
||||
if (result.flFraction >= 1.0f)
|
||||
{
|
||||
|
|
@ -184,17 +183,17 @@ bool Bot::CheckVisibility (edict_t *target, Vector *origin, byte *bodyPart)
|
|||
|
||||
bool Bot::IsEnemyViewable (edict_t *player)
|
||||
{
|
||||
if (IsEntityNull (player))
|
||||
if (engine.IsNullEntity (player))
|
||||
return false;
|
||||
|
||||
bool forceTrueIfVisible = false;
|
||||
|
||||
if (IsValidPlayer (pev->dmg_inflictor) && GetTeam (pev->dmg_inflictor) != m_team)
|
||||
if (IsValidPlayer (pev->dmg_inflictor) && engine.GetTeam (pev->dmg_inflictor) != m_team)
|
||||
forceTrueIfVisible = true;
|
||||
|
||||
if ((IsInViewCone (player->v.origin + pev->view_ofs) || forceTrueIfVisible) && CheckVisibility (player, &m_enemyOrigin, &m_visibility))
|
||||
{
|
||||
m_seeEnemyTime = GetWorldTime ();
|
||||
m_seeEnemyTime = engine.Time ();
|
||||
m_lastEnemy = player;
|
||||
m_lastEnemyOrigin = player->v.origin;
|
||||
|
||||
|
|
@ -208,7 +207,7 @@ bool Bot::LookupEnemy (void)
|
|||
// this function tries to find the best suitable enemy for the bot
|
||||
|
||||
// do not search for enemies while we're blinded, or shooting disabled by user
|
||||
if (m_enemyIgnoreTimer > GetWorldTime () || m_blindTime > GetWorldTime () || yb_ignore_enemies.GetBool ())
|
||||
if (m_enemyIgnoreTimer > engine.Time () || m_blindTime > engine.Time () || yb_ignore_enemies.GetBool ())
|
||||
return false;
|
||||
|
||||
edict_t *player, *newEnemy = NULL;
|
||||
|
|
@ -216,10 +215,10 @@ bool Bot::LookupEnemy (void)
|
|||
float nearestDistance = m_viewDistance;
|
||||
|
||||
// clear suspected flag
|
||||
if (m_seeEnemyTime + 3.0f < GetWorldTime ())
|
||||
if (m_seeEnemyTime + 3.0f < engine.Time ())
|
||||
m_states &= ~STATE_SUSPECT_ENEMY;
|
||||
|
||||
if (!IsEntityNull (m_enemy) && m_enemyUpdateTime > GetWorldTime ())
|
||||
if (!engine.IsNullEntity (m_enemy) && m_enemyUpdateTime > engine.Time ())
|
||||
{
|
||||
player = m_enemy;
|
||||
|
||||
|
|
@ -229,9 +228,9 @@ bool Bot::LookupEnemy (void)
|
|||
}
|
||||
|
||||
// the old enemy is no longer visible or
|
||||
if (IsEntityNull (newEnemy))
|
||||
if (engine.IsNullEntity (newEnemy))
|
||||
{
|
||||
m_enemyUpdateTime = GetWorldTime () + 0.5f;
|
||||
m_enemyUpdateTime = engine.Time () + 0.5f;
|
||||
|
||||
// ignore shielded enemies, while we have real one
|
||||
edict_t *shieldEnemy = NULL;
|
||||
|
|
@ -245,7 +244,7 @@ bool Bot::LookupEnemy (void)
|
|||
byte *pvs = ENGINE_SET_PVS (reinterpret_cast <float *> (&potentialVisibility));
|
||||
|
||||
// search the world for players...
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || g_clients[i].team == m_team || g_clients[i].ent == GetEntity ())
|
||||
continue;
|
||||
|
|
@ -257,19 +256,19 @@ bool Bot::LookupEnemy (void)
|
|||
continue;
|
||||
|
||||
// do some blind by smoke grenade
|
||||
if (m_blindRecognizeTime < GetWorldTime () && IsBehindSmokeClouds (player))
|
||||
if (m_blindRecognizeTime < engine.Time () && IsBehindSmokeClouds (player))
|
||||
{
|
||||
m_blindRecognizeTime = GetWorldTime () + Random.Float (1.0f, 2.0f);
|
||||
m_blindRecognizeTime = engine.Time () + Random.Float (1.0f, 2.0f);
|
||||
|
||||
if (Random.Long (0, 100) < 50)
|
||||
ChatterMessage (Chatter_BehindSmoke);
|
||||
}
|
||||
|
||||
if (player->v.button & (IN_ATTACK | IN_ATTACK2))
|
||||
m_blindRecognizeTime = GetWorldTime () - 0.1f;
|
||||
m_blindRecognizeTime = engine.Time () - 0.1f;
|
||||
|
||||
// see if bot can see the player...
|
||||
if (m_blindRecognizeTime < GetWorldTime () && IsEnemyViewable (player))
|
||||
if (m_blindRecognizeTime < engine.Time () && IsEnemyViewable (player))
|
||||
{
|
||||
if (IsEnemyProtectedByShield (player))
|
||||
{
|
||||
|
|
@ -290,7 +289,7 @@ bool Bot::LookupEnemy (void)
|
|||
}
|
||||
}
|
||||
|
||||
if (IsEntityNull (newEnemy) && !IsEntityNull (shieldEnemy))
|
||||
if (engine.IsNullEntity (newEnemy) && !engine.IsNullEntity (shieldEnemy))
|
||||
newEnemy = shieldEnemy;
|
||||
}
|
||||
|
||||
|
|
@ -304,7 +303,7 @@ bool Bot::LookupEnemy (void)
|
|||
if (newEnemy == m_enemy)
|
||||
{
|
||||
// if enemy is still visible and in field of view, keep it keep track of when we last saw an enemy
|
||||
m_seeEnemyTime = GetWorldTime ();
|
||||
m_seeEnemyTime = engine.Time ();
|
||||
|
||||
// zero out reaction time
|
||||
m_actualReactionTime = 0.0f;
|
||||
|
|
@ -315,15 +314,15 @@ bool Bot::LookupEnemy (void)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (m_seeEnemyTime + 3.0 < GetWorldTime () && (m_hasC4 || HasHostage () || !IsEntityNull (m_targetEntity)))
|
||||
if (m_seeEnemyTime + 3.0 < engine.Time () && (m_hasC4 || HasHostage () || !engine.IsNullEntity (m_targetEntity)))
|
||||
RadioMessage (Radio_EnemySpotted);
|
||||
|
||||
m_targetEntity = NULL; // stop following when we see an enemy...
|
||||
|
||||
if (Random.Long (0, 100) < m_difficulty * 25)
|
||||
m_enemySurpriseTime = GetWorldTime () + m_actualReactionTime * 0.5f;
|
||||
m_enemySurpriseTime = engine.Time () + m_actualReactionTime * 0.5f;
|
||||
else
|
||||
m_enemySurpriseTime = GetWorldTime () + m_actualReactionTime;
|
||||
m_enemySurpriseTime = engine.Time () + m_actualReactionTime;
|
||||
|
||||
// zero out reaction time
|
||||
m_actualReactionTime = 0.0f;
|
||||
|
|
@ -333,24 +332,24 @@ bool Bot::LookupEnemy (void)
|
|||
m_enemyReachableTimer = 0.0f;
|
||||
|
||||
// keep track of when we last saw an enemy
|
||||
m_seeEnemyTime = GetWorldTime ();
|
||||
m_seeEnemyTime = engine.Time ();
|
||||
|
||||
if (!(pev->oldbuttons & IN_ATTACK))
|
||||
return true;
|
||||
|
||||
// now alarm all teammates who see this bot & don't have an actual enemy of the bots enemy should simulate human players seeing a teammate firing
|
||||
for (int j = 0; j < GetMaxClients (); j++)
|
||||
for (int j = 0; j < engine.MaxClients (); j++)
|
||||
{
|
||||
if (!(g_clients[j].flags & CF_USED) || !(g_clients[j].flags & CF_ALIVE) || g_clients[j].team != m_team || g_clients[j].ent == GetEntity ())
|
||||
continue;
|
||||
|
||||
Bot *friendBot = bots.GetBot (g_clients[j].ent);
|
||||
|
||||
if (friendBot != NULL && friendBot->m_seeEnemyTime + 2.0f < GetWorldTime () && IsEntityNull (friendBot->m_lastEnemy) && IsVisible (pev->origin, ENT (friendBot->pev)) && friendBot->IsInViewCone (pev->origin))
|
||||
if (friendBot != NULL && friendBot->m_seeEnemyTime + 2.0f < engine.Time () && engine.IsNullEntity (friendBot->m_lastEnemy) && IsVisible (pev->origin, friendBot->GetEntity ()) && friendBot->IsInViewCone (pev->origin))
|
||||
{
|
||||
friendBot->m_lastEnemy = newEnemy;
|
||||
friendBot->m_lastEnemyOrigin = m_lastEnemyOrigin;
|
||||
friendBot->m_seeEnemyTime = GetWorldTime ();
|
||||
friendBot->m_seeEnemyTime = engine.Time ();
|
||||
friendBot->m_states |= (STATE_SUSPECT_ENEMY | STATE_HEARING_ENEMY);
|
||||
friendBot->m_aimFlags |= AIM_LAST_ENEMY;
|
||||
}
|
||||
|
|
@ -358,7 +357,7 @@ bool Bot::LookupEnemy (void)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
else if (!IsEntityNull (m_enemy))
|
||||
else if (!engine.IsNullEntity (m_enemy))
|
||||
{
|
||||
newEnemy = m_enemy;
|
||||
m_lastEnemy = newEnemy;
|
||||
|
|
@ -368,11 +367,11 @@ bool Bot::LookupEnemy (void)
|
|||
m_enemy = NULL;
|
||||
|
||||
// shoot at dying players if no new enemy to give some more human-like illusion
|
||||
if (m_seeEnemyTime + 0.1f > GetWorldTime ())
|
||||
if (m_seeEnemyTime + 0.1f > engine.Time ())
|
||||
{
|
||||
if (!UsesSniper ())
|
||||
{
|
||||
m_shootAtDeadTime = GetWorldTime () + 0.4f;
|
||||
m_shootAtDeadTime = engine.Time () + 0.4f;
|
||||
m_actualReactionTime = 0.0f;
|
||||
m_states |= STATE_SUSPECT_ENEMY;
|
||||
|
||||
|
|
@ -380,7 +379,7 @@ bool Bot::LookupEnemy (void)
|
|||
}
|
||||
return false;
|
||||
}
|
||||
else if (m_shootAtDeadTime > GetWorldTime ())
|
||||
else if (m_shootAtDeadTime > engine.Time ())
|
||||
{
|
||||
m_actualReactionTime = 0.0f;
|
||||
m_states |= STATE_SUSPECT_ENEMY;
|
||||
|
|
@ -393,7 +392,7 @@ bool Bot::LookupEnemy (void)
|
|||
// if no enemy visible check if last one shoot able through wall
|
||||
if (yb_shoots_thru_walls.GetBool () && m_difficulty >= 2 && IsShootableThruObstacle (newEnemy->v.origin))
|
||||
{
|
||||
m_seeEnemyTime = GetWorldTime ();
|
||||
m_seeEnemyTime = engine.Time ();
|
||||
|
||||
m_states |= STATE_SUSPECT_ENEMY;
|
||||
m_aimFlags |= AIM_LAST_ENEMY;
|
||||
|
|
@ -407,14 +406,14 @@ bool Bot::LookupEnemy (void)
|
|||
}
|
||||
|
||||
// check if bots should reload...
|
||||
if ((m_aimFlags <= AIM_PREDICT_PATH && m_seeEnemyTime + 3.0f < GetWorldTime () && !(m_states & (STATE_SEEING_ENEMY | STATE_HEARING_ENEMY)) && IsEntityNull (m_lastEnemy) && IsEntityNull (m_enemy) && GetTaskId () != TASK_SHOOTBREAKABLE && GetTaskId () != TASK_PLANTBOMB && GetTaskId () != TASK_DEFUSEBOMB) || g_roundEnded)
|
||||
if ((m_aimFlags <= AIM_PREDICT_PATH && m_seeEnemyTime + 3.0f < engine.Time () && !(m_states & (STATE_SEEING_ENEMY | STATE_HEARING_ENEMY)) && engine.IsNullEntity (m_lastEnemy) && engine.IsNullEntity (m_enemy) && GetTaskId () != TASK_SHOOTBREAKABLE && GetTaskId () != TASK_PLANTBOMB && GetTaskId () != TASK_DEFUSEBOMB) || g_roundEnded)
|
||||
{
|
||||
if (!m_reloadState)
|
||||
m_reloadState = RELOAD_PRIMARY;
|
||||
}
|
||||
|
||||
// is the bot using a sniper rifle or a zoomable rifle?
|
||||
if ((UsesSniper () || UsesZoomableRifle ()) && m_zoomCheckTime + 1.0f < GetWorldTime ())
|
||||
if ((UsesSniper () || UsesZoomableRifle ()) && m_zoomCheckTime + 1.0f < engine.Time ())
|
||||
{
|
||||
if (pev->fov < 90.0f) // let the bot zoom out
|
||||
pev->button |= IN_ATTACK2;
|
||||
|
|
@ -558,20 +557,20 @@ bool Bot::IsFriendInLineOfFire (float distance)
|
|||
MakeVectors (pev->v_angle);
|
||||
|
||||
TraceResult tr;
|
||||
TraceLine (EyePosition (), EyePosition () + 10000.0f * pev->v_angle, false, false, GetEntity (), &tr);
|
||||
engine.TestLine (EyePosition (), EyePosition () + 10000.0f * pev->v_angle, TRACE_IGNORE_NONE, GetEntity (), &tr);
|
||||
|
||||
// check if we hit something
|
||||
if (!IsEntityNull (tr.pHit) && tr.pHit != g_worldEntity)
|
||||
if (!engine.IsNullEntity (tr.pHit))
|
||||
{
|
||||
int playerIndex = IndexOfEntity (tr.pHit) - 1;
|
||||
int playerIndex = engine.IndexOfEntity (tr.pHit) - 1;
|
||||
|
||||
// check valid range
|
||||
if (playerIndex >= 0 && playerIndex < GetMaxClients () && g_clients[playerIndex].team == m_team && (g_clients[playerIndex].flags & CF_ALIVE))
|
||||
if (playerIndex >= 0 && playerIndex < engine.MaxClients () && g_clients[playerIndex].team == m_team && (g_clients[playerIndex].flags & CF_ALIVE))
|
||||
return true;
|
||||
}
|
||||
|
||||
// search the world for players
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || g_clients[i].team != m_team || g_clients[i].ent == GetEntity ())
|
||||
continue;
|
||||
|
|
@ -606,12 +605,12 @@ bool Bot::IsShootableThruObstacle (const Vector &dest)
|
|||
TraceResult tr;
|
||||
|
||||
float obstacleDistance = 0.0f;
|
||||
TraceLine (EyePosition (), dest, true, GetEntity (), &tr);
|
||||
engine.TestLine (EyePosition (), dest, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
if (tr.fStartSolid)
|
||||
{
|
||||
const Vector &source = tr.vecEndPos;
|
||||
TraceLine (dest, source, true, GetEntity (), &tr);
|
||||
engine.TestLine (dest, source, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
if (tr.flFraction != 1.0f)
|
||||
{
|
||||
|
|
@ -657,7 +656,7 @@ bool Bot::IsShootableThruObstacleEx (const Vector &dest)
|
|||
int numHits = 0;
|
||||
|
||||
TraceResult tr;
|
||||
TraceLine (source, dest, true, true, GetEntity (), &tr);
|
||||
engine.TestLine (source, dest, TRACE_IGNORE_EVERYTHING, GetEntity (), &tr);
|
||||
|
||||
while (tr.flFraction != 1.0f && numHits < 3)
|
||||
{
|
||||
|
|
@ -671,7 +670,7 @@ bool Bot::IsShootableThruObstacleEx (const Vector &dest)
|
|||
point = point + direction;
|
||||
thikness++;
|
||||
}
|
||||
TraceLine (point, dest, true, true, GetEntity (), &tr);
|
||||
engine.TestLine (point, dest, TRACE_IGNORE_EVERYTHING, GetEntity (), &tr);
|
||||
}
|
||||
|
||||
if (numHits < 3 && thikness < 98)
|
||||
|
|
@ -686,7 +685,7 @@ bool Bot::DoFirePause (float distance)
|
|||
{
|
||||
// returns true if bot needs to pause between firing to compensate for punchangle & weapon spread
|
||||
|
||||
if (m_firePause > GetWorldTime ())
|
||||
if (m_firePause > engine.Time ())
|
||||
return true;
|
||||
|
||||
if ((m_aimFlags & AIM_ENEMY) && !m_enemyOrigin.IsZero ())
|
||||
|
|
@ -711,8 +710,8 @@ bool Bot::DoFirePause (float distance)
|
|||
// check if we need to compensate recoil
|
||||
if (tanf (sqrtf (fabsf (xPunch * xPunch) + fabsf (yPunch * yPunch))) * distance > offset + 30.0f + ((100 - (m_difficulty * 25)) / 100.f))
|
||||
{
|
||||
if (m_firePause < GetWorldTime () - 0.4f)
|
||||
m_firePause = GetWorldTime () + Random.Float (0.4f, 0.4f + 0.3f * ((100 - (m_difficulty * 25)) / 100.f));
|
||||
if (m_firePause < engine.Time () - 0.4f)
|
||||
m_firePause = engine.Time () + Random.Float (0.4f, 0.4f + 0.3f * ((100 - (m_difficulty * 25)) / 100.f));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -727,22 +726,22 @@ void Bot::FireWeapon (void)
|
|||
// if using grenade stop this
|
||||
if (m_isUsingGrenade)
|
||||
{
|
||||
m_shootTime = GetWorldTime () + 0.1f;
|
||||
m_shootTime = engine.Time () + 0.1f;
|
||||
return;
|
||||
}
|
||||
|
||||
// or if friend in line of fire, stop this too but do not update shoot time
|
||||
if (!IsEntityNull (m_enemy))
|
||||
if (!engine.IsNullEntity (m_enemy))
|
||||
{
|
||||
if (IsFriendInLineOfFire (distance))
|
||||
{
|
||||
m_fightStyle = 0;
|
||||
m_lastFightStyleCheck = GetWorldTime ();
|
||||
m_fightStyle = FIGHT_STRAFE;
|
||||
m_lastFightStyleCheck = engine.Time ();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
WeaponSelect *selectTab = &g_weaponSelect[0];
|
||||
WeaponSelect *tab = &g_weaponSelect[0];
|
||||
|
||||
edict_t *enemy = m_enemy;
|
||||
|
||||
|
|
@ -754,22 +753,22 @@ void Bot::FireWeapon (void)
|
|||
goto WeaponSelectEnd;
|
||||
|
||||
// use knife if near and good difficulty (l33t dude!)
|
||||
if (m_difficulty >= 3 && pev->health > 80.0f && !IsEntityNull (enemy) && pev->health >= enemy->v.health && distance < 100.0f && !IsOnLadder () && !IsGroupOfEnemies (pev->origin))
|
||||
if (m_difficulty >= 3 && pev->health > 80.0f && !engine.IsNullEntity (enemy) && pev->health >= enemy->v.health && distance < 100.0f && !IsOnLadder () && !IsGroupOfEnemies (pev->origin))
|
||||
goto WeaponSelectEnd;
|
||||
|
||||
// loop through all the weapons until terminator is found...
|
||||
while (selectTab[selectIndex].id)
|
||||
while (tab[selectIndex].id)
|
||||
{
|
||||
// is the bot carrying this weapon?
|
||||
if (weapons & (1 << selectTab[selectIndex].id))
|
||||
if (weapons & (1 << tab[selectIndex].id))
|
||||
{
|
||||
// is enough ammo available to fire AND check is better to use pistol in our current situation...
|
||||
if (m_ammoInClip[selectTab[selectIndex].id] > 0 && !IsWeaponBadInDistance (selectIndex, distance))
|
||||
if (m_ammoInClip[tab[selectIndex].id] > 0 && !IsWeaponBadInDistance (selectIndex, distance))
|
||||
chosenWeaponIndex = selectIndex;
|
||||
}
|
||||
selectIndex++;
|
||||
}
|
||||
selectId = selectTab[chosenWeaponIndex].id;
|
||||
selectId = tab[chosenWeaponIndex].id;
|
||||
|
||||
// if no available weapon...
|
||||
if (chosenWeaponIndex == 0)
|
||||
|
|
@ -777,21 +776,21 @@ void Bot::FireWeapon (void)
|
|||
selectIndex = 0;
|
||||
|
||||
// loop through all the weapons until terminator is found...
|
||||
while (selectTab[selectIndex].id)
|
||||
while (tab[selectIndex].id)
|
||||
{
|
||||
int id = selectTab[selectIndex].id;
|
||||
int id = tab[selectIndex].id;
|
||||
|
||||
// is the bot carrying this weapon?
|
||||
if (weapons & (1 << id))
|
||||
{
|
||||
if ( g_weaponDefs[id].ammo1 != -1 && g_weaponDefs[id].ammo1 < 32 && m_ammo[g_weaponDefs[id].ammo1] >= selectTab[selectIndex].minPrimaryAmmo)
|
||||
if ( g_weaponDefs[id].ammo1 != -1 && g_weaponDefs[id].ammo1 < 32 && m_ammo[g_weaponDefs[id].ammo1] >= tab[selectIndex].minPrimaryAmmo)
|
||||
{
|
||||
// available ammo found, reload weapon
|
||||
if (m_reloadState == RELOAD_NONE || m_reloadCheckTime > GetWorldTime ())
|
||||
if (m_reloadState == RELOAD_NONE || m_reloadCheckTime > engine.Time ())
|
||||
{
|
||||
m_isReloading = true;
|
||||
m_reloadState = RELOAD_PRIMARY;
|
||||
m_reloadCheckTime = GetWorldTime ();
|
||||
m_reloadCheckTime = engine.Time ();
|
||||
|
||||
RadioMessage (Radio_NeedBackup);
|
||||
}
|
||||
|
|
@ -809,7 +808,7 @@ WeaponSelectEnd:
|
|||
if (!m_isReloading)
|
||||
{
|
||||
m_reloadState = RELOAD_NONE;
|
||||
m_reloadCheckTime = GetWorldTime () + 3.0f;
|
||||
m_reloadCheckTime = engine.Time () + 3.0f;
|
||||
}
|
||||
|
||||
// select this weapon if it isn't already selected
|
||||
|
|
@ -824,14 +823,14 @@ WeaponSelectEnd:
|
|||
return;
|
||||
}
|
||||
|
||||
if (selectTab[chosenWeaponIndex].id != selectId)
|
||||
if (tab[chosenWeaponIndex].id != selectId)
|
||||
{
|
||||
chosenWeaponIndex = 0;
|
||||
|
||||
// loop through all the weapons until terminator is found...
|
||||
while (selectTab[chosenWeaponIndex].id)
|
||||
while (tab[chosenWeaponIndex].id)
|
||||
{
|
||||
if (selectTab[chosenWeaponIndex].id == selectId)
|
||||
if (tab[chosenWeaponIndex].id == selectId)
|
||||
break;
|
||||
|
||||
chosenWeaponIndex++;
|
||||
|
|
@ -841,17 +840,17 @@ WeaponSelectEnd:
|
|||
// if we're have a glock or famas vary burst fire mode
|
||||
CheckBurstMode (distance);
|
||||
|
||||
if (HasShield () && m_shieldCheckTime < GetWorldTime () && GetTaskId () != TASK_CAMP) // better shield gun usage
|
||||
if (HasShield () && m_shieldCheckTime < engine.Time () && GetTaskId () != TASK_CAMP) // better shield gun usage
|
||||
{
|
||||
if (distance >= 750.0f && !IsShieldDrawn ())
|
||||
pev->button |= IN_ATTACK2; // draw the shield
|
||||
else if (IsShieldDrawn () || (!IsEntityNull (m_enemy) && ((m_enemy->v.button & IN_RELOAD) || !IsEnemyViewable(m_enemy))))
|
||||
else if (IsShieldDrawn () || (!engine.IsNullEntity (m_enemy) && ((m_enemy->v.button & IN_RELOAD) || !IsEnemyViewable(m_enemy))))
|
||||
pev->button |= IN_ATTACK2; // draw out the shield
|
||||
|
||||
m_shieldCheckTime = GetWorldTime () + 1.0f;
|
||||
m_shieldCheckTime = engine.Time () + 1.0f;
|
||||
}
|
||||
|
||||
if (UsesSniper () && m_zoomCheckTime + 1.0f < GetWorldTime ()) // is the bot holding a sniper rifle?
|
||||
if (UsesSniper () && m_zoomCheckTime + 1.0f < engine.Time ()) // is the bot holding a sniper rifle?
|
||||
{
|
||||
if (distance > 1500.0f && pev->fov >= 40.0f) // should the bot switch to the long-range zoom?
|
||||
pev->button |= IN_ATTACK2;
|
||||
|
|
@ -862,13 +861,13 @@ WeaponSelectEnd:
|
|||
else if (distance <= 150.0f && pev->fov < 90.0f) // else should the bot restore the normal view ?
|
||||
pev->button |= IN_ATTACK2;
|
||||
|
||||
m_zoomCheckTime = GetWorldTime ();
|
||||
m_zoomCheckTime = engine.Time ();
|
||||
|
||||
if (!IsEntityNull (m_enemy) && (m_states & STATE_SEEING_ENEMY))
|
||||
if (!engine.IsNullEntity (m_enemy) && (m_states & STATE_SEEING_ENEMY))
|
||||
{
|
||||
m_moveSpeed = 0.0f;
|
||||
m_strafeSpeed = 0.0f;
|
||||
m_navTimeset = GetWorldTime ();
|
||||
m_navTimeset = engine.Time ();
|
||||
}
|
||||
}
|
||||
else if (m_difficulty < 4 && UsesZoomableRifle ()) // else is the bot holding a zoomable rifle?
|
||||
|
|
@ -879,11 +878,11 @@ WeaponSelectEnd:
|
|||
else if (distance <= 800.0f && pev->fov < 90.0f) // else should the bot restore the normal view?
|
||||
pev->button |= IN_ATTACK2;
|
||||
|
||||
m_zoomCheckTime = GetWorldTime ();
|
||||
m_zoomCheckTime = engine.Time ();
|
||||
}
|
||||
|
||||
// need to care for burst fire?
|
||||
if (distance < 256.0f || m_blindTime > GetWorldTime ())
|
||||
if (distance < 256.0f || m_blindTime > engine.Time ())
|
||||
{
|
||||
if (selectId == WEAPON_KNIFE)
|
||||
{
|
||||
|
|
@ -897,7 +896,7 @@ WeaponSelectEnd:
|
|||
}
|
||||
else
|
||||
{
|
||||
if (selectTab[chosenWeaponIndex].primaryFireHold && m_ammo[g_weaponDefs[selectTab[selectIndex].id].ammo1] > selectTab[selectIndex].minPrimaryAmmo) // if automatic weapon, just press attack
|
||||
if (tab[chosenWeaponIndex].primaryFireHold && m_ammo[g_weaponDefs[tab[selectIndex].id].ammo1] > tab[selectIndex].minPrimaryAmmo) // if automatic weapon, just press attack
|
||||
pev->button |= IN_ATTACK;
|
||||
else // if not, toggle buttons
|
||||
{
|
||||
|
|
@ -905,7 +904,7 @@ WeaponSelectEnd:
|
|||
pev->button |= IN_ATTACK;
|
||||
}
|
||||
}
|
||||
m_shootTime = GetWorldTime ();
|
||||
m_shootTime = engine.Time ();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -915,14 +914,14 @@ WeaponSelectEnd:
|
|||
// don't attack with knife over long distance
|
||||
if (selectId == WEAPON_KNIFE)
|
||||
{
|
||||
m_shootTime = GetWorldTime ();
|
||||
m_shootTime = engine.Time ();
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectTab[chosenWeaponIndex].primaryFireHold)
|
||||
if (tab[chosenWeaponIndex].primaryFireHold)
|
||||
{
|
||||
m_shootTime = GetWorldTime ();
|
||||
m_zoomCheckTime = GetWorldTime ();
|
||||
m_shootTime = engine.Time ();
|
||||
m_zoomCheckTime = engine.Time ();
|
||||
|
||||
pev->button |= IN_ATTACK; // use primary attack
|
||||
}
|
||||
|
|
@ -930,8 +929,8 @@ WeaponSelectEnd:
|
|||
{
|
||||
pev->button |= IN_ATTACK;
|
||||
|
||||
m_shootTime = GetWorldTime () + Random.Float (0.15f, 0.35f);
|
||||
m_zoomCheckTime = GetWorldTime () - 0.09f;
|
||||
m_shootTime = engine.Time () + Random.Float (0.15f, 0.35f);
|
||||
m_zoomCheckTime = engine.Time () - 0.09f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -944,9 +943,9 @@ bool Bot::IsWeaponBadInDistance (int weaponIndex, float distance)
|
|||
if (m_difficulty < 2)
|
||||
return false;
|
||||
|
||||
int weaponID = g_weaponSelect[weaponIndex].id;
|
||||
int wid = g_weaponSelect[weaponIndex].id;
|
||||
|
||||
if (weaponID == WEAPON_KNIFE)
|
||||
if (wid == WEAPON_KNIFE)
|
||||
return false;
|
||||
|
||||
// check is ammo available for secondary weapon
|
||||
|
|
@ -954,11 +953,11 @@ bool Bot::IsWeaponBadInDistance (int weaponIndex, float distance)
|
|||
return false;
|
||||
|
||||
// better use pistol in short range distances, when using sniper weapons
|
||||
if ((weaponID == WEAPON_SCOUT || weaponID == WEAPON_AWP || weaponID == WEAPON_G3SG1 || weaponID == WEAPON_SG550) && distance < 500.0f)
|
||||
if ((wid == WEAPON_SCOUT || wid == WEAPON_AWP || wid == WEAPON_G3SG1 || wid == WEAPON_SG550) && distance < 500.0f)
|
||||
return true;
|
||||
|
||||
// shotguns is too inaccurate at long distances, so weapon is bad
|
||||
if ((weaponID == WEAPON_M3 || weaponID == WEAPON_XM1014) && distance > 750.0f)
|
||||
if ((wid == WEAPON_M3 || wid == WEAPON_XM1014) && distance > 750.0f)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
@ -969,7 +968,7 @@ void Bot::FocusEnemy (void)
|
|||
// aim for the head and/or body
|
||||
m_lookAt = GetAimPosition ();
|
||||
|
||||
if (m_enemySurpriseTime > GetWorldTime ())
|
||||
if (m_enemySurpriseTime > engine.Time ())
|
||||
return;
|
||||
|
||||
float distance = (m_lookAt - EyePosition ()).GetLength2D (); // how far away is the enemy scum?
|
||||
|
|
@ -1012,18 +1011,18 @@ void Bot::FocusEnemy (void)
|
|||
void Bot::CombatFight (void)
|
||||
{
|
||||
// no enemy? no need to do strafing
|
||||
if (IsEntityNull (m_enemy))
|
||||
if (engine.IsNullEntity (m_enemy))
|
||||
return;
|
||||
|
||||
float distance = (m_lookAt - EyePosition ()).GetLength2D (); // how far away is the enemy scum?
|
||||
|
||||
if (m_timeWaypointMove < GetWorldTime ())
|
||||
if (m_timeWaypointMove < engine.Time ())
|
||||
{
|
||||
int approach;
|
||||
|
||||
if (m_currentWeapon == WEAPON_KNIFE) // knife?
|
||||
approach = 100;
|
||||
if ((m_states & STATE_SUSPECT_ENEMY) && !(m_states & STATE_SEEING_ENEMY)) // if suspecting enemy stand still
|
||||
else if ((m_states & STATE_SUSPECT_ENEMY) && !(m_states & STATE_SEEING_ENEMY)) // if suspecting enemy stand still
|
||||
approach = 49;
|
||||
else if (m_isReloading || m_isVIP) // if reloading or vip back off
|
||||
approach = 29;
|
||||
|
|
@ -1056,50 +1055,50 @@ void Bot::CombatFight (void)
|
|||
|
||||
if (UsesSniper ())
|
||||
{
|
||||
m_fightStyle = 1;
|
||||
m_lastFightStyleCheck = GetWorldTime ();
|
||||
m_fightStyle = FIGHT_STAY;
|
||||
m_lastFightStyleCheck = engine.Time ();
|
||||
}
|
||||
else if (UsesRifle () || UsesSubmachineGun ())
|
||||
{
|
||||
if (m_lastFightStyleCheck + 3.0f < GetWorldTime ())
|
||||
if (m_lastFightStyleCheck + 3.0f < engine.Time ())
|
||||
{
|
||||
int rand = Random.Long (1, 100);
|
||||
|
||||
if (distance < 450.0f)
|
||||
m_fightStyle = 0;
|
||||
m_fightStyle = FIGHT_STRAFE;
|
||||
else if (distance < 1024.0f)
|
||||
{
|
||||
if (rand < (UsesSubmachineGun () ? 50 : 30))
|
||||
m_fightStyle = 0;
|
||||
m_fightStyle = FIGHT_STRAFE;
|
||||
else
|
||||
m_fightStyle = 1;
|
||||
m_fightStyle = FIGHT_STAY;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rand < (UsesSubmachineGun () ? 80 : 93))
|
||||
m_fightStyle = 1;
|
||||
m_fightStyle = FIGHT_STAY;
|
||||
else
|
||||
m_fightStyle = 0;
|
||||
m_fightStyle = FIGHT_STRAFE;
|
||||
}
|
||||
m_lastFightStyleCheck = GetWorldTime ();
|
||||
m_lastFightStyleCheck = engine.Time ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_lastFightStyleCheck + 3.0f < GetWorldTime ())
|
||||
if (m_lastFightStyleCheck + 3.0f < engine.Time ())
|
||||
{
|
||||
if (Random.Long (0, 100) < 50)
|
||||
m_fightStyle = 1;
|
||||
m_fightStyle = FIGHT_STRAFE;
|
||||
else
|
||||
m_fightStyle = 0;
|
||||
m_fightStyle = FIGHT_STAY;
|
||||
|
||||
m_lastFightStyleCheck = GetWorldTime ();
|
||||
m_lastFightStyleCheck = engine.Time ();
|
||||
}
|
||||
}
|
||||
|
||||
if (m_fightStyle == 0 || ((pev->button & IN_RELOAD) || m_isReloading) || (UsesPistol () && distance < 400.0f) || m_currentWeapon == WEAPON_KNIFE)
|
||||
if (m_fightStyle == FIGHT_STRAFE || ((pev->button & IN_RELOAD) || m_isReloading) || (UsesPistol () && distance < 400.0f) || m_currentWeapon == WEAPON_KNIFE)
|
||||
{
|
||||
if (m_strafeSetTime < GetWorldTime ())
|
||||
if (m_strafeSetTime < engine.Time ())
|
||||
{
|
||||
// to start strafing, we have to first figure out if the target is on the left side or right side
|
||||
MakeVectors (m_enemy->v.v_angle);
|
||||
|
|
@ -1108,24 +1107,24 @@ void Bot::CombatFight (void)
|
|||
const Vector &rightSide = g_pGlobals->v_right.Normalize2D ();
|
||||
|
||||
if ((dirToPoint | rightSide) < 0)
|
||||
m_combatStrafeDir = 1;
|
||||
m_combatStrafeDir = STRAFE_DIR_LEFT;
|
||||
else
|
||||
m_combatStrafeDir = 0;
|
||||
m_combatStrafeDir = STRAFE_DIR_RIGHT;
|
||||
|
||||
if (Random.Long (1, 100) < 30)
|
||||
m_combatStrafeDir ^= 1;
|
||||
m_combatStrafeDir = (m_combatStrafeDir == STRAFE_DIR_LEFT ? STRAFE_DIR_RIGHT : STRAFE_DIR_LEFT);
|
||||
|
||||
m_strafeSetTime = GetWorldTime () + Random.Float (0.5f, 3.0f);
|
||||
m_strafeSetTime = engine.Time () + Random.Float (0.5f, 3.0f);
|
||||
}
|
||||
|
||||
if (m_combatStrafeDir == 0)
|
||||
if (m_combatStrafeDir == STRAFE_DIR_RIGHT)
|
||||
{
|
||||
if (!CheckWallOnLeft ())
|
||||
m_strafeSpeed = -pev->maxspeed;
|
||||
else
|
||||
{
|
||||
m_combatStrafeDir ^= 1;
|
||||
m_strafeSetTime = GetWorldTime () + 1.0f;
|
||||
m_combatStrafeDir = STRAFE_DIR_LEFT;
|
||||
m_strafeSetTime = engine.Time () + 1.5f;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -1134,12 +1133,12 @@ void Bot::CombatFight (void)
|
|||
m_strafeSpeed = pev->maxspeed;
|
||||
else
|
||||
{
|
||||
m_combatStrafeDir ^= 1;
|
||||
m_strafeSetTime = GetWorldTime () + 1.0f;
|
||||
m_combatStrafeDir = STRAFE_DIR_RIGHT;
|
||||
m_strafeSetTime = engine.Time () + 1.5f;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_difficulty >= 3 && (m_jumpTime + 5.0f < GetWorldTime () && IsOnFloor () && Random.Long (0, 1000) < (m_isReloading ? 8 : 2) && pev->velocity.GetLength2D () > 150.0f) && !UsesSniper ())
|
||||
if (m_difficulty >= 3 && (m_jumpTime + 5.0f < engine.Time () && IsOnFloor () && Random.Long (0, 1000) < (m_isReloading ? 8 : 2) && pev->velocity.GetLength2D () > 150.0f) && !UsesSniper ())
|
||||
pev->button |= IN_JUMP;
|
||||
|
||||
if (m_moveSpeed > 0.0f && distance > 100.0f && m_currentWeapon != WEAPON_KNIFE)
|
||||
|
|
@ -1148,18 +1147,18 @@ void Bot::CombatFight (void)
|
|||
if (m_currentWeapon == WEAPON_KNIFE)
|
||||
m_strafeSpeed = 0.0f;
|
||||
}
|
||||
else if (m_fightStyle == 1)
|
||||
else if (m_fightStyle == FIGHT_STAY)
|
||||
{
|
||||
if (!(m_visibility & (VISIBLE_HEAD | VISIBLE_BODY)) && GetTaskId () != TASK_SEEKCOVER && GetTaskId () != TASK_HUNTENEMY && (m_visibility & VISIBLE_BODY) && !(m_visibility & VISIBLE_OTHER) && waypoints.IsDuckVisible (m_currentWaypointIndex, waypoints.FindNearest (m_enemy->v.origin)))
|
||||
m_duckTime = GetWorldTime () + 0.5f;
|
||||
if ((m_visibility & (VISIBLE_HEAD | VISIBLE_BODY)) && GetTaskId () != TASK_SEEKCOVER && GetTaskId () != TASK_HUNTENEMY && waypoints.IsDuckVisible (m_currentWaypointIndex, waypoints.FindNearest (m_enemy->v.origin)))
|
||||
m_duckTime = engine.Time () + 0.5f;
|
||||
|
||||
m_moveSpeed = 0.0f;
|
||||
m_strafeSpeed = 0.0f;
|
||||
m_navTimeset = GetWorldTime ();
|
||||
m_navTimeset = engine.Time ();
|
||||
}
|
||||
}
|
||||
|
||||
if (m_duckTime > GetWorldTime ())
|
||||
if (m_duckTime > engine.Time ())
|
||||
{
|
||||
m_moveSpeed = 0.0f;
|
||||
m_strafeSpeed = 0.0f;
|
||||
|
|
@ -1171,7 +1170,7 @@ void Bot::CombatFight (void)
|
|||
if (m_isReloading)
|
||||
{
|
||||
m_moveSpeed = -pev->maxspeed;
|
||||
m_duckTime = GetWorldTime () - 1.0f;
|
||||
m_duckTime = engine.Time () - 1.0f;
|
||||
}
|
||||
|
||||
if (!IsInWater () && !IsOnLadder () && (m_moveSpeed > 0.0f || m_strafeSpeed >= 0.0f))
|
||||
|
|
@ -1224,7 +1223,7 @@ bool Bot::IsEnemyProtectedByShield (edict_t *enemy)
|
|||
{
|
||||
// this function returns true, if enemy protected by the shield
|
||||
|
||||
if (IsEntityNull (enemy) || IsShieldDrawn ())
|
||||
if (engine.IsNullEntity (enemy) || IsShieldDrawn ())
|
||||
return false;
|
||||
|
||||
// check if enemy has shield and this shield is drawn
|
||||
|
|
@ -1245,19 +1244,19 @@ bool Bot::UsesSniper (void)
|
|||
|
||||
bool Bot::UsesRifle (void)
|
||||
{
|
||||
WeaponSelect *selectTab = &g_weaponSelect[0];
|
||||
WeaponSelect *tab = &g_weaponSelect[0];
|
||||
int count = 0;
|
||||
|
||||
while (selectTab->id)
|
||||
while (tab->id)
|
||||
{
|
||||
if (m_currentWeapon == selectTab->id)
|
||||
if (m_currentWeapon == tab->id)
|
||||
break;
|
||||
|
||||
selectTab++;
|
||||
tab++;
|
||||
count++;
|
||||
}
|
||||
|
||||
if (selectTab->id && count > 13)
|
||||
if (tab->id && count > 13)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
@ -1265,20 +1264,20 @@ bool Bot::UsesRifle (void)
|
|||
|
||||
bool Bot::UsesPistol (void)
|
||||
{
|
||||
WeaponSelect *selectTab = &g_weaponSelect[0];
|
||||
WeaponSelect *tab = &g_weaponSelect[0];
|
||||
int count = 0;
|
||||
|
||||
// loop through all the weapons until terminator is found
|
||||
while (selectTab->id)
|
||||
while (tab->id)
|
||||
{
|
||||
if (m_currentWeapon == selectTab->id)
|
||||
if (m_currentWeapon == tab->id)
|
||||
break;
|
||||
|
||||
selectTab++;
|
||||
tab++;
|
||||
count++;
|
||||
}
|
||||
|
||||
if (selectTab->id && count < 7)
|
||||
if (tab->id && count < 7)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
@ -1331,30 +1330,30 @@ void Bot::SelectBestWeapon (void)
|
|||
if (m_isReloading)
|
||||
return;
|
||||
|
||||
WeaponSelect *selectTab = &g_weaponSelect[0];
|
||||
WeaponSelect *tab = &g_weaponSelect[0];
|
||||
|
||||
int selectIndex = 0;
|
||||
int chosenWeaponIndex = 0;
|
||||
|
||||
// loop through all the weapons until terminator is found...
|
||||
while (selectTab[selectIndex].id)
|
||||
while (tab[selectIndex].id)
|
||||
{
|
||||
// is the bot NOT carrying this weapon?
|
||||
if (!(pev->weapons & (1 << selectTab[selectIndex].id)))
|
||||
if (!(pev->weapons & (1 << tab[selectIndex].id)))
|
||||
{
|
||||
selectIndex++; // skip to next weapon
|
||||
continue;
|
||||
}
|
||||
|
||||
int id = selectTab[selectIndex].id;
|
||||
int id = tab[selectIndex].id;
|
||||
bool ammoLeft = false;
|
||||
|
||||
// is the bot already holding this weapon and there is still ammo in clip?
|
||||
if (selectTab[selectIndex].id == m_currentWeapon && (GetAmmoInClip () < 0 || GetAmmoInClip () >= selectTab[selectIndex].minPrimaryAmmo))
|
||||
if (tab[selectIndex].id == m_currentWeapon && (GetAmmoInClip () < 0 || GetAmmoInClip () >= tab[selectIndex].minPrimaryAmmo))
|
||||
ammoLeft = true;
|
||||
|
||||
// is no ammo required for this weapon OR enough ammo available to fire
|
||||
if (g_weaponDefs[id].ammo1 < 0 || (g_weaponDefs[id].ammo1 < 32 && m_ammo[g_weaponDefs[id].ammo1] >= selectTab[selectIndex].minPrimaryAmmo))
|
||||
if (g_weaponDefs[id].ammo1 < 0 || (g_weaponDefs[id].ammo1 < 32 && m_ammo[g_weaponDefs[id].ammo1] >= tab[selectIndex].minPrimaryAmmo))
|
||||
ammoLeft = true;
|
||||
|
||||
if (ammoLeft)
|
||||
|
|
@ -1366,11 +1365,11 @@ void Bot::SelectBestWeapon (void)
|
|||
chosenWeaponIndex %= NUM_WEAPONS + 1;
|
||||
selectIndex = chosenWeaponIndex;
|
||||
|
||||
int id = selectTab[selectIndex].id;
|
||||
int id = tab[selectIndex].id;
|
||||
|
||||
// select this weapon if it isn't already selected
|
||||
if (m_currentWeapon != id)
|
||||
SelectWeaponByName (selectTab[selectIndex].weaponName);
|
||||
SelectWeaponByName (tab[selectIndex].weaponName);
|
||||
|
||||
m_isReloading = false;
|
||||
m_reloadState = RELOAD_NONE;
|
||||
|
|
@ -1388,33 +1387,33 @@ void Bot::SelectPistol (void)
|
|||
|
||||
int Bot::GetHighestWeapon (void)
|
||||
{
|
||||
WeaponSelect *selectTab = &g_weaponSelect[0];
|
||||
WeaponSelect *tab = &g_weaponSelect[0];
|
||||
|
||||
int weapons = pev->weapons;
|
||||
int num = 0;
|
||||
int i = 0;
|
||||
|
||||
// loop through all the weapons until terminator is found...
|
||||
while (selectTab->id)
|
||||
while (tab->id)
|
||||
{
|
||||
// is the bot carrying this weapon?
|
||||
if (weapons & (1 << selectTab->id))
|
||||
if (weapons & (1 << tab->id))
|
||||
num = i;
|
||||
|
||||
i++;
|
||||
selectTab++;
|
||||
tab++;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
void Bot::SelectWeaponByName (const char *name)
|
||||
{
|
||||
FakeClientCommand (GetEntity (), name);
|
||||
engine.IssueBotCommand (GetEntity (), name);
|
||||
}
|
||||
|
||||
void Bot::SelectWeaponbyNumber (int num)
|
||||
{
|
||||
FakeClientCommand (GetEntity (), g_weaponSelect[num].weaponName);
|
||||
engine.IssueBotCommand (GetEntity (), g_weaponSelect[num].weaponName);
|
||||
}
|
||||
|
||||
void Bot::AttachToUser (void)
|
||||
|
|
@ -1423,7 +1422,7 @@ void Bot::AttachToUser (void)
|
|||
Array <edict_t *> foundUsers;
|
||||
|
||||
// search friends near us
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || g_clients[i].team != m_team || g_clients[i].ent == GetEntity ())
|
||||
continue;
|
||||
|
|
@ -1444,14 +1443,14 @@ void Bot::AttachToUser (void)
|
|||
void Bot::CommandTeam (void)
|
||||
{
|
||||
// prevent spamming
|
||||
if (m_timeTeamOrder > GetWorldTime () + 2 || yb_csdm_mode.GetInt () == 2 || yb_communication_type.GetInt () == 0)
|
||||
if (m_timeTeamOrder > engine.Time () + 2 || yb_csdm_mode.GetInt () == 2 || yb_communication_type.GetInt () == 0)
|
||||
return;
|
||||
|
||||
bool memberNear = false;
|
||||
bool memberExists = false;
|
||||
|
||||
// search teammates seen by this bot
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || g_clients[i].team != m_team || g_clients[i].ent == GetEntity ())
|
||||
continue;
|
||||
|
|
@ -1477,7 +1476,7 @@ void Bot::CommandTeam (void)
|
|||
else if (memberExists && yb_communication_type.GetInt () == 2)
|
||||
ChatterMessage(Chatter_ScaredEmotion);
|
||||
|
||||
m_timeTeamOrder = GetWorldTime () + Random.Float (5.0f, 30.0f);
|
||||
m_timeTeamOrder = engine.Time () + Random.Float (5.0f, 30.0f);
|
||||
}
|
||||
|
||||
bool Bot::IsGroupOfEnemies (const Vector &location, int numEnemies, int radius)
|
||||
|
|
@ -1485,7 +1484,7 @@ bool Bot::IsGroupOfEnemies (const Vector &location, int numEnemies, int radius)
|
|||
int numPlayers = 0;
|
||||
|
||||
// search the world for enemy players...
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || g_clients[i].ent == GetEntity ())
|
||||
continue;
|
||||
|
|
@ -1513,7 +1512,7 @@ void Bot::CheckReload (void)
|
|||
}
|
||||
|
||||
m_isReloading = false; // update reloading status
|
||||
m_reloadCheckTime = GetWorldTime () + 3.0f;
|
||||
m_reloadCheckTime = engine.Time () + 3.0f;
|
||||
|
||||
if (m_reloadState != RELOAD_NONE)
|
||||
{
|
||||
|
|
@ -1620,7 +1619,7 @@ void Bot::CheckReload (void)
|
|||
else
|
||||
{
|
||||
// if we have enemy don't reload next weapon
|
||||
if ((m_states & (STATE_SEEING_ENEMY | STATE_HEARING_ENEMY)) || m_seeEnemyTime + 5.0f > GetWorldTime ())
|
||||
if ((m_states & (STATE_SEEING_ENEMY | STATE_HEARING_ENEMY)) || m_seeEnemyTime + 5.0f > engine.Time ())
|
||||
{
|
||||
m_reloadState = RELOAD_NONE;
|
||||
return;
|
||||
|
|
|
|||
1062
source/engine.cpp
Normal file
1062
source/engine.cpp
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -9,6 +9,13 @@
|
|||
|
||||
#include <core.h>
|
||||
|
||||
// forward for super-globals
|
||||
//NetworkMsg netmsg;
|
||||
//Localizer locale;
|
||||
//Waypoint waypoints;
|
||||
//BotManager bots;
|
||||
//Engine engine;
|
||||
|
||||
bool g_canSayBombPlanted = true;
|
||||
bool g_isMetamod = false;
|
||||
bool g_radioInsteadVoice = false;
|
||||
|
|
@ -19,7 +26,6 @@ bool g_bombPlanted = false;
|
|||
bool g_bombSayString = false;
|
||||
bool g_isCommencing = false;
|
||||
bool g_editNoclip = false;
|
||||
bool g_isFakeCommand = false;
|
||||
bool g_waypointOn = false;
|
||||
bool g_waypointsChanged = true;
|
||||
bool g_autoWaypoint = false;
|
||||
|
|
@ -38,8 +44,7 @@ float g_autoPathDistance = 250.0f;
|
|||
|
||||
int g_lastRadio[2];
|
||||
int g_storeAddbotVars[4];
|
||||
int g_radioSelect[32];
|
||||
int g_fakeArgc = 0;
|
||||
int g_radioSelect[MAX_ENGINE_PLAYERS];
|
||||
int g_gameFlags = 0;
|
||||
int g_numWaypoints = 0;
|
||||
int g_mapType = 0;
|
||||
|
|
@ -48,9 +53,6 @@ int g_highestDamageCT = 1;
|
|||
int g_highestDamageT = 1;
|
||||
int g_highestKills = 1;
|
||||
|
||||
short g_modelIndexLaser = 0;
|
||||
short g_modelIndexArrow = 0;
|
||||
char g_fakeArgv[256];
|
||||
|
||||
Array <Array <String> > g_chatFactory;
|
||||
Array <Array <ChatterItem> > g_chatterFactory;
|
||||
|
|
@ -70,10 +72,9 @@ BlendAPI_t g_serverBlendingAPI = NULL;
|
|||
FuncPointers_t g_funcPointers = NULL;
|
||||
|
||||
enginefuncs_t g_engfuncs;
|
||||
Client g_clients[32];
|
||||
Client g_clients[MAX_ENGINE_PLAYERS];
|
||||
WeaponProperty g_weaponDefs[MAX_WEAPONS + 1];
|
||||
|
||||
edict_t *g_worldEntity = NULL;
|
||||
edict_t *g_hostEntity = NULL;
|
||||
globalvars_t *g_pGlobals = NULL;
|
||||
Experience *g_experienceData = NULL;
|
||||
|
|
@ -104,10 +105,10 @@ int *g_weaponPrefs[] =
|
|||
// metamod engine & dllapi function tables
|
||||
metamod_funcs_t gMetaFunctionTable =
|
||||
{
|
||||
NULL, // pfnEntityAPI_t ()
|
||||
NULL, // pfnEntityAPI_t_Post ()
|
||||
GetEntityAPI2, // pfnEntityAPI_t2 ()
|
||||
GetEntityAPI2_Post, // pfnEntityAPI_t2_Post ()
|
||||
NULL, // pfnGetEntityAPI ()
|
||||
NULL, // pfnGetEntityAPI_Post ()
|
||||
GetEntityAPI2, // pfnGetEntityAPI2 ()
|
||||
GetEntityAPI2_Post, // pfnGetEntityAPI2_Post ()
|
||||
NULL, // pfnGetNewDLLFunctions ()
|
||||
NULL, // pfnGetNewDLLFunctions_Post ()
|
||||
GetEngineFunctions, // pfnGetEngineFunctions ()
|
||||
|
|
@ -429,4 +430,4 @@ MenuText g_menus[21] =
|
|||
"3. Bidirectional (Both Ways)\v\v"
|
||||
"0. Exit"
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,4 @@
|
|||
//
|
||||
//
|
||||
// Yet Another POD-Bot, based on PODBot by Markus Klinge ("CountFloyd").
|
||||
// Copyright (c) YaPB Development Team.
|
||||
//
|
||||
|
|
@ -41,11 +41,12 @@ BotManager::BotManager (void)
|
|||
|
||||
m_creationTab.RemoveAll ();
|
||||
m_killerEntity = NULL;
|
||||
m_balanceCount = 0;
|
||||
}
|
||||
|
||||
BotManager::~BotManager (void)
|
||||
{
|
||||
// this is a bot manager class destructor, do not use GetMaxClients () here !!
|
||||
// this is a bot manager class destructor, do not use engine.MaxClients () here !!
|
||||
Free ();
|
||||
}
|
||||
|
||||
|
|
@ -66,13 +67,13 @@ void BotManager::CreateKillerEntity (void)
|
|||
|
||||
void BotManager::DestroyKillerEntity (void)
|
||||
{
|
||||
if (!IsEntityNull (m_killerEntity))
|
||||
if (!engine.IsNullEntity (m_killerEntity))
|
||||
g_engfuncs.pfnRemoveEntity (m_killerEntity);
|
||||
}
|
||||
|
||||
void BotManager::TouchWithKillerEntity (Bot *bot)
|
||||
{
|
||||
if (IsEntityNull (m_killerEntity))
|
||||
if (engine.IsNullEntity (m_killerEntity))
|
||||
{
|
||||
MDLL_ClientKill (bot->GetEntity ());
|
||||
return;
|
||||
|
|
@ -117,12 +118,12 @@ int BotManager::CreateBot (const String &name, int difficulty, int personality,
|
|||
|
||||
if (g_numWaypoints < 1) // don't allow creating bots with no waypoints loaded
|
||||
{
|
||||
CenterPrint ("Map is not waypointed. Cannot create bot");
|
||||
engine.CenterPrintf ("Map is not waypointed. Cannot create bot");
|
||||
return 0;
|
||||
}
|
||||
else if (g_waypointsChanged) // don't allow creating bots with changed waypoints (distance tables are messed up)
|
||||
{
|
||||
CenterPrint ("Waypoints have been changed. Load waypoints again...");
|
||||
engine.CenterPrintf ("Waypoints have been changed. Load waypoints again...");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -194,14 +195,14 @@ int BotManager::CreateBot (const String &name, int difficulty, int personality,
|
|||
strcpy (outputName, prefixedName);
|
||||
}
|
||||
|
||||
if (IsEntityNull ((bot = (*g_engfuncs.pfnCreateFakeClient) (outputName))))
|
||||
if (engine.IsNullEntity ((bot = (*g_engfuncs.pfnCreateFakeClient) (outputName))))
|
||||
{
|
||||
CenterPrint ("Maximum players reached (%d/%d). Unable to create Bot.", GetMaxClients (), GetMaxClients ());
|
||||
engine.CenterPrintf ("Maximum players reached (%d/%d). Unable to create Bot.", engine.MaxClients (), engine.MaxClients ());
|
||||
return 2;
|
||||
}
|
||||
int index = IndexOfEntity (bot) - 1;
|
||||
int index = engine.IndexOfEntity (bot) - 1;
|
||||
|
||||
InternalAssert (index >= 0 && index <= 32); // check index
|
||||
InternalAssert (index >= 0 && index <= MAX_ENGINE_PLAYERS); // check index
|
||||
InternalAssert (m_bots[index] == NULL); // check bot slot
|
||||
|
||||
m_bots[index] = new Bot (bot, difficulty, personality, team, member, steamId);
|
||||
|
|
@ -209,7 +210,7 @@ int BotManager::CreateBot (const String &name, int difficulty, int personality,
|
|||
if (m_bots[index] == NULL)
|
||||
TerminateOnMalloc ();
|
||||
|
||||
ServerPrint ("Connecting Bot...");
|
||||
engine.Printf ("Connecting Bot...");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -217,12 +218,12 @@ int BotManager::CreateBot (const String &name, int difficulty, int personality,
|
|||
int BotManager::GetIndex (edict_t *ent)
|
||||
{
|
||||
// this function returns index of bot (using own bot array)
|
||||
if (IsEntityNull (ent))
|
||||
if (engine.IsNullEntity (ent))
|
||||
return -1;
|
||||
|
||||
int index = IndexOfEntity (ent) - 1;
|
||||
int index = engine.IndexOfEntity (ent) - 1;
|
||||
|
||||
if (index < 0 || index >= 32)
|
||||
if (index < 0 || index >= MAX_ENGINE_PLAYERS)
|
||||
return -1;
|
||||
|
||||
if (m_bots[index] != NULL)
|
||||
|
|
@ -235,7 +236,7 @@ Bot *BotManager::GetBot (int index)
|
|||
{
|
||||
// this function finds a bot specified by index, and then returns pointer to it (using own bot array)
|
||||
|
||||
if (index < 0 || index >= 32)
|
||||
if (index < 0 || index >= MAX_ENGINE_PLAYERS)
|
||||
return NULL;
|
||||
|
||||
if (m_bots[index] != NULL)
|
||||
|
|
@ -257,7 +258,7 @@ Bot *BotManager::FindOneValidAliveBot (void)
|
|||
|
||||
Array <int> foundBots;
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (foundBots.GetSize () > 4)
|
||||
break;
|
||||
|
|
@ -276,7 +277,7 @@ void BotManager::Think (void)
|
|||
{
|
||||
// this function calls think () function for all available at call moment bots
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (m_bots[i] != NULL)
|
||||
m_bots[i]->Think ();
|
||||
|
|
@ -287,7 +288,7 @@ void BotManager::PeriodicThink (void)
|
|||
{
|
||||
// this function calls periodic SecondThink () function for all available at call moment bots
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (m_bots[i] != NULL)
|
||||
m_bots[i]->PeriodicThink ();
|
||||
|
|
@ -329,9 +330,9 @@ void BotManager::AddBot (const String &name, const String &difficulty, const Str
|
|||
|
||||
void BotManager::AdjustQuota (bool isPlayerConnection, edict_t *ent)
|
||||
{
|
||||
// this function increases or decreases bot quota amount depending on autovacate variables
|
||||
// this function increases or decreases bot quota amount depending on auto vacate variables
|
||||
|
||||
if (!IsDedicatedServer () || !yb_autovacate.GetBool () || GetBot (ent) != NULL)
|
||||
if (!engine.IsDedicatedServer () || !yb_autovacate.GetBool () || GetBot (ent) != NULL)
|
||||
return;
|
||||
|
||||
if (isPlayerConnection)
|
||||
|
|
@ -374,7 +375,7 @@ void BotManager::VerifyPlayersHasJoinedTeam (int &desiredCount)
|
|||
if (!m_trackedPlayers.GetElementNumber ())
|
||||
return;
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
Client &cl = g_clients[i];
|
||||
|
||||
|
|
@ -405,7 +406,7 @@ void BotManager::MaintainBotQuota (void)
|
|||
return;
|
||||
|
||||
// bot's creation update
|
||||
if (!m_creationTab.IsEmpty () && m_maintainTime < GetWorldTime ())
|
||||
if (!m_creationTab.IsEmpty () && m_maintainTime < engine.Time ())
|
||||
{
|
||||
CreateQueue last = m_creationTab.Pop ();
|
||||
int resultOfCall = CreateBot (last.name, last.difficulty, last.personality, last.team, last.member);
|
||||
|
|
@ -421,11 +422,11 @@ void BotManager::MaintainBotQuota (void)
|
|||
m_creationTab.RemoveAll (); // maximum players reached, so set quota to maximum players
|
||||
yb_quota.SetInt (GetBotsNum ());
|
||||
}
|
||||
m_maintainTime = GetWorldTime () + 0.45f;
|
||||
m_maintainTime = engine.Time () + 0.20f;
|
||||
}
|
||||
|
||||
// now keep bot number up to date
|
||||
if (m_quotaMaintainTime < GetWorldTime ())
|
||||
if (m_quotaMaintainTime < engine.Time ())
|
||||
{
|
||||
// don't allow that quota is below zero
|
||||
if (yb_quota.GetInt () < 0)
|
||||
|
|
@ -447,9 +448,9 @@ void BotManager::MaintainBotQuota (void)
|
|||
desiredCount = max (0, yb_quota.GetInt () * numHumans);
|
||||
|
||||
if (yb_autovacate.GetBool ())
|
||||
desiredCount = min (desiredCount, GetMaxClients () - (numHumans + 1));
|
||||
desiredCount = min (desiredCount, engine.MaxClients () - (numHumans + 1));
|
||||
else
|
||||
desiredCount = min (desiredCount, GetMaxClients () - numHumans);
|
||||
desiredCount = min (desiredCount, engine.MaxClients () - numHumans);
|
||||
|
||||
if (yb_autovacate_smart_kick.GetBool () && numBots > 1 && desiredCount > 1)
|
||||
VerifyPlayersHasJoinedTeam (desiredCount);
|
||||
|
|
@ -459,7 +460,7 @@ void BotManager::MaintainBotQuota (void)
|
|||
else if (desiredCount < numBots)
|
||||
RemoveRandom ();
|
||||
|
||||
m_quotaMaintainTime = GetWorldTime () + 0.90f;
|
||||
m_quotaMaintainTime = engine.Time () + 0.90f;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -467,8 +468,8 @@ void BotManager::InitQuota (void)
|
|||
{
|
||||
m_balanceCount = 0;
|
||||
|
||||
m_maintainTime = GetWorldTime () + 3.0f;
|
||||
m_quotaMaintainTime = GetWorldTime () + 3.0f;
|
||||
m_maintainTime = engine.Time () + 3.0f;
|
||||
m_quotaMaintainTime = engine.Time () + 3.0f;
|
||||
|
||||
m_trackedPlayers.RemoveAll ();
|
||||
m_creationTab.RemoveAll ();
|
||||
|
|
@ -478,7 +479,7 @@ void BotManager::FillServer (int selection, int personality, int difficulty, int
|
|||
{
|
||||
// this function fill server with bots, with specified team & personality
|
||||
|
||||
if (GetBotsNum () >= GetMaxClients () - GetHumansNum ())
|
||||
if (GetBotsNum () >= engine.MaxClients () - GetHumansNum ())
|
||||
return;
|
||||
|
||||
if (selection == 1 || selection == 2)
|
||||
|
|
@ -499,14 +500,13 @@ void BotManager::FillServer (int selection, int personality, int difficulty, int
|
|||
{"Random"},
|
||||
};
|
||||
|
||||
int toAdd = numToAdd == -1 ? GetMaxClients () - (GetHumansNum () + GetBotsNum ()) : numToAdd;
|
||||
int toAdd = numToAdd == -1 ? engine.MaxClients () - (GetHumansNum () + GetBotsNum ()) : numToAdd;
|
||||
|
||||
for (int i = 0; i <= toAdd; i++)
|
||||
AddBot ("", difficulty, personality, selection, -1);
|
||||
|
||||
yb_quota.SetInt (toAdd);
|
||||
|
||||
CenterPrint ("Fill Server with %s bots...", &teamDesc[selection][0]);
|
||||
engine.CenterPrintf ("Fill Server with %s bots...", &teamDesc[selection][0]);
|
||||
}
|
||||
|
||||
void BotManager::RemoveAll (bool zeroQuota)
|
||||
|
|
@ -514,9 +514,9 @@ void BotManager::RemoveAll (bool zeroQuota)
|
|||
// this function drops all bot clients from server (this function removes only yapb's)`q
|
||||
|
||||
if (zeroQuota)
|
||||
CenterPrint ("Bots are removed from server.");
|
||||
engine.CenterPrintf ("Bots are removed from server.");
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (m_bots[i] != NULL) // is this slot used?
|
||||
m_bots[i]->Kick ();
|
||||
|
|
@ -535,9 +535,9 @@ void BotManager::RemoveFromTeam (Team team, bool removeAll)
|
|||
{
|
||||
// this function remove random bot from specified team (if removeAll value = 1 then removes all players from team)
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (m_bots[i] != NULL && team == GetTeam (m_bots[i]->GetEntity ()))
|
||||
if (m_bots[i] != NULL && team == engine.GetTeam (m_bots[i]->GetEntity ()))
|
||||
{
|
||||
m_bots[i]->Kick ();
|
||||
|
||||
|
|
@ -551,7 +551,6 @@ void BotManager::RemoveMenu (edict_t *ent, int selection)
|
|||
{
|
||||
// this function displays remove bot menu to specified entity (this function show's only yapb's).
|
||||
|
||||
|
||||
if (selection > 4 || selection < 1)
|
||||
return;
|
||||
|
||||
|
|
@ -565,10 +564,10 @@ void BotManager::RemoveMenu (edict_t *ent, int selection)
|
|||
|
||||
for (int i = ((selection - 1) * 8); i < selection * 8; i++)
|
||||
{
|
||||
if ((m_bots[i] != NULL) && !IsEntityNull (m_bots[i]->GetEntity ()))
|
||||
if ((m_bots[i] != NULL) && !engine.IsNullEntity (m_bots[i]->GetEntity ()))
|
||||
{
|
||||
validSlots |= 1 << (i - ((selection - 1) * 8));
|
||||
sprintf (buffer, "%s %1.1d. %s%s\n", buffer, i - ((selection - 1) * 8) + 1, STRING (m_bots[i]->pev->netname), GetTeam (m_bots[i]->GetEntity ()) == CT ? " \\y(CT)\\w" : " \\r(T)\\w");
|
||||
sprintf (buffer, "%s %1.1d. %s%s\n", buffer, i - ((selection - 1) * 8) + 1, STRING (m_bots[i]->pev->netname), engine.GetTeam (m_bots[i]->GetEntity ()) == CT ? " \\y(CT)\\w" : " \\r(T)\\w");
|
||||
}
|
||||
else
|
||||
sprintf (buffer, "%s\\d %1.1d. Not a Bot\\w\n", buffer, i - ((selection - 1) * 8) + 1);
|
||||
|
|
@ -612,7 +611,7 @@ void BotManager::KillAll (int team)
|
|||
{
|
||||
// this function kills all bots on server (only this dll controlled bots)
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (m_bots[i] != NULL)
|
||||
{
|
||||
|
|
@ -622,7 +621,7 @@ void BotManager::KillAll (int team)
|
|||
m_bots[i]->Kill ();
|
||||
}
|
||||
}
|
||||
CenterPrint ("All Bots died !");
|
||||
engine.CenterPrintf ("All Bots died !");
|
||||
}
|
||||
|
||||
void BotManager::RemoveRandom (void)
|
||||
|
|
@ -633,7 +632,7 @@ void BotManager::RemoveRandom (void)
|
|||
|
||||
|
||||
// first try to kick the bot that is currently dead
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (m_bots[i] != NULL && !m_bots[i]->m_notKilled) // is this slot used?
|
||||
{
|
||||
|
|
@ -652,7 +651,7 @@ void BotManager::RemoveRandom (void)
|
|||
float score = 9999.0f;
|
||||
|
||||
// search bots in this team
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
Bot *bot = bots.GetBot (i);
|
||||
|
||||
|
|
@ -671,7 +670,7 @@ void BotManager::RemoveRandom (void)
|
|||
}
|
||||
|
||||
// worst case, just kick some random bot
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (m_bots[i] != NULL) // is this slot used?
|
||||
{
|
||||
|
|
@ -730,27 +729,22 @@ void BotManager::SetWeaponMode (int selection)
|
|||
else
|
||||
yb_jasonmode.SetInt (0);
|
||||
|
||||
CenterPrint ("%s weapon mode selected", &modeName[selection][0]);
|
||||
engine.CenterPrintf ("%s weapon mode selected", &modeName[selection][0]);
|
||||
}
|
||||
|
||||
void BotManager::ListBots (void)
|
||||
{
|
||||
// this function list's bots currently playing on the server
|
||||
|
||||
ServerPrint ("%-3.5s %-9.13s %-17.18s %-3.4s %-3.4s %-3.4s", "index", "name", "personality", "team", "difficulty", "frags");
|
||||
engine.Printf ("%-3.5s %-9.13s %-17.18s %-3.4s %-3.4s %-3.4s", "index", "name", "personality", "team", "difficulty", "frags");
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
edict_t *player = EntityOfIndex (i);
|
||||
Bot *bot = GetBot (i);
|
||||
|
||||
// is this player slot valid
|
||||
if (IsValidBot (player))
|
||||
{
|
||||
Bot *bot = GetBot (player);
|
||||
|
||||
if (bot != NULL)
|
||||
ServerPrint ("[%-3.1d] %-9.13s %-17.18s %-3.4s %-3.1d %-3.1d", i, STRING (player->v.netname), bot->m_personality == PERSONALITY_RUSHER ? "rusher" : bot->m_personality == PERSONALITY_NORMAL ? "normal" : "careful", GetTeam (player) != 0 ? "CT" : "T", bot->m_difficulty, static_cast <int> (player->v.frags));
|
||||
}
|
||||
if (bot != NULL)
|
||||
engine.Printf ("[%-3.1d] %-9.13s %-17.18s %-3.4s %-3.1d %-3.1d", i, STRING (bot->pev->netname), bot->m_personality == PERSONALITY_RUSHER ? "rusher" : bot->m_personality == PERSONALITY_NORMAL ? "normal" : "careful", bot->m_team == CT ? "CT" : "T", bot->m_difficulty, static_cast <int> (bot->pev->frags));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -760,7 +754,7 @@ int BotManager::GetBotsNum (void)
|
|||
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (m_bots[i] != NULL)
|
||||
count++;
|
||||
|
|
@ -774,11 +768,11 @@ Bot *BotManager::GetHighestFragsBot (int team)
|
|||
float bestScore = -1;
|
||||
|
||||
// search bots in this team
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
Bot *bot = bots.GetBot (i);
|
||||
|
||||
if (bot != NULL && IsAlive (bot->GetEntity ()) && GetTeam (bot->GetEntity ()) == team)
|
||||
if (bot != NULL && bot->m_notKilled && bot->m_team == team)
|
||||
{
|
||||
if (bot->pev->frags > bestScore)
|
||||
{
|
||||
|
|
@ -798,7 +792,7 @@ void BotManager::CheckTeamEconomics (int team, bool setTrue)
|
|||
|
||||
extern ConVar yb_economics_rounds;
|
||||
|
||||
if (!yb_economics_rounds.GetBool () || setTrue)
|
||||
if (setTrue || !yb_economics_rounds.GetBool ())
|
||||
{
|
||||
m_economicsGood[team] = true;
|
||||
return; // don't check economics while economics disable
|
||||
|
|
@ -808,9 +802,9 @@ void BotManager::CheckTeamEconomics (int team, bool setTrue)
|
|||
int numTeamPlayers = 0;
|
||||
|
||||
// start calculating
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (m_bots[i] != NULL && GetTeam (m_bots[i]->GetEntity ()) == team)
|
||||
if (m_bots[i] != NULL && engine.GetTeam (m_bots[i]->GetEntity ()) == team)
|
||||
{
|
||||
if (m_bots[i]->m_moneyAmount <= g_botBuyEconomyTable[0])
|
||||
numPoorPlayers++;
|
||||
|
|
@ -836,7 +830,7 @@ void BotManager::Free (void)
|
|||
{
|
||||
// this function free all bots slots (used on server shutdown)
|
||||
|
||||
for (int i = 0; i < 32; i++)
|
||||
for (int i = 0; i < MAX_ENGINE_PLAYERS; i++)
|
||||
Free (i);
|
||||
}
|
||||
|
||||
|
|
@ -854,7 +848,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c
|
|||
// when bot setup completed, (this is a bot class constructor)
|
||||
|
||||
char rejectReason[128];
|
||||
int clientIndex = IndexOfEntity (bot);
|
||||
int clientIndex = engine.IndexOfEntity (bot);
|
||||
|
||||
memset (reinterpret_cast <void *> (this), 0, sizeof (*this));
|
||||
|
||||
|
|
@ -877,7 +871,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c
|
|||
SET_CLIENT_KEYVALUE (clientIndex, buffer, "*bot", "1");
|
||||
|
||||
rejectReason[0] = 0; // reset the reject reason template string
|
||||
MDLL_ClientConnect (bot, "BOT", FormatBuffer ("127.0.0.%d", IndexOfEntity (bot) + 100), rejectReason);
|
||||
MDLL_ClientConnect (bot, "BOT", FormatBuffer ("127.0.0.%d", engine.IndexOfEntity (bot) + 100), rejectReason);
|
||||
|
||||
// should be set after client connect
|
||||
if (yb_avatar_display.GetBool () && !steamId.IsEmpty ())
|
||||
|
|
@ -889,7 +883,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c
|
|||
if (!IsNullString (rejectReason))
|
||||
{
|
||||
AddLogEntry (true, LL_WARNING, "Server refused '%s' connection (%s)", STRING (bot->v.netname), rejectReason);
|
||||
ServerCommand ("kick \"%s\"", STRING (bot->v.netname)); // kick the bot player if the server refused it
|
||||
engine.IssueCmd ("kick \"%s\"", STRING (bot->v.netname)); // kick the bot player if the server refused it
|
||||
|
||||
bot->v.flags |= FL_KILLME;
|
||||
}
|
||||
|
|
@ -918,8 +912,8 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c
|
|||
yb_difficulty.SetInt (difficulty);
|
||||
}
|
||||
|
||||
m_lastCommandTime = GetWorldTime () - 0.1f;
|
||||
m_frameInterval = GetWorldTime ();
|
||||
m_lastCommandTime = engine.Time () - 0.1f;
|
||||
m_frameInterval = engine.Time ();
|
||||
m_timePeriodicUpdate = 0.0f;
|
||||
|
||||
switch (personality)
|
||||
|
|
@ -952,7 +946,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c
|
|||
// copy them over to the temp level variables
|
||||
m_agressionLevel = m_baseAgressionLevel;
|
||||
m_fearLevel = m_baseFearLevel;
|
||||
m_nextEmotionUpdate = GetWorldTime () + 0.5f;
|
||||
m_nextEmotionUpdate = engine.Time () + 0.5f;
|
||||
|
||||
// just to be sure
|
||||
m_actMessageIndex = 0;
|
||||
|
|
@ -965,7 +959,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c
|
|||
int newBotsNum = bots.GetBotsNum () + 1;
|
||||
|
||||
// keep quota number up to date
|
||||
if (newBotsNum < GetMaxClients () && newBotsNum > yb_quota.GetInt ())
|
||||
if (newBotsNum < engine.MaxClients () && newBotsNum > yb_quota.GetInt ())
|
||||
yb_quota.SetInt (newBotsNum);
|
||||
|
||||
NewRound ();
|
||||
|
|
@ -999,7 +993,7 @@ int BotManager::GetHumansNum (void)
|
|||
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
Client *cl = &g_clients[i];
|
||||
|
||||
|
|
@ -1015,7 +1009,7 @@ int BotManager::GetHumansAliveNum (void)
|
|||
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
Client *cl = &g_clients[i];
|
||||
|
||||
|
|
@ -1031,7 +1025,7 @@ int BotManager::GetHumansJoinedTeam (void)
|
|||
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
Client *cl = &g_clients[i];
|
||||
|
||||
|
|
@ -1072,8 +1066,8 @@ void Bot::NewRound (void)
|
|||
for (i = 0; i < 5; i++)
|
||||
m_prevWptIndex[i] = -1;
|
||||
|
||||
m_navTimeset = GetWorldTime ();
|
||||
m_team = GetTeam (GetEntity ());
|
||||
m_navTimeset = engine.Time ();
|
||||
m_team = engine.GetTeam (GetEntity ());
|
||||
|
||||
switch (m_personality)
|
||||
{
|
||||
|
|
@ -1102,13 +1096,14 @@ void Bot::NewRound (void)
|
|||
|
||||
m_maxThrowTimer = 0.0f;
|
||||
m_timeTeamOrder = 0.0f;
|
||||
m_timeRepotingInDelay = Random.Float (40.0f, 240.0f);
|
||||
m_askCheckTime = 0.0f;
|
||||
m_minSpeed = 260.0f;
|
||||
m_prevSpeed = 0.0f;
|
||||
m_prevOrigin = Vector (9999.0f, 9999.0f, 9999.0f);
|
||||
m_prevTime = GetWorldTime ();
|
||||
m_blindRecognizeTime = GetWorldTime ();
|
||||
m_lookUpdateTime = GetWorldTime ();
|
||||
m_prevTime = engine.Time ();
|
||||
m_blindRecognizeTime = engine.Time ();
|
||||
m_lookUpdateTime = engine.Time ();
|
||||
|
||||
m_viewDistance = 4096.0f;
|
||||
m_maxViewDistance = 4096.0f;
|
||||
|
|
@ -1119,7 +1114,7 @@ void Bot::NewRound (void)
|
|||
m_itemCheckTime = 0.0f;
|
||||
|
||||
m_breakableEntity = NULL;
|
||||
m_breakable.Zero ();
|
||||
m_breakableOrigin.Zero ();
|
||||
m_timeDoorOpen = 0.0f;
|
||||
|
||||
ResetCollideState ();
|
||||
|
|
@ -1157,7 +1152,7 @@ void Bot::NewRound (void)
|
|||
SetIdealReactionTimes (true);
|
||||
|
||||
m_targetEntity = NULL;
|
||||
m_tasks = NULL;
|
||||
m_tasks.RemoveAll ();
|
||||
m_followWaitTime = 0.0f;
|
||||
|
||||
for (i = 0; i < MAX_HOSTAGES; i++)
|
||||
|
|
@ -1170,8 +1165,8 @@ void Bot::NewRound (void)
|
|||
m_reloadState = RELOAD_NONE;
|
||||
|
||||
m_reloadCheckTime = 0.0f;
|
||||
m_shootTime = GetWorldTime ();
|
||||
m_playerTargetTime = GetWorldTime ();
|
||||
m_shootTime = engine.Time ();
|
||||
m_playerTargetTime = engine.Time ();
|
||||
m_firePause = 0.0f;
|
||||
m_timeLastFired = 0.0f;
|
||||
|
||||
|
|
@ -1185,7 +1180,7 @@ void Bot::NewRound (void)
|
|||
m_jumpFinished = false;
|
||||
m_isStuck = false;
|
||||
|
||||
m_sayTextBuffer.timeNextChat = GetWorldTime ();
|
||||
m_sayTextBuffer.timeNextChat = engine.Time ();
|
||||
m_sayTextBuffer.entityIndex = -1;
|
||||
m_sayTextBuffer.sayText[0] = 0x0;
|
||||
|
||||
|
|
@ -1200,8 +1195,8 @@ void Bot::NewRound (void)
|
|||
m_currentWeapon = 0;
|
||||
}
|
||||
|
||||
m_knifeAttackTime = GetWorldTime () + Random.Float (1.3f, 2.6f);
|
||||
m_nextBuyTime = GetWorldTime () + Random.Float (0.6f, 2.0f);
|
||||
m_knifeAttackTime = engine.Time () + Random.Float (1.3f, 2.6f);
|
||||
m_nextBuyTime = engine.Time () + Random.Float (0.6f, 2.0f);
|
||||
|
||||
m_buyPending = false;
|
||||
m_inBombZone = false;
|
||||
|
|
@ -1210,8 +1205,8 @@ void Bot::NewRound (void)
|
|||
m_shieldCheckTime = 0.0f;
|
||||
m_zoomCheckTime = 0.0f;
|
||||
m_strafeSetTime = 0.0f;
|
||||
m_combatStrafeDir = 0;
|
||||
m_fightStyle = 0;
|
||||
m_combatStrafeDir = STRAFE_DIR_NONE;
|
||||
m_fightStyle = FIGHT_NONE;
|
||||
m_lastFightStyleCheck = 0.0f;
|
||||
|
||||
m_checkWeaponSwitch = true;
|
||||
|
|
@ -1224,9 +1219,9 @@ void Bot::NewRound (void)
|
|||
m_defendHostage = false;
|
||||
m_headedTime = 0.0f;
|
||||
|
||||
m_timeLogoSpray = GetWorldTime () + Random.Float (0.5f, 2.0f);
|
||||
m_spawnTime = GetWorldTime ();
|
||||
m_lastChatTime = GetWorldTime ();
|
||||
m_timeLogoSpray = engine.Time () + Random.Float (0.5f, 2.0f);
|
||||
m_spawnTime = engine.Time ();
|
||||
m_lastChatTime = engine.Time ();
|
||||
|
||||
m_timeCamping = 0;
|
||||
m_campDirection = 0;
|
||||
|
|
@ -1234,7 +1229,7 @@ void Bot::NewRound (void)
|
|||
m_campButtons = 0;
|
||||
|
||||
m_soundUpdateTime = 0.0f;
|
||||
m_heardSoundTime = GetWorldTime ();
|
||||
m_heardSoundTime = engine.Time ();
|
||||
|
||||
// clear its message queue
|
||||
for (i = 0; i < 32; i++)
|
||||
|
|
@ -1270,13 +1265,13 @@ void Bot::Kick (void)
|
|||
{
|
||||
// this function kick off one bot from the server.
|
||||
|
||||
ServerCommand ("kick \"%s\"", STRING (pev->netname));
|
||||
CenterPrint ("Bot '%s' kicked", STRING (pev->netname));
|
||||
engine.IssueCmd ("kick \"%s\"", STRING (pev->netname));
|
||||
engine.CenterPrintf ("Bot '%s' kicked", STRING (pev->netname));
|
||||
|
||||
int newBotsNum = bots.GetBotsNum () - 1;
|
||||
|
||||
// keep quota number up to date
|
||||
if (newBotsNum < GetMaxClients () && newBotsNum < yb_quota.GetInt ())
|
||||
if (newBotsNum < engine.MaxClients () && newBotsNum < yb_quota.GetInt ())
|
||||
yb_quota.SetInt (newBotsNum);
|
||||
}
|
||||
|
||||
|
|
@ -1287,7 +1282,7 @@ void Bot::StartGame (void)
|
|||
#ifdef XASH_CSDM
|
||||
m_wantedTeam = Random.Long (1, 2);
|
||||
|
||||
FakeClientCommand (GetEntity (), "jointeam %d", m_wantedTeam);
|
||||
engine.IssueBotCommand (GetEntity (), "jointeam %d", m_wantedTeam);
|
||||
|
||||
SET_CLIENT_KEYVALUE (GetIndex (), GET_INFOKEYBUFFER (GetEntity ()), "model", m_wantedTeam == 2 ? "Counter-Terrorists" : "Terrorists");
|
||||
|
||||
|
|
@ -1314,7 +1309,7 @@ void Bot::StartGame (void)
|
|||
m_wantedTeam = 5;
|
||||
|
||||
// select the team the bot wishes to join...
|
||||
FakeClientCommand (GetEntity (), "menuselect %d", m_wantedTeam);
|
||||
engine.IssueBotCommand (GetEntity (), "menuselect %d", m_wantedTeam);
|
||||
}
|
||||
else if (m_startAction == GSM_CLASS_SELECT)
|
||||
{
|
||||
|
|
@ -1332,7 +1327,7 @@ void Bot::StartGame (void)
|
|||
}
|
||||
|
||||
// select the class the bot wishes to use...
|
||||
FakeClientCommand (GetEntity (), "menuselect %d", m_wantedClass);
|
||||
engine.IssueBotCommand (GetEntity (), "menuselect %d", m_wantedClass);
|
||||
|
||||
// bot has now joined the game (doesn't need to be started)
|
||||
m_notStarted = false;
|
||||
|
|
@ -1351,9 +1346,9 @@ void BotManager::CalculatePingOffsets (void)
|
|||
int averagePing = 0;
|
||||
int numHumans = 0;
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
edict_t *ent = EntityOfIndex (i + 1);
|
||||
edict_t *ent = engine.EntityOfIndex (i + 1);
|
||||
|
||||
if (!IsValidPlayer (ent))
|
||||
continue;
|
||||
|
|
@ -1374,7 +1369,7 @@ void BotManager::CalculatePingOffsets (void)
|
|||
else
|
||||
averagePing = Random.Long (30, 40);
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
Bot *bot = GetBot (i);
|
||||
|
||||
|
|
@ -1405,7 +1400,7 @@ void BotManager::CalculatePingOffsets (void)
|
|||
|
||||
void BotManager::SendPingDataOffsets (edict_t *to)
|
||||
{
|
||||
if ((g_gameFlags & GAME_LEGACY) || yb_latency_display.GetInt () != 2 || IsEntityNull (to))
|
||||
if ((g_gameFlags & GAME_LEGACY) || yb_latency_display.GetInt () != 2 || engine.IsNullEntity (to) || (to->v.flags & FL_FAKECLIENT))
|
||||
return;
|
||||
|
||||
if (!(to->v.flags & FL_CLIENT) && !(((to->v.button & IN_SCORE) || !(to->v.oldbuttons & IN_SCORE))))
|
||||
|
|
@ -1417,9 +1412,9 @@ void BotManager::SendPingDataOffsets (edict_t *to)
|
|||
// missing from sdk
|
||||
static const int SVC_PINGS = 17;
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
Bot *bot = GetBot (i);
|
||||
Bot *bot = m_bots[i];
|
||||
|
||||
if (bot == NULL)
|
||||
continue;
|
||||
|
|
@ -1470,7 +1465,7 @@ void BotManager::SendDeathMsgFix (void)
|
|||
{
|
||||
m_deathMsgSent = false;
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
SendPingDataOffsets (g_clients[i].ent);
|
||||
}
|
||||
}
|
||||
|
|
@ -1483,7 +1478,7 @@ void BotManager::UpdateActiveGrenades (void)
|
|||
m_activeGrenades.RemoveAll ();
|
||||
|
||||
// search the map for any type of grenade
|
||||
while (!IsEntityNull (grenade = FIND_ENTITY_BY_CLASSNAME (grenade, "grenade")))
|
||||
while (!engine.IsNullEntity (grenade = FIND_ENTITY_BY_CLASSNAME (grenade, "grenade")))
|
||||
{
|
||||
// do not count c4 as a grenade
|
||||
if (strcmp (STRING (grenade->v.model) + 9, "c4.mdl") == 0)
|
||||
|
|
@ -1493,7 +1488,7 @@ void BotManager::UpdateActiveGrenades (void)
|
|||
}
|
||||
}
|
||||
|
||||
const Array <entity_t> &BotManager::GetActiveGrenades (void)
|
||||
const Array <edict_t *> &BotManager::GetActiveGrenades (void)
|
||||
{
|
||||
return m_activeGrenades;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
//
|
||||
//
|
||||
// Yet Another POD-Bot, based on PODBot by Markus Klinge ("CountFloyd").
|
||||
// Copyright (c) YaPB Development Team.
|
||||
//
|
||||
|
|
@ -18,11 +18,11 @@ int Bot::FindGoal (void)
|
|||
{
|
||||
edict_t *pent = NULL;
|
||||
|
||||
while (!IsEntityNull (pent = FIND_ENTITY_BY_STRING (pent, "classname", "weaponbox")))
|
||||
while (!engine.IsNullEntity (pent = FIND_ENTITY_BY_STRING (pent, "classname", "weaponbox")))
|
||||
{
|
||||
if (strcmp (STRING (pent->v.model), "models/w_backpack.mdl") == 0)
|
||||
{
|
||||
int index = waypoints.FindNearest (GetEntityOrigin (pent));
|
||||
int index = waypoints.FindNearest (engine.GetAbsOrigin (pent));
|
||||
|
||||
if (index >= 0 && index < g_numWaypoints)
|
||||
return m_loosedBombWptIndex = index;
|
||||
|
|
@ -30,6 +30,10 @@ int Bot::FindGoal (void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// forcing terrorist bot to not move to another bombspot
|
||||
if (m_inBombZone && !m_hasProgressBar && m_hasC4)
|
||||
return waypoints.FindNearest (pev->origin, 400.0f, FLAG_GOAL);
|
||||
}
|
||||
int tactic = 0;
|
||||
|
||||
|
|
@ -116,7 +120,7 @@ int Bot::FindGoal (void)
|
|||
if (m_personality != PERSONALITY_RUSHER)
|
||||
defensive += 10.0f;
|
||||
}
|
||||
else if ((g_mapType & MAP_DE) && m_team == TERRORIST && g_timeRoundStart + 10.0f < GetWorldTime ())
|
||||
else if ((g_mapType & MAP_DE) && m_team == TERRORIST && g_timeRoundStart + 10.0f < engine.Time ())
|
||||
{
|
||||
// send some terrorists to guard planted bomb
|
||||
if (!m_defendedBomb && g_bombPlanted && GetTaskId () != TASK_ESCAPEFROMBOMB && GetBombTimeleft () >= 15.0)
|
||||
|
|
@ -167,7 +171,7 @@ TacticChoosen:
|
|||
else if (tactic == 3 && !waypoints.m_goalPoints.IsEmpty ()) // map goal waypoint
|
||||
{
|
||||
// force bomber to select closest goal, if round-start goal was reset by something
|
||||
if (m_hasC4 && g_timeRoundStart + 10.0f < GetWorldTime ())
|
||||
if (m_hasC4 && g_timeRoundStart + 10.0f < engine.Time ())
|
||||
{
|
||||
float minDist = 99999.0f;
|
||||
int count = 0;
|
||||
|
|
@ -302,21 +306,21 @@ void Bot::IgnoreCollisionShortly (void)
|
|||
{
|
||||
ResetCollideState ();
|
||||
|
||||
m_lastCollTime = GetWorldTime () + 0.35f;
|
||||
m_lastCollTime = engine.Time () + 0.35f;
|
||||
m_isStuck = false;
|
||||
m_checkTerrain = false;
|
||||
}
|
||||
|
||||
void Bot::CheckCloseAvoidance (const Vector &dirNormal)
|
||||
{
|
||||
if (m_seeEnemyTime + 1.5f < GetWorldTime ())
|
||||
if (m_seeEnemyTime + 1.5f < engine.Time ())
|
||||
return;
|
||||
|
||||
edict_t *nearest = NULL;
|
||||
float nearestDist = 99999.0f;
|
||||
int playerCount = 0;
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
Client *cl = &g_clients[i];
|
||||
|
||||
|
|
@ -372,28 +376,26 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal)
|
|||
|
||||
// Standing still, no need to check?
|
||||
// FIXME: doesn't care for ladder movement (handled separately) should be included in some way
|
||||
if ((m_moveSpeed >= 10.0f || m_strafeSpeed >= 10.0f) && m_lastCollTime < GetWorldTime () && m_seeEnemyTime + 0.8f < GetWorldTime () && GetTaskId () != TASK_ATTACK)
|
||||
if ((m_moveSpeed >= 10.0f || m_strafeSpeed >= 10.0f) && m_lastCollTime < engine.Time () && m_seeEnemyTime + 0.8f < engine.Time () && GetTaskId () != TASK_ATTACK)
|
||||
{
|
||||
bool cantMoveForward = false;
|
||||
|
||||
if (movedDistance < 2.0f && m_prevSpeed >= 20.0f) // didn't we move enough previously?
|
||||
{
|
||||
// Then consider being stuck
|
||||
m_prevTime = GetWorldTime ();
|
||||
m_prevTime = engine.Time ();
|
||||
m_isStuck = true;
|
||||
|
||||
if (m_firstCollideTime == 0.0)
|
||||
m_firstCollideTime = GetWorldTime () + 0.2f;
|
||||
m_firstCollideTime = engine.Time () + 0.2f;
|
||||
}
|
||||
else // not stuck yet
|
||||
{
|
||||
// test if there's something ahead blocking the way
|
||||
if ((cantMoveForward = CantMoveForward (dirNormal, &tr)) && !IsOnLadder ())
|
||||
if (CantMoveForward (dirNormal, &tr) && !IsOnLadder ())
|
||||
{
|
||||
if (m_firstCollideTime == 0.0f)
|
||||
m_firstCollideTime = GetWorldTime () + 0.2f;
|
||||
m_firstCollideTime = engine.Time () + 0.2f;
|
||||
|
||||
else if (m_firstCollideTime <= GetWorldTime ())
|
||||
else if (m_firstCollideTime <= engine.Time ())
|
||||
m_isStuck = true;
|
||||
}
|
||||
else
|
||||
|
|
@ -402,7 +404,7 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal)
|
|||
|
||||
if (!m_isStuck) // not stuck?
|
||||
{
|
||||
if (m_probeTime + 0.5f < GetWorldTime ())
|
||||
if (m_probeTime + 0.5f < engine.Time ())
|
||||
ResetCollideState (); // reset collision memory if not being stuck for 0.5 secs
|
||||
else
|
||||
{
|
||||
|
|
@ -427,7 +429,7 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal)
|
|||
else if (IsInWater ())
|
||||
bits |= (PROBE_JUMP | PROBE_STRAFE);
|
||||
else
|
||||
bits |= (PROBE_STRAFE | (m_jumpStateTimer < GetWorldTime () ? PROBE_JUMP : 0));
|
||||
bits |= (PROBE_STRAFE | (m_jumpStateTimer < engine.Time () ? PROBE_JUMP : 0));
|
||||
|
||||
// collision check allowed if not flying through the air
|
||||
if (IsOnFloor () || IsOnLadder () || IsInWater ())
|
||||
|
|
@ -439,7 +441,7 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal)
|
|||
state[i++] = COLLISION_STRAFELEFT;
|
||||
state[i++] = COLLISION_STRAFERIGHT;
|
||||
state[i++] = COLLISION_JUMP;
|
||||
// state[i++] = COLLISION_DUCK;
|
||||
state[i++] = COLLISION_DUCK;
|
||||
|
||||
if (bits & PROBE_STRAFE)
|
||||
{
|
||||
|
|
@ -468,7 +470,7 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal)
|
|||
src = pev->origin + g_pGlobals->v_right * 32.0f;
|
||||
dst = src + testDir * 32.0f;
|
||||
|
||||
TraceHull (src, dst, true, head_hull, GetEntity (), &tr);
|
||||
engine.TestHull (src, dst, TRACE_IGNORE_MONSTERS, head_hull, GetEntity (), &tr);
|
||||
|
||||
if (tr.flFraction != 1.0f)
|
||||
blockedRight = true;
|
||||
|
|
@ -476,7 +478,7 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal)
|
|||
src = pev->origin - g_pGlobals->v_right * 32.0f;
|
||||
dst = src + testDir * 32.0f;
|
||||
|
||||
TraceHull (src, dst, true, head_hull, GetEntity (), &tr);
|
||||
engine.TestHull (src, dst, TRACE_IGNORE_MONSTERS, head_hull, GetEntity (), &tr);
|
||||
|
||||
if (tr.flFraction != 1.0f)
|
||||
blockedLeft = true;
|
||||
|
|
@ -518,14 +520,14 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal)
|
|||
src = EyePosition ();
|
||||
src = src + g_pGlobals->v_right * 15.0f;
|
||||
|
||||
TraceLine (src, m_destOrigin, true, true, GetEntity (), &tr);
|
||||
engine.TestLine (src, m_destOrigin, TRACE_IGNORE_EVERYTHING, GetEntity (), &tr);
|
||||
|
||||
if (tr.flFraction >= 1.0f)
|
||||
{
|
||||
src = EyePosition ();
|
||||
src = src - g_pGlobals->v_right * 15.0f;
|
||||
|
||||
TraceLine (src, m_destOrigin, true, true, GetEntity (), &tr);
|
||||
engine.TestLine (src, m_destOrigin, TRACE_IGNORE_EVERYTHING, GetEntity (), &tr);
|
||||
|
||||
if (tr.flFraction >= 1.0f)
|
||||
state[i] += 5;
|
||||
|
|
@ -537,7 +539,7 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal)
|
|||
src = pev->origin + Vector (0.0f, 0.0f, -17.0f);
|
||||
|
||||
dst = src + dirNormal * 30.0f;
|
||||
TraceLine (src, dst, true, true, GetEntity (), &tr);
|
||||
engine.TestLine (src, dst, TRACE_IGNORE_EVERYTHING, GetEntity (), &tr);
|
||||
|
||||
if (tr.flFraction != 1.0f)
|
||||
state[i] += 10;
|
||||
|
|
@ -546,6 +548,7 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal)
|
|||
state[i] = 0;
|
||||
i++;
|
||||
|
||||
#if 0
|
||||
if (bits & PROBE_DUCK)
|
||||
{
|
||||
state[i] = 0;
|
||||
|
|
@ -557,7 +560,8 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal)
|
|||
state[i] += 5;
|
||||
}
|
||||
else
|
||||
state[i] = 0;
|
||||
#endif
|
||||
state[i] = 0;
|
||||
i++;
|
||||
|
||||
// weighted all possible moves, now sort them to start with most probable
|
||||
|
|
@ -588,8 +592,8 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal)
|
|||
for (i = 0; i < MAX_COLLIDE_MOVES; i++)
|
||||
m_collideMoves[i] = state[i];
|
||||
|
||||
m_collideTime = GetWorldTime ();
|
||||
m_probeTime = GetWorldTime () + 0.5f;
|
||||
m_collideTime = engine.Time ();
|
||||
m_probeTime = engine.Time () + 0.5f;
|
||||
m_collisionProbeBits = bits;
|
||||
m_collisionState = COLLISION_PROBING;
|
||||
m_collStateIndex = 0;
|
||||
|
|
@ -598,14 +602,14 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal)
|
|||
|
||||
if (m_collisionState == COLLISION_PROBING)
|
||||
{
|
||||
if (m_probeTime < GetWorldTime ())
|
||||
if (m_probeTime < engine.Time ())
|
||||
{
|
||||
m_collStateIndex++;
|
||||
m_probeTime = GetWorldTime () + 0.5f;
|
||||
m_probeTime = engine.Time () + 0.5f;
|
||||
|
||||
if (m_collStateIndex > MAX_COLLIDE_MOVES)
|
||||
{
|
||||
m_navTimeset = GetWorldTime () - 5.0f;
|
||||
m_navTimeset = engine.Time () - 5.0f;
|
||||
ResetCollideState ();
|
||||
}
|
||||
}
|
||||
|
|
@ -660,7 +664,7 @@ bool Bot::DoWaypointNav (void)
|
|||
MakeVectors (Vector (pev->angles.x, AngleNormalize (pev->angles.y + Random.Float (-90.0f, 90.0f)), 0.0f));
|
||||
m_waypointOrigin = m_waypointOrigin + g_pGlobals->v_forward * Random.Float (0, m_currentPath->radius);
|
||||
}
|
||||
m_navTimeset = GetWorldTime ();
|
||||
m_navTimeset = engine.Time ();
|
||||
}
|
||||
|
||||
if (pev->flags & FL_DUCKING)
|
||||
|
|
@ -715,26 +719,26 @@ bool Bot::DoWaypointNav (void)
|
|||
bool liftClosedDoorExists = false;
|
||||
|
||||
// update waypoint time set
|
||||
m_navTimeset = GetWorldTime ();
|
||||
m_navTimeset = engine.Time ();
|
||||
|
||||
// trace line to door
|
||||
TraceLine (pev->origin, m_currentPath->origin, true, true, GetEntity (), &tr2);
|
||||
engine.TestLine (pev->origin, m_currentPath->origin, TRACE_IGNORE_EVERYTHING, GetEntity (), &tr2);
|
||||
|
||||
if (tr2.flFraction < 1.0f && strcmp (STRING (tr2.pHit->v.classname), "func_door") == 0 && (m_liftState == LIFT_NO_NEARBY || m_liftState == LIFT_WAITING_FOR || m_liftState == LIFT_LOOKING_BUTTON_OUTSIDE) && pev->groundentity != tr2.pHit)
|
||||
{
|
||||
if (m_liftState == LIFT_NO_NEARBY)
|
||||
{
|
||||
m_liftState = LIFT_LOOKING_BUTTON_OUTSIDE;
|
||||
m_liftUsageTime = GetWorldTime () + 7.0;
|
||||
m_liftUsageTime = engine.Time () + 7.0;
|
||||
}
|
||||
liftClosedDoorExists = true;
|
||||
}
|
||||
|
||||
// trace line down
|
||||
TraceLine (m_currentPath->origin, m_currentPath->origin + Vector (0.0f, 0.0f, -50.0f), true, true, GetEntity (), &tr);
|
||||
engine.TestLine (m_currentPath->origin, m_currentPath->origin + Vector (0.0f, 0.0f, -50.0f), TRACE_IGNORE_EVERYTHING, GetEntity (), &tr);
|
||||
|
||||
// if trace result shows us that it is a lift
|
||||
if (!IsEntityNull (tr.pHit) && m_navNode != NULL && (strcmp (STRING (tr.pHit->v.classname), "func_door") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_plat") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_train") == 0) && !liftClosedDoorExists)
|
||||
if (!engine.IsNullEntity (tr.pHit) && m_navNode != NULL && (strcmp (STRING (tr.pHit->v.classname), "func_door") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_plat") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_train") == 0) && !liftClosedDoorExists)
|
||||
{
|
||||
if ((m_liftState == LIFT_NO_NEARBY || m_liftState == LIFT_WAITING_FOR || m_liftState == LIFT_LOOKING_BUTTON_OUTSIDE) && tr.pHit->v.velocity.z == 0.0f)
|
||||
{
|
||||
|
|
@ -743,13 +747,13 @@ bool Bot::DoWaypointNav (void)
|
|||
m_liftEntity = tr.pHit;
|
||||
m_liftState = LIFT_ENTERING_IN;
|
||||
m_liftTravelPos = m_currentPath->origin;
|
||||
m_liftUsageTime = GetWorldTime () + 5.0f;
|
||||
m_liftUsageTime = engine.Time () + 5.0f;
|
||||
}
|
||||
}
|
||||
else if (m_liftState == LIFT_TRAVELING_BY)
|
||||
{
|
||||
m_liftState = LIFT_LEAVING;
|
||||
m_liftUsageTime = GetWorldTime () + 7.0f;
|
||||
m_liftUsageTime = engine.Time () + 7.0f;
|
||||
}
|
||||
}
|
||||
else if (m_navNode != NULL) // no lift found at waypoint
|
||||
|
|
@ -758,13 +762,13 @@ bool Bot::DoWaypointNav (void)
|
|||
{
|
||||
if (m_navNode->next->index >= 0 && m_navNode->next->index < g_numWaypoints && (waypoints.GetPath (m_navNode->next->index)->flags & FLAG_LIFT))
|
||||
{
|
||||
TraceLine (m_currentPath->origin, waypoints.GetPath (m_navNode->next->index)->origin, true, true, GetEntity (), &tr);
|
||||
engine.TestLine (m_currentPath->origin, waypoints.GetPath (m_navNode->next->index)->origin, TRACE_IGNORE_EVERYTHING, GetEntity (), &tr);
|
||||
|
||||
if (!IsEntityNull (tr.pHit) && (strcmp (STRING (tr.pHit->v.classname), "func_door") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_plat") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_train") == 0))
|
||||
if (!engine.IsNullEntity (tr.pHit) && (strcmp (STRING (tr.pHit->v.classname), "func_door") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_plat") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_train") == 0))
|
||||
m_liftEntity = tr.pHit;
|
||||
}
|
||||
m_liftState = LIFT_LOOKING_BUTTON_OUTSIDE;
|
||||
m_liftUsageTime = GetWorldTime () + 15.0f;
|
||||
m_liftUsageTime = engine.Time () + 15.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -779,7 +783,7 @@ bool Bot::DoWaypointNav (void)
|
|||
m_moveSpeed = 0.0f;
|
||||
m_strafeSpeed = 0.0f;
|
||||
|
||||
m_navTimeset = GetWorldTime ();
|
||||
m_navTimeset = engine.Time ();
|
||||
m_aimFlags |= AIM_NAVPOINT;
|
||||
|
||||
ResetCollideState ();
|
||||
|
|
@ -788,14 +792,14 @@ bool Bot::DoWaypointNav (void)
|
|||
bool needWaitForTeammate = false;
|
||||
|
||||
// if some bot is following a bot going into lift - he should take the same lift to go
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
Bot *bot = bots.GetBot (i);
|
||||
|
||||
if (bot == NULL || bot == this)
|
||||
continue;
|
||||
|
||||
if (!IsAlive (bot->GetEntity ()) || GetTeam (bot->GetEntity ()) != m_team || bot->m_targetEntity != GetEntity () || bot->GetTaskId () != TASK_FOLLOWUSER)
|
||||
if (!bot->m_notKilled || bot->m_team != m_team || bot->m_targetEntity != GetEntity () || bot->GetTaskId () != TASK_FOLLOWUSER)
|
||||
continue;
|
||||
|
||||
if (bot->pev->groundentity == m_liftEntity && bot->IsOnFloor ())
|
||||
|
|
@ -811,12 +815,12 @@ bool Bot::DoWaypointNav (void)
|
|||
if (needWaitForTeammate)
|
||||
{
|
||||
m_liftState = LIFT_WAIT_FOR_TEAMMATES;
|
||||
m_liftUsageTime = GetWorldTime () + 8.0f;
|
||||
m_liftUsageTime = engine.Time () + 8.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_liftState = LIFT_LOOKING_BUTTON_INSIDE;
|
||||
m_liftUsageTime = GetWorldTime () + 10.0f;
|
||||
m_liftUsageTime = engine.Time () + 10.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -827,14 +831,14 @@ bool Bot::DoWaypointNav (void)
|
|||
// need to wait our following teammate ?
|
||||
bool needWaitForTeammate = false;
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
Bot *bot = bots.GetBot (i);
|
||||
|
||||
if (bot == NULL)
|
||||
continue; // skip invalid bots
|
||||
|
||||
if (!IsAlive (bot->GetEntity ()) || GetTeam (bot->GetEntity ()) != m_team || bot->m_targetEntity != GetEntity () || bot->GetTaskId () != TASK_FOLLOWUSER || bot->m_liftEntity != m_liftEntity)
|
||||
if (!bot->m_notKilled || bot->m_team != m_team || bot->m_targetEntity != GetEntity () || bot->GetTaskId () != TASK_FOLLOWUSER || bot->m_liftEntity != m_liftEntity)
|
||||
continue;
|
||||
|
||||
if (bot->pev->groundentity == m_liftEntity || !bot->IsOnFloor ())
|
||||
|
|
@ -854,7 +858,7 @@ bool Bot::DoWaypointNav (void)
|
|||
m_moveSpeed = 0.0f;
|
||||
m_strafeSpeed = 0.0f;
|
||||
|
||||
m_navTimeset = GetWorldTime ();
|
||||
m_navTimeset = engine.Time ();
|
||||
m_aimFlags |= AIM_NAVPOINT;
|
||||
|
||||
ResetCollideState ();
|
||||
|
|
@ -862,10 +866,10 @@ bool Bot::DoWaypointNav (void)
|
|||
}
|
||||
|
||||
// else we need to look for button
|
||||
if (!needWaitForTeammate || m_liftUsageTime < GetWorldTime ())
|
||||
if (!needWaitForTeammate || m_liftUsageTime < engine.Time ())
|
||||
{
|
||||
m_liftState = LIFT_LOOKING_BUTTON_INSIDE;
|
||||
m_liftUsageTime = GetWorldTime () + 10.0;
|
||||
m_liftUsageTime = engine.Time () + 10.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -875,29 +879,29 @@ bool Bot::DoWaypointNav (void)
|
|||
edict_t *button = FindNearestButton (STRING (m_liftEntity->v.targetname));
|
||||
|
||||
// got a valid button entity ?
|
||||
if (!IsEntityNull (button) && pev->groundentity == m_liftEntity && m_buttonPushTime + 1.0f < GetWorldTime () && m_liftEntity->v.velocity.z == 0.0f && IsOnFloor ())
|
||||
if (!engine.IsNullEntity (button) && pev->groundentity == m_liftEntity && m_buttonPushTime + 1.0f < engine.Time () && m_liftEntity->v.velocity.z == 0.0f && IsOnFloor ())
|
||||
{
|
||||
m_pickupItem = button;
|
||||
m_pickupType = PICKUP_BUTTON;
|
||||
|
||||
m_navTimeset = GetWorldTime ();
|
||||
m_navTimeset = engine.Time ();
|
||||
}
|
||||
}
|
||||
|
||||
// is lift activated and bot is standing on it and lift is moving ?
|
||||
if (m_liftState == LIFT_LOOKING_BUTTON_INSIDE || m_liftState == LIFT_ENTERING_IN || m_liftState == LIFT_WAIT_FOR_TEAMMATES || m_liftState == LIFT_WAITING_FOR)
|
||||
{
|
||||
if (pev->groundentity == m_liftEntity && m_liftEntity->v.velocity.z != 0.0f && IsOnFloor () && ((waypoints.GetPath (m_prevWptIndex[0])->flags & FLAG_LIFT) || !IsEntityNull (m_targetEntity)))
|
||||
if (pev->groundentity == m_liftEntity && m_liftEntity->v.velocity.z != 0.0f && IsOnFloor () && ((waypoints.GetPath (m_prevWptIndex[0])->flags & FLAG_LIFT) || !engine.IsNullEntity (m_targetEntity)))
|
||||
{
|
||||
m_liftState = LIFT_TRAVELING_BY;
|
||||
m_liftUsageTime = GetWorldTime () + 14.0f;
|
||||
m_liftUsageTime = engine.Time () + 14.0f;
|
||||
|
||||
if ((pev->origin - m_destOrigin).GetLengthSquared () < 225.0f)
|
||||
{
|
||||
m_moveSpeed = 0.0f;
|
||||
m_strafeSpeed = 0.0f;
|
||||
|
||||
m_navTimeset = GetWorldTime ();
|
||||
m_navTimeset = engine.Time ();
|
||||
m_aimFlags |= AIM_NAVPOINT;
|
||||
|
||||
ResetCollideState ();
|
||||
|
|
@ -915,7 +919,7 @@ bool Bot::DoWaypointNav (void)
|
|||
m_moveSpeed = 0.0f;
|
||||
m_strafeSpeed = 0.0f;
|
||||
|
||||
m_navTimeset = GetWorldTime ();
|
||||
m_navTimeset = engine.Time ();
|
||||
m_aimFlags |= AIM_NAVPOINT;
|
||||
|
||||
ResetCollideState ();
|
||||
|
|
@ -927,7 +931,7 @@ bool Bot::DoWaypointNav (void)
|
|||
{
|
||||
|
||||
// button has been pressed, lift should come
|
||||
if (m_buttonPushTime + 8.0f >= GetWorldTime ())
|
||||
if (m_buttonPushTime + 8.0f >= engine.Time ())
|
||||
{
|
||||
if (m_prevWptIndex[0] >= 0 && m_prevWptIndex[0] < g_numWaypoints)
|
||||
m_destOrigin = waypoints.GetPath (m_prevWptIndex[0])->origin;
|
||||
|
|
@ -939,26 +943,26 @@ bool Bot::DoWaypointNav (void)
|
|||
m_moveSpeed = 0.0f;
|
||||
m_strafeSpeed = 0.0f;
|
||||
|
||||
m_navTimeset = GetWorldTime ();
|
||||
m_navTimeset = engine.Time ();
|
||||
m_aimFlags |= AIM_NAVPOINT;
|
||||
|
||||
ResetCollideState ();
|
||||
}
|
||||
}
|
||||
else if (!IsEntityNull(m_liftEntity))
|
||||
else if (!engine.IsNullEntity(m_liftEntity))
|
||||
{
|
||||
edict_t *button = FindNearestButton (STRING (m_liftEntity->v.targetname));
|
||||
|
||||
// if we got a valid button entity
|
||||
if (!IsEntityNull (button))
|
||||
if (!engine.IsNullEntity (button))
|
||||
{
|
||||
// lift is already used ?
|
||||
bool liftUsed = false;
|
||||
|
||||
// iterate though clients, and find if lift already used
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || g_clients[i].team != m_team || g_clients[i].ent == GetEntity () || IsEntityNull (g_clients[i].ent->v.groundentity))
|
||||
if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || g_clients[i].team != m_team || g_clients[i].ent == GetEntity () || engine.IsNullEntity (g_clients[i].ent->v.groundentity))
|
||||
continue;
|
||||
|
||||
if (g_clients[i].ent->v.groundentity == m_liftEntity)
|
||||
|
|
@ -988,14 +992,14 @@ bool Bot::DoWaypointNav (void)
|
|||
m_pickupType = PICKUP_BUTTON;
|
||||
m_liftState = LIFT_WAITING_FOR;
|
||||
|
||||
m_navTimeset = GetWorldTime ();
|
||||
m_liftUsageTime = GetWorldTime () + 20.0f;
|
||||
m_navTimeset = engine.Time ();
|
||||
m_liftUsageTime = engine.Time () + 20.0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_liftState = LIFT_WAITING_FOR;
|
||||
m_liftUsageTime = GetWorldTime () + 15.0f;
|
||||
m_liftUsageTime = engine.Time () + 15.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1016,7 +1020,7 @@ bool Bot::DoWaypointNav (void)
|
|||
m_moveSpeed = 0.0f;
|
||||
m_strafeSpeed = 0.0f;
|
||||
|
||||
m_navTimeset = GetWorldTime ();
|
||||
m_navTimeset = engine.Time ();
|
||||
m_aimFlags |= AIM_NAVPOINT;
|
||||
|
||||
ResetCollideState ();
|
||||
|
|
@ -1047,14 +1051,14 @@ bool Bot::DoWaypointNav (void)
|
|||
}
|
||||
}
|
||||
|
||||
if (!IsEntityNull (m_liftEntity) && !(m_currentPath->flags & FLAG_LIFT))
|
||||
if (!engine.IsNullEntity (m_liftEntity) && !(m_currentPath->flags & FLAG_LIFT))
|
||||
{
|
||||
if (m_liftState == LIFT_TRAVELING_BY)
|
||||
{
|
||||
m_liftState = LIFT_LEAVING;
|
||||
m_liftUsageTime = GetWorldTime () + 10.0f;
|
||||
m_liftUsageTime = engine.Time () + 10.0f;
|
||||
}
|
||||
if (m_liftState == LIFT_LEAVING && m_liftUsageTime < GetWorldTime () && pev->groundentity != m_liftEntity)
|
||||
if (m_liftState == LIFT_LEAVING && m_liftUsageTime < engine.Time () && pev->groundentity != m_liftEntity)
|
||||
{
|
||||
m_liftState = LIFT_NO_NEARBY;
|
||||
m_liftUsageTime = 0.0f;
|
||||
|
|
@ -1063,7 +1067,7 @@ bool Bot::DoWaypointNav (void)
|
|||
}
|
||||
}
|
||||
|
||||
if (m_liftUsageTime < GetWorldTime () && m_liftUsageTime != 0.0f)
|
||||
if (m_liftUsageTime < engine.Time () && m_liftUsageTime != 0.0f)
|
||||
{
|
||||
m_liftEntity = NULL;
|
||||
m_liftState = LIFT_NO_NEARBY;
|
||||
|
|
@ -1085,12 +1089,12 @@ bool Bot::DoWaypointNav (void)
|
|||
}
|
||||
|
||||
// check if we are going through a door...
|
||||
TraceLine (pev->origin, m_waypointOrigin, true, GetEntity (), &tr);
|
||||
engine.TestLine (pev->origin, m_waypointOrigin, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
if (!IsEntityNull (tr.pHit) && IsEntityNull (m_liftEntity) && strncmp (STRING (tr.pHit->v.classname), "func_door", 9) == 0)
|
||||
if (!engine.IsNullEntity (tr.pHit) && engine.IsNullEntity (m_liftEntity) && strncmp (STRING (tr.pHit->v.classname), "func_door", 9) == 0)
|
||||
{
|
||||
// if the door is near enough...
|
||||
if ((GetEntityOrigin (tr.pHit) - pev->origin).GetLengthSquared () < 2500.0f)
|
||||
if ((engine.GetAbsOrigin (tr.pHit) - pev->origin).GetLengthSquared () < 2500.0f)
|
||||
{
|
||||
IgnoreCollisionShortly (); // don't consider being stuck
|
||||
|
||||
|
|
@ -1104,39 +1108,39 @@ bool Bot::DoWaypointNav (void)
|
|||
edict_t *button = FindNearestButton (STRING (tr.pHit->v.targetname));
|
||||
|
||||
// check if we got valid button
|
||||
if (!IsEntityNull (button))
|
||||
if (!engine.IsNullEntity (button))
|
||||
{
|
||||
m_pickupItem = button;
|
||||
m_pickupType = PICKUP_BUTTON;
|
||||
|
||||
m_navTimeset = GetWorldTime ();
|
||||
m_navTimeset = engine.Time ();
|
||||
}
|
||||
|
||||
// if bot hits the door, then it opens, so wait a bit to let it open safely
|
||||
if (pev->velocity.GetLength2D () < 2 && m_timeDoorOpen < GetWorldTime ())
|
||||
if (pev->velocity.GetLength2D () < 2 && m_timeDoorOpen < engine.Time ())
|
||||
{
|
||||
PushTask (TASK_PAUSE, TASKPRI_PAUSE, -1, GetWorldTime () + 1, false);
|
||||
PushTask (TASK_PAUSE, TASKPRI_PAUSE, -1, engine.Time () + 1, false);
|
||||
|
||||
m_doorOpenAttempt++;
|
||||
m_timeDoorOpen = GetWorldTime () + 1.0f; // retry in 1 sec until door is open
|
||||
m_timeDoorOpen = engine.Time () + 1.0f; // retry in 1 sec until door is open
|
||||
|
||||
edict_t *ent = NULL;
|
||||
|
||||
if (m_doorOpenAttempt > 2 && !IsEntityNull (ent = FIND_ENTITY_IN_SPHERE (ent, pev->origin, 256.0f)))
|
||||
if (m_doorOpenAttempt > 2 && !engine.IsNullEntity (ent = FIND_ENTITY_IN_SPHERE (ent, pev->origin, 512.0f)))
|
||||
{
|
||||
if (IsValidPlayer (ent) && IsAlive (ent) && m_team != GetTeam (ent) && GetWeaponPenetrationPower (m_currentWeapon) > 0)
|
||||
if (IsValidPlayer (ent) && IsAlive (ent) && m_team != engine.GetTeam (ent) && GetWeaponPenetrationPower (m_currentWeapon) > 0)
|
||||
{
|
||||
m_seeEnemyTime = GetWorldTime ();
|
||||
m_seeEnemyTime = engine.Time () - 0.5f;
|
||||
|
||||
m_states |= STATE_SUSPECT_ENEMY;
|
||||
m_aimFlags |= AIM_LAST_ENEMY;
|
||||
m_states |= STATE_SEEING_ENEMY;
|
||||
m_aimFlags |= AIM_ENEMY;
|
||||
|
||||
m_lastEnemy = ent;
|
||||
m_enemy = ent;
|
||||
m_lastEnemyOrigin = ent->v.origin;
|
||||
|
||||
}
|
||||
else if (IsValidPlayer (ent) && IsAlive (ent) && m_team == GetTeam (ent))
|
||||
else if (IsValidPlayer (ent) && IsAlive (ent) && m_team == engine.GetTeam (ent))
|
||||
{
|
||||
DeleteSearchNodes ();
|
||||
ResetTasks ();
|
||||
|
|
@ -1406,7 +1410,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
float gfunctionKillsDistT (int currentIndex, int parentIndex)
|
||||
{
|
||||
// least kills and number of nodes to goal for a team
|
||||
|
|
@ -1923,7 +1926,7 @@ bool Bot::FindWaypoint (void)
|
|||
waypointIndeces[i] = Random.Long (0, g_numWaypoints - 1);
|
||||
}
|
||||
|
||||
m_collideTime = GetWorldTime ();
|
||||
m_collideTime = engine.Time ();
|
||||
ChangeWptIndex (waypointIndeces[i]);
|
||||
|
||||
return true;
|
||||
|
|
@ -1943,7 +1946,7 @@ void Bot::GetValidWaypoint (void)
|
|||
|
||||
// FIXME: Do some error checks if we got a waypoint
|
||||
}
|
||||
else if (m_navTimeset + GetEstimatedReachTime () < GetWorldTime () && IsEntityNull (m_enemy))
|
||||
else if (m_navTimeset + GetEstimatedReachTime () < engine.Time () && engine.IsNullEntity (m_enemy))
|
||||
{
|
||||
if (m_team == TERRORIST)
|
||||
{
|
||||
|
|
@ -2034,7 +2037,7 @@ int Bot::ChangeWptIndex(int waypointIndex)
|
|||
m_prevWptIndex[0] = m_currentWaypointIndex;
|
||||
|
||||
m_currentWaypointIndex = waypointIndex;
|
||||
m_navTimeset = GetWorldTime ();
|
||||
m_navTimeset = engine.Time ();
|
||||
|
||||
m_currentPath = waypoints.GetPath (m_currentWaypointIndex);
|
||||
m_waypointFlags = m_currentPath->flags;
|
||||
|
|
@ -2119,7 +2122,7 @@ int Bot::FindDefendWaypoint (const Vector &origin)
|
|||
if (distance > 512)
|
||||
continue;
|
||||
|
||||
TraceLine (waypoints.GetPath (i)->origin, waypoints.GetPath (posIndex)->origin, true, true, GetEntity (), &tr);
|
||||
engine.TestLine (waypoints.GetPath (i)->origin, waypoints.GetPath (posIndex)->origin, TRACE_IGNORE_EVERYTHING, GetEntity (), &tr);
|
||||
|
||||
// check if line not hit anything
|
||||
if (tr.flFraction != 1.0f)
|
||||
|
|
@ -2331,7 +2334,7 @@ int Bot::FindCoverWaypoint (float maxDistance)
|
|||
{
|
||||
if (waypointIndex[i] != -1)
|
||||
{
|
||||
TraceLine (m_lastEnemyOrigin + Vector (0.0f, 0.0f, 36.0f), waypoints.GetPath (waypointIndex[i])->origin, true, true, GetEntity (), &tr);
|
||||
engine.TestLine (m_lastEnemyOrigin + Vector (0.0f, 0.0f, 36.0f), waypoints.GetPath (waypointIndex[i])->origin, TRACE_IGNORE_EVERYTHING, GetEntity (), &tr);
|
||||
|
||||
if (tr.flFraction < 1.0f)
|
||||
return waypointIndex[i];
|
||||
|
|
@ -2400,7 +2403,7 @@ bool Bot::HeadTowardWaypoint (void)
|
|||
m_minSpeed = pev->maxspeed;
|
||||
|
||||
// only if we in normal task and bomb is not planted
|
||||
if (GetTaskId () == TASK_NORMAL && g_timeRoundMid + 5.0f < GetWorldTime () && m_timeCamping + 5.0f < GetWorldTime () && !g_bombPlanted && m_personality != PERSONALITY_RUSHER && !m_hasC4 && !m_isVIP && m_loosedBombWptIndex == -1 && !HasHostage ())
|
||||
if (GetTaskId () == TASK_NORMAL && g_timeRoundMid + 5.0f < engine.Time () && m_timeCamping + 5.0f < engine.Time () && !g_bombPlanted && m_personality != PERSONALITY_RUSHER && !m_hasC4 && !m_isVIP && m_loosedBombWptIndex == -1 && !HasHostage ())
|
||||
{
|
||||
m_campButtons = 0;
|
||||
|
||||
|
|
@ -2413,7 +2416,7 @@ bool Bot::HeadTowardWaypoint (void)
|
|||
kills = (g_experienceData + (nextIndex * g_numWaypoints) + nextIndex)->team1Damage;
|
||||
|
||||
// if damage done higher than one
|
||||
if (kills > 1.0f && g_timeRoundMid > GetWorldTime ())
|
||||
if (kills > 1.0f && g_timeRoundMid > engine.Time ())
|
||||
{
|
||||
switch (m_personality)
|
||||
{
|
||||
|
|
@ -2428,8 +2431,8 @@ bool Bot::HeadTowardWaypoint (void)
|
|||
|
||||
if (m_baseAgressionLevel < kills && HasPrimaryWeapon ())
|
||||
{
|
||||
PushTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (m_difficulty * 0.5f, m_difficulty) * 5.0f, true);
|
||||
PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, FindDefendWaypoint (waypoints.GetPath (nextIndex)->origin), GetWorldTime () + Random.Float (3.0f, 10.0f), true);
|
||||
PushTask (TASK_CAMP, TASKPRI_CAMP, -1, engine.Time () + Random.Float (m_difficulty * 0.5f, m_difficulty) * 5.0f, true);
|
||||
PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, FindDefendWaypoint (waypoints.GetPath (nextIndex)->origin), engine.Time () + Random.Float (3.0f, 10.0f), true);
|
||||
}
|
||||
}
|
||||
else if (g_botsCanPause && !IsOnLadder () && !IsInWater () && !m_currentTravelFlags && IsOnFloor ())
|
||||
|
|
@ -2490,21 +2493,21 @@ bool Bot::HeadTowardWaypoint (void)
|
|||
}
|
||||
|
||||
// is there a jump waypoint right ahead and do we need to draw out the light weapon ?
|
||||
if (willJump && m_currentWeapon != WEAPON_KNIFE && m_currentWeapon != WEAPON_SCOUT && !m_isReloading && !UsesPistol () && (jumpDistance > 210.0f || (dst.z + 32.0f > src.z && jumpDistance > 150.0f) || ((dst - src).GetLength2D () < 60.0f && jumpDistance > 60.0f)) && IsEntityNull (m_enemy))
|
||||
if (willJump && m_currentWeapon != WEAPON_KNIFE && m_currentWeapon != WEAPON_SCOUT && !m_isReloading && !UsesPistol () && (jumpDistance > 210.0f || (dst.z + 32.0f > src.z && jumpDistance > 150.0f) || ((dst - src).GetLength2D () < 60.0f && jumpDistance > 60.0f)) && engine.IsNullEntity (m_enemy))
|
||||
SelectWeaponByName ("weapon_knife"); // draw out the knife if we needed
|
||||
|
||||
// bot not already on ladder but will be soon?
|
||||
if ((waypoints.GetPath (destIndex)->flags & FLAG_LADDER) && !IsOnLadder ())
|
||||
{
|
||||
// get ladder waypoints used by other (first moving) bots
|
||||
for (int c = 0; c < GetMaxClients (); c++)
|
||||
for (int c = 0; c < engine.MaxClients (); c++)
|
||||
{
|
||||
Bot *otherBot = bots.GetBot (c);
|
||||
|
||||
// if another bot uses this ladder, wait 3 secs
|
||||
if (otherBot != NULL && otherBot != this && IsAlive (otherBot->GetEntity ()) && otherBot->m_currentWaypointIndex == m_navNode->index)
|
||||
{
|
||||
PushTask (TASK_PAUSE, TASKPRI_PAUSE, -1, GetWorldTime () + 3.0f, false);
|
||||
PushTask (TASK_PAUSE, TASKPRI_PAUSE, -1, engine.Time () + 3.0f, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -2524,12 +2527,12 @@ bool Bot::HeadTowardWaypoint (void)
|
|||
|
||||
if (IsOnLadder ())
|
||||
{
|
||||
TraceLine (Vector (pev->origin.x, pev->origin.y, pev->absmin.z), m_waypointOrigin, true, true, GetEntity (), &tr);
|
||||
engine.TestLine (Vector (pev->origin.x, pev->origin.y, pev->absmin.z), m_waypointOrigin, TRACE_IGNORE_EVERYTHING, GetEntity (), &tr);
|
||||
|
||||
if (tr.flFraction < 1.0f)
|
||||
m_waypointOrigin = m_waypointOrigin + (pev->origin - m_waypointOrigin) * 0.5f + Vector (0.0f, 0.0f, 32.0f);
|
||||
}
|
||||
m_navTimeset = GetWorldTime ();
|
||||
m_navTimeset = engine.Time ();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2547,7 +2550,7 @@ bool Bot::CantMoveForward (const Vector &normal, TraceResult *tr)
|
|||
MakeVectors (Vector (0.0f, pev->angles.y, 0.0f));
|
||||
|
||||
// trace from the bot's eyes straight forward...
|
||||
TraceLine (src, forward, true, GetEntity (), tr);
|
||||
engine.TestLine (src, forward, TRACE_IGNORE_MONSTERS, GetEntity (), tr);
|
||||
|
||||
// check if the trace hit something...
|
||||
if (tr->flFraction < 1.0f)
|
||||
|
|
@ -2563,7 +2566,7 @@ bool Bot::CantMoveForward (const Vector &normal, TraceResult *tr)
|
|||
src = EyePosition () + Vector (0.0f, 0.0f, -16.0f) - g_pGlobals->v_right * -16.0f;
|
||||
forward = EyePosition () + Vector (0.0f, 0.0f, -16.0f) + g_pGlobals->v_right * 16.0f + normal * 24.0f;
|
||||
|
||||
TraceLine (src, forward, true, GetEntity (), tr);
|
||||
engine.TestLine (src, forward, TRACE_IGNORE_MONSTERS, GetEntity (), tr);
|
||||
|
||||
// check if the trace hit something...
|
||||
if (tr->flFraction < 1.0f && strncmp ("func_door", STRING (tr->pHit->v.classname), 9) != 0)
|
||||
|
|
@ -2574,7 +2577,7 @@ bool Bot::CantMoveForward (const Vector &normal, TraceResult *tr)
|
|||
src = EyePosition () + Vector (0.0f, 0.0f, -16.0f) + g_pGlobals->v_right * 16.0f;
|
||||
forward = EyePosition () + Vector (0.0f, 0.0f, -16.0f) - g_pGlobals->v_right * -16.0f + normal * 24.0f;
|
||||
|
||||
TraceLine (src, forward, true, GetEntity (), tr);
|
||||
engine.TestLine (src, forward, TRACE_IGNORE_MONSTERS, GetEntity (), tr);
|
||||
|
||||
// check if the trace hit something...
|
||||
if (tr->flFraction < 1.0f && strncmp ("func_door", STRING (tr->pHit->v.classname), 9) != 0)
|
||||
|
|
@ -2586,7 +2589,7 @@ bool Bot::CantMoveForward (const Vector &normal, TraceResult *tr)
|
|||
src = pev->origin + Vector (0.0f, 0.0f, -19.0f + 19.0f);
|
||||
forward = src + Vector (0.0f, 0.0f, 10.0f) + normal * 24.0f;
|
||||
|
||||
TraceLine (src, forward, true, GetEntity (), tr);
|
||||
engine.TestLine (src, forward, TRACE_IGNORE_MONSTERS, GetEntity (), tr);
|
||||
|
||||
// check if the trace hit something...
|
||||
if (tr->flFraction < 1.0f && strncmp ("func_door", STRING (tr->pHit->v.classname), 9) != 0)
|
||||
|
|
@ -2595,7 +2598,7 @@ bool Bot::CantMoveForward (const Vector &normal, TraceResult *tr)
|
|||
src = pev->origin;
|
||||
forward = src + normal * 24.0f;
|
||||
|
||||
TraceLine (src, forward, true, GetEntity (), tr);
|
||||
engine.TestLine (src, forward, TRACE_IGNORE_MONSTERS, GetEntity (), tr);
|
||||
|
||||
// check if the trace hit something...
|
||||
if (tr->flFraction < 1.0f && strncmp ("func_door", STRING (tr->pHit->v.classname), 9) != 0)
|
||||
|
|
@ -2608,7 +2611,7 @@ bool Bot::CantMoveForward (const Vector &normal, TraceResult *tr)
|
|||
forward = pev->origin + Vector (0.0f, 0.0f, -17.0f) + g_pGlobals->v_right * 16.0f + normal * 24.0f;
|
||||
|
||||
// trace from the bot's waist straight forward...
|
||||
TraceLine (src, forward, true, GetEntity (), tr);
|
||||
engine.TestLine (src, forward, TRACE_IGNORE_MONSTERS, GetEntity (), tr);
|
||||
|
||||
// check if the trace hit something...
|
||||
if (tr->flFraction < 1.0f && strncmp ("func_door", STRING (tr->pHit->v.classname), 9) != 0)
|
||||
|
|
@ -2618,7 +2621,7 @@ bool Bot::CantMoveForward (const Vector &normal, TraceResult *tr)
|
|||
src = pev->origin + Vector (0.0f, 0.0f, -17.0f) + g_pGlobals->v_right * 16.0f;
|
||||
forward = pev->origin + Vector (0.0f, 0.0f, -17.0f) - g_pGlobals->v_right * -16.0f + normal * 24.0f;
|
||||
|
||||
TraceLine (src, forward, true, GetEntity (), tr);
|
||||
engine.TestLine (src, forward, TRACE_IGNORE_MONSTERS, GetEntity (), tr);
|
||||
|
||||
// check if the trace hit something...
|
||||
if (tr->flFraction < 1.0f && strncmp ("func_door", STRING (tr->pHit->v.classname), 9) != 0)
|
||||
|
|
@ -2706,7 +2709,7 @@ bool Bot::CanJumpUp (const Vector &normal)
|
|||
Vector dest = src + normal * 32.0f;
|
||||
|
||||
// trace a line forward at maximum jump height...
|
||||
TraceLine (src, dest, true, GetEntity (), &tr);
|
||||
engine.TestLine (src, dest, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
if (tr.flFraction < 1.0f)
|
||||
goto CheckDuckJump;
|
||||
|
|
@ -2716,7 +2719,7 @@ bool Bot::CanJumpUp (const Vector &normal)
|
|||
src = dest;
|
||||
dest.z = dest.z + 37.0f;
|
||||
|
||||
TraceLine (src, dest, true, GetEntity (), &tr);
|
||||
engine.TestLine (src, dest, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
if (tr.flFraction < 1.0f)
|
||||
return false;
|
||||
|
|
@ -2727,7 +2730,7 @@ bool Bot::CanJumpUp (const Vector &normal)
|
|||
dest = src + normal * 32.0f;
|
||||
|
||||
// trace a line forward at maximum jump height...
|
||||
TraceLine (src, dest, true, GetEntity (), &tr);
|
||||
engine.TestLine (src, dest, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
// if trace hit something, return false
|
||||
if (tr.flFraction < 1.0f)
|
||||
|
|
@ -2737,7 +2740,7 @@ bool Bot::CanJumpUp (const Vector &normal)
|
|||
src = dest;
|
||||
dest.z = dest.z + 37.0f;
|
||||
|
||||
TraceLine (src, dest, true, GetEntity (), &tr);
|
||||
engine.TestLine (src, dest, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
// if trace hit something, return false
|
||||
if (tr.flFraction < 1.0f)
|
||||
|
|
@ -2748,7 +2751,7 @@ bool Bot::CanJumpUp (const Vector &normal)
|
|||
dest = src + normal * 32.0f;
|
||||
|
||||
// trace a line forward at maximum jump height...
|
||||
TraceLine (src, dest, true, GetEntity (), &tr);
|
||||
engine.TestLine (src, dest, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
// if trace hit something, return false
|
||||
if (tr.flFraction < 1.0f)
|
||||
|
|
@ -2758,7 +2761,7 @@ bool Bot::CanJumpUp (const Vector &normal)
|
|||
src = dest;
|
||||
dest.z = dest.z + 37.0f;
|
||||
|
||||
TraceLine (src, dest, true, GetEntity (), &tr);
|
||||
engine.TestLine (src, dest, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
// if trace hit something, return false
|
||||
return tr.flFraction > 1.0f;
|
||||
|
|
@ -2771,7 +2774,7 @@ CheckDuckJump:
|
|||
dest = src + normal * 32.0f;
|
||||
|
||||
// trace a line forward at maximum jump height...
|
||||
TraceLine (src, dest, true, GetEntity (), &tr);
|
||||
engine.TestLine (src, dest, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
if (tr.flFraction < 1.0f)
|
||||
return false;
|
||||
|
|
@ -2781,7 +2784,7 @@ CheckDuckJump:
|
|||
src = dest;
|
||||
dest.z = dest.z + 37.0f;
|
||||
|
||||
TraceLine (src, dest, true, GetEntity (), &tr);
|
||||
engine.TestLine (src, dest, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
// if trace hit something, check duckjump
|
||||
if (tr.flFraction < 1.0f)
|
||||
|
|
@ -2793,7 +2796,7 @@ CheckDuckJump:
|
|||
dest = src + normal * 32.0f;
|
||||
|
||||
// trace a line forward at maximum jump height...
|
||||
TraceLine (src, dest, true, GetEntity (), &tr);
|
||||
engine.TestLine (src, dest, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
// if trace hit something, return false
|
||||
if (tr.flFraction < 1.0f)
|
||||
|
|
@ -2803,7 +2806,7 @@ CheckDuckJump:
|
|||
src = dest;
|
||||
dest.z = dest.z + 37.0f;
|
||||
|
||||
TraceLine (src, dest, true, GetEntity (), &tr);
|
||||
engine.TestLine (src, dest, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
// if trace hit something, return false
|
||||
if (tr.flFraction < 1.0f)
|
||||
|
|
@ -2814,7 +2817,7 @@ CheckDuckJump:
|
|||
dest = src + normal * 32.0f;
|
||||
|
||||
// trace a line forward at maximum jump height...
|
||||
TraceLine (src, dest, true, GetEntity (), &tr);
|
||||
engine.TestLine (src, dest, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
// if trace hit something, return false
|
||||
if (tr.flFraction < 1.0f)
|
||||
|
|
@ -2824,7 +2827,7 @@ CheckDuckJump:
|
|||
src = dest;
|
||||
dest.z = dest.z + 37.0f;
|
||||
|
||||
TraceLine (src, dest, true, GetEntity (), &tr);
|
||||
engine.TestLine (src, dest, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
// if trace hit something, return false
|
||||
return tr.flFraction > 1.0f;
|
||||
|
|
@ -2850,7 +2853,7 @@ bool Bot::CanDuckUnder (const Vector &normal)
|
|||
Vector dest = src + normal * 32.0f;
|
||||
|
||||
// trace a line forward at duck height...
|
||||
TraceLine (src, dest, true, GetEntity (), &tr);
|
||||
engine.TestLine (src, dest, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
// if trace hit something, return false
|
||||
if (tr.flFraction < 1.0f)
|
||||
|
|
@ -2861,7 +2864,7 @@ bool Bot::CanDuckUnder (const Vector &normal)
|
|||
dest = src + normal * 32.0f;
|
||||
|
||||
// trace a line forward at duck height...
|
||||
TraceLine (src, dest, true, GetEntity (), &tr);
|
||||
engine.TestLine (src, dest, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
// if trace hit something, return false
|
||||
if (tr.flFraction < 1.0f)
|
||||
|
|
@ -2872,7 +2875,7 @@ bool Bot::CanDuckUnder (const Vector &normal)
|
|||
dest = src + normal * 32.0f;
|
||||
|
||||
// trace a line forward at duck height...
|
||||
TraceLine (src, dest, true, GetEntity (), &tr);
|
||||
engine.TestLine (src, dest, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
// if trace hit something, return false
|
||||
return tr.flFraction > 1.0f;
|
||||
|
|
@ -2891,7 +2894,7 @@ bool Bot::IsBlockedLeft (void)
|
|||
MakeVectors (pev->angles);
|
||||
|
||||
// do a trace to the left...
|
||||
TraceLine (pev->origin, g_pGlobals->v_forward * direction - g_pGlobals->v_right * 48.0f, true, GetEntity (), &tr);
|
||||
engine.TestLine (pev->origin, g_pGlobals->v_forward * direction - g_pGlobals->v_right * 48.0f, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
// check if the trace hit something...
|
||||
if (tr.flFraction < 1.0f && strncmp ("func_door", STRING (tr.pHit->v.classname), 9) != 0)
|
||||
|
|
@ -2911,7 +2914,7 @@ bool Bot::IsBlockedRight (void)
|
|||
MakeVectors (pev->angles);
|
||||
|
||||
// do a trace to the right...
|
||||
TraceLine (pev->origin, pev->origin + g_pGlobals->v_forward * direction + g_pGlobals->v_right * 48.0f, true, GetEntity (), &tr);
|
||||
engine.TestLine (pev->origin, pev->origin + g_pGlobals->v_forward * direction + g_pGlobals->v_right * 48.0f, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
// check if the trace hit something...
|
||||
if (tr.flFraction < 1.0f && (strncmp ("func_door", STRING (tr.pHit->v.classname), 9) != 0))
|
||||
|
|
@ -2927,7 +2930,7 @@ bool Bot::CheckWallOnLeft (void)
|
|||
TraceResult tr;
|
||||
MakeVectors (pev->angles);
|
||||
|
||||
TraceLine (pev->origin, pev->origin - g_pGlobals->v_right * 40.0f, true, GetEntity (), &tr);
|
||||
engine.TestLine (pev->origin, pev->origin - g_pGlobals->v_right * 40.0f, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
// check if the trace hit something...
|
||||
if (tr.flFraction < 1.0f)
|
||||
|
|
@ -2942,7 +2945,7 @@ bool Bot::CheckWallOnRight (void)
|
|||
MakeVectors (pev->angles);
|
||||
|
||||
// do a trace to the right...
|
||||
TraceLine (pev->origin, pev->origin + g_pGlobals->v_right * 40.0f, true, GetEntity (), &tr);
|
||||
engine.TestLine (pev->origin, pev->origin + g_pGlobals->v_right * 40.0f, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
|
||||
|
||||
// check if the trace hit something...
|
||||
if (tr.flFraction < 1.0f)
|
||||
|
|
@ -2967,7 +2970,7 @@ bool Bot::IsDeadlyDrop (const Vector &to)
|
|||
|
||||
down.z = down.z - 1000.0f; // straight down 1000 units
|
||||
|
||||
TraceHull (check, down, true, head_hull, GetEntity (), &tr);
|
||||
engine.TestHull (check, down, TRACE_IGNORE_MONSTERS, head_hull, GetEntity (), &tr);
|
||||
|
||||
if (tr.flFraction > 0.036f) // we're not on ground anymore?
|
||||
tr.flFraction = 0.036f;
|
||||
|
|
@ -2983,7 +2986,7 @@ bool Bot::IsDeadlyDrop (const Vector &to)
|
|||
down = check;
|
||||
down.z = down.z - 1000.0f; // straight down 1000 units
|
||||
|
||||
TraceHull (check, down, true, head_hull, GetEntity (), &tr);
|
||||
engine.TestHull (check, down, TRACE_IGNORE_MONSTERS, head_hull, GetEntity (), &tr);
|
||||
|
||||
if (tr.fStartSolid) // Wall blocking?
|
||||
return false;
|
||||
|
|
@ -3132,8 +3135,8 @@ void Bot::UpdateBodyAngles (void)
|
|||
|
||||
void Bot::UpdateLookAngles (void)
|
||||
{
|
||||
const float delta = Clamp <float> (GetWorldTime () - m_lookUpdateTime, MATH_EQEPSILON, 0.05f);
|
||||
m_lookUpdateTime = GetWorldTime ();
|
||||
const float delta = Clamp <float> (engine.Time () - m_lookUpdateTime, MATH_EQEPSILON, 0.05f);
|
||||
m_lookUpdateTime = engine.Time ();
|
||||
|
||||
// adjust all body and view angles to face an absolute vector
|
||||
Vector direction = (m_lookAt - EyePosition ()).ToAngles ();
|
||||
|
|
@ -3226,7 +3229,7 @@ void Bot::UpdateLookAnglesLowSkill (const Vector &direction, const float delta)
|
|||
|
||||
if (m_aimFlags & (AIM_ENEMY | AIM_ENTITY | AIM_GRENADE | AIM_LAST_ENEMY) || GetTaskId () == TASK_SHOOTBREAKABLE)
|
||||
{
|
||||
m_playerTargetTime = GetWorldTime ();
|
||||
m_playerTargetTime = engine.Time ();
|
||||
m_randomizedIdealAngles = m_idealAngles;
|
||||
|
||||
stiffness = spring * (0.2f + (m_difficulty * 25) / 125.0f);
|
||||
|
|
@ -3234,7 +3237,7 @@ void Bot::UpdateLookAnglesLowSkill (const Vector &direction, const float delta)
|
|||
else
|
||||
{
|
||||
// is it time for bot to randomize the aim direction again (more often where moving) ?
|
||||
if (m_randomizeAnglesTime < GetWorldTime () && ((pev->velocity.GetLength () > 1.0f && m_angularDeviation.GetLength () < 5.0f) || m_angularDeviation.GetLength () < 1.0f))
|
||||
if (m_randomizeAnglesTime < engine.Time () && ((pev->velocity.GetLength () > 1.0f && m_angularDeviation.GetLength () < 5.0f) || m_angularDeviation.GetLength () < 1.0f))
|
||||
{
|
||||
// is the bot standing still ?
|
||||
if (pev->velocity.GetLength () < 1.0f)
|
||||
|
|
@ -3246,14 +3249,14 @@ void Bot::UpdateLookAnglesLowSkill (const Vector &direction, const float delta)
|
|||
m_randomizedIdealAngles = m_idealAngles + Vector (Random.Float (-randomize.x * 0.5f, randomize.x * 1.5f), Random.Float (-randomize.y, randomize.y), 0.0f);
|
||||
|
||||
// set next time to do this
|
||||
m_randomizeAnglesTime = GetWorldTime () + Random.Float (0.4f, offsetDelay);
|
||||
m_randomizeAnglesTime = engine.Time () + Random.Float (0.4f, offsetDelay);
|
||||
}
|
||||
float stiffnessMultiplier = noTargetRatio;
|
||||
|
||||
// take in account whether the bot was targeting someone in the last N seconds
|
||||
if (GetWorldTime () - (m_playerTargetTime + offsetDelay) < noTargetRatio * 10.0f)
|
||||
if (engine.Time () - (m_playerTargetTime + offsetDelay) < noTargetRatio * 10.0f)
|
||||
{
|
||||
stiffnessMultiplier = 1.0f - (GetWorldTime () - m_timeLastFired) * 0.1f;
|
||||
stiffnessMultiplier = 1.0f - (engine.Time () - m_timeLastFired) * 0.1f;
|
||||
|
||||
// don't allow that stiffness multiplier less than zero
|
||||
if (stiffnessMultiplier < 0.0f)
|
||||
|
|
@ -3310,11 +3313,11 @@ int Bot::FindPlantedBomb (void)
|
|||
edict_t *bombEntity = NULL; // temporaly pointer to bomb
|
||||
|
||||
// search the bomb on the map
|
||||
while (!IsEntityNull (bombEntity = FIND_ENTITY_BY_CLASSNAME (bombEntity, "grenade")))
|
||||
while (!engine.IsNullEntity (bombEntity = FIND_ENTITY_BY_CLASSNAME (bombEntity, "grenade")))
|
||||
{
|
||||
if (strcmp (STRING (bombEntity->v.model) + 9, "c4.mdl") == 0)
|
||||
{
|
||||
int nearestIndex = waypoints.FindNearest (GetEntityOrigin (bombEntity));
|
||||
int nearestIndex = waypoints.FindNearest (engine.GetAbsOrigin (bombEntity));
|
||||
|
||||
if (nearestIndex >= 0 && nearestIndex < g_numWaypoints)
|
||||
return nearestIndex;
|
||||
|
|
@ -3331,7 +3334,7 @@ bool Bot::IsPointOccupied (int index)
|
|||
return true;
|
||||
|
||||
// first check if current waypoint of one of the bots is index waypoint
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
Bot *bot = bots.GetBot (i);
|
||||
|
||||
|
|
@ -3341,7 +3344,7 @@ bool Bot::IsPointOccupied (int index)
|
|||
// check if this waypoint is already used
|
||||
// TODO: take in account real players
|
||||
|
||||
if (bot->m_notKilled)
|
||||
if (bot->m_notKilled && m_currentWaypointIndex != -1 && bot->m_prevWptIndex[0] != -1)
|
||||
{
|
||||
int occupyId = GetShootingConeDeviation (bot->GetEntity (), &pev->origin) >= 0.7f ? bot->m_prevWptIndex[0] : m_currentWaypointIndex;
|
||||
|
||||
|
|
@ -3367,9 +3370,9 @@ edict_t *Bot::FindNearestButton (const char *targetName)
|
|||
edict_t *searchEntity = NULL, *foundEntity = NULL;
|
||||
|
||||
// find the nearest button which can open our target
|
||||
while (!IsEntityNull(searchEntity = FIND_ENTITY_BY_TARGET (searchEntity, targetName)))
|
||||
while (!engine.IsNullEntity(searchEntity = FIND_ENTITY_BY_TARGET (searchEntity, targetName)))
|
||||
{
|
||||
Vector entityOrign = GetEntityOrigin (searchEntity);
|
||||
Vector entityOrign = engine.GetAbsOrigin (searchEntity);
|
||||
|
||||
// check if this place safe
|
||||
if (!IsDeadlyDrop (entityOrign))
|
||||
|
|
|
|||
|
|
@ -1,499 +0,0 @@
|
|||
//
|
||||
// Yet Another POD-Bot, based on PODBot by Markus Klinge ("CountFloyd").
|
||||
// Copyright (c) YaPB Development Team.
|
||||
//
|
||||
// This software is licensed under the BSD-style license.
|
||||
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
||||
// http://yapb.jeefo.net/license
|
||||
//
|
||||
|
||||
#include <core.h>
|
||||
|
||||
NetworkMsg::NetworkMsg (void)
|
||||
{
|
||||
m_message = NETMSG_UNDEFINED;
|
||||
m_state = 0;
|
||||
m_bot = NULL;
|
||||
|
||||
for (int i = 0; i < NETMSG_BOTVOICE; i++)
|
||||
m_registerdMessages[i] = -1;
|
||||
}
|
||||
|
||||
void NetworkMsg::HandleMessageIfRequired (int messageType, int requiredType)
|
||||
{
|
||||
if (messageType == m_registerdMessages[requiredType])
|
||||
SetMessage (requiredType);
|
||||
}
|
||||
|
||||
void NetworkMsg::Execute (void *p)
|
||||
{
|
||||
if (m_message == NETMSG_UNDEFINED)
|
||||
return; // no message or not for bot, return
|
||||
|
||||
// some needed variables
|
||||
static byte r, g, b;
|
||||
static byte enabled;
|
||||
|
||||
static int damageArmor, damageTaken, damageBits;
|
||||
static int killerIndex, victimIndex, playerIndex;
|
||||
static int index, numPlayers;
|
||||
static int state, id, clip;
|
||||
|
||||
static Vector damageOrigin;
|
||||
static WeaponProperty weaponProp;
|
||||
|
||||
// now starts of netmessage execution
|
||||
switch (m_message)
|
||||
{
|
||||
case NETMSG_VGUI:
|
||||
// this message is sent when a VGUI menu is displayed.
|
||||
|
||||
if (m_state == 0)
|
||||
{
|
||||
switch (PTR_TO_INT (p))
|
||||
{
|
||||
case VMS_TEAM:
|
||||
m_bot->m_startAction = GSM_TEAM_SELECT;
|
||||
break;
|
||||
|
||||
case VMS_TF:
|
||||
case VMS_CT:
|
||||
m_bot->m_startAction = GSM_CLASS_SELECT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NETMSG_SHOWMENU:
|
||||
// this message is sent when a text menu is displayed.
|
||||
|
||||
if (m_state < 3) // ignore first 3 fields of message
|
||||
break;
|
||||
|
||||
if (strcmp (PTR_TO_STR (p), "#Team_Select") == 0) // team select menu?
|
||||
m_bot->m_startAction = GSM_TEAM_SELECT;
|
||||
else if (strcmp (PTR_TO_STR (p), "#Team_Select_Spect") == 0) // team select menu?
|
||||
m_bot->m_startAction = GSM_TEAM_SELECT;
|
||||
else if (strcmp (PTR_TO_STR (p), "#IG_Team_Select_Spect") == 0) // team select menu?
|
||||
m_bot->m_startAction = GSM_TEAM_SELECT;
|
||||
else if (strcmp (PTR_TO_STR (p), "#IG_Team_Select") == 0) // team select menu?
|
||||
m_bot->m_startAction = GSM_TEAM_SELECT;
|
||||
else if (strcmp (PTR_TO_STR (p), "#IG_VIP_Team_Select") == 0) // team select menu?
|
||||
m_bot->m_startAction = GSM_TEAM_SELECT;
|
||||
else if (strcmp (PTR_TO_STR (p), "#IG_VIP_Team_Select_Spect") == 0) // team select menu?
|
||||
m_bot->m_startAction = GSM_TEAM_SELECT;
|
||||
else if (strcmp (PTR_TO_STR (p), "#Terrorist_Select") == 0) // T model select?
|
||||
m_bot->m_startAction = GSM_CLASS_SELECT;
|
||||
else if (strcmp (PTR_TO_STR (p), "#CT_Select") == 0) // CT model select menu?
|
||||
m_bot->m_startAction = GSM_CLASS_SELECT;
|
||||
|
||||
break;
|
||||
|
||||
case NETMSG_WEAPONLIST:
|
||||
// this message is sent when a client joins the game. All of the weapons are sent with the weapon ID and information about what ammo is used.
|
||||
|
||||
switch (m_state)
|
||||
{
|
||||
case 0:
|
||||
strncpy (weaponProp.className, PTR_TO_STR (p), SIZEOF_CHAR (weaponProp.className));
|
||||
break;
|
||||
|
||||
case 1:
|
||||
weaponProp.ammo1 = PTR_TO_INT (p); // ammo index 1
|
||||
break;
|
||||
|
||||
case 2:
|
||||
weaponProp.ammo1Max = PTR_TO_INT (p); // max ammo 1
|
||||
break;
|
||||
|
||||
case 5:
|
||||
weaponProp.slotID = PTR_TO_INT (p); // slot for this weapon
|
||||
break;
|
||||
|
||||
case 6:
|
||||
weaponProp.position = PTR_TO_INT (p); // position in slot
|
||||
break;
|
||||
|
||||
case 7:
|
||||
weaponProp.id = PTR_TO_INT (p); // weapon ID
|
||||
break;
|
||||
|
||||
case 8:
|
||||
weaponProp.flags = PTR_TO_INT (p); // flags for weapon (WTF???)
|
||||
g_weaponDefs[weaponProp.id] = weaponProp; // store away this weapon with it's ammo information...
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case NETMSG_CURWEAPON:
|
||||
// this message is sent when a weapon is selected (either by the bot chosing a weapon or by the server auto assigning the bot a weapon). In CS it's also called when Ammo is increased/decreased
|
||||
|
||||
switch (m_state)
|
||||
{
|
||||
case 0:
|
||||
state = PTR_TO_INT (p); // state of the current weapon (WTF???)
|
||||
break;
|
||||
|
||||
case 1:
|
||||
id = PTR_TO_INT (p); // weapon ID of current weapon
|
||||
break;
|
||||
|
||||
case 2:
|
||||
clip = PTR_TO_INT (p); // ammo currently in the clip for this weapon
|
||||
|
||||
if (id <= 31)
|
||||
{
|
||||
if (state != 0)
|
||||
m_bot->m_currentWeapon = id;
|
||||
|
||||
// ammo amount decreased ? must have fired a bullet...
|
||||
if (id == m_bot->m_currentWeapon && m_bot->m_ammoInClip[id] > clip)
|
||||
m_bot->m_timeLastFired = GetWorldTime (); // remember the last bullet time
|
||||
|
||||
m_bot->m_ammoInClip[id] = clip;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case NETMSG_AMMOX:
|
||||
// this message is sent whenever ammo amounts are adjusted (up or down). NOTE: Logging reveals that CS uses it very unreliable!
|
||||
|
||||
switch (m_state)
|
||||
{
|
||||
case 0:
|
||||
index = PTR_TO_INT (p); // ammo index (for type of ammo)
|
||||
break;
|
||||
|
||||
case 1:
|
||||
m_bot->m_ammo[index] = PTR_TO_INT (p); // store it away
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case NETMSG_AMMOPICKUP:
|
||||
// this message is sent when the bot picks up some ammo (AmmoX messages are also sent so this message is probably
|
||||
// not really necessary except it allows the HUD to draw pictures of ammo that have been picked up. The bots
|
||||
// don't really need pictures since they don't have any eyes anyway.
|
||||
|
||||
switch (m_state)
|
||||
{
|
||||
case 0:
|
||||
index = PTR_TO_INT (p);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
m_bot->m_ammo[index] = PTR_TO_INT (p);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case NETMSG_DAMAGE:
|
||||
// this message gets sent when the bots are getting damaged.
|
||||
|
||||
switch (m_state)
|
||||
{
|
||||
case 0:
|
||||
damageArmor = PTR_TO_INT (p);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
damageTaken = PTR_TO_INT (p);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
damageBits = PTR_TO_INT (p);
|
||||
|
||||
if (m_bot != NULL && (damageArmor > 0 || damageTaken > 0))
|
||||
m_bot->TakeDamage (m_bot->pev->dmg_inflictor, damageTaken, damageArmor, damageBits);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case NETMSG_MONEY:
|
||||
// this message gets sent when the bots money amount changes
|
||||
|
||||
if (m_state == 0)
|
||||
m_bot->m_moneyAmount = PTR_TO_INT (p); // amount of money
|
||||
break;
|
||||
|
||||
case NETMSG_STATUSICON:
|
||||
switch (m_state)
|
||||
{
|
||||
case 0:
|
||||
enabled = PTR_TO_BYTE (p);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (strcmp (PTR_TO_STR (p), "defuser") == 0)
|
||||
m_bot->m_hasDefuser = (enabled != 0);
|
||||
else if (strcmp (PTR_TO_STR (p), "buyzone") == 0)
|
||||
{
|
||||
m_bot->m_inBuyZone = (enabled != 0);
|
||||
|
||||
// try to equip in buyzone
|
||||
m_bot->EquipInBuyzone (BUYSTATE_PRIMARY_WEAPON);
|
||||
}
|
||||
else if (strcmp (PTR_TO_STR (p), "vipsafety") == 0)
|
||||
m_bot->m_inVIPZone = (enabled != 0);
|
||||
else if (strcmp (PTR_TO_STR (p), "c4") == 0)
|
||||
m_bot->m_inBombZone = (enabled == 2);
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case NETMSG_DEATH: // this message sends on death
|
||||
switch (m_state)
|
||||
{
|
||||
case 0:
|
||||
killerIndex = PTR_TO_INT (p);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
victimIndex = PTR_TO_INT (p);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
bots.SetDeathMsgState (true);
|
||||
|
||||
if (killerIndex != 0 && killerIndex != victimIndex)
|
||||
{
|
||||
edict_t *killer = EntityOfIndex (killerIndex);
|
||||
edict_t *victim = EntityOfIndex (victimIndex);
|
||||
|
||||
if (IsEntityNull (killer) || IsEntityNull (victim))
|
||||
break;
|
||||
|
||||
if (yb_communication_type.GetInt () == 2)
|
||||
{
|
||||
// need to send congrats on well placed shot
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
{
|
||||
Bot *bot = bots.GetBot (i);
|
||||
|
||||
if (bot != NULL && IsAlive (bot->GetEntity ()) && killer != bot->GetEntity () && bot->EntityIsVisible (victim->v.origin) && GetTeam (killer) == GetTeam (bot->GetEntity ()) && GetTeam (killer) != GetTeam (victim))
|
||||
{
|
||||
if (killer == g_hostEntity)
|
||||
bot->HandleChatterMessage ("#Bot_NiceShotCommander");
|
||||
else
|
||||
bot->HandleChatterMessage ("#Bot_NiceShotPall");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// notice nearby to victim teammates, that attacker is near
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
{
|
||||
Bot *bot = bots.GetBot (i);
|
||||
|
||||
if (bot != NULL && bot->m_seeEnemyTime + 2.0f < GetWorldTime () && IsAlive (bot->GetEntity ()) && GetTeam (bot->GetEntity ()) == GetTeam (victim) && IsVisible (killer->v.origin, bot->GetEntity ()) && IsEntityNull (bot->m_enemy) && GetTeam (killer) != GetTeam (victim))
|
||||
{
|
||||
bot->m_actualReactionTime = 0.0f;
|
||||
bot->m_seeEnemyTime = GetWorldTime ();
|
||||
bot->m_enemy = killer;
|
||||
bot->m_lastEnemy = killer;
|
||||
bot->m_lastEnemyOrigin = killer->v.origin;
|
||||
}
|
||||
}
|
||||
|
||||
Bot *bot = bots.GetBot (killer);
|
||||
|
||||
// is this message about a bot who killed somebody?
|
||||
if (bot != NULL)
|
||||
bot->m_lastVictim = victim;
|
||||
|
||||
else // did a human kill a bot on his team?
|
||||
{
|
||||
Bot *target = bots.GetBot (victim);
|
||||
|
||||
if (target != NULL)
|
||||
{
|
||||
if (GetTeam (killer) == GetTeam (victim))
|
||||
target->m_voteKickIndex = killerIndex;
|
||||
|
||||
target->m_notKilled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case NETMSG_SCREENFADE: // this message gets sent when the Screen fades (Flashbang)
|
||||
switch (m_state)
|
||||
{
|
||||
case 3:
|
||||
r = PTR_TO_BYTE (p);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
g = PTR_TO_BYTE (p);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
b = PTR_TO_BYTE (p);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
m_bot->TakeBlinded (Vector (r, g, b), PTR_TO_BYTE (p));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case NETMSG_HLTV: // round restart in steam cs
|
||||
switch (m_state)
|
||||
{
|
||||
case 0:
|
||||
numPlayers = PTR_TO_INT (p);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (numPlayers == 0 && PTR_TO_INT (p) == 0)
|
||||
RoundInit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case NETMSG_RESETHUD:
|
||||
#if 0
|
||||
if (m_bot != NULL)
|
||||
m_bot->NewRound ();
|
||||
#endif
|
||||
break;
|
||||
|
||||
case NETMSG_TEXTMSG:
|
||||
if (m_state == 1)
|
||||
{
|
||||
if (FStrEq (PTR_TO_STR (p), "#CTs_Win") ||
|
||||
FStrEq (PTR_TO_STR (p), "#Bomb_Defused") ||
|
||||
FStrEq (PTR_TO_STR (p), "#Terrorists_Win") ||
|
||||
FStrEq (PTR_TO_STR (p), "#Round_Draw") ||
|
||||
FStrEq (PTR_TO_STR (p), "#All_Hostages_Rescued") ||
|
||||
FStrEq (PTR_TO_STR (p), "#Target_Saved") ||
|
||||
FStrEq (PTR_TO_STR (p), "#Hostages_Not_Rescued") ||
|
||||
FStrEq (PTR_TO_STR (p), "#Terrorists_Not_Escaped") ||
|
||||
FStrEq (PTR_TO_STR (p), "#VIP_Not_Escaped") ||
|
||||
FStrEq (PTR_TO_STR (p), "#Escaping_Terrorists_Neutralized") ||
|
||||
FStrEq (PTR_TO_STR (p), "#VIP_Assassinated") ||
|
||||
FStrEq (PTR_TO_STR (p), "#VIP_Escaped") ||
|
||||
FStrEq (PTR_TO_STR (p), "#Terrorists_Escaped") ||
|
||||
FStrEq (PTR_TO_STR (p), "#CTs_PreventEscape") ||
|
||||
FStrEq (PTR_TO_STR (p), "#Target_Bombed") ||
|
||||
FStrEq (PTR_TO_STR (p), "#Game_Commencing") ||
|
||||
FStrEq (PTR_TO_STR (p), "#Game_will_restart_in"))
|
||||
{
|
||||
g_roundEnded = true;
|
||||
|
||||
if (FStrEq (PTR_TO_STR (p), "#Game_Commencing"))
|
||||
g_isCommencing = true;
|
||||
|
||||
if (FStrEq (PTR_TO_STR (p), "#CTs_Win"))
|
||||
{
|
||||
bots.SetLastWinner (CT); // update last winner for economics
|
||||
|
||||
if (yb_communication_type.GetInt () == 2)
|
||||
{
|
||||
Bot *bot = bots.FindOneValidAliveBot ();
|
||||
|
||||
if (bot != NULL && IsAlive (bot->GetEntity ()))
|
||||
bot->HandleChatterMessage (PTR_TO_STR (p));
|
||||
}
|
||||
}
|
||||
|
||||
if (FStrEq (PTR_TO_STR (p), "#Game_will_restart_in"))
|
||||
{
|
||||
bots.CheckTeamEconomics (CT, true);
|
||||
bots.CheckTeamEconomics (TERRORIST, true);
|
||||
}
|
||||
|
||||
if (FStrEq (PTR_TO_STR (p), "#Terrorists_Win"))
|
||||
{
|
||||
bots.SetLastWinner (TERRORIST); // update last winner for economics
|
||||
|
||||
if (yb_communication_type.GetInt () == 2)
|
||||
{
|
||||
Bot *bot = bots.FindOneValidAliveBot ();
|
||||
|
||||
if (bot != NULL && IsAlive (bot->GetEntity ()))
|
||||
bot->HandleChatterMessage (PTR_TO_STR (p));
|
||||
}
|
||||
}
|
||||
waypoints.SetBombPosition (true);
|
||||
}
|
||||
else if (!g_bombPlanted && FStrEq (PTR_TO_STR (p), "#Bomb_Planted"))
|
||||
{
|
||||
waypoints.SetBombPosition ();
|
||||
|
||||
g_bombPlanted = g_bombSayString = true;
|
||||
g_timeBombPlanted = GetWorldTime ();
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
{
|
||||
Bot *bot = bots.GetBot (i);
|
||||
|
||||
if (bot != NULL && IsAlive (bot->GetEntity ()))
|
||||
{
|
||||
bot->DeleteSearchNodes ();
|
||||
bot->ResetTasks ();
|
||||
|
||||
if (yb_communication_type.GetInt () == 2 && Random.Long (0, 100) < 75 && GetTeam (bot->GetEntity ()) == CT)
|
||||
bot->ChatterMessage (Chatter_WhereIsTheBomb);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_bot != NULL && FStrEq (PTR_TO_STR (p), "#Switch_To_BurstFire"))
|
||||
m_bot->m_weaponBurstMode = BM_ON;
|
||||
else if (m_bot != NULL && FStrEq (PTR_TO_STR (p), "#Switch_To_SemiAuto"))
|
||||
m_bot->m_weaponBurstMode = BM_OFF;
|
||||
}
|
||||
break;
|
||||
|
||||
case NETMSG_SCOREINFO:
|
||||
switch (m_state)
|
||||
{
|
||||
case 0:
|
||||
playerIndex = PTR_TO_INT (p);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (playerIndex >= 0 && playerIndex <= GetMaxClients ())
|
||||
{
|
||||
#ifndef XASH_CSDM
|
||||
Client &cl = g_clients[playerIndex - 1];
|
||||
|
||||
if (PTR_TO_INT (p) == 1)
|
||||
cl.realTeam = TERRORIST;
|
||||
else if (PTR_TO_INT (p) == 2)
|
||||
cl.realTeam = CT;
|
||||
else
|
||||
cl.realTeam = SPECTATOR;
|
||||
|
||||
if (yb_csdm_mode.GetInt () == 2)
|
||||
cl.team = playerIndex;
|
||||
else
|
||||
cl.team = g_clients[playerIndex - 1].realTeam;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case NETMSG_BARTIME:
|
||||
if (m_state == 0)
|
||||
{
|
||||
if (PTR_TO_INT (p) > 0)
|
||||
m_bot->m_hasProgressBar = true; // the progress bar on a hud
|
||||
else if (PTR_TO_INT (p) == 0)
|
||||
m_bot->m_hasProgressBar = false; // no progress bar or disappeared
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
AddLogEntry (true, LL_FATAL, "Network message handler error. Call to unrecognized message id (%d).\n", m_message);
|
||||
}
|
||||
m_state++; // and finally update network message state
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue