improved sniping

fixed bots never choice camping tactic, due to agression level oveflow
cosmetic changes
This commit is contained in:
jeefo 2016-01-30 13:15:50 +03:00
commit 9e5c1540f9
13 changed files with 336 additions and 310 deletions

View file

@ -18,155 +18,7 @@
using namespace Math;
// detects the build platform
#if defined (__linux__) || defined (__debian__) || defined (__linux)
#define PLATFORM_LINUX 1
#elif defined (__APPLE__)
#define PLATFORM_OSX 1
#elif defined (_WIN32)
#define PLATFORM_WIN32 1
#endif
// detects the compiler
#if defined (_MSC_VER)
#define COMPILER_VISUALC _MSC_VER
#elif defined (__MINGW32__)
#define COMPILER_MINGW32 __MINGW32__
#endif
// configure export macros
#if defined (COMPILER_VISUALC) || defined (COMPILER_MINGW32)
#define export extern "C" __declspec (dllexport)
#elif defined (PLATFORM_LINUX) || defined (PLATFORM_OSX)
#define export extern "C" __attribute__((visibility("default")))
#else
#error "Can't configure export macros. Compiler unrecognized."
#endif
// operating system specific macros, functions and typedefs
#ifdef PLATFORM_WIN32
#include <direct.h>
#define DLL_ENTRYPOINT int STDCALL DllMain (HINSTANCE, DWORD dwReason, LPVOID)
#define DLL_DETACHING (dwReason == DLL_PROCESS_DETACH)
#define DLL_RETENTRY return TRUE
#if defined (COMPILER_VISUALC)
#define DLL_GIVEFNPTRSTODLL extern "C" void STDCALL
#elif defined (COMPILER_MINGW32)
#define DLL_GIVEFNPTRSTODLL export void STDCALL
#endif
// specify export parameter
#if defined (COMPILER_VISUALC) && (COMPILER_VISUALC > 1000)
#pragma comment (linker, "/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1")
#pragma comment (linker, "/SECTION:.data,RW")
#endif
typedef int (FAR *EntityAPI_t) (gamefuncs_t *, int);
typedef int (FAR *NewEntityAPI_t) (newgamefuncs_t *, int *);
typedef int (FAR *BlendAPI_t) (int, void **, void *, float (*)[3][4], float (*)[128][3][4]);
typedef void (STDCALL *FuncPointers_t) (enginefuncs_t *, globalvars_t *);
typedef void (FAR *EntityPtr_t) (entvars_t *);
#elif defined (PLATFORM_LINUX) || defined (PLATFORM_OSX)
#include <unistd.h>
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#define DLL_ENTRYPOINT __attribute__((destructor)) void _fini (void)
#define DLL_DETACHING TRUE
#define DLL_RETENTRY return
#define DLL_GIVEFNPTRSTODLL extern "C" void __attribute__((visibility("default")))
#if defined (__ANDROID__)
#define PLATFORM_ANDROID 1
#endif
typedef int (*EntityAPI_t) (gamefuncs_t *, int);
typedef int (*NewEntityAPI_t) (newgamefuncs_t *, int *);
typedef int (*BlendAPI_t) (int, void **, void *, float (*)[3][4], float (*)[128][3][4]);
typedef void (*FuncPointers_t) (enginefuncs_t *, globalvars_t *);
typedef void (*EntityPtr_t) (entvars_t *);
#else
#error "Platform unrecognized."
#endif
// library wrapper
class Library
{
private:
void *m_ptr;
public:
Library (const char *fileName)
{
m_ptr = NULL;
if (fileName == NULL)
return;
LoadLib (fileName);
}
~Library (void)
{
if (!IsLoaded ())
return;
#ifdef PLATFORM_WIN32
FreeLibrary ((HMODULE) m_ptr);
#else
dlclose (m_ptr);
#endif
}
public:
inline void *LoadLib (const char *fileName)
{
#ifdef PLATFORM_WIN32
m_ptr = LoadLibrary (fileName);
#else
m_ptr = dlopen (fileName, RTLD_NOW);
#endif
return m_ptr;
}
template <typename R> R GetFuncAddr (const char *function)
{
if (!IsLoaded ())
return NULL;
#ifdef PLATFORM_WIN32
return reinterpret_cast <R> (GetProcAddress (static_cast <HMODULE> (m_ptr), function));
#else
return reinterpret_cast <R> (dlsym (m_ptr, function));
#endif
}
template <typename R> R GetHandle (void)
{
return (R) m_ptr;
}
inline bool IsLoaded (void) const
{
return m_ptr != NULL;
}
};
#include "platform.h"
#include <assert.h>
#include <ctype.h>
@ -258,9 +110,9 @@ enum CollisionState
// counter-strike team id's
enum Team
{
TEAM_TF = 0,
TEAM_CF,
TEAM_SPEC
TERRORIST = 0,
CT,
SPECTATOR
};
// client flags
@ -1362,6 +1214,7 @@ private:
float m_maintainTime; // time to maintain bot creation
float m_quotaMaintainTime; // time to maintain bot quota
int m_lastWinner; // the team who won previous round
int m_balanceCount; // limit of bots to add
bool m_economicsGood[2]; // is team able to buy anything
bool m_deathMsgSent; // for fakeping

View file

@ -127,6 +127,6 @@ static inline int GetTeam (edict_t *ent)
#ifndef XASH_CSDM
return g_clients[IndexOfEntity (ent) - 1].team;
#else
return g_clients[IndexOfEntity (ent) - 1].team = ent->v.team == 1 ? TEAM_TF : TEAM_CF;
return g_clients[IndexOfEntity (ent) - 1].team = ent->v.team == 1 ? TERRORIST : CT;
#endif
}

160
include/platform.h Normal file
View file

@ -0,0 +1,160 @@
//
// Yet Another POD-Bot, based on PODBot by Markus Klinge ("CountFloyd").
// Copyright (c) YaPB Development Team.
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// http://yapb.jeefo.net/license
//
#pragma once
// detects the build platform
#if defined (__linux__) || defined (__debian__) || defined (__linux)
#define PLATFORM_LINUX 1
#elif defined (__APPLE__)
#define PLATFORM_OSX 1
#elif defined (_WIN32)
#define PLATFORM_WIN32 1
#endif
// detects the compiler
#if defined (_MSC_VER)
#define COMPILER_VISUALC _MSC_VER
#elif defined (__MINGW32__)
#define COMPILER_MINGW32 __MINGW32__
#endif
// configure export macros
#if defined (COMPILER_VISUALC) || defined (COMPILER_MINGW32)
#define export extern "C" __declspec (dllexport)
#elif defined (PLATFORM_LINUX) || defined (PLATFORM_OSX)
#define export extern "C" __attribute__((visibility("default")))
#else
#error "Can't configure export macros. Compiler unrecognized."
#endif
// operating system specific macros, functions and typedefs
#ifdef PLATFORM_WIN32
#include <direct.h>
#define DLL_ENTRYPOINT int STDCALL DllMain (HINSTANCE, DWORD dwReason, LPVOID)
#define DLL_DETACHING (dwReason == DLL_PROCESS_DETACH)
#define DLL_RETENTRY return TRUE
#if defined (COMPILER_VISUALC)
#define DLL_GIVEFNPTRSTODLL extern "C" void STDCALL
#elif defined (COMPILER_MINGW32)
#define DLL_GIVEFNPTRSTODLL export void STDCALL
#endif
// specify export parameter
#if defined (COMPILER_VISUALC) && (COMPILER_VISUALC > 1000)
#pragma comment (linker, "/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1")
#pragma comment (linker, "/SECTION:.data,RW")
#endif
typedef int (FAR *EntityAPI_t) (gamefuncs_t *, int);
typedef int (FAR *NewEntityAPI_t) (newgamefuncs_t *, int *);
typedef int (FAR *BlendAPI_t) (int, void **, void *, float (*)[3][4], float (*)[128][3][4]);
typedef void (STDCALL *FuncPointers_t) (enginefuncs_t *, globalvars_t *);
typedef void (FAR *EntityPtr_t) (entvars_t *);
#elif defined (PLATFORM_LINUX) || defined (PLATFORM_OSX)
#include <unistd.h>
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#define DLL_ENTRYPOINT __attribute__((destructor)) void _fini (void)
#define DLL_DETACHING TRUE
#define DLL_RETENTRY return
#define DLL_GIVEFNPTRSTODLL extern "C" void __attribute__((visibility("default")))
#if defined (__ANDROID__)
#define PLATFORM_ANDROID 1
#endif
typedef int (*EntityAPI_t) (gamefuncs_t *, int);
typedef int (*NewEntityAPI_t) (newgamefuncs_t *, int *);
typedef int (*BlendAPI_t) (int, void **, void *, float (*)[3][4], float (*)[128][3][4]);
typedef void (*FuncPointers_t) (enginefuncs_t *, globalvars_t *);
typedef void (*EntityPtr_t) (entvars_t *);
#else
#error "Platform unrecognized."
#endif
// library wrapper
class Library
{
private:
void *m_ptr;
public:
Library (const char *fileName)
{
m_ptr = NULL;
if (fileName == NULL)
return;
LoadLib (fileName);
}
~Library (void)
{
if (!IsLoaded ())
return;
#ifdef PLATFORM_WIN32
FreeLibrary ((HMODULE) m_ptr);
#else
dlclose (m_ptr);
#endif
}
public:
inline void *LoadLib (const char *fileName)
{
#ifdef PLATFORM_WIN32
m_ptr = LoadLibrary (fileName);
#else
m_ptr = dlopen (fileName, RTLD_NOW);
#endif
return m_ptr;
}
template <typename R> R GetFuncAddr (const char *function)
{
if (!IsLoaded ())
return NULL;
#ifdef PLATFORM_WIN32
return reinterpret_cast <R> (GetProcAddress (static_cast <HMODULE> (m_ptr), function));
#else
return reinterpret_cast <R> (dlsym (m_ptr, function));
#endif
}
template <typename R> R GetHandle (void)
{
return (R) m_ptr;
}
inline bool IsLoaded (void) const
{
return m_ptr != NULL;
}
};

View file

@ -27,6 +27,7 @@
<ClInclude Include="..\include\engine\sdk_util.h" />
<ClInclude Include="..\include\engine\util.h" />
<ClInclude Include="..\include\globals.h" />
<ClInclude Include="..\include\platform.h" />
<ClInclude Include="..\include\resource.h" />
</ItemGroup>
<ItemGroup>

View file

@ -66,6 +66,9 @@
<ClInclude Include="..\include\engine\archtypes.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\platform.h">
<Filter>include</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\source\chatlib.cpp">

View file

@ -641,7 +641,7 @@ void Bot::FindItem (void)
allowPickup = true;
pickupType = PICKUP_SHIELD;
}
else if (strncmp ("item_thighpack", STRING (ent->v.classname), 14) == 0 && m_team == TEAM_CF && !m_hasDefuser)
else if (strncmp ("item_thighpack", STRING (ent->v.classname), 14) == 0 && m_team == CT && !m_hasDefuser)
{
allowPickup = true;
pickupType = PICKUP_DEFUSEKIT;
@ -698,7 +698,7 @@ void Bot::FindItem (void)
if ((pev->weapons & (1 << WEAPON_ELITE)) || HasShield () || m_isVIP || (HasPrimaryWeapon () && !RateGroundWeapon (ent)))
allowPickup = false;
}
else if (m_team == TEAM_TF) // terrorist team specific
else if (m_team == TERRORIST) // terrorist team specific
{
if (pickupType == PICKUP_DROPPED_C4)
{
@ -765,7 +765,7 @@ void Bot::FindItem (void)
}
}
}
else if (m_team == TEAM_CF)
else if (m_team == CT)
{
if (pickupType == PICKUP_HOSTAGE)
{
@ -1119,7 +1119,7 @@ void Bot::CheckMessageQueue (void)
}
// prevent terrorists from buying on es maps
if ((g_mapType & MAP_ES) && m_team == TEAM_TF)
if ((g_mapType & MAP_ES) && m_team == TERRORIST)
m_buyState = 6;
// prevent teams from buying on fun maps
@ -1185,7 +1185,7 @@ void Bot::CheckMessageQueue (void)
if (path->flags & FLAG_GOAL)
{
if ((g_mapType & MAP_DE) && m_team == TEAM_TF && m_hasC4)
if ((g_mapType & MAP_DE) && m_team == TERRORIST && m_hasC4)
InstantChatterMessage (Chatter_GoingToPlantBomb);
else
InstantChatterMessage (Chatter_Nothing);
@ -1210,9 +1210,9 @@ void Bot::CheckMessageQueue (void)
if (Random.Long (0, 100) < 40)
{
if (g_bombPlanted && m_team == TEAM_TF)
if (g_bombPlanted && m_team == TERRORIST)
InstantChatterMessage (Chatter_GuardDroppedC4);
else if (m_inVIPZone && m_team == TEAM_TF)
else if (m_inVIPZone && m_team == TERRORIST)
InstantChatterMessage (Chatter_GuardingVipSafety);
else
InstantChatterMessage (Chatter_Camp);
@ -1461,7 +1461,7 @@ void Bot::PurchaseWeapons (void)
break;
}
if (m_team == TEAM_CF)
if (m_team == CT)
{
switch (selectedWeapon->id)
{
@ -1477,7 +1477,7 @@ void Bot::PurchaseWeapons (void)
if (selectedWeapon->id == WEAPON_SHIELD && m_moneyAmount > g_botBuyEconomyTable[10])
ignoreWeapon = true;
}
else if (m_team == TEAM_TF)
else if (m_team == TERRORIST)
{
switch (selectedWeapon->id)
{
@ -1549,7 +1549,7 @@ void Bot::PurchaseWeapons (void)
FakeClientCommand(GetEntity (), "menuselect %d", selectedWeapon->buySelect);
else // SteamCS buy menu is different from the old one
{
if (m_team == TEAM_TF)
if (m_team == TERRORIST)
FakeClientCommand(GetEntity (), "menuselect %d", selectedWeapon->newBuySelectT);
else
FakeClientCommand (GetEntity (), "menuselect %d", selectedWeapon->newBuySelectCT);
@ -1638,7 +1638,7 @@ void Bot::PurchaseWeapons (void)
else // steam cs buy menu is different from old one
{
if (GetTeam (GetEntity ()) == TEAM_TF)
if (GetTeam (GetEntity ()) == TERRORIST)
FakeClientCommand (GetEntity (), "menuselect %d", selectedWeapon->newBuySelectT);
else
FakeClientCommand (GetEntity (), "menuselect %d", selectedWeapon->newBuySelectCT);
@ -1671,7 +1671,7 @@ void Bot::PurchaseWeapons (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 && Random.Long (1, 100) < 80 && m_moneyAmount > 200 && !IsRestricted (WEAPON_DEFUSER))
if ((g_mapType & MAP_DE) && m_team == CT && Random.Long (1, 100) < 80 && m_moneyAmount > 200 && !IsRestricted (WEAPON_DEFUSER))
{
if (g_gameVersion == CSV_OLD)
FakeClientCommand (GetEntity (), "buyequip;menuselect 6");
@ -1761,12 +1761,6 @@ void Bot::UpdateEmotions (void)
if (m_nextEmotionUpdate > GetWorldTime ())
return;
if (m_difficulty == 4)
{
m_agressionLevel *= 2;
m_fearLevel *= 0.5f;
}
if (m_agressionLevel > m_baseAgressionLevel)
m_agressionLevel -= 0.10f;
else
@ -1890,7 +1884,7 @@ void Bot::SetConditions (void)
}
// if no more enemies found AND bomb planted, switch to knife to get to bombplace faster
if (m_team == TEAM_CF && m_currentWeapon != WEAPON_KNIFE && m_numEnemiesLeft == 0 && g_bombPlanted)
if (m_team == CT && m_currentWeapon != WEAPON_KNIFE && m_numEnemiesLeft == 0 && g_bombPlanted)
{
SelectWeaponByName ("weapon_knife");
m_plantedBombWptIndex = FindPlantedBomb ();
@ -2159,7 +2153,7 @@ void Bot::PushTask (TaskID id, float desire, int data, float time, bool resume)
else
m_chosenGoalIndex = GetTask ()->data;
if (Random.Long (0, 100) < 80 && GetTaskId () == TASK_CAMP && m_team == TEAM_TF && m_inVIPZone)
if (Random.Long (0, 100) < 80 && GetTaskId () == TASK_CAMP && m_team == TERRORIST && m_inVIPZone)
ChatterMessage (Chatter_GoingToGuardVIPSafety);
}
@ -2482,7 +2476,7 @@ void Bot::CheckRadioCommands (void)
break;
case Radio_ShesGonnaBlow:
if (IsEntityNull (m_enemy) && distance < 2048.0f && g_bombPlanted && m_team == TEAM_TF)
if (IsEntityNull (m_enemy) && distance < 2048.0f && g_bombPlanted && m_team == TERRORIST)
{
RadioMessage (Radio_Affirmative);
@ -2499,7 +2493,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 == TEAM_CF) && 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");
@ -2607,7 +2601,7 @@ void Bot::CheckRadioCommands (void)
int bombPoint = -1;
// check if it's a ct command
if (GetTeam (m_radioEntity) == TEAM_CF && m_team == TEAM_CF && IsValidBot (m_radioEntity))
if (GetTeam (m_radioEntity) == CT && m_team == CT && IsValidBot (m_radioEntity))
{
if (g_timeNextBombUpdate < GetWorldTime ())
{
@ -2731,7 +2725,7 @@ void Bot::SelectLeaderEachTeam (int team)
{
if (g_mapType & MAP_AS)
{
if (m_isVIP && !g_leaderChoosen[TEAM_CF])
if (m_isVIP && !g_leaderChoosen[CT])
{
// vip bot is the leader
m_isLeader = true;
@ -2741,9 +2735,9 @@ void Bot::SelectLeaderEachTeam (int team)
RadioMessage (Radio_FollowMe);
m_campButtons = 0;
}
g_leaderChoosen[TEAM_CF] = true;
g_leaderChoosen[CT] = true;
}
else if ((team == TEAM_TF) && !g_leaderChoosen[TEAM_TF])
else if ((team == TERRORIST) && !g_leaderChoosen[TERRORIST])
{
Bot *botLeader = bots.GetHighestFragsBot(team);
@ -2754,12 +2748,12 @@ void Bot::SelectLeaderEachTeam (int team)
if (Random.Long (1, 100) < 45)
botLeader->RadioMessage (Radio_FollowMe);
}
g_leaderChoosen[TEAM_TF] = true;
g_leaderChoosen[TERRORIST] = true;
}
}
else if (g_mapType & MAP_DE)
{
if (team == TEAM_TF && !g_leaderChoosen[TEAM_TF])
if (team == TERRORIST && !g_leaderChoosen[TERRORIST])
{
if (m_hasC4)
{
@ -2776,10 +2770,10 @@ void Bot::SelectLeaderEachTeam (int team)
m_campButtons = 0;
}
g_leaderChoosen[TEAM_TF] = true;
g_leaderChoosen[TERRORIST] = true;
}
}
else if (!g_leaderChoosen[TEAM_CF])
else if (!g_leaderChoosen[CT])
{
Bot *botLeader = bots.GetHighestFragsBot(team);
@ -2790,7 +2784,7 @@ void Bot::SelectLeaderEachTeam (int team)
if (Random.Long (1, 100) < 30)
botLeader->RadioMessage (Radio_FollowMe);
}
g_leaderChoosen[TEAM_CF] = true;
g_leaderChoosen[CT] = true;
}
}
else if (g_mapType & (MAP_ES | MAP_KA | MAP_FY))
@ -2813,7 +2807,7 @@ void Bot::SelectLeaderEachTeam (int team)
{
botLeader->m_isLeader = true;
if (Random.Long (1, 100) < (team == TEAM_TF ? 30 : 40))
if (Random.Long (1, 100) < (team == TERRORIST ? 30 : 40))
botLeader->RadioMessage (Radio_FollowMe);
}
}
@ -2885,7 +2879,7 @@ void Bot::ChooseAimDirection (void)
{
int index = m_currentWaypointIndex;
if (m_team == TEAM_TF)
if (m_team == TERRORIST)
{
if ((g_experienceData + (index * g_numWaypoints) + index)->team0DangerIndex != -1)
m_lookAt = waypoints.GetPath ((g_experienceData + (index * g_numWaypoints) + index)->team0DangerIndex)->origin;
@ -2929,7 +2923,7 @@ void Bot::ThinkDelayed (void)
m_notKilled = IsAlive (GetEntity ());
m_team = GetTeam (GetEntity ());
if (m_team == TEAM_TF && (g_mapType & MAP_DE))
if (m_team == TERRORIST && (g_mapType & MAP_DE))
m_hasC4 = !!(pev->weapons & (1 << WEAPON_C4));
// is bot movement enabled
@ -3024,7 +3018,7 @@ void Bot::PeriodicThink (void)
m_numFriendsLeft = GetNearbyFriendsNearPosition (pev->origin, 99999.0f);
m_numEnemiesLeft = GetNearbyEnemiesNearPosition (pev->origin, 99999.0f);
if (g_bombPlanted && m_team == TEAM_CF && (pev->origin - waypoints.GetBombPosition ()).GetLength () < 700 && !IsBombDefusing (waypoints.GetBombPosition ()) && !m_hasProgressBar && GetTaskId () != TASK_ESCAPEFROMBOMB)
if (g_bombPlanted && m_team == CT && (pev->origin - waypoints.GetBombPosition ()).GetLength () < 700 && !IsBombDefusing (waypoints.GetBombPosition ()) && !m_hasProgressBar && GetTaskId () != TASK_ESCAPEFROMBOMB)
ResetTasks ();
CheckSpawnTimeConditions ();
@ -3064,7 +3058,7 @@ void Bot::RunTask_Normal (void)
m_reloadState = RELOAD_PRIMARY;
// if bomb planted and it's a CT calculate new path to bomb point if he's not already heading for
if (g_bombPlanted && m_team == TEAM_CF && GetTask ()->data != -1 && !(waypoints.GetPath (GetTask ()->data)->flags & FLAG_GOAL) && GetTaskId () != TASK_ESCAPEFROMBOMB)
if (g_bombPlanted && m_team == CT && GetTask ()->data != -1 && !(waypoints.GetPath (GetTask ()->data)->flags & FLAG_GOAL) && GetTaskId () != TASK_ESCAPEFROMBOMB)
{
DeleteSearchNodes ();
GetTask ()->data = -1;
@ -3082,7 +3076,7 @@ void Bot::RunTask_Normal (void)
// spray logo sometimes if allowed to do so
if (m_timeLogoSpray < GetWorldTime () && yb_spraypaints.GetBool () && Random.Long (1, 100) < 60 && m_moveSpeed > GetWalkSpeed () && IsEntityNull (m_pickupItem))
{
if (!((g_mapType & MAP_DE) && g_bombPlanted && m_team == TEAM_CF))
if (!((g_mapType & MAP_DE) && g_bombPlanted && m_team == CT))
PushTask (TASK_SPRAY, TASKPRI_SPRAYLOGO, -1, GetWorldTime () + 1.0f, false);
}
@ -3095,7 +3089,7 @@ void Bot::RunTask_Normal (void)
bool campingAllowed = true;
// Check if it's not allowed for this team to camp here
if (m_team == TEAM_TF)
if (m_team == TERRORIST)
{
if (m_currentPath->flags & FLAG_CF_ONLY)
campingAllowed = false;
@ -3107,11 +3101,11 @@ void Bot::RunTask_Normal (void)
}
// don't allow vip on as_ maps to camp + don't allow terrorist carrying c4 to camp
if (IsPlayerVIP (GetEntity ()) || ((g_mapType & MAP_DE) && m_team == TEAM_TF && !g_bombPlanted && m_hasC4))
if (campingAllowed && IsPlayerVIP (GetEntity ()) || ((g_mapType & MAP_DE) && m_team == TERRORIST && !g_bombPlanted && m_hasC4))
campingAllowed = false;
// check if another bot is already camping here
if (IsPointOccupied (m_currentWaypointIndex))
if (campingAllowed && IsPointOccupied (m_currentWaypointIndex))
campingAllowed = false;
if (campingAllowed)
@ -3136,7 +3130,7 @@ void Bot::RunTask_Normal (void)
m_campDirection = 0;
// tell the world we're camping
if (Random.Long (0, 100) < 80)
if (Random.Long (0, 100) < 60)
RadioMessage (Radio_InPosition);
m_moveToGoal = false;
@ -3153,7 +3147,7 @@ void Bot::RunTask_Normal (void)
if (g_mapType & MAP_CS)
{
// CT Bot has some hostages following?
if (HasHostage () && m_team == TEAM_CF)
if (m_team == CT && HasHostage ())
{
// and reached a Rescue Point?
if (m_currentPath->flags & FLAG_RESCUE)
@ -3162,7 +3156,7 @@ void Bot::RunTask_Normal (void)
m_hostages[i] = NULL; // clear array of hostage pointers
}
}
else if (m_team == TEAM_TF && Random.Long (0, 100) < 80)
else if (m_team == TERRORIST && Random.Long (0, 100) < 80)
{
int index = FindDefendWaypoint (m_currentPath->origin);
@ -3177,7 +3171,7 @@ void Bot::RunTask_Normal (void)
ChatterMessage (Chatter_GoingToGuardVIPSafety); // play info about that
}
}
else if ((g_mapType & MAP_DE) && ((m_currentPath->flags & FLAG_GOAL) || m_inBombZone) && m_seeEnemyTime + 1.5f < GetWorldTime ())
else if ((g_mapType & MAP_DE) && ((m_currentPath->flags & FLAG_GOAL) || m_inBombZone))
{
// is it a terrorist carrying the bomb?
if (m_hasC4)
@ -3193,15 +3187,17 @@ void Bot::RunTask_Normal (void)
else
PushTask (TASK_PLANTBOMB, TASKPRI_PLANTBOMB, -1, 0.0f, false);
}
else if (m_team == TEAM_CF)
else if (m_team == CT)
{
if (!g_bombPlanted && GetNearbyFriendsNearPosition (pev->origin, 360.0f) < 3 && Random.Long (0, 100) < 85 && m_personality != PERSONALITY_RUSHER)
if (!g_bombPlanted && GetNearbyFriendsNearPosition (pev->origin, 360.0f) < 4 && m_personality != PERSONALITY_RUSHER)
{
int index = FindDefendWaypoint (m_currentPath->origin);
PushTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (25.0, 40.0), true); // push camp task on to stack
PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + Random.Float (5.0f, 11.0f), true); // push move command
DebugMsg ("i'm ct and going to defend bomb!");
if (waypoints.GetPath (index)->vis.crouch <= waypoints.GetPath (index)->vis.stand)
m_campButtons |= IN_DUCK;
else
@ -3219,13 +3215,8 @@ void Bot::RunTask_Normal (void)
m_moveSpeed = 0.0f;
DeleteSearchNodes ();
int destIndex = -1;
// did we already decide about a goal before?
if (GetTask ()->data != -1)
destIndex = GetTask ()->data;
else
destIndex = FindGoal ();
int destIndex = GetTask ()->data != -1 ? GetTask ()->data : FindGoal ();
m_prevGoalIndex = destIndex;
m_chosenGoalIndex = destIndex;
@ -3235,7 +3226,7 @@ void Bot::RunTask_Normal (void)
// do pathfinding if it's not the current waypoint
if (destIndex != m_currentWaypointIndex)
FindPath (m_currentWaypointIndex, destIndex, ((g_bombPlanted && m_team == TEAM_CF) || yb_debug_goal.GetInt () != -1) ? 0 : m_pathType);
FindPath (m_currentWaypointIndex, destIndex, ((g_bombPlanted && m_team == CT) || yb_debug_goal.GetInt () != -1) ? 0 : m_pathType);
}
else
{
@ -3243,13 +3234,13 @@ void Bot::RunTask_Normal (void)
m_moveSpeed = m_minSpeed;
}
if ((yb_walking_allowed.GetBool () && mp_footsteps.GetBool ()) && m_difficulty >= 2 && !(m_aimFlags & AIM_ENEMY) && (m_heardSoundTime + 13.0f >= GetWorldTime () || (m_states & (STATE_HEARING_ENEMY | STATE_SUSPECT_ENEMY))) && GetNearbyEnemiesNearPosition (pev->origin, 1024.0f) >= 1 && !yb_jasonmode.GetBool () && !g_bombPlanted)
if ((yb_walking_allowed.GetBool () && mp_footsteps.GetBool ()) && m_difficulty >= 2 && !(m_aimFlags & AIM_ENEMY) && (m_heardSoundTime + 8.0f >= GetWorldTime () || (m_states & (STATE_HEARING_ENEMY | STATE_SUSPECT_ENEMY))) && GetNearbyEnemiesNearPosition (pev->origin, 1024.0f) >= 1 && !yb_jasonmode.GetBool () && !g_bombPlanted)
m_moveSpeed = GetWalkSpeed ();
// bot hasn't seen anything in a long time and is asking his teammates to report in
if (m_seeEnemyTime + Random.Float (45.0f, 80.0f) < GetWorldTime () && Random.Long (0, 100) < 30 && g_timeRoundStart + 20.0f < GetWorldTime () && m_askCheckTime + Random.Float (20.0f, 30.0f) < GetWorldTime ())
if (m_seeEnemyTime + Random.Float (45.0f, 80.0f) < GetWorldTime () && Random.Long (0, 100) < 30 && g_timeRoundStart + 20.0f < GetWorldTime () && m_askCheckTime < GetWorldTime ())
{
m_askCheckTime = GetWorldTime ();
m_askCheckTime = GetWorldTime () + Random.Float (45.0f, 80.0f);
RadioMessage (Radio_ReportTeam);
}
}
@ -3281,7 +3272,7 @@ void Bot::RunTask_Spray (void)
// paint the actual logo decal
DecalTrace (pev, &tr, m_logotypeIndex);
m_timeLogoSpray = GetWorldTime () + Random.Float (30.0f, 45.0f);
m_timeLogoSpray = GetWorldTime () + Random.Float (60.0f, 90.0f);
}
}
else
@ -3546,7 +3537,7 @@ void Bot::RunTask_Camp (void)
m_checkTerrain = false;
m_moveToGoal = false;
if (m_team == TEAM_CF && g_bombPlanted && m_defendedBomb && !IsBombDefusing (waypoints.GetBombPosition ()) && !OutOfBombTimer ())
if (m_team == CT && g_bombPlanted && m_defendedBomb && !IsBombDefusing (waypoints.GetBombPosition ()) && !OutOfBombTimer ())
{
m_defendedBomb = false;
TaskComplete ();
@ -4513,7 +4504,7 @@ void Bot::RunTask_PickupItem ()
case PICKUP_PLANTED_C4:
m_aimFlags |= AIM_ENTITY;
if (m_team == TEAM_CF && itemDistance < 80.0f)
if (m_team == CT && itemDistance < 80.0f)
{
ChatterMessage (Chatter_DefusingC4);
@ -4833,7 +4824,7 @@ void Bot::BotAI (void)
if (!hasFriendNearby && Random.Long (0, 100) < 45 && (m_enemy->v.weapons & (1 << WEAPON_C4)))
ChatterMessage (Chatter_SpotTheBomber);
else if (!hasFriendNearby && Random.Long (0, 100) < 45 && m_team == TEAM_TF && IsPlayerVIP (m_enemy))
else if (!hasFriendNearby && Random.Long (0, 100) < 45 && m_team == TERRORIST && IsPlayerVIP (m_enemy))
ChatterMessage (Chatter_VIPSpotted);
else if (!hasFriendNearby && Random.Long (0, 100) < 50 && GetTeam (m_enemy) != m_team && IsGroupOfEnemies (m_enemy->v.origin, 2, 384.0f))
@ -4848,7 +4839,7 @@ void Bot::BotAI (void)
}
// if bomb planted warn teammates !
if (g_canSayBombPlanted && g_bombPlanted && GetTeam (GetEntity ()) == TEAM_CF)
if (g_canSayBombPlanted && g_bombPlanted && GetTeam (GetEntity ()) == CT)
{
g_canSayBombPlanted = false;
ChatterMessage (Chatter_GottaFindTheBomb);
@ -5186,9 +5177,9 @@ void Bot::DisplayDebugOverlay (void)
WRITE_SHORT (FixedSigned16 (-1, 1 << 13));
WRITE_SHORT (FixedSigned16 (0, 1 << 13));
WRITE_BYTE (0);
WRITE_BYTE (m_team == TEAM_CF ? 0 : 255);
WRITE_BYTE (m_team == CT ? 0 : 255);
WRITE_BYTE (100);
WRITE_BYTE (m_team != TEAM_CF ? 0 : 255);
WRITE_BYTE (m_team != CT ? 0 : 255);
WRITE_BYTE (0);
WRITE_BYTE (255);
WRITE_BYTE (255);
@ -5383,7 +5374,7 @@ void Bot::CollectGoalExperience (int damage, int team)
// FIXME: could be done a lot better, however this cares most about damage done by sniping or really deadly weapons
if (pev->health - damage <= 0)
{
if (team == TEAM_TF)
if (team == TERRORIST)
{
int value = (g_experienceData + (m_chosenGoalIndex * g_numWaypoints) + m_prevGoalIndex)->team0Value;
value -= static_cast <int> (pev->health / 20);
@ -5439,7 +5430,7 @@ void Bot::CollectExperienceData (edict_t *attacker, int damage)
if (pev->health > 20.0f)
{
if (victimTeam == TEAM_TF)
if (victimTeam == TERRORIST)
(g_experienceData + (victimIndex * g_numWaypoints) + victimIndex)->team0Damage++;
else
(g_experienceData + (victimIndex * g_numWaypoints) + victimIndex)->team1Damage++;
@ -5454,7 +5445,7 @@ void Bot::CollectExperienceData (edict_t *attacker, int damage)
float updateDamage = IsValidBot (attacker) ? 10.0f : 7.0f;
// store away the damage done
if (victimTeam == TEAM_TF)
if (victimTeam == TERRORIST)
{
int value = (g_experienceData + (victimIndex * g_numWaypoints) + attackerIndex)->team0Damage;
value += static_cast <int> (damage / updateDamage);
@ -5486,7 +5477,7 @@ void Bot::HandleChatterMessage (const char *tempMessage)
{
// this function is added to prevent engine crashes with: 'Message XX started, before message XX ended', or something.
if (FStrEq (tempMessage, "#CTs_Win") && m_team == TEAM_CF)
if (FStrEq (tempMessage, "#CTs_Win") && m_team == CT)
{
if (g_timeRoundMid > GetWorldTime ())
ChatterMessage (Chatter_QuicklyWonTheRound);
@ -5494,7 +5485,7 @@ void Bot::HandleChatterMessage (const char *tempMessage)
ChatterMessage (Chatter_WonTheRound);
}
if (FStrEq (tempMessage, "#Terrorists_Win") && m_team == TEAM_TF)
if (FStrEq (tempMessage, "#Terrorists_Win") && m_team == TERRORIST)
{
if (g_timeRoundMid > GetWorldTime ())
ChatterMessage (Chatter_QuicklyWonTheRound);
@ -5589,13 +5580,24 @@ void Bot::DebugMsg (const char *format, ...)
vsprintf (buffer, format, ap);
va_end (ap);
if (level == 3 && !IsEntityNull (g_hostEntity) && g_hostEntity->v.iuser2 == IndexOfEntity (GetEntity ()))
ServerPrint ("%s: %s", STRING (pev->netname), buffer);
else if (level != 3)
ServerPrint ("%s: %s", STRING (pev->netname), buffer);
char printBuf[1024];
sprintf (printBuf, "%s: %s", STRING (pev->netname), buffer);
if (level > 3)
AddLogEntry (false, LL_DEFAULT, "%s: %s", STRING (pev->netname), buffer);
bool playMessage = false;
if (level == 3 && !IsEntityNull (g_hostEntity) && g_hostEntity->v.iuser2 == IndexOfEntity (GetEntity ()))
playMessage = true;
else if (level != 3)
playMessage = true;
if (playMessage && level > 3)
AddLogEntry (false, LL_DEFAULT, printBuf);
if (playMessage)
{
ServerPrint (printBuf);
SayText (printBuf);
}
}
Vector Bot::CheckToss(const Vector &start, const Vector &stop)
@ -5865,7 +5867,7 @@ bool Bot::OutOfBombTimer (void)
const Vector &bombOrigin = waypoints.GetBombPosition ();
// for terrorist, if timer is lower than eleven seconds, return true
if (static_cast <int> (timeLeft) < 16 && m_team == TEAM_TF && (bombOrigin - pev->origin).GetLength () < 1000.0f)
if (static_cast <int> (timeLeft) < 16 && m_team == TERRORIST && (bombOrigin - pev->origin).GetLength () < 1000.0f)
return true;
bool hasTeammatesWithDefuserKit = false;
@ -5876,7 +5878,7 @@ bool Bot::OutOfBombTimer (void)
Bot *bot = NULL; // temporaly pointer to bot
// search players with defuse kit
if ((bot = bots.GetBot (i)) != NULL && GetTeam (bot->GetEntity ()) == TEAM_CF && bot->m_hasDefuser && (bombOrigin - bot->pev->origin).GetLength () < 500.0f)
if ((bot = bots.GetBot (i)) != NULL && GetTeam (bot->GetEntity ()) == CT && bot->m_hasDefuser && (bombOrigin - bot->pev->origin).GetLength () < 500.0f)
{
hasTeammatesWithDefuserKit = true;
break;
@ -5931,11 +5933,8 @@ void Bot::ReactOnSound (void)
}
edict_t *player = NULL;
if (hearEnemyIndex >= 0)
{
if (g_clients[hearEnemyIndex].team != m_team && yb_csdm_mode.GetInt () != 2)
if (hearEnemyIndex >= 0 && g_clients[hearEnemyIndex].team != m_team && yb_csdm_mode.GetInt () != 2)
player = g_clients[hearEnemyIndex].ent;
}
// did the bot hear someone ?
if (IsValidPlayer (player))
@ -5944,7 +5943,7 @@ void Bot::ReactOnSound (void)
if (m_shootTime < GetWorldTime () - 5.0f && IsOnFloor () && m_currentWeapon != WEAPON_C4 && m_currentWeapon != WEAPON_EXPLOSIVE && m_currentWeapon != WEAPON_SMOKE && m_currentWeapon != WEAPON_FLASHBANG && !yb_jasonmode.GetBool ())
SelectBestWeapon ();
m_heardSoundTime = GetWorldTime () + 5.0f;
m_heardSoundTime = GetWorldTime ();
m_states |= STATE_HEARING_ENEMY;
if ((Random.Long (0, 100) < 15) && IsEntityNull (m_enemy) && IsEntityNull (m_lastEnemy) && m_seeEnemyTime + 7.0f < GetWorldTime ())

View file

@ -536,7 +536,7 @@ float Bot::GetZOffset (float distance)
if (distance < 2800.0f && distance > DoubleBurstDistance)
{
if (sniper) result = 3.5f;
if (sniper) result = 1.5f;
else if (zoomableRifle) result = 4.5f;
else if (pistol) result = 6.5f;
else if (submachine) result = 5.5f;
@ -546,7 +546,7 @@ float Bot::GetZOffset (float distance)
}
else if (distance > BurstDistance && distance <= DoubleBurstDistance)
{
if (sniper) result = 3.5f;
if (sniper) result = 2.5f;
else if (zoomableRifle) result = 3.5f;
else if (pistol) result = 6.5f;
else if (submachine) result = 3.5f;

View file

@ -38,19 +38,19 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
// kicking off one bot from the terrorist team
else if (stricmp (arg0, "kickbot_t") == 0 || stricmp (arg0, "kick_t") == 0)
bots.RemoveFromTeam (TEAM_TF);
bots.RemoveFromTeam (TERRORIST);
// kicking off one bot from the counter-terrorist team
else if (stricmp (arg0, "kickbot_ct") == 0 || stricmp (arg0, "kick_ct") == 0)
bots.RemoveFromTeam (TEAM_CF);
bots.RemoveFromTeam (CT);
// kills all bots on the terrorist team
else if (stricmp (arg0, "killbots_t") == 0 || stricmp (arg0, "kill_t") == 0)
bots.KillAll (TEAM_TF);
bots.KillAll (TERRORIST);
// kills all bots on the counter-terrorist team
else if (stricmp (arg0, "killbots_ct") == 0 || stricmp (arg0, "kill_ct") == 0)
bots.KillAll (TEAM_CF);
bots.KillAll (CT);
// list all bots playeing on the server
else if (stricmp (arg0, "listbots") == 0 || stricmp (arg0, "list") == 0)
@ -2769,7 +2769,7 @@ void pfnAlertMessage (ALERT_TYPE alertType, char *format, ...)
{
Bot *bot = bots.GetBot (i);
if (bot != NULL && GetTeam (bot->GetEntity ()) == TEAM_TF && IsAlive (bot->GetEntity ()))
if (bot != NULL && GetTeam (bot->GetEntity ()) == TERRORIST && IsAlive (bot->GetEntity ()))
{
bot->ResetTasks ();
bot->MoveToVector (waypoints.GetBombPosition ());

View file

@ -31,8 +31,8 @@ BotManager::BotManager (void)
m_lastWinner = -1;
m_deathMsgSent = false;
m_economicsGood[TEAM_TF] = true;
m_economicsGood[TEAM_CF] = true;
m_economicsGood[TERRORIST] = true;
m_economicsGood[CT] = true;
memset (m_bots, 0, sizeof (m_bots));
@ -341,9 +341,14 @@ void BotManager::AdjustQuota (bool isPlayerConnection, edict_t *ent)
AddPlayerToCheckTeamQueue (ent);
else
RemoveRandom ();
m_balanceCount--;
}
else
else if (m_balanceCount <= 0)
{
AddRandom ();
m_balanceCount++;
}
}
void BotManager::AddPlayerToCheckTeamQueue (edict_t *ent)
@ -373,7 +378,7 @@ void BotManager::VerifyPlayersHasJoinedTeam (int &desiredCount)
{
Client &cl = g_clients[i];
if ((cl.flags & CF_USED) && cl.team != TEAM_SPEC && !IsValidBot (cl.ent))
if ((cl.flags & CF_USED) && cl.team != SPECTATOR && !IsValidBot (cl.ent))
{
FOR_EACH_AE (m_trackedPlayers, it)
{
@ -458,6 +463,8 @@ void BotManager::MaintainBotQuota (void)
void BotManager::InitQuota (void)
{
m_balanceCount = 0;
m_maintainTime = GetWorldTime () + 3.0f;
m_quotaMaintainTime = GetWorldTime () + 3.0f;
@ -559,7 +566,7 @@ void BotManager::RemoveMenu (edict_t *ent, int selection)
if ((m_bots[i] != NULL) && !IsEntityNull (m_bots[i]->GetEntity ()))
{
validSlots |= 1 << (i - ((selection - 1) * 8));
sprintf (buffer, "%s %1.1d. %s%s\n", buffer, i - ((selection - 1) * 8) + 1, STRING (m_bots[i]->pev->netname), GetTeam (m_bots[i]->GetEntity ()) == TEAM_CF ? " \\y(CT)\\w" : " \\r(T)\\w");
sprintf (buffer, "%s %1.1d. %s%s\n", buffer, i - ((selection - 1) * 8) + 1, STRING (m_bots[i]->pev->netname), GetTeam (m_bots[i]->GetEntity ()) == CT ? " \\y(CT)\\w" : " \\r(T)\\w");
}
else
sprintf (buffer, "%s\\d %1.1d. Not a Bot\\w\n", buffer, i - ((selection - 1) * 8) + 1);
@ -1026,7 +1033,7 @@ int BotManager::GetHumansJoinedTeam (void)
{
Client *cl = &g_clients[i];
if ((cl->flags & (CF_USED | CF_ALIVE)) && m_bots[i] == NULL && cl->team != TEAM_SPEC && !(cl->ent->v.flags & FL_FAKECLIENT) && cl->ent->v.movetype != MOVETYPE_FLY)
if ((cl->flags & (CF_USED | CF_ALIVE)) && m_bots[i] == NULL && cl->team != SPECTATOR && !(cl->ent->v.flags & FL_FAKECLIENT) && cl->ent->v.movetype != MOVETYPE_FLY)
count++;
}
return count;

View file

@ -14,7 +14,7 @@ ConVar yb_whose_your_daddy ("yb_whose_your_daddy", "0");
int Bot::FindGoal (void)
{
// chooses a destination (goal) waypoint for a bot
if (!g_bombPlanted && m_team == TEAM_TF && (g_mapType & MAP_DE))
if (!g_bombPlanted && m_team == TERRORIST && (g_mapType & MAP_DE))
{
edict_t *pent = NULL;
@ -31,31 +31,32 @@ int Bot::FindGoal (void)
}
}
}
int tactic;
int tactic = 0;
// path finding behaviour depending on map type
float offensive;
float defensive;
float offensive = 0.0f;
float defensive = 0.0f;
float goalDesire;
float forwardDesire;
float campDesire;
float backoffDesire;
float tacticChoice;
float goalDesire = 0.0f;
float forwardDesire = 0.0f;
float campDesire = 0.0f;
float backoffDesire = 0.0f;
float tacticChoice = 0.0f;
Array <int> offensiveWpts;
Array <int> defensiveWpts;
Array <int> *offensiveWpts = NULL;
Array <int> *defensiveWpts = NULL;
switch (m_team)
{
case TEAM_TF:
offensiveWpts = waypoints.m_ctPoints;
defensiveWpts = waypoints.m_terrorPoints;
case TERRORIST:
offensiveWpts = &waypoints.m_ctPoints;
defensiveWpts = &waypoints.m_terrorPoints;
break;
case TEAM_CF:
offensiveWpts = waypoints.m_terrorPoints;
defensiveWpts = waypoints.m_ctPoints;
case CT:
default:
offensiveWpts = &waypoints.m_terrorPoints;
defensiveWpts = &waypoints.m_ctPoints;
break;
}
@ -65,10 +66,10 @@ int Bot::FindGoal (void)
tactic = 3;
goto TacticChoosen;
}
else if (m_team == TEAM_CF && HasHostage ())
else if (m_team == CT && HasHostage ())
{
tactic = 2;
offensiveWpts = waypoints.m_rescuePoints;
offensiveWpts = &waypoints.m_rescuePoints;
goto TacticChoosen;
}
@ -78,12 +79,12 @@ int Bot::FindGoal (void)
if (g_mapType & (MAP_AS | MAP_CS))
{
if (m_team == TEAM_TF)
if (m_team == TERRORIST)
{
defensive += 25.0f;
offensive -= 25.0f;
}
else if (m_team == TEAM_CF)
else if (m_team == CT)
{
// on hostage maps force more bots to save hostages
if (g_mapType & MAP_CS)
@ -98,7 +99,7 @@ int Bot::FindGoal (void)
}
}
}
else if ((g_mapType & MAP_DE) && m_team == TEAM_CF)
else if ((g_mapType & MAP_DE) && m_team == CT)
{
if (g_bombPlanted && GetTaskId () != TASK_ESCAPEFROMBOMB && !waypoints.GetBombPosition ().IsZero ())
{
@ -109,13 +110,13 @@ int Bot::FindGoal (void)
}
return m_chosenGoalIndex = ChooseBombWaypoint ();
}
defensive += 25.0f + m_difficulty * 2.0f;
defensive += 25.0f + m_difficulty * 4.0f;
offensive -= 25.0f - m_difficulty * 0.5f;
if (m_personality != PERSONALITY_RUSHER)
defensive += 10.0f;
}
else if ((g_mapType & MAP_DE) && m_team == TEAM_TF && g_timeRoundStart + 10.0f < GetWorldTime ())
else if ((g_mapType & MAP_DE) && m_team == TERRORIST && g_timeRoundStart + 10.0f < GetWorldTime ())
{
// send some terrorists to guard planted bomb
if (!m_defendedBomb && g_bombPlanted && GetTaskId () != TASK_ESCAPEFROMBOMB && GetBombTimeleft () >= 15.0)
@ -151,8 +152,8 @@ int Bot::FindGoal (void)
TacticChoosen:
int goalChoices[4] = {-1, -1, -1, -1};
if (tactic == 0 && !defensiveWpts.IsEmpty ()) // careful goal
FilterGoals (defensiveWpts, goalChoices);
if (tactic == 0 && !(*defensiveWpts).IsEmpty ()) // careful goal
FilterGoals (*defensiveWpts, goalChoices);
else if (tactic == 1 && !waypoints.m_campPoints.IsEmpty ()) // camp waypoint goal
{
// pickup sniper points if possible for sniping bots
@ -161,8 +162,8 @@ TacticChoosen:
else
FilterGoals (waypoints.m_campPoints, goalChoices);
}
else if (tactic == 2 && !offensiveWpts.IsEmpty ()) // offensive goal
FilterGoals (offensiveWpts, goalChoices);
else if (tactic == 2 && !(*offensiveWpts).IsEmpty ()) // offensive goal
FilterGoals (*offensiveWpts, goalChoices);
else if (tactic == 3 && !waypoints.m_goalPoints.IsEmpty ()) // map goal waypoint
{
// force bomber to select closest goal, if round-start goal was reset by something
@ -223,8 +224,8 @@ TacticChoosen:
if (testIndex < 0)
break;
int goal1 = m_team == TEAM_TF ? (g_experienceData + (m_currentWaypointIndex * g_numWaypoints) + goalChoices[i])->team0Value : (g_experienceData + (m_currentWaypointIndex * g_numWaypoints) + goalChoices[i])->team1Value;
int goal2 = m_team == TEAM_TF ? (g_experienceData + (m_currentWaypointIndex * g_numWaypoints) + goalChoices[i + 1])->team0Value : (g_experienceData + (m_currentWaypointIndex * g_numWaypoints) + goalChoices[i + 1])->team1Value;
int goal1 = m_team == TERRORIST ? (g_experienceData + (m_currentWaypointIndex * g_numWaypoints) + goalChoices[i])->team0Value : (g_experienceData + (m_currentWaypointIndex * g_numWaypoints) + goalChoices[i])->team1Value;
int goal2 = m_team == TERRORIST ? (g_experienceData + (m_currentWaypointIndex * g_numWaypoints) + goalChoices[i + 1])->team0Value : (g_experienceData + (m_currentWaypointIndex * g_numWaypoints) + goalChoices[i + 1])->team1Value;
if (goal1 < goal2)
{
@ -1186,7 +1187,7 @@ bool Bot::DoWaypointNav (void)
int startIndex = m_chosenGoalIndex;
int goalIndex = m_currentWaypointIndex;
if (m_team == TEAM_TF)
if (m_team == TERRORIST)
{
waypointValue = (g_experienceData + (startIndex * g_numWaypoints) + goalIndex)->team0Value;
waypointValue += static_cast <int> (pev->health * 0.5f);
@ -1218,7 +1219,7 @@ bool Bot::DoWaypointNav (void)
else if (m_navNode == NULL)
return false;
if ((g_mapType & MAP_DE) && g_bombPlanted && m_team == TEAM_CF && GetTaskId () != TASK_ESCAPEFROMBOMB && GetTask ()->data != -1)
if ((g_mapType & MAP_DE) && g_bombPlanted && m_team == CT && GetTaskId () != TASK_ESCAPEFROMBOMB && GetTask ()->data != -1)
{
const Vector &bombOrigin = CheckBombAudible ();
@ -1657,7 +1658,7 @@ void Bot::FindPath (int srcIndex, int destIndex, unsigned char pathType)
break;
case 1:
if (m_team == TEAM_TF)
if (m_team == TERRORIST)
{
gcalc = gfunctionKillsDistT;
hcalc = hfunctionSquareDist;
@ -1676,7 +1677,7 @@ void Bot::FindPath (int srcIndex, int destIndex, unsigned char pathType)
case 2:
default:
if (m_team == TEAM_TF)
if (m_team == TERRORIST)
{
gcalc = gfunctionKillsT;
hcalc = hfunctionNone;
@ -1926,7 +1927,7 @@ void Bot::GetValidWaypoint (void)
}
else if (m_navTimeset + GetEstimatedReachTime () < GetWorldTime () && IsEntityNull (m_enemy))
{
if (m_team == TEAM_TF)
if (m_team == TERRORIST)
{
int value = (g_experienceData + (m_currentWaypointIndex * g_numWaypoints) + m_currentWaypointIndex)->team0Damage;
value += 100;
@ -2124,12 +2125,12 @@ int Bot::FindDefendWaypoint (const Vector &origin)
Experience *exp = (g_experienceData + (waypointIndex[i] * g_numWaypoints) + waypointIndex[i]);
int experience = -1;
if (m_team == TEAM_TF)
if (m_team == TERRORIST)
experience = exp->team0Damage;
else
experience = exp->team1Damage;
experience = (experience * 100) / (m_team == TEAM_TF ? g_highestDamageT : g_highestDamageCT);
experience = (experience * 100) / (m_team == TERRORIST ? g_highestDamageT : g_highestDamageCT);
minDistance[i] = (experience * 100) / 8192;
minDistance[i] += experience;
}
@ -2273,7 +2274,7 @@ int Bot::FindCoverWaypoint (float maxDistance)
Experience *exp = (g_experienceData + (waypointIndex[i] * g_numWaypoints) + waypointIndex[i]);
int experience = -1;
if (m_team == TEAM_TF)
if (m_team == TERRORIST)
experience = exp->team0Damage;
else
experience = exp->team1Damage;
@ -2381,20 +2382,20 @@ bool Bot::HeadTowardWaypoint (void)
m_minSpeed = pev->maxspeed;
// only if we in normal task and bomb is not planted
if (GetTaskId () == TASK_NORMAL && g_timeRoundMid + 10.0f < GetWorldTime () && m_timeCamping + 30.0f < GetWorldTime () && !g_bombPlanted && m_personality != PERSONALITY_RUSHER && !m_hasC4 && !m_isVIP && m_loosedBombWptIndex == -1 && !HasHostage ())
if (GetTaskId () == TASK_NORMAL && g_timeRoundMid + 5.0f < GetWorldTime () && m_timeCamping + 5.0f < GetWorldTime () && !g_bombPlanted && m_personality != PERSONALITY_RUSHER && !m_hasC4 && !m_isVIP && m_loosedBombWptIndex == -1 && !HasHostage ())
{
m_campButtons = 0;
int nextIndex = m_navNode->next->index;
float kills = 0;
if (m_team == TEAM_TF)
kills = (g_experienceData + (nextIndex * g_numWaypoints) + nextIndex)->team0Damage / g_highestDamageT;
if (m_team == TERRORIST)
kills = (g_experienceData + (nextIndex * g_numWaypoints) + nextIndex)->team0Damage;
else
kills = (g_experienceData + (nextIndex * g_numWaypoints) + nextIndex)->team1Damage / g_highestDamageCT;
kills = (g_experienceData + (nextIndex * g_numWaypoints) + nextIndex)->team1Damage;
// if damage done higher than one
if (kills > 0.15f && g_timeRoundMid + 15.0f < GetWorldTime ())
if (kills > 1.0f && g_timeRoundMid > GetWorldTime ())
{
switch (m_personality)
{
@ -3285,7 +3286,7 @@ int Bot::FindPlantedBomb (void)
{
// this function tries to find planted c4 on the defuse scenario map and returns nearest to it waypoint
if (m_team != TEAM_TF || !(g_mapType & MAP_DE))
if (m_team != TERRORIST || !(g_mapType & MAP_DE))
return -1; // don't search for bomb if the player is CT, or it's not defusing bomb
edict_t *bombEntity = NULL; // temporaly pointer to bomb

View file

@ -393,7 +393,7 @@ void NetworkMsg::Execute (void *p)
if (FStrEq (PTR_TO_STR (p), "#CTs_Win"))
{
bots.SetLastWinner (TEAM_CF); // update last winner for economics
bots.SetLastWinner (CT); // update last winner for economics
if (yb_communication_type.GetInt () == 2)
{
@ -406,13 +406,13 @@ void NetworkMsg::Execute (void *p)
if (FStrEq (PTR_TO_STR (p), "#Game_will_restart_in"))
{
bots.CheckTeamEconomics (TEAM_CF, true);
bots.CheckTeamEconomics (TEAM_TF, true);
bots.CheckTeamEconomics (CT, true);
bots.CheckTeamEconomics (TERRORIST, true);
}
if (FStrEq (PTR_TO_STR (p), "#Terrorists_Win"))
{
bots.SetLastWinner (TEAM_TF); // update last winner for economics
bots.SetLastWinner (TERRORIST); // update last winner for economics
if (yb_communication_type.GetInt () == 2)
{
@ -440,7 +440,7 @@ void NetworkMsg::Execute (void *p)
bot->DeleteSearchNodes ();
bot->ResetTasks ();
if (yb_communication_type.GetInt () == 2 && Random.Long (0, 100) < 75 && GetTeam (bot->GetEntity ()) == TEAM_CF)
if (yb_communication_type.GetInt () == 2 && Random.Long (0, 100) < 75 && GetTeam (bot->GetEntity ()) == CT)
bot->ChatterMessage (Chatter_WhereIsTheBomb);
}
}
@ -466,11 +466,11 @@ void NetworkMsg::Execute (void *p)
Client &cl = g_clients[playerIndex - 1];
if (PTR_TO_INT (p) == 1)
cl.realTeam = TEAM_TF;
cl.realTeam = TERRORIST;
else if (PTR_TO_INT (p) == 2)
cl.realTeam = TEAM_CF;
cl.realTeam = CT;
else
cl.realTeam = TEAM_SPEC;
cl.realTeam = SPECTATOR;
if (yb_csdm_mode.GetInt () == 2)
cl.team = playerIndex;

View file

@ -736,8 +736,8 @@ void RoundInit (void)
g_roundEnded = false;
// check team economics
bots.CheckTeamEconomics (TEAM_TF);
bots.CheckTeamEconomics (TEAM_CF);
bots.CheckTeamEconomics (TERRORIST);
bots.CheckTeamEconomics (CT);
for (int i = 0; i < GetMaxClients (); i++)
{
@ -753,8 +753,8 @@ void RoundInit (void)
g_timeBombPlanted = 0.0f;
g_timeNextBombUpdate = 0.0f;
g_leaderChoosen[TEAM_CF] = false;
g_leaderChoosen[TEAM_TF] = false;
g_leaderChoosen[CT] = false;
g_leaderChoosen[TERRORIST] = false;
g_lastRadioTime[0] = 0.0f;
g_lastRadioTime[1] = 0.0f;
@ -1306,6 +1306,9 @@ void SoundAttachToClients (edict_t *ent, const char *sample, float volume)
}
Client *client = &g_clients[index];
if (client == NULL)
return;
if (strncmp ("player/bhit_flesh", sample, 17) == 0 || strncmp ("player/headshot", sample, 15) == 0)
{
// hit/fall sound?
@ -1362,7 +1365,6 @@ void SoundSimulateUpdate (int playerIndex)
// this function tries to simulate playing of sounds to let the bots hear sounds which aren't
// captured through server sound hooking
if (playerIndex < 0 || playerIndex >= GetMaxClients ())
return; // reliability check
@ -1373,17 +1375,17 @@ void SoundSimulateUpdate (int playerIndex)
if (client->ent->v.oldbuttons & IN_ATTACK) // pressed attack button?
{
hearDistance = 3072.0;
hearDistance = 2048.0f;
timeSound = GetWorldTime () + 0.3f;
}
else if (client->ent->v.oldbuttons & IN_USE) // pressed used button?
{
hearDistance = 512.0;
hearDistance = 512.0f;
timeSound = GetWorldTime () + 0.5f;
}
else if (client->ent->v.oldbuttons & IN_RELOAD) // pressed reload button?
{
hearDistance = 512.0;
hearDistance = 512.0f;
timeSound = GetWorldTime () + 0.5f;
}
else if (client->ent->v.movetype == MOVETYPE_FLY) // uses ladder?

View file

@ -1730,10 +1730,10 @@ void Waypoint::Think (void)
// draw the danger directions
if (!g_waypointsChanged)
{
if ((g_experienceData + (nearestIndex * g_numWaypoints) + nearestIndex)->team0DangerIndex != -1 && GetTeam (g_hostEntity) == TEAM_TF)
if ((g_experienceData + (nearestIndex * g_numWaypoints) + nearestIndex)->team0DangerIndex != -1 && GetTeam (g_hostEntity) == TERRORIST)
DrawArrow (g_hostEntity, path->origin, m_paths[(g_experienceData + (nearestIndex * g_numWaypoints) + nearestIndex)->team0DangerIndex]->origin, 15, 0, 255, 0, 0, 200, 0, 10); // draw a red arrow to this index's danger point
if ((g_experienceData + (nearestIndex * g_numWaypoints) + nearestIndex)->team1DangerIndex != -1 && GetTeam (g_hostEntity) == TEAM_CF)
if ((g_experienceData + (nearestIndex * g_numWaypoints) + nearestIndex)->team1DangerIndex != -1 && GetTeam (g_hostEntity) == CT)
DrawArrow (g_hostEntity, path->origin, m_paths[(g_experienceData + (nearestIndex * g_numWaypoints) + nearestIndex)->team1DangerIndex]->origin, 15, 0, 0, 0, 255, 200, 0, 10); // draw a blue arrow to this index's danger point
}