a little cleanup of code save point
This commit is contained in:
parent
d300c13e85
commit
f8344a464e
18 changed files with 1197 additions and 1141 deletions
|
|
@ -556,24 +556,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
|
||||
{
|
||||
|
|
@ -1617,11 +1599,7 @@ public:
|
|||
|
||||
// prototypes of bot functions...
|
||||
extern int GetWeaponReturn (bool isString, const char *weaponAlias, int weaponIndex = -1);
|
||||
|
||||
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);
|
||||
|
|
@ -1631,41 +1609,22 @@ 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 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 *GetWaypointDir (void);
|
||||
|
||||
// very global convars
|
||||
extern ConVar yb_jasonmode;
|
||||
|
|
@ -1673,6 +1632,7 @@ extern ConVar yb_communication_type;
|
|||
extern ConVar yb_csdm_mode;
|
||||
extern ConVar yb_ignore_enemies;
|
||||
|
||||
#include <engine.h>
|
||||
#include <globals.h>
|
||||
#include <compress.h>
|
||||
#include <resource.h>
|
||||
|
|
|
|||
105
include/engine.h
Normal file
105
include/engine.h
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
//
|
||||
// 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
|
||||
};
|
||||
|
||||
// provides utility functions to not call original engine (less call-cost)
|
||||
class Engine
|
||||
{
|
||||
private:
|
||||
short m_drawModels[DRAW_NUM];
|
||||
|
||||
// public functions
|
||||
public:
|
||||
|
||||
// precaches internal stuff
|
||||
void Precache (void);
|
||||
|
||||
// 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);
|
||||
|
||||
// public inlines
|
||||
public:
|
||||
|
||||
// get the current time on server
|
||||
static inline float Time (void)
|
||||
{
|
||||
return g_pGlobals->time;
|
||||
}
|
||||
|
||||
// get "maxplayers" limit on server
|
||||
static inline int MaxClients (void)
|
||||
{
|
||||
return g_pGlobals->maxClients;
|
||||
}
|
||||
};
|
||||
|
||||
// provides quick access to engine instance
|
||||
extern Engine engine;
|
||||
|
|
@ -207,8 +207,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
|
||||
|
|
|
|||
|
|
@ -55,8 +55,6 @@ 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;
|
||||
|
|
@ -92,16 +90,6 @@ 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);
|
||||
|
|
|
|||
|
|
@ -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,6 +34,7 @@
|
|||
<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" />
|
||||
|
|
|
|||
|
|
@ -69,6 +69,9 @@
|
|||
<ClInclude Include="..\include\platform.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\engine.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\source\chatlib.cpp">
|
||||
|
|
@ -101,6 +104,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">
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -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,11 +204,11 @@ 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?
|
||||
|
|
@ -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,7 +230,7 @@ void Bot::PrepareChatMessage (char *text)
|
|||
break;
|
||||
}
|
||||
|
||||
if (i < GetMaxClients ())
|
||||
if (i < engine.MaxClients ())
|
||||
{
|
||||
if (!IsEntityNull (pev->dmg_inflictor) && m_team == GetTeam (pev->dmg_inflictor))
|
||||
talkEntity = pev->dmg_inflictor;
|
||||
|
|
@ -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 ();
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -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)
|
||||
{
|
||||
|
|
@ -194,7 +193,7 @@ bool Bot::IsEnemyViewable (edict_t *player)
|
|||
|
||||
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 (!IsEntityNull (m_enemy) && m_enemyUpdateTime > engine.Time ())
|
||||
{
|
||||
player = m_enemy;
|
||||
|
||||
|
|
@ -231,7 +230,7 @@ bool Bot::LookupEnemy (void)
|
|||
// the old enemy is no longer visible or
|
||||
if (IsEntityNull (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))
|
||||
{
|
||||
|
|
@ -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 () || !IsEntityNull (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 () && IsEntityNull (friendBot->m_lastEnemy) && IsVisible (pev->origin, ENT (friendBot->pev)) && 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;
|
||||
}
|
||||
|
|
@ -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)) && IsEntityNull (m_lastEnemy) && IsEntityNull (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,7 +557,7 @@ 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)
|
||||
|
|
@ -566,12 +565,12 @@ bool Bot::IsFriendInLineOfFire (float distance)
|
|||
int playerIndex = 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,7 +726,7 @@ void Bot::FireWeapon (void)
|
|||
// if using grenade stop this
|
||||
if (m_isUsingGrenade)
|
||||
{
|
||||
m_shootTime = GetWorldTime () + 0.1f;
|
||||
m_shootTime = engine.Time () + 0.1f;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -737,7 +736,7 @@ void Bot::FireWeapon (void)
|
|||
if (IsFriendInLineOfFire (distance))
|
||||
{
|
||||
m_fightStyle = 0;
|
||||
m_lastFightStyleCheck = GetWorldTime ();
|
||||
m_lastFightStyleCheck = engine.Time ();
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -787,11 +786,11 @@ void Bot::FireWeapon (void)
|
|||
if ( g_weaponDefs[id].ammo1 != -1 && g_weaponDefs[id].ammo1 < 32 && m_ammo[g_weaponDefs[id].ammo1] >= selectTab[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
|
||||
|
|
@ -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))))
|
||||
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))
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
|
@ -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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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?
|
||||
|
|
@ -1017,7 +1016,7 @@ void Bot::CombatFight (void)
|
|||
|
||||
float distance = (m_lookAt - EyePosition ()).GetLength2D (); // how far away is the enemy scum?
|
||||
|
||||
if (m_timeWaypointMove < GetWorldTime ())
|
||||
if (m_timeWaypointMove < engine.Time ())
|
||||
{
|
||||
int approach;
|
||||
|
||||
|
|
@ -1057,11 +1056,11 @@ void Bot::CombatFight (void)
|
|||
if (UsesSniper ())
|
||||
{
|
||||
m_fightStyle = 1;
|
||||
m_lastFightStyleCheck = GetWorldTime ();
|
||||
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);
|
||||
|
||||
|
|
@ -1081,25 +1080,25 @@ void Bot::CombatFight (void)
|
|||
else
|
||||
m_fightStyle = 0;
|
||||
}
|
||||
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;
|
||||
else
|
||||
m_fightStyle = 0;
|
||||
|
||||
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_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);
|
||||
|
|
@ -1115,7 +1114,7 @@ void Bot::CombatFight (void)
|
|||
if (Random.Long (1, 100) < 30)
|
||||
m_combatStrafeDir ^= 1;
|
||||
|
||||
m_strafeSetTime = GetWorldTime () + Random.Float (0.5f, 3.0f);
|
||||
m_strafeSetTime = engine.Time () + Random.Float (0.5f, 3.0f);
|
||||
}
|
||||
|
||||
if (m_combatStrafeDir == 0)
|
||||
|
|
@ -1125,7 +1124,7 @@ void Bot::CombatFight (void)
|
|||
else
|
||||
{
|
||||
m_combatStrafeDir ^= 1;
|
||||
m_strafeSetTime = GetWorldTime () + 1.0f;
|
||||
m_strafeSetTime = engine.Time () + 1.0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -1135,11 +1134,11 @@ void Bot::CombatFight (void)
|
|||
else
|
||||
{
|
||||
m_combatStrafeDir ^= 1;
|
||||
m_strafeSetTime = GetWorldTime () + 1.0f;
|
||||
m_strafeSetTime = engine.Time () + 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
@ -1151,15 +1150,15 @@ void Bot::CombatFight (void)
|
|||
else if (m_fightStyle == 1)
|
||||
{
|
||||
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;
|
||||
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))
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
308
source/engine.cpp
Normal file
308
source/engine.cpp
Normal file
|
|
@ -0,0 +1,308 @@
|
|||
//
|
||||
// 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>
|
||||
|
||||
void Engine::Precache (void)
|
||||
{
|
||||
// this function precaches needed models for DrawLine
|
||||
|
||||
m_drawModels[DRAW_SIMPLE] = PRECACHE_MODEL (ENGINE_STR ("sprites/laserbeam.spr"));
|
||||
m_drawModels[DRAW_ARROW] = PRECACHE_MODEL (ENGINE_STR ("sprites/arrow1.spr"));
|
||||
}
|
||||
|
||||
void Engine::Printf (const char *fmt, ...)
|
||||
{
|
||||
// this function outputs string into server console
|
||||
|
||||
va_list ap;
|
||||
char string[1024];
|
||||
|
||||
va_start (ap, fmt);
|
||||
vsprintf (string, locale.TranslateInput (fmt), ap);
|
||||
va_end (ap);
|
||||
|
||||
g_engfuncs.pfnServerPrint (string);
|
||||
g_engfuncs.pfnServerPrint ("\n");
|
||||
}
|
||||
|
||||
void Engine::ChatPrintf (const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char string[512];
|
||||
|
||||
va_start (ap, fmt);
|
||||
vsprintf (string, locale.TranslateInput (fmt), ap);
|
||||
va_end (ap);
|
||||
|
||||
if (IsDedicatedServer ())
|
||||
{
|
||||
engine.Printf (string);
|
||||
return;
|
||||
}
|
||||
strcat (string, "\n");
|
||||
|
||||
MESSAGE_BEGIN (MSG_BROADCAST, netmsg.GetId (NETMSG_TEXTMSG));
|
||||
WRITE_BYTE (HUD_PRINTTALK);
|
||||
WRITE_STRING (string);
|
||||
MESSAGE_END ();
|
||||
}
|
||||
|
||||
void Engine::CenterPrintf (const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char string[512];
|
||||
|
||||
va_start (ap, fmt);
|
||||
vsprintf (string, locale.TranslateInput (fmt), ap);
|
||||
va_end (ap);
|
||||
|
||||
if (IsDedicatedServer ())
|
||||
{
|
||||
engine.Printf (string);
|
||||
return;
|
||||
}
|
||||
strcat (string, "\n");
|
||||
|
||||
MESSAGE_BEGIN (MSG_BROADCAST, netmsg.GetId (NETMSG_TEXTMSG));
|
||||
WRITE_BYTE (HUD_PRINTCENTER);
|
||||
WRITE_STRING (string);
|
||||
MESSAGE_END ();
|
||||
}
|
||||
|
||||
void Engine::ClientPrintf (edict_t *ent, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char string[2048];
|
||||
|
||||
va_start (ap, fmt);
|
||||
vsprintf (string, locale.TranslateInput (fmt), ap);
|
||||
va_end (ap);
|
||||
|
||||
if (IsEntityNull (ent) || ent == g_hostEntity)
|
||||
{
|
||||
engine.Printf (string);
|
||||
return;
|
||||
}
|
||||
strcat (string, "\n");
|
||||
g_engfuncs.pfnClientPrintf (ent, print_console, string);
|
||||
}
|
||||
|
||||
void Engine::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)
|
||||
{
|
||||
// this function draws a arrow visible from the client side of the player whose player entity
|
||||
// is pointed to by ent, from the vector location start to the vector location end,
|
||||
// which is supposed to last life tenths seconds, and having the color defined by RGB.
|
||||
|
||||
if (!IsValidPlayer (ent))
|
||||
return; // reliability check
|
||||
|
||||
MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, ent);
|
||||
WRITE_BYTE (TE_BEAMPOINTS);
|
||||
WRITE_COORD (end.x);
|
||||
WRITE_COORD (end.y);
|
||||
WRITE_COORD (end.z);
|
||||
WRITE_COORD (start.x);
|
||||
WRITE_COORD (start.y);
|
||||
WRITE_COORD (start.z);
|
||||
WRITE_SHORT (m_drawModels[type]);
|
||||
WRITE_BYTE (0); // framestart
|
||||
WRITE_BYTE (10); // framerate
|
||||
WRITE_BYTE (life); // life in 0.1's
|
||||
WRITE_BYTE (width); // width
|
||||
WRITE_BYTE (noise); // noise
|
||||
|
||||
WRITE_BYTE (red); // r, g, b
|
||||
WRITE_BYTE (green); // r, g, b
|
||||
WRITE_BYTE (blue); // r, g, b
|
||||
|
||||
WRITE_BYTE (brightness); // brightness
|
||||
WRITE_BYTE (speed); // speed
|
||||
MESSAGE_END ();
|
||||
}
|
||||
|
||||
void Engine::TestLine (const Vector &start, const Vector &end, int ignoreFlags, edict_t *ignoreEntity, TraceResult *ptr)
|
||||
{
|
||||
// this function traces a line dot by dot, starting from vecStart in the direction of vecEnd,
|
||||
// ignoring or not monsters (depending on the value of IGNORE_MONSTERS, true or false), and stops
|
||||
// at the first obstacle encountered, returning the results of the trace in the TraceResult structure
|
||||
// ptr. Such results are (amongst others) the distance traced, the hit surface, the hit plane
|
||||
// vector normal, etc. See the TraceResult structure for details. This function allows to specify
|
||||
// whether the trace starts "inside" an entity's polygonal model, and if so, to specify that entity
|
||||
// in ignoreEntity in order to ignore it as a possible obstacle.
|
||||
|
||||
int engineFlags = 0;
|
||||
|
||||
if (ignoreFlags & TRACE_IGNORE_MONSTERS)
|
||||
engineFlags = 1;
|
||||
|
||||
if (ignoreFlags & TRACE_IGNORE_GLASS)
|
||||
engineFlags |= 0x100;
|
||||
|
||||
g_engfuncs.pfnTraceLine (start, end, engineFlags, ignoreEntity, ptr);
|
||||
}
|
||||
|
||||
void Engine::TestHull (const Vector &start, const Vector &end, int ignoreFlags, int hullNumber, edict_t *ignoreEntity, TraceResult *ptr)
|
||||
{
|
||||
// this function traces a hull dot by dot, starting from vecStart in the direction of vecEnd,
|
||||
// ignoring or not monsters (depending on the value of IGNORE_MONSTERS, true or
|
||||
// false), and stops at the first obstacle encountered, returning the results
|
||||
// of the trace in the TraceResult structure ptr, just like TraceLine. Hulls that can be traced
|
||||
// (by parameter hull_type) are point_hull (a line), head_hull (size of a crouching player),
|
||||
// human_hull (a normal body size) and large_hull (for monsters?). Not all the hulls in the
|
||||
// game can be traced here, this function is just useful to give a relative idea of spatial
|
||||
// reachability (i.e. can a hostage pass through that tiny hole ?) Also like TraceLine, this
|
||||
// function allows to specify whether the trace starts "inside" an entity's polygonal model,
|
||||
// and if so, to specify that entity in ignoreEntity in order to ignore it as an obstacle.
|
||||
|
||||
(*g_engfuncs.pfnTraceHull) (start, end, (ignoreFlags & TRACE_IGNORE_MONSTERS), hullNumber, ignoreEntity, ptr);
|
||||
}
|
||||
|
||||
float Engine::GetWaveLength (const char *fileName)
|
||||
{
|
||||
extern ConVar yb_chatter_path;
|
||||
File fp (FormatBuffer ("%s/%s/%s.wav", GetModName (), yb_chatter_path.GetString (), fileName), "rb");
|
||||
|
||||
// we're got valid handle?
|
||||
if (!fp.IsValid ())
|
||||
return 0.0f;
|
||||
|
||||
// check if we have engine function for this
|
||||
if (g_engfuncs.pfnGetApproxWavePlayLen != NULL)
|
||||
{
|
||||
fp.Close ();
|
||||
return g_engfuncs.pfnGetApproxWavePlayLen (fileName) / 1000.0f;
|
||||
}
|
||||
|
||||
// else fuck with manual search
|
||||
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;
|
||||
} waveHdr;
|
||||
|
||||
memset (&waveHdr, 0, sizeof (waveHdr));
|
||||
|
||||
if (fp.Read (&waveHdr, sizeof (WavHeader)) == 0)
|
||||
{
|
||||
AddLogEntry (true, LL_ERROR, "Wave File %s - has wrong or unsupported format", fileName);
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
if (strncmp (waveHdr.chunkID, "WAVE", 4) != 0)
|
||||
{
|
||||
AddLogEntry (true, LL_ERROR, "Wave File %s - has wrong wave chunk id", fileName);
|
||||
return 0.0f;
|
||||
}
|
||||
fp.Close ();
|
||||
|
||||
if (waveHdr.dataChunkLength == 0)
|
||||
{
|
||||
AddLogEntry (true, LL_ERROR, "Wave File %s - has zero length!", fileName);
|
||||
return 0.0f;
|
||||
}
|
||||
return static_cast <float> (waveHdr.dataChunkLength) / static_cast <float> (waveHdr.bytesPerSecond);
|
||||
}
|
||||
|
||||
bool Engine::IsDedicatedServer (void)
|
||||
{
|
||||
// return true if server is dedicated server, false otherwise
|
||||
return g_engfuncs.pfnIsDedicatedServer () > 0;
|
||||
}
|
||||
|
||||
const char *Engine::GetModName (void)
|
||||
{
|
||||
// this function returns mod name without path
|
||||
|
||||
char engineModName[256];
|
||||
g_engfuncs.pfnGetGameDir (engineModName); // ask the engine for the MOD directory path
|
||||
|
||||
String mod (engineModName);
|
||||
int pos = mod.ReverseFind ('\\');
|
||||
|
||||
if (pos == -1)
|
||||
pos = mod.ReverseFind ('/');
|
||||
|
||||
if (pos == -1)
|
||||
return &engineModName[0];
|
||||
|
||||
return mod.Mid (pos, -1).GetBuffer ();
|
||||
}
|
||||
|
||||
const char *Engine::GetMapName (void)
|
||||
{
|
||||
// this function gets the map name and store it in the map_name global string variable.
|
||||
|
||||
static char engineMap[256];
|
||||
strncpy (engineMap, const_cast <const char *> (g_pGlobals->pStringBase + static_cast <int> (g_pGlobals->mapname)), SIZEOF_CHAR (engineMap));
|
||||
|
||||
return &engineMap[0];
|
||||
}
|
||||
|
||||
Vector Engine::GetAbsOrigin (edict_t *ent)
|
||||
{
|
||||
// this expanded function returns the vector origin of a bounded entity, assuming that any
|
||||
// entity that has a bounding box has its center at the center of the bounding box itself.
|
||||
|
||||
if (IsEntityNull (ent))
|
||||
return Vector::GetZero ();
|
||||
|
||||
if (ent->v.origin.IsZero ())
|
||||
return ent->v.absmin + ent->v.size * 0.5f;
|
||||
|
||||
return ent->v.origin;
|
||||
}
|
||||
|
||||
void Engine::RegisterCmd (const char * command, void func (void))
|
||||
{
|
||||
// this function tells the engine that a new server command is being declared, in addition
|
||||
// to the standard ones, whose name is command_name. The engine is thus supposed to be aware
|
||||
// that for every "command_name" server command it receives, it should call the function
|
||||
// pointed to by "function" in order to handle it.
|
||||
|
||||
g_engfuncs.pfnAddServerCommand (const_cast <char *> (command), func);
|
||||
}
|
||||
|
||||
void Engine::EmitSound (edict_t *ent, const char *sound)
|
||||
{
|
||||
g_engfuncs.pfnEmitSound (ent, CHAN_WEAPON, sound, 1.0f, ATTN_NORM, 0, 100.0f);
|
||||
}
|
||||
|
||||
void Engine::IssueCmd (const char *fmt, ...)
|
||||
{
|
||||
// this function asks the engine to execute a server command
|
||||
|
||||
va_list ap;
|
||||
static char string[1024];
|
||||
|
||||
// concatenate all the arguments in one string
|
||||
va_start (ap, fmt);
|
||||
vsprintf (string, fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
strcat (string, "\n");
|
||||
|
||||
g_engfuncs.pfnServerCommand (string);
|
||||
g_engfuncs.pfnServerExecute ();
|
||||
}
|
||||
|
||||
|
||||
// expose singleton
|
||||
Engine engine;
|
||||
|
|
@ -48,8 +48,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;
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
|
|||
if (selection >= 1 && selection <= 7)
|
||||
bots.SetWeaponMode (selection);
|
||||
else
|
||||
ClientPrint (ent, print_withtag, "Choose weapon from 1 to 7 range");
|
||||
engine.ClientPrintf (ent, "Choose weapon from 1 to 7 range");
|
||||
}
|
||||
|
||||
// force all bots to vote to specified map
|
||||
|
|
@ -92,12 +92,14 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
|
|||
int nominatedMap = atoi (arg1);
|
||||
|
||||
// loop through all players
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (bots.GetBot (i) != NULL)
|
||||
bots.GetBot (i)->m_voteMap = nominatedMap;
|
||||
Bot *bot = bots.GetBot (i);
|
||||
|
||||
if (bot != NULL)
|
||||
bot->m_voteMap = nominatedMap;
|
||||
}
|
||||
ClientPrint (ent, print_withtag, "All dead bots will vote for map #%d", nominatedMap);
|
||||
engine.ClientPrintf (ent, "All dead bots will vote for map #%d", nominatedMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -113,68 +115,67 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
|
|||
"Git Commit Author: %s\n"
|
||||
"------------------------------------------------";
|
||||
|
||||
ClientPrint (ent, print_console, versionData, PRODUCT_NAME, PRODUCT_VERSION, GenerateBuildNumber (), __DATE__, __TIME__, PRODUCT_GIT_HASH, PRODUCT_GIT_COMMIT_AUTHOR);
|
||||
engine.ClientPrintf (ent, versionData, PRODUCT_NAME, PRODUCT_VERSION, GenerateBuildNumber (), __DATE__, __TIME__, PRODUCT_GIT_HASH, PRODUCT_GIT_COMMIT_AUTHOR);
|
||||
}
|
||||
|
||||
// display some sort of help information
|
||||
else if (stricmp (arg0, "?") == 0 || stricmp (arg0, "help") == 0)
|
||||
{
|
||||
ClientPrint (ent, print_console, "Bot Commands:");
|
||||
ClientPrint (ent, print_console, "%s version\t - display version information.", self);
|
||||
ClientPrint (ent, print_console, "%s add\t - create a bot in current game.", self);
|
||||
ClientPrint (ent, print_console, "%s fill\t - fill the server with random bots.", self);
|
||||
ClientPrint (ent, print_console, "%s kickall\t - disconnects all bots from current game.", self);
|
||||
ClientPrint (ent, print_console, "%s killbots\t - kills all bots in current game.", self);
|
||||
ClientPrint (ent, print_console, "%s kick\t - disconnect one random bot from game.", self);
|
||||
ClientPrint (ent, print_console, "%s weaponmode\t - select bot weapon mode.", self);
|
||||
ClientPrint (ent, print_console, "%s votemap\t - allows dead bots to vote for specific map.", self);
|
||||
ClientPrint (ent, print_console, "%s cmenu\t - displaying bots command menu.", self);
|
||||
engine.ClientPrintf (ent, "Bot Commands:");
|
||||
engine.ClientPrintf (ent, "%s version\t - display version information.", self);
|
||||
engine.ClientPrintf (ent, "%s add\t - create a bot in current game.", self);
|
||||
engine.ClientPrintf (ent, "%s fill\t - fill the server with random bots.", self);
|
||||
engine.ClientPrintf (ent, "%s kickall\t - disconnects all bots from current game.", self);
|
||||
engine.ClientPrintf (ent, "%s killbots\t - kills all bots in current game.", self);
|
||||
engine.ClientPrintf (ent, "%s kick\t - disconnect one random bot from game.", self);
|
||||
engine.ClientPrintf (ent, "%s weaponmode\t - select bot weapon mode.", self);
|
||||
engine.ClientPrintf (ent, "%s votemap\t - allows dead bots to vote for specific map.", self);
|
||||
engine.ClientPrintf (ent, "%s cmenu\t - displaying bots command menu.", self);
|
||||
|
||||
if (stricmp (arg1, "full") == 0 || stricmp (arg1, "f") == 0 || stricmp (arg1, "?") == 0)
|
||||
{
|
||||
ClientPrint (ent, print_console, "%s add_t\t - creates one random bot to terrorist team.", self);
|
||||
ClientPrint (ent, print_console, "%s add_ct\t - creates one random bot to ct team.", self);
|
||||
ClientPrint (ent, print_console, "%s kick_t\t - disconnect one random bot from terrorist team.", self);
|
||||
ClientPrint (ent, print_console, "%s kick_ct\t - disconnect one random bot from ct team.", self);
|
||||
ClientPrint (ent, print_console, "%s kill_t\t - kills all bots on terrorist team.", self);
|
||||
ClientPrint (ent, print_console, "%s kill_ct\t - kills all bots on ct team.", self);
|
||||
ClientPrint (ent, print_console, "%s list\t - display list of bots currently playing.", self);
|
||||
ClientPrint (ent, print_console, "%s order\t - execute specific command on specified bot.", self);
|
||||
ClientPrint (ent, print_console, "%s time\t - displays current time on server.", self);
|
||||
ClientPrint (ent, print_console, "%s deletewp\t - erase waypoint file from hard disk (permanently).", self);
|
||||
engine.ClientPrintf (ent, "%s add_t\t - creates one random bot to terrorist team.", self);
|
||||
engine.ClientPrintf (ent, "%s add_ct\t - creates one random bot to ct team.", self);
|
||||
engine.ClientPrintf (ent, "%s kick_t\t - disconnect one random bot from terrorist team.", self);
|
||||
engine.ClientPrintf (ent, "%s kick_ct\t - disconnect one random bot from ct team.", self);
|
||||
engine.ClientPrintf (ent, "%s kill_t\t - kills all bots on terrorist team.", self);
|
||||
engine.ClientPrintf (ent, "%s kill_ct\t - kills all bots on ct team.", self);
|
||||
engine.ClientPrintf (ent, "%s list\t - display list of bots currently playing.", self);
|
||||
engine.ClientPrintf (ent, "%s order\t - execute specific command on specified bot.", self);
|
||||
engine.ClientPrintf (ent, "%s time\t - displays current time on server.", self);
|
||||
engine.ClientPrintf (ent, "%s deletewp\t - erase waypoint file from hard disk (permanently).", self);
|
||||
|
||||
if (!IsDedicatedServer ())
|
||||
if (!engine.IsDedicatedServer ())
|
||||
{
|
||||
ServerPrint ("%s autowp\t - toggle autowaypointing.", self);
|
||||
ServerPrint ("%s wp\t - toggle waypoint showing.", self);
|
||||
ServerPrint ("%s wp on noclip\t - enable noclip cheat", self);
|
||||
ServerPrint ("%s wp save nocheck\t - save waypoints without checking.", self);
|
||||
ServerPrint ("%s wp add\t - open menu for waypoint creation.", self);
|
||||
ServerPrint ("%s wp menu\t - open main waypoint menu.", self);
|
||||
ServerPrint ("%s wp addbasic\t - creates basic waypoints on map.", self);
|
||||
ServerPrint ("%s wp find\t - show direction to specified waypoint.", self);
|
||||
ServerPrint ("%s wp load\t - load the waypoint file from hard disk.", self);
|
||||
ServerPrint ("%s wp check\t - checks if all waypoints connections are valid.", self);
|
||||
ServerPrint ("%s wp cache\t - cache nearest waypoint.", self);
|
||||
ServerPrint ("%s wp teleport\t - teleport hostile to specified waypoint.", self);
|
||||
ServerPrint ("%s wp setradius\t - manually sets the wayzone radius for this waypoint.", self);
|
||||
ServerPrint ("%s path autodistance - opens menu for setting autopath maximum distance.", self);
|
||||
ServerPrint ("%s path cache\t - remember the nearest to player waypoint.", self);
|
||||
ServerPrint ("%s path create\t - opens menu for path creation.", self);
|
||||
ServerPrint ("%s path delete\t - delete path from cached to nearest waypoint.", self);
|
||||
ServerPrint ("%s path create_in\t - creating incoming path connection.", self);
|
||||
ServerPrint ("%s path create_out\t - creating outgoing path connection.", self);
|
||||
ServerPrint ("%s path create_both\t - creating both-ways path connection.", self);
|
||||
ServerPrint ("%s exp save\t - save the experience data.", self);
|
||||
engine.Printf ("%s autowp\t - toggle autowaypointing.", self);
|
||||
engine.Printf ("%s wp\t - toggle waypoint showing.", self);
|
||||
engine.Printf ("%s wp on noclip\t - enable noclip cheat", self);
|
||||
engine.Printf ("%s wp save nocheck\t - save waypoints without checking.", self);
|
||||
engine.Printf ("%s wp add\t - open menu for waypoint creation.", self);
|
||||
engine.Printf ("%s wp menu\t - open main waypoint menu.", self);
|
||||
engine.Printf ("%s wp addbasic\t - creates basic waypoints on map.", self);
|
||||
engine.Printf ("%s wp find\t - show direction to specified waypoint.", self);
|
||||
engine.Printf ("%s wp load\t - load the waypoint file from hard disk.", self);
|
||||
engine.Printf ("%s wp check\t - checks if all waypoints connections are valid.", self);
|
||||
engine.Printf ("%s wp cache\t - cache nearest waypoint.", self);
|
||||
engine.Printf ("%s wp teleport\t - teleport hostile to specified waypoint.", self);
|
||||
engine.Printf ("%s wp setradius\t - manually sets the wayzone radius for this waypoint.", self);
|
||||
engine.Printf ("%s path autodistance - opens menu for setting autopath maximum distance.", self);
|
||||
engine.Printf ("%s path cache\t - remember the nearest to player waypoint.", self);
|
||||
engine.Printf ("%s path create\t - opens menu for path creation.", self);
|
||||
engine.Printf ("%s path delete\t - delete path from cached to nearest waypoint.", self);
|
||||
engine.Printf ("%s path create_in\t - creating incoming path connection.", self);
|
||||
engine.Printf ("%s path create_out\t - creating outgoing path connection.", self);
|
||||
engine.Printf ("%s path create_both\t - creating both-ways path connection.", self);
|
||||
engine.Printf ("%s exp save\t - save the experience data.", self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (stricmp (arg0, "bot_takedamage") == 0 && !IsNullString (arg1))
|
||||
{
|
||||
bool isOn = !!(atoi (arg1) == 1);
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
Bot *bot = bots.GetBot (i);
|
||||
|
||||
|
|
@ -197,21 +198,21 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
|
|||
else
|
||||
{
|
||||
DisplayMenuToClient (ent, NULL); // reset menu display
|
||||
CenterPrint ("You're dead, and have no access to this menu");
|
||||
engine.CenterPrintf ("You're dead, and have no access to this menu");
|
||||
}
|
||||
}
|
||||
|
||||
// waypoint manimupulation (really obsolete, can be edited through menu) (supported only on listen server)
|
||||
else if (stricmp (arg0, "waypoint") == 0 || stricmp (arg0, "wp") == 0 || stricmp (arg0, "wpt") == 0)
|
||||
{
|
||||
if (IsDedicatedServer () || IsEntityNull (g_hostEntity))
|
||||
if (engine.IsDedicatedServer () || IsEntityNull (g_hostEntity))
|
||||
return 2;
|
||||
|
||||
// enables or disable waypoint displaying
|
||||
if (stricmp (arg1, "on") == 0)
|
||||
{
|
||||
g_waypointOn = true;
|
||||
ServerPrint ("Waypoint Editing Enabled");
|
||||
engine.Printf ("Waypoint Editing Enabled");
|
||||
|
||||
// enables noclip cheat
|
||||
if (stricmp (arg2, "noclip") == 0)
|
||||
|
|
@ -219,16 +220,16 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
|
|||
if (g_editNoclip)
|
||||
{
|
||||
g_hostEntity->v.movetype = MOVETYPE_WALK;
|
||||
ServerPrint ("Noclip Cheat Disabled");
|
||||
engine.Printf ("Noclip Cheat Disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_hostEntity->v.movetype = MOVETYPE_NOCLIP;
|
||||
ServerPrint ("Noclip Cheat Enabled");
|
||||
engine.Printf ("Noclip Cheat Enabled");
|
||||
}
|
||||
g_editNoclip = !g_editNoclip; // switch on/off (XOR it!)
|
||||
}
|
||||
ServerCommand ("yapb wp mdl on");
|
||||
engine.IssueCmd ("yapb wp mdl on");
|
||||
}
|
||||
|
||||
// switching waypoint editing off
|
||||
|
|
@ -238,8 +239,8 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
|
|||
g_editNoclip = false;
|
||||
g_hostEntity->v.movetype = MOVETYPE_WALK;
|
||||
|
||||
ServerPrint ("Waypoint Editing Disabled");
|
||||
ServerCommand ("yapb wp mdl off");
|
||||
engine.Printf ("Waypoint Editing Disabled");
|
||||
engine.IssueCmd ("yapb wp mdl off");
|
||||
}
|
||||
|
||||
// toggles displaying player models on spawn spots
|
||||
|
|
@ -256,9 +257,9 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
|
|||
while (!IsEntityNull (spawnEntity = FIND_ENTITY_BY_CLASSNAME (spawnEntity, "info_vip_start")))
|
||||
spawnEntity->v.effects &= ~EF_NODRAW;
|
||||
|
||||
ServerCommand ("mp_roundtime 9"); // reset round time to maximum
|
||||
ServerCommand ("mp_timelimit 0"); // disable the time limit
|
||||
ServerCommand ("mp_freezetime 0"); // disable freezetime
|
||||
engine.IssueCmd ("mp_roundtime 9"); // reset round time to maximum
|
||||
engine.IssueCmd ("mp_timelimit 0"); // disable the time limit
|
||||
engine.IssueCmd ("mp_freezetime 0"); // disable freezetime
|
||||
}
|
||||
else if (stricmp (arg2, "off") == 0)
|
||||
{
|
||||
|
|
@ -286,7 +287,7 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
|
|||
else if (stricmp (arg1, "addbasic") == 0)
|
||||
{
|
||||
waypoints.CreateBasic ();
|
||||
CenterPrint ("Basic waypoints was Created");
|
||||
engine.CenterPrintf ("Basic waypoints was Created");
|
||||
}
|
||||
|
||||
// delete nearest to host edict waypoint
|
||||
|
|
@ -304,12 +305,12 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
|
|||
if (FStrEq (arg2, "nocheck"))
|
||||
{
|
||||
waypoints.Save ();
|
||||
ServerPrint (waypointSaveMessage);
|
||||
engine.Printf (waypointSaveMessage);
|
||||
}
|
||||
else if (waypoints.NodesValid ())
|
||||
{
|
||||
waypoints.Save ();
|
||||
ServerPrint (waypointSaveMessage);
|
||||
engine.Printf (waypointSaveMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -321,14 +322,14 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
|
|||
else if (stricmp (arg1, "load") == 0)
|
||||
{
|
||||
if (waypoints.Load ())
|
||||
ServerPrint ("Waypoints loaded");
|
||||
engine.Printf ("Waypoints loaded");
|
||||
}
|
||||
|
||||
// check all nodes for validation
|
||||
else if (stricmp (arg1, "check") == 0)
|
||||
{
|
||||
if (waypoints.NodesValid ())
|
||||
CenterPrint ("Nodes work Fine");
|
||||
engine.CenterPrintf ("Nodes work Fine");
|
||||
}
|
||||
|
||||
// opens menu for setting (removing) waypoint flags
|
||||
|
|
@ -355,7 +356,7 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
|
|||
(*g_engfuncs.pfnSetOrigin) (g_hostEntity, path->origin);
|
||||
g_waypointOn = true;
|
||||
|
||||
ServerPrint ("Player '%s' teleported to waypoint #%d (x:%.1f, y:%.1f, z:%.1f)", STRING (g_hostEntity->v.netname), teleportPoint, path->origin.x, path->origin.y, path->origin.z); //-V807
|
||||
engine.Printf ("Player '%s' teleported to waypoint #%d (x:%.1f, y:%.1f, z:%.1f)", STRING (g_hostEntity->v.netname), teleportPoint, path->origin.x, path->origin.y, path->origin.z); //-V807
|
||||
g_editNoclip = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -366,13 +367,13 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
|
|||
|
||||
// otherwise display waypoint current status
|
||||
else
|
||||
ServerPrint ("Waypoints are %s", g_waypointOn == true ? "Enabled" : "Disabled");
|
||||
engine.Printf ("Waypoints are %s", g_waypointOn == true ? "Enabled" : "Disabled");
|
||||
}
|
||||
|
||||
// path waypoint editing system (supported only on listen server)
|
||||
else if (stricmp (arg0, "pathwaypoint") == 0 || stricmp (arg0, "path") == 0 || stricmp (arg0, "pwp") == 0)
|
||||
{
|
||||
if (IsDedicatedServer () || IsEntityNull (g_hostEntity))
|
||||
if (engine.IsDedicatedServer () || IsEntityNull (g_hostEntity))
|
||||
return 2;
|
||||
|
||||
// opens path creation menu
|
||||
|
|
@ -403,7 +404,7 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
|
|||
// automatic waypoint handling (supported only on listen server)
|
||||
else if (stricmp (arg0, "autowaypoint") == 0 || stricmp (arg0, "autowp") == 0)
|
||||
{
|
||||
if (IsDedicatedServer () || IsEntityNull (g_hostEntity))
|
||||
if (engine.IsDedicatedServer () || IsEntityNull (g_hostEntity))
|
||||
return 2;
|
||||
|
||||
// enable autowaypointing
|
||||
|
|
@ -418,13 +419,13 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
|
|||
g_autoWaypoint = false;
|
||||
|
||||
// display status
|
||||
ServerPrint ("Auto-Waypoint %s", g_autoWaypoint ? "Enabled" : "Disabled");
|
||||
engine.Printf ("Auto-Waypoint %s", g_autoWaypoint ? "Enabled" : "Disabled");
|
||||
}
|
||||
|
||||
// experience system handling (supported only on listen server)
|
||||
else if (stricmp (arg0, "experience") == 0 || stricmp (arg0, "exp") == 0)
|
||||
{
|
||||
if (IsDedicatedServer () || IsEntityNull (g_hostEntity))
|
||||
if (engine.IsDedicatedServer () || IsEntityNull (g_hostEntity))
|
||||
return 2;
|
||||
|
||||
// write experience table (and visibility table) to hard disk
|
||||
|
|
@ -433,7 +434,7 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
|
|||
waypoints.SaveExperienceTab ();
|
||||
waypoints.SaveVisibilityTab ();
|
||||
|
||||
ServerPrint ("Experience tab saved");
|
||||
engine.Printf ("Experience tab saved");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -453,7 +454,7 @@ void CommandHandler (void)
|
|||
|
||||
// check status for dedicated server command
|
||||
if (BotCommandHandler (g_hostEntity, IsNullString (CMD_ARGV (1)) ? "help" : CMD_ARGV (1), CMD_ARGV (2), CMD_ARGV (3), CMD_ARGV (4), CMD_ARGV (5), CMD_ARGV (6), CMD_ARGV (0)) == 0)
|
||||
ServerPrint ("Unknown command: %s", CMD_ARGV (1));
|
||||
engine.Printf ("Unknown command: %s", CMD_ARGV (1));
|
||||
}
|
||||
|
||||
void ParseVoiceEvent (const String &base, int type, float timeToRepeat)
|
||||
|
|
@ -467,7 +468,7 @@ void ParseVoiceEvent (const String &base, int type, float timeToRepeat)
|
|||
{
|
||||
temp[i].Trim ().TrimQuotes ();
|
||||
|
||||
if (GetWaveLength (temp[i]) == 0.0f)
|
||||
if (engine.GetWaveLength (temp[i]) <= 0.0f)
|
||||
continue;
|
||||
|
||||
chatterItem.name = temp[i];
|
||||
|
|
@ -833,7 +834,7 @@ void InitConfig (void)
|
|||
// LOCALIZER INITITALIZATION
|
||||
if (OpenConfig ("lang.cfg", "Specified language not found", &fp, true) && !(g_gameFlags & GAME_LEGACY))
|
||||
{
|
||||
if (IsDedicatedServer ())
|
||||
if (engine.IsDedicatedServer ())
|
||||
return; // dedicated server will use only english translation
|
||||
|
||||
enum Lang { Lang_Original, Lang_Translate } langState = static_cast <Lang> (2);
|
||||
|
|
@ -904,7 +905,7 @@ void CommandHandler_NotMM (void)
|
|||
// the stdio command-line parsing in C when you write "long main (long argc, char **argv)".
|
||||
// this function is handler for non-metamod launch of yapb, it's just print error message.
|
||||
|
||||
ServerPrint ("You're launched standalone version of yapb. Metamod is not installed or not enabled!");
|
||||
engine.Printf ("You're launched standalone version of yapb. Metamod is not installed or not enabled!");
|
||||
}
|
||||
|
||||
void GameDLLInit (void)
|
||||
|
|
@ -940,22 +941,22 @@ void GameDLLInit (void)
|
|||
|
||||
gameVersionStr.Replace ("Legacy", "1.6 Limited");
|
||||
}
|
||||
ServerPrint ("YaPB Bot has detect game version as Counter-Strike: %s", gameVersionStr.GetBuffer ());
|
||||
engine.Printf ("YaPB Bot has detect game version as Counter-Strike: %s", gameVersionStr.GetBuffer ());
|
||||
}
|
||||
|
||||
// register server command(s)
|
||||
RegisterCommand ("yapb", CommandHandler);
|
||||
RegisterCommand ("yb", CommandHandler);
|
||||
engine.RegisterCmd ("yapb", CommandHandler);
|
||||
engine.RegisterCmd ("yb", CommandHandler);
|
||||
|
||||
// execute main config
|
||||
ServerCommand ("exec addons/yapb/conf/yapb.cfg");
|
||||
engine.IssueCmd ("exec addons/yapb/conf/yapb.cfg");
|
||||
|
||||
// set correct version string
|
||||
yb_version.SetString (FormatBuffer ("%d.%d.%d.%u", PRODUCT_VERSION_DWORD_INTERNAL, GenerateBuildNumber ()));
|
||||
|
||||
// register fake metamod command handler if we not! under mm
|
||||
if (!g_isMetamod)
|
||||
RegisterCommand ("meta", CommandHandler_NotMM);
|
||||
engine.RegisterCmd ("meta", CommandHandler_NotMM);
|
||||
|
||||
if (g_isMetamod)
|
||||
RETURN_META (MRES_IGNORED);
|
||||
|
|
@ -1012,8 +1013,7 @@ int Spawn (edict_t *ent)
|
|||
PRECACHE_SOUND (ENGINE_STR ("common/wpn_moveselect.wav")); // path add/delete cancel
|
||||
PRECACHE_SOUND (ENGINE_STR ("common/wpn_denyselect.wav")); // path add/delete error
|
||||
|
||||
g_modelIndexLaser = PRECACHE_MODEL (ENGINE_STR ("sprites/laserbeam.spr"));
|
||||
g_modelIndexArrow = PRECACHE_MODEL (ENGINE_STR ("sprites/arrow1.spr"));
|
||||
engine.Precache ();
|
||||
g_roundEnded = true;
|
||||
|
||||
RoundInit ();
|
||||
|
|
@ -1079,9 +1079,9 @@ int Spawn (edict_t *ent)
|
|||
g_mapType |= MAP_ES;
|
||||
|
||||
// next maps doesn't have map-specific entities, so determine it by name
|
||||
else if (strncmp (GetMapName (), "fy_", 3) == 0) // fun map
|
||||
else if (strncmp (engine.GetMapName (), "fy_", 3) == 0) // fun map
|
||||
g_mapType |= MAP_FY;
|
||||
else if (strncmp (GetMapName (), "ka_", 3) == 0) // knife arena map
|
||||
else if (strncmp (engine.GetMapName (), "ka_", 3) == 0) // knife arena map
|
||||
g_mapType |= MAP_KA;
|
||||
|
||||
if (g_isMetamod)
|
||||
|
|
@ -1188,7 +1188,7 @@ void ClientUserInfoChanged (edict_t *ent, char *infobuffer)
|
|||
// change their player model). But most commonly, this function is in charge of handling
|
||||
// team changes, recounting the teams population, etc...
|
||||
|
||||
if (IsDedicatedServer () && !IsValidBot (ent))
|
||||
if (engine.IsDedicatedServer () && !IsValidBot (ent))
|
||||
{
|
||||
const char *passwordField = yb_password_key.GetString ();
|
||||
const char *password = yb_password.GetString ();
|
||||
|
|
@ -1240,11 +1240,11 @@ void ClientCommand (edict_t *ent)
|
|||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
ClientPrint (ent, print_withtag, "Unknown command: %s", arg1);
|
||||
engine.ClientPrintf (ent, "Unknown command: %s", arg1);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
ClientPrint (ent, print_withtag, "Command %s, can only be executed from server console.", arg1);
|
||||
engine.ClientPrintf (ent, "Command %s, can only be executed from server console.", arg1);
|
||||
break;
|
||||
}
|
||||
if (g_isMetamod)
|
||||
|
|
@ -1329,9 +1329,9 @@ void ClientCommand (edict_t *ent)
|
|||
{
|
||||
case 1:
|
||||
if (g_waypointOn)
|
||||
ServerCommand ("yapb waypoint off");
|
||||
engine.IssueCmd ("yapb waypoint off");
|
||||
else
|
||||
ServerCommand ("yapb waypoint on");
|
||||
engine.IssueCmd ("yapb waypoint on");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
|
@ -1423,7 +1423,7 @@ void ClientCommand (edict_t *ent)
|
|||
if (path->flags & FLAG_NOHOSTAGE)
|
||||
noHostagePoints++;
|
||||
}
|
||||
ServerPrint ("Waypoints: %d - T Points: %d\n"
|
||||
engine.Printf ("Waypoints: %d - T Points: %d\n"
|
||||
"CT Points: %d - Goal Points: %d\n"
|
||||
"Rescue Points: %d - Camp Points: %d\n"
|
||||
"Block Hostage Points: %d - Sniper Points: %d\n", g_numWaypoints, terrPoints, ctPoints, goalPoints, rescuePoints, campPoints, noHostagePoints, sniperPoints);
|
||||
|
|
@ -1435,7 +1435,7 @@ void ClientCommand (edict_t *ent)
|
|||
g_autoWaypoint &= 1;
|
||||
g_autoWaypoint ^= 1;
|
||||
|
||||
CenterPrint ("Auto-Waypoint %s", g_autoWaypoint ? "Enabled" : "Disabled");
|
||||
engine.CenterPrintf ("Auto-Waypoint %s", g_autoWaypoint ? "Enabled" : "Disabled");
|
||||
break;
|
||||
|
||||
case 3:
|
||||
|
|
@ -1447,7 +1447,7 @@ void ClientCommand (edict_t *ent)
|
|||
if (waypoints.NodesValid ())
|
||||
waypoints.Save ();
|
||||
else
|
||||
CenterPrint ("Waypoint not saved\nThere are errors, see console");
|
||||
engine.CenterPrintf ("Waypoint not saved\nThere are errors, see console");
|
||||
break;
|
||||
|
||||
case 5:
|
||||
|
|
@ -1460,13 +1460,13 @@ void ClientCommand (edict_t *ent)
|
|||
|
||||
case 7:
|
||||
if (waypoints.NodesValid ())
|
||||
CenterPrint ("Nodes works fine");
|
||||
engine.CenterPrintf ("Nodes works fine");
|
||||
else
|
||||
CenterPrint ("There are errors, see console");
|
||||
engine.CenterPrintf ("There are errors, see console");
|
||||
break;
|
||||
|
||||
case 8:
|
||||
ServerCommand ("yapb wp on noclip");
|
||||
engine.IssueCmd ("yapb wp on noclip");
|
||||
break;
|
||||
|
||||
case 9:
|
||||
|
|
@ -1593,7 +1593,7 @@ void ClientCommand (edict_t *ent)
|
|||
else
|
||||
{
|
||||
DisplayMenuToClient (ent, NULL); // reset menu display
|
||||
CenterPrint ("You're dead, and have no access to this menu");
|
||||
engine.CenterPrintf ("You're dead, and have no access to this menu");
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1626,7 +1626,7 @@ void ClientCommand (edict_t *ent)
|
|||
bot->m_doubleJumpOrigin = client->ent->v.origin;
|
||||
bot->m_doubleJumpEntity = client->ent;
|
||||
|
||||
bot->PushTask (TASK_DOUBLEJUMP, TASKPRI_DOUBLEJUMP, -1, GetWorldTime (), true);
|
||||
bot->PushTask (TASK_DOUBLEJUMP, TASKPRI_DOUBLEJUMP, -1, engine.Time (), true);
|
||||
bot->TeamSayText (FormatBuffer ("Ok %s, i will help you!", STRING (ent->v.netname)));
|
||||
}
|
||||
else if (selection == 2)
|
||||
|
|
@ -1662,9 +1662,9 @@ void ClientCommand (edict_t *ent)
|
|||
g_autoPathDistance = autoDistanceValue[selection - 1];
|
||||
|
||||
if (g_autoPathDistance == 0)
|
||||
CenterPrint ("AutoPath disabled");
|
||||
engine.CenterPrintf ("AutoPath disabled");
|
||||
else
|
||||
CenterPrint ("AutoPath maximum distance set to %f", g_autoPathDistance);
|
||||
engine.CenterPrintf ("AutoPath maximum distance set to %f", g_autoPathDistance);
|
||||
|
||||
if (g_isMetamod)
|
||||
RETURN_META (MRES_SUPERCEDE);
|
||||
|
|
@ -2029,7 +2029,7 @@ void ClientCommand (edict_t *ent)
|
|||
if (FStrEq (command, "say_team"))
|
||||
team = GetTeam (ent);
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (!(g_clients[i].flags & CF_USED) || (team != -1 && team != g_clients[i].team) || isAlive != IsAlive (g_clients[i].ent))
|
||||
continue;
|
||||
|
|
@ -2044,7 +2044,7 @@ void ClientCommand (edict_t *ent)
|
|||
continue;
|
||||
|
||||
strncpy (target->m_sayTextBuffer.sayText, CMD_ARGS (), SIZEOF_CHAR (target->m_sayTextBuffer.sayText));
|
||||
target->m_sayTextBuffer.timeNextChat = GetWorldTime () + target->m_sayTextBuffer.chatDelay;
|
||||
target->m_sayTextBuffer.timeNextChat = engine.Time () + target->m_sayTextBuffer.chatDelay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2061,7 +2061,7 @@ void ClientCommand (edict_t *ent)
|
|||
|
||||
if (radioCommand != Radio_Affirmative && radioCommand != Radio_Negative && radioCommand != Radio_ReportingIn)
|
||||
{
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
Bot *bot = bots.GetBot (i);
|
||||
|
||||
|
|
@ -2073,7 +2073,7 @@ void ClientCommand (edict_t *ent)
|
|||
}
|
||||
}
|
||||
}
|
||||
g_lastRadioTime[g_clients[clientIndex].team] = GetWorldTime ();
|
||||
g_lastRadioTime[g_clients[clientIndex].team] = engine.Time ();
|
||||
}
|
||||
g_radioSelect[clientIndex] = 0;
|
||||
}
|
||||
|
|
@ -2106,12 +2106,12 @@ void ServerActivate (edict_t *pentEdictList, int edictCount, int clientMax)
|
|||
bots.CreateKillerEntity ();
|
||||
|
||||
// execute main config
|
||||
ServerCommand ("exec addons/yapb/conf/yapb.cfg");
|
||||
engine.IssueCmd ("exec addons/yapb/conf/yapb.cfg");
|
||||
|
||||
if (File::Accessible (FormatBuffer ("%s/maps/%s_yapb.cfg", GetModName (), GetMapName ())))
|
||||
if (File::Accessible (FormatBuffer ("%s/maps/%s_yapb.cfg", engine.GetModName (), engine.GetMapName ())))
|
||||
{
|
||||
ServerCommand ("exec maps/%s_yapb.cfg", GetMapName ());
|
||||
ServerPrint ("Executing Map-Specific config file");
|
||||
engine.IssueCmd ("exec maps/%s_yapb.cfg", engine.GetMapName ());
|
||||
engine.Printf ("Executing Map-Specific config file");
|
||||
}
|
||||
bots.InitQuota ();
|
||||
|
||||
|
|
@ -2164,7 +2164,7 @@ void StartFrame (void)
|
|||
bots.PeriodicThink ();
|
||||
|
||||
// record some stats of all players on the server
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
edict_t *player = EntityOfIndex (i + 1);
|
||||
|
||||
|
|
@ -2195,7 +2195,7 @@ void StartFrame (void)
|
|||
}
|
||||
}
|
||||
|
||||
if (!IsDedicatedServer () && !IsEntityNull (g_hostEntity))
|
||||
if (!engine.IsDedicatedServer () && !IsEntityNull (g_hostEntity))
|
||||
{
|
||||
if (g_waypointOn)
|
||||
waypoints.Think ();
|
||||
|
|
@ -2204,14 +2204,14 @@ void StartFrame (void)
|
|||
}
|
||||
bots.SetDeathMsgState (false);
|
||||
|
||||
if (g_timePerSecondUpdate < GetWorldTime ())
|
||||
if (g_timePerSecondUpdate < engine.Time ())
|
||||
{
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
edict_t *player = EntityOfIndex (i + 1);
|
||||
|
||||
// code below is executed only on dedicated server
|
||||
if (IsDedicatedServer () && !IsEntityNull (player) && (player->v.flags & FL_CLIENT) && !(player->v.flags & FL_FAKECLIENT))
|
||||
if (engine.IsDedicatedServer () && !IsEntityNull (player) && (player->v.flags & FL_CLIENT) && !(player->v.flags & FL_FAKECLIENT))
|
||||
{
|
||||
if (g_clients[i].flags & CF_ADMIN)
|
||||
{
|
||||
|
|
@ -2220,7 +2220,7 @@ void StartFrame (void)
|
|||
else if (strcmp (yb_password.GetString (), INFOKEY_VALUE (GET_INFOKEYBUFFER (g_clients[i].ent), const_cast <char *> (yb_password_key.GetString ()))))
|
||||
{
|
||||
g_clients[i].flags &= ~CF_ADMIN;
|
||||
ServerPrint ("Player %s had lost remote access to yapb.", STRING (player->v.netname));
|
||||
engine.Printf ("Player %s had lost remote access to yapb.", STRING (player->v.netname));
|
||||
}
|
||||
}
|
||||
else if (!(g_clients[i].flags & CF_ADMIN) && !IsNullString (yb_password_key.GetString ()) && !IsNullString (yb_password.GetString ()))
|
||||
|
|
@ -2228,7 +2228,7 @@ void StartFrame (void)
|
|||
if (strcmp (yb_password.GetString (), INFOKEY_VALUE (GET_INFOKEYBUFFER (g_clients[i].ent), const_cast <char *> (yb_password_key.GetString ()))) == 0)
|
||||
{
|
||||
g_clients[i].flags |= CF_ADMIN;
|
||||
ServerPrint ("Player %s had gained full remote access to yapb.", STRING (player->v.netname));
|
||||
engine.Printf ("Player %s had gained full remote access to yapb.", STRING (player->v.netname));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2249,9 +2249,9 @@ void StartFrame (void)
|
|||
if (csdm_active != NULL && csdm_active->value > 0)
|
||||
yb_csdm_mode.SetInt (mp_freeforall != NULL && mp_freeforall->value > 0 ? 2 : 1);
|
||||
}
|
||||
g_timePerSecondUpdate = GetWorldTime () + 1.0f;
|
||||
g_timePerSecondUpdate = engine.Time () + 1.0f;
|
||||
}
|
||||
else if (g_timePerSecondUpdate * 0.5f < GetWorldTime ())
|
||||
else if (g_timePerSecondUpdate * 0.5f < engine.Time ())
|
||||
bots.UpdateActiveGrenades ();
|
||||
|
||||
// keep bot number up to date
|
||||
|
|
@ -2475,7 +2475,7 @@ void pfnMessageBegin (int msgDest, int msgType, const float *origin, edict_t *ed
|
|||
|
||||
if (msgType == SVC_INTERMISSION)
|
||||
{
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
Bot *bot = bots.GetBot (i);
|
||||
|
||||
|
|
@ -2794,7 +2794,7 @@ void pfnAlertMessage (ALERT_TYPE alertType, char *format, ...)
|
|||
if ((g_mapType & MAP_DE) && g_bombPlanted && strstr (buffer, "_Defuse_") != NULL)
|
||||
{
|
||||
// notify all terrorists that CT is starting bomb defusing
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
Bot *bot = bots.GetBot (i);
|
||||
|
||||
|
|
@ -3109,7 +3109,7 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t
|
|||
{
|
||||
ModSupport *mod = &s_supportedMods[i];
|
||||
|
||||
if (strcmp (mod->name, GetModName ()) == 0 && File::Accessible (FormatBuffer ("%s/dlls/%s", mod->name,
|
||||
if (strcmp (mod->name, engine.GetModName ()) == 0 && File::Accessible (FormatBuffer ("%s/dlls/%s", mod->name,
|
||||
#if defined (PLATFORM_WIN32)
|
||||
mod->winLib
|
||||
#elif defined (PLATFORM_LINUX)
|
||||
|
|
@ -3145,10 +3145,10 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t
|
|||
g_gameLib = new Library (gameDLLName);
|
||||
|
||||
if (!g_gameLib->IsLoaded ())
|
||||
AddLogEntry (true, LL_FATAL | LL_IGNORE, "Unable to load gamedll \"%s\". Exiting... (gamedir: %s)", gameDLLName, GetModName ());
|
||||
AddLogEntry (true, LL_FATAL | LL_IGNORE, "Unable to load gamedll \"%s\". Exiting... (gamedir: %s)", gameDLLName, engine.GetModName ());
|
||||
}
|
||||
else
|
||||
AddLogEntry (true, LL_FATAL | LL_IGNORE, "Mod that you has started, not supported by this bot (gamedir: %s)", GetModName ());
|
||||
AddLogEntry (true, LL_FATAL | LL_IGNORE, "Mod that you has started, not supported by this bot (gamedir: %s)", engine.GetModName ());
|
||||
#endif
|
||||
|
||||
g_funcPointers = g_gameLib->GetFuncAddr <FuncPointers_t> ("GiveFnptrsToDll");
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ BotManager::BotManager (void)
|
|||
|
||||
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 ();
|
||||
}
|
||||
|
||||
|
|
@ -117,12 +117,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;
|
||||
}
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ int BotManager::CreateBot (const String &name, int difficulty, int personality,
|
|||
|
||||
if (IsEntityNull ((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;
|
||||
|
|
@ -209,7 +209,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;
|
||||
}
|
||||
|
|
@ -257,7 +257,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 +276,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 +287,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 ();
|
||||
|
|
@ -331,7 +331,7 @@ void BotManager::AdjustQuota (bool isPlayerConnection, edict_t *ent)
|
|||
{
|
||||
// this function increases or decreases bot quota amount depending on autovacate variables
|
||||
|
||||
if (!IsDedicatedServer () || !yb_autovacate.GetBool () || GetBot (ent) != NULL)
|
||||
if (!engine.IsDedicatedServer () || !yb_autovacate.GetBool () || GetBot (ent) != NULL)
|
||||
return;
|
||||
|
||||
if (isPlayerConnection)
|
||||
|
|
@ -374,7 +374,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 +405,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 +421,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.45f;
|
||||
}
|
||||
|
||||
// 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 +447,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 +459,7 @@ void BotManager::MaintainBotQuota (void)
|
|||
else if (desiredCount < numBots)
|
||||
RemoveRandom ();
|
||||
|
||||
m_quotaMaintainTime = GetWorldTime () + 0.90f;
|
||||
m_quotaMaintainTime = engine.Time () + 0.90f;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -467,8 +467,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 +478,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 +499,14 @@ 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,7 +535,7 @@ 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 ()))
|
||||
{
|
||||
|
|
@ -612,7 +612,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 +622,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 +633,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 +652,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 +671,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,16 +730,16 @@ 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);
|
||||
|
||||
|
|
@ -749,7 +749,7 @@ void BotManager::ListBots (void)
|
|||
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));
|
||||
engine.Printf ("[%-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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -760,7 +760,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,7 +774,7 @@ 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);
|
||||
|
||||
|
|
@ -808,7 +808,7 @@ 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)
|
||||
{
|
||||
|
|
@ -889,7 +889,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 +918,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 +952,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 +965,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 +999,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 +1015,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 +1031,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,7 +1072,7 @@ void Bot::NewRound (void)
|
|||
for (i = 0; i < 5; i++)
|
||||
m_prevWptIndex[i] = -1;
|
||||
|
||||
m_navTimeset = GetWorldTime ();
|
||||
m_navTimeset = engine.Time ();
|
||||
m_team = GetTeam (GetEntity ());
|
||||
|
||||
switch (m_personality)
|
||||
|
|
@ -1106,9 +1106,9 @@ void Bot::NewRound (void)
|
|||
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;
|
||||
|
|
@ -1170,8 +1170,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 +1185,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 +1200,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;
|
||||
|
|
@ -1224,9 +1224,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 +1234,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 +1270,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);
|
||||
}
|
||||
|
||||
|
|
@ -1351,7 +1351,7 @@ 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);
|
||||
|
||||
|
|
@ -1374,7 +1374,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);
|
||||
|
||||
|
|
@ -1417,7 +1417,7 @@ 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);
|
||||
|
||||
|
|
@ -1470,7 +1470,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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ int Bot::FindGoal (void)
|
|||
{
|
||||
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;
|
||||
|
|
@ -116,7 +116,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 +167,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 +302,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,18 +372,18 @@ 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
|
||||
{
|
||||
|
|
@ -391,9 +391,9 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal)
|
|||
if ((cantMoveForward = 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 +402,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 +427,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 ())
|
||||
|
|
@ -468,7 +468,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 +476,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 +518,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 +537,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;
|
||||
|
|
@ -588,8 +588,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 +598,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 +660,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,23 +715,23 @@ 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)
|
||||
|
|
@ -743,13 +743,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 +758,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))
|
||||
m_liftEntity = tr.pHit;
|
||||
}
|
||||
m_liftState = LIFT_LOOKING_BUTTON_OUTSIDE;
|
||||
m_liftUsageTime = GetWorldTime () + 15.0f;
|
||||
m_liftUsageTime = engine.Time () + 15.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -779,7 +779,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,7 +788,7 @@ 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);
|
||||
|
||||
|
|
@ -811,12 +811,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,7 +827,7 @@ 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);
|
||||
|
||||
|
|
@ -854,7 +854,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 +862,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,12 +875,12 @@ 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 (!IsEntityNull (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 ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -890,14 +890,14 @@ bool Bot::DoWaypointNav (void)
|
|||
if (pev->groundentity == m_liftEntity && m_liftEntity->v.velocity.z != 0.0f && IsOnFloor () && ((waypoints.GetPath (m_prevWptIndex[0])->flags & FLAG_LIFT) || !IsEntityNull (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 +915,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 +927,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,7 +939,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 ();
|
||||
|
|
@ -956,7 +956,7 @@ bool Bot::DoWaypointNav (void)
|
|||
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))
|
||||
continue;
|
||||
|
|
@ -988,14 +988,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 +1016,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 ();
|
||||
|
|
@ -1052,9 +1052,9 @@ bool Bot::DoWaypointNav (void)
|
|||
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 +1063,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 +1085,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 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
|
||||
|
||||
|
|
@ -1109,16 +1109,16 @@ bool Bot::DoWaypointNav (void)
|
|||
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;
|
||||
|
||||
|
|
@ -1126,7 +1126,7 @@ bool Bot::DoWaypointNav (void)
|
|||
{
|
||||
if (IsValidPlayer (ent) && IsAlive (ent) && m_team != GetTeam (ent) && GetWeaponPenetrationPower (m_currentWeapon) > 0)
|
||||
{
|
||||
m_seeEnemyTime = GetWorldTime ();
|
||||
m_seeEnemyTime = engine.Time ();
|
||||
|
||||
m_states |= STATE_SUSPECT_ENEMY;
|
||||
m_aimFlags |= AIM_LAST_ENEMY;
|
||||
|
|
@ -1923,7 +1923,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 +1943,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 () && IsEntityNull (m_enemy))
|
||||
{
|
||||
if (m_team == TERRORIST)
|
||||
{
|
||||
|
|
@ -2034,7 +2034,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 +2119,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 +2331,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 +2400,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 +2413,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 +2428,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 ())
|
||||
|
|
@ -2497,14 +2497,14 @@ bool Bot::HeadTowardWaypoint (void)
|
|||
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 +2524,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 +2547,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 +2563,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 +2574,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 +2586,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 +2595,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 +2608,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 +2618,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 +2706,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 +2716,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 +2727,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 +2737,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 +2748,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 +2758,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 +2771,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 +2781,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 +2793,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 +2803,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 +2814,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 +2824,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 +2850,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 +2861,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 +2872,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 +2891,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 +2911,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 +2927,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 +2942,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 +2967,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 +2983,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 +3132,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 +3226,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 +3234,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 +3246,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)
|
||||
|
|
@ -3314,7 +3314,7 @@ int Bot::FindPlantedBomb (void)
|
|||
{
|
||||
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 +3331,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);
|
||||
|
||||
|
|
@ -3369,7 +3369,7 @@ edict_t *Bot::FindNearestButton (const char *targetName)
|
|||
// find the nearest button which can open our target
|
||||
while (!IsEntityNull(searchEntity = FIND_ENTITY_BY_TARGET (searchEntity, targetName)))
|
||||
{
|
||||
Vector entityOrign = GetEntityOrigin (searchEntity);
|
||||
Vector entityOrign = engine.GetAbsOrigin (searchEntity);
|
||||
|
||||
// check if this place safe
|
||||
if (!IsDeadlyDrop (entityOrign))
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ void NetworkMsg::Execute (void *p)
|
|||
|
||||
// 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_timeLastFired = engine.Time (); // remember the last bullet time
|
||||
|
||||
m_bot->m_ammoInClip[id] = clip;
|
||||
}
|
||||
|
|
@ -268,7 +268,7 @@ void NetworkMsg::Execute (void *p)
|
|||
if (yb_communication_type.GetInt () == 2)
|
||||
{
|
||||
// need to send congrats on well placed shot
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
Bot *bot = bots.GetBot (i);
|
||||
|
||||
|
|
@ -285,14 +285,14 @@ void NetworkMsg::Execute (void *p)
|
|||
}
|
||||
|
||||
// notice nearby to victim teammates, that attacker is near
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); 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))
|
||||
if (bot != NULL && bot->m_seeEnemyTime + 2.0f < engine.Time () && 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_seeEnemyTime = engine.Time ();
|
||||
bot->m_enemy = killer;
|
||||
bot->m_lastEnemy = killer;
|
||||
bot->m_lastEnemyOrigin = killer->v.origin;
|
||||
|
|
@ -429,9 +429,9 @@ void NetworkMsg::Execute (void *p)
|
|||
waypoints.SetBombPosition ();
|
||||
|
||||
g_bombPlanted = g_bombSayString = true;
|
||||
g_timeBombPlanted = GetWorldTime ();
|
||||
g_timeBombPlanted = engine.Time ();
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
Bot *bot = bots.GetBot (i);
|
||||
|
||||
|
|
@ -460,7 +460,7 @@ void NetworkMsg::Execute (void *p)
|
|||
break;
|
||||
|
||||
case 4:
|
||||
if (playerIndex >= 0 && playerIndex <= GetMaxClients ())
|
||||
if (playerIndex >= 0 && playerIndex <= engine.MaxClients ())
|
||||
{
|
||||
#ifndef XASH_CSDM
|
||||
Client &cl = g_clients[playerIndex - 1];
|
||||
|
|
|
|||
|
|
@ -19,49 +19,6 @@ ConVar mp_freezetime ("mp_freezetime", NULL, VT_NOREGISTER);
|
|||
ConVar mp_freezetime ("mp_freezetime", "0", VT_NOSERVER);
|
||||
#endif
|
||||
|
||||
void TraceLine (const Vector &start, const Vector &end, bool ignoreMonsters, bool ignoreGlass, edict_t *ignoreEntity, TraceResult *ptr)
|
||||
{
|
||||
// this function traces a line dot by dot, starting from vecStart in the direction of vecEnd,
|
||||
// ignoring or not monsters (depending on the value of IGNORE_MONSTERS, true or false), and stops
|
||||
// at the first obstacle encountered, returning the results of the trace in the TraceResult structure
|
||||
// ptr. Such results are (amongst others) the distance traced, the hit surface, the hit plane
|
||||
// vector normal, etc. See the TraceResult structure for details. This function allows to specify
|
||||
// whether the trace starts "inside" an entity's polygonal model, and if so, to specify that entity
|
||||
// in ignoreEntity in order to ignore it as a possible obstacle.
|
||||
// this is an overloaded prototype to add IGNORE_GLASS in the same way as IGNORE_MONSTERS work.
|
||||
|
||||
(*g_engfuncs.pfnTraceLine) (start, end, (ignoreMonsters ? TRUE : FALSE) | (ignoreGlass ? 0x100 : 0), ignoreEntity, ptr);
|
||||
}
|
||||
|
||||
void TraceLine (const Vector &start, const Vector &end, bool ignoreMonsters, edict_t *ignoreEntity, TraceResult *ptr)
|
||||
{
|
||||
// this function traces a line dot by dot, starting from vecStart in the direction of vecEnd,
|
||||
// ignoring or not monsters (depending on the value of IGNORE_MONSTERS, true or false), and stops
|
||||
// at the first obstacle encountered, returning the results of the trace in the TraceResult structure
|
||||
// ptr. Such results are (amongst others) the distance traced, the hit surface, the hit plane
|
||||
// vector normal, etc. See the TraceResult structure for details. This function allows to specify
|
||||
// whether the trace starts "inside" an entity's polygonal model, and if so, to specify that entity
|
||||
// in ignoreEntity in order to ignore it as a possible obstacle.
|
||||
|
||||
(*g_engfuncs.pfnTraceLine) (start, end, ignoreMonsters ? TRUE : FALSE, ignoreEntity, ptr);
|
||||
}
|
||||
|
||||
void TraceHull (const Vector &start, const Vector &end, bool ignoreMonsters, int hullNumber, edict_t *ignoreEntity, TraceResult *ptr)
|
||||
{
|
||||
// this function traces a hull dot by dot, starting from vecStart in the direction of vecEnd,
|
||||
// ignoring or not monsters (depending on the value of IGNORE_MONSTERS, true or
|
||||
// false), and stops at the first obstacle encountered, returning the results
|
||||
// of the trace in the TraceResult structure ptr, just like TraceLine. Hulls that can be traced
|
||||
// (by parameter hull_type) are point_hull (a line), head_hull (size of a crouching player),
|
||||
// human_hull (a normal body size) and large_hull (for monsters?). Not all the hulls in the
|
||||
// game can be traced here, this function is just useful to give a relative idea of spatial
|
||||
// reachability (i.e. can a hostage pass through that tiny hole ?) Also like TraceLine, this
|
||||
// function allows to specify whether the trace starts "inside" an entity's polygonal model,
|
||||
// and if so, to specify that entity in ignoreEntity in order to ignore it as an obstacle.
|
||||
|
||||
(*g_engfuncs.pfnTraceHull) (start, end, ignoreMonsters ? TRUE : FALSE, hullNumber, ignoreEntity, ptr);
|
||||
}
|
||||
|
||||
uint16 FixedUnsigned16 (float value, float scale)
|
||||
{
|
||||
int output = (static_cast <int> (value * scale));
|
||||
|
|
@ -133,7 +90,7 @@ bool IsVisible (const Vector &origin, edict_t *ent)
|
|||
return false;
|
||||
|
||||
TraceResult tr;
|
||||
TraceLine (ent->v.origin + ent->v.view_ofs, origin, true, true, ent, &tr);
|
||||
engine.TestLine (ent->v.origin + ent->v.view_ofs, origin, TRACE_IGNORE_EVERYTHING, ent, &tr);
|
||||
|
||||
if (tr.flFraction != 1.0f)
|
||||
return false;
|
||||
|
|
@ -141,20 +98,6 @@ bool IsVisible (const Vector &origin, edict_t *ent)
|
|||
return true;
|
||||
}
|
||||
|
||||
Vector GetEntityOrigin (edict_t *ent)
|
||||
{
|
||||
// this expanded function returns the vector origin of a bounded entity, assuming that any
|
||||
// entity that has a bounding box has its center at the center of the bounding box itself.
|
||||
|
||||
if (IsEntityNull (ent))
|
||||
return Vector::GetZero ();
|
||||
|
||||
if (ent->v.origin.IsZero ())
|
||||
return ent->v.absmin + ent->v.size * 0.5f;
|
||||
|
||||
return ent->v.origin;
|
||||
}
|
||||
|
||||
void DisplayMenuToClient (edict_t *ent, MenuText *menu)
|
||||
{
|
||||
if (!IsValidPlayer (ent))
|
||||
|
|
@ -493,34 +436,6 @@ void strtrim (char *string)
|
|||
string[length] = 0;
|
||||
}
|
||||
|
||||
const char *GetModName (void)
|
||||
{
|
||||
static char modName[256];
|
||||
|
||||
GET_GAME_DIR (modName); // ask the engine for the MOD directory path
|
||||
int length = strlen (modName); // get the length of the returned string
|
||||
|
||||
// format the returned string to get the last directory name
|
||||
int stop = length - 1;
|
||||
while ((modName[stop] == '\\' || modName[stop] == '/') && stop > 0)
|
||||
stop--; // shift back any trailing separator
|
||||
|
||||
int start = stop;
|
||||
while (modName[start] != '\\' && modName[start] != '/' && start > 0)
|
||||
start--; // shift back to the start of the last subdirectory name
|
||||
|
||||
if (modName[start] == '\\' || modName[start] == '/')
|
||||
start++; // if we reached a separator, step over it
|
||||
|
||||
// now copy the formatted string back onto itself character per character
|
||||
for (length = start; length <= stop; length++)
|
||||
modName[length - start] = modName[length];
|
||||
|
||||
modName[length - start] = 0; // terminate the string
|
||||
|
||||
return &modName[0];
|
||||
}
|
||||
|
||||
// Create a directory tree
|
||||
void CreatePath (char *path)
|
||||
{
|
||||
|
|
@ -545,72 +460,6 @@ void CreatePath (char *path)
|
|||
#endif
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// this function draws a line visible from the client side of the player whose player entity
|
||||
// is pointed to by ent, from the vector location start to the vector location end,
|
||||
// which is supposed to last life tenths seconds, and having the color defined by RGB.
|
||||
|
||||
if (!IsValidPlayer (ent))
|
||||
return; // reliability check
|
||||
|
||||
MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, ent);
|
||||
WRITE_BYTE (TE_BEAMPOINTS);
|
||||
WRITE_COORD (start.x);
|
||||
WRITE_COORD (start.y);
|
||||
WRITE_COORD (start.z);
|
||||
WRITE_COORD (end.x);
|
||||
WRITE_COORD (end.y);
|
||||
WRITE_COORD (end.z);
|
||||
WRITE_SHORT (g_modelIndexLaser);
|
||||
WRITE_BYTE (0); // framestart
|
||||
WRITE_BYTE (10); // framerate
|
||||
WRITE_BYTE (life); // life in 0.1's
|
||||
WRITE_BYTE (width); // width
|
||||
WRITE_BYTE (noise); // noise
|
||||
|
||||
WRITE_BYTE (red); // r, g, b
|
||||
WRITE_BYTE (green); // r, g, b
|
||||
WRITE_BYTE (blue); // r, g, b
|
||||
|
||||
WRITE_BYTE (brightness); // brightness
|
||||
WRITE_BYTE (speed); // speed
|
||||
MESSAGE_END ();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// this function draws a arrow visible from the client side of the player whose player entity
|
||||
// is pointed to by ent, from the vector location start to the vector location end,
|
||||
// which is supposed to last life tenths seconds, and having the color defined by RGB.
|
||||
|
||||
if (!IsValidPlayer (ent))
|
||||
return; // reliability check
|
||||
|
||||
MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, ent);
|
||||
WRITE_BYTE (TE_BEAMPOINTS);
|
||||
WRITE_COORD (end.x);
|
||||
WRITE_COORD (end.y);
|
||||
WRITE_COORD (end.z);
|
||||
WRITE_COORD (start.x);
|
||||
WRITE_COORD (start.y);
|
||||
WRITE_COORD (start.z);
|
||||
WRITE_SHORT (g_modelIndexArrow);
|
||||
WRITE_BYTE (0); // framestart
|
||||
WRITE_BYTE (10); // framerate
|
||||
WRITE_BYTE (life); // life in 0.1's
|
||||
WRITE_BYTE (width); // width
|
||||
WRITE_BYTE (noise); // noise
|
||||
|
||||
WRITE_BYTE (red); // r, g, b
|
||||
WRITE_BYTE (green); // r, g, b
|
||||
WRITE_BYTE (blue); // r, g, b
|
||||
|
||||
WRITE_BYTE (brightness); // brightness
|
||||
WRITE_BYTE (speed); // speed
|
||||
MESSAGE_END ();
|
||||
}
|
||||
|
||||
void UpdateGlobalExperienceData (void)
|
||||
{
|
||||
// this function called after each end of the round to update knowledge about most dangerous waypoints for each team.
|
||||
|
|
@ -725,8 +574,8 @@ void UpdateGlobalExperienceData (void)
|
|||
{
|
||||
for (int i = 0; i < g_numWaypoints; i++)
|
||||
{
|
||||
(g_experienceData + (i * g_numWaypoints) + i)->team0Damage /= static_cast <unsigned short> (GetMaxClients () * 0.5);
|
||||
(g_experienceData + (i * g_numWaypoints) + i)->team1Damage /= static_cast <unsigned short> (GetMaxClients () * 0.5);
|
||||
(g_experienceData + (i * g_numWaypoints) + i)->team0Damage /= static_cast <unsigned short> (engine.MaxClients () * 0.5);
|
||||
(g_experienceData + (i * g_numWaypoints) + i)->team1Damage /= static_cast <unsigned short> (engine.MaxClients () * 0.5);
|
||||
}
|
||||
g_highestKills = 1;
|
||||
}
|
||||
|
|
@ -742,7 +591,7 @@ void RoundInit (void)
|
|||
bots.CheckTeamEconomics (TERRORIST);
|
||||
bots.CheckTeamEconomics (CT);
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
if (bots.GetBot (i))
|
||||
bots.GetBot (i)->NewRound ();
|
||||
|
|
@ -769,7 +618,7 @@ void RoundInit (void)
|
|||
UpdateGlobalExperienceData (); // update experience data on round start
|
||||
|
||||
// calculate the round mid/end in world time
|
||||
g_timeRoundStart = GetWorldTime () + mp_freezetime.GetFloat ();
|
||||
g_timeRoundStart = engine.Time () + mp_freezetime.GetFloat ();
|
||||
g_timeRoundMid = g_timeRoundStart + mp_roundtime.GetFloat () * 60.0f * 0.5f;
|
||||
g_timeRoundEnd = g_timeRoundStart + mp_roundtime.GetFloat () * 60.0f;
|
||||
}
|
||||
|
|
@ -824,135 +673,29 @@ bool IsValidBot (edict_t *ent)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool IsDedicatedServer (void)
|
||||
{
|
||||
// return true if server is dedicated server, false otherwise
|
||||
|
||||
return (IS_DEDICATED_SERVER () > 0); // ask engine for this
|
||||
}
|
||||
|
||||
void ServerPrint (const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char string[3072];
|
||||
|
||||
va_start (ap, format);
|
||||
vsprintf (string, locale.TranslateInput (format), ap);
|
||||
va_end (ap);
|
||||
|
||||
SERVER_PRINT (string);
|
||||
SERVER_PRINT ("\n");
|
||||
}
|
||||
|
||||
void CenterPrint (const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char string[2048];
|
||||
|
||||
va_start (ap, format);
|
||||
vsprintf (string, locale.TranslateInput (format), ap);
|
||||
va_end (ap);
|
||||
|
||||
if (IsDedicatedServer ())
|
||||
{
|
||||
ServerPrint (string);
|
||||
return;
|
||||
}
|
||||
|
||||
MESSAGE_BEGIN (MSG_BROADCAST, netmsg.GetId (NETMSG_TEXTMSG));
|
||||
WRITE_BYTE (HUD_PRINTCENTER);
|
||||
WRITE_STRING (FormatBuffer ("%s\n", string));
|
||||
MESSAGE_END ();
|
||||
}
|
||||
|
||||
void ChartPrint (const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char string[2048];
|
||||
|
||||
va_start (ap, format);
|
||||
vsprintf (string, locale.TranslateInput (format), ap);
|
||||
va_end (ap);
|
||||
|
||||
if (IsDedicatedServer ())
|
||||
{
|
||||
ServerPrint (string);
|
||||
return;
|
||||
}
|
||||
strcat (string, "\n");
|
||||
|
||||
MESSAGE_BEGIN (MSG_BROADCAST, netmsg.GetId (NETMSG_TEXTMSG));
|
||||
WRITE_BYTE (HUD_PRINTTALK);
|
||||
WRITE_STRING (string);
|
||||
MESSAGE_END ();
|
||||
}
|
||||
|
||||
void ClientPrint (edict_t *ent, int dest, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char string[2048];
|
||||
|
||||
va_start (ap, format);
|
||||
vsprintf (string, locale.TranslateInput (format), ap);
|
||||
va_end (ap);
|
||||
|
||||
if (IsEntityNull (ent) || ent == g_hostEntity)
|
||||
{
|
||||
ServerPrint (string);
|
||||
return;
|
||||
}
|
||||
strcat (string, "\n");
|
||||
(*g_engfuncs.pfnClientPrintf) (ent, static_cast <PRINT_TYPE> (dest), string);
|
||||
|
||||
}
|
||||
|
||||
void ServerCommand (const char *format, ...)
|
||||
{
|
||||
// this function asks the engine to execute a server command
|
||||
|
||||
va_list ap;
|
||||
static char string[1024];
|
||||
|
||||
// concatenate all the arguments in one string
|
||||
va_start (ap, format);
|
||||
vsprintf (string, format, ap);
|
||||
va_end (ap);
|
||||
|
||||
SERVER_COMMAND (const_cast <char *> (FormatBuffer ("%s\n", string))); // execute command
|
||||
}
|
||||
|
||||
const char *GetMapName (void)
|
||||
{
|
||||
// this function gets the map name and store it in the map_name global string variable.
|
||||
|
||||
static char mapName[256];
|
||||
strncpy (mapName, const_cast <const char *> (g_pGlobals->pStringBase + static_cast <int> (g_pGlobals->mapname)), SIZEOF_CHAR (mapName));
|
||||
|
||||
return &mapName[0]; // and return a pointer to it
|
||||
}
|
||||
|
||||
extern bool OpenConfig(const char *fileName, const char *errorIfNotExists, File *outFile, bool languageDependant /*= false*/)
|
||||
bool OpenConfig (const char *fileName, const char *errorIfNotExists, File *outFile, bool languageDependant /*= false*/)
|
||||
{
|
||||
if (outFile->IsValid ())
|
||||
outFile->Close ();
|
||||
|
||||
if (languageDependant)
|
||||
{
|
||||
const char *mod = engine.GetModName ();
|
||||
extern ConVar yb_language;
|
||||
|
||||
if (strcmp (fileName, "lang.cfg") == 0 && strcmp (yb_language.GetString (), "en") == 0)
|
||||
return false;
|
||||
|
||||
const char *languageDependantConfigFile = FormatBuffer ("%s/addons/yapb/conf/lang/%s_%s", GetModName (), yb_language.GetString (), fileName);
|
||||
const char *languageDependantConfigFile = FormatBuffer ("%s/addons/yapb/conf/lang/%s_%s", mod, yb_language.GetString (), fileName);
|
||||
|
||||
// check is file is exists for this language
|
||||
if (File::Accessible (languageDependantConfigFile))
|
||||
outFile->Open (languageDependantConfigFile, "rt");
|
||||
else
|
||||
outFile->Open (FormatBuffer ("%s/addons/yapb/conf/lang/en_%s", GetModName (), fileName), "rt");
|
||||
outFile->Open (FormatBuffer ("%s/addons/yapb/conf/lang/en_%s", mod, fileName), "rt");
|
||||
}
|
||||
else
|
||||
outFile->Open (FormatBuffer ("%s/addons/yapb/conf/%s", GetModName (), fileName), "rt");
|
||||
outFile->Open (FormatBuffer ("%s/addons/yapb/conf/%s", engine.GetModName (), fileName), "rt");
|
||||
|
||||
if (!outFile->IsValid ())
|
||||
{
|
||||
|
|
@ -964,20 +707,7 @@ extern bool OpenConfig(const char *fileName, const char *errorIfNotExists, File
|
|||
|
||||
const char *GetWaypointDir (void)
|
||||
{
|
||||
return FormatBuffer ("%s/addons/yapb/data/", GetModName ());
|
||||
}
|
||||
|
||||
extern void RegisterCommand(const char *command, void funcPtr (void))
|
||||
{
|
||||
// this function tells the engine that a new server command is being declared, in addition
|
||||
// to the standard ones, whose name is command_name. The engine is thus supposed to be aware
|
||||
// that for every "command_name" server command it receives, it should call the function
|
||||
// pointed to by "function" in order to handle it.
|
||||
|
||||
if (IsNullString (command) || funcPtr == NULL)
|
||||
return; // reliability check
|
||||
|
||||
REG_SVR_COMMAND (const_cast <char *> (command), funcPtr); // ask the engine to register this new command
|
||||
return FormatBuffer ("%s/addons/yapb/data/", engine.GetModName ());
|
||||
}
|
||||
|
||||
void CheckWelcomeMessage (void)
|
||||
|
|
@ -1014,14 +744,14 @@ void CheckWelcomeMessage (void)
|
|||
}
|
||||
|
||||
if (IsAlive (g_hostEntity) && !alreadyReceived && receiveTime < 1.0 && (g_numWaypoints > 0 ? g_isCommencing : true))
|
||||
receiveTime = GetWorldTime () + 4.0f; // receive welcome message in four seconds after game has commencing
|
||||
receiveTime = engine.Time () + 4.0f; // receive welcome message in four seconds after game has commencing
|
||||
|
||||
if (receiveTime > 0.0f && receiveTime < GetWorldTime () && !alreadyReceived && (g_numWaypoints > 0 ? g_isCommencing : true))
|
||||
if (receiveTime > 0.0f && receiveTime < engine.Time () && !alreadyReceived && (g_numWaypoints > 0 ? g_isCommencing : true))
|
||||
{
|
||||
if (!(g_gameFlags & (GAME_MOBILITY | GAME_XASH)))
|
||||
ServerCommand ("speak \"%s\"", const_cast <char *> (sentences.GetRandomElement ().GetBuffer ()));
|
||||
engine.IssueCmd ("speak \"%s\"", const_cast <char *> (sentences.GetRandomElement ().GetBuffer ()));
|
||||
|
||||
ChartPrint ("----- %s v%s (Build: %u), {%s}, (c) 2016, by %s (%s)-----", PRODUCT_NAME, PRODUCT_VERSION, GenerateBuildNumber (), PRODUCT_DATE, PRODUCT_AUTHOR, PRODUCT_URL);
|
||||
engine.ChatPrintf ("----- %s v%s (Build: %u), {%s}, (c) 2016, by %s (%s)-----", PRODUCT_NAME, PRODUCT_VERSION, GenerateBuildNumber (), PRODUCT_DATE, PRODUCT_AUTHOR, PRODUCT_URL);
|
||||
|
||||
MESSAGE_BEGIN (MSG_ONE, SVC_TEMPENTITY, NULL, g_hostEntity);
|
||||
WRITE_BYTE (TE_TEXTMESSAGE);
|
||||
|
|
@ -1074,48 +804,6 @@ void DetectCSVersion (void)
|
|||
(*g_engfuncs.pfnFreeFile) (detection);
|
||||
}
|
||||
|
||||
void PlaySound (edict_t *ent, const char *name)
|
||||
{
|
||||
// TODO: make this obsolete
|
||||
EMIT_SOUND_DYN2 (ent, CHAN_WEAPON, name, 1.0f, ATTN_NORM, 0, 100.0f);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
float GetWaveLength (const char *fileName)
|
||||
{
|
||||
WavHeader waveHdr;
|
||||
memset (&waveHdr, 0, sizeof (waveHdr));
|
||||
|
||||
extern ConVar yb_chatter_path;
|
||||
|
||||
File fp (FormatBuffer ("%s/%s/%s.wav", GetModName (), yb_chatter_path.GetString (), fileName), "rb");
|
||||
|
||||
// we're got valid handle?
|
||||
if (!fp.IsValid ())
|
||||
return 0;
|
||||
|
||||
if (fp.Read (&waveHdr, sizeof (WavHeader)) == 0)
|
||||
{
|
||||
AddLogEntry (true, LL_ERROR, "Wave File %s - has wrong or unsupported format", fileName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strncmp (waveHdr.chunkID, "WAVE", 4) != 0)
|
||||
{
|
||||
AddLogEntry (true, LL_ERROR, "Wave File %s - has wrong wave chunk id", fileName);
|
||||
return 0;
|
||||
}
|
||||
fp.Close ();
|
||||
|
||||
if (waveHdr.dataChunkLength == 0)
|
||||
{
|
||||
AddLogEntry (true, LL_ERROR, "Wave File %s - has zero length!", fileName);
|
||||
return 0;
|
||||
}
|
||||
return static_cast <float> (waveHdr.dataChunkLength) / static_cast <float> (waveHdr.bytesPerSecond);
|
||||
}
|
||||
|
||||
void AddLogEntry (bool outputToConsole, int logLevel, const char *format, ...)
|
||||
{
|
||||
// this function logs a message to the message log file root directory.
|
||||
|
|
@ -1147,7 +835,7 @@ void AddLogEntry (bool outputToConsole, int logLevel, const char *format, ...)
|
|||
}
|
||||
|
||||
if (outputToConsole)
|
||||
ServerPrint ("%s%s", levelString, buffer);
|
||||
engine.Printf ("%s%s", levelString, buffer);
|
||||
|
||||
// now check if logging disabled
|
||||
if (!(logLevel & LL_IGNORE))
|
||||
|
|
@ -1201,7 +889,7 @@ void AddLogEntry (bool outputToConsole, int logLevel, const char *format, ...)
|
|||
|
||||
char *Localizer::TranslateInput (const char *input)
|
||||
{
|
||||
if (IsDedicatedServer ())
|
||||
if (engine.IsDedicatedServer ())
|
||||
return const_cast <char *> (&input[0]);
|
||||
|
||||
static char string[1024];
|
||||
|
|
@ -1253,7 +941,7 @@ bool FindNearestPlayer (void **pvHolder, edict_t *to, float searchDistance, bool
|
|||
|
||||
int toTeam = GetTeam (to);
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
for (int i = 0; i < engine.MaxClients (); i++)
|
||||
{
|
||||
edict_t *ent = g_clients[i].ent;
|
||||
|
||||
|
|
@ -1292,15 +980,15 @@ void SoundAttachToClients (edict_t *ent, const char *sample, float volume)
|
|||
if (IsEntityNull (ent) || IsNullString (sample))
|
||||
return; // reliability check
|
||||
|
||||
const Vector &origin = GetEntityOrigin (ent);
|
||||
const Vector &origin = engine.GetAbsOrigin (ent);
|
||||
int index = IndexOfEntity (ent) - 1;
|
||||
|
||||
if (index < 0 || index >= GetMaxClients ())
|
||||
if (index < 0 || index >= engine.MaxClients ())
|
||||
{
|
||||
float nearestDistance = 99999.0f;
|
||||
|
||||
// loop through all 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))
|
||||
continue;
|
||||
|
|
@ -1324,49 +1012,49 @@ void SoundAttachToClients (edict_t *ent, const char *sample, float volume)
|
|||
{
|
||||
// hit/fall sound?
|
||||
client->hearingDistance = 768.0f * volume;
|
||||
client->timeSoundLasting = GetWorldTime () + 0.5f;
|
||||
client->timeSoundLasting = engine.Time () + 0.5f;
|
||||
client->soundPosition = origin;
|
||||
}
|
||||
else if (strncmp ("items/gunpickup", sample, 15) == 0)
|
||||
{
|
||||
// weapon pickup?
|
||||
client->hearingDistance = 768.0f * volume;
|
||||
client->timeSoundLasting = GetWorldTime () + 0.5f;
|
||||
client->timeSoundLasting = engine.Time () + 0.5f;
|
||||
client->soundPosition = origin;
|
||||
}
|
||||
else if (strncmp ("weapons/zoom", sample, 12) == 0)
|
||||
{
|
||||
// sniper zooming?
|
||||
client->hearingDistance = 512.0f * volume;
|
||||
client->timeSoundLasting = GetWorldTime () + 0.1f;
|
||||
client->timeSoundLasting = engine.Time () + 0.1f;
|
||||
client->soundPosition = origin;
|
||||
}
|
||||
else if (strncmp ("items/9mmclip", sample, 13) == 0)
|
||||
{
|
||||
// ammo pickup?
|
||||
client->hearingDistance = 512.0f * volume;
|
||||
client->timeSoundLasting = GetWorldTime () + 0.1f;
|
||||
client->timeSoundLasting = engine.Time () + 0.1f;
|
||||
client->soundPosition = origin;
|
||||
}
|
||||
else if (strncmp ("hostage/hos", sample, 11) == 0)
|
||||
{
|
||||
// CT used hostage?
|
||||
client->hearingDistance = 1024.0f * volume;
|
||||
client->timeSoundLasting = GetWorldTime () + 5.0f;
|
||||
client->timeSoundLasting = engine.Time () + 5.0f;
|
||||
client->soundPosition = origin;
|
||||
}
|
||||
else if (strncmp ("debris/bustmetal", sample, 16) == 0 || strncmp ("debris/bustglass", sample, 16) == 0)
|
||||
{
|
||||
// broke something?
|
||||
client->hearingDistance = 1024.0f * volume;
|
||||
client->timeSoundLasting = GetWorldTime () + 2.0f;
|
||||
client->timeSoundLasting = engine.Time () + 2.0f;
|
||||
client->soundPosition = origin;
|
||||
}
|
||||
else if (strncmp ("doors/doormove", sample, 14) == 0)
|
||||
{
|
||||
// someone opened a door
|
||||
client->hearingDistance = 1024.0f * volume;
|
||||
client->timeSoundLasting = GetWorldTime () + 3.0f;
|
||||
client->timeSoundLasting = engine.Time () + 3.0f;
|
||||
client->soundPosition = origin;
|
||||
}
|
||||
}
|
||||
|
|
@ -1376,7 +1064,7 @@ void SoundSimulateUpdate (int playerIndex)
|
|||
// this function tries to simulate playing of sounds to let the bots hear sounds which aren't
|
||||
// captured through server sound hooking
|
||||
|
||||
if (playerIndex < 0 || playerIndex >= GetMaxClients ())
|
||||
if (playerIndex < 0 || playerIndex >= engine.MaxClients ())
|
||||
return; // reliability check
|
||||
|
||||
Client *client = &g_clients[playerIndex];
|
||||
|
|
@ -1387,24 +1075,24 @@ void SoundSimulateUpdate (int playerIndex)
|
|||
if (client->ent->v.oldbuttons & IN_ATTACK) // pressed attack button?
|
||||
{
|
||||
hearDistance = 2048.0f;
|
||||
timeSound = GetWorldTime () + 0.3f;
|
||||
timeSound = engine.Time () + 0.3f;
|
||||
}
|
||||
else if (client->ent->v.oldbuttons & IN_USE) // pressed used button?
|
||||
{
|
||||
hearDistance = 512.0f;
|
||||
timeSound = GetWorldTime () + 0.5f;
|
||||
timeSound = engine.Time () + 0.5f;
|
||||
}
|
||||
else if (client->ent->v.oldbuttons & IN_RELOAD) // pressed reload button?
|
||||
{
|
||||
hearDistance = 512.0f;
|
||||
timeSound = GetWorldTime () + 0.5f;
|
||||
timeSound = engine.Time () + 0.5f;
|
||||
}
|
||||
else if (client->ent->v.movetype == MOVETYPE_FLY) // uses ladder?
|
||||
{
|
||||
if (fabsf (client->ent->v.velocity.z) > 50.0f)
|
||||
{
|
||||
hearDistance = 1024.0f;
|
||||
timeSound = GetWorldTime () + 0.3f;
|
||||
timeSound = engine.Time () + 0.3f;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -1415,7 +1103,7 @@ void SoundSimulateUpdate (int playerIndex)
|
|||
{
|
||||
// moves fast enough?
|
||||
hearDistance = 1280.0f * (client->ent->v.velocity.GetLength2D () / 260.0f);
|
||||
timeSound = GetWorldTime () + 0.3f;
|
||||
timeSound = engine.Time () + 0.3f;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1423,7 +1111,7 @@ void SoundSimulateUpdate (int playerIndex)
|
|||
return; // didn't issue sound?
|
||||
|
||||
// some sound already associated
|
||||
if (client->timeSoundLasting > GetWorldTime ())
|
||||
if (client->timeSoundLasting > engine.Time ())
|
||||
{
|
||||
if (client->hearingDistance <= hearDistance)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin)
|
|||
|
||||
if (!(path->flags & FLAG_CAMP))
|
||||
{
|
||||
CenterPrint ("This is not Camping Waypoint");
|
||||
engine.CenterPrintf ("This is not Camping Waypoint");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin)
|
|||
path->campEndY = forward.y;
|
||||
|
||||
// play "done" sound...
|
||||
PlaySound (g_hostEntity, "common/wpn_hudon.wav");
|
||||
engine.EmitSound (g_hostEntity, "common/wpn_hudon.wav");
|
||||
}
|
||||
return;
|
||||
|
||||
|
|
@ -366,7 +366,7 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin)
|
|||
if (m_paths[i]->flags & FLAG_LADDER)
|
||||
{
|
||||
// check if the waypoint is reachable from the new one
|
||||
TraceLine (newOrigin, m_paths[i]->origin, true, g_hostEntity, &tr);
|
||||
engine.TestLine (newOrigin, m_paths[i]->origin, TRACE_IGNORE_MONSTERS, g_hostEntity, &tr);
|
||||
|
||||
if (tr.flFraction == 1.0f && fabs (newOrigin.x - m_paths[i]->origin.x) < 64.0f && fabs (newOrigin.y - m_paths[i]->origin.y) < 64.0f && fabs (newOrigin.z - m_paths[i]->origin.z) < g_autoPathDistance)
|
||||
{
|
||||
|
|
@ -432,7 +432,7 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin)
|
|||
}
|
||||
}
|
||||
}
|
||||
PlaySound (g_hostEntity, "weapons/xbow_hit1.wav");
|
||||
engine.EmitSound (g_hostEntity, "weapons/xbow_hit1.wav");
|
||||
CalculateWayzone (index); // calculate the wayzone of this waypoint
|
||||
}
|
||||
|
||||
|
|
@ -497,7 +497,7 @@ void Waypoint::Delete (void)
|
|||
g_numWaypoints--;
|
||||
m_waypointDisplayTime[index] = 0;
|
||||
|
||||
PlaySound (g_hostEntity, "weapons/mine_activate.wav");
|
||||
engine.EmitSound (g_hostEntity, "weapons/mine_activate.wav");
|
||||
}
|
||||
|
||||
void Waypoint::ToggleFlags (int toggleFlag)
|
||||
|
|
@ -522,7 +522,7 @@ void Waypoint::ToggleFlags (int toggleFlag)
|
|||
}
|
||||
|
||||
// play "done" sound...
|
||||
PlaySound (g_hostEntity, "common/wpn_hudon.wav");
|
||||
engine.EmitSound (g_hostEntity, "common/wpn_hudon.wav");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -537,7 +537,7 @@ void Waypoint::SetRadius (int radius)
|
|||
m_paths[index]->radius = static_cast <float> (radius);
|
||||
|
||||
// play "done" sound...
|
||||
PlaySound (g_hostEntity, "common/wpn_hudon.wav");
|
||||
engine.EmitSound (g_hostEntity, "common/wpn_hudon.wav");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -594,7 +594,7 @@ void Waypoint::CreatePath (char dir)
|
|||
|
||||
if (nodeFrom == -1)
|
||||
{
|
||||
CenterPrint ("Unable to find nearest waypoint in 50 units");
|
||||
engine.CenterPrintf ("Unable to find nearest waypoint in 50 units");
|
||||
return;
|
||||
}
|
||||
int nodeTo = m_facingAtIndex;
|
||||
|
|
@ -605,14 +605,14 @@ void Waypoint::CreatePath (char dir)
|
|||
nodeTo = m_cacheWaypointIndex;
|
||||
else
|
||||
{
|
||||
CenterPrint ("Unable to find destination waypoint");
|
||||
engine.CenterPrintf ("Unable to find destination waypoint");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (nodeTo == nodeFrom)
|
||||
{
|
||||
CenterPrint ("Unable to connect waypoint with itself");
|
||||
engine.CenterPrintf ("Unable to connect waypoint with itself");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -628,7 +628,7 @@ void Waypoint::CreatePath (char dir)
|
|||
AddPath (nodeTo, nodeFrom, distance);
|
||||
}
|
||||
|
||||
PlaySound (g_hostEntity, "common/wpn_hudon.wav");
|
||||
engine.EmitSound (g_hostEntity, "common/wpn_hudon.wav");
|
||||
g_waypointsChanged = true;
|
||||
}
|
||||
|
||||
|
|
@ -642,7 +642,7 @@ void Waypoint::DeletePath (void)
|
|||
|
||||
if (nodeFrom == -1)
|
||||
{
|
||||
CenterPrint ("Unable to find nearest waypoint in 50 units");
|
||||
engine.CenterPrintf ("Unable to find nearest waypoint in 50 units");
|
||||
return;
|
||||
}
|
||||
int nodeTo = m_facingAtIndex;
|
||||
|
|
@ -653,7 +653,7 @@ void Waypoint::DeletePath (void)
|
|||
nodeTo = m_cacheWaypointIndex;
|
||||
else
|
||||
{
|
||||
CenterPrint ("Unable to find destination waypoint");
|
||||
engine.CenterPrintf ("Unable to find destination waypoint");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -669,7 +669,7 @@ void Waypoint::DeletePath (void)
|
|||
m_paths[nodeFrom]->connectionFlags[index] = 0;
|
||||
m_paths[nodeFrom]->connectionVelocity[index].Zero ();
|
||||
|
||||
PlaySound (g_hostEntity, "weapons/mine_activate.wav");
|
||||
engine.EmitSound (g_hostEntity, "weapons/mine_activate.wav");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -691,11 +691,11 @@ void Waypoint::DeletePath (void)
|
|||
m_paths[nodeFrom]->connectionFlags[index] = 0;
|
||||
m_paths[nodeFrom]->connectionVelocity[index].Zero ();
|
||||
|
||||
PlaySound (g_hostEntity, "weapons/mine_activate.wav");
|
||||
engine.EmitSound (g_hostEntity, "weapons/mine_activate.wav");
|
||||
return;
|
||||
}
|
||||
}
|
||||
CenterPrint ("There is already no path on this waypoint");
|
||||
engine.CenterPrintf ("There is already no path on this waypoint");
|
||||
}
|
||||
|
||||
void Waypoint::CacheWaypoint (void)
|
||||
|
|
@ -705,12 +705,12 @@ void Waypoint::CacheWaypoint (void)
|
|||
if (node == -1)
|
||||
{
|
||||
m_cacheWaypointIndex = -1;
|
||||
CenterPrint ("Cached waypoint cleared (nearby point not found in 50 units range)");
|
||||
engine.CenterPrintf ("Cached waypoint cleared (nearby point not found in 50 units range)");
|
||||
|
||||
return;
|
||||
}
|
||||
m_cacheWaypointIndex = node;
|
||||
CenterPrint ("Waypoint #%d has been put into memory", m_cacheWaypointIndex);
|
||||
engine.CenterPrintf ("Waypoint #%d has been put into memory", m_cacheWaypointIndex);
|
||||
}
|
||||
|
||||
void Waypoint::CalculateWayzone (int index)
|
||||
|
|
@ -755,11 +755,11 @@ void Waypoint::CalculateWayzone (int index)
|
|||
Vector radiusStart = start - g_pGlobals->v_forward * scanDistance;
|
||||
Vector radiusEnd = start + g_pGlobals->v_forward * scanDistance;
|
||||
|
||||
TraceHull (radiusStart, radiusEnd, true, head_hull, NULL, &tr);
|
||||
engine.TestHull (radiusStart, radiusEnd, TRACE_IGNORE_MONSTERS, head_hull, NULL, &tr);
|
||||
|
||||
if (tr.flFraction < 1.0f)
|
||||
{
|
||||
TraceLine (radiusStart, radiusEnd, true, NULL, &tr);
|
||||
engine.TestLine (radiusStart, radiusEnd, TRACE_IGNORE_MONSTERS, NULL, &tr);
|
||||
|
||||
if (FClassnameIs (tr.pHit, "func_door") || FClassnameIs (tr.pHit, "func_door_rotating"))
|
||||
{
|
||||
|
|
@ -778,7 +778,7 @@ void Waypoint::CalculateWayzone (int index)
|
|||
Vector dropStart = start + g_pGlobals->v_forward * scanDistance;
|
||||
Vector dropEnd = dropStart - Vector (0.0f, 0.0f, scanDistance + 60.0f);
|
||||
|
||||
TraceHull (dropStart, dropEnd, true, head_hull, NULL, &tr);
|
||||
engine.TestHull (dropStart, dropEnd, TRACE_IGNORE_MONSTERS, head_hull, NULL, &tr);
|
||||
|
||||
if (tr.flFraction >= 1.0f)
|
||||
{
|
||||
|
|
@ -790,7 +790,7 @@ void Waypoint::CalculateWayzone (int index)
|
|||
dropStart = start - g_pGlobals->v_forward * scanDistance;
|
||||
dropEnd = dropStart - Vector (0.0f, 0.0f, scanDistance + 60.0f);
|
||||
|
||||
TraceHull (dropStart, dropEnd, true, head_hull, NULL, &tr);
|
||||
engine.TestHull (dropStart, dropEnd, TRACE_IGNORE_MONSTERS, head_hull, NULL, &tr);
|
||||
|
||||
if (tr.flFraction >= 1.0f)
|
||||
{
|
||||
|
|
@ -800,7 +800,7 @@ void Waypoint::CalculateWayzone (int index)
|
|||
}
|
||||
|
||||
radiusEnd.z += 34.0f;
|
||||
TraceHull (radiusStart, radiusEnd, true, head_hull, NULL, &tr);
|
||||
engine.TestHull (radiusStart, radiusEnd, TRACE_IGNORE_MONSTERS, head_hull, NULL, &tr);
|
||||
|
||||
if (tr.flFraction < 1.0f)
|
||||
{
|
||||
|
|
@ -846,7 +846,7 @@ void Waypoint::SaveExperienceTab (void)
|
|||
}
|
||||
}
|
||||
|
||||
int result = Compressor::Compress (FormatBuffer ("%slearned/%s.exp", GetWaypointDir (), GetMapName ()), (unsigned char *)&header, sizeof (ExtensionHeader), (unsigned char *)experienceSave, g_numWaypoints * g_numWaypoints * sizeof (ExperienceSave));
|
||||
int result = Compressor::Compress (FormatBuffer ("%slearned/%s.exp", GetWaypointDir (), engine.GetMapName ()), (unsigned char *)&header, sizeof (ExtensionHeader), (unsigned char *)experienceSave, g_numWaypoints * g_numWaypoints * sizeof (ExperienceSave));
|
||||
|
||||
delete [] experienceSave;
|
||||
|
||||
|
|
@ -885,7 +885,7 @@ void Waypoint::InitExperienceTab (void)
|
|||
(g_experienceData + (i * g_numWaypoints) + j)->team1Value = 0;
|
||||
}
|
||||
}
|
||||
File fp (FormatBuffer ("%slearned/%s.exp", GetWaypointDir (), GetMapName ()), "rb");
|
||||
File fp (FormatBuffer ("%slearned/%s.exp", GetWaypointDir (), engine.GetMapName ()), "rb");
|
||||
|
||||
// if file exists, read the experience data from it
|
||||
if (fp.IsValid ())
|
||||
|
|
@ -908,7 +908,7 @@ void Waypoint::InitExperienceTab (void)
|
|||
{
|
||||
ExperienceSave *experienceLoad = new ExperienceSave[g_numWaypoints * g_numWaypoints];
|
||||
|
||||
Compressor::Uncompress (FormatBuffer ("%slearned/%s.exp", GetWaypointDir (), GetMapName ()), sizeof (ExtensionHeader), (unsigned char *)experienceLoad, g_numWaypoints * g_numWaypoints * sizeof (ExperienceSave));
|
||||
Compressor::Uncompress (FormatBuffer ("%slearned/%s.exp", GetWaypointDir (), engine.GetMapName ()), sizeof (ExtensionHeader), (unsigned char *)experienceLoad, g_numWaypoints * g_numWaypoints * sizeof (ExperienceSave));
|
||||
|
||||
for (i = 0; i < g_numWaypoints; i++)
|
||||
{
|
||||
|
|
@ -958,7 +958,7 @@ void Waypoint::SaveVisibilityTab (void)
|
|||
header.fileVersion = FV_VISTABLE;
|
||||
header.pointNumber = g_numWaypoints;
|
||||
|
||||
File fp (FormatBuffer ("%slearned/%s.vis", GetWaypointDir (), GetMapName ()), "wb");
|
||||
File fp (FormatBuffer ("%slearned/%s.vis", GetWaypointDir (), engine.GetMapName ()), "wb");
|
||||
|
||||
if (!fp.IsValid ())
|
||||
{
|
||||
|
|
@ -967,7 +967,7 @@ void Waypoint::SaveVisibilityTab (void)
|
|||
}
|
||||
fp.Close ();
|
||||
|
||||
Compressor::Compress (FormatBuffer ("%slearned/%s.vis", GetWaypointDir (), GetMapName ()), (unsigned char *) &header, sizeof (ExtensionHeader), (unsigned char *) m_visLUT, MAX_WAYPOINTS * (MAX_WAYPOINTS / 4) * sizeof (byte));
|
||||
Compressor::Compress (FormatBuffer ("%slearned/%s.vis", GetWaypointDir (), engine.GetMapName ()), (unsigned char *) &header, sizeof (ExtensionHeader), (unsigned char *) m_visLUT, MAX_WAYPOINTS * (MAX_WAYPOINTS / 4) * sizeof (byte));
|
||||
}
|
||||
|
||||
void Waypoint::InitVisibilityTab (void)
|
||||
|
|
@ -977,7 +977,7 @@ void Waypoint::InitVisibilityTab (void)
|
|||
|
||||
ExtensionHeader header;
|
||||
|
||||
File fp (FormatBuffer ("%slearned/%s.vis", GetWaypointDir (), GetMapName ()), "rb");
|
||||
File fp (FormatBuffer ("%slearned/%s.vis", GetWaypointDir (), engine.GetMapName ()), "rb");
|
||||
m_redoneVisibility = false;
|
||||
|
||||
if (!fp.IsValid ())
|
||||
|
|
@ -1008,7 +1008,7 @@ void Waypoint::InitVisibilityTab (void)
|
|||
|
||||
return;
|
||||
}
|
||||
int result = Compressor::Uncompress (FormatBuffer ("%slearned/%s.vis", GetWaypointDir (), GetMapName ()), sizeof (ExtensionHeader), (unsigned char *) m_visLUT, MAX_WAYPOINTS * (MAX_WAYPOINTS / 4) * sizeof (byte));
|
||||
int result = Compressor::Uncompress (FormatBuffer ("%slearned/%s.vis", GetWaypointDir (), engine.GetMapName ()), sizeof (ExtensionHeader), (unsigned char *) m_visLUT, MAX_WAYPOINTS * (MAX_WAYPOINTS / 4) * sizeof (byte));
|
||||
|
||||
if (result == -1)
|
||||
{
|
||||
|
|
@ -1057,11 +1057,14 @@ bool Waypoint::Load (void)
|
|||
WaypointHeader header;
|
||||
memset (&header, 0, sizeof (header));
|
||||
|
||||
// save for faster access
|
||||
const char *map = engine.GetMapName ();
|
||||
|
||||
if (fp.IsValid ())
|
||||
{
|
||||
if (fp.Read (&header, sizeof (header)) == 0)
|
||||
{
|
||||
sprintf (m_infoBuffer, "%s.pwf - damaged waypoint file (unable to read header)", GetMapName ());
|
||||
sprintf (m_infoBuffer, "%s.pwf - damaged waypoint file (unable to read header)", map);
|
||||
AddLogEntry (true, LL_ERROR, m_infoBuffer);
|
||||
|
||||
fp.Close ();
|
||||
|
|
@ -1072,15 +1075,15 @@ bool Waypoint::Load (void)
|
|||
{
|
||||
if (header.fileVersion != FV_WAYPOINT)
|
||||
{
|
||||
sprintf (m_infoBuffer, "%s.pwf - incorrect waypoint file version (expected '%d' found '%ld')", GetMapName (), FV_WAYPOINT, header.fileVersion);
|
||||
sprintf (m_infoBuffer, "%s.pwf - incorrect waypoint file version (expected '%d' found '%ld')", map, FV_WAYPOINT, header.fileVersion);
|
||||
AddLogEntry (true, LL_ERROR, m_infoBuffer);
|
||||
|
||||
fp.Close ();
|
||||
return false;
|
||||
}
|
||||
else if (stricmp (header.mapName, GetMapName ()))
|
||||
else if (stricmp (header.mapName, map))
|
||||
{
|
||||
sprintf (m_infoBuffer, "%s.pwf - hacked waypoint file, file name doesn't match waypoint header information (mapname: '%s', header: '%s')", GetMapName (), GetMapName (), header.mapName);
|
||||
sprintf (m_infoBuffer, "%s.pwf - hacked waypoint file, file name doesn't match waypoint header information (mapname: '%s', header: '%s')", map, map, header.mapName);
|
||||
AddLogEntry (true, LL_ERROR, m_infoBuffer);
|
||||
|
||||
fp.Close ();
|
||||
|
|
@ -1090,7 +1093,7 @@ bool Waypoint::Load (void)
|
|||
{
|
||||
if (header.pointNumber == 0 || header.pointNumber > MAX_WAYPOINTS)
|
||||
{
|
||||
sprintf (m_infoBuffer, "%s.pwf - waypoint file contains illegal number of waypoints (mapname: '%s', header: '%s')", GetMapName (), GetMapName (), header.mapName);
|
||||
sprintf (m_infoBuffer, "%s.pwf - waypoint file contains illegal number of waypoints (mapname: '%s', header: '%s')", map, map, header.mapName);
|
||||
AddLogEntry (true, LL_ERROR, m_infoBuffer);
|
||||
|
||||
fp.Close ();
|
||||
|
|
@ -1109,7 +1112,7 @@ bool Waypoint::Load (void)
|
|||
|
||||
if (fp.Read (m_paths[i], sizeof (Path)) == 0)
|
||||
{
|
||||
sprintf (m_infoBuffer, "%s.pwf - truncated waypoint file (count: %d, need: %d)", GetMapName (), i, g_numWaypoints);
|
||||
sprintf (m_infoBuffer, "%s.pwf - truncated waypoint file (count: %d, need: %d)", map, i, g_numWaypoints);
|
||||
AddLogEntry (true, LL_ERROR, m_infoBuffer);
|
||||
|
||||
fp.Close ();
|
||||
|
|
@ -1121,7 +1124,7 @@ bool Waypoint::Load (void)
|
|||
}
|
||||
else
|
||||
{
|
||||
sprintf (m_infoBuffer, "%s.pwf is not a yapb waypoint file (header found '%s' needed '%s'", GetMapName (), header.header, FH_WAYPOINT);
|
||||
sprintf (m_infoBuffer, "%s.pwf is not a yapb waypoint file (header found '%s' needed '%s'", map, header.header, FH_WAYPOINT);
|
||||
AddLogEntry (true, LL_ERROR, m_infoBuffer);
|
||||
|
||||
fp.Close ();
|
||||
|
|
@ -1133,14 +1136,14 @@ bool Waypoint::Load (void)
|
|||
{
|
||||
if (yb_waypoint_autodl_enable.GetBool ())
|
||||
{
|
||||
AddLogEntry (true, LL_DEFAULT, "%s.pwf does not exist, trying to download from waypoint database", GetMapName ());
|
||||
AddLogEntry (true, LL_DEFAULT, "%s.pwf does not exist, trying to download from waypoint database", map);
|
||||
|
||||
WaypointDownloader dl;
|
||||
WaypointDownloadError status = dl.DoDownload ();
|
||||
|
||||
if (status == WDE_SOCKET_ERROR)
|
||||
{
|
||||
sprintf (m_infoBuffer, "%s.pwf does not exist. Can't autodownload. Socket error.", GetMapName ());
|
||||
sprintf (m_infoBuffer, "%s.pwf does not exist. Can't autodownload. Socket error.", map);
|
||||
AddLogEntry (true, LL_ERROR, m_infoBuffer);
|
||||
|
||||
yb_waypoint_autodl_enable.SetInt (0);
|
||||
|
|
@ -1149,7 +1152,7 @@ bool Waypoint::Load (void)
|
|||
}
|
||||
else if (status == WDE_CONNECT_ERROR)
|
||||
{
|
||||
sprintf (m_infoBuffer, "%s.pwf does not exist. Can't autodownload. Connection problems.", GetMapName ());
|
||||
sprintf (m_infoBuffer, "%s.pwf does not exist. Can't autodownload. Connection problems.", map);
|
||||
AddLogEntry (true, LL_ERROR, m_infoBuffer);
|
||||
|
||||
yb_waypoint_autodl_enable.SetInt (0);
|
||||
|
|
@ -1158,18 +1161,18 @@ bool Waypoint::Load (void)
|
|||
}
|
||||
else if (status == WDE_NOTFOUND_ERROR)
|
||||
{
|
||||
sprintf (m_infoBuffer, "%s.pwf does not exist. Can't autodownload. Waypoint not available.", GetMapName ());
|
||||
sprintf (m_infoBuffer, "%s.pwf does not exist. Can't autodownload. Waypoint not available.", map);
|
||||
AddLogEntry (true, LL_ERROR, m_infoBuffer);
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
AddLogEntry (true, LL_DEFAULT, "%s.pwf was downloaded from waypoint database. Trying to load...", GetMapName ());
|
||||
AddLogEntry (true, LL_DEFAULT, "%s.pwf was downloaded from waypoint database. Trying to load...", map);
|
||||
return Load ();
|
||||
}
|
||||
}
|
||||
sprintf (m_infoBuffer, "%s.pwf does not exist", GetMapName ());
|
||||
sprintf (m_infoBuffer, "%s.pwf does not exist", map);
|
||||
AddLogEntry (true, LL_ERROR, m_infoBuffer);
|
||||
|
||||
return false;
|
||||
|
|
@ -1213,7 +1216,7 @@ void Waypoint::Save (void)
|
|||
|
||||
strcpy (header.header, FH_WAYPOINT);
|
||||
strncpy (header.author, STRING (g_hostEntity->v.netname), SIZEOF_CHAR (header.author));
|
||||
strncpy (header.mapName, GetMapName (), SIZEOF_CHAR (header.mapName));
|
||||
strncpy (header.mapName, engine.GetMapName (), SIZEOF_CHAR (header.mapName));
|
||||
|
||||
header.mapName[31] = 0;
|
||||
header.fileVersion = FV_WAYPOINT;
|
||||
|
|
@ -1234,7 +1237,7 @@ void Waypoint::Save (void)
|
|||
fp.Close ();
|
||||
}
|
||||
else
|
||||
AddLogEntry (true, LL_ERROR, "Error writing '%s.pwf' waypoint file", GetMapName ());
|
||||
AddLogEntry (true, LL_ERROR, "Error writing '%s.pwf' waypoint file", engine.GetMapName ());
|
||||
}
|
||||
|
||||
String Waypoint::CheckSubfolderFile (void)
|
||||
|
|
@ -1244,12 +1247,12 @@ String Waypoint::CheckSubfolderFile (void)
|
|||
if (!IsNullString (yb_wptsubfolder.GetString ()))
|
||||
returnFile += (String (yb_wptsubfolder.GetString ()) + "/");
|
||||
|
||||
returnFile = FormatBuffer ("%s%s%s.pwf", GetWaypointDir (), returnFile.GetBuffer (), GetMapName ());
|
||||
returnFile = FormatBuffer ("%s%s%s.pwf", GetWaypointDir (), returnFile.GetBuffer (), engine.GetMapName ());
|
||||
|
||||
if (File::Accessible (returnFile))
|
||||
return returnFile;
|
||||
|
||||
return FormatBuffer ("%s%s.pwf", GetWaypointDir (), GetMapName ());
|
||||
return FormatBuffer ("%s%s.pwf", GetWaypointDir (), engine.GetMapName ());
|
||||
}
|
||||
|
||||
float Waypoint::GetTravelTime (float maxSpeed, const Vector &src, const Vector &origin)
|
||||
|
|
@ -1276,7 +1279,7 @@ bool Waypoint::Reachable (Bot *bot, int index)
|
|||
return false;
|
||||
|
||||
TraceResult tr;
|
||||
TraceLine (src, dest, true, bot->GetEntity (), &tr);
|
||||
engine.TestLine (src, dest, TRACE_IGNORE_MONSTERS, bot->GetEntity (), &tr);
|
||||
|
||||
// if waypoint is visible from current position (even behind head)...
|
||||
if (tr.flFraction >= 1.0f)
|
||||
|
|
@ -1306,13 +1309,13 @@ bool Waypoint::IsNodeReachable (const Vector &src, const Vector &destination)
|
|||
return false;
|
||||
|
||||
// check if we go through a func_illusionary, in which case return false
|
||||
TraceHull (src, destination, ignore_monsters, head_hull, g_hostEntity, &tr);
|
||||
engine.TestHull (src, destination, TRACE_IGNORE_MONSTERS, head_hull, g_hostEntity, &tr);
|
||||
|
||||
if (!IsEntityNull (tr.pHit) && strcmp ("func_illusionary", STRING (tr.pHit->v.classname)) == 0)
|
||||
return false; // don't add pathwaypoints through func_illusionaries
|
||||
|
||||
// check if this waypoint is "visible"...
|
||||
TraceLine (src, destination, ignore_monsters, g_hostEntity, &tr);
|
||||
engine.TestLine (src, destination, TRACE_IGNORE_MONSTERS, g_hostEntity, &tr);
|
||||
|
||||
// if waypoint is visible from current position (even behind head)...
|
||||
if (tr.flFraction >= 1.0f || strncmp ("func_door", STRING (tr.pHit->v.classname), 9) == 0)
|
||||
|
|
@ -1320,7 +1323,7 @@ bool Waypoint::IsNodeReachable (const Vector &src, const Vector &destination)
|
|||
// if it's a door check if nothing blocks behind
|
||||
if (strncmp ("func_door", STRING (tr.pHit->v.classname), 9) == 0)
|
||||
{
|
||||
TraceLine (tr.vecEndPos, destination, ignore_monsters, tr.pHit, &tr);
|
||||
engine.TestLine (tr.vecEndPos, destination, TRACE_IGNORE_MONSTERS, tr.pHit, &tr);
|
||||
|
||||
if (tr.flFraction < 1.0f)
|
||||
return false;
|
||||
|
|
@ -1337,7 +1340,7 @@ bool Waypoint::IsNodeReachable (const Vector &src, const Vector &destination)
|
|||
Vector destinationNew = destination;
|
||||
destinationNew.z = destinationNew.z - 50.0f; // straight down 50 units
|
||||
|
||||
TraceLine (sourceNew, destinationNew, ignore_monsters, g_hostEntity, &tr);
|
||||
engine.TestLine (sourceNew, destinationNew, TRACE_IGNORE_MONSTERS, g_hostEntity, &tr);
|
||||
|
||||
// check if we didn't hit anything, if not then it's in mid-air
|
||||
if (tr.flFraction >= 1.0)
|
||||
|
|
@ -1350,7 +1353,7 @@ bool Waypoint::IsNodeReachable (const Vector &src, const Vector &destination)
|
|||
|
||||
down.z = down.z - 1000.0f; // straight down 1000 units
|
||||
|
||||
TraceLine (check, down, ignore_monsters, g_hostEntity, &tr);
|
||||
engine.TestLine (check, down, TRACE_IGNORE_MONSTERS, g_hostEntity, &tr);
|
||||
|
||||
float lastHeight = tr.flFraction * 1000.0f; // height from ground
|
||||
distance = (destination - check).GetLength (); // distance from goal
|
||||
|
|
@ -1363,7 +1366,7 @@ bool Waypoint::IsNodeReachable (const Vector &src, const Vector &destination)
|
|||
down = check;
|
||||
down.z = down.z - 1000.0f; // straight down 1000 units
|
||||
|
||||
TraceLine (check, down, ignore_monsters, g_hostEntity, &tr);
|
||||
engine.TestLine (check, down, TRACE_IGNORE_MONSTERS, g_hostEntity, &tr);
|
||||
|
||||
float height = tr.flFraction * 1000.0f; // height from ground
|
||||
|
||||
|
|
@ -1409,7 +1412,7 @@ void Waypoint::InitializeVisibility (void)
|
|||
// first check ducked visibility
|
||||
Vector dest = m_paths[i]->origin;
|
||||
|
||||
TraceLine (sourceDuck, dest, true, NULL, &tr);
|
||||
engine.TestLine (sourceDuck, dest, TRACE_IGNORE_MONSTERS, NULL, &tr);
|
||||
|
||||
// check if line of sight to object is not blocked (i.e. visible)
|
||||
if (tr.flFraction != 1.0f || tr.fStartSolid)
|
||||
|
|
@ -1419,7 +1422,7 @@ void Waypoint::InitializeVisibility (void)
|
|||
|
||||
res <<= 1;
|
||||
|
||||
TraceLine (sourceStand, dest, true, NULL, &tr);
|
||||
engine.TestLine (sourceStand, dest, TRACE_IGNORE_MONSTERS, NULL, &tr);
|
||||
|
||||
// check if line of sight to object is not blocked (i.e. visible)
|
||||
if (tr.flFraction != 1.0f || tr.fStartSolid)
|
||||
|
|
@ -1511,7 +1514,7 @@ void Waypoint::Think (void)
|
|||
{
|
||||
Add (9);
|
||||
|
||||
m_timeJumpStarted = GetWorldTime ();
|
||||
m_timeJumpStarted = engine.Time ();
|
||||
m_endJumpPoint = true;
|
||||
}
|
||||
else
|
||||
|
|
@ -1520,7 +1523,7 @@ void Waypoint::Think (void)
|
|||
m_learnPosition = g_hostEntity->v.origin;
|
||||
}
|
||||
}
|
||||
else if (((g_hostEntity->v.flags & FL_ONGROUND) || g_hostEntity->v.movetype == MOVETYPE_FLY) && m_timeJumpStarted + 0.1 < GetWorldTime () && m_endJumpPoint)
|
||||
else if (((g_hostEntity->v.flags & FL_ONGROUND) || g_hostEntity->v.movetype == MOVETYPE_FLY) && m_timeJumpStarted + 0.1 < engine.Time () && m_endJumpPoint)
|
||||
{
|
||||
Add (10);
|
||||
|
||||
|
|
@ -1574,7 +1577,7 @@ void Waypoint::Think (void)
|
|||
nearestDistance = distance;
|
||||
}
|
||||
|
||||
if (m_waypointDisplayTime[i] + 0.8f < GetWorldTime ())
|
||||
if (m_waypointDisplayTime[i] + 0.8f < engine.Time ())
|
||||
{
|
||||
float nodeHeight = 0.0f;
|
||||
|
||||
|
|
@ -1616,13 +1619,13 @@ void Waypoint::Think (void)
|
|||
|
||||
// draw node without additional flags
|
||||
if (nodeFlagColor.x == -1)
|
||||
DrawLine (g_hostEntity, m_paths[i]->origin - Vector (0, 0, nodeHalfHeight), m_paths[i]->origin + Vector (0, 0, nodeHalfHeight), 15, 0, static_cast <int> (nodeColor.x), static_cast <int> (nodeColor.y), static_cast <int> (nodeColor.z), 250, 0, 10);
|
||||
engine.DrawLine (g_hostEntity, m_paths[i]->origin - Vector (0, 0, nodeHalfHeight), m_paths[i]->origin + Vector (0, 0, nodeHalfHeight), 15, 0, static_cast <int> (nodeColor.x), static_cast <int> (nodeColor.y), static_cast <int> (nodeColor.z), 250, 0, 10);
|
||||
else // draw node with flags
|
||||
{
|
||||
DrawLine (g_hostEntity, m_paths[i]->origin - Vector (0, 0, nodeHalfHeight), m_paths[i]->origin - Vector (0, 0, nodeHalfHeight - nodeHeight * 0.75), 14, 0, static_cast <int> (nodeColor.x), static_cast <int> (nodeColor.y), static_cast <int> (nodeColor.z), 250, 0, 10); // draw basic path
|
||||
DrawLine (g_hostEntity, m_paths[i]->origin - Vector (0, 0, nodeHalfHeight - nodeHeight * 0.75), m_paths[i]->origin + Vector (0, 0, nodeHalfHeight), 14, 0, static_cast <int> (nodeFlagColor.x), static_cast <int> (nodeFlagColor.y), static_cast <int> (nodeFlagColor.z), 250, 0, 10); // draw additional path
|
||||
engine.DrawLine (g_hostEntity, m_paths[i]->origin - Vector (0, 0, nodeHalfHeight), m_paths[i]->origin - Vector (0, 0, nodeHalfHeight - nodeHeight * 0.75), 14, 0, static_cast <int> (nodeColor.x), static_cast <int> (nodeColor.y), static_cast <int> (nodeColor.z), 250, 0, 10); // draw basic path
|
||||
engine.DrawLine (g_hostEntity, m_paths[i]->origin - Vector (0, 0, nodeHalfHeight - nodeHeight * 0.75), m_paths[i]->origin + Vector (0, 0, nodeHalfHeight), 14, 0, static_cast <int> (nodeFlagColor.x), static_cast <int> (nodeFlagColor.y), static_cast <int> (nodeFlagColor.z), 250, 0, 10); // draw additional path
|
||||
}
|
||||
m_waypointDisplayTime[i] = GetWorldTime ();
|
||||
m_waypointDisplayTime[i] = engine.Time ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1634,21 +1637,21 @@ void Waypoint::Think (void)
|
|||
if ((m_findWPIndex != -1 && m_findWPIndex < g_numWaypoints) || (m_cacheWaypointIndex != -1 && m_cacheWaypointIndex < g_numWaypoints) || (m_facingAtIndex != -1 && m_facingAtIndex < g_numWaypoints))
|
||||
{
|
||||
// check for drawing code
|
||||
if (m_arrowDisplayTime + 0.5f < GetWorldTime ())
|
||||
if (m_arrowDisplayTime + 0.5f < engine.Time ())
|
||||
{
|
||||
// finding waypoint - pink arrow
|
||||
if (m_findWPIndex != -1)
|
||||
DrawArrow (g_hostEntity, g_hostEntity->v.origin, m_paths[m_findWPIndex]->origin, 10, 0, 128, 0, 128, 200, 0, 5);
|
||||
engine.DrawLine (g_hostEntity, g_hostEntity->v.origin, m_paths[m_findWPIndex]->origin, 10, 0, 128, 0, 128, 200, 0, 5, DRAW_ARROW);
|
||||
|
||||
// cached waypoint - yellow arrow
|
||||
if (m_cacheWaypointIndex != -1)
|
||||
DrawArrow (g_hostEntity, g_hostEntity->v.origin, m_paths[m_cacheWaypointIndex]->origin, 10, 0, 255, 255, 0, 200, 0, 5);
|
||||
engine.DrawLine (g_hostEntity, g_hostEntity->v.origin, m_paths[m_cacheWaypointIndex]->origin, 10, 0, 255, 255, 0, 200, 0, 5, DRAW_ARROW);
|
||||
|
||||
// waypoint user facing at - white arrow
|
||||
if (m_facingAtIndex != -1)
|
||||
DrawArrow (g_hostEntity, g_hostEntity->v.origin, m_paths[m_facingAtIndex]->origin, 10, 0, 255, 255, 255, 200, 0, 5);
|
||||
engine.DrawLine (g_hostEntity, g_hostEntity->v.origin, m_paths[m_facingAtIndex]->origin, 10, 0, 255, 255, 255, 200, 0, 5, DRAW_ARROW);
|
||||
|
||||
m_arrowDisplayTime = GetWorldTime ();
|
||||
m_arrowDisplayTime = engine.Time ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1656,9 +1659,9 @@ void Waypoint::Think (void)
|
|||
Path *path = m_paths[nearestIndex];
|
||||
|
||||
// draw a paths, camplines and danger directions for nearest waypoint
|
||||
if (nearestDistance <= 56.0f && m_pathDisplayTime <= GetWorldTime ())
|
||||
if (nearestDistance <= 56.0f && m_pathDisplayTime <= engine.Time ())
|
||||
{
|
||||
m_pathDisplayTime = GetWorldTime () + 1.0f;
|
||||
m_pathDisplayTime = engine.Time () + 1.0f;
|
||||
|
||||
// draw the camplines
|
||||
if (path->flags & FLAG_CAMP)
|
||||
|
|
@ -1673,8 +1676,8 @@ void Waypoint::Think (void)
|
|||
Vector campEndOrigin = Vector (path->campEndX, path->campEndY, campSourceOrigin.z); // camp end
|
||||
|
||||
// draw it now
|
||||
DrawLine (g_hostEntity, campSourceOrigin, campStartOrigin, 10, 0, 255, 0, 0, 200, 0, 10);
|
||||
DrawLine (g_hostEntity, campSourceOrigin, campEndOrigin, 10, 0, 255, 0, 0, 200, 0, 10);
|
||||
engine.DrawLine (g_hostEntity, campSourceOrigin, campStartOrigin, 10, 0, 255, 0, 0, 200, 0, 10);
|
||||
engine.DrawLine (g_hostEntity, campSourceOrigin, campEndOrigin, 10, 0, 255, 0, 0, 200, 0, 10);
|
||||
}
|
||||
|
||||
// draw the connections
|
||||
|
|
@ -1685,18 +1688,18 @@ void Waypoint::Think (void)
|
|||
|
||||
// jump connection
|
||||
if (path->connectionFlags[i] & PATHFLAG_JUMP)
|
||||
DrawLine (g_hostEntity, path->origin, m_paths[path->index[i]]->origin, 5, 0, 255, 0, 128, 200, 0, 10);
|
||||
engine.DrawLine (g_hostEntity, path->origin, m_paths[path->index[i]]->origin, 5, 0, 255, 0, 128, 200, 0, 10);
|
||||
else if (IsConnected (path->index[i], nearestIndex)) // twoway connection
|
||||
DrawLine (g_hostEntity, path->origin, m_paths[path->index[i]]->origin, 5, 0, 255, 255, 0, 200, 0, 10);
|
||||
engine.DrawLine (g_hostEntity, path->origin, m_paths[path->index[i]]->origin, 5, 0, 255, 255, 0, 200, 0, 10);
|
||||
else // oneway connection
|
||||
DrawLine (g_hostEntity, path->origin, m_paths[path->index[i]]->origin, 5, 0, 250, 250, 250, 200, 0, 10);
|
||||
engine.DrawLine (g_hostEntity, path->origin, m_paths[path->index[i]]->origin, 5, 0, 250, 250, 250, 200, 0, 10);
|
||||
}
|
||||
|
||||
// now look for oneway incoming connections
|
||||
for (int i = 0; i < g_numWaypoints; i++)
|
||||
{
|
||||
if (IsConnected (m_paths[i]->pathNumber, path->pathNumber) && !IsConnected (path->pathNumber, m_paths[i]->pathNumber))
|
||||
DrawLine (g_hostEntity, path->origin, m_paths[i]->origin, 5, 0, 0, 192, 96, 200, 0, 10);
|
||||
engine.DrawLine (g_hostEntity, path->origin, m_paths[i]->origin, 5, 0, 0, 192, 96, 200, 0, 10);
|
||||
}
|
||||
|
||||
// draw the radius circle
|
||||
|
|
@ -1707,34 +1710,34 @@ void Waypoint::Think (void)
|
|||
{
|
||||
float squareRoot = sqrtf (path->radius * path->radius * 0.5f);
|
||||
|
||||
DrawLine (g_hostEntity, origin + Vector (path->radius, 0.0f, 0.0f), origin + Vector (squareRoot, -squareRoot, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10);
|
||||
DrawLine (g_hostEntity, origin + Vector (squareRoot, -squareRoot, 0.0f), origin + Vector (0.0f, -path->radius, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10);
|
||||
engine.DrawLine (g_hostEntity, origin + Vector (path->radius, 0.0f, 0.0f), origin + Vector (squareRoot, -squareRoot, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10);
|
||||
engine.DrawLine (g_hostEntity, origin + Vector (squareRoot, -squareRoot, 0.0f), origin + Vector (0.0f, -path->radius, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10);
|
||||
|
||||
DrawLine (g_hostEntity, origin + Vector (0.0f, -path->radius, 0.0f), origin + Vector (-squareRoot, -squareRoot, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10);
|
||||
DrawLine (g_hostEntity, origin + Vector (-squareRoot, -squareRoot, 0.0f), origin + Vector (-path->radius, 0.0f, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10);
|
||||
engine.DrawLine (g_hostEntity, origin + Vector (0.0f, -path->radius, 0.0f), origin + Vector (-squareRoot, -squareRoot, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10);
|
||||
engine.DrawLine (g_hostEntity, origin + Vector (-squareRoot, -squareRoot, 0.0f), origin + Vector (-path->radius, 0.0f, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10);
|
||||
|
||||
DrawLine (g_hostEntity, origin + Vector (-path->radius, 0.0f, 0.0f), origin + Vector (-squareRoot, squareRoot, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10);
|
||||
DrawLine (g_hostEntity, origin + Vector (-squareRoot, squareRoot, 0.0f), origin + Vector (0.0f, path->radius, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10);
|
||||
engine.DrawLine (g_hostEntity, origin + Vector (-path->radius, 0.0f, 0.0f), origin + Vector (-squareRoot, squareRoot, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10);
|
||||
engine.DrawLine (g_hostEntity, origin + Vector (-squareRoot, squareRoot, 0.0f), origin + Vector (0.0f, path->radius, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10);
|
||||
|
||||
DrawLine (g_hostEntity, origin + Vector (0.0f, path->radius, 0.0f), origin + Vector (squareRoot, squareRoot, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10);
|
||||
DrawLine (g_hostEntity, origin + Vector (squareRoot, squareRoot, 0.0f), origin + Vector (path->radius, 0.0f, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10);
|
||||
engine.DrawLine (g_hostEntity, origin + Vector (0.0f, path->radius, 0.0f), origin + Vector (squareRoot, squareRoot, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10);
|
||||
engine.DrawLine (g_hostEntity, origin + Vector (squareRoot, squareRoot, 0.0f), origin + Vector (path->radius, 0.0f, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
float squareRoot = sqrtf (32.0f);
|
||||
|
||||
DrawLine (g_hostEntity, origin + Vector (squareRoot, -squareRoot, 0.0f), origin + Vector (-squareRoot, squareRoot, 0.0f), 5, 0, 255, 0, 0, 200, 0, 10);
|
||||
DrawLine (g_hostEntity, origin + Vector (-squareRoot, -squareRoot, 0.0f), origin + Vector (squareRoot, squareRoot, 0.0f), 5, 0, 255, 0, 0, 200, 0, 10);
|
||||
engine.DrawLine (g_hostEntity, origin + Vector (squareRoot, -squareRoot, 0.0f), origin + Vector (-squareRoot, squareRoot, 0.0f), 5, 0, 255, 0, 0, 200, 0, 10);
|
||||
engine.DrawLine (g_hostEntity, origin + Vector (-squareRoot, -squareRoot, 0.0f), origin + Vector (squareRoot, squareRoot, 0.0f), 5, 0, 255, 0, 0, 200, 0, 10);
|
||||
}
|
||||
|
||||
// draw the danger directions
|
||||
if (!g_waypointsChanged)
|
||||
{
|
||||
if ((g_experienceData + (nearestIndex * g_numWaypoints) + nearestIndex)->team0DangerIndex != -1 && GetTeam (g_hostEntity) == TERRORIST)
|
||||
DrawArrow (g_hostEntity, path->origin, m_paths[(g_experienceData + (nearestIndex * g_numWaypoints) + nearestIndex)->team0DangerIndex]->origin, 15, 0, 255, 0, 0, 200, 0, 10); // draw a red arrow to this index's danger point
|
||||
engine.DrawLine (g_hostEntity, path->origin, m_paths[(g_experienceData + (nearestIndex * g_numWaypoints) + nearestIndex)->team0DangerIndex]->origin, 15, 0, 255, 0, 0, 200, 0, 10, DRAW_ARROW); // draw a red arrow to this index's danger point
|
||||
|
||||
if ((g_experienceData + (nearestIndex * g_numWaypoints) + nearestIndex)->team1DangerIndex != -1 && GetTeam (g_hostEntity) == CT)
|
||||
DrawArrow (g_hostEntity, path->origin, m_paths[(g_experienceData + (nearestIndex * g_numWaypoints) + nearestIndex)->team1DangerIndex]->origin, 15, 0, 0, 0, 255, 200, 0, 10); // draw a blue arrow to this index's danger point
|
||||
engine.DrawLine (g_hostEntity, path->origin, m_paths[(g_experienceData + (nearestIndex * g_numWaypoints) + nearestIndex)->team1DangerIndex]->origin, 15, 0, 0, 0, 255, 200, 0, 10, DRAW_ARROW); // draw a blue arrow to this index's danger point
|
||||
}
|
||||
|
||||
// display some information
|
||||
|
|
@ -1889,7 +1892,7 @@ bool Waypoint::NodesValid (void)
|
|||
{
|
||||
AddLogEntry (true, LL_WARNING, "Waypoint %d - Pathindex %d points to itself!", i, k);
|
||||
|
||||
if (g_waypointOn && !IsDedicatedServer ())
|
||||
if (g_waypointOn && !engine.IsDedicatedServer ())
|
||||
{
|
||||
(*g_engfuncs.pfnSetOrigin) (g_hostEntity, m_paths[i]->origin);
|
||||
|
||||
|
|
@ -1972,7 +1975,7 @@ bool Waypoint::NodesValid (void)
|
|||
{
|
||||
AddLogEntry (true, LL_WARNING, "Path broken from Waypoint #0 to Waypoint #%d!", i);
|
||||
|
||||
if (g_waypointOn && !IsDedicatedServer ())
|
||||
if (g_waypointOn && !engine.IsDedicatedServer ())
|
||||
{
|
||||
(*g_engfuncs.pfnSetOrigin) (g_hostEntity, m_paths[i]->origin);
|
||||
|
||||
|
|
@ -2033,7 +2036,7 @@ bool Waypoint::NodesValid (void)
|
|||
{
|
||||
AddLogEntry (true, LL_WARNING, "Path broken from Waypoint #%d to Waypoint #0!", i);
|
||||
|
||||
if (g_waypointOn && !IsDedicatedServer ())
|
||||
if (g_waypointOn && !engine.IsDedicatedServer ())
|
||||
{
|
||||
(*g_engfuncs.pfnSetOrigin) (g_hostEntity, m_paths[i]->origin);
|
||||
|
||||
|
|
@ -2107,7 +2110,7 @@ void Waypoint::InitPathMatrix (void)
|
|||
|
||||
void Waypoint::SavePathMatrix (void)
|
||||
{
|
||||
File fp (FormatBuffer ("%slearned/%s.pmt", GetWaypointDir (), GetMapName ()), "wb");
|
||||
File fp (FormatBuffer ("%slearned/%s.pmt", GetWaypointDir (), engine.GetMapName ()), "wb");
|
||||
|
||||
// unable to open file
|
||||
if (!fp.IsValid ())
|
||||
|
|
@ -2129,7 +2132,7 @@ void Waypoint::SavePathMatrix (void)
|
|||
|
||||
bool Waypoint::LoadPathMatrix (void)
|
||||
{
|
||||
File fp (FormatBuffer ("%slearned/%s.pmt", GetWaypointDir (), GetMapName ()), "rb");
|
||||
File fp (FormatBuffer ("%slearned/%s.pmt", GetWaypointDir (), engine.GetMapName ()), "rb");
|
||||
|
||||
// file doesn't exists return false
|
||||
if (!fp.IsValid ())
|
||||
|
|
@ -2218,7 +2221,7 @@ void Waypoint::CreateBasic (void)
|
|||
Vector up, down, front, back;
|
||||
|
||||
Vector diff = ((ladderLeft - ladderRight) ^ Vector (0.0f, 0.0f, 0.0f)).Normalize () * 15.0f;
|
||||
front = back = GetEntityOrigin (ent);
|
||||
front = back = engine.GetAbsOrigin (ent);
|
||||
|
||||
front = front + diff; // front
|
||||
back = back - diff; // back
|
||||
|
|
@ -2226,7 +2229,7 @@ void Waypoint::CreateBasic (void)
|
|||
up = down = front;
|
||||
down.z = ent->v.absmax.z;
|
||||
|
||||
TraceHull (down, up, true, point_hull, NULL, &tr);
|
||||
engine.TestHull (down, up, TRACE_IGNORE_MONSTERS, point_hull, NULL, &tr);
|
||||
|
||||
if (POINT_CONTENTS (up) == CONTENTS_SOLID || tr.flFraction != 1.0f)
|
||||
{
|
||||
|
|
@ -2234,7 +2237,7 @@ void Waypoint::CreateBasic (void)
|
|||
down.z = ent->v.absmax.z;
|
||||
}
|
||||
|
||||
TraceHull (down, up - Vector (0.0f, 0.0f, 1000.0f), true, point_hull, NULL, &tr);
|
||||
engine.TestHull (down, up - Vector (0.0f, 0.0f, 1000.0f), TRACE_IGNORE_MONSTERS, point_hull, NULL, &tr);
|
||||
up = tr.vecEndPos;
|
||||
|
||||
Vector pointOrigin = up + Vector (0.0f, 0.0f, 39.0f);
|
||||
|
|
@ -2259,7 +2262,7 @@ void Waypoint::CreateBasic (void)
|
|||
// then terrortist spawnpoints
|
||||
while (!IsEntityNull (ent = FIND_ENTITY_BY_CLASSNAME (ent, "info_player_deathmatch")))
|
||||
{
|
||||
Vector origin = GetEntityOrigin (ent);
|
||||
Vector origin = engine.GetAbsOrigin (ent);
|
||||
|
||||
if (FindNearest (origin, 50.0f) == -1)
|
||||
Add (0, origin);
|
||||
|
|
@ -2268,7 +2271,7 @@ void Waypoint::CreateBasic (void)
|
|||
// then add ct spawnpoints
|
||||
while (!IsEntityNull (ent = FIND_ENTITY_BY_CLASSNAME (ent, "info_player_start")))
|
||||
{
|
||||
Vector origin = GetEntityOrigin (ent);
|
||||
Vector origin = engine.GetAbsOrigin (ent);
|
||||
|
||||
if (FindNearest (origin, 50.0f) == -1)
|
||||
Add (0, origin);
|
||||
|
|
@ -2277,7 +2280,7 @@ void Waypoint::CreateBasic (void)
|
|||
// then vip spawnpoint
|
||||
while (!IsEntityNull (ent = FIND_ENTITY_BY_CLASSNAME (ent, "info_vip_start")))
|
||||
{
|
||||
Vector origin = GetEntityOrigin (ent);
|
||||
Vector origin = engine.GetAbsOrigin (ent);
|
||||
|
||||
if (FindNearest (origin, 50.0f) == -1)
|
||||
Add (0, origin);
|
||||
|
|
@ -2286,7 +2289,7 @@ void Waypoint::CreateBasic (void)
|
|||
// hostage rescue zone
|
||||
while (!IsEntityNull (ent = FIND_ENTITY_BY_CLASSNAME (ent, "func_hostage_rescue")))
|
||||
{
|
||||
Vector origin = GetEntityOrigin (ent);
|
||||
Vector origin = engine.GetAbsOrigin (ent);
|
||||
|
||||
if (FindNearest (origin, 50.0f) == -1)
|
||||
Add (4, origin);
|
||||
|
|
@ -2295,7 +2298,7 @@ void Waypoint::CreateBasic (void)
|
|||
// hostage rescue zone (same as above)
|
||||
while (!IsEntityNull (ent = FIND_ENTITY_BY_CLASSNAME (ent, "info_hostage_rescue")))
|
||||
{
|
||||
Vector origin = GetEntityOrigin (ent);
|
||||
Vector origin = engine.GetAbsOrigin (ent);
|
||||
|
||||
if (FindNearest (origin, 50.0f) == -1)
|
||||
Add (4, origin);
|
||||
|
|
@ -2304,7 +2307,7 @@ void Waypoint::CreateBasic (void)
|
|||
// bombspot zone
|
||||
while (!IsEntityNull (ent = FIND_ENTITY_BY_CLASSNAME (ent, "func_bomb_target")))
|
||||
{
|
||||
Vector origin = GetEntityOrigin (ent);
|
||||
Vector origin = engine.GetAbsOrigin (ent);
|
||||
|
||||
if (FindNearest (origin, 50.0f) == -1)
|
||||
Add (100, origin);
|
||||
|
|
@ -2313,7 +2316,7 @@ void Waypoint::CreateBasic (void)
|
|||
// bombspot zone (same as above)
|
||||
while (!IsEntityNull (ent = FIND_ENTITY_BY_CLASSNAME (ent, "info_bomb_target")))
|
||||
{
|
||||
Vector origin = GetEntityOrigin (ent);
|
||||
Vector origin = engine.GetAbsOrigin (ent);
|
||||
|
||||
if (FindNearest (origin, 50.0f) == -1)
|
||||
Add (100, origin);
|
||||
|
|
@ -2326,7 +2329,7 @@ void Waypoint::CreateBasic (void)
|
|||
if ((ent->v.effects & EF_NODRAW) && ent->v.speed > 0.0f)
|
||||
continue;
|
||||
|
||||
Vector origin = GetEntityOrigin (ent);
|
||||
Vector origin = engine.GetAbsOrigin (ent);
|
||||
|
||||
if (FindNearest (origin, 50) == -1)
|
||||
Add (100, origin);
|
||||
|
|
@ -2335,7 +2338,7 @@ void Waypoint::CreateBasic (void)
|
|||
// vip rescue (safety) zone
|
||||
while (!IsEntityNull (ent = FIND_ENTITY_BY_CLASSNAME (ent, "func_vip_safetyzone")))
|
||||
{
|
||||
Vector origin = GetEntityOrigin (ent);
|
||||
Vector origin = engine.GetAbsOrigin (ent);
|
||||
|
||||
if (FindNearest (origin, 50.0f) == -1)
|
||||
Add (100, origin);
|
||||
|
|
@ -2344,7 +2347,7 @@ void Waypoint::CreateBasic (void)
|
|||
// terrorist escape zone
|
||||
while (!IsEntityNull (ent = FIND_ENTITY_BY_CLASSNAME (ent, "func_escapezone")))
|
||||
{
|
||||
Vector origin = GetEntityOrigin (ent);
|
||||
Vector origin = engine.GetAbsOrigin (ent);
|
||||
|
||||
if (FindNearest (origin, 50.0f) == -1)
|
||||
Add (100, origin);
|
||||
|
|
@ -2353,7 +2356,7 @@ void Waypoint::CreateBasic (void)
|
|||
// weapons on the map ?
|
||||
while (!IsEntityNull (ent = FIND_ENTITY_BY_CLASSNAME (ent, "armoury_entity")))
|
||||
{
|
||||
Vector origin = GetEntityOrigin (ent);
|
||||
Vector origin = engine.GetAbsOrigin (ent);
|
||||
|
||||
if (FindNearest (origin, 50.0f) == -1)
|
||||
Add (0, origin);
|
||||
|
|
@ -2375,13 +2378,14 @@ void Waypoint::EraseFromHardDisk (void)
|
|||
// this function removes waypoint file from the hard disk
|
||||
|
||||
String deleteList[5];
|
||||
const char *map = engine.GetMapName ();
|
||||
|
||||
// if we're delete waypoint, delete all corresponding to it files
|
||||
deleteList[0] = FormatBuffer ("%s%s.pwf", GetWaypointDir (), GetMapName ()); // waypoint itself
|
||||
deleteList[1] = FormatBuffer ("%slearned/%s.exp", GetWaypointDir (), GetMapName ()); // corresponding to waypoint experience
|
||||
deleteList[3] = FormatBuffer ("%slearned/%s.vis", GetWaypointDir (), GetMapName ()); // corresponding to waypoint vistable
|
||||
deleteList[3] = FormatBuffer ("%slearned/%s.pmt", GetWaypointDir (), GetMapName ()); // corresponding to waypoint path matrix
|
||||
deleteList[4] = FormatBuffer ("%slearned/%s.xml", GetWaypointDir (), GetMapName ()); // corresponding to waypoint xml database
|
||||
deleteList[0] = FormatBuffer ("%s%s.pwf", GetWaypointDir (), map); // waypoint itself
|
||||
deleteList[1] = FormatBuffer ("%slearned/%s.exp", GetWaypointDir (), map); // corresponding to waypoint experience
|
||||
deleteList[3] = FormatBuffer ("%slearned/%s.vis", GetWaypointDir (), map); // corresponding to waypoint vistable
|
||||
deleteList[3] = FormatBuffer ("%slearned/%s.pmt", GetWaypointDir (), map); // corresponding to waypoint path matrix
|
||||
deleteList[4] = FormatBuffer ("%slearned/%s.xml", GetWaypointDir (), map); // corresponding to waypoint xml database
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
|
|
@ -2414,7 +2418,7 @@ void Waypoint::SetBombPosition (bool shouldReset)
|
|||
{
|
||||
if (strcmp (STRING (ent->v.model) + 9, "c4.mdl") == 0)
|
||||
{
|
||||
m_foundBombOrigin = GetEntityOrigin (ent);
|
||||
m_foundBombOrigin = engine.GetAbsOrigin (ent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -2430,7 +2434,7 @@ void Waypoint::SetFindIndex (int index)
|
|||
m_findWPIndex = index;
|
||||
|
||||
if (m_findWPIndex < g_numWaypoints)
|
||||
ServerPrint ("Showing Direction to Waypoint #%d", m_findWPIndex);
|
||||
engine.Printf ("Showing Direction to Waypoint #%d", m_findWPIndex);
|
||||
else
|
||||
m_findWPIndex = -1;
|
||||
}
|
||||
|
|
@ -2548,7 +2552,7 @@ WaypointDownloadError WaypointDownloader::DoDownload (void)
|
|||
}
|
||||
|
||||
String request;
|
||||
request.AssignFormat ("GET /wpdb/%s.pwf HTTP/1.0\r\nAccept: */*\r\nUser-Agent: YaPB/%s\r\nHost: %s\r\n\r\n", GetMapName (), PRODUCT_VERSION, yb_waypoint_autodl_host.GetString ());
|
||||
request.AssignFormat ("GET /wpdb/%s.pwf HTTP/1.0\r\nAccept: */*\r\nUser-Agent: YaPB/%s\r\nHost: %s\r\n\r\n", engine.GetMapName (), PRODUCT_VERSION, yb_waypoint_autodl_host.GetString ());
|
||||
|
||||
if (send (socketHandle, request.GetBuffer (), request.GetLength () + 1, 0) < 1)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue