2014-07-30 14:17:46 +04:00
//
2014-09-09 18:29:42 +04:00
// Yet Another POD-Bot, based on PODBot by Markus Klinge ("CountFloyd").
// Copyright (c) YaPB Development Team.
2014-07-30 14:17:46 +04:00
//
2014-09-09 18:29:42 +04:00
// 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
2014-07-30 14:17:46 +04:00
//
# include <core.h>
2016-08-27 22:49:42 +03:00
class Chat
{
public :
} ;
class Globals
{
public :
} ;
class Practice
{
public :
} ;
class GameState
{
public :
} ;
class MenuManager
{
public :
} ;
2014-07-30 14:17:46 +04:00
bool g_canSayBombPlanted = true ;
bool g_roundEnded = true ;
bool g_botsCanPause = false ;
bool g_bombPlanted = false ;
bool g_bombSayString = false ;
bool g_isCommencing = false ;
2016-08-27 22:49:42 +03:00
2014-07-30 14:17:46 +04:00
bool g_editNoclip = false ;
bool g_waypointOn = false ;
bool g_autoWaypoint = false ;
2015-08-15 18:09:15 +03:00
float g_lastChatTime = 0.0f ;
float g_timeRoundStart = 0.0f ;
float g_timeRoundEnd = 0.0f ;
float g_timeRoundMid = 0.0f ;
float g_timeNextBombUpdate = 0.0f ;
float g_timeBombPlanted = 0.0f ;
float g_timePerSecondUpdate = 0.0f ;
float g_lastRadioTime [ 2 ] = { 0.0f , 0.0f } ;
float g_autoPathDistance = 250.0f ;
2014-07-30 14:17:46 +04:00
int g_lastRadio [ 2 ] ;
int g_storeAddbotVars [ 4 ] ;
2016-03-10 00:37:33 +03:00
int g_radioSelect [ MAX_ENGINE_PLAYERS ] ;
2016-02-11 21:50:05 +03:00
int g_gameFlags = 0 ;
2014-07-30 14:17:46 +04:00
int g_numWaypoints = 0 ;
int g_mapType = 0 ;
2014-08-05 21:04:43 +04:00
int g_highestDamageCT = 1 ;
int g_highestDamageT = 1 ;
int g_highestKills = 1 ;
2014-07-30 14:17:46 +04:00
Array < Array < String > > g_chatFactory ;
Array < Array < ChatterItem > > g_chatterFactory ;
Array < BotName > g_botNames ;
Array < KeywordFactory > g_replyFactory ;
2015-06-09 15:45:34 +03:00
RandomSequenceOfUnique Random ;
2014-07-30 14:17:46 +04:00
Library * g_gameLib = NULL ;
meta_globals_t * gpMetaGlobals = NULL ;
gamedll_funcs_t * gpGamedllFuncs = NULL ;
mutil_funcs_t * gpMetaUtilFuncs = NULL ;
gamefuncs_t g_functionTable ;
enginefuncs_t g_engfuncs ;
2016-03-10 00:37:33 +03:00
Client g_clients [ MAX_ENGINE_PLAYERS ] ;
2014-07-30 14:17:46 +04:00
WeaponProperty g_weaponDefs [ MAX_WEAPONS + 1 ] ;
edict_t * g_hostEntity = NULL ;
globalvars_t * g_pGlobals = NULL ;
Experience * g_experienceData = NULL ;
// default tables for personality weapon preferences, overridden by weapons.cfg
int g_normalWeaponPrefs [ NUM_WEAPONS ] =
{ 0 , 2 , 1 , 4 , 5 , 6 , 3 , 12 , 10 , 24 , 25 , 13 , 11 , 8 , 7 , 22 , 23 , 18 , 21 , 17 , 19 , 15 , 17 , 9 , 14 , 16 } ;
int g_rusherWeaponPrefs [ NUM_WEAPONS ] =
{ 0 , 2 , 1 , 4 , 5 , 6 , 3 , 24 , 19 , 22 , 23 , 20 , 21 , 10 , 12 , 13 , 7 , 8 , 11 , 9 , 18 , 17 , 19 , 25 , 15 , 16 } ;
int g_carefulWeaponPrefs [ NUM_WEAPONS ] =
{ 0 , 2 , 1 , 4 , 25 , 6 , 3 , 7 , 8 , 12 , 10 , 13 , 11 , 9 , 24 , 18 , 14 , 17 , 16 , 15 , 19 , 20 , 21 , 22 , 23 , 5 } ;
int g_grenadeBuyPrecent [ NUM_WEAPONS - 23 ] =
{ 95 , 85 , 60 } ;
int g_botBuyEconomyTable [ NUM_WEAPONS - 15 ] =
{ 1900 , 2100 , 2100 , 4000 , 6000 , 7000 , 16000 , 1200 , 800 , 1000 , 3000 } ;
int * g_weaponPrefs [ ] =
{
g_normalWeaponPrefs ,
g_rusherWeaponPrefs ,
g_carefulWeaponPrefs
} ;
// metamod engine & dllapi function tables
metamod_funcs_t gMetaFunctionTable =
{
2016-03-12 14:35:44 +03:00
NULL , // pfnGetEntityAPI ()
NULL , // pfnGetEntityAPI_Post ()
GetEntityAPI2 , // pfnGetEntityAPI2 ()
GetEntityAPI2_Post , // pfnGetEntityAPI2_Post ()
2014-07-30 14:17:46 +04:00
NULL , // pfnGetNewDLLFunctions ()
NULL , // pfnGetNewDLLFunctions_Post ()
GetEngineFunctions , // pfnGetEngineFunctions ()
2014-08-01 22:28:45 +04:00
GetEngineFunctions_Post , // pfnGetEngineFunctions_Post ()
2014-07-30 14:17:46 +04:00
} ;
// metamod plugin information
plugin_info_t Plugin_info =
{
META_INTERFACE_VERSION , // interface version
PRODUCT_NAME , // plugin name
PRODUCT_VERSION , // plugin version
PRODUCT_DATE , // date of creation
PRODUCT_AUTHOR , // plugin author
PRODUCT_URL , // plugin URL
PRODUCT_LOGTAG , // plugin logtag
PT_CHANGELEVEL , // when loadable
PT_ANYTIME , // when unloadable
} ;
// table with all available actions for the bots (filtered in & out in Bot::SetConditions) some of them have subactions included
TaskItem g_taskFilters [ ] =
{
2015-08-15 18:09:15 +03:00
{ TASK_NORMAL , 0 , - 1 , 0.0f , true } ,
{ TASK_PAUSE , 0 , - 1 , 0.0f , false } ,
{ TASK_MOVETOPOSITION , 0 , - 1 , 0.0f , true } ,
{ TASK_FOLLOWUSER , 0 , - 1 , 0.0f , true } ,
{ TASK_WAITFORGO , 0 , - 1 , 0.0f , true } ,
{ TASK_PICKUPITEM , 0 , - 1 , 0.0f , true } ,
{ TASK_CAMP , 0 , - 1 , 0.0f , true } ,
{ TASK_PLANTBOMB , 0 , - 1 , 0.0f , false } ,
{ TASK_DEFUSEBOMB , 0 , - 1 , 0.0f , false } ,
{ TASK_ATTACK , 0 , - 1 , 0.0f , false } ,
{ TASK_HUNTENEMY , 0 , - 1 , 0.0f , false } ,
{ TASK_SEEKCOVER , 0 , - 1 , 0.0f , false } ,
{ TASK_THROWHEGRENADE , 0 , - 1 , 0.0f , false } ,
{ TASK_THROWFLASHBANG , 0 , - 1 , 0.0f , false } ,
{ TASK_THROWSMOKE , 0 , - 1 , 0.0f , false } ,
{ TASK_DOUBLEJUMP , 0 , - 1 , 0.0f , false } ,
{ TASK_ESCAPEFROMBOMB , 0 , - 1 , 0.0f , false } ,
{ TASK_SHOOTBREAKABLE , 0 , - 1 , 0.0f , false } ,
{ TASK_HIDE , 0 , - 1 , 0.0f , false } ,
{ TASK_BLINDED , 0 , - 1 , 0.0f , false } ,
{ TASK_SPRAY , 0 , - 1 , 0.0f , false }
2014-07-30 14:17:46 +04:00
} ;
// weapons and their specifications
WeaponSelect g_weaponSelect [ NUM_WEAPONS + 1 ] =
{
2015-06-04 11:52:48 +03:00
{ WEAPON_KNIFE , " weapon_knife " , " knife.mdl " , 0 , 0 , - 1 , - 1 , 0 , 0 , 0 , 0 , 0 , true } ,
{ WEAPON_USP , " weapon_usp " , " usp.mdl " , 500 , 1 , - 1 , - 1 , 1 , 1 , 2 , 2 , 0 , false } ,
{ WEAPON_GLOCK , " weapon_glock18 " , " glock18.mdl " , 400 , 1 , - 1 , - 1 , 1 , 2 , 1 , 1 , 0 , false } ,
{ WEAPON_DEAGLE , " weapon_deagle " , " deagle.mdl " , 650 , 1 , 2 , 2 , 1 , 3 , 4 , 4 , 2 , false } ,
{ WEAPON_P228 , " weapon_p228 " , " p228.mdl " , 600 , 1 , 2 , 2 , 1 , 4 , 3 , 3 , 0 , false } ,
{ WEAPON_ELITE , " weapon_elite " , " elite.mdl " , 1000 , 1 , 0 , 0 , 1 , 5 , 5 , 5 , 0 , false } ,
{ WEAPON_FIVESEVEN , " weapon_fiveseven " , " fiveseven.mdl " , 750 , 1 , 1 , 1 , 1 , 6 , 5 , 5 , 0 , false } ,
{ WEAPON_M3 , " weapon_m3 " , " m3.mdl " , 1700 , 1 , 2 , - 1 , 2 , 1 , 1 , 1 , 0 , false } ,
{ WEAPON_XM1014 , " weapon_xm1014 " , " xm1014.mdl " , 3000 , 1 , 2 , - 1 , 2 , 2 , 2 , 2 , 0 , false } ,
{ WEAPON_MP5 , " weapon_mp5navy " , " mp5.mdl " , 1500 , 1 , 2 , 1 , 3 , 1 , 2 , 2 , 0 , true } ,
{ WEAPON_TMP , " weapon_tmp " , " tmp.mdl " , 1250 , 1 , 1 , 1 , 3 , 2 , 1 , 1 , 0 , true } ,
{ WEAPON_P90 , " weapon_p90 " , " p90.mdl " , 2350 , 1 , 2 , 1 , 3 , 3 , 4 , 4 , 0 , true } ,
{ WEAPON_MAC10 , " weapon_mac10 " , " mac10.mdl " , 1400 , 1 , 0 , 0 , 3 , 4 , 1 , 1 , 0 , true } ,
{ WEAPON_UMP45 , " weapon_ump45 " , " ump45.mdl " , 1700 , 1 , 2 , 2 , 3 , 5 , 3 , 3 , 0 , true } ,
{ WEAPON_AK47 , " weapon_ak47 " , " ak47.mdl " , 2500 , 1 , 0 , 0 , 4 , 1 , 2 , 2 , 2 , true } ,
{ WEAPON_SG552 , " weapon_sg552 " , " sg552.mdl " , 3500 , 1 , 0 , - 1 , 4 , 2 , 4 , 4 , 2 , true } ,
{ WEAPON_M4A1 , " weapon_m4a1 " , " m4a1.mdl " , 3100 , 1 , 1 , 1 , 4 , 3 , 3 , 3 , 2 , true } ,
{ WEAPON_GALIL , " weapon_galil " , " galil.mdl " , 2000 , 1 , 0 , 0 , 4 , - 1 , 1 , 1 , 2 , true } ,
{ WEAPON_FAMAS , " weapon_famas " , " famas.mdl " , 2250 , 1 , 1 , 1 , 4 , - 1 , 1 , 1 , 2 , true } ,
{ WEAPON_AUG , " weapon_aug " , " aug.mdl " , 3500 , 1 , 1 , 1 , 4 , 4 , 4 , 4 , 2 , true } ,
{ WEAPON_SCOUT , " weapon_scout " , " scout.mdl " , 2750 , 1 , 2 , 0 , 4 , 5 , 3 , 2 , 3 , false } ,
{ WEAPON_AWP , " weapon_awp " , " awp.mdl " , 4750 , 1 , 2 , 0 , 4 , 6 , 5 , 6 , 3 , false } ,
{ WEAPON_G3SG1 , " weapon_g3sg1 " , " g3sg1.mdl " , 5000 , 1 , 0 , 2 , 4 , 7 , 6 , 6 , 3 , false } ,
{ WEAPON_SG550 , " weapon_sg550 " , " sg550.mdl " , 4200 , 1 , 1 , 1 , 4 , 8 , 5 , 5 , 3 , false } ,
{ WEAPON_M249 , " weapon_m249 " , " m249.mdl " , 5750 , 1 , 2 , 1 , 5 , 1 , 1 , 1 , 2 , true } ,
{ WEAPON_SHIELD , " weapon_shield " , " shield.mdl " , 2200 , 0 , 1 , 1 , 8 , - 1 , 8 , 8 , 0 , false } ,
{ 0 , " " , " " , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , false }
2014-07-30 14:17:46 +04:00
} ;
// bot menus
MenuText g_menus [ 21 ] =
{
// main menu
{
0x2ff ,
2015-06-04 11:52:48 +03:00
" \\ yMain Menu \\ w \v \v "
" 1. Control Bots \v "
2014-07-30 14:17:46 +04:00
" 2. Features \v \v "
" 3. Fill Server \v "
" 4. End Round \v \v "
" 0. Exit "
} ,
// bot features menu
{
0x25f ,
2015-06-04 11:52:48 +03:00
" \\ yBots Features \\ w \v \v "
2014-07-30 14:17:46 +04:00
" 1. Weapon Mode Menu \v "
" 2. Waypoint Menu \v "
" 3. Select Personality \v \v "
" 4. Toggle Debug Mode \v "
" 5. Command Menu \v \v "
" 0. Exit "
} ,
// bot control menu
{
0x2ff ,
2015-06-04 11:52:48 +03:00
" \\ yBots Control Menu \\ w \v \v "
2014-07-30 14:17:46 +04:00
" 1. Add a Bot, Quick \v "
" 2. Add a Bot, Specified \v \v "
" 3. Remove Random Bot \v "
" 4. Remove All Bots \v \v "
" 5. Remove Bot Menu \v \v "
" 0. Exit "
} ,
// weapon mode select menu
{
0x27f ,
2015-06-04 11:52:48 +03:00
" \\ yBots Weapon Mode \\ w \v \v "
2014-07-30 14:17:46 +04:00
" 1. Knives only \v "
" 2. Pistols only \v "
" 3. Shotguns only \v "
" 4. Machine Guns only \v "
" 5. Rifles only \v "
" 6. Sniper Weapons only \v "
" 7. All Weapons \v \v "
" 0. Exit "
} ,
// personality select menu
{
0x20f ,
2015-06-04 11:52:48 +03:00
" \\ yBots Personality \\ w \v \v "
2014-07-30 14:17:46 +04:00
" 1. Random \v "
" 2. Normal \v "
" 3. Aggressive \v "
" 4. Careful \v \v "
" 0. Exit "
} ,
2015-06-04 11:52:48 +03:00
// difficulty select menu
2014-07-30 14:17:46 +04:00
{
0x23f ,
2015-06-04 11:52:48 +03:00
" \\ yBots Difficulty Level \\ w \v \v "
" 1. Newbie \v "
" 2. Average \v "
" 3. Normal \v "
" 4. Professional \v "
2015-06-14 13:48:39 +03:00
" 5. Godlike \v \v "
2014-07-30 14:17:46 +04:00
" 0. Exit "
} ,
// team select menu
{
0x213 ,
" \\ ySelect a team \\ w \v \v "
" 1. Terrorist Force \v "
" 2. Counter-Terrorist Force \v \v "
" 5. Auto-select \v \v "
" 0. Exit "
} ,
// terrorist model select menu
{
0x21f ,
" \\ ySelect an appearance \\ w \v \v "
" 1. Phoenix Connexion \v "
" 2. L337 Krew \v "
" 3. Arctic Avengers \v "
" 4. Guerilla Warfare \v \v "
" 5. Auto-select \v \v "
" 0. Exit "
} ,
// counter-terrirust model select menu
{
0x21f ,
" \\ ySelect an appearance \\ w \v \v "
" 1. Seal Team 6 (DEVGRU) \v "
" 2. German GSG-9 \v "
" 3. UK SAS \v "
" 4. French GIGN \v \v "
" 5. Auto-select \v \v "
" 0. Exit "
} ,
// main waypoint menu
{
0x3ff ,
" \\ yWaypoint Operations (Page 1) \\ w \v \v "
" 1. Show/Hide waypoints \v "
" 2. Cache waypoint \v "
" 3. Create path \v "
" 4. Delete path \v "
" 5. Add waypoint \v "
" 6. Delete waypoint \v "
" 7. Set Autopath Distance \v "
" 8. Set Radius \v \v "
" 9. Next... \v \v "
" 0. Exit "
} ,
// main waypoint menu (page 2)
{
0x3ff ,
" \\ yWaypoint Operations (Page 2) \\ w \v \v "
" 1. Waypoint stats \v "
" 2. Autowaypoint on/off \v "
" 3. Set flags \v "
" 4. Save waypoints \v "
" 5. Save without checking \v "
" 6. Load waypoints \v "
" 7. Check waypoints \v "
" 8. Noclip cheat on/off \v \v "
" 9. Previous... \v \v "
" 0. Exit "
} ,
// select waypoint radius menu
{
0x3ff ,
" \\ yWaypoint Radius \\ w \v \v "
" 1. SetRadius 0 \v "
" 2. SetRadius 8 \v "
" 3. SetRadius 16 \v "
" 4. SetRadius 32 \v "
" 5. SetRadius 48 \v "
" 6. SetRadius 64 \v "
" 7. SetRadius 80 \v "
" 8. SetRadius 96 \v "
" 9. SetRadius 128 \v \v "
" 0. Exit "
} ,
// waypoint add menu
{
0x3ff ,
" \\ yWaypoint Type \\ w \v \v "
" 1. Normal \v "
" \\ r2. Terrorist Important \v "
" 3. Counter-Terrorist Important \v "
" \\ w4. Block with hostage / Ladder \v "
" \\ y5. Rescue Zone \v "
" \\ w6. Camping \v "
" 7. Camp End \v "
" \\ r8. Map Goal \v "
" \\ w9. Jump \v \v "
" 0. Exit "
} ,
// set waypoint flag menu
{
0x2ff ,
" \\ yToggle Waypoint Flags \\ w \v \v "
" 1. Block with Hostage \v "
" 2. Terrorists Specific \v "
" 3. CTs Specific \v "
" 4. Use Elevator \v "
" 5. Sniper Point ( \\ yFor Camp Points Only! \\ w) \v \v "
" 0. Exit "
} ,
// kickmenu #1
{
0x0 ,
NULL ,
} ,
// kickmenu #2
{
0x0 ,
NULL ,
} ,
// kickmenu #3
{
0x0 ,
NULL ,
} ,
// kickmenu #4
{
0x0 ,
NULL ,
} ,
// command menu
{
0x23f ,
" \\ yBot Command Menu \\ w \v \v "
" 1. Make Double Jump \v "
" 2. Finish Double Jump \v \v "
" 3. Drop the C4 Bomb \v "
" 4. Drop the Weapon \v \v "
" 0. Exit "
} ,
// auto-path max distance
{
0x27f ,
" \\ yAutoPath Distance \\ w \v \v "
" 1. Distance 0 \v "
" 2. Distance 100 \v "
" 3. Distance 130 \v "
" 4. Distance 160 \v "
" 5. Distance 190 \v "
" 6. Distance 220 \v "
" 7. Distance 250 (Default) \v \v "
" 0. Exit "
} ,
// path connections
{
0x207 ,
" \\ yCreate Path (Choose Direction) \\ w \v \v "
" 1. Outgoing Path \v "
" 2. Incoming Path \v "
" 3. Bidirectional (Both Ways) \v \v "
" 0. Exit "
}
2016-03-01 22:52:17 +03:00
} ;
2016-08-27 23:37:27 +03:00
void WelcomeMessage : : VerifyMessageSent ( void )
{
if ( m_msgReceived )
return ;
static Array < String > sentences ;
if ( ! ( g_gameFlags & ( GAME_MOBILITY | GAME_XASH ) ) & & sentences . IsEmpty ( ) )
{
// add default messages
sentences . Push ( " hello user,communication is acquired " ) ;
sentences . Push ( " your presence is acknowledged " ) ;
sentences . Push ( " high man, your in command now " ) ;
sentences . Push ( " blast your hostile for good " ) ;
sentences . Push ( " high man, kill some idiot here " ) ;
sentences . Push ( " is there a doctor in the area " ) ;
sentences . Push ( " warning, experimental materials detected " ) ;
sentences . Push ( " high amigo, shoot some but " ) ;
sentences . Push ( " attention, hours of work software, detected " ) ;
sentences . Push ( " time for some bad ass explosion " ) ;
sentences . Push ( " bad ass son of a breach device activated " ) ;
sentences . Push ( " high, do not question this great service " ) ;
sentences . Push ( " engine is operative, hello and goodbye " ) ;
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 " ) ;
}
if ( IsAlive ( g_hostEntity ) & & ! m_msgReceived & & m_receiveTimer < 1.0f & & ( g_numWaypoints > 0 ? m_gameCommenced : true ) )
m_receiveTimer = engine . Time ( ) + 4.0f ; // receive welcome message in four seconds after game has commencing
if ( m_receiveTimer > 0.0f & & m_receiveTimer < engine . Time ( ) & & ! m_msgReceived & & ( g_numWaypoints > 0 ? m_gameCommenced : true ) )
{
if ( ! ( g_gameFlags & ( GAME_MOBILITY | GAME_XASH ) ) )
engine . IssueCmd ( " speak \" %s \" " , const_cast < char * > ( sentences . GetRandomElement ( ) . GetBuffer ( ) ) ) ;
engine . ChatPrintf ( " ----- %s v%s (Build: %u), {%s}, (c) 2016, by %s (%s)----- " , PRODUCT_NAME , PRODUCT_VERSION , GenerateBuildNumber ( ) , PRODUCT_DATE , PRODUCT_AUTHOR , PRODUCT_URL ) ;
MESSAGE_BEGIN ( MSG_ONE , SVC_TEMPENTITY , NULL , g_hostEntity ) ;
WRITE_BYTE ( TE_TEXTMESSAGE ) ;
WRITE_BYTE ( 1 ) ;
WRITE_SHORT ( FixedSigned16 ( - 1 , 1 < < 13 ) ) ;
WRITE_SHORT ( FixedSigned16 ( - 1 , 1 < < 13 ) ) ;
WRITE_BYTE ( 2 ) ;
WRITE_BYTE ( Random . Long ( 33 , 255 ) ) ;
WRITE_BYTE ( Random . Long ( 33 , 255 ) ) ;
WRITE_BYTE ( Random . Long ( 33 , 255 ) ) ;
WRITE_BYTE ( 0 ) ;
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.0078125f , 1 < < 8 ) ) ;
WRITE_SHORT ( FixedUnsigned16 ( 2.0f , 1 < < 8 ) ) ;
WRITE_SHORT ( FixedUnsigned16 ( 6.0f , 1 < < 8 ) ) ;
WRITE_SHORT ( FixedUnsigned16 ( 0.1f , 1 < < 8 ) ) ;
WRITE_STRING ( FormatBuffer ( " \n Server is running YaPB v%s (Build: %u) \n Developed by %s \n \n %s " , PRODUCT_VERSION , GenerateBuildNumber ( ) , PRODUCT_AUTHOR , waypoints . GetInfo ( ) ) ) ;
MESSAGE_END ( ) ;
m_receiveTimer = 0.0 ;
m_msgReceived = true ;
}
}