Merge pull request #30 from jeefo/develop

Develop
This commit is contained in:
jeefo 2016-02-06 23:38:26 +03:00
commit 0b2bbf1ae8
9 changed files with 149 additions and 98 deletions

View file

@ -58,9 +58,11 @@ enum TaskID
// supported cs's
enum CSVersion
{
CSV_STEAM = 1, // Counter-Strike 1.6 and Above
CSV_CZERO = 2, // Counter-Strike: Condition Zero
CSV_OLD = 3 // Counter-Strike 1.3-1.5 with/without Steam
CSVERSION_CSTRIKE16 = (1 << 0), // Counter-Strike 1.6 and Above
CSVERSION_XASH = (1 << 1), // Counter-Strike 1.6 under the xash engine (additional flag)
CSVERSION_CZERO = (1 << 2), // Counter-Strike: Condition Zero
CSVERSION_LEGACY = (1 << 3), // Counter-Strike 1.3-1.5 with/without Steam
CSVERSION_MOBILITY = (1 << 4) // additional flag that bot is running on android (additional flag)
};
// log levels
@ -811,6 +813,7 @@ private:
float m_lastFightStyleCheck; // time checked style
float m_strafeSetTime; // time strafe direction was set
float m_maxThrowTimer; // time that completes the throw task
float m_timeCamping; // time to camp
int m_campDirection; // camp Facing direction
float m_nextCampDirTime; // time next camp direction change

View file

@ -133,7 +133,7 @@ bool Bot::EntityIsVisible (const Vector &dest, bool fromBody)
void Bot::CheckGrenadeThrow (void)
{
// check if throwing a grenade is a good thing to do...
if (m_lastEnemy == NULL || yb_ignore_enemies.GetBool () || yb_jasonmode.GetBool () || m_grenadeCheckTime > GetWorldTime () || m_isUsingGrenade || GetTaskId () == TASK_PLANTBOMB || GetTaskId () == TASK_DEFUSEBOMB || m_isReloading || !IsAlive (m_lastEnemy))
if (m_lastEnemy == NULL || yb_ignore_enemies.GetBool () || yb_jasonmode.GetBool () || m_grenadeCheckTime > GetWorldTime () && m_isUsingGrenade || GetTaskId () == TASK_PLANTBOMB || GetTaskId () == TASK_DEFUSEBOMB || m_isReloading || !IsAlive (m_lastEnemy))
{
m_states &= ~(STATE_THROW_HE | STATE_THROW_FB | STATE_THROW_SG);
return;
@ -267,7 +267,10 @@ void Bot::CheckGrenadeThrow (void)
// delay next grenade throw
if (m_states & (STATE_THROW_HE | STATE_THROW_FB | STATE_THROW_SG))
{
m_grenadeCheckTime = GetWorldTime () + MAX_GRENADE_TIMER;
m_maxThrowTimer = GetWorldTime () + MAX_GRENADE_TIMER * 2.0f;
}
}
void Bot::AvoidGrenades (void)
@ -960,7 +963,7 @@ void Bot::SwitchChatterIcon (bool show)
{
// this function depending on show boolen, shows/remove chatter, icon, on the head of bot.
if (g_gameVersion == CSV_OLD || yb_communication_type.GetInt () != 2)
if ((g_gameVersion & CSVERSION_LEGACY) || yb_communication_type.GetInt () != 2)
return;
for (int i = 0; i < GetMaxClients (); i++)
@ -979,7 +982,7 @@ void Bot::InstantChatterMessage (int type)
{
// this function sends instant chatter messages.
if (yb_communication_type.GetInt () != 2 || g_chatterFactory[type].IsEmpty () || g_gameVersion == CSV_OLD || !g_sendAudioFinished)
if (yb_communication_type.GetInt () != 2 || g_chatterFactory[type].IsEmpty () || (g_gameVersion & CSVERSION_LEGACY) || !g_sendAudioFinished)
return;
if (m_notKilled)
@ -1030,7 +1033,7 @@ void Bot::RadioMessage (int message)
if (yb_communication_type.GetInt () == 0 || m_numFriendsLeft == 0)
return;
if (g_chatterFactory[message].IsEmpty () || g_gameVersion == CSV_OLD || yb_communication_type.GetInt () != 2)
if (g_chatterFactory[message].IsEmpty () || (g_gameVersion & CSVERSION_LEGACY) || yb_communication_type.GetInt () != 2)
g_radioInsteadVoice = true; // use radio instead voice
m_radioSelect = message;
@ -1041,7 +1044,7 @@ void Bot::ChatterMessage (int message)
{
// this function inserts the voice message into the message queue (mostly same as above)
if (g_gameVersion == CSV_OLD || yb_communication_type.GetInt () != 2 || g_chatterFactory[message].IsEmpty () || m_numFriendsLeft == 0)
if ((g_gameVersion & CSVERSION_LEGACY) || yb_communication_type.GetInt () != 2 || g_chatterFactory[message].IsEmpty () || m_numFriendsLeft == 0)
return;
bool shouldExecute = false;
@ -1242,7 +1245,7 @@ void Bot::CheckMessageQueue (void)
}
}
if ((m_radioSelect != Radio_ReportingIn && g_radioInsteadVoice) || yb_communication_type.GetInt () != 2 || g_chatterFactory[m_radioSelect].IsEmpty () || g_gameVersion == CSV_OLD)
if ((m_radioSelect != Radio_ReportingIn && g_radioInsteadVoice) || yb_communication_type.GetInt () != 2 || g_chatterFactory[m_radioSelect].IsEmpty () || (g_gameVersion & CSVERSION_LEGACY))
{
if (m_radioSelect < Radio_GoGoGo)
FakeClientCommand (GetEntity (), "radio1");
@ -1407,6 +1410,10 @@ void Bot::PurchaseWeapons (void)
bool isPistolMode = g_weaponSelect[25].teamStandard == -1 && g_weaponSelect[3].teamStandard == 2;
bool teamEcoValid = bots.EconomicsValid (m_team);
// do this, because xash engine is not capable to run all the features goldsrc, but we have cs 1.6 on it, so buy table must be the same
bool isOldGame = (g_gameVersion & CSVERSION_LEGACY) && !(g_gameVersion & CSVERSION_XASH);
switch (m_buyState)
{
case 0: // if no primary weapon and bot has some money, buy a primary weapon
@ -1432,7 +1439,7 @@ void Bot::PurchaseWeapons (void)
continue;
// ignore weapon if this weapon not supported by currently running cs version...
if (g_gameVersion == CSV_OLD && selectedWeapon->buySelect == -1)
if (isOldGame && selectedWeapon->buySelect == -1)
continue;
// ignore weapon if this weapon is not targeted to out team....
@ -1545,7 +1552,7 @@ void Bot::PurchaseWeapons (void)
{
FakeClientCommand (GetEntity (), "buy;menuselect %d", selectedWeapon->buyGroup);
if (g_gameVersion == CSV_OLD)
if (isOldGame)
FakeClientCommand(GetEntity (), "menuselect %d", selectedWeapon->buySelect);
else // SteamCS buy menu is different from the old one
{
@ -1602,7 +1609,7 @@ void Bot::PurchaseWeapons (void)
if ((g_mapType & MAP_AS) && selectedWeapon->teamAS != 2 && selectedWeapon->teamAS != m_team)
continue;
if (g_gameVersion == CSV_OLD && selectedWeapon->buySelect == -1)
if (isOldGame && selectedWeapon->buySelect == -1)
continue;
if (selectedWeapon->teamStandard != 2 && selectedWeapon->teamStandard != m_team)
@ -1633,7 +1640,7 @@ void Bot::PurchaseWeapons (void)
{
FakeClientCommand (GetEntity (), "buy;menuselect %d", selectedWeapon->buyGroup);
if (g_gameVersion == CSV_OLD)
if (isOldGame)
FakeClientCommand (GetEntity (), "menuselect %d", selectedWeapon->buySelect);
else // steam cs buy menu is different from old one
@ -1673,7 +1680,7 @@ void Bot::PurchaseWeapons (void)
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 == CT && Random.Long (1, 100) < 80 && m_moneyAmount > 200 && !IsRestricted (WEAPON_DEFUSER))
{
if (g_gameVersion == CSV_OLD)
if (isOldGame)
FakeClientCommand (GetEntity (), "buyequip;menuselect 6");
else
FakeClientCommand (GetEntity (), "defuser"); // use alias in SteamCS
@ -2350,10 +2357,10 @@ void Bot::CheckRadioCommands (void)
}
}
}
else if (m_radioOrder != Chatter_GoingToPlantBomb && Random.Long (0, 100) < 65)
else if (m_radioOrder != Chatter_GoingToPlantBomb && Random.Long (0, 100) < 50)
RadioMessage (Radio_Negative);
}
else if (m_radioOrder != Chatter_GoingToPlantBomb && Random.Long (0, 100) < 65)
else if (m_radioOrder != Chatter_GoingToPlantBomb && Random.Long (0, 100) < 50)
RadioMessage (Radio_Negative);
}
break;
@ -2423,7 +2430,7 @@ void Bot::CheckRadioCommands (void)
TryHeadTowardRadioEntity ();
}
else if (Random.Long (0, 100) < 80 && m_radioOrder == Radio_NeedBackup)
else if (Random.Long (0, 100) < 60 && m_radioOrder == Radio_NeedBackup)
RadioMessage (Radio_Negative);
break;
@ -2441,7 +2448,7 @@ void Bot::CheckRadioCommands (void)
if (m_fearLevel < 0.0f)
m_fearLevel = 0.0f;
}
else if ((IsEntityNull (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 2048)
else if ((IsEntityNull (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 2048.0f)
{
TaskID taskID = GetTaskId ();
@ -2493,7 +2500,7 @@ void Bot::CheckRadioCommands (void)
case Radio_RegroupTeam:
// if no more enemies found AND bomb planted, switch to knife to get to bombplace faster
if ((m_team == CT) && m_currentWeapon != WEAPON_KNIFE && m_numEnemiesLeft == 0 && g_bombPlanted && GetTaskId () != TASK_DEFUSEBOMB)
if (m_team == CT && m_currentWeapon != WEAPON_KNIFE && m_numEnemiesLeft == 0 && g_bombPlanted && GetTaskId () != TASK_DEFUSEBOMB)
{
SelectWeaponByName ("weapon_knife");
@ -4074,7 +4081,7 @@ void Bot::RunTask_Throw_HE (void)
IgnoreCollisionShortly ();
if ((pev->origin - dest).GetLengthSquared () < GET_SQUARE (400.0f))
if (m_maxThrowTimer > GetWorldTime () || (pev->origin - dest).GetLengthSquared () < GET_SQUARE (400.0f))
{
// heck, I don't wanna blow up myself
m_grenadeCheckTime = GetWorldTime () + MAX_GRENADE_TIMER;
@ -4155,7 +4162,7 @@ void Bot::RunTask_Throw_FL (void)
if (m_grenade.GetLengthSquared () < 100.0f)
m_grenade = CheckToss (pev->origin, dest);
if (m_grenade.GetLengthSquared () <= 100.0f)
if (m_maxThrowTimer > GetWorldTime () || m_grenade.GetLengthSquared () <= 100.0f)
{
m_grenadeCheckTime = GetWorldTime () + MAX_GRENADE_TIMER;
m_grenade = m_lookAt;
@ -4219,7 +4226,7 @@ void Bot::RunTask_Throw_SG (void)
m_grenade = (src - EyePosition ()).Normalize ();
if (GetTask ()->time < GetWorldTime () + 0.5f)
if (m_maxThrowTimer > GetWorldTime () || GetTask ()->time < GetWorldTime () + 0.5f)
{
m_aimFlags &= ~AIM_GRENADE;
m_states &= ~STATE_THROW_SG;
@ -5861,13 +5868,13 @@ bool Bot::OutOfBombTimer (void)
float timeLeft = GetBombTimeleft ();
// if time left greater than 13, no need to do other checks
if (timeLeft > 16.0f)
if (timeLeft > 13.0f)
return false;
const Vector &bombOrigin = waypoints.GetBombPosition ();
// for terrorist, if timer is lower than eleven seconds, return true
if (static_cast <int> (timeLeft) < 16 && m_team == TERRORIST && (bombOrigin - pev->origin).GetLength () < 1000.0f)
// for terrorist, if timer is lower than 13 seconds, return true
if (static_cast <int> (timeLeft) < 13 && m_team == TERRORIST && (bombOrigin - pev->origin).GetLength () < 1000.0f)
return true;
bool hasTeammatesWithDefuserKit = false;

View file

@ -290,14 +290,14 @@ void Bot::PrepareChatMessage (char *text)
}
else if (*pattern == 'd')
{
if (g_gameVersion == CSV_CZERO)
if (g_gameVersion == CSVERSION_CZERO)
{
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)
else if (g_gameVersion == CSVERSION_CSTRIKE16 || g_gameVersion == CSVERSION_LEGACY)
{
if (Random.Long (1, 100) < 30)
strcat (m_tempStrings, "CS");

View file

@ -704,12 +704,6 @@ bool Bot::DoFirePause (float distance)
{
// returns true if bot needs to pause between firing to compensate for punchangle & weapon spread
if (UsesSniper ())
{
m_shootTime = GetWorldTime ();
return false;
}
if (m_firePause > GetWorldTime ())
return true;
@ -875,7 +869,7 @@ WeaponSelectEnd:
m_shieldCheckTime = GetWorldTime () + 1.0f;
}
if (UsesSniper () && m_zoomCheckTime < GetWorldTime ()) // is the bot holding a sniper rifle?
if (UsesSniper () && m_zoomCheckTime + 1.0f < GetWorldTime ()) // 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;
@ -888,14 +882,14 @@ WeaponSelectEnd:
m_zoomCheckTime = GetWorldTime ();
if (!IsEntityNull (m_enemy) && (pev->velocity.x != 0.0f || pev->velocity.y != 0.0f || pev->velocity.z != 0.0f) && (pev->basevelocity.x != 0.0f || pev->basevelocity.y != 0.0f || pev->basevelocity.z != 0.0f))
if (!IsEntityNull (m_enemy) && (m_states & STATE_SEEING_ENEMY))
{
m_moveSpeed = 0.0f;
m_strafeSpeed = 0.0f;
m_navTimeset = GetWorldTime ();
}
}
else if (m_difficulty < 4 && UsesZoomableRifle () && m_zoomCheckTime < GetWorldTime ()) // else is the bot holding a zoomable rifle?
else if (m_difficulty < 4 && UsesZoomableRifle ()) // else is the bot holding a zoomable rifle?
{
if (distance > 800.0f && pev->fov >= 90.0f) // should the bot switch to zoomed mode?
pev->button |= IN_ATTACK2;

View file

@ -40,7 +40,7 @@ int g_lastRadio[2];
int g_storeAddbotVars[4];
int g_radioSelect[32];
int g_fakeArgc = 0;
int g_gameVersion = CSV_STEAM;
int g_gameVersion = 0;
int g_numWaypoints = 0;
int g_mapType = 0;

View file

@ -716,7 +716,7 @@ void InitConfig (void)
}
// CHATTER SYSTEM INITIALIZATION
if (OpenConfig ("chatter.cfg", "Couldn't open chatter system configuration", &fp) && g_gameVersion != CSV_OLD && yb_communication_type.GetInt () == 2)
if (OpenConfig ("chatter.cfg", "Couldn't open chatter system configuration", &fp) && !(g_gameVersion & CSVERSION_LEGACY) && yb_communication_type.GetInt () == 2)
{
Array <String> array;
@ -831,7 +831,7 @@ void InitConfig (void)
}
// LOCALIZER INITITALIZATION
if (OpenConfig ("lang.cfg", "Specified language not found", &fp, true) && g_gameVersion != CSV_OLD)
if (OpenConfig ("lang.cfg", "Specified language not found", &fp, true) && !(g_gameVersion & CSVERSION_LEGACY))
{
if (IsDedicatedServer ())
return; // dedicated server will use only english translation
@ -881,7 +881,7 @@ void InitConfig (void)
}
fp.Close ();
}
else if (g_gameVersion == CSV_OLD)
else if (g_gameVersion & CSVERSION_LEGACY)
AddLogEntry (true, LL_DEFAULT, "Multilingual system disabled, due to your Counter-Strike Version!");
else if (strcmp (yb_language.GetString (), "en") != 0)
AddLogEntry (true, LL_ERROR, "Couldn't load language configuration");
@ -918,6 +918,30 @@ void GameDLLInit (void)
// to register by the engine side the server commands we need to administrate our bots.
DetectCSVersion ();
{
// print game detection info
String gameVersionStr;
if (g_gameVersion & CSVERSION_LEGACY)
gameVersionStr.Assign ("Legacy");
else if (g_gameVersion & CSVERSION_CZERO)
gameVersionStr.Assign ("Condition Zero");
else if (g_gameVersion & CSVERSION_CSTRIKE16)
gameVersionStr.Assign ("v1.6");
if (g_gameVersion & CSVERSION_XASH)
{
gameVersionStr.Append (" @ Xash3D Engine");
if (g_gameVersion & CSVERSION_MOBILITY)
gameVersionStr.Append (" Mobile");
gameVersionStr.Replace ("Legacy", "1.6 Limited");
}
ServerPrint ("YaPB Bot has detect game version as Counter-Strike: %s", gameVersionStr.GetBuffer ());
}
// register server command(s)
RegisterCommand ("yapb", CommandHandler);
@ -998,7 +1022,7 @@ int Spawn (edict_t *ent)
}
else if (strcmp (entityClassname, "player_weaponstrip") == 0)
{
if (g_gameVersion == CSV_OLD && (STRING (ent->v.target))[0] == '0')
if ((g_gameVersion & CSVERSION_LEGACY) && (STRING (ent->v.target))[0] == '0')
ent->v.target = ent->v.targetname = ALLOC_STRING ("fake");
else
{
@ -2401,12 +2425,12 @@ void pfnMessageBegin (int msgDest, int msgType, const float *origin, edict_t *ed
netmsg.SetId (NETMSG_SAYTEXT, GET_USER_MSG_ID (PLID, "SayText", NULL));
netmsg.SetId (NETMSG_RESETHUD, GET_USER_MSG_ID (PLID, "ResetHUD", NULL));
if (g_gameVersion != CSV_OLD)
if (!(g_gameVersion & CSVERSION_LEGACY))
netmsg.SetId (NETMSG_BOTVOICE, GET_USER_MSG_ID (PLID, "BotVoice", NULL));
}
netmsg.Reset ();
if (msgDest == MSG_SPEC && msgType == netmsg.GetId (NETMSG_HLTV) && g_gameVersion != CSV_OLD)
if (msgDest == MSG_SPEC && msgType == netmsg.GetId (NETMSG_HLTV) && !(g_gameVersion & CSVERSION_LEGACY))
netmsg.SetMessage (NETMSG_HLTV);
netmsg.HandleMessageIfRequired (msgType, NETMSG_WEAPONLIST);
@ -3036,7 +3060,7 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t
convars.PushRegisteredConVarsToEngine ();
#ifdef PLATFORM_ANDROID
g_gameVersion = CSV_OLD; // temporary, until opensource client dll get BotVoice message
g_gameVersion |= (CSVERSION_LEGACY | CSVERSION_XASH | CSVERSION_MOBILITY);
if (g_isMetamod)
return; // we should stop the attempt for loading the real gamedll, since metamod handle this for us
@ -3065,13 +3089,13 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t
int modType;
} s_supportedMods[] =
{
{ "cstrike", "cs_i386.so", "cs.dylib", "mp.dll", "Counter-Strike v1.6", CSV_STEAM },
{ "cstrike", "cs.so", "cs.dylib", "mp.dll", "Counter-Strike v1.6 (Newer)", CSV_STEAM },
{ "czero", "cs_i386.so", "cs.dylib", "mp.dll", "Counter-Strike: Condition Zero", CSV_CZERO },
{ "czero", "cs.so", "cs.dylib", "mp.dll", "Counter-Strike: Condition Zero (Newer)", CSV_CZERO },
{ "csv15", "cs_i386.so", "cs.dylib", "mp.dll", "CS 1.5 for Steam", CSV_OLD },
{ "csdm", "cs_i386.so", "cs.dylib", "mp.dll", "CSDM for Windows", CSV_OLD },
{ "cs13", "cs_i386.so", "cs.dylib", "mp.dll", "Counter-Strike v1.3", CSV_OLD }, // assume cs13 = cs15
{ "cstrike", "cs_i386.so", "cs.dylib", "mp.dll", "Counter-Strike v1.6", CSVERSION_CSTRIKE16 },
{ "cstrike", "cs.so", "cs.dylib", "mp.dll", "Counter-Strike v1.6 (Newer)", CSVERSION_CSTRIKE16 },
{ "czero", "cs_i386.so", "cs.dylib", "mp.dll", "Counter-Strike: Condition Zero", CSVERSION_CZERO },
{ "czero", "cs.so", "cs.dylib", "mp.dll", "Counter-Strike: Condition Zero (Newer)", CSVERSION_CZERO },
{ "csv15", "cs_i386.so", "cs.dylib", "mp.dll", "CS 1.5 for Steam", CSVERSION_LEGACY },
{ "csdm", "cs_i386.so", "cs.dylib", "mp.dll", "CSDM for Windows", CSVERSION_LEGACY },
{ "cs13", "cs_i386.so", "cs.dylib", "mp.dll", "Counter-Strike v1.3", CSVERSION_LEGACY }, // assume cs13 = cs15
};
ModSupport *knownMod = NULL;
@ -3097,7 +3121,7 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t
if (knownMod != NULL)
{
g_gameVersion = knownMod->modType;
g_gameVersion |= knownMod->modType;
if (g_isMetamod)
return; // we should stop the attempt for loading the real gamedll, since metamod handle this for us
@ -3208,7 +3232,7 @@ void ConVarWrapper::PushRegisteredConVarsToEngine (bool gameVars)
static void LinkEntity_Helper (EntityPtr_t &entAddress, const char *name, entvars_t *pev)
{
// here we're see an ugliest hack :)
if (entAddress == NULL || g_gameVersion == CSV_CZERO)
if (entAddress == NULL || (g_gameVersion & CSVERSION_CZERO))
entAddress = g_gameLib->GetFuncAddr <EntityPtr_t > (name);
if (entAddress == NULL)

View file

@ -422,7 +422,7 @@ void BotManager::MaintainBotQuota (void)
m_creationTab.RemoveAll (); // maximum players reached, so set quota to maximum players
yb_quota.SetInt (GetBotsNum ());
}
m_maintainTime = GetWorldTime () + 0.15f;
m_maintainTime = GetWorldTime () + 0.45f;
}
// now keep bot number up to date
@ -460,7 +460,7 @@ void BotManager::MaintainBotQuota (void)
else if (desiredCount < numBots)
RemoveRandom ();
m_quotaMaintainTime = GetWorldTime () + 0.5f;
m_quotaMaintainTime = GetWorldTime () + 0.90f;
}
}
@ -874,7 +874,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c
char *buffer = GET_INFOKEYBUFFER (bot);
SET_CLIENT_KEYVALUE (clientIndex, buffer, "_vgui_menus", "0");
if (g_gameVersion != CSV_OLD && yb_latency_display.GetInt () == 1)
if (!(g_gameVersion & CSVERSION_LEGACY) && yb_latency_display.GetInt () == 1)
SET_CLIENT_KEYVALUE (clientIndex, buffer, "*bot", "1");
rejectReason[0] = 0; // reset the reject reason template string
@ -1101,6 +1101,7 @@ void Bot::NewRound (void)
m_canChooseAimDirection = true;
m_turnAwayFromFlashbang = 0.0f;
m_maxThrowTimer = 0.0f;
m_timeTeamOrder = 0.0f;
m_askCheckTime = 0.0f;
m_minSpeed = 260.0f;
@ -1249,7 +1250,18 @@ void Bot::NewRound (void)
if (Random.Long (0, 100) < 50)
ChatterMessage (Chatter_NewRound);
m_thinkInterval = g_gameVersion == CSV_OLD ? 0.0f : (1.0f / 30.0f) * Random.Float (0.95f, 1.05f);
const float interval = (1.0f / 30.0f) * Random.Float (0.95f, 1.05f);
if (g_gameVersion & CSVERSION_LEGACY)
{
m_thinkInterval = 0.0f;
// android xash engine allows frameskip
if ((g_gameVersion & CSVERSION_XASH) && (g_gameVersion & CSVERSION_MOBILITY))
m_thinkInterval = interval;
}
else
m_thinkInterval = interval;
}
void Bot::Kill (void)
@ -1314,7 +1326,7 @@ void Bot::StartGame (void)
{
m_startAction = GSM_IDLE; // switch back to idle
if (g_gameVersion == CSV_CZERO) // czero has spetsnaz and militia skins
if (g_gameVersion & CSVERSION_CZERO) // czero has spetsnaz and militia skins
{
if (m_wantedClass < 1 || m_wantedClass > 5)
m_wantedClass = Random.Long (1, 5); // use random if invalid
@ -1339,7 +1351,7 @@ void Bot::StartGame (void)
void BotManager::CalculatePingOffsets (void)
{
if (g_gameVersion == CSV_OLD || yb_latency_display.GetInt () != 2)
if ((g_gameVersion & CSVERSION_LEGACY) || yb_latency_display.GetInt () != 2)
return;
int averagePing = 0;
@ -1399,10 +1411,7 @@ void BotManager::CalculatePingOffsets (void)
void BotManager::SendPingDataOffsets (edict_t *to)
{
if (g_gameVersion == CSV_OLD || yb_latency_display.GetInt () != 2)
return;
if (IsEntityNull (to))
if ((g_gameVersion & CSVERSION_LEGACY) || yb_latency_display.GetInt () != 2 || IsEntityNull (to))
return;
if (!(to->v.flags & FL_CLIENT) && !(((to->v.button & IN_SCORE) || !(to->v.oldbuttons & IN_SCORE))))

View file

@ -1219,20 +1219,32 @@ bool Bot::DoWaypointNav (void)
else if (m_navNode == NULL)
return false;
if ((g_mapType & MAP_DE) && g_bombPlanted && m_team == CT && GetTaskId () != TASK_ESCAPEFROMBOMB && GetTask ()->data != -1)
int taskTarget = GetTask ()->data;
if ((g_mapType & MAP_DE) && g_bombPlanted && m_team == CT && GetTaskId () != TASK_ESCAPEFROMBOMB && taskTarget != -1)
{
const Vector &bombOrigin = CheckBombAudible ();
// bot within 'hearable' bomb tick noises?
if (!bombOrigin.IsZero ())
{
float distance = (bombOrigin - waypoints.GetPath (GetTask ()->data)->origin).GetLength ();
float distance = (bombOrigin - waypoints.GetPath (taskTarget)->origin).GetLength ();
if (distance > 512.0)
waypoints.SetGoalVisited (GetTask ()->data); // doesn't hear so not a good goal
{
if (Random.Long (0, 100) < 50 && !waypoints.IsGoalVisited (taskTarget))
RadioMessage (Radio_SectorClear);
waypoints.SetGoalVisited (taskTarget); // doesn't hear so not a good goal
}
}
else
waypoints.SetGoalVisited (GetTask ()->data); // doesn't hear so not a good goal
{
if (Random.Long (0, 100) < 50 && !waypoints.IsGoalVisited (taskTarget))
RadioMessage (Radio_SectorClear);
waypoints.SetGoalVisited (taskTarget); // doesn't hear so not a good goal
}
}
HeadTowardWaypoint (); // do the actual movement checking
}

View file

@ -9,7 +9,7 @@
#include <core.h>
ConVar yb_listenserver_welcome ("yb_listenserver_welcome", "1");
ConVar yb_display_menu_text ("yb_display_menu_text", "1");
ConVar mp_roundtime ("mp_roundtime", NULL, VT_NOREGISTER);
@ -174,6 +174,9 @@ void DisplayMenuToClient (edict_t *ent, MenuText *menu)
for (int i = 0; i <= 9; i++)
tempText.Replace (FormatBuffer ("%d.", i), FormatBuffer ("\\r%d.\\w", i));
if ((g_gameVersion & CSVERSION_XASH | CSVERSION_MOBILITY) && !yb_display_menu_text.GetBool ())
text = " ";
else
text = (char *) tempText.GetBuffer ();
while (strlen (text) >= 64)
@ -981,15 +984,16 @@ void CheckWelcomeMessage (void)
{
// the purpose of this function, is to send quick welcome message, to the listenserver entity.
static bool alreadyReceived = !yb_listenserver_welcome.GetBool ();
static bool alreadyReceived = false;
static float receiveTime = 0.0f;
if (alreadyReceived)
return;
#ifndef PLATFORM_ANDROID
Array <String> sentences;
if (!(g_gameVersion & (CSVERSION_MOBILITY | CSVERSION_XASH)))
{
// add default messages
sentences.Push ("hello user,communication is acquired");
sentences.Push ("your presence is acknowledged");
@ -1007,16 +1011,16 @@ void CheckWelcomeMessage (void)
sentences.Push ("high amigo, your administration has been great last day");
sentences.Push ("attention, expect experimental armed hostile presence");
sentences.Push ("warning, medical attention required");
#endif
}
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
if (receiveTime > 0.0f && receiveTime < GetWorldTime () && !alreadyReceived && (g_numWaypoints > 0 ? g_isCommencing : true))
{
#ifndef PLATFORM_ANDROID
if (!(g_gameVersion & (CSVERSION_MOBILITY | CSVERSION_XASH)))
ServerCommand ("speak \"%s\"", const_cast <char *> (sentences.GetRandomElement ().GetBuffer ()));
#endif
ChartPrint ("----- %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);
@ -1047,15 +1051,13 @@ void CheckWelcomeMessage (void)
void DetectCSVersion (void)
{
if (g_gameVersion == CSV_OLD || g_gameVersion == CSV_CZERO)
if (g_gameVersion & CSVERSION_CZERO)
return;
// detect xash engine
if (g_engfuncs.pfnCVarGetPointer ("build") != NULL)
{
AddLogEntry (true, LL_DEFAULT, "Detected Xash3D Engine. Setting game version to old.");
g_gameVersion = CSV_OLD;
g_gameVersion |= (CSVERSION_LEGACY | CSVERSION_XASH);
return;
}
@ -1063,9 +1065,9 @@ void DetectCSVersion (void)
byte *detection = (*g_engfuncs.pfnLoadFileForMe) ("events/galil.sc", NULL);
if (detection != NULL)
g_gameVersion = CSV_STEAM; // just to be sure
g_gameVersion |= CSVERSION_CSTRIKE16; // just to be sure
else if (detection == NULL)
g_gameVersion = CSV_OLD; // reset it to WON
g_gameVersion |= CSVERSION_LEGACY; // reset it to WON
// if we have loaded the file free it
if (detection != NULL)