replaced random number generator with faster one
optimized breakable handling (need testing)
This commit is contained in:
parent
f0dcda5747
commit
e5ce504176
15 changed files with 308 additions and 415 deletions
|
|
@ -1219,7 +1219,8 @@ public:
|
|||
bool EntityIsVisible (const Vector &dest, bool fromBody = false);
|
||||
|
||||
void SwitchChatterIcon (bool show);
|
||||
void DeleteSearchNodes (void);
|
||||
void DeleteSearchNodes (void);
|
||||
void VerifyBreakable (edict_t *touch);
|
||||
|
||||
void RemoveCertainTask (TaskId_t id);
|
||||
void StartTask (TaskId_t id, float desire, int data, float time, bool canContinue);
|
||||
|
|
|
|||
|
|
@ -236,71 +236,54 @@ namespace Math
|
|||
}
|
||||
|
||||
//
|
||||
// Class: RandGen
|
||||
// Class: RandomSequenceOfUnique
|
||||
// Random number generator used by the bot code.
|
||||
// See: https://github.com/preshing/RandomSequence/
|
||||
//
|
||||
class RandGen
|
||||
class RandomSequenceOfUnique
|
||||
{
|
||||
private:
|
||||
enum GenerationConstants_t
|
||||
{ KK = 17, JJ = 10, R1 = 19, R2 = 27 };
|
||||
|
||||
int m_bufferIndex1;
|
||||
int m_bufferIndex2;
|
||||
|
||||
union
|
||||
{
|
||||
long double m_randomPtr;
|
||||
uint32 m_randomBits[3];
|
||||
};
|
||||
|
||||
uint32 m_historyBuffer[KK][2];
|
||||
uint32 m_selfTestBuffer[KK * 2][2];
|
||||
unsigned int m_index;
|
||||
unsigned int m_intermediateOffset;
|
||||
unsigned long long m_divider;
|
||||
|
||||
private:
|
||||
unsigned int PermuteQPR (unsigned int x)
|
||||
{
|
||||
static const unsigned int prime = 4294967291u;
|
||||
|
||||
//
|
||||
// Function: Random
|
||||
// Generates random number.
|
||||
//
|
||||
long double Random (void);
|
||||
if (x >= prime)
|
||||
return x;
|
||||
|
||||
//
|
||||
// Function: GetRandomBits
|
||||
// Generates random bits for random number generator.
|
||||
//
|
||||
uint32 GetRandomBits (void);
|
||||
unsigned int residue = (static_cast <unsigned long long> (x)* x) % prime;
|
||||
|
||||
return (x <= prime / 2) ? residue : prime - residue;
|
||||
}
|
||||
|
||||
unsigned int Random (void)
|
||||
{
|
||||
return PermuteQPR ((PermuteQPR (m_index++) + m_intermediateOffset) ^ 0x5bf03635);
|
||||
}
|
||||
public:
|
||||
RandomSequenceOfUnique (void)
|
||||
{
|
||||
unsigned int seedBase = time (NULL);
|
||||
unsigned int seedOffset = seedBase + 1;
|
||||
|
||||
//
|
||||
// Function: Initialize
|
||||
// Initializes random number generator using specified seed.
|
||||
//
|
||||
// Parameters:
|
||||
// seed - Seed for the random generator.
|
||||
//
|
||||
void Initialize (uint32 seed);
|
||||
m_index = PermuteQPR (PermuteQPR (seedBase) + 0x682f0161);
|
||||
m_intermediateOffset = PermuteQPR (PermuteQPR (seedOffset) + 0x46790905);
|
||||
m_divider = (static_cast <unsigned long long> (1)) << 32;
|
||||
}
|
||||
|
||||
//
|
||||
// Function: Long
|
||||
// Generates random 32bit long random number between specified bounds.
|
||||
//
|
||||
// Parameters:
|
||||
// low - Lowest number.
|
||||
// high - Higher number.
|
||||
//
|
||||
int Long (int low, int high);
|
||||
inline int Long (int low, int high)
|
||||
{
|
||||
return static_cast <int> (Random () * (static_cast <double> (high)-static_cast <double> (low)+1.0) / m_divider + static_cast <double> (low));
|
||||
}
|
||||
|
||||
//
|
||||
// Function: Float
|
||||
// Generates random 32bit float random number between specified bounds.
|
||||
//
|
||||
// Parameters:
|
||||
// low - Lowest number.
|
||||
// high - Higher number.
|
||||
//
|
||||
float Float (float low, float high);
|
||||
inline float Float (float low, float high)
|
||||
{
|
||||
return static_cast <float> (Random () * (static_cast <double> (high)-static_cast <double> (low)) / (m_divider - 1) + static_cast <double> (low));
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
|
|
@ -1633,9 +1616,9 @@ public:
|
|||
//
|
||||
T &GetRandomElement (void) const
|
||||
{
|
||||
extern class RandGen g_randGen;
|
||||
extern class RandomSequenceOfUnique Random;
|
||||
|
||||
return m_elements[g_randGen.Long (0, m_itemCount - 1)];
|
||||
return m_elements[Random.Long (0, m_itemCount - 1)];
|
||||
}
|
||||
|
||||
Array <T> &operator = (const Array <T> &other)
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ extern Array <Array <String> > g_chatFactory;
|
|||
extern Array <Array <ChatterItem> > g_chatterFactory;
|
||||
extern Array <BotName> g_botNames;
|
||||
extern Array <KeywordFactory> g_replyFactory;
|
||||
extern RandGen g_randGen;
|
||||
extern RandomSequenceOfUnique Random;
|
||||
|
||||
extern FireDelay g_fireDelay[NUM_WEAPONS + 1];
|
||||
extern WeaponSelect g_weaponSelect[NUM_WEAPONS + 1];
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@
|
|||
#define PRODUCT_LEGAL "Half-Life, Counter-Strike, Counter-Strike: Condition Zero, Steam, Valve is a trademark of Valve Corporation"
|
||||
#define PRODUCT_ORIGINAL_NAME "yapb.dll"
|
||||
#define PRODUCT_INTERNAL_NAME "podbot"
|
||||
#define PRODUCT_VERSION_DWORD 2,7,0 // major version, minor version, WIP (or Update) version, BUILD number (generated with RES file)
|
||||
#define PRODUCT_VERSION_DWORD 2,7,0,0 // major version, minor version, WIP (or Update) version
|
||||
#define PRODUCT_SUPPORT_VERSION "1.0 - CZ"
|
||||
#define PRODUCT_COMMENTS "http://github.com/jeefo/yapb/"
|
||||
#define PRODUCT_DATE __DATE__
|
||||
|
||||
|
|
|
|||
|
|
@ -1,36 +1,18 @@
|
|||
//
|
||||
// Copyright (c) 2003-2007, by YaPB Development Team. All rights reserved.
|
||||
// Yet Another POD-Bot, based on PODBot by Markus Klinge ("CountFloyd").
|
||||
// Copyright (c) YaPB Development Team.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
// Version: $Id$
|
||||
// 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 <winver.h>
|
||||
#include <../include/resource.h>
|
||||
|
||||
// generated by update tool -- do not edit --
|
||||
#define PRODUCT_BUILD_TOOL 4153
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION PRODUCT_VERSION_DWORD, PRODUCT_BUILD_TOOL
|
||||
PRODUCTVERSION PRODUCT_VERSION_DWORD, PRODUCT_BUILD_TOOL
|
||||
FILEVERSION PRODUCT_VERSION_DWORD
|
||||
PRODUCTVERSION PRODUCT_VERSION_DWORD
|
||||
FILEOS 0x40004
|
||||
FILETYPE 0x2
|
||||
{
|
||||
|
|
@ -45,6 +27,7 @@ FILETYPE 0x2
|
|||
VALUE "LegalCopyright", PRODUCT_COPYRIGHT "\0"
|
||||
VALUE "LegalTrademarks", PRODUCT_LEGAL "\0"
|
||||
VALUE "ProductName", PRODUCT_NAME "\0"
|
||||
VALUE "ProductVersion", PRODUCT_COMMENTS "\0"
|
||||
VALUE "InternalName", PRODUCT_INTERNAL_NAME "\0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,9 +164,9 @@ bool Bot::CheckVisibility (entvars_t *targetEntity, Vector *origin, byte *bodyPa
|
|||
Vector targetOrigin = targetEntity->origin; // get the player origin
|
||||
|
||||
// find the vector beetwen mins and maxs of the player body
|
||||
targetOrigin.x += g_randGen.Float (targetEntity->mins.x * 0.5, targetEntity->maxs.x * 0.5);
|
||||
targetOrigin.y += g_randGen.Float (targetEntity->mins.y * 0.5, targetEntity->maxs.y * 0.5);
|
||||
targetOrigin.z += g_randGen.Float (targetEntity->mins.z * 0.5, targetEntity->maxs.z * 0.5);
|
||||
targetOrigin.x += Random.Float (targetEntity->mins.x * 0.5, targetEntity->maxs.x * 0.5);
|
||||
targetOrigin.y += Random.Float (targetEntity->mins.y * 0.5, targetEntity->maxs.y * 0.5);
|
||||
targetOrigin.z += Random.Float (targetEntity->mins.z * 0.5, targetEntity->maxs.z * 0.5);
|
||||
|
||||
// check direct line to random part of the player body
|
||||
TraceLine (botHead, targetOrigin, true, true, GetEntity (), &tr);
|
||||
|
|
@ -417,10 +417,25 @@ bool Bot::RateGroundWeapon (edict_t *ent)
|
|||
return groundIndex > hasWeapon;
|
||||
}
|
||||
|
||||
void Bot::VerifyBreakable (edict_t *touch)
|
||||
{
|
||||
if (m_breakableCheckTime >= GetWorldTime () || !IsShootableBreakable (touch))
|
||||
return;
|
||||
|
||||
m_breakableEntity = FindBreakable ();
|
||||
|
||||
if (IsEntityNull (m_breakableEntity))
|
||||
return;
|
||||
|
||||
m_campButtons = pev->button & IN_DUCK;
|
||||
|
||||
StartTask (TASK_SHOOTBREAKABLE, TASKPRI_SHOOTBREAKABLE, -1, 0.0, false);
|
||||
m_breakableCheckTime = GetWorldTime () + 1.0f;
|
||||
}
|
||||
|
||||
edict_t *Bot::FindBreakable (void)
|
||||
{
|
||||
// this function checks if bot is blocked by a shoot able breakable in his moving direction
|
||||
// @todo@
|
||||
|
||||
TraceResult tr;
|
||||
TraceLine (pev->origin, pev->origin + (m_destOrigin - pev->origin).Normalize () * 64, false, false, GetEntity (), &tr);
|
||||
|
|
@ -490,7 +505,7 @@ void Bot::SetIdealReactionTimes (bool actual)
|
|||
|
||||
return;
|
||||
}
|
||||
m_idealReactionTime = g_randGen.Float (min, max);
|
||||
m_idealReactionTime = Random.Float (min, max);
|
||||
}
|
||||
|
||||
void Bot::FindItem (void)
|
||||
|
|
@ -654,12 +669,12 @@ void Bot::FindItem (void)
|
|||
m_itemIgnore = ent;
|
||||
allowPickup = false;
|
||||
|
||||
if (!m_defendHostage && m_difficulty >= 3 && g_randGen.Long (0, 100) < 30 && m_timeCamping + 15.0f < GetWorldTime ())
|
||||
if (!m_defendHostage && m_difficulty >= 3 && Random.Long (0, 100) < 30 && m_timeCamping + 15.0f < GetWorldTime ())
|
||||
{
|
||||
int index = FindDefendWaypoint (entityOrigin);
|
||||
|
||||
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + g_randGen.Float (30.0, 60.0), true); // push camp task on to stack
|
||||
StartTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + g_randGen.Float (3.0, 6.0), true); // push move command
|
||||
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (30.0, 60.0), true); // push camp task on to stack
|
||||
StartTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + Random.Float (3.0, 6.0), true); // push move command
|
||||
|
||||
if (g_waypoint->GetPath (index)->vis.crouch <= g_waypoint->GetPath (index)->vis.stand)
|
||||
m_campButtons |= IN_DUCK;
|
||||
|
|
@ -698,7 +713,7 @@ void Bot::FindItem (void)
|
|||
else
|
||||
m_campButtons &= ~IN_DUCK;
|
||||
|
||||
if (g_randGen.Long (0, 100) < 90)
|
||||
if (Random.Long (0, 100) < 90)
|
||||
ChatterMessage (Chatter_DefendingBombSite);
|
||||
}
|
||||
else
|
||||
|
|
@ -735,7 +750,7 @@ void Bot::FindItem (void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (g_randGen.Long (0, 100) < 90)
|
||||
if (Random.Long (0, 100) < 90)
|
||||
ChatterMessage (Chatter_FoundBombPlace);
|
||||
|
||||
allowPickup = !IsBombDefusing (g_waypoint->GetBombPosition ()) || m_hasProgressBar;
|
||||
|
|
@ -760,7 +775,7 @@ void Bot::FindItem (void)
|
|||
else
|
||||
m_campButtons &= ~IN_DUCK;
|
||||
|
||||
if (g_randGen.Long (0, 100) < 90)
|
||||
if (Random.Long (0, 100) < 90)
|
||||
ChatterMessage (Chatter_DefendingBombSite);
|
||||
}
|
||||
}
|
||||
|
|
@ -769,12 +784,12 @@ void Bot::FindItem (void)
|
|||
m_itemIgnore = ent;
|
||||
allowPickup = false;
|
||||
|
||||
if (!m_defendedBomb && m_difficulty >= 2 && g_randGen.Long (0, 100) < 80)
|
||||
if (!m_defendedBomb && m_difficulty >= 2 && Random.Long (0, 100) < 80)
|
||||
{
|
||||
int index = FindDefendWaypoint (entityOrigin);
|
||||
|
||||
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + g_randGen.Float (30.0, 70.0), true); // push camp task on to stack
|
||||
StartTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + g_randGen.Float (10.0, 30.0), true); // push move command
|
||||
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (30.0, 70.0), true); // push camp task on to stack
|
||||
StartTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + Random.Float (10.0, 30.0), true); // push move command
|
||||
|
||||
if (g_waypoint->GetPath (index)->vis.crouch <= g_waypoint->GetPath (index)->vis.stand)
|
||||
m_campButtons |= IN_DUCK;
|
||||
|
|
@ -935,7 +950,7 @@ void Bot::InstantChatterMessage (int type)
|
|||
if (reportTime >= GetWorldTime ())
|
||||
return;
|
||||
|
||||
reportTime = GetWorldTime () + g_randGen.Float (30.0, 80.0);
|
||||
reportTime = GetWorldTime () + Random.Float (30.0, 80.0);
|
||||
}
|
||||
|
||||
String defaultSound = g_chatterFactory[type].GetRandomElement ().name;
|
||||
|
|
@ -1039,7 +1054,7 @@ void Bot::CheckMessageQueue (void)
|
|||
}
|
||||
|
||||
m_buyPending = false;
|
||||
m_nextBuyTime = GetWorldTime () + g_randGen.Float (0.3, 0.8);
|
||||
m_nextBuyTime = GetWorldTime () + Random.Float (0.3, 0.8);
|
||||
|
||||
// if bot buying is off then no need to buy
|
||||
if (!yb_botbuy.GetBool ())
|
||||
|
|
@ -1121,7 +1136,7 @@ void Bot::CheckMessageQueue (void)
|
|||
switch (GetTaskId ())
|
||||
{
|
||||
case TASK_NORMAL:
|
||||
if (GetTask ()->data != -1 && g_randGen.Long (0, 100) < 70)
|
||||
if (GetTask ()->data != -1 && Random.Long (0, 100) < 70)
|
||||
{
|
||||
Path *path = g_waypoint->GetPath (GetTask ()->data);
|
||||
|
||||
|
|
@ -1134,12 +1149,12 @@ void Bot::CheckMessageQueue (void)
|
|||
}
|
||||
else if (path->flags & FLAG_RESCUE)
|
||||
InstantChatterMessage (Chatter_RescuingHostages);
|
||||
else if ((path->flags & FLAG_CAMP) && g_randGen.Long (0, 100) > 15)
|
||||
else if ((path->flags & FLAG_CAMP) && Random.Long (0, 100) > 15)
|
||||
InstantChatterMessage (Chatter_GoingToCamp);
|
||||
else
|
||||
InstantChatterMessage (Chatter_HearSomething);
|
||||
}
|
||||
else if (g_randGen.Long (0, 100) < 40)
|
||||
else if (Random.Long (0, 100) < 40)
|
||||
InstantChatterMessage (Chatter_ReportingIn);
|
||||
|
||||
break;
|
||||
|
|
@ -1149,7 +1164,7 @@ void Bot::CheckMessageQueue (void)
|
|||
break;
|
||||
|
||||
case TASK_CAMP:
|
||||
if (g_randGen.Long (0, 100) < 40)
|
||||
if (Random.Long (0, 100) < 40)
|
||||
{
|
||||
|
||||
if (g_bombPlanted && m_team == TEAM_TF)
|
||||
|
|
@ -1446,7 +1461,7 @@ void Bot::PerformWeaponPurchase (void)
|
|||
if (ignoreWeapon && g_weaponSelect[25].teamStandard == 1 && yb_economics_rounds.GetBool ())
|
||||
continue;
|
||||
|
||||
int moneySave = g_randGen.Long (900, 1100);
|
||||
int moneySave = Random.Long (900, 1100);
|
||||
|
||||
if (g_botManager->GetLastWinner () == m_team)
|
||||
moneySave = 0;
|
||||
|
|
@ -1463,7 +1478,7 @@ void Bot::PerformWeaponPurchase (void)
|
|||
|
||||
// choose randomly from the best ones...
|
||||
if (foundWeapons > 1)
|
||||
chosenWeapon = choices[g_randGen.Long (0, foundWeapons - 1)];
|
||||
chosenWeapon = choices[Random.Long (0, foundWeapons - 1)];
|
||||
else
|
||||
chosenWeapon = choices[foundWeapons - 1];
|
||||
|
||||
|
|
@ -1499,7 +1514,7 @@ void Bot::PerformWeaponPurchase (void)
|
|||
}
|
||||
|
||||
case 1: // if armor is damaged and bot has some money, buy some armor
|
||||
if (pev->armorvalue < g_randGen.Long (50, 80) && (isPistolMode || (teamEcoValid && HasPrimaryWeapon ())))
|
||||
if (pev->armorvalue < Random.Long (50, 80) && (isPistolMode || (teamEcoValid && HasPrimaryWeapon ())))
|
||||
{
|
||||
// if bot is rich, buy kevlar + helmet, else buy a single kevlar
|
||||
if (m_moneyAmount > 1500 && !IsRestricted (WEAPON_ARMORHELM))
|
||||
|
|
@ -1510,7 +1525,7 @@ void Bot::PerformWeaponPurchase (void)
|
|||
break;
|
||||
|
||||
case 2: // if bot has still some money, buy a better secondary weapon
|
||||
if (isPistolMode || (HasPrimaryWeapon () && (pev->weapons & ((1 << WEAPON_USP) | (1 << WEAPON_GLOCK))) && m_moneyAmount > g_randGen.Long (7500, 9000)))
|
||||
if (isPistolMode || (HasPrimaryWeapon () && (pev->weapons & ((1 << WEAPON_USP) | (1 << WEAPON_GLOCK))) && m_moneyAmount > Random.Long (7500, 9000)))
|
||||
{
|
||||
do
|
||||
{
|
||||
|
|
@ -1539,7 +1554,7 @@ void Bot::PerformWeaponPurchase (void)
|
|||
if (selectedWeapon->teamStandard != 2 && selectedWeapon->teamStandard != m_team)
|
||||
continue;
|
||||
|
||||
if (selectedWeapon->price <= (m_moneyAmount - g_randGen.Long (100, 200)))
|
||||
if (selectedWeapon->price <= (m_moneyAmount - Random.Long (100, 200)))
|
||||
choices[foundWeapons++] = *ptr;
|
||||
|
||||
} while (count < NUM_WEAPONS && foundWeapons < 4);
|
||||
|
|
@ -1551,7 +1566,7 @@ void Bot::PerformWeaponPurchase (void)
|
|||
|
||||
// choose randomly from the best ones...
|
||||
if (foundWeapons > 1)
|
||||
chosenWeapon = choices[g_randGen.Long (0, foundWeapons - 1)];
|
||||
chosenWeapon = choices[Random.Long (0, foundWeapons - 1)];
|
||||
else
|
||||
chosenWeapon = choices[foundWeapons - 1];
|
||||
|
||||
|
|
@ -1579,21 +1594,21 @@ void Bot::PerformWeaponPurchase (void)
|
|||
break;
|
||||
|
||||
case 3: // if bot has still some money, choose if bot should buy a grenade or not
|
||||
if (g_randGen.Long (1, 100) < g_grenadeBuyPrecent[0] && m_moneyAmount >= 400 && !IsRestricted (WEAPON_EXPLOSIVE))
|
||||
if (Random.Long (1, 100) < g_grenadeBuyPrecent[0] && m_moneyAmount >= 400 && !IsRestricted (WEAPON_EXPLOSIVE))
|
||||
{
|
||||
// buy a he grenade
|
||||
FakeClientCommand (GetEntity (), "buyequip");
|
||||
FakeClientCommand (GetEntity (), "menuselect 4");
|
||||
}
|
||||
|
||||
if (g_randGen.Long (1, 100) < g_grenadeBuyPrecent[1] && m_moneyAmount >= 300 && teamEcoValid && !IsRestricted (WEAPON_FLASHBANG))
|
||||
if (Random.Long (1, 100) < g_grenadeBuyPrecent[1] && m_moneyAmount >= 300 && teamEcoValid && !IsRestricted (WEAPON_FLASHBANG))
|
||||
{
|
||||
// buy a concussion grenade, i.e., 'flashbang'
|
||||
FakeClientCommand (GetEntity (), "buyequip");
|
||||
FakeClientCommand (GetEntity (), "menuselect 3");
|
||||
}
|
||||
|
||||
if (g_randGen.Long (1, 100) < g_grenadeBuyPrecent[2] && m_moneyAmount >= 400 && teamEcoValid && !IsRestricted (WEAPON_SMOKE))
|
||||
if (Random.Long (1, 100) < g_grenadeBuyPrecent[2] && m_moneyAmount >= 400 && teamEcoValid && !IsRestricted (WEAPON_SMOKE))
|
||||
{
|
||||
// buy a smoke grenade
|
||||
FakeClientCommand (GetEntity (), "buyequip");
|
||||
|
|
@ -1602,7 +1617,7 @@ void Bot::PerformWeaponPurchase (void)
|
|||
break;
|
||||
|
||||
case 4: // if bot is CT and we're on a bomb map, randomly buy the defuse kit
|
||||
if ((g_mapType & MAP_DE) && m_team == TEAM_CF && g_randGen.Long (1, 100) < 80 && m_moneyAmount > 200 && !IsRestricted (WEAPON_DEFUSER))
|
||||
if ((g_mapType & MAP_DE) && m_team == TEAM_CF && Random.Long (1, 100) < 80 && m_moneyAmount > 200 && !IsRestricted (WEAPON_DEFUSER))
|
||||
{
|
||||
if (g_gameVersion == CSV_OLD)
|
||||
FakeClientCommand (GetEntity (), "buyequip;menuselect 6");
|
||||
|
|
@ -1613,7 +1628,7 @@ void Bot::PerformWeaponPurchase (void)
|
|||
|
||||
case 5: // buy enough primary & secondary ammo (do not check for money here)
|
||||
for (int i = 0; i <= 5; i++)
|
||||
FakeClientCommand (GetEntity (), "buyammo%d", g_randGen.Long (1, 2)); // simulate human
|
||||
FakeClientCommand (GetEntity (), "buyammo%d", Random.Long (1, 2)); // simulate human
|
||||
|
||||
// buy enough secondary ammo
|
||||
if (HasPrimaryWeapon ())
|
||||
|
|
@ -1741,10 +1756,10 @@ void Bot::SetConditions (void)
|
|||
if (m_agressionLevel > 1.0)
|
||||
m_agressionLevel = 1.0;
|
||||
|
||||
if (g_randGen.Long (1, 100) < 10)
|
||||
if (Random.Long (1, 100) < 10)
|
||||
ChatMessage (CHAT_KILLING);
|
||||
|
||||
if (g_randGen.Long (1, 100) < 10)
|
||||
if (Random.Long (1, 100) < 10)
|
||||
RadioMessage (Radio_EnemyDown);
|
||||
else
|
||||
{
|
||||
|
|
@ -1755,7 +1770,7 @@ void Bot::SetConditions (void)
|
|||
switch (GetNearbyEnemiesNearPosition (pev->origin, 9999))
|
||||
{
|
||||
case 0:
|
||||
if (g_randGen.Long (0, 100) < 50)
|
||||
if (Random.Long (0, 100) < 50)
|
||||
ChatterMessage (Chatter_NoEnemiesLeft);
|
||||
else
|
||||
ChatterMessage (Chatter_EnemyDown);
|
||||
|
|
@ -1854,7 +1869,7 @@ void Bot::SetConditions (void)
|
|||
else
|
||||
{
|
||||
// care about different types of grenades
|
||||
if ((grenadeToThrow == WEAPON_EXPLOSIVE || grenadeToThrow == WEAPON_SMOKE) && g_randGen.Long (0, 100) < 45 && !(m_states & (STATE_SEEING_ENEMY | STATE_THROW_HE | STATE_THROW_FB | STATE_THROW_SG)))
|
||||
if ((grenadeToThrow == WEAPON_EXPLOSIVE || grenadeToThrow == WEAPON_SMOKE) && Random.Long (0, 100) < 45 && !(m_states & (STATE_SEEING_ENEMY | STATE_THROW_HE | STATE_THROW_FB | STATE_THROW_SG)))
|
||||
{
|
||||
float distance = (m_lastEnemy->v.origin - pev->origin).GetLength ();
|
||||
|
||||
|
|
@ -1922,7 +1937,7 @@ void Bot::SetConditions (void)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (IsAlive (m_lastEnemy) && grenadeToThrow == WEAPON_FLASHBANG && (m_lastEnemy->v.origin - pev->origin).GetLength () < 800 && !(m_aimFlags & AIM_ENEMY) && g_randGen.Long (0, 100) < 50)
|
||||
else if (IsAlive (m_lastEnemy) && grenadeToThrow == WEAPON_FLASHBANG && (m_lastEnemy->v.origin - pev->origin).GetLength () < 800 && !(m_aimFlags & AIM_ENEMY) && Random.Long (0, 100) < 50)
|
||||
{
|
||||
bool allowThrowing = true;
|
||||
Array <int> inRadius;
|
||||
|
|
@ -2164,7 +2179,7 @@ void Bot::StartTask (TaskId_t id, float desire, int data, float time, bool resum
|
|||
SelectBestWeapon ();
|
||||
|
||||
// this is best place to handle some voice commands report team some info
|
||||
if (g_randGen.Long (0, 100) < 95)
|
||||
if (Random.Long (0, 100) < 95)
|
||||
{
|
||||
switch (GetTaskId ())
|
||||
{
|
||||
|
|
@ -2178,7 +2193,7 @@ void Bot::StartTask (TaskId_t id, float desire, int data, float time, bool resum
|
|||
}
|
||||
}
|
||||
|
||||
if (g_randGen.Long (0, 100) < 80 && GetTaskId () == TASK_CAMP)
|
||||
if (Random.Long (0, 100) < 80 && GetTaskId () == TASK_CAMP)
|
||||
{
|
||||
if ((g_mapType & MAP_DE) && g_bombPlanted)
|
||||
ChatterMessage (Chatter_GuardDroppedC4);
|
||||
|
|
@ -2191,7 +2206,7 @@ void Bot::StartTask (TaskId_t id, float desire, int data, float time, bool resum
|
|||
else
|
||||
m_chosenGoalIndex = GetTask ()->data;
|
||||
|
||||
if (g_randGen.Long (0, 100) < 80 && GetTaskId () == TASK_CAMP && m_team == TEAM_TF && m_inVIPZone)
|
||||
if (Random.Long (0, 100) < 80 && GetTaskId () == TASK_CAMP && m_team == TEAM_TF && m_inVIPZone)
|
||||
ChatterMessage (Chatter_GoingToGuardVIPSafety);
|
||||
}
|
||||
|
||||
|
|
@ -2354,7 +2369,7 @@ void Bot::CheckRadioCommands (void)
|
|||
// check if line of sight to object is not blocked (i.e. visible)
|
||||
if ((EntityIsVisible (m_radioEntity->v.origin)) || (m_radioOrder == Radio_StickTogether))
|
||||
{
|
||||
if (IsEntityNull (m_targetEntity) && IsEntityNull (m_enemy) && g_randGen.Long (0, 100) < (m_personality == PERSONALITY_CAREFUL ? 80 : 20))
|
||||
if (IsEntityNull (m_targetEntity) && IsEntityNull (m_enemy) && Random.Long (0, 100) < (m_personality == PERSONALITY_CAREFUL ? 80 : 20))
|
||||
{
|
||||
int numFollowers = 0;
|
||||
|
||||
|
|
@ -2428,7 +2443,7 @@ void Bot::CheckRadioCommands (void)
|
|||
|
||||
m_campButtons = 0;
|
||||
|
||||
StartTask (TASK_PAUSE, TASKPRI_PAUSE, -1, GetWorldTime () + g_randGen.Float (30.0, 60.0), false);
|
||||
StartTask (TASK_PAUSE, TASKPRI_PAUSE, -1, GetWorldTime () + Random.Float (30.0, 60.0), false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -2448,14 +2463,14 @@ void Bot::CheckRadioCommands (void)
|
|||
if (m_fearLevel < 0.0)
|
||||
m_fearLevel = 0.0;
|
||||
|
||||
if (g_randGen.Long (0, 100) < 45 && yb_communication_type.GetInt () == 2)
|
||||
if (Random.Long (0, 100) < 45 && yb_communication_type.GetInt () == 2)
|
||||
ChatterMessage (Chatter_OnMyWay);
|
||||
else if (m_radioOrder == Radio_NeedBackup && yb_communication_type.GetInt () != 2)
|
||||
RadioMessage (Radio_Affirmative);
|
||||
|
||||
TryHeadTowardRadioEntity ();
|
||||
}
|
||||
else if (g_randGen.Long (0, 100) < 80)
|
||||
else if (Random.Long (0, 100) < 80)
|
||||
RadioMessage (Radio_Negative);
|
||||
}
|
||||
break;
|
||||
|
|
@ -2469,28 +2484,28 @@ void Bot::CheckRadioCommands (void)
|
|||
case Radio_NeedBackup:
|
||||
case Chatter_ScaredEmotion:
|
||||
case Chatter_Pinned_Down:
|
||||
if (((IsEntityNull (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 2048 || !m_moveToC4) && g_randGen.Long (0, 100) > 50 && m_seeEnemyTime + 4.0 < GetWorldTime ())
|
||||
if (((IsEntityNull (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 2048 || !m_moveToC4) && Random.Long (0, 100) > 50 && m_seeEnemyTime + 4.0 < GetWorldTime ())
|
||||
{
|
||||
m_fearLevel -= 0.1;
|
||||
|
||||
if (m_fearLevel < 0.0)
|
||||
m_fearLevel = 0.0;
|
||||
|
||||
if (g_randGen.Long (0, 100) < 45 && yb_communication_type.GetInt () == 2)
|
||||
if (Random.Long (0, 100) < 45 && yb_communication_type.GetInt () == 2)
|
||||
ChatterMessage (Chatter_OnMyWay);
|
||||
else if (m_radioOrder == Radio_NeedBackup && yb_communication_type.GetInt () != 2)
|
||||
RadioMessage (Radio_Affirmative);
|
||||
|
||||
TryHeadTowardRadioEntity ();
|
||||
}
|
||||
else if (g_randGen.Long (0, 100) < 80 && m_radioOrder == Radio_NeedBackup)
|
||||
else if (Random.Long (0, 100) < 80 && m_radioOrder == Radio_NeedBackup)
|
||||
RadioMessage (Radio_Negative);
|
||||
break;
|
||||
|
||||
case Radio_GoGoGo:
|
||||
if (m_radioEntity == m_targetEntity)
|
||||
{
|
||||
if (g_randGen.Long (0, 100) < 45 && yb_communication_type.GetInt () == 2)
|
||||
if (Random.Long (0, 100) < 45 && yb_communication_type.GetInt () == 2)
|
||||
RadioMessage (Radio_Affirmative);
|
||||
else if (m_radioOrder == Radio_NeedBackup && yb_communication_type.GetInt () != 2)
|
||||
RadioMessage (Radio_Affirmative);
|
||||
|
|
@ -2519,7 +2534,7 @@ void Bot::CheckRadioCommands (void)
|
|||
m_targetEntity = NULL;
|
||||
MakeVectors (m_radioEntity->v.v_angle);
|
||||
|
||||
m_position = m_radioEntity->v.origin + g_pGlobals->v_forward * g_randGen.Long (1024, 2048);
|
||||
m_position = m_radioEntity->v.origin + g_pGlobals->v_forward * Random.Long (1024, 2048);
|
||||
|
||||
DeleteSearchNodes ();
|
||||
StartTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, -1, 0.0, true);
|
||||
|
|
@ -2564,7 +2579,7 @@ void Bot::CheckRadioCommands (void)
|
|||
break;
|
||||
|
||||
case Radio_StormTheFront:
|
||||
if (((IsEntityNull (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 1024) && g_randGen.Long (0, 100) > 50)
|
||||
if (((IsEntityNull (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 1024) && Random.Long (0, 100) > 50)
|
||||
{
|
||||
RadioMessage (Radio_Affirmative);
|
||||
|
||||
|
|
@ -2577,7 +2592,7 @@ void Bot::CheckRadioCommands (void)
|
|||
m_targetEntity = NULL;
|
||||
|
||||
MakeVectors (m_radioEntity->v.v_angle);
|
||||
m_position = m_radioEntity->v.origin + g_pGlobals->v_forward * g_randGen.Long (1024, 2048);
|
||||
m_position = m_radioEntity->v.origin + g_pGlobals->v_forward * Random.Long (1024, 2048);
|
||||
|
||||
DeleteSearchNodes ();
|
||||
StartTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, -1, 0.0, true);
|
||||
|
|
@ -2608,7 +2623,7 @@ void Bot::CheckRadioCommands (void)
|
|||
m_agressionLevel = 0.0;
|
||||
|
||||
if (GetTaskId () == TASK_CAMP)
|
||||
GetTask ()->time += g_randGen.Float (10.0, 15.0);
|
||||
GetTask ()->time += Random.Float (10.0, 15.0);
|
||||
else
|
||||
{
|
||||
// don't pause/camp anymore
|
||||
|
|
@ -2648,7 +2663,7 @@ void Bot::CheckRadioCommands (void)
|
|||
break;
|
||||
|
||||
case Radio_ReportTeam:
|
||||
if (g_randGen.Long (0, 100) < 30)
|
||||
if (Random.Long (0, 100) < 30)
|
||||
RadioMessage ((GetNearbyEnemiesNearPosition (pev->origin, 400) == 0 && yb_communication_type.GetInt () != 2) ? Radio_SectorClear : Radio_ReportingIn);
|
||||
break;
|
||||
|
||||
|
|
@ -2704,7 +2719,7 @@ void Bot::CheckRadioCommands (void)
|
|||
RadioMessage (Radio_Affirmative);
|
||||
|
||||
if (GetTaskId () == TASK_CAMP)
|
||||
GetTask ()->time = GetWorldTime () + g_randGen.Float (30.0, 60.0);
|
||||
GetTask ()->time = GetWorldTime () + Random.Float (30.0, 60.0);
|
||||
else
|
||||
{
|
||||
// don't pause anymore
|
||||
|
|
@ -2743,9 +2758,9 @@ void Bot::CheckRadioCommands (void)
|
|||
int index = FindDefendWaypoint (m_radioEntity->v.origin);
|
||||
|
||||
// push camp task on to stack
|
||||
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + g_randGen.Float (30.0, 60.0), true);
|
||||
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (30.0, 60.0), true);
|
||||
// push move command
|
||||
StartTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + g_randGen.Float (30.0, 60.0), true);
|
||||
StartTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + Random.Float (30.0, 60.0), true);
|
||||
|
||||
if (g_waypoint->GetPath (index)->vis.crouch <= g_waypoint->GetPath (index)->vis.stand)
|
||||
m_campButtons |= IN_DUCK;
|
||||
|
|
@ -2765,7 +2780,7 @@ void Bot::TryHeadTowardRadioEntity (void)
|
|||
if (taskID == TASK_MOVETOPOSITION || m_headedTime + 15.0f < GetWorldTime () || !IsAlive (m_radioEntity) || m_hasC4)
|
||||
return;
|
||||
|
||||
if ((IsValidBot (m_radioEntity) && g_randGen.Long (0, 100) < 25 && m_personality == PERSONALITY_NORMAL) || !(m_radioEntity->v.flags & FL_FAKECLIENT))
|
||||
if ((IsValidBot (m_radioEntity) && Random.Long (0, 100) < 25 && m_personality == PERSONALITY_NORMAL) || !(m_radioEntity->v.flags & FL_FAKECLIENT))
|
||||
{
|
||||
if (taskID == TASK_PAUSE || taskID == TASK_CAMP)
|
||||
GetTask ()->time = GetWorldTime ();
|
||||
|
|
@ -2787,7 +2802,7 @@ void Bot::SelectLeaderEachTeam (int team)
|
|||
// vip bot is the leader
|
||||
m_isLeader = true;
|
||||
|
||||
if (g_randGen.Long (1, 100) < 50)
|
||||
if (Random.Long (1, 100) < 50)
|
||||
{
|
||||
RadioMessage (Radio_FollowMe);
|
||||
m_campButtons = 0;
|
||||
|
|
@ -2802,7 +2817,7 @@ void Bot::SelectLeaderEachTeam (int team)
|
|||
{
|
||||
botLeader->m_isLeader = true;
|
||||
|
||||
if (g_randGen.Long (1, 100) < 45)
|
||||
if (Random.Long (1, 100) < 45)
|
||||
botLeader->RadioMessage (Radio_FollowMe);
|
||||
}
|
||||
g_leaderChoosen[TEAM_TF] = true;
|
||||
|
|
@ -2818,7 +2833,7 @@ void Bot::SelectLeaderEachTeam (int team)
|
|||
m_isLeader = true;
|
||||
|
||||
// terrorist carrying a bomb needs to have some company
|
||||
if (g_randGen.Long (1, 100) < 80)
|
||||
if (Random.Long (1, 100) < 80)
|
||||
{
|
||||
if (yb_communication_type.GetInt () == 2)
|
||||
ChatterMessage (Chatter_GoingToPlantBomb);
|
||||
|
|
@ -2838,7 +2853,7 @@ void Bot::SelectLeaderEachTeam (int team)
|
|||
{
|
||||
botLeader->m_isLeader = true;
|
||||
|
||||
if (g_randGen.Long (1, 100) < 30)
|
||||
if (Random.Long (1, 100) < 30)
|
||||
botLeader->RadioMessage (Radio_FollowMe);
|
||||
}
|
||||
g_leaderChoosen[TEAM_CF] = true;
|
||||
|
|
@ -2852,7 +2867,7 @@ void Bot::SelectLeaderEachTeam (int team)
|
|||
{
|
||||
botLeader->m_isLeader = true;
|
||||
|
||||
if (g_randGen.Long (1, 100) < 30)
|
||||
if (Random.Long (1, 100) < 30)
|
||||
botLeader->RadioMessage (Radio_FollowMe);
|
||||
}
|
||||
}
|
||||
|
|
@ -2864,7 +2879,7 @@ void Bot::SelectLeaderEachTeam (int team)
|
|||
{
|
||||
botLeader->m_isLeader = true;
|
||||
|
||||
if (g_randGen.Long (1, 100) < (team == TEAM_TF ? 30 : 40))
|
||||
if (Random.Long (1, 100) < (team == TEAM_TF ? 30 : 40))
|
||||
botLeader->RadioMessage (Radio_FollowMe);
|
||||
}
|
||||
}
|
||||
|
|
@ -3101,7 +3116,7 @@ void Bot::Think (void)
|
|||
if (yb_chat.GetBool () && !RepliesToPlayer () && m_lastChatTime + 10.0 < GetWorldTime () && g_lastChatTime + 5.0 < GetWorldTime ()) // bot chatting turned on?
|
||||
{
|
||||
// say a text every now and then
|
||||
if (g_randGen.Long (1, 1500) < 2)
|
||||
if (Random.Long (1, 1500) < 2)
|
||||
{
|
||||
m_lastChatTime = GetWorldTime ();
|
||||
g_lastChatTime = GetWorldTime ();
|
||||
|
|
@ -3126,7 +3141,7 @@ void Bot::Think (void)
|
|||
}
|
||||
|
||||
// clear the used line buffer every now and then
|
||||
if (m_sayTextBuffer.lastUsedSentences.GetElementNumber () > g_randGen.Long (4, 6))
|
||||
if (m_sayTextBuffer.lastUsedSentences.GetElementNumber () > Random.Long (4, 6))
|
||||
m_sayTextBuffer.lastUsedSentences.RemoveAll ();
|
||||
}
|
||||
}
|
||||
|
|
@ -3137,7 +3152,7 @@ void Bot::Think (void)
|
|||
int team = g_clients[IndexOfEntity (GetEntity ()) - 1].realTeam;;
|
||||
|
||||
// remove voice icon
|
||||
if (g_lastRadioTime[team] + g_randGen.Float (0.8, 2.1) < GetWorldTime ())
|
||||
if (g_lastRadioTime[team] + Random.Float (0.8, 2.1) < GetWorldTime ())
|
||||
SwitchChatterIcon (false); // hide icon
|
||||
|
||||
// check is it time to execute think (called once per second (not frame))
|
||||
|
|
@ -3211,12 +3226,12 @@ void Bot::RunTask (void)
|
|||
// bots rushing with knife, when have no enemy (thanks for idea to nicebot project)
|
||||
if (m_currentWeapon == WEAPON_KNIFE && (IsEntityNull (m_lastEnemy) || !IsAlive (m_lastEnemy)) && IsEntityNull (m_enemy) && m_knifeAttackTime < GetWorldTime () && !HasShield () && GetNearbyFriendsNearPosition (pev->origin, 96) == 0)
|
||||
{
|
||||
if (g_randGen.Long (0, 100) < 40)
|
||||
if (Random.Long (0, 100) < 40)
|
||||
pev->button |= IN_ATTACK;
|
||||
else
|
||||
pev->button |= IN_ATTACK2;
|
||||
|
||||
m_knifeAttackTime = GetWorldTime () + g_randGen.Float (2.5, 6.0);
|
||||
m_knifeAttackTime = GetWorldTime () + Random.Float (2.5, 6.0);
|
||||
}
|
||||
|
||||
if (m_reloadState == RELOAD_NONE && GetAmmo () != 0 && GetAmmoInClip () < 5 && g_weaponDefs[m_currentWeapon].ammo1 != -1)
|
||||
|
|
@ -3229,7 +3244,7 @@ void Bot::RunTask (void)
|
|||
GetTask ()->data = -1;
|
||||
}
|
||||
|
||||
if (!g_bombPlanted && m_currentWaypointIndex != -1 && (m_currentPath->flags & FLAG_GOAL) && g_randGen.Long (0, 100) < 80 && GetNearbyEnemiesNearPosition (pev->origin, 650) == 0)
|
||||
if (!g_bombPlanted && m_currentWaypointIndex != -1 && (m_currentPath->flags & FLAG_GOAL) && Random.Long (0, 100) < 80 && GetNearbyEnemiesNearPosition (pev->origin, 650) == 0)
|
||||
RadioMessage (Radio_SectorClear);
|
||||
|
||||
// reached the destination (goal) waypoint?
|
||||
|
|
@ -3239,7 +3254,7 @@ void Bot::RunTask (void)
|
|||
m_prevGoalIndex = -1;
|
||||
|
||||
// spray logo sometimes if allowed to do so
|
||||
if (m_timeLogoSpray < GetWorldTime () && yb_spraypaints.GetBool () && g_randGen.Long (1, 100) < 80 && m_moveSpeed > GetWalkSpeed ())
|
||||
if (m_timeLogoSpray < GetWorldTime () && yb_spraypaints.GetBool () && Random.Long (1, 100) < 80 && m_moveSpeed > GetWalkSpeed ())
|
||||
StartTask (TASK_SPRAY, TASKPRI_SPRAYLOGO, -1, GetWorldTime () + 1.0, false);
|
||||
|
||||
// reached waypoint is a camp waypoint
|
||||
|
|
@ -3285,7 +3300,7 @@ void Bot::RunTask (void)
|
|||
|
||||
MakeVectors (pev->v_angle);
|
||||
|
||||
m_timeCamping = GetWorldTime () + g_randGen.Float (10.0f, 30.0f);
|
||||
m_timeCamping = GetWorldTime () + Random.Float (10.0f, 30.0f);
|
||||
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, m_timeCamping, true);
|
||||
|
||||
m_camp = Vector (m_currentPath->campStartX, m_currentPath->campStartY, 0.0f);
|
||||
|
|
@ -3293,7 +3308,7 @@ void Bot::RunTask (void)
|
|||
m_campDirection = 0;
|
||||
|
||||
// tell the world we're camping
|
||||
if (g_randGen.Long (0, 100) < 95)
|
||||
if (Random.Long (0, 100) < 95)
|
||||
RadioMessage (Radio_InPosition);
|
||||
|
||||
m_moveToGoal = false;
|
||||
|
|
@ -3319,12 +3334,12 @@ void Bot::RunTask (void)
|
|||
m_hostages[i] = NULL; // clear array of hostage pointers
|
||||
}
|
||||
}
|
||||
else if (m_team == TEAM_TF && g_randGen.Long (0, 100) < 80)
|
||||
else if (m_team == TEAM_TF && Random.Long (0, 100) < 80)
|
||||
{
|
||||
int index = FindDefendWaypoint (m_currentPath->origin);
|
||||
|
||||
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + g_randGen.Float (60.0, 120.0), true); // push camp task on to stack
|
||||
StartTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + g_randGen.Float (5.0, 10.0), true); // push move command
|
||||
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (60.0, 120.0), true); // push camp task on to stack
|
||||
StartTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + Random.Float (5.0, 10.0), true); // push move command
|
||||
|
||||
if (g_waypoint->GetPath (index)->vis.crouch <= g_waypoint->GetPath (index)->vis.stand)
|
||||
m_campButtons |= IN_DUCK;
|
||||
|
|
@ -3346,19 +3361,19 @@ void Bot::RunTask (void)
|
|||
RadioMessage (Radio_NeedBackup);
|
||||
InstantChatterMessage (Chatter_ScaredEmotion);
|
||||
|
||||
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + g_randGen.Float (4.0, 8.0), true);
|
||||
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (4.0, 8.0), true);
|
||||
}
|
||||
else
|
||||
StartTask (TASK_PLANTBOMB, TASKPRI_PLANTBOMB, -1, 0.0, false);
|
||||
}
|
||||
else if (m_team == TEAM_CF)
|
||||
{
|
||||
if (!g_bombPlanted && GetNearbyFriendsNearPosition (pev->origin, 360) < 3 && g_randGen.Long (0, 100) < 85 && GetTaskId () == TASK_NORMAL && m_fearLevel > m_agressionLevel / 2)
|
||||
if (!g_bombPlanted && GetNearbyFriendsNearPosition (pev->origin, 360) < 3 && Random.Long (0, 100) < 85 && GetTaskId () == TASK_NORMAL && m_fearLevel > m_agressionLevel / 2)
|
||||
{
|
||||
int index = FindDefendWaypoint (m_currentPath->origin);
|
||||
|
||||
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + g_randGen.Float (45.0, 60.0), true); // push camp task on to stack
|
||||
StartTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + g_randGen.Float (10.0, 15.0), true); // push move command
|
||||
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (45.0, 60.0), true); // push camp task on to stack
|
||||
StartTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + Random.Float (10.0, 15.0), true); // push move command
|
||||
|
||||
if (g_waypoint->GetPath (index)->vis.crouch <= g_waypoint->GetPath (index)->vis.stand)
|
||||
m_campButtons |= IN_DUCK;
|
||||
|
|
@ -3403,7 +3418,7 @@ void Bot::RunTask (void)
|
|||
m_moveSpeed = GetWalkSpeed ();
|
||||
|
||||
// bot hasn't seen anything in a long time and is asking his teammates to report in
|
||||
if (m_seeEnemyTime != 0.0 && m_seeEnemyTime + g_randGen.Float (30.0, 80.0) < GetWorldTime () && g_randGen.Long (0, 100) < 70 && g_timeRoundStart + 20.0 < GetWorldTime () && m_askCheckTime + g_randGen.Float (20.0, 30.0) < GetWorldTime ())
|
||||
if (m_seeEnemyTime != 0.0 && m_seeEnemyTime + Random.Float (30.0, 80.0) < GetWorldTime () && Random.Long (0, 100) < 70 && g_timeRoundStart + 20.0 < GetWorldTime () && m_askCheckTime + Random.Float (20.0, 30.0) < GetWorldTime ())
|
||||
{
|
||||
m_askCheckTime = GetWorldTime ();
|
||||
RadioMessage (Radio_ReportTeam);
|
||||
|
|
@ -3437,7 +3452,7 @@ void Bot::RunTask (void)
|
|||
|
||||
// paint the actual logo decal
|
||||
DecalTrace (pev, &tr, m_logotypeIndex);
|
||||
m_timeLogoSpray = GetWorldTime () + g_randGen.Float (30.0, 45.0);
|
||||
m_timeLogoSpray = GetWorldTime () + Random.Float (30.0, 45.0);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -3536,7 +3551,7 @@ void Bot::RunTask (void)
|
|||
m_pathType = 0;
|
||||
|
||||
// start hide task
|
||||
StartTask (TASK_HIDE, TASKPRI_HIDE, -1, GetWorldTime () + g_randGen.Float (5.0, 15.0), false);
|
||||
StartTask (TASK_HIDE, TASKPRI_HIDE, -1, GetWorldTime () + Random.Float (5.0, 15.0), false);
|
||||
destination = m_lastEnemyOrigin;
|
||||
|
||||
// get a valid look direction
|
||||
|
|
@ -3609,7 +3624,14 @@ void Bot::RunTask (void)
|
|||
m_checkTerrain = false;
|
||||
|
||||
if (!IsEntityNull (m_enemy))
|
||||
{
|
||||
if (IsOnLadder ())
|
||||
{
|
||||
pev->button |= IN_DUCK;
|
||||
DeleteSearchNodes ();
|
||||
}
|
||||
CombatFight ();
|
||||
}
|
||||
else
|
||||
{
|
||||
TaskComplete ();
|
||||
|
|
@ -3702,7 +3724,7 @@ void Bot::RunTask (void)
|
|||
|
||||
if (m_nextCampDirTime < GetWorldTime ())
|
||||
{
|
||||
m_nextCampDirTime = GetWorldTime () + g_randGen.Float (2.0, 5.0);
|
||||
m_nextCampDirTime = GetWorldTime () + Random.Float (2.0, 5.0);
|
||||
|
||||
if (m_currentPath->flags & FLAG_CAMP)
|
||||
{
|
||||
|
|
@ -3766,7 +3788,7 @@ void Bot::RunTask (void)
|
|||
}
|
||||
|
||||
if (--numFoundPoints >= 0)
|
||||
m_camp = g_waypoint->GetPath (foundPoints[g_randGen.Long (0, numFoundPoints)])->origin;
|
||||
m_camp = g_waypoint->GetPath (foundPoints[Random.Long (0, numFoundPoints)])->origin;
|
||||
else
|
||||
m_camp = g_waypoint->GetPath (GetAimingWaypoint ())->origin;
|
||||
}
|
||||
|
|
@ -3946,7 +3968,7 @@ void Bot::RunTask (void)
|
|||
exceptionCaught = true;
|
||||
g_bombPlanted = false;
|
||||
|
||||
if (GetNearbyFriendsNearPosition (pev->origin, 9999) != 0 && g_randGen.Long (0, 100) < 50)
|
||||
if (GetNearbyFriendsNearPosition (pev->origin, 9999) != 0 && Random.Long (0, 100) < 50)
|
||||
{
|
||||
if (timeToBlowUp <= 3.0)
|
||||
{
|
||||
|
|
@ -4429,7 +4451,7 @@ void Bot::RunTask (void)
|
|||
{
|
||||
if (m_doubleJumpEntity->v.button & IN_JUMP)
|
||||
{
|
||||
m_duckForJump = GetWorldTime () + g_randGen.Float (3.0, 5.0);
|
||||
m_duckForJump = GetWorldTime () + Random.Float (3.0, 5.0);
|
||||
GetTask ()->time = GetWorldTime ();
|
||||
}
|
||||
}
|
||||
|
|
@ -4497,7 +4519,7 @@ void Bot::RunTask (void)
|
|||
DeleteSearchNodes ();
|
||||
|
||||
int lastSelectedGoal = -1;
|
||||
float safeRadius = g_randGen.Float (1024.0, 2048.0), minPathDistance = 4096.0;
|
||||
float safeRadius = Random.Float (1024.0, 2048.0), minPathDistance = 4096.0;
|
||||
|
||||
for (i = 0; i < g_numWaypoints; i++)
|
||||
{
|
||||
|
|
@ -4696,7 +4718,7 @@ void Bot::RunTask (void)
|
|||
// use game dll function to make sure the hostage is correctly 'used'
|
||||
MDLL_Use (m_pickupItem, GetEntity ());
|
||||
|
||||
if (g_randGen.Long (0, 100) < 80)
|
||||
if (Random.Long (0, 100) < 80)
|
||||
ChatterMessage (Chatter_UseHostage);
|
||||
|
||||
for (i = 0; i < MAX_HOSTAGES; i++)
|
||||
|
|
@ -4768,22 +4790,22 @@ void Bot::CheckSpawnTimeConditions (void)
|
|||
// this function is called instead of BotAI when buying finished, but freezetime is not yet left.
|
||||
|
||||
// switch to knife if time to do this
|
||||
if (m_checkKnifeSwitch && !m_checkWeaponSwitch && m_buyingFinished && m_spawnTime + g_randGen.Float (4.0, 6.5) < GetWorldTime ())
|
||||
if (m_checkKnifeSwitch && !m_checkWeaponSwitch && m_buyingFinished && m_spawnTime + Random.Float (4.0, 6.5) < GetWorldTime ())
|
||||
{
|
||||
if (g_randGen.Long (1, 100) < 2 && yb_spraypaints.GetBool ())
|
||||
if (Random.Long (1, 100) < 2 && yb_spraypaints.GetBool ())
|
||||
StartTask (TASK_SPRAY, TASKPRI_SPRAYLOGO, -1, GetWorldTime () + 1.0, false);
|
||||
|
||||
if (m_difficulty >= 2 && g_randGen.Long (0, 100) < (m_personality == PERSONALITY_RUSHER ? 99 : 50) && !m_isReloading && (g_mapType & (MAP_CS | MAP_DE | MAP_ES | MAP_AS)))
|
||||
if (m_difficulty >= 2 && Random.Long (0, 100) < (m_personality == PERSONALITY_RUSHER ? 99 : 50) && !m_isReloading && (g_mapType & (MAP_CS | MAP_DE | MAP_ES | MAP_AS)))
|
||||
SelectWeaponByName ("weapon_knife");
|
||||
|
||||
m_checkKnifeSwitch = false;
|
||||
|
||||
if (g_randGen.Long (0, 100) < yb_user_follow_percent.GetInt () && IsEntityNull (m_targetEntity) && !m_isLeader && !m_hasC4)
|
||||
if (Random.Long (0, 100) < yb_user_follow_percent.GetInt () && IsEntityNull (m_targetEntity) && !m_isLeader && !m_hasC4)
|
||||
AttachToUser ();
|
||||
}
|
||||
|
||||
// check if we already switched weapon mode
|
||||
if (m_checkWeaponSwitch && m_buyingFinished && m_spawnTime + g_randGen.Float (2.0, 3.5) < GetWorldTime ())
|
||||
if (m_checkWeaponSwitch && m_buyingFinished && m_spawnTime + Random.Float (2.0, 3.5) < GetWorldTime ())
|
||||
{
|
||||
if (HasShield () && IsShieldDrawn ())
|
||||
pev->button |= IN_ATTACK2;
|
||||
|
|
@ -4798,7 +4820,7 @@ void Bot::CheckSpawnTimeConditions (void)
|
|||
|
||||
case WEAPON_FAMAS:
|
||||
case WEAPON_GLOCK:
|
||||
if (g_randGen.Long (0, 100) < 50)
|
||||
if (Random.Long (0, 100) < 50)
|
||||
pev->button |= IN_ATTACK2;
|
||||
break;
|
||||
}
|
||||
|
|
@ -4856,16 +4878,16 @@ void Bot::BotAI (void)
|
|||
// some stuff required by by chatter engine
|
||||
if ((m_states & STATE_SEEING_ENEMY) && !IsEntityNull (m_enemy))
|
||||
{
|
||||
if (g_randGen.Long (0, 100) < 45 && GetNearbyFriendsNearPosition (pev->origin, 512) == 0 && (m_enemy->v.weapons & (1 << WEAPON_C4)))
|
||||
if (Random.Long (0, 100) < 45 && GetNearbyFriendsNearPosition (pev->origin, 512) == 0 && (m_enemy->v.weapons & (1 << WEAPON_C4)))
|
||||
ChatterMessage (Chatter_SpotTheBomber);
|
||||
|
||||
if (g_randGen.Long (0, 100) < 45 && m_team == TEAM_TF && GetNearbyFriendsNearPosition (pev->origin, 512) == 0 && *g_engfuncs.pfnInfoKeyValue (g_engfuncs.pfnGetInfoKeyBuffer (m_enemy), "model") == 'v')
|
||||
if (Random.Long (0, 100) < 45 && m_team == TEAM_TF && GetNearbyFriendsNearPosition (pev->origin, 512) == 0 && *g_engfuncs.pfnInfoKeyValue (g_engfuncs.pfnGetInfoKeyBuffer (m_enemy), "model") == 'v')
|
||||
ChatterMessage (Chatter_VIPSpotted);
|
||||
|
||||
if (g_randGen.Long (0, 100) < 50 && GetNearbyFriendsNearPosition (pev->origin, 450) == 0 && GetTeam (m_enemy) != m_team && IsGroupOfEnemies (m_enemy->v.origin, 2, 384))
|
||||
if (Random.Long (0, 100) < 50 && GetNearbyFriendsNearPosition (pev->origin, 450) == 0 && GetTeam (m_enemy) != m_team && IsGroupOfEnemies (m_enemy->v.origin, 2, 384))
|
||||
ChatterMessage (Chatter_ScaredEmotion);
|
||||
|
||||
if (g_randGen.Long (0, 100) < 40 && GetNearbyFriendsNearPosition (pev->origin, 1024) == 0 && ((m_enemy->v.weapons & (1 << WEAPON_AWP)) || (m_enemy->v.weapons & (1 << WEAPON_SCOUT)) || (m_enemy->v.weapons & (1 << WEAPON_G3SG1)) || (m_enemy->v.weapons & (1 << WEAPON_SG550))))
|
||||
if (Random.Long (0, 100) < 40 && GetNearbyFriendsNearPosition (pev->origin, 1024) == 0 && ((m_enemy->v.weapons & (1 << WEAPON_AWP)) || (m_enemy->v.weapons & (1 << WEAPON_SCOUT)) || (m_enemy->v.weapons & (1 << WEAPON_G3SG1)) || (m_enemy->v.weapons & (1 << WEAPON_SG550))))
|
||||
ChatterMessage (Chatter_SniperWarning);
|
||||
}
|
||||
|
||||
|
|
@ -5383,7 +5405,7 @@ void Bot::TakeBlinded (const Vector &fade, int alpha)
|
|||
|
||||
m_enemy = NULL;
|
||||
|
||||
m_maxViewDistance = g_randGen.Float (10, 20);
|
||||
m_maxViewDistance = Random.Float (10, 20);
|
||||
m_blindTime = GetWorldTime () + static_cast <float> (alpha - 200) / 16;
|
||||
|
||||
if (m_difficulty <= 2)
|
||||
|
|
@ -5399,7 +5421,7 @@ void Bot::TakeBlinded (const Vector &fade, int alpha)
|
|||
|
||||
float walkSpeed = GetWalkSpeed ();
|
||||
|
||||
if (g_randGen.Long (0, 100) > 50)
|
||||
if (Random.Long (0, 100) > 50)
|
||||
m_blindSidemoveSpeed = walkSpeed;
|
||||
else
|
||||
m_blindSidemoveSpeed = -walkSpeed;
|
||||
|
|
@ -5859,7 +5881,7 @@ void Bot::CheckSilencer (void)
|
|||
int iRandomNum = (m_personality == PERSONALITY_RUSHER ? 35 : 65);
|
||||
|
||||
// aggressive bots don't like the silencer
|
||||
if (g_randGen.Long (1, 100) <= (m_currentWeapon == WEAPON_USP ? iRandomNum / 3 : iRandomNum))
|
||||
if (Random.Long (1, 100) <= (m_currentWeapon == WEAPON_USP ? iRandomNum / 3 : iRandomNum))
|
||||
{
|
||||
if (pev->weaponanim > 6) // is the silencer not attached...
|
||||
pev->button |= IN_ATTACK2; // attach the silencer
|
||||
|
|
@ -6030,7 +6052,7 @@ void Bot::ReactOnSound (void)
|
|||
m_heardSoundTime = GetWorldTime () + 5.0;
|
||||
m_states |= STATE_HEARING_ENEMY;
|
||||
|
||||
if ((g_randGen.Long (0, 100) < 25) && IsEntityNull (m_enemy) && IsEntityNull (m_lastEnemy) && m_seeEnemyTime + 7.0 < GetWorldTime ())
|
||||
if ((Random.Long (0, 100) < 25) && IsEntityNull (m_enemy) && IsEntityNull (m_lastEnemy) && m_seeEnemyTime + 7.0 < GetWorldTime ())
|
||||
ChatterMessage (Chatter_HeardEnemy);
|
||||
|
||||
m_aimFlags |= AIM_LAST_ENEMY;
|
||||
|
|
@ -6104,7 +6126,7 @@ void Bot::EquipInBuyzone (int buyCount)
|
|||
// this function is gets called when bot enters a buyzone, to allow bot to buy some stuff
|
||||
|
||||
// if bot is in buy zone, try to buy ammo for this weapon...
|
||||
if (m_lastEquipTime + 15.0 < GetWorldTime () && m_inBuyZone && g_timeRoundStart + g_randGen.Float (10.0, 20.0) + mp_buytime.GetFloat () < GetWorldTime () && !g_bombPlanted && m_moneyAmount > g_botBuyEconomyTable[0])
|
||||
if (m_lastEquipTime + 15.0 < GetWorldTime () && m_inBuyZone && g_timeRoundStart + Random.Float (10.0, 20.0) + mp_buytime.GetFloat () < GetWorldTime () && !g_bombPlanted && m_moneyAmount > g_botBuyEconomyTable[0])
|
||||
{
|
||||
m_buyingFinished = false;
|
||||
m_buyState = buyCount;
|
||||
|
|
|
|||
|
|
@ -94,14 +94,14 @@ char *HumanizeName (char *name)
|
|||
strcpy (outputName, name); // copy name to new buffer
|
||||
|
||||
// drop tag marks, 80 percent of time
|
||||
if (g_randGen.Long (1, 100) < 80)
|
||||
if (Random.Long (1, 100) < 80)
|
||||
StripTags (outputName);
|
||||
else
|
||||
strtrim (outputName);
|
||||
|
||||
// sometimes switch name to lower characters
|
||||
// note: since we're using russian names written in english, we reduce this shit to 6 percent
|
||||
if (g_randGen.Long (1, 100) <= 6)
|
||||
if (Random.Long (1, 100) <= 6)
|
||||
{
|
||||
for (int i = 0; i < static_cast <int> (strlen (outputName)); i++)
|
||||
outputName[i] = tolower (outputName[i]); // to lower case
|
||||
|
|
@ -118,7 +118,7 @@ void HumanizeChat (char *buffer)
|
|||
|
||||
// sometimes switch text to lowercase
|
||||
// note: since we're using russian chat written in english, we reduce this shit to 4 percent
|
||||
if (g_randGen.Long (1, 100) <= 4)
|
||||
if (Random.Long (1, 100) <= 4)
|
||||
{
|
||||
for (i = 0; i < length; i++)
|
||||
buffer[i] = tolower (buffer[i]); // switch to lowercase
|
||||
|
|
@ -127,9 +127,9 @@ void HumanizeChat (char *buffer)
|
|||
if (length > 15)
|
||||
{
|
||||
// "length / 2" percent of time drop a character
|
||||
if (g_randGen.Long (1, 100) < (length / 2))
|
||||
if (Random.Long (1, 100) < (length / 2))
|
||||
{
|
||||
int pos = g_randGen.Long ((length / 8), length - (length / 8)); // chose random position in string
|
||||
int pos = Random.Long ((length / 8), length - (length / 8)); // chose random position in string
|
||||
|
||||
for (i = pos; i < length - 1; i++)
|
||||
buffer[i] = buffer[i + 1]; // overwrite the buffer with stripped string
|
||||
|
|
@ -139,9 +139,9 @@ void HumanizeChat (char *buffer)
|
|||
}
|
||||
|
||||
// "length" / 4 precent of time swap character
|
||||
if (g_randGen.Long (1, 100) < (length / 4))
|
||||
if (Random.Long (1, 100) < (length / 4))
|
||||
{
|
||||
int pos = g_randGen.Long ((length / 8), ((3 * length) / 8)); // choose random position in string
|
||||
int pos = Random.Long ((length / 8), ((3 * length) / 8)); // choose random position in string
|
||||
char ch = buffer[pos]; // swap characters
|
||||
|
||||
buffer[pos] = buffer[pos + 1];
|
||||
|
|
@ -301,14 +301,14 @@ void Bot::PrepareChatMessage (char *text)
|
|||
{
|
||||
if (g_gameVersion == CSV_CZERO)
|
||||
{
|
||||
if (g_randGen.Long (1, 100) < 30)
|
||||
if (Random.Long (1, 100) < 30)
|
||||
strcat (m_tempStrings, "CZ");
|
||||
else
|
||||
strcat (m_tempStrings, "Condition Zero");
|
||||
}
|
||||
else if (g_gameVersion == CSV_STEAM || g_gameVersion == CSV_OLD)
|
||||
{
|
||||
if (g_randGen.Long (1, 100) < 30)
|
||||
if (Random.Long (1, 100) < 30)
|
||||
strcat (m_tempStrings, "CS");
|
||||
else
|
||||
strcat (m_tempStrings, "Counter-Strike");
|
||||
|
|
@ -376,7 +376,7 @@ bool CheckKeywords (char *tempMessage, char *reply)
|
|||
}
|
||||
|
||||
// didn't find a keyword? 70% of the time use some universal reply
|
||||
if (g_randGen.Long (1, 100) < 70 && !g_chatFactory[CHAT_NOKW].IsEmpty ())
|
||||
if (Random.Long (1, 100) < 70 && !g_chatFactory[CHAT_NOKW].IsEmpty ())
|
||||
{
|
||||
strcpy (reply, g_chatFactory[CHAT_NOKW].GetRandomElement ().GetBuffer ());
|
||||
return true;
|
||||
|
|
@ -409,7 +409,7 @@ bool Bot::RepliesToPlayer (void)
|
|||
// check is time to chat is good
|
||||
if (m_sayTextBuffer.timeNextChat < GetWorldTime ())
|
||||
{
|
||||
if (g_randGen.Long (1, 100) < m_sayTextBuffer.chatProbability + g_randGen.Long (2, 10) && ParseChat (reinterpret_cast <char *> (&text)))
|
||||
if (Random.Long (1, 100) < m_sayTextBuffer.chatProbability + Random.Long (2, 10) && ParseChat (reinterpret_cast <char *> (&text)))
|
||||
{
|
||||
PrepareChatMessage (text);
|
||||
PushMessageQueue (GSM_SAY);
|
||||
|
|
|
|||
|
|
@ -112,9 +112,9 @@ bool Bot::LookupEnemy (void)
|
|||
// do some blind by smoke grenade
|
||||
if (m_blindRecognizeTime < GetWorldTime () && IsBehindSmokeClouds (player))
|
||||
{
|
||||
m_blindRecognizeTime = GetWorldTime () + g_randGen.Float (1.0, 2.0);
|
||||
m_blindRecognizeTime = GetWorldTime () + Random.Float (1.0, 2.0);
|
||||
|
||||
if (g_randGen.Long (0, 100) < 50)
|
||||
if (Random.Long (0, 100) < 50)
|
||||
ChatterMessage (Chatter_BehindSmoke);
|
||||
}
|
||||
|
||||
|
|
@ -166,7 +166,7 @@ bool Bot::LookupEnemy (void)
|
|||
|
||||
m_targetEntity = NULL; // stop following when we see an enemy...
|
||||
|
||||
if (g_randGen.Long (0, 100) < m_difficulty * 25)
|
||||
if (Random.Long (0, 100) < m_difficulty * 25)
|
||||
m_enemySurpriseTime = GetWorldTime () + m_actualReactionTime / 3;
|
||||
else
|
||||
m_enemySurpriseTime = GetWorldTime () + m_actualReactionTime;
|
||||
|
|
@ -282,7 +282,7 @@ Vector Bot::GetAimPosition (void)
|
|||
Vector targetOrigin = m_enemy->v.origin;
|
||||
Vector randomize = nullvec;
|
||||
|
||||
const Vector &adjust = Vector (g_randGen.Float (m_enemy->v.mins.x * 0.5f, m_enemy->v.maxs.x * 0.5f), g_randGen.Float (m_enemy->v.mins.y * 0.5f, m_enemy->v.maxs.y * 0.5f), g_randGen.Float (m_enemy->v.mins.z * 0.5f, m_enemy->v.maxs.z * 0.5f));
|
||||
const Vector &adjust = Vector (Random.Float (m_enemy->v.mins.x * 0.5f, m_enemy->v.maxs.x * 0.5f), Random.Float (m_enemy->v.mins.y * 0.5f, m_enemy->v.maxs.y * 0.5f), Random.Float (m_enemy->v.mins.z * 0.5f, m_enemy->v.maxs.z * 0.5f));
|
||||
|
||||
// do not aim at head, at long distance (only if not using sniper weapon)
|
||||
if ((m_visibility & VISIBLE_BODY) && !UsesSniper () && !UsesPistol () && (distance > (m_difficulty == 4 ? 2400.0 : 1200.0)))
|
||||
|
|
@ -299,7 +299,7 @@ Vector Bot::GetAimPosition (void)
|
|||
int headshotFreq[5] = { 20, 40, 60, 90, 100 };
|
||||
|
||||
// now check is our skill match to aim at head, else aim at enemy body
|
||||
if ((g_randGen.Long (1, 100) < headshotFreq[m_difficulty]) || UsesPistol ())
|
||||
if ((Random.Long (1, 100) < headshotFreq[m_difficulty]) || UsesPistol ())
|
||||
targetOrigin = targetOrigin + m_enemy->v.view_ofs + Vector (0.0f, 0.0f, GetZOffset (distance));
|
||||
else
|
||||
targetOrigin = targetOrigin + Vector (0.0f, 0.0f, GetZOffset (distance));
|
||||
|
|
@ -550,12 +550,12 @@ bool Bot::DoFirePause (float distance, FireDelay *fireDelay)
|
|||
if (tanf (angle) * distance > offset + 30.0f + ((100 - (m_difficulty * 25)) / 100.f))
|
||||
{
|
||||
if (m_firePause < GetWorldTime () - 0.4f)
|
||||
m_firePause = GetWorldTime () + g_randGen.Float (0.4f, 0.4f + 0.3f * ((100 - (m_difficulty * 25)) / 100.f));
|
||||
m_firePause = GetWorldTime () + Random.Float (0.4f, 0.4f + 0.3f * ((100 - (m_difficulty * 25)) / 100.f));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_difficulty < 3 && fireDelay->maxFireBullets + g_randGen.Long (0, 1) <= m_burstShotsFired)
|
||||
if (m_difficulty < 3 && fireDelay->maxFireBullets + Random.Long (0, 1) <= m_burstShotsFired)
|
||||
{
|
||||
float delayTime = 0.1 * distance / fireDelay->minBurstPauseFactor;
|
||||
|
||||
|
|
@ -651,8 +651,8 @@ void Bot::FireWeapon (void)
|
|||
// ignore enemies protected by shields
|
||||
if (IsEnemyProtectedByShield (m_enemy) && !(m_currentWeapon == WEAPON_KNIFE) && IsEnemyViewable (m_enemy))
|
||||
{
|
||||
if (!g_bombPlanted && g_randGen.Float (0, 100) < 50)
|
||||
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + g_randGen.Float (5, 10), true);
|
||||
if (!g_bombPlanted && Random.Float (0, 100) < 50)
|
||||
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (5, 10), true);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -660,7 +660,7 @@ void Bot::FireWeapon (void)
|
|||
if (HasShield () && m_shieldCheckTime < GetWorldTime () && GetTaskId () != TASK_CAMP && IsEnemyViewable (m_enemy))
|
||||
{
|
||||
if (IsGroupOfEnemies (pev->origin, 3, 750) && !IsShieldDrawn () && !g_bombPlanted)
|
||||
StartTask (TASK_SEEKCOVER, TASKPRI_SEEKCOVER, -1, GetWorldTime () + g_randGen.Float (10, 20), true);
|
||||
StartTask (TASK_SEEKCOVER, TASKPRI_SEEKCOVER, -1, GetWorldTime () + Random.Float (10, 20), true);
|
||||
|
||||
if (distance >= 750 || ((m_enemy->v.button & IN_ATTACK) && !IsShieldDrawn()))
|
||||
{
|
||||
|
|
@ -673,12 +673,12 @@ void Bot::FireWeapon (void)
|
|||
FacePosition ();
|
||||
}
|
||||
else if(!g_bombPlanted)
|
||||
StartTask (TASK_CAMP, TASKPRI_PAUSE, -1, GetWorldTime () + g_randGen.Float (10, 20), true);
|
||||
StartTask (TASK_CAMP, TASKPRI_PAUSE, -1, GetWorldTime () + Random.Float (10, 20), true);
|
||||
|
||||
if (IsEnemyProtectedByShield (m_lastEnemy) && !(m_currentWeapon == WEAPON_KNIFE) && IsEnemyViewable (m_lastEnemy))
|
||||
{
|
||||
pev->button &= ~IN_ATTACK;
|
||||
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + g_randGen.Float (10, 20), true);
|
||||
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (10, 20), true);
|
||||
}
|
||||
}
|
||||
else if (IsShieldDrawn () || (!IsEntityNull (m_enemy) && (m_enemy->v.button & IN_RELOAD) || !IsEnemyViewable (m_enemy)))
|
||||
|
|
@ -686,7 +686,7 @@ void Bot::FireWeapon (void)
|
|||
pev->button |= (IN_ATTACK2 | IN_DUCK); // draw out the shield
|
||||
|
||||
if (!g_bombPlanted)
|
||||
StartTask (TASK_SEEKCOVER, TASKPRI_SEEKCOVER, -1, GetWorldTime () + g_randGen.Float (10, 25), true);
|
||||
StartTask (TASK_SEEKCOVER, TASKPRI_SEEKCOVER, -1, GetWorldTime () + Random.Float (10, 25), true);
|
||||
}
|
||||
m_shieldCheckTime = GetWorldTime () + 0.5;
|
||||
}
|
||||
|
|
@ -796,7 +796,7 @@ WeaponSelectEnd:
|
|||
{
|
||||
if (distance < 102.0f)
|
||||
{
|
||||
if (g_randGen.Long (1, 100) < 30)
|
||||
if (Random.Long (1, 100) < 30)
|
||||
pev->button |= IN_ATTACK; // use primary attack
|
||||
else
|
||||
pev->button |= IN_ATTACK2; // use secondary attack
|
||||
|
|
@ -863,7 +863,7 @@ WeaponSelectEnd:
|
|||
}
|
||||
pev->button |= IN_ATTACK;
|
||||
|
||||
m_shootTime = GetWorldTime () + baseDelay + g_randGen.Float (minDelay, maxDelay);
|
||||
m_shootTime = GetWorldTime () + baseDelay + Random.Float (minDelay, maxDelay);
|
||||
m_zoomCheckTime = GetWorldTime ();
|
||||
}
|
||||
|
||||
|
|
@ -988,7 +988,7 @@ void Bot::CombatFight (void)
|
|||
CheckThrow (EyePosition(), m_throw);
|
||||
|
||||
if ((m_states & STATE_SEEING_ENEMY) && !m_hasC4)
|
||||
StartTask (TASK_SEEKCOVER, TASKPRI_SEEKCOVER, -1, g_randGen.Long (10, 20), true);
|
||||
StartTask (TASK_SEEKCOVER, TASKPRI_SEEKCOVER, -1, Random.Long (10, 20), true);
|
||||
}
|
||||
// If using sniper do not jump around !
|
||||
if (UsesSniper () && m_states & STATE_SEEING_ENEMY || IsEnemyViewable (m_enemy) && !m_isStuck)
|
||||
|
|
@ -1022,7 +1022,7 @@ void Bot::CombatFight (void)
|
|||
{
|
||||
if (m_lastFightStyleCheck + 3.0 < GetWorldTime ())
|
||||
{
|
||||
int rand = g_randGen.Long (1, 100);
|
||||
int rand = Random.Long (1, 100);
|
||||
|
||||
if (distance < 450)
|
||||
m_fightStyle = 0;
|
||||
|
|
@ -1047,7 +1047,7 @@ void Bot::CombatFight (void)
|
|||
{
|
||||
if (m_lastFightStyleCheck + 3.0 < GetWorldTime ())
|
||||
{
|
||||
if (g_randGen.Long (0, 100) < 50)
|
||||
if (Random.Long (0, 100) < 50)
|
||||
m_fightStyle = 1;
|
||||
else
|
||||
m_fightStyle = 0;
|
||||
|
|
@ -1075,10 +1075,10 @@ void Bot::CombatFight (void)
|
|||
else
|
||||
m_combatStrafeDir = 0;
|
||||
|
||||
if (g_randGen.Long (1, 100) < 30)
|
||||
if (Random.Long (1, 100) < 30)
|
||||
m_combatStrafeDir ^= 1;
|
||||
|
||||
m_strafeSetTime = GetWorldTime () + g_randGen.Float (0.5, 3.0);
|
||||
m_strafeSetTime = GetWorldTime () + Random.Float (0.5, 3.0);
|
||||
}
|
||||
|
||||
if (m_combatStrafeDir == 0)
|
||||
|
|
@ -1102,7 +1102,7 @@ void Bot::CombatFight (void)
|
|||
}
|
||||
}
|
||||
|
||||
if (m_difficulty >= 3 && (m_jumpTime + 5.0 < GetWorldTime () && IsOnFloor () && g_randGen.Long (0, 1000) < (m_isReloading ? 8 : 2) && pev->velocity.GetLength2D () > 150.0))
|
||||
if (m_difficulty >= 3 && (m_jumpTime + 5.0 < GetWorldTime () && IsOnFloor () && Random.Long (0, 1000) < (m_isReloading ? 8 : 2) && pev->velocity.GetLength2D () > 150.0))
|
||||
pev->button |= IN_JUMP;
|
||||
|
||||
if (m_moveSpeed > 0.0 && distance > 150.0 && m_currentWeapon != WEAPON_KNIFE)
|
||||
|
|
@ -1116,13 +1116,10 @@ void Bot::CombatFight (void)
|
|||
float enemyHalfHeight = ((m_enemy->v.flags & FL_DUCKING) == FL_DUCKING ? 36.0 : 72.0) / 2;
|
||||
|
||||
// check center/feet
|
||||
|
||||
if (!IsVisible (m_enemy->v.origin, GetEntity ()) && !IsVisible (m_enemy->v.origin + Vector (0, 0, -enemyHalfHeight), GetEntity ()))
|
||||
shouldDuck = false;
|
||||
|
||||
int nearestToEnemyPoint = g_waypoint->FindNearest (m_enemy->v.origin);
|
||||
|
||||
if (shouldDuck && GetTaskId () != TASK_SEEKCOVER && GetTaskId () != TASK_HUNTENEMY && (m_visibility & VISIBLE_BODY) && !(m_visibility & VISIBLE_OTHER) && g_waypoint->IsDuckVisible (m_currentWaypointIndex, nearestToEnemyPoint))
|
||||
if (shouldDuck && GetTaskId () != TASK_SEEKCOVER && GetTaskId () != TASK_HUNTENEMY && (m_visibility & VISIBLE_BODY) && !(m_visibility & VISIBLE_OTHER) && g_waypoint->IsDuckVisible (m_currentWaypointIndex, g_waypoint->FindNearest (m_enemy->v.origin)))
|
||||
m_duckTime = GetWorldTime () + 0.5f;
|
||||
|
||||
m_moveSpeed = 0.0;
|
||||
|
|
@ -1449,7 +1446,7 @@ void Bot::CommandTeam (void)
|
|||
else if (memberExists && yb_communication_type.GetInt () == 2)
|
||||
ChatterMessage(Chatter_ScaredEmotion);
|
||||
|
||||
m_timeTeamOrder = GetWorldTime () + g_randGen.Float (5.0, 30.0);
|
||||
m_timeTeamOrder = GetWorldTime () + Random.Float (5.0, 30.0);
|
||||
}
|
||||
|
||||
bool Bot::IsGroupOfEnemies (Vector location, int numEnemies, int radius)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ Array <Array <String> > g_chatFactory;
|
|||
Array <Array <ChatterItem> > g_chatterFactory;
|
||||
Array <BotName> g_botNames;
|
||||
Array <KeywordFactory> g_replyFactory;
|
||||
RandGen g_randGen;
|
||||
RandomSequenceOfUnique Random;
|
||||
Library *g_gameLib = NULL;
|
||||
|
||||
meta_globals_t *gpMetaGlobals = NULL;
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
|
|||
" Website: " PRODUCT_URL "\n"
|
||||
"+---------------------------------------------------------------------------------+\n";
|
||||
|
||||
HudMessage (ent, true, Vector (g_randGen.Long (33, 255), g_randGen.Long (33, 255), g_randGen.Long (33, 255)), aboutData);
|
||||
HudMessage (ent, true, Vector (Random.Long (33, 255), Random.Long (33, 255), Random.Long (33, 255)), aboutData);
|
||||
}
|
||||
|
||||
// displays version information
|
||||
|
|
@ -249,7 +249,7 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
|
|||
if (stricmp (arg0, "randgen") == 0)
|
||||
{
|
||||
for (int i = 0; i < 500; i++)
|
||||
ServerPrintNoTag ("Result Range[0 - 100]: %d", g_randGen.Long (0, 100));
|
||||
ServerPrintNoTag ("Result Range[0 - 100]: %d", Random.Long (0, 100));
|
||||
}
|
||||
#if defined (MMGR_H)
|
||||
// dump memory information
|
||||
|
|
@ -984,6 +984,30 @@ void GameDLLInit (void)
|
|||
(*g_functionTable.pfnGameInit) ();
|
||||
}
|
||||
|
||||
void Touch (edict_t *pentTouched, edict_t *pentOther)
|
||||
{
|
||||
// this function is called when two entities' bounding boxes enter in collision. For example,
|
||||
// when a player walks upon a gun, the player entity bounding box collides to the gun entity
|
||||
// bounding box, and the result is that this function is called. It is used by the game for
|
||||
// taking the appropriate action when such an event occurs (in our example, the player who
|
||||
// is walking upon the gun will "pick it up"). Entities that "touch" others are usually
|
||||
// entities having a velocity, as it is assumed that static entities (entities that don't
|
||||
// move) will never touch anything. Hence, in our example, the pentTouched will be the gun
|
||||
// (static entity), whereas the pentOther will be the player (as it is the one moving). When
|
||||
// the two entities both have velocities, for example two players colliding, this function
|
||||
// is called twice, once for each entity moving.
|
||||
|
||||
Bot *touched = g_botManager->GetBot (pentTouched);
|
||||
|
||||
if (touched != NULL)
|
||||
touched->VerifyBreakable (pentOther);
|
||||
|
||||
if (g_isMetamod)
|
||||
RETURN_META (MRES_IGNORED);
|
||||
|
||||
(*g_functionTable.pfnTouch) (pentTouched, pentOther);
|
||||
}
|
||||
|
||||
int Spawn (edict_t *ent)
|
||||
{
|
||||
// this function asks the game DLL to spawn (i.e, give a physical existence in the virtual
|
||||
|
|
@ -2839,6 +2863,7 @@ export int GetEntityAPI2 (gamefuncs_t *functionTable, int *interfaceVersion)
|
|||
|
||||
functionTable->pfnGameInit = GameDLLInit;
|
||||
functionTable->pfnSpawn = Spawn;
|
||||
functionTable->pfnTouch = Touch;
|
||||
functionTable->pfnClientConnect = ClientConnect;
|
||||
functionTable->pfnClientDisconnect = ClientDisconnect;
|
||||
functionTable->pfnClientPutInServer = ClientPutInServer;
|
||||
|
|
@ -3052,10 +3077,7 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t
|
|||
// such if necessary. Nothing really bot-related is done in this function. The actual bot
|
||||
// initialization stuff will be done later, when we'll be certain to have a multilayer game.
|
||||
|
||||
// initialize random number generator
|
||||
g_randGen.Initialize (time (NULL));
|
||||
|
||||
static struct ModSupport_t
|
||||
static struct ModSupport
|
||||
{
|
||||
char name[10];
|
||||
char linuxLib[12];
|
||||
|
|
@ -3080,11 +3102,11 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t
|
|||
// register our cvars
|
||||
g_convarWrapper->PushRegisteredConVarsToEngine ();
|
||||
|
||||
ModSupport_t *knownMod = NULL;
|
||||
ModSupport *knownMod = NULL;
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE_HLSDK (s_supportedMods); i++)
|
||||
{
|
||||
ModSupport_t *mod = &s_supportedMods[i];
|
||||
ModSupport *mod = &s_supportedMods[i];
|
||||
|
||||
if (strcmp (mod->name, GetModName ()) == 0 && TryFileOpen (FormatBuffer ("%s/dlls/%s", mod->name,
|
||||
#if defined (PLATFORM_WIN32)
|
||||
|
|
|
|||
|
|
@ -89,17 +89,17 @@ int BotManager::CreateBot (String name, int difficulty, int personality, int tea
|
|||
|
||||
if (difficulty < 0 || difficulty > 4)
|
||||
{
|
||||
difficulty = g_randGen.Long (3, 4);
|
||||
difficulty = Random.Long (3, 4);
|
||||
yb_difficulty.SetInt (difficulty);
|
||||
}
|
||||
|
||||
if (personality < 0 || personality > 2)
|
||||
{
|
||||
if (g_randGen.Long (0, 100) < 50)
|
||||
if (Random.Long (0, 100) < 50)
|
||||
personality = PERSONALITY_NORMAL;
|
||||
else
|
||||
{
|
||||
if (g_randGen.Long (0, 100) > 50)
|
||||
if (Random.Long (0, 100) > 50)
|
||||
personality = PERSONALITY_RUSHER;
|
||||
else
|
||||
personality = PERSONALITY_CAREFUL;
|
||||
|
|
@ -131,7 +131,7 @@ int BotManager::CreateBot (String name, int difficulty, int personality, int tea
|
|||
}
|
||||
}
|
||||
else
|
||||
sprintf (outputName, "bot%i", g_randGen.Long (0, 100)); // just pick ugly random name
|
||||
sprintf (outputName, "bot%i", Random.Long (0, 100)); // just pick ugly random name
|
||||
}
|
||||
else
|
||||
strncpy (outputName, name, 21);
|
||||
|
|
@ -776,12 +776,12 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member)
|
|||
m_startAction = GSM_IDLE;
|
||||
m_moneyAmount = 0;
|
||||
|
||||
m_logotypeIndex = g_randGen.Long (0, 5);
|
||||
m_logotypeIndex = Random.Long (0, 5);
|
||||
m_msecVal = static_cast <byte> (g_pGlobals->frametime * 1000.0);
|
||||
|
||||
// assign how talkative this bot will be
|
||||
m_sayTextBuffer.chatDelay = g_randGen.Float (3.8, 10.0);
|
||||
m_sayTextBuffer.chatProbability = g_randGen.Long (1, 100);
|
||||
m_sayTextBuffer.chatDelay = Random.Float (3.8, 10.0);
|
||||
m_sayTextBuffer.chatProbability = Random.Long (1, 100);
|
||||
|
||||
m_notKilled = false;
|
||||
m_weaponBurstMode = BM_OFF;
|
||||
|
|
@ -789,7 +789,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member)
|
|||
|
||||
if (difficulty < 0 || difficulty > 4)
|
||||
{
|
||||
difficulty = g_randGen.Long (3, 4);
|
||||
difficulty = Random.Long (3, 4);
|
||||
yb_difficulty.SetInt (difficulty);
|
||||
}
|
||||
|
||||
|
|
@ -800,27 +800,27 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member)
|
|||
bot->v.idealpitch = bot->v.v_angle.x;
|
||||
bot->v.ideal_yaw = bot->v.v_angle.y;
|
||||
|
||||
bot->v.yaw_speed = g_randGen.Float (m_difficulty * 40, m_difficulty * 45);
|
||||
bot->v.pitch_speed = g_randGen.Float (m_difficulty * 40, m_difficulty * 45);
|
||||
bot->v.yaw_speed = Random.Float (m_difficulty * 40, m_difficulty * 45);
|
||||
bot->v.pitch_speed = Random.Float (m_difficulty * 40, m_difficulty * 45);
|
||||
|
||||
switch (personality)
|
||||
{
|
||||
case 1:
|
||||
m_personality = PERSONALITY_RUSHER;
|
||||
m_baseAgressionLevel = g_randGen.Float (0.7, 1.0);
|
||||
m_baseFearLevel = g_randGen.Float (0.0, 0.4);
|
||||
m_baseAgressionLevel = Random.Float (0.7, 1.0);
|
||||
m_baseFearLevel = Random.Float (0.0, 0.4);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
m_personality = PERSONALITY_CAREFUL;
|
||||
m_baseAgressionLevel = g_randGen.Float (0.2, 0.5);
|
||||
m_baseFearLevel = g_randGen.Float (0.7, 1.0);
|
||||
m_baseAgressionLevel = Random.Float (0.2, 0.5);
|
||||
m_baseFearLevel = Random.Float (0.7, 1.0);
|
||||
break;
|
||||
|
||||
default:
|
||||
m_personality = PERSONALITY_NORMAL;
|
||||
m_baseAgressionLevel = g_randGen.Float (0.4, 0.7);
|
||||
m_baseFearLevel = g_randGen.Float (0.4, 0.7);
|
||||
m_baseAgressionLevel = Random.Float (0.4, 0.7);
|
||||
m_baseFearLevel = Random.Float (0.4, 0.7);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -828,7 +828,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member)
|
|||
memset (&m_ammo, 0, sizeof (m_ammo));
|
||||
|
||||
m_currentWeapon = 0; // current weapon is not assigned at start
|
||||
m_voicePitch = g_randGen.Long (166, 250) / 2; // assign voice pitch
|
||||
m_voicePitch = Random.Long (166, 250) / 2; // assign voice pitch
|
||||
|
||||
// copy them over to the temp level variables
|
||||
m_agressionLevel = m_baseAgressionLevel;
|
||||
|
|
@ -952,7 +952,7 @@ void Bot::NewRound (void)
|
|||
switch (m_personality)
|
||||
{
|
||||
case PERSONALITY_NORMAL:
|
||||
m_pathType = g_randGen.Long (0, 100) > 50 ? 1 : 2;
|
||||
m_pathType = Random.Long (0, 100) > 50 ? 1 : 2;
|
||||
break;
|
||||
|
||||
case PERSONALITY_RUSHER:
|
||||
|
|
@ -1071,8 +1071,8 @@ void Bot::NewRound (void)
|
|||
m_currentWeapon = 0;
|
||||
}
|
||||
|
||||
m_knifeAttackTime = GetWorldTime () + g_randGen.Float (1.3, 2.6);
|
||||
m_nextBuyTime = GetWorldTime () + g_randGen.Float (0.6, 1.2);
|
||||
m_knifeAttackTime = GetWorldTime () + Random.Float (1.3, 2.6);
|
||||
m_nextBuyTime = GetWorldTime () + Random.Float (0.6, 1.2);
|
||||
|
||||
m_buyPending = false;
|
||||
m_inBombZone = false;
|
||||
|
|
@ -1095,7 +1095,7 @@ void Bot::NewRound (void)
|
|||
m_defendHostage = false;
|
||||
m_headedTime = 0.0f;
|
||||
|
||||
m_timeLogoSpray = GetWorldTime () + g_randGen.Float (0.5, 2.0);
|
||||
m_timeLogoSpray = GetWorldTime () + Random.Float (0.5, 2.0);
|
||||
m_spawnTime = GetWorldTime ();
|
||||
m_lastChatTime = GetWorldTime ();
|
||||
pev->v_angle.y = pev->ideal_yaw;
|
||||
|
|
@ -1119,7 +1119,7 @@ void Bot::NewRound (void)
|
|||
PushMessageQueue (GSM_BUY_STUFF);
|
||||
StartTask (TASK_NORMAL, TASKPRI_NORMAL, -1, 0.0, true);
|
||||
|
||||
if (g_randGen.Long (0, 100) < 50)
|
||||
if (Random.Long (0, 100) < 50)
|
||||
ChatterMessage (Chatter_NewRound);
|
||||
}
|
||||
|
||||
|
|
@ -1197,12 +1197,12 @@ void Bot::StartGame (void)
|
|||
if (g_gameVersion == CSV_CZERO) // czero has spetsnaz and militia skins
|
||||
{
|
||||
if (m_wantedClass < 1 || m_wantedClass > 5)
|
||||
m_wantedClass = g_randGen.Long (1, 5); // use random if invalid
|
||||
m_wantedClass = Random.Long (1, 5); // use random if invalid
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_wantedClass < 1 || m_wantedClass > 4)
|
||||
m_wantedClass = g_randGen.Long (1, 4); // use random if invalid
|
||||
m_wantedClass = Random.Long (1, 4); // use random if invalid
|
||||
}
|
||||
|
||||
// select the class the bot wishes to use...
|
||||
|
|
@ -1212,7 +1212,7 @@ void Bot::StartGame (void)
|
|||
m_notStarted = false;
|
||||
|
||||
// check for greeting other players, since we connected
|
||||
if (g_randGen.Long (0, 100) < 20)
|
||||
if (Random.Long (0, 100) < 20)
|
||||
ChatMessage (CHAT_WELCOME);
|
||||
}
|
||||
}
|
||||
|
|
@ -1238,7 +1238,7 @@ void BotManager::CalculatePingOffsets (void)
|
|||
PLAYER_CNX_STATS (ent, &ping, &loss);
|
||||
|
||||
if (ping < 0 || ping > 100)
|
||||
ping = g_randGen.Long (3, 15);
|
||||
ping = Random.Long (3, 15);
|
||||
|
||||
averagePing += ping;
|
||||
}
|
||||
|
|
@ -1246,7 +1246,7 @@ void BotManager::CalculatePingOffsets (void)
|
|||
if (numHumans > 0)
|
||||
averagePing /= numHumans;
|
||||
else
|
||||
averagePing = g_randGen.Long (30, 40);
|
||||
averagePing = Random.Long (30, 40);
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
{
|
||||
|
|
@ -1255,12 +1255,12 @@ void BotManager::CalculatePingOffsets (void)
|
|||
if (bot == NULL)
|
||||
continue;
|
||||
|
||||
int botPing = g_randGen.Long (averagePing - averagePing * 0.2f, averagePing + averagePing * 0.2f) + g_randGen.Long (bot->m_difficulty + 3, bot->m_difficulty + 6) + 10;
|
||||
int botPing = Random.Long (averagePing - averagePing * 0.2f, averagePing + averagePing * 0.2f) + Random.Long (bot->m_difficulty + 3, bot->m_difficulty + 6) + 10;
|
||||
|
||||
if (botPing <= 5)
|
||||
botPing = g_randGen.Long (10, 23);
|
||||
botPing = Random.Long (10, 23);
|
||||
else if (botPing > 100)
|
||||
botPing = g_randGen.Long (30, 40);
|
||||
botPing = Random.Long (30, 40);
|
||||
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -128,10 +128,10 @@ int Bot::FindGoal (void)
|
|||
return m_chosenGoalIndex = FindDefendWaypoint (g_waypoint->GetBombPosition ());
|
||||
}
|
||||
|
||||
goalDesire = g_randGen.Long (0, 100 + (offensive * 0.5)) + offensive;
|
||||
forwardDesire = g_randGen.Long (0, 100) + offensive;
|
||||
campDesire = g_randGen.Long (0, 100) + defensive;
|
||||
backoffDesire = g_randGen.Long (0, 100) + defensive;
|
||||
goalDesire = Random.Long (0, 100 + (offensive * 0.5)) + offensive;
|
||||
forwardDesire = Random.Long (0, 100) + offensive;
|
||||
campDesire = Random.Long (0, 100) + defensive;
|
||||
backoffDesire = Random.Long (0, 100) + defensive;
|
||||
|
||||
if (!UsesCampGun ())
|
||||
campDesire = 0;
|
||||
|
|
@ -244,7 +244,7 @@ TacticChoosen:
|
|||
ChangeWptIndex (g_waypoint->FindNearest (pev->origin));
|
||||
|
||||
if (goalChoices[0] == -1)
|
||||
return m_chosenGoalIndex = g_randGen.Long (0, g_numWaypoints - 1);
|
||||
return m_chosenGoalIndex = Random.Long (0, g_numWaypoints - 1);
|
||||
|
||||
bool isSorting = false;
|
||||
|
||||
|
|
@ -311,19 +311,6 @@ bool Bot::GoalIsValid (void)
|
|||
|
||||
void Bot::CheckTerrain (float movedDistance, const Vector &dir, const Vector &dirNormal)
|
||||
{
|
||||
edict_t *ent = NULL;
|
||||
|
||||
// Test if there's a shootable breakable in our way
|
||||
if (m_breakableCheckTime < GetWorldTime () && !IsEntityNull (ent = FindBreakable ()))
|
||||
{
|
||||
m_breakableEntity = ent;
|
||||
m_campButtons = pev->button & IN_DUCK;
|
||||
|
||||
StartTask (TASK_SHOOTBREAKABLE, TASKPRI_SHOOTBREAKABLE, -1, 0.0, false);
|
||||
m_breakableCheckTime = GetWorldTime () + 1.0f;
|
||||
|
||||
return;
|
||||
}
|
||||
m_isStuck = false;
|
||||
|
||||
Vector src = nullvec;
|
||||
|
|
@ -333,11 +320,9 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dir, const Vector &di
|
|||
Vector directionNormal = dirNormal;
|
||||
|
||||
TraceResult tr;
|
||||
edict_t *nearest = NULL;
|
||||
|
||||
ent = NULL;
|
||||
edict_t *pentNearest = NULL;
|
||||
|
||||
if (FindNearestPlayer (reinterpret_cast <void **> (&pentNearest), GetEntity (), pev->maxspeed, true, false, true, true)) // found somebody?
|
||||
if (FindNearestPlayer (reinterpret_cast <void **> (&nearest), GetEntity (), pev->maxspeed, true, false, true, true)) // found somebody?
|
||||
{
|
||||
MakeVectors (m_moveAngles); // use our movement angles
|
||||
|
||||
|
|
@ -346,14 +331,14 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dir, const Vector &di
|
|||
moved = moved + g_pGlobals->v_right * m_strafeSpeed * m_frameInterval;
|
||||
moved = moved + pev->velocity * m_frameInterval;
|
||||
|
||||
float nearestDistance = (pentNearest->v.origin - pev->origin).GetLength2D ();
|
||||
float nextFrameDistance = ((pentNearest->v.origin + pentNearest->v.velocity * m_frameInterval) - pev->origin).GetLength2D ();
|
||||
float nearestDistance = (nearest->v.origin - pev->origin).GetLength2D ();
|
||||
float nextFrameDistance = ((nearest->v.origin + nearest->v.velocity * m_frameInterval) - pev->origin).GetLength2D ();
|
||||
|
||||
// is player that near now or in future that we need to steer away?
|
||||
if ((pentNearest->v.origin - moved).GetLength2D () <= 48.0 || (nearestDistance <= 56.0 && nextFrameDistance < nearestDistance))
|
||||
if ((nearest->v.origin - moved).GetLength2D () <= 48.0 || (nearestDistance <= 56.0 && nextFrameDistance < nearestDistance))
|
||||
{
|
||||
// to start strafing, we have to first figure out if the target is on the left side or right side
|
||||
Vector dirToPoint = (pev->origin - pentNearest->v.origin).SkipZ ();
|
||||
Vector dirToPoint = (pev->origin - nearest->v.origin).SkipZ ();
|
||||
|
||||
if ((dirToPoint | g_pGlobals->v_right.SkipZ ()) > 0.0)
|
||||
SetStrafeSpeed (directionNormal, pev->maxspeed);
|
||||
|
|
@ -419,7 +404,7 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dir, const Vector &di
|
|||
else if (IsInWater ())
|
||||
bits = (PROBE_JUMP | PROBE_STRAFE);
|
||||
else
|
||||
bits = ((g_randGen.Long (0, 10) > 7 ? PROBE_JUMP : 0) | PROBE_STRAFE | PROBE_DUCK);
|
||||
bits = ((Random.Long (0, 10) > 7 ? PROBE_JUMP : 0) | PROBE_STRAFE | PROBE_DUCK);
|
||||
|
||||
// collision check allowed if not flying through the air
|
||||
if (IsOnFloor () || IsOnLadder () || IsInWater ())
|
||||
|
|
@ -657,8 +642,8 @@ bool Bot::DoWaypointNav (void)
|
|||
// if wayzone radios non zero vary origin a bit depending on the body angles
|
||||
if (m_currentPath->radius > 0)
|
||||
{
|
||||
MakeVectors (Vector (pev->angles.x, AngleNormalize (pev->angles.y + g_randGen.Float (-90, 90)), 0.0));
|
||||
m_waypointOrigin = m_waypointOrigin + g_pGlobals->v_forward * g_randGen.Float (0, m_currentPath->radius);
|
||||
MakeVectors (Vector (pev->angles.x, AngleNormalize (pev->angles.y + Random.Float (-90, 90)), 0.0));
|
||||
m_waypointOrigin = m_waypointOrigin + g_pGlobals->v_forward * Random.Float (0, m_currentPath->radius);
|
||||
}
|
||||
m_navTimeset = GetWorldTime ();
|
||||
}
|
||||
|
|
@ -1063,7 +1048,7 @@ bool Bot::DoWaypointNav (void)
|
|||
{
|
||||
m_lastCollTime = GetWorldTime () + 0.5; // don't consider being stuck
|
||||
|
||||
if (g_randGen.Long (1, 100) < 50)
|
||||
if (Random.Long (1, 100) < 50)
|
||||
MDLL_Use (tr.pHit, GetEntity ()); // also 'use' the door randomly
|
||||
}
|
||||
|
||||
|
|
@ -1851,13 +1836,13 @@ bool Bot::FindWaypoint (void)
|
|||
|
||||
// now pick random one from choosen
|
||||
if (waypointIndeces[2] != -1)
|
||||
i = g_randGen.Long (0, 2);
|
||||
i = Random.Long (0, 2);
|
||||
|
||||
else if (waypointIndeces[1] != -1)
|
||||
i = g_randGen.Long (0, 1);
|
||||
i = Random.Long (0, 1);
|
||||
|
||||
else if (waypointIndeces[0] != -1)
|
||||
i = g_randGen.Long (0, 0);
|
||||
i = Random.Long (0, 0);
|
||||
|
||||
else if (coveredWaypoint != -1)
|
||||
{
|
||||
|
|
@ -1893,7 +1878,7 @@ bool Bot::FindWaypoint (void)
|
|||
waypointIndeces[i] = random;
|
||||
}
|
||||
else
|
||||
waypointIndeces[i] = g_randGen.Long (0, g_numWaypoints - 1);
|
||||
waypointIndeces[i] = Random.Long (0, g_numWaypoints - 1);
|
||||
}
|
||||
|
||||
m_collideTime = GetWorldTime ();
|
||||
|
|
@ -2001,7 +1986,7 @@ int Bot::ChooseBombWaypoint (void)
|
|||
Array <int> &goals = g_waypoint->m_goalPoints;
|
||||
|
||||
if (goals.IsEmpty ())
|
||||
return g_randGen.Long (0, g_numWaypoints - 1); // reliability check
|
||||
return Random.Long (0, g_numWaypoints - 1); // reliability check
|
||||
|
||||
Vector bombOrigin = CheckBombAudible ();
|
||||
|
||||
|
|
@ -2056,7 +2041,7 @@ int Bot::FindDefendWaypoint (Vector origin)
|
|||
|
||||
// some of points not found, return random one
|
||||
if (srcIndex == -1 || posIndex == -1)
|
||||
return g_randGen.Long (0, g_numWaypoints - 1);
|
||||
return Random.Long (0, g_numWaypoints - 1);
|
||||
|
||||
for (int i = 0; i < g_numWaypoints; i++) // find the best waypoint now
|
||||
{
|
||||
|
|
@ -2138,7 +2123,7 @@ int Bot::FindDefendWaypoint (Vector origin)
|
|||
g_waypoint->FindInRadius (found, 1024.0f, origin);
|
||||
|
||||
if (found.IsEmpty ())
|
||||
return g_randGen.Long (0, g_numWaypoints - 1); // most worst case, since there a evil error in waypoints
|
||||
return Random.Long (0, g_numWaypoints - 1); // most worst case, since there a evil error in waypoints
|
||||
|
||||
return found.GetRandomElement ();
|
||||
}
|
||||
|
|
@ -2149,7 +2134,7 @@ int Bot::FindDefendWaypoint (Vector origin)
|
|||
if (waypointIndex[index] == -1)
|
||||
break;
|
||||
}
|
||||
return waypointIndex[g_randGen.Long (0, (index - 1) / 2)];
|
||||
return waypointIndex[Random.Long (0, (index - 1) / 2)];
|
||||
}
|
||||
|
||||
int Bot::FindCoverWaypoint (float maxDistance)
|
||||
|
|
@ -2388,7 +2373,7 @@ bool Bot::HeadTowardWaypoint (void)
|
|||
{
|
||||
if (static_cast <float> (kills) == m_baseAgressionLevel)
|
||||
m_campButtons |= IN_DUCK;
|
||||
else if (g_randGen.Long (1, 100) > (m_difficulty * 25 + g_randGen.Long (1, 20)))
|
||||
else if (Random.Long (1, 100) > (m_difficulty * 25 + Random.Long (1, 20)))
|
||||
m_minSpeed = GetWalkSpeed ();
|
||||
}
|
||||
}
|
||||
|
|
@ -2471,8 +2456,8 @@ bool Bot::HeadTowardWaypoint (void)
|
|||
// if wayzone radius non zero vary origin a bit depending on the body angles
|
||||
if (m_currentPath->radius > 0.0f)
|
||||
{
|
||||
MakeVectors (Vector (pev->angles.x, AngleNormalize (pev->angles.y + g_randGen.Float (-90, 90)), 0.0));
|
||||
m_waypointOrigin = m_waypointOrigin + g_pGlobals->v_forward * g_randGen.Float (0, m_currentPath->radius);
|
||||
MakeVectors (Vector (pev->angles.x, AngleNormalize (pev->angles.y + Random.Float (-90, 90)), 0.0));
|
||||
m_waypointOrigin = m_waypointOrigin + g_pGlobals->v_forward * Random.Float (0, m_currentPath->radius);
|
||||
}
|
||||
|
||||
if (IsOnLadder ())
|
||||
|
|
@ -3083,9 +3068,9 @@ int Bot::GetAimingWaypoint (void)
|
|||
count--;
|
||||
|
||||
if (count >= 0)
|
||||
return indeces[g_randGen.Long (0, count)];
|
||||
return indeces[Random.Long (0, count)];
|
||||
|
||||
return g_randGen.Long (0, g_numWaypoints - 1);
|
||||
return Random.Long (0, g_numWaypoints - 1);
|
||||
}
|
||||
|
||||
void Bot::FacePosition (void)
|
||||
|
|
@ -3193,10 +3178,10 @@ void Bot::FacePosition (void)
|
|||
randomize = randomization;
|
||||
|
||||
// randomize targeted location a bit (slightly towards the ground)
|
||||
m_randomizedIdealAngles = m_idealAngles + Vector (g_randGen.Float (-randomize.x * 0.5, randomize.x * 1.5), g_randGen.Float (-randomize.y, randomize.y), 0);
|
||||
m_randomizedIdealAngles = m_idealAngles + Vector (Random.Float (-randomize.x * 0.5, randomize.x * 1.5), Random.Float (-randomize.y, randomize.y), 0);
|
||||
|
||||
// set next time to do this
|
||||
m_randomizeAnglesTime = GetWorldTime () + g_randGen.Float (0.4, yb_aim_offset_delay.GetFloat ());
|
||||
m_randomizeAnglesTime = GetWorldTime () + Random.Float (0.4, yb_aim_offset_delay.GetFloat ());
|
||||
}
|
||||
float stiffnessMultiplier = yb_aim_notarget_slowdown_ratio.GetFloat ();
|
||||
|
||||
|
|
|
|||
|
|
@ -417,7 +417,7 @@ void NetworkMsg::Execute (void *p)
|
|||
bot->DeleteSearchNodes();
|
||||
bot->ResetTasks();
|
||||
|
||||
if (g_randGen.Long(0, 100) < 75 && GetTeam(bot->GetEntity()) == TEAM_CF)
|
||||
if (Random.Long(0, 100) < 75 && GetTeam(bot->GetEntity()) == TEAM_CF)
|
||||
bot->ChatterMessage(Chatter_WhereIsTheBomb);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -860,9 +860,9 @@ void HudMessage (edict_t *ent, bool toCenter, Vector rgb, char *format, ...)
|
|||
WRITE_BYTE (static_cast <int> (rgb.y));
|
||||
WRITE_BYTE (static_cast <int> (rgb.z));
|
||||
WRITE_BYTE (0);
|
||||
WRITE_BYTE (g_randGen.Long (230, 255));
|
||||
WRITE_BYTE (g_randGen.Long (230, 255));
|
||||
WRITE_BYTE (g_randGen.Long (230, 255));
|
||||
WRITE_BYTE (Random.Long (230, 255));
|
||||
WRITE_BYTE (Random.Long (230, 255));
|
||||
WRITE_BYTE (Random.Long (230, 255));
|
||||
WRITE_BYTE (200);
|
||||
WRITE_SHORT (FixedUnsigned16 (0.0078125, 1 << 8));
|
||||
WRITE_SHORT (FixedUnsigned16 (2, 1 << 8));
|
||||
|
|
@ -1079,7 +1079,7 @@ void CheckWelcomeMessage (void)
|
|||
ServerCommand ("speak \"%s\"", const_cast <char *> (sentences.GetRandomElement ().GetBuffer ()));
|
||||
|
||||
ChartPrint ("----- YaPB v%s (Build: %u), {%s}, (c) 2015, by %s -----", PRODUCT_VERSION, GenerateBuildNumber (), PRODUCT_DATE, PRODUCT_AUTHOR);
|
||||
HudMessage (g_hostEntity, true, Vector (g_randGen.Long (33, 255), g_randGen.Long (33, 255), g_randGen.Long (33, 255)), "\nServer is running YaPB v%s (Build: %u)\nDeveloped by %s\n\n%s", PRODUCT_VERSION, GenerateBuildNumber (), PRODUCT_AUTHOR, g_waypoint->GetInfo ());
|
||||
HudMessage (g_hostEntity, true, Vector (Random.Long (33, 255), Random.Long (33, 255), Random.Long (33, 255)), "\nServer is running YaPB v%s (Build: %u)\nDeveloped by %s\n\n%s", PRODUCT_VERSION, GenerateBuildNumber (), PRODUCT_AUTHOR, g_waypoint->GetInfo ());
|
||||
|
||||
receiveTime = 0.0;
|
||||
isReceived = true;
|
||||
|
|
@ -1287,109 +1287,6 @@ char *Localizer::TranslateInput (const char *input)
|
|||
return const_cast <char *> (&input[0]); // nothing found
|
||||
}
|
||||
|
||||
uint32 RandGen::GetRandomBits (void)
|
||||
{
|
||||
// generate next number
|
||||
uint32 x = _lrotl (m_historyBuffer[m_bufferIndex1][0], R1) + m_historyBuffer[m_bufferIndex2][0];
|
||||
uint32 y = _lrotl (m_historyBuffer[m_bufferIndex1][1], R2) + m_historyBuffer[m_bufferIndex2][1];
|
||||
|
||||
m_historyBuffer[m_bufferIndex1][0] = y;
|
||||
m_historyBuffer[m_bufferIndex1][1] = x;
|
||||
|
||||
// rotate list pointers
|
||||
if (m_bufferIndex1-- < 0)
|
||||
m_bufferIndex1 = KK - 1;
|
||||
|
||||
if (m_bufferIndex2-- < 0)
|
||||
m_bufferIndex2 = KK - 1;
|
||||
|
||||
// perform self-test
|
||||
if (m_historyBuffer[m_bufferIndex1][0] == m_selfTestBuffer[0][0] && memcmp (m_historyBuffer, m_selfTestBuffer[KK - m_bufferIndex1], 2 * KK * sizeof (uint32)) == 0)
|
||||
{
|
||||
// self-test failed
|
||||
if ((m_bufferIndex2 + KK - m_bufferIndex1) % KK != JJ)
|
||||
AddLogEntry (false, LL_FATAL, "Random number generator could not be initialized.");
|
||||
else
|
||||
AddLogEntry (false, LL_FATAL, "Random number generator returned to initial state.");
|
||||
}
|
||||
m_randomBits[0] = y;
|
||||
m_randomBits[1] = x;
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
long double RandGen::Random (void)
|
||||
{
|
||||
return static_cast <double> (GetRandomBits () * (1.0 / (static_cast <double> (static_cast <uint32> (-1L)) + 1.0)));
|
||||
}
|
||||
|
||||
int RandGen::Long (int low, int high)
|
||||
{
|
||||
// this function returns a random integer number between (and including) the starting and
|
||||
// ending values passed by parameters from and to.
|
||||
|
||||
int interval = high - low + 1;
|
||||
|
||||
if (interval <= 0)
|
||||
return low;
|
||||
|
||||
int truncate = static_cast <int> (interval * Random ());
|
||||
|
||||
if (truncate >= interval)
|
||||
truncate = interval - 1.0;
|
||||
|
||||
return low + truncate;
|
||||
}
|
||||
|
||||
float RandGen::Float (float low, float high)
|
||||
{
|
||||
// this function returns a random floating-point number between (and including) the starting
|
||||
// and ending values passed by parameters from and to.
|
||||
|
||||
float interval = high - low;
|
||||
|
||||
if (interval <= 0.0)
|
||||
return low;
|
||||
|
||||
float truncate = static_cast <float> (interval * Random ());
|
||||
|
||||
if (truncate >= interval)
|
||||
truncate = interval;
|
||||
|
||||
return low + truncate;
|
||||
}
|
||||
|
||||
void RandGen::Initialize (uint32 seed)
|
||||
{
|
||||
// this function initializes the random number generator.
|
||||
|
||||
// make random numbers and put them into the buffer
|
||||
for (int i = 0; i < KK; i++)
|
||||
{
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
seed = seed * 2891336453UL + 1;
|
||||
m_historyBuffer[i][j] = seed;
|
||||
}
|
||||
}
|
||||
|
||||
// set exponent of randp
|
||||
m_randomBits[2] = 0;
|
||||
m_randomPtr = 1.0;
|
||||
|
||||
// initialize pointers to circular buffer
|
||||
m_bufferIndex1 = 0;
|
||||
m_bufferIndex2 = JJ;
|
||||
|
||||
// store state for self-test
|
||||
memcpy (m_selfTestBuffer, m_historyBuffer, 2 * KK * sizeof (uint32));
|
||||
memcpy (m_selfTestBuffer[KK], m_historyBuffer, 2 * KK * sizeof (uint32));
|
||||
|
||||
// randomize some more
|
||||
for (int i = 0; i < 128; i++)
|
||||
GetRandomBits ();
|
||||
}
|
||||
|
||||
bool FindNearestPlayer (void **pvHolder, edict_t *to, float searchDistance, bool sameTeam, bool needBot, bool isAlive, bool needDrawn)
|
||||
{
|
||||
// this function finds nearest to to, player with set of parameters, like his
|
||||
|
|
@ -1399,6 +1296,8 @@ bool FindNearestPlayer (void **pvHolder, edict_t *to, float searchDistance, bool
|
|||
edict_t *survive = NULL; // pointer to temporaly & survive entity
|
||||
float nearestPlayer = 4096.0; // nearest player
|
||||
|
||||
int toTeam = GetTeam (to);
|
||||
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
{
|
||||
edict_t *ent = g_clients[i].ent;
|
||||
|
|
@ -1406,7 +1305,7 @@ bool FindNearestPlayer (void **pvHolder, edict_t *to, float searchDistance, bool
|
|||
if (!(g_clients[i].flags & CF_USED) || ent == to)
|
||||
continue;
|
||||
|
||||
if ((sameTeam && g_clients[i].team != GetTeam (to)) || (isAlive && !(g_clients[i].flags & CF_ALIVE)) || (needBot && !IsValidBot (ent)) || (needDrawn && (ent->v.effects & EF_NODRAW)))
|
||||
if ((sameTeam && g_clients[i].team != toTeam) || (isAlive && !(g_clients[i].flags & CF_ALIVE)) || (needBot && !IsValidBot (ent)) || (needDrawn && (ent->v.effects & EF_NODRAW)))
|
||||
continue; // filter players with parameters
|
||||
|
||||
float distance = (ent->v.origin - to->v.origin).GetLengthSquared ();
|
||||
|
|
|
|||
|
|
@ -2423,7 +2423,7 @@ int Waypoint::AddGoalScore (int index, int other[4])
|
|||
}
|
||||
|
||||
if (left.IsEmpty ())
|
||||
index = other[g_randGen.Long (0, 3)];
|
||||
index = other[Random.Long (0, 3)];
|
||||
else
|
||||
index = left.GetRandomElement ();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue