This commit is contained in:
ineed bots 2023-12-23 20:21:38 -06:00
parent 4db437222c
commit aae66eed8d
4 changed files with 1505 additions and 5 deletions

View File

@ -22,7 +22,9 @@ bot_give_loadout()
self SetPlayerRenderOptions( int( self.pers[ "bot" ][ "class_render_opts" ] ) );
if ( !isDefined( self.bot ) )
{
self.bot = [];
}
self.bot[ "specialty1" ] = "specialty_null";
self.bot[ "specialty2" ] = "specialty_null";
@ -36,7 +38,9 @@ bot_give_loadout()
tokens = strtok( id[ "reference" ], "|" );
for ( i = 0; i < tokens.size; i++ )
{
self setPerk( tokens[ i ] );
}
}
switch ( self.pers[ "bot" ][ "class_perk1" ] )
@ -82,7 +86,9 @@ bot_give_loadout()
tokens = strtok( id[ "reference" ], "|" );
for ( i = 0; i < tokens.size; i++ )
{
self setPerk( tokens[ i ] );
}
}
if ( self.pers[ "bot" ][ "class_perk3" ] != "" && GetDvarInt( #"scr_game_perks" ) )
@ -93,19 +99,25 @@ bot_give_loadout()
tokens = strtok( id[ "reference" ], "|" );
for ( i = 0; i < tokens.size; i++ )
{
self setPerk( tokens[ i ] );
}
}
self takeAllWeapons();
if ( getDvarInt( "bots_play_knife" ) )
{
self GiveWeapon( "knife_mp" );
}
weap = self.pers[ "bot" ][ "class_primary" ];
if ( weap == "" )
{
weap = "ak47_mp";
}
primaryTokens = strtok( self.pers[ "bot" ][ "class_primary" ], "_" );
self.pers[ "primaryWeapon" ] = primaryTokens[ 0 ];
@ -113,19 +125,25 @@ bot_give_loadout()
weap = self.pers[ "bot" ][ "class_primary" ];
if ( GetDvarInt( #"scr_disable_attachments" ) )
{
weap = self.pers[ "primaryWeapon" ] + "_mp";
}
self GiveWeapon( weap, 0, int( self.pers[ "bot" ][ "class_primary_opts" ] ) );
if ( self hasPerk( "specialty_extraammo" ) )
{
self giveMaxAmmo( weap );
}
if ( self.pers[ "bot" ][ "class_secondary" ] != "" )
{
self GiveWeapon( self.pers[ "bot" ][ "class_secondary" ], 0, int( self.pers[ "bot" ][ "class_secondary_opts" ] ) );
if ( self hasPerk( "specialty_extraammo" ) )
{
self giveMaxAmmo( self.pers[ "bot" ][ "class_secondary" ] );
}
}
self SetActionSlot( 3, "altMode" );
@ -145,9 +163,13 @@ bot_give_loadout()
self GiveWeapon( self.pers[ "bot" ][ "class_lethal" ] );
if ( self hasPerk( "specialty_twogrenades" ) )
{
self SetWeaponAmmoClip( self.pers[ "bot" ][ "class_lethal" ], 2 );
}
else
{
self SetWeaponAmmoClip( self.pers[ "bot" ][ "class_lethal" ], 1 );
}
self SwitchToOffhand( self.pers[ "bot" ][ "class_lethal" ] );
}
@ -157,11 +179,17 @@ bot_give_loadout()
self giveWeapon( self.pers[ "bot" ][ "class_tacticle" ] );
if ( self.pers[ "bot" ][ "class_tacticle" ] == "willy_pete_mp" )
{
self SetWeaponAmmoClip( self.pers[ "bot" ][ "class_tacticle" ], 1 );
}
else if ( self hasPerk( "specialty_twogrenades" ) )
{
self SetWeaponAmmoClip( self.pers[ "bot" ][ "class_tacticle" ], 3 );
}
else
{
self SetWeaponAmmoClip( self.pers[ "bot" ][ "class_tacticle" ], 2 );
}
self setOffhandSecondaryClass( self.pers[ "bot" ][ "class_tacticle" ] );
}
@ -184,10 +212,14 @@ bot_get_prestige()
player = level.players[ i ];
if ( !isDefined( player.team ) )
{
continue;
}
if ( player is_bot() )
{
continue;
}
p = player maps\mp\gametypes\_persistence::statGet( "plevel" );
break;
@ -226,7 +258,9 @@ bot_rank()
self maps\mp\gametypes\_rank::syncxpstat();
if ( !level.gameEnded )
{
level waittill( "game_ended" );
}
self.pers[ "bot" ][ "rankxp" ] = self.pers[ "rankxp" ];
}
@ -282,13 +316,17 @@ bot_set_class()
case 3:
if ( rank >= 1 )
{
_class = "CLASS_LMG";
}
break;
case 4:
if ( rank >= 2 )
{
_class = "CLASS_SNIPER";
}
break;
}
@ -316,31 +354,51 @@ bot_set_class()
self bot_get_random_weapon( "equipment", rank );
if ( rank >= 21 )
{
camo = self bot_random_camo();
}
else
{
camo = 0;
}
if ( rank >= 18 )
{
tag = self bot_random_tag();
}
else
{
tag = 0;
}
if ( rank >= 15 )
{
emblem = self bot_random_emblem();
}
else
{
emblem = 0;
}
if ( isSubStr( self.pers[ "bot" ][ "class_primary" ], "_elbit_" ) || isSubStr( self.pers[ "bot" ][ "class_primary" ], "_reflex_" ) )
{
if ( rank >= 24 )
{
reticle = self bot_random_reticle();
}
else
{
reticle = 0;
}
if ( rank >= 27 )
{
lens = self bot_random_lens();
}
else
{
lens = 0;
}
}
else
{
@ -351,15 +409,21 @@ bot_set_class()
self.pers[ "bot" ][ "class_primary_opts" ] = self calcWeaponOptions( camo, lens, reticle, tag, emblem );
if ( rank >= 30 )
{
face = self bot_random_face();
}
else
{
face = 0;
}
self.pers[ "bot" ][ "class_render_opts" ] = self calcPlayerOptions( face, 0 );
}
if ( !GetDvarInt( "bots_loadout_allow_op" ) && isSubStr( self.pers[ "bot" ][ "class_perk3" ], "perk_second_chance" ) )
{
self.pers[ "bot" ][ "class_perk3" ] = "";
}
}
/*
@ -368,7 +432,9 @@ bot_set_class()
bot_get_random_weapon( slot, rank )
{
if ( !isDefined( level.bot_weapon_ids ) )
{
level.bot_weapon_ids = [];
}
if ( !IsDefined( level.bot_weapon_ids[ slot ] ) )
{
@ -382,13 +448,19 @@ bot_get_random_weapon( slot, rank )
id = level.tbl_weaponIDs[ key ];
if ( id[ "reference" ] == "weapon_null" )
{
continue;
}
if ( isSubStr( id[ "reference" ], "dw" ) )
{
continue;
}
if ( id[ "cost" ] == "-1" )
{
continue;
}
if ( id[ "slot" ] == slot )
{
@ -401,17 +473,23 @@ bot_get_random_weapon( slot, rank )
diff = self GetBotDiffNum();
if ( slot == "equipment" && self.pers[ "bot" ][ "cod_points" ] < 2000 )
{
return;
}
for ( ;; )
{
id = PickRandom( level.bot_weapon_ids[ slot ] );
if ( !isDefined( id ) )
{
return;
}
if ( !bot_weapon_unlocked( id, rank ) )
{
continue;
}
if ( reason )
{
@ -419,13 +497,17 @@ bot_get_random_weapon( slot, rank )
{
case "willy_pete":
if ( self.pers[ "bot" ][ "cod_points" ] >= 1500 )
{
continue;
}
break;
case "camera_spike":
if ( self.pers[ "bot" ][ "cod_points" ] >= 2500 )
{
continue;
}
break;
@ -475,27 +557,39 @@ bot_get_random_weapon( slot, rank )
}
if ( id[ "reference" ] == "camera_spike" && self IsSplitScreen() )
{
continue;
}
if ( id[ "reference" ] == level.tacticalInsertionWeapon && level.disable_tacinsert )
{
continue;
}
cost = bot_weapon_cost( id );
if ( cost > 0 && self.pers[ "bot" ][ "cod_points" ] < cost )
{
continue;
}
self.pers[ "bot" ][ "cod_points" ] = self.pers[ "bot" ][ "cod_points" ] - cost;
maxAttachs = 1;
if ( isSubStr( self.pers[ "bot" ][ "class_perk2" ], "perk_professional" ) && slot == "primary" )
{
maxAttachs = 2;
}
if ( RandomFloatRange( 0, 1 ) < ( ( rank / level.maxRank ) + 0.1 ) )
{
weap = bot_random_attachments( id[ "reference" ], id[ "attachment" ], maxAttachs );
}
else
{
weap = id[ "reference" ];
}
weap = bot_validate_weapon( weap );
weap = weap + "_mp";
@ -539,28 +633,40 @@ bot_get_random_perk( slot, rank )
id = PickRandom( level.allowedPerks[ 0 ] );
if ( !isDefined( id ) )
{
return;
}
id = level.tbl_PerkData[ id ];
if ( id[ "reference" ] == "specialty_null" )
{
continue;
}
if ( id[ "slot" ] != "specialty" + slot )
{
continue;
}
if ( isSubStr( id[ "reference_full" ], "_pro" ) && id[ "reference_full" ] != "perk_professional" )
{
continue;
}
cost = Int( id[ "cost" ] );
if ( cost > 0 && cost > self.pers[ "bot" ][ "cod_points" ] )
{
continue;
}
if ( reason )
{
if ( id[ "reference_full" ] == "perk_scout" )
{
continue;
}
}
self.pers[ "bot" ][ "cod_points" ] = self.pers[ "bot" ][ "cod_points" ] - cost;
@ -588,14 +694,18 @@ bot_random_face()
face = randomint( 25 );
if ( face == 0 )
{
return face;
}
if ( face >= 17 )
{
if ( face >= 21 ) // pres faces
{
if ( self.pers[ "bot" ][ "cod_points" ] < 500 )
{
continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 500;
@ -605,7 +715,9 @@ bot_random_face()
if ( face == 17 )
{
if ( self.pers[ "bot" ][ "cod_points" ] < 1500 )
{
continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 1500;
@ -615,7 +727,9 @@ bot_random_face()
if ( face == 18 )
{
if ( self.pers[ "bot" ][ "cod_points" ] < 3500 )
{
continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 3500;
@ -625,7 +739,9 @@ bot_random_face()
if ( face == 19 )
{
if ( self.pers[ "bot" ][ "cod_points" ] < 5500 )
{
continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 5500;
@ -633,7 +749,9 @@ bot_random_face()
}
if ( self.pers[ "bot" ][ "cod_points" ] < 7500 )
{
continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 7500;
@ -641,7 +759,9 @@ bot_random_face()
}
if ( self.pers[ "bot" ][ "cod_points" ] < 500 )
{
continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 500;
@ -659,10 +779,14 @@ bot_random_lens()
lens = randomint( 6 );
if ( lens == 0 )
{
return lens;
}
if ( self.pers[ "bot" ][ "cod_points" ] < 500 )
{
continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 500;
@ -680,10 +804,14 @@ bot_random_reticle()
ret = randomint( 40 );
if ( ret == 0 )
{
return ret;
}
if ( self.pers[ "bot" ][ "cod_points" ] < 500 )
{
continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 500;
@ -701,10 +829,14 @@ bot_random_tag()
tag = randomInt( 2 );
if ( tag == 0 )
{
return tag;
}
if ( self.pers[ "bot" ][ "cod_points" ] < 1000 )
{
continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 1000;
@ -722,10 +854,14 @@ bot_random_emblem()
emblem = randomInt( 2 );
if ( emblem == 0 )
{
return emblem;
}
if ( self.pers[ "bot" ][ "cod_points" ] < 1000 )
{
continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 1000;
@ -743,12 +879,16 @@ bot_random_camo()
camo = randomInt( 16 );
if ( camo == 0 )
{
return camo;
}
if ( camo == 15 ) // gold
{
if ( self.pers[ "bot" ][ "cod_points" ] < 50000 )
{
continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 50000;
@ -756,7 +896,9 @@ bot_random_camo()
}
if ( self.pers[ "bot" ][ "cod_points" ] < 250 )
{
continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 250;
@ -777,15 +919,21 @@ bot_weapon_cost( id )
slot = "primary";
if ( id[ "group" ] == "weapon_pistol" )
{
slot = "secondary";
}
for ( i = 0; i < level.bot_weapon_ids[ slot ].size; i++ )
{
if ( id[ "reference" ] == level.bot_weapon_ids[ slot ][ i ][ "reference" ] )
{
continue;
}
if ( id[ "group" ] != level.bot_weapon_ids[ slot ][ i ][ "group" ] )
{
continue;
}
cost += int( level.bot_weapon_ids[ slot ][ i ][ "cost" ] );
}
@ -829,7 +977,9 @@ bot_weapon_unlocked( id, rank )
unlock = Int( id[ "unlock_level" ] );
if ( unlock <= 3 )
{
return true;
}
return ( rank >= unlock );
}
@ -885,24 +1035,34 @@ bot_validate_weapon( weap )
tokens = strtok( weap, "_" );
if ( tokens.size <= 1 )
{
return weapon;
}
if ( tokens.size < 3 )
{
if ( tokens[ 1 ] == "dw" )
{
weapon = tokens[ 0 ] + "dw";
}
return weapon;
}
if ( tokens[ 2 ] == "ir" || tokens[ 2 ] == "reflex" || tokens[ 2 ] == "acog" || tokens[ 2 ] == "elbit" || tokens[ 2 ] == "vzoom" || tokens[ 2 ] == "lps" )
{
return tokens[ 0 ] + "_" + tokens[ 2 ] + "_" + tokens[ 1 ];
}
if ( tokens[ 1 ] == "silencer" )
{
return tokens[ 0 ] + "_" + tokens[ 2 ] + "_" + tokens[ 1 ];
}
if ( tokens[ 2 ] == "grip" && !( tokens[ 1 ] == "ir" || tokens[ 1 ] == "reflex" || tokens[ 1 ] == "acog" || tokens[ 1 ] == "elbit" || tokens[ 1 ] == "vzoom" || tokens[ 1 ] == "lps" ) )
{
return tokens[ 0 ] + "_" + tokens[ 2 ] + "_" + tokens[ 1 ];
}
return weapon;
}
@ -929,7 +1089,9 @@ bot_random_attachments( weap, atts, num )
attachments = array_remove( attachments, attachment );
if ( attachment == "" )
{
return weapon;
}
if ( reason )
{
@ -959,14 +1121,18 @@ bot_random_attachments( weap, atts, num )
cost = bot_attachment_cost( attachment );
if ( cost > 0 && cost > self.pers[ "bot" ][ "cod_points" ] )
{
continue;
}
self.pers[ "bot" ][ "cod_points" ] -= cost;
weapon = weapon + "_" + attachment;
if ( attachment == "dw" || attachment == "gl" || attachment == "ft" || attachment == "mk" || num == 1 )
{
return weapon;
}
break;
}
@ -982,7 +1148,9 @@ bot_random_attachments( weap, atts, num )
attachments = array_remove( attachments, _attachment );
if ( _attachment == "" )
{
return weapon;
}
if ( reason )
{
@ -1010,18 +1178,26 @@ bot_random_attachments( weap, atts, num )
}
if ( _attachment == "dw" || _attachment == "gl" || _attachment == "ft" || _attachment == "mk" )
{
continue;
}
if ( ( attachment == "ir" || attachment == "reflex" || attachment == "acog" || attachment == "elbit" || attachment == "vzoom" || attachment == "lps" ) && ( _attachment == "ir" || _attachment == "reflex" || _attachment == "acog" || _attachment == "elbit" || _attachment == "vzoom" || _attachment == "lps" ) )
{
continue;
}
if ( ( attachment == "dualclip" || attachment == "extclip" || attachment == "rf" ) && ( _attachment == "dualclip" || _attachment == "extclip" || _attachment == "rf" ) )
{
continue;
}
cost = bot_attachment_cost( _attachment );
if ( cost > 0 && cost > self.pers[ "bot" ][ "cod_points" ] )
{
continue;
}
self.pers[ "bot" ][ "cod_points" ] -= cost;
weapon = weapon + "_" + _attachment;
@ -1076,7 +1252,9 @@ bot_get_cod_points()
}
if ( !isDefined( players[ i ].pers[ "currencyspent" ] ) || !isDefined( players[ i ].pers[ "codpoints" ] ) )
{
continue;
}
total_points[ total_points.size ] = players[ i ].pers[ "currencyspent" ] + players[ i ].pers[ "codpoints" ];
}
@ -1118,10 +1296,14 @@ bot_get_rank()
for ( i = 0; i < players.size; i++ )
{
if ( players[ i ] == self )
{
continue;
}
if ( !IsDefined( players[ i ].pers[ "rank" ] ) )
{
continue;
}
if ( players[ i ] is_bot() )
{
@ -1204,7 +1386,9 @@ bot_setKillstreaks()
killstreak = PickRandom( allowed_killstreaks );
if ( !isDefined( killstreak ) )
{
break;
}
allowed_killstreaks = array_remove( allowed_killstreaks, killstreak );

File diff suppressed because it is too large Load Diff

View File

@ -17,12 +17,18 @@ wait_for_builtins()
for ( i = 0; i < 20; i++ )
{
if ( isDefined( level.bot_builtins ) )
{
return true;
}
if ( i < 18 )
{
waittillframeend;
}
else
{
wait 0.05;
}
}
return false;
@ -197,7 +203,9 @@ getBotArray()
player = level.players[ i ];
if ( !player is_bot() )
{
continue;
}
result[ result.size ] = player;
}
@ -227,12 +235,18 @@ Round( x )
if ( abs( x ) - abs( y ) > 0.5 )
{
if ( x < 0 )
{
return y - 1;
}
else
{
return y + 1;
}
}
else
{
return y;
}
}
/*
@ -241,7 +255,9 @@ Round( x )
PickRandom( arr )
{
if ( !arr.size )
{
return undefined;
}
return arr[ randomInt( arr.size ) ];
}
@ -346,7 +362,9 @@ GetBotDiffNum()
isWeaponAltmode( weap )
{
if ( isStrStart( weap, "gl_" ) || isStrStart( weap, "ft_" ) || isStrStart( weap, "mk_" ) )
{
return true;
}
return false;
}
@ -364,24 +382,36 @@ bot_lookat( pos, time, vel, doAimPredict )
level endon ( "game_ended" );
if ( level.gameEnded || level.inPrematchPeriod || self BotIsFrozen() || !getDvarInt( "bots_play_aim" ) )
{
return;
}
if ( !isDefined( pos ) )
{
return;
}
if ( !isDefined( doAimPredict ) )
{
doAimPredict = false;
}
if ( !isDefined( time ) )
{
time = 0.05;
}
if ( !isDefined( vel ) )
{
vel = ( 0, 0, 0 );
}
steps = int( time * 20 );
if ( steps < 1 )
{
steps = 1;
}
myEye = self GetEye(); // get our eye pos
@ -450,10 +480,14 @@ getValidTube()
weap = weaps[ i ];
if ( !self getAmmoCount( weap ) )
{
continue;
}
if ( ( isSubStr( weap, "gl_" ) && !isSubStr( weap, "_gl_" ) ) || weap == "china_lake_mp" )
{
return weap;
}
}
return undefined;
@ -464,29 +498,37 @@ getValidTube()
*/
waittill_any_timeout( timeOut, string1, string2, string3, string4, string5 )
{
if ( ( !isdefined( string1 ) || string1 != "death" ) &&
( !isdefined( string2 ) || string2 != "death" ) &&
( !isdefined( string3 ) || string3 != "death" ) &&
( !isdefined( string4 ) || string4 != "death" ) &&
( !isdefined( string5 ) || string5 != "death" ) )
if ( ( !isdefined( string1 ) || string1 != "death" ) && ( !isdefined( string2 ) || string2 != "death" ) && ( !isdefined( string3 ) || string3 != "death" ) && ( !isdefined( string4 ) || string4 != "death" ) && ( !isdefined( string5 ) || string5 != "death" ) )
{
self endon( "death" );
}
ent = spawnstruct();
if ( isdefined( string1 ) )
{
self thread waittill_string( string1, ent );
}
if ( isdefined( string2 ) )
{
self thread waittill_string( string2, ent );
}
if ( isdefined( string3 ) )
{
self thread waittill_string( string3, ent );
}
if ( isdefined( string4 ) )
{
self thread waittill_string( string4, ent );
}
if ( isdefined( string5 ) )
{
self thread waittill_string( string5, ent );
}
ent thread _timeout( timeOut );
@ -514,7 +556,9 @@ getBotToKick()
bots = getBotArray();
if ( !isDefined( bots ) || !isDefined( bots.size ) || bots.size <= 0 || !isDefined( bots[ 0 ] ) )
{
return undefined;
}
tokick = undefined;
axis = 0;
@ -527,14 +571,22 @@ getBotToKick()
bot = bots[ i ];
if ( !isDefined( bot ) || !isDefined( bot.team ) )
{
continue;
}
if ( bot.team == "allies" )
{
allies++;
}
else if ( bot.team == "axis" )
{
axis++;
}
else // choose bots that are not on a team first
{
return bot;
}
}
// search for a bot on the other team
@ -548,7 +600,9 @@ getBotToKick()
team = "allies";
if ( axis > allies )
{
team = "axis";
}
}
else
{
@ -561,16 +615,22 @@ getBotToKick()
bot = bots[ i ];
if ( !isDefined( bot ) || !isDefined( bot.team ) )
{
continue;
}
if ( bot.team != team )
{
continue;
}
tokick = bot;
}
if ( isDefined( tokick ) )
{
return tokick;
}
// just kick lowest skill
for ( i = 0; i < bots.size; i++ )
@ -578,7 +638,9 @@ getBotToKick()
bot = bots[ i ];
if ( !isDefined( bot ) || !isDefined( bot.team ) )
{
continue;
}
tokick = bot;
}
@ -594,36 +656,48 @@ bot_wait_for_host()
host = undefined;
while ( !isDefined( level ) || !isDefined( level.players ) )
{
wait 0.05;
}
for ( i = getDvarFloat( "bots_main_waitForHostTime" ); i > 0; i -= 0.05 )
{
host = GetHostPlayer();
if ( isDefined( host ) )
{
break;
}
wait 0.05;
}
if ( !isDefined( host ) )
{
return;
}
for ( i = getDvarFloat( "bots_main_waitForHostTime" ); i > 0; i -= 0.05 )
{
if ( IsDefined( host.pers[ "team" ] ) )
{
break;
}
wait 0.05;
}
if ( !IsDefined( host.pers[ "team" ] ) )
{
return;
}
for ( i = getDvarFloat( "bots_main_waitForHostTime" ); i > 0; i -= 0.05 )
{
if ( host.pers[ "team" ] == "allies" || host.pers[ "team" ] == "axis" )
{
break;
}
wait 0.05;
}
@ -701,7 +775,9 @@ botStopMove2( what )
self endon( "botStopMove" );
if ( !what )
{
return;
}
og = self.origin;
@ -879,7 +955,9 @@ bot_onUsePlantObjectFix( player )
for ( index = 0; index < level.bombZones.size; index++ )
{
if ( level.bombZones[ index ] == self )
{
continue;
}
level.bombZones[ index ] maps\mp\gametypes\_gameobjects::disableObject();
}
@ -940,7 +1018,9 @@ bot_bombPlanted( destroyedObj, player )
for ( index = 0; index < level.players.size; index++ )
{
if ( isDefined( level.players[ index ].carryIcon ) )
{
level.players[ index ].carryIcon destroyElem();
}
}
trace = bulletTrace( player.origin + ( 0, 0, 20 ), player.origin - ( 0, 0, 2000 ), false, player );
@ -995,7 +1075,9 @@ bot_bombPlanted( destroyedObj, player )
destroyedObj.visuals[ 0 ] maps\mp\gametypes\_globallogic_utils::stopTickingSound();
if ( level.gameEnded || level.bombDefused )
{
return;
}
level.bombExploded = true;
@ -1012,7 +1094,9 @@ bot_bombPlanted( destroyedObj, player )
player maps\mp\gametypes\_persistence::statAddWithGameType( "DESTRUCTIONS", 1 );
}
else
{
destroyedObj.visuals[ 0 ] radiusDamage( explosionOrigin, 512, 200, 20, undefined, "MOD_EXPLOSIVE", "briefcase_bomb_mp" );
}
rot = randomfloat( 360 );
explosionEffect = spawnFx( level._effect[ "bombexplosion" ], explosionOrigin + ( 0, 0, 50 ), ( 0, 0, 1 ), ( cos( rot ), sin( rot ), 0 ) );
@ -1022,10 +1106,14 @@ bot_bombPlanted( destroyedObj, player )
// thread maps\mp\gametypes\_globallogic_audio::set_music_on_team( "SILENT", "both" );
if ( isDefined( destroyedObj.exploderIndex ) )
{
exploder( destroyedObj.exploderIndex );
}
for ( index = 0; index < level.bombZones.size; index++ )
{
level.bombZones[ index ] maps\mp\gametypes\_gameobjects::disableObject();
}
defuseObject maps\mp\gametypes\_gameobjects::disableObject();

View File

@ -20,104 +20,168 @@ init()
level.bot_offline = false;
if ( getDvar( "bots_main" ) == "" )
{
setDvar( "bots_main", true );
}
if ( !getDvarInt( "bots_main" ) )
{
return;
}
if ( !wait_for_builtins() )
{
PrintLn( "FATAL: NO BUILT-INS FOR BOTS" );
}
if ( getDvar( "bots_main_waitForHostTime" ) == "" )
{
setDvar( "bots_main_waitForHostTime", 10.0 ); // how long to wait to wait for the host player
}
if ( getDvar( "bots_main_kickBotsAtEnd" ) == "" )
{
setDvar( "bots_main_kickBotsAtEnd", false ); // kicks the bots at game end
}
if ( getDvar( "bots_manage_add" ) == "" )
{
setDvar( "bots_manage_add", 0 ); // amount of bots to add to the game
}
if ( getDvar( "bots_manage_fill" ) == "" )
{
setDvar( "bots_manage_fill", 0 ); // amount of bots to maintain
}
if ( getDvar( "bots_manage_fill_spec" ) == "" )
{
setDvar( "bots_manage_fill_spec", true ); // to count for fill if player is on spec team
}
if ( getDvar( "bots_manage_fill_mode" ) == "" )
{
setDvar( "bots_manage_fill_mode", 0 ); // fill mode, 0 adds everyone, 1 just bots, 2 maintains at maps, 3 is 2 with 1
}
if ( getDvar( "bots_manage_fill_kick" ) == "" )
{
setDvar( "bots_manage_fill_kick", false ); // kick bots if too many
}
if ( getDvar( "bots_skill" ) == "" ) // alias for bot_difficulty
{
setDvar( "bots_skill", "" );
}
if ( getDvar( "bots_team" ) == "" )
{
setDvar( "bots_team", "autoassign" ); // which team for bots to join
}
if ( getDvar( "bots_team_amount" ) == "" )
{
setDvar( "bots_team_amount", 0 ); // amount of bots on axis team
}
if ( getDvar( "bots_team_force" ) == "" )
{
setDvar( "bots_team_force", false ); // force bots on team
}
if ( getDvar( "bots_team_mode" ) == "" )
{
setDvar( "bots_team_mode", 0 ); // counts just bots when 1
}
if ( getDvar( "bots_loadout_reasonable" ) == "" ) // filter out the bad 'guns' and perks
{
setDvar( "bots_loadout_reasonable", false );
}
if ( getDvar( "bots_loadout_allow_op" ) == "" ) // allows jug, marty and laststand
{
setDvar( "bots_loadout_allow_op", true );
}
if ( getDvar( "bots_loadout_rank" ) == "" ) // what rank the bots should be around, -1 is around the players, 0 is all random
{
setDvar( "bots_loadout_rank", -1 );
}
if ( getDvar( "bots_loadout_codpoints" ) == "" ) // how much cod points a bot should have, -1 is around the players, 0 is all random
{
setDvar( "bots_loadout_codpoints", -1 );
}
if ( getDvar( "bots_loadout_prestige" ) == "" ) // what pretige the bots will be, -1 is the players, -2 is random
{
setDvar( "bots_loadout_prestige", -1 );
}
if ( getDvar( "bots_play_target_other" ) == "" ) // bot target non play ents (vehicles)
{
setDvar( "bots_play_target_other", true );
}
if ( getDvar( "bots_play_killstreak" ) == "" ) // bot use killstreaks
{
setDvar( "bots_play_killstreak", true );
}
if ( getDvar( "bots_play_nade" ) == "" ) // bots grenade
{
setDvar( "bots_play_nade", true );
}
if ( getDvar( "bots_play_knife" ) == "" ) // bots knife
{
setDvar( "bots_play_knife", true );
}
if ( getDvar( "bots_play_fire" ) == "" ) // bots fire
{
setDvar( "bots_play_fire", true );
}
if ( getDvar( "bots_play_move" ) == "" ) // bots move
{
setDvar( "bots_play_move", true );
}
if ( getDvar( "bots_play_take_carepackages" ) == "" ) // bots take carepackages
{
setDvar( "bots_play_take_carepackages", true );
}
if ( getDvar( "bots_play_obj" ) == "" ) // bots play the obj
{
setDvar( "bots_play_obj", true );
}
if ( getDvar( "bots_play_camp" ) == "" ) // bots camp and follow
{
setDvar( "bots_play_camp", true );
}
if ( getDvar( "bots_play_aim" ) == "" )
{
setDvar( "bots_play_aim", true );
}
if ( getDvar( "bots_play_jumpdrop" ) == "" ) // bots jump and dropshot
{
setDvar( "bots_play_jumpdrop", true );
}
level.bots = [];
level.bot_decoys = [];
level.bot_planes = [];
if ( !isDefined( game[ "botWarfare" ] ) )
{
game[ "botWarfare" ] = true;
}
thread fixGamemodes();
thread onPlayerConnect();
@ -153,12 +217,16 @@ handleBots()
addBots();
while ( !level.intermission )
{
wait 0.05;
}
setDvar( "bots_manage_add", getBotArray().size );
if ( !getDvarInt( "bots_main_kickBotsAtEnd" ) )
{
return;
}
bots = getBotArray();
@ -186,7 +254,9 @@ connected()
self endon( "disconnect" );
if ( !self is_bot() )
{
return;
}
self thread maps\mp\bots\_bot_script::connected();
@ -214,22 +284,34 @@ watchBotDebugEvent()
big_str = "Bot Warfare debug: " + self.name + ": " + msg + ": " + str;
if ( isDefined( b ) && isString( b ) )
{
big_str += ": " + b;
}
if ( isDefined( c ) && isString( c ) )
{
big_str += ": " + c;
}
if ( isDefined( d ) && isString( d ) )
{
big_str += ": " + d;
}
if ( isDefined( e ) && isString( e ) )
{
big_str += ": " + e;
}
if ( isDefined( f ) && isString( f ) )
{
big_str += ": " + f;
}
if ( isDefined( g ) && isString( g ) )
{
big_str += ": " + g;
}
BotBuiltinPrintConsole( big_str );
}
@ -267,18 +349,26 @@ diffBots()
doNonDediBots()
{
if ( !GetDvarInt( #"xblive_basictraining" ) )
{
return;
}
if ( isDefined( game[ "bots_spawned" ] ) )
{
return;
}
game[ "bots_spawned" ] = true;
if ( getDvar( "bot_enemies_extra" ) == "" )
{
setDvar( "bot_enemies_extra", 0 );
}
if ( getDvar( "bot_friends_extra" ) == "" )
{
setDvar( "bot_friends_extra", 0 );
}
bot_friends = GetDvarInt( #"bot_friends" );
bot_enemies = GetDvarInt( #"bot_enemies" );
@ -292,7 +382,9 @@ doNonDediBots()
team = "allies";
if ( isDefined( host ) && isDefined( host.pers[ "team" ] ) && ( host.pers[ "team" ] == "allies" || host.pers[ "team" ] == "axis" ) )
{
team = host.pers[ "team" ];
}
setDvar( "bots_manage_add", bot_enemies + bot_friends - 1 );
setDvar( "bots_manage_fill", bot_enemies + bot_friends );
@ -303,9 +395,13 @@ doNonDediBots()
setDvar( "bots_team", "custom" );
if ( team == "axis" )
{
setDvar( "bots_team_amount", bot_friends );
}
else
{
setDvar( "bots_team_amount", bot_enemies );
}
setDvar( "bots_team_force", true );
setDvar( "bots_team_mode", 0 );
@ -401,7 +497,9 @@ bot_set_difficulty( difficulty )
else // 'normal' difficulty
{
if ( difficulty != "normal" )
{
return;
}
SetDvar( "sv_botMinDeathTime", "500" );
SetDvar( "sv_botMaxDeathTime", "1000" );
@ -445,7 +543,9 @@ bot_set_difficulty( difficulty )
}
if ( !getDvarInt( "bots_play_nade" ) )
{
SetDvar( "sv_botAllowGrenades", "0" );
}
if ( !getDvarInt( "bots_play_aim" ) )
{
@ -480,21 +580,31 @@ teamBots_loop()
player = level.players[ i ];
if ( !isDefined( player.pers[ "team" ] ) )
{
continue;
}
if ( player is_bot() )
{
if ( player.pers[ "team" ] == "allies" )
{
alliesbots++;
}
else if ( player.pers[ "team" ] == "axis" )
{
axisbots++;
}
}
else
{
if ( player.pers[ "team" ] == "allies" )
{
alliesplayers++;
}
else if ( player.pers[ "team" ] == "axis" )
{
axisplayers++;
}
}
}
@ -518,7 +628,9 @@ teamBots_loop()
toTeam = "axis";
if ( axis > allies )
{
toTeam = "allies";
}
}
}
@ -531,20 +643,32 @@ teamBots_loop()
player = level.players[ i ];
if ( !isDefined( player.pers[ "team" ] ) )
{
continue;
}
if ( !player is_bot() )
{
continue;
}
if ( player.pers[ "team" ] == toTeam )
{
continue;
}
if ( toTeam == "allies" )
{
player thread [[ level.allies ]]();
}
else if ( toTeam == "axis" )
{
player thread [[ level.axis ]]();
}
else
{
player thread [[ level.spectator ]]();
}
break;
}
@ -560,10 +684,14 @@ teamBots_loop()
player = level.players[ i ];
if ( !isDefined( player.pers[ "team" ] ) )
{
continue;
}
if ( !player is_bot() )
{
continue;
}
if ( player.pers[ "team" ] == "axis" )
{
@ -614,7 +742,9 @@ addBots_loop()
SetDvar( "bots_manage_add", 0 );
if ( botsToAdd > 64 )
{
botsToAdd = 64;
}
for ( ; botsToAdd > 0; botsToAdd-- )
{
@ -626,7 +756,9 @@ addBots_loop()
fillMode = getDVarInt( "bots_manage_fill_mode" );
if ( fillMode == 2 || fillMode == 3 )
{
setDvar( "bots_manage_fill", getGoodMapAmount() );
}
fillAmount = getDvarInt( "bots_manage_fill" );
@ -641,14 +773,22 @@ addBots_loop()
player = level.players[ i ];
if ( player isdemoclient() )
{
continue;
}
if ( player is_bot() )
{
bots++;
}
else if ( !isDefined( player.pers[ "team" ] ) || ( player.pers[ "team" ] != "axis" && player.pers[ "team" ] != "allies" ) )
{
spec++;
}
else
{
players++;
}
}
if ( fillMode == 4 )
@ -663,15 +803,23 @@ addBots_loop()
player = level.players[ i ];
if ( player is_bot() )
{
continue;
}
if ( !isDefined( player.pers[ "team" ] ) )
{
continue;
}
if ( player.pers[ "team" ] == "axis" )
{
axisplayers++;
}
else if ( player.pers[ "team" ] == "allies" )
{
alliesplayers++;
}
}
result = fillAmount - abs( axisplayers - alliesplayers ) + bots;
@ -679,11 +827,17 @@ addBots_loop()
if ( players == 0 )
{
if ( bots < fillAmount )
{
result = fillAmount - 1;
}
else if ( bots > fillAmount )
{
result = fillAmount + 1;
}
else
{
result = fillAmount;
}
}
bots = result;
@ -700,19 +854,27 @@ addBots_loop()
amount = bots;
if ( fillMode == 0 || fillMode == 2 )
{
amount += players;
}
if ( getDVarInt( "bots_manage_fill_spec" ) )
{
amount += spec;
}
if ( amount < fillAmount )
{
setDvar( "bots_manage_add", 1 );
}
else if ( amount > fillAmount && getDvarInt( "bots_manage_fill_kick" ) )
{
tempBot = getBotToKick();
if ( isDefined( tempBot ) )
{
kick( tempBot getEntityNumber(), "EXE_PLAYERKICKED" );
}
}
}
@ -805,13 +967,19 @@ bot_is_idle()
}
if ( self UseButtonPressed() )
{
return false;
}
if ( self isPlanting() )
{
return false;
}
if ( self isDefusing() )
{
return false;
}
return true;
}
@ -830,7 +998,9 @@ watch_grenade()
self waittill( "grenade_fire", g, name );
if ( !isDefined( g ) )
{
continue;
}
if ( name == "scrambler_mp" )
{
@ -891,7 +1061,9 @@ scramble_nearby( trig )
self endon( "hacked" );
while ( !isDefined( self.owner ) || !isDefined( self.owner.team ) )
{
wait 0.05;
}
self.team = self.owner.team;
@ -900,16 +1072,24 @@ scramble_nearby( trig )
trig waittill( "trigger", player );
if ( !isDefined( player ) || !isDefined( player.team ) )
{
continue;
}
if ( self maps\mp\gametypes\_weaponobjects::isStunned() )
{
continue;
}
if ( isDefined( self.owner ) && player == self.owner )
{
continue;
}
if ( level.teamBased && self.team == player.team )
{
continue;
}
player thread scramble_player();
}
@ -927,7 +1107,9 @@ scramble_player()
wait 0.1;
if ( isDefined( self ) )
{
self.bot_scrambled = false;
}
}
/*
@ -971,10 +1153,14 @@ bot_watch_planes_loop()
ent = ents[ i ];
if ( isDefined( ent.bot_plane ) )
{
continue;
}
if ( ent.model != level.spyplanemodel )
{
continue;
}
thread watch_plane( ent );
}
@ -1040,7 +1226,9 @@ fixGamemodes()
level.isKillBoosting = ::bot_killBoost;
for ( i = 0; i < level.bombZones.size; i++ )
{
level.bombZones[ i ].onUse = ::bot_onUsePlantObjectFix;
}
break;
}