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" ] ) ); self SetPlayerRenderOptions( int( self.pers[ "bot" ][ "class_render_opts" ] ) );
if ( !isDefined( self.bot ) ) if ( !isDefined( self.bot ) )
{
self.bot = []; self.bot = [];
}
self.bot[ "specialty1" ] = "specialty_null"; self.bot[ "specialty1" ] = "specialty_null";
self.bot[ "specialty2" ] = "specialty_null"; self.bot[ "specialty2" ] = "specialty_null";
@ -36,7 +38,9 @@ bot_give_loadout()
tokens = strtok( id[ "reference" ], "|" ); tokens = strtok( id[ "reference" ], "|" );
for ( i = 0; i < tokens.size; i++ ) for ( i = 0; i < tokens.size; i++ )
{
self setPerk( tokens[ i ] ); self setPerk( tokens[ i ] );
}
} }
switch ( self.pers[ "bot" ][ "class_perk1" ] ) switch ( self.pers[ "bot" ][ "class_perk1" ] )
@ -82,7 +86,9 @@ bot_give_loadout()
tokens = strtok( id[ "reference" ], "|" ); tokens = strtok( id[ "reference" ], "|" );
for ( i = 0; i < tokens.size; i++ ) for ( i = 0; i < tokens.size; i++ )
{
self setPerk( tokens[ i ] ); self setPerk( tokens[ i ] );
}
} }
if ( self.pers[ "bot" ][ "class_perk3" ] != "" && GetDvarInt( #"scr_game_perks" ) ) if ( self.pers[ "bot" ][ "class_perk3" ] != "" && GetDvarInt( #"scr_game_perks" ) )
@ -93,19 +99,25 @@ bot_give_loadout()
tokens = strtok( id[ "reference" ], "|" ); tokens = strtok( id[ "reference" ], "|" );
for ( i = 0; i < tokens.size; i++ ) for ( i = 0; i < tokens.size; i++ )
{
self setPerk( tokens[ i ] ); self setPerk( tokens[ i ] );
}
} }
self takeAllWeapons(); self takeAllWeapons();
if ( getDvarInt( "bots_play_knife" ) ) if ( getDvarInt( "bots_play_knife" ) )
{
self GiveWeapon( "knife_mp" ); self GiveWeapon( "knife_mp" );
}
weap = self.pers[ "bot" ][ "class_primary" ]; weap = self.pers[ "bot" ][ "class_primary" ];
if ( weap == "" ) if ( weap == "" )
{
weap = "ak47_mp"; weap = "ak47_mp";
}
primaryTokens = strtok( self.pers[ "bot" ][ "class_primary" ], "_" ); primaryTokens = strtok( self.pers[ "bot" ][ "class_primary" ], "_" );
self.pers[ "primaryWeapon" ] = primaryTokens[ 0 ]; self.pers[ "primaryWeapon" ] = primaryTokens[ 0 ];
@ -113,19 +125,25 @@ bot_give_loadout()
weap = self.pers[ "bot" ][ "class_primary" ]; weap = self.pers[ "bot" ][ "class_primary" ];
if ( GetDvarInt( #"scr_disable_attachments" ) ) if ( GetDvarInt( #"scr_disable_attachments" ) )
{
weap = self.pers[ "primaryWeapon" ] + "_mp"; weap = self.pers[ "primaryWeapon" ] + "_mp";
}
self GiveWeapon( weap, 0, int( self.pers[ "bot" ][ "class_primary_opts" ] ) ); self GiveWeapon( weap, 0, int( self.pers[ "bot" ][ "class_primary_opts" ] ) );
if ( self hasPerk( "specialty_extraammo" ) ) if ( self hasPerk( "specialty_extraammo" ) )
{
self giveMaxAmmo( weap ); self giveMaxAmmo( weap );
}
if ( self.pers[ "bot" ][ "class_secondary" ] != "" ) if ( self.pers[ "bot" ][ "class_secondary" ] != "" )
{ {
self GiveWeapon( self.pers[ "bot" ][ "class_secondary" ], 0, int( self.pers[ "bot" ][ "class_secondary_opts" ] ) ); self GiveWeapon( self.pers[ "bot" ][ "class_secondary" ], 0, int( self.pers[ "bot" ][ "class_secondary_opts" ] ) );
if ( self hasPerk( "specialty_extraammo" ) ) if ( self hasPerk( "specialty_extraammo" ) )
{
self giveMaxAmmo( self.pers[ "bot" ][ "class_secondary" ] ); self giveMaxAmmo( self.pers[ "bot" ][ "class_secondary" ] );
}
} }
self SetActionSlot( 3, "altMode" ); self SetActionSlot( 3, "altMode" );
@ -145,9 +163,13 @@ bot_give_loadout()
self GiveWeapon( self.pers[ "bot" ][ "class_lethal" ] ); self GiveWeapon( self.pers[ "bot" ][ "class_lethal" ] );
if ( self hasPerk( "specialty_twogrenades" ) ) if ( self hasPerk( "specialty_twogrenades" ) )
{
self SetWeaponAmmoClip( self.pers[ "bot" ][ "class_lethal" ], 2 ); self SetWeaponAmmoClip( self.pers[ "bot" ][ "class_lethal" ], 2 );
}
else else
{
self SetWeaponAmmoClip( self.pers[ "bot" ][ "class_lethal" ], 1 ); self SetWeaponAmmoClip( self.pers[ "bot" ][ "class_lethal" ], 1 );
}
self SwitchToOffhand( self.pers[ "bot" ][ "class_lethal" ] ); self SwitchToOffhand( self.pers[ "bot" ][ "class_lethal" ] );
} }
@ -157,11 +179,17 @@ bot_give_loadout()
self giveWeapon( self.pers[ "bot" ][ "class_tacticle" ] ); self giveWeapon( self.pers[ "bot" ][ "class_tacticle" ] );
if ( self.pers[ "bot" ][ "class_tacticle" ] == "willy_pete_mp" ) if ( self.pers[ "bot" ][ "class_tacticle" ] == "willy_pete_mp" )
{
self SetWeaponAmmoClip( self.pers[ "bot" ][ "class_tacticle" ], 1 ); self SetWeaponAmmoClip( self.pers[ "bot" ][ "class_tacticle" ], 1 );
}
else if ( self hasPerk( "specialty_twogrenades" ) ) else if ( self hasPerk( "specialty_twogrenades" ) )
{
self SetWeaponAmmoClip( self.pers[ "bot" ][ "class_tacticle" ], 3 ); self SetWeaponAmmoClip( self.pers[ "bot" ][ "class_tacticle" ], 3 );
}
else else
{
self SetWeaponAmmoClip( self.pers[ "bot" ][ "class_tacticle" ], 2 ); self SetWeaponAmmoClip( self.pers[ "bot" ][ "class_tacticle" ], 2 );
}
self setOffhandSecondaryClass( self.pers[ "bot" ][ "class_tacticle" ] ); self setOffhandSecondaryClass( self.pers[ "bot" ][ "class_tacticle" ] );
} }
@ -184,10 +212,14 @@ bot_get_prestige()
player = level.players[ i ]; player = level.players[ i ];
if ( !isDefined( player.team ) ) if ( !isDefined( player.team ) )
{
continue; continue;
}
if ( player is_bot() ) if ( player is_bot() )
{
continue; continue;
}
p = player maps\mp\gametypes\_persistence::statGet( "plevel" ); p = player maps\mp\gametypes\_persistence::statGet( "plevel" );
break; break;
@ -226,7 +258,9 @@ bot_rank()
self maps\mp\gametypes\_rank::syncxpstat(); self maps\mp\gametypes\_rank::syncxpstat();
if ( !level.gameEnded ) if ( !level.gameEnded )
{
level waittill( "game_ended" ); level waittill( "game_ended" );
}
self.pers[ "bot" ][ "rankxp" ] = self.pers[ "rankxp" ]; self.pers[ "bot" ][ "rankxp" ] = self.pers[ "rankxp" ];
} }
@ -282,13 +316,17 @@ bot_set_class()
case 3: case 3:
if ( rank >= 1 ) if ( rank >= 1 )
{
_class = "CLASS_LMG"; _class = "CLASS_LMG";
}
break; break;
case 4: case 4:
if ( rank >= 2 ) if ( rank >= 2 )
{
_class = "CLASS_SNIPER"; _class = "CLASS_SNIPER";
}
break; break;
} }
@ -316,31 +354,51 @@ bot_set_class()
self bot_get_random_weapon( "equipment", rank ); self bot_get_random_weapon( "equipment", rank );
if ( rank >= 21 ) if ( rank >= 21 )
{
camo = self bot_random_camo(); camo = self bot_random_camo();
}
else else
{
camo = 0; camo = 0;
}
if ( rank >= 18 ) if ( rank >= 18 )
{
tag = self bot_random_tag(); tag = self bot_random_tag();
}
else else
{
tag = 0; tag = 0;
}
if ( rank >= 15 ) if ( rank >= 15 )
{
emblem = self bot_random_emblem(); emblem = self bot_random_emblem();
}
else else
{
emblem = 0; emblem = 0;
}
if ( isSubStr( self.pers[ "bot" ][ "class_primary" ], "_elbit_" ) || isSubStr( self.pers[ "bot" ][ "class_primary" ], "_reflex_" ) ) if ( isSubStr( self.pers[ "bot" ][ "class_primary" ], "_elbit_" ) || isSubStr( self.pers[ "bot" ][ "class_primary" ], "_reflex_" ) )
{ {
if ( rank >= 24 ) if ( rank >= 24 )
{
reticle = self bot_random_reticle(); reticle = self bot_random_reticle();
}
else else
{
reticle = 0; reticle = 0;
}
if ( rank >= 27 ) if ( rank >= 27 )
{
lens = self bot_random_lens(); lens = self bot_random_lens();
}
else else
{
lens = 0; lens = 0;
}
} }
else else
{ {
@ -351,15 +409,21 @@ bot_set_class()
self.pers[ "bot" ][ "class_primary_opts" ] = self calcWeaponOptions( camo, lens, reticle, tag, emblem ); self.pers[ "bot" ][ "class_primary_opts" ] = self calcWeaponOptions( camo, lens, reticle, tag, emblem );
if ( rank >= 30 ) if ( rank >= 30 )
{
face = self bot_random_face(); face = self bot_random_face();
}
else else
{
face = 0; face = 0;
}
self.pers[ "bot" ][ "class_render_opts" ] = self calcPlayerOptions( 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" ) ) if ( !GetDvarInt( "bots_loadout_allow_op" ) && isSubStr( self.pers[ "bot" ][ "class_perk3" ], "perk_second_chance" ) )
{
self.pers[ "bot" ][ "class_perk3" ] = ""; self.pers[ "bot" ][ "class_perk3" ] = "";
}
} }
/* /*
@ -368,7 +432,9 @@ bot_set_class()
bot_get_random_weapon( slot, rank ) bot_get_random_weapon( slot, rank )
{ {
if ( !isDefined( level.bot_weapon_ids ) ) if ( !isDefined( level.bot_weapon_ids ) )
{
level.bot_weapon_ids = []; level.bot_weapon_ids = [];
}
if ( !IsDefined( level.bot_weapon_ids[ slot ] ) ) if ( !IsDefined( level.bot_weapon_ids[ slot ] ) )
{ {
@ -382,13 +448,19 @@ bot_get_random_weapon( slot, rank )
id = level.tbl_weaponIDs[ key ]; id = level.tbl_weaponIDs[ key ];
if ( id[ "reference" ] == "weapon_null" ) if ( id[ "reference" ] == "weapon_null" )
{
continue; continue;
}
if ( isSubStr( id[ "reference" ], "dw" ) ) if ( isSubStr( id[ "reference" ], "dw" ) )
{
continue; continue;
}
if ( id[ "cost" ] == "-1" ) if ( id[ "cost" ] == "-1" )
{
continue; continue;
}
if ( id[ "slot" ] == slot ) if ( id[ "slot" ] == slot )
{ {
@ -401,17 +473,23 @@ bot_get_random_weapon( slot, rank )
diff = self GetBotDiffNum(); diff = self GetBotDiffNum();
if ( slot == "equipment" && self.pers[ "bot" ][ "cod_points" ] < 2000 ) if ( slot == "equipment" && self.pers[ "bot" ][ "cod_points" ] < 2000 )
{
return; return;
}
for ( ;; ) for ( ;; )
{ {
id = PickRandom( level.bot_weapon_ids[ slot ] ); id = PickRandom( level.bot_weapon_ids[ slot ] );
if ( !isDefined( id ) ) if ( !isDefined( id ) )
{
return; return;
}
if ( !bot_weapon_unlocked( id, rank ) ) if ( !bot_weapon_unlocked( id, rank ) )
{
continue; continue;
}
if ( reason ) if ( reason )
{ {
@ -419,13 +497,17 @@ bot_get_random_weapon( slot, rank )
{ {
case "willy_pete": case "willy_pete":
if ( self.pers[ "bot" ][ "cod_points" ] >= 1500 ) if ( self.pers[ "bot" ][ "cod_points" ] >= 1500 )
{
continue; continue;
}
break; break;
case "camera_spike": case "camera_spike":
if ( self.pers[ "bot" ][ "cod_points" ] >= 2500 ) if ( self.pers[ "bot" ][ "cod_points" ] >= 2500 )
{
continue; continue;
}
break; break;
@ -475,27 +557,39 @@ bot_get_random_weapon( slot, rank )
} }
if ( id[ "reference" ] == "camera_spike" && self IsSplitScreen() ) if ( id[ "reference" ] == "camera_spike" && self IsSplitScreen() )
{
continue; continue;
}
if ( id[ "reference" ] == level.tacticalInsertionWeapon && level.disable_tacinsert ) if ( id[ "reference" ] == level.tacticalInsertionWeapon && level.disable_tacinsert )
{
continue; continue;
}
cost = bot_weapon_cost( id ); cost = bot_weapon_cost( id );
if ( cost > 0 && self.pers[ "bot" ][ "cod_points" ] < cost ) if ( cost > 0 && self.pers[ "bot" ][ "cod_points" ] < cost )
{
continue; continue;
}
self.pers[ "bot" ][ "cod_points" ] = self.pers[ "bot" ][ "cod_points" ] - cost; self.pers[ "bot" ][ "cod_points" ] = self.pers[ "bot" ][ "cod_points" ] - cost;
maxAttachs = 1; maxAttachs = 1;
if ( isSubStr( self.pers[ "bot" ][ "class_perk2" ], "perk_professional" ) && slot == "primary" ) if ( isSubStr( self.pers[ "bot" ][ "class_perk2" ], "perk_professional" ) && slot == "primary" )
{
maxAttachs = 2; maxAttachs = 2;
}
if ( RandomFloatRange( 0, 1 ) < ( ( rank / level.maxRank ) + 0.1 ) ) if ( RandomFloatRange( 0, 1 ) < ( ( rank / level.maxRank ) + 0.1 ) )
{
weap = bot_random_attachments( id[ "reference" ], id[ "attachment" ], maxAttachs ); weap = bot_random_attachments( id[ "reference" ], id[ "attachment" ], maxAttachs );
}
else else
{
weap = id[ "reference" ]; weap = id[ "reference" ];
}
weap = bot_validate_weapon( weap ); weap = bot_validate_weapon( weap );
weap = weap + "_mp"; weap = weap + "_mp";
@ -539,28 +633,40 @@ bot_get_random_perk( slot, rank )
id = PickRandom( level.allowedPerks[ 0 ] ); id = PickRandom( level.allowedPerks[ 0 ] );
if ( !isDefined( id ) ) if ( !isDefined( id ) )
{
return; return;
}
id = level.tbl_PerkData[ id ]; id = level.tbl_PerkData[ id ];
if ( id[ "reference" ] == "specialty_null" ) if ( id[ "reference" ] == "specialty_null" )
{
continue; continue;
}
if ( id[ "slot" ] != "specialty" + slot ) if ( id[ "slot" ] != "specialty" + slot )
{
continue; continue;
}
if ( isSubStr( id[ "reference_full" ], "_pro" ) && id[ "reference_full" ] != "perk_professional" ) if ( isSubStr( id[ "reference_full" ], "_pro" ) && id[ "reference_full" ] != "perk_professional" )
{
continue; continue;
}
cost = Int( id[ "cost" ] ); cost = Int( id[ "cost" ] );
if ( cost > 0 && cost > self.pers[ "bot" ][ "cod_points" ] ) if ( cost > 0 && cost > self.pers[ "bot" ][ "cod_points" ] )
{
continue; continue;
}
if ( reason ) if ( reason )
{ {
if ( id[ "reference_full" ] == "perk_scout" ) if ( id[ "reference_full" ] == "perk_scout" )
{
continue; continue;
}
} }
self.pers[ "bot" ][ "cod_points" ] = self.pers[ "bot" ][ "cod_points" ] - cost; self.pers[ "bot" ][ "cod_points" ] = self.pers[ "bot" ][ "cod_points" ] - cost;
@ -588,14 +694,18 @@ bot_random_face()
face = randomint( 25 ); face = randomint( 25 );
if ( face == 0 ) if ( face == 0 )
{
return face; return face;
}
if ( face >= 17 ) if ( face >= 17 )
{ {
if ( face >= 21 ) // pres faces if ( face >= 21 ) // pres faces
{ {
if ( self.pers[ "bot" ][ "cod_points" ] < 500 ) if ( self.pers[ "bot" ][ "cod_points" ] < 500 )
{
continue; continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 500; self.pers[ "bot" ][ "cod_points" ] -= 500;
@ -605,7 +715,9 @@ bot_random_face()
if ( face == 17 ) if ( face == 17 )
{ {
if ( self.pers[ "bot" ][ "cod_points" ] < 1500 ) if ( self.pers[ "bot" ][ "cod_points" ] < 1500 )
{
continue; continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 1500; self.pers[ "bot" ][ "cod_points" ] -= 1500;
@ -615,7 +727,9 @@ bot_random_face()
if ( face == 18 ) if ( face == 18 )
{ {
if ( self.pers[ "bot" ][ "cod_points" ] < 3500 ) if ( self.pers[ "bot" ][ "cod_points" ] < 3500 )
{
continue; continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 3500; self.pers[ "bot" ][ "cod_points" ] -= 3500;
@ -625,7 +739,9 @@ bot_random_face()
if ( face == 19 ) if ( face == 19 )
{ {
if ( self.pers[ "bot" ][ "cod_points" ] < 5500 ) if ( self.pers[ "bot" ][ "cod_points" ] < 5500 )
{
continue; continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 5500; self.pers[ "bot" ][ "cod_points" ] -= 5500;
@ -633,7 +749,9 @@ bot_random_face()
} }
if ( self.pers[ "bot" ][ "cod_points" ] < 7500 ) if ( self.pers[ "bot" ][ "cod_points" ] < 7500 )
{
continue; continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 7500; self.pers[ "bot" ][ "cod_points" ] -= 7500;
@ -641,7 +759,9 @@ bot_random_face()
} }
if ( self.pers[ "bot" ][ "cod_points" ] < 500 ) if ( self.pers[ "bot" ][ "cod_points" ] < 500 )
{
continue; continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 500; self.pers[ "bot" ][ "cod_points" ] -= 500;
@ -659,10 +779,14 @@ bot_random_lens()
lens = randomint( 6 ); lens = randomint( 6 );
if ( lens == 0 ) if ( lens == 0 )
{
return lens; return lens;
}
if ( self.pers[ "bot" ][ "cod_points" ] < 500 ) if ( self.pers[ "bot" ][ "cod_points" ] < 500 )
{
continue; continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 500; self.pers[ "bot" ][ "cod_points" ] -= 500;
@ -680,10 +804,14 @@ bot_random_reticle()
ret = randomint( 40 ); ret = randomint( 40 );
if ( ret == 0 ) if ( ret == 0 )
{
return ret; return ret;
}
if ( self.pers[ "bot" ][ "cod_points" ] < 500 ) if ( self.pers[ "bot" ][ "cod_points" ] < 500 )
{
continue; continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 500; self.pers[ "bot" ][ "cod_points" ] -= 500;
@ -701,10 +829,14 @@ bot_random_tag()
tag = randomInt( 2 ); tag = randomInt( 2 );
if ( tag == 0 ) if ( tag == 0 )
{
return tag; return tag;
}
if ( self.pers[ "bot" ][ "cod_points" ] < 1000 ) if ( self.pers[ "bot" ][ "cod_points" ] < 1000 )
{
continue; continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 1000; self.pers[ "bot" ][ "cod_points" ] -= 1000;
@ -722,10 +854,14 @@ bot_random_emblem()
emblem = randomInt( 2 ); emblem = randomInt( 2 );
if ( emblem == 0 ) if ( emblem == 0 )
{
return emblem; return emblem;
}
if ( self.pers[ "bot" ][ "cod_points" ] < 1000 ) if ( self.pers[ "bot" ][ "cod_points" ] < 1000 )
{
continue; continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 1000; self.pers[ "bot" ][ "cod_points" ] -= 1000;
@ -743,12 +879,16 @@ bot_random_camo()
camo = randomInt( 16 ); camo = randomInt( 16 );
if ( camo == 0 ) if ( camo == 0 )
{
return camo; return camo;
}
if ( camo == 15 ) // gold if ( camo == 15 ) // gold
{ {
if ( self.pers[ "bot" ][ "cod_points" ] < 50000 ) if ( self.pers[ "bot" ][ "cod_points" ] < 50000 )
{
continue; continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 50000; self.pers[ "bot" ][ "cod_points" ] -= 50000;
@ -756,7 +896,9 @@ bot_random_camo()
} }
if ( self.pers[ "bot" ][ "cod_points" ] < 250 ) if ( self.pers[ "bot" ][ "cod_points" ] < 250 )
{
continue; continue;
}
self.pers[ "bot" ][ "cod_points" ] -= 250; self.pers[ "bot" ][ "cod_points" ] -= 250;
@ -777,15 +919,21 @@ bot_weapon_cost( id )
slot = "primary"; slot = "primary";
if ( id[ "group" ] == "weapon_pistol" ) if ( id[ "group" ] == "weapon_pistol" )
{
slot = "secondary"; slot = "secondary";
}
for ( i = 0; i < level.bot_weapon_ids[ slot ].size; i++ ) for ( i = 0; i < level.bot_weapon_ids[ slot ].size; i++ )
{ {
if ( id[ "reference" ] == level.bot_weapon_ids[ slot ][ i ][ "reference" ] ) if ( id[ "reference" ] == level.bot_weapon_ids[ slot ][ i ][ "reference" ] )
{
continue; continue;
}
if ( id[ "group" ] != level.bot_weapon_ids[ slot ][ i ][ "group" ] ) if ( id[ "group" ] != level.bot_weapon_ids[ slot ][ i ][ "group" ] )
{
continue; continue;
}
cost += int( level.bot_weapon_ids[ slot ][ i ][ "cost" ] ); cost += int( level.bot_weapon_ids[ slot ][ i ][ "cost" ] );
} }
@ -829,7 +977,9 @@ bot_weapon_unlocked( id, rank )
unlock = Int( id[ "unlock_level" ] ); unlock = Int( id[ "unlock_level" ] );
if ( unlock <= 3 ) if ( unlock <= 3 )
{
return true; return true;
}
return ( rank >= unlock ); return ( rank >= unlock );
} }
@ -885,24 +1035,34 @@ bot_validate_weapon( weap )
tokens = strtok( weap, "_" ); tokens = strtok( weap, "_" );
if ( tokens.size <= 1 ) if ( tokens.size <= 1 )
{
return weapon; return weapon;
}
if ( tokens.size < 3 ) if ( tokens.size < 3 )
{ {
if ( tokens[ 1 ] == "dw" ) if ( tokens[ 1 ] == "dw" )
{
weapon = tokens[ 0 ] + "dw"; weapon = tokens[ 0 ] + "dw";
}
return weapon; return weapon;
} }
if ( tokens[ 2 ] == "ir" || tokens[ 2 ] == "reflex" || tokens[ 2 ] == "acog" || tokens[ 2 ] == "elbit" || tokens[ 2 ] == "vzoom" || tokens[ 2 ] == "lps" ) 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 ]; return tokens[ 0 ] + "_" + tokens[ 2 ] + "_" + tokens[ 1 ];
}
if ( tokens[ 1 ] == "silencer" ) if ( tokens[ 1 ] == "silencer" )
{
return tokens[ 0 ] + "_" + tokens[ 2 ] + "_" + tokens[ 1 ]; 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" ) ) 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 tokens[ 0 ] + "_" + tokens[ 2 ] + "_" + tokens[ 1 ];
}
return weapon; return weapon;
} }
@ -929,7 +1089,9 @@ bot_random_attachments( weap, atts, num )
attachments = array_remove( attachments, attachment ); attachments = array_remove( attachments, attachment );
if ( attachment == "" ) if ( attachment == "" )
{
return weapon; return weapon;
}
if ( reason ) if ( reason )
{ {
@ -959,14 +1121,18 @@ bot_random_attachments( weap, atts, num )
cost = bot_attachment_cost( attachment ); cost = bot_attachment_cost( attachment );
if ( cost > 0 && cost > self.pers[ "bot" ][ "cod_points" ] ) if ( cost > 0 && cost > self.pers[ "bot" ][ "cod_points" ] )
{
continue; continue;
}
self.pers[ "bot" ][ "cod_points" ] -= cost; self.pers[ "bot" ][ "cod_points" ] -= cost;
weapon = weapon + "_" + attachment; weapon = weapon + "_" + attachment;
if ( attachment == "dw" || attachment == "gl" || attachment == "ft" || attachment == "mk" || num == 1 ) if ( attachment == "dw" || attachment == "gl" || attachment == "ft" || attachment == "mk" || num == 1 )
{
return weapon; return weapon;
}
break; break;
} }
@ -982,7 +1148,9 @@ bot_random_attachments( weap, atts, num )
attachments = array_remove( attachments, _attachment ); attachments = array_remove( attachments, _attachment );
if ( _attachment == "" ) if ( _attachment == "" )
{
return weapon; return weapon;
}
if ( reason ) if ( reason )
{ {
@ -1010,18 +1178,26 @@ bot_random_attachments( weap, atts, num )
} }
if ( _attachment == "dw" || _attachment == "gl" || _attachment == "ft" || _attachment == "mk" ) if ( _attachment == "dw" || _attachment == "gl" || _attachment == "ft" || _attachment == "mk" )
{
continue; 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" ) ) 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; continue;
}
if ( ( attachment == "dualclip" || attachment == "extclip" || attachment == "rf" ) && ( _attachment == "dualclip" || _attachment == "extclip" || _attachment == "rf" ) ) if ( ( attachment == "dualclip" || attachment == "extclip" || attachment == "rf" ) && ( _attachment == "dualclip" || _attachment == "extclip" || _attachment == "rf" ) )
{
continue; continue;
}
cost = bot_attachment_cost( _attachment ); cost = bot_attachment_cost( _attachment );
if ( cost > 0 && cost > self.pers[ "bot" ][ "cod_points" ] ) if ( cost > 0 && cost > self.pers[ "bot" ][ "cod_points" ] )
{
continue; continue;
}
self.pers[ "bot" ][ "cod_points" ] -= cost; self.pers[ "bot" ][ "cod_points" ] -= cost;
weapon = weapon + "_" + _attachment; weapon = weapon + "_" + _attachment;
@ -1076,7 +1252,9 @@ bot_get_cod_points()
} }
if ( !isDefined( players[ i ].pers[ "currencyspent" ] ) || !isDefined( players[ i ].pers[ "codpoints" ] ) ) if ( !isDefined( players[ i ].pers[ "currencyspent" ] ) || !isDefined( players[ i ].pers[ "codpoints" ] ) )
{
continue; continue;
}
total_points[ total_points.size ] = players[ i ].pers[ "currencyspent" ] + players[ i ].pers[ "codpoints" ]; 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++ ) for ( i = 0; i < players.size; i++ )
{ {
if ( players[ i ] == self ) if ( players[ i ] == self )
{
continue; continue;
}
if ( !IsDefined( players[ i ].pers[ "rank" ] ) ) if ( !IsDefined( players[ i ].pers[ "rank" ] ) )
{
continue; continue;
}
if ( players[ i ] is_bot() ) if ( players[ i ] is_bot() )
{ {
@ -1204,7 +1386,9 @@ bot_setKillstreaks()
killstreak = PickRandom( allowed_killstreaks ); killstreak = PickRandom( allowed_killstreaks );
if ( !isDefined( killstreak ) ) if ( !isDefined( killstreak ) )
{
break; break;
}
allowed_killstreaks = array_remove( allowed_killstreaks, killstreak ); 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++ ) for ( i = 0; i < 20; i++ )
{ {
if ( isDefined( level.bot_builtins ) ) if ( isDefined( level.bot_builtins ) )
{
return true; return true;
}
if ( i < 18 ) if ( i < 18 )
{
waittillframeend; waittillframeend;
}
else else
{
wait 0.05; wait 0.05;
}
} }
return false; return false;
@ -197,7 +203,9 @@ getBotArray()
player = level.players[ i ]; player = level.players[ i ];
if ( !player is_bot() ) if ( !player is_bot() )
{
continue; continue;
}
result[ result.size ] = player; result[ result.size ] = player;
} }
@ -227,12 +235,18 @@ Round( x )
if ( abs( x ) - abs( y ) > 0.5 ) if ( abs( x ) - abs( y ) > 0.5 )
{ {
if ( x < 0 ) if ( x < 0 )
{
return y - 1; return y - 1;
}
else else
{
return y + 1; return y + 1;
}
} }
else else
{
return y; return y;
}
} }
/* /*
@ -241,7 +255,9 @@ Round( x )
PickRandom( arr ) PickRandom( arr )
{ {
if ( !arr.size ) if ( !arr.size )
{
return undefined; return undefined;
}
return arr[ randomInt( arr.size ) ]; return arr[ randomInt( arr.size ) ];
} }
@ -346,7 +362,9 @@ GetBotDiffNum()
isWeaponAltmode( weap ) isWeaponAltmode( weap )
{ {
if ( isStrStart( weap, "gl_" ) || isStrStart( weap, "ft_" ) || isStrStart( weap, "mk_" ) ) if ( isStrStart( weap, "gl_" ) || isStrStart( weap, "ft_" ) || isStrStart( weap, "mk_" ) )
{
return true; return true;
}
return false; return false;
} }
@ -364,24 +382,36 @@ bot_lookat( pos, time, vel, doAimPredict )
level endon ( "game_ended" ); level endon ( "game_ended" );
if ( level.gameEnded || level.inPrematchPeriod || self BotIsFrozen() || !getDvarInt( "bots_play_aim" ) ) if ( level.gameEnded || level.inPrematchPeriod || self BotIsFrozen() || !getDvarInt( "bots_play_aim" ) )
{
return; return;
}
if ( !isDefined( pos ) ) if ( !isDefined( pos ) )
{
return; return;
}
if ( !isDefined( doAimPredict ) ) if ( !isDefined( doAimPredict ) )
{
doAimPredict = false; doAimPredict = false;
}
if ( !isDefined( time ) ) if ( !isDefined( time ) )
{
time = 0.05; time = 0.05;
}
if ( !isDefined( vel ) ) if ( !isDefined( vel ) )
{
vel = ( 0, 0, 0 ); vel = ( 0, 0, 0 );
}
steps = int( time * 20 ); steps = int( time * 20 );
if ( steps < 1 ) if ( steps < 1 )
{
steps = 1; steps = 1;
}
myEye = self GetEye(); // get our eye pos myEye = self GetEye(); // get our eye pos
@ -450,10 +480,14 @@ getValidTube()
weap = weaps[ i ]; weap = weaps[ i ];
if ( !self getAmmoCount( weap ) ) if ( !self getAmmoCount( weap ) )
{
continue; continue;
}
if ( ( isSubStr( weap, "gl_" ) && !isSubStr( weap, "_gl_" ) ) || weap == "china_lake_mp" ) if ( ( isSubStr( weap, "gl_" ) && !isSubStr( weap, "_gl_" ) ) || weap == "china_lake_mp" )
{
return weap; return weap;
}
} }
return undefined; return undefined;
@ -464,29 +498,37 @@ getValidTube()
*/ */
waittill_any_timeout( timeOut, string1, string2, string3, string4, string5 ) waittill_any_timeout( timeOut, string1, string2, string3, string4, string5 )
{ {
if ( ( !isdefined( string1 ) || string1 != "death" ) && if ( ( !isdefined( string1 ) || string1 != "death" ) && ( !isdefined( string2 ) || string2 != "death" ) && ( !isdefined( string3 ) || string3 != "death" ) && ( !isdefined( string4 ) || string4 != "death" ) && ( !isdefined( string5 ) || string5 != "death" ) )
( !isdefined( string2 ) || string2 != "death" ) && {
( !isdefined( string3 ) || string3 != "death" ) &&
( !isdefined( string4 ) || string4 != "death" ) &&
( !isdefined( string5 ) || string5 != "death" ) )
self endon( "death" ); self endon( "death" );
}
ent = spawnstruct(); ent = spawnstruct();
if ( isdefined( string1 ) ) if ( isdefined( string1 ) )
{
self thread waittill_string( string1, ent ); self thread waittill_string( string1, ent );
}
if ( isdefined( string2 ) ) if ( isdefined( string2 ) )
{
self thread waittill_string( string2, ent ); self thread waittill_string( string2, ent );
}
if ( isdefined( string3 ) ) if ( isdefined( string3 ) )
{
self thread waittill_string( string3, ent ); self thread waittill_string( string3, ent );
}
if ( isdefined( string4 ) ) if ( isdefined( string4 ) )
{
self thread waittill_string( string4, ent ); self thread waittill_string( string4, ent );
}
if ( isdefined( string5 ) ) if ( isdefined( string5 ) )
{
self thread waittill_string( string5, ent ); self thread waittill_string( string5, ent );
}
ent thread _timeout( timeOut ); ent thread _timeout( timeOut );
@ -514,7 +556,9 @@ getBotToKick()
bots = getBotArray(); bots = getBotArray();
if ( !isDefined( bots ) || !isDefined( bots.size ) || bots.size <= 0 || !isDefined( bots[ 0 ] ) ) if ( !isDefined( bots ) || !isDefined( bots.size ) || bots.size <= 0 || !isDefined( bots[ 0 ] ) )
{
return undefined; return undefined;
}
tokick = undefined; tokick = undefined;
axis = 0; axis = 0;
@ -527,14 +571,22 @@ getBotToKick()
bot = bots[ i ]; bot = bots[ i ];
if ( !isDefined( bot ) || !isDefined( bot.team ) ) if ( !isDefined( bot ) || !isDefined( bot.team ) )
{
continue; continue;
}
if ( bot.team == "allies" ) if ( bot.team == "allies" )
{
allies++; allies++;
}
else if ( bot.team == "axis" ) else if ( bot.team == "axis" )
{
axis++; axis++;
}
else // choose bots that are not on a team first else // choose bots that are not on a team first
{
return bot; return bot;
}
} }
// search for a bot on the other team // search for a bot on the other team
@ -548,7 +600,9 @@ getBotToKick()
team = "allies"; team = "allies";
if ( axis > allies ) if ( axis > allies )
{
team = "axis"; team = "axis";
}
} }
else else
{ {
@ -561,16 +615,22 @@ getBotToKick()
bot = bots[ i ]; bot = bots[ i ];
if ( !isDefined( bot ) || !isDefined( bot.team ) ) if ( !isDefined( bot ) || !isDefined( bot.team ) )
{
continue; continue;
}
if ( bot.team != team ) if ( bot.team != team )
{
continue; continue;
}
tokick = bot; tokick = bot;
} }
if ( isDefined( tokick ) ) if ( isDefined( tokick ) )
{
return tokick; return tokick;
}
// just kick lowest skill // just kick lowest skill
for ( i = 0; i < bots.size; i++ ) for ( i = 0; i < bots.size; i++ )
@ -578,7 +638,9 @@ getBotToKick()
bot = bots[ i ]; bot = bots[ i ];
if ( !isDefined( bot ) || !isDefined( bot.team ) ) if ( !isDefined( bot ) || !isDefined( bot.team ) )
{
continue; continue;
}
tokick = bot; tokick = bot;
} }
@ -594,36 +656,48 @@ bot_wait_for_host()
host = undefined; host = undefined;
while ( !isDefined( level ) || !isDefined( level.players ) ) while ( !isDefined( level ) || !isDefined( level.players ) )
{
wait 0.05; wait 0.05;
}
for ( i = getDvarFloat( "bots_main_waitForHostTime" ); i > 0; i -= 0.05 ) for ( i = getDvarFloat( "bots_main_waitForHostTime" ); i > 0; i -= 0.05 )
{ {
host = GetHostPlayer(); host = GetHostPlayer();
if ( isDefined( host ) ) if ( isDefined( host ) )
{
break; break;
}
wait 0.05; wait 0.05;
} }
if ( !isDefined( host ) ) if ( !isDefined( host ) )
{
return; return;
}
for ( i = getDvarFloat( "bots_main_waitForHostTime" ); i > 0; i -= 0.05 ) for ( i = getDvarFloat( "bots_main_waitForHostTime" ); i > 0; i -= 0.05 )
{ {
if ( IsDefined( host.pers[ "team" ] ) ) if ( IsDefined( host.pers[ "team" ] ) )
{
break; break;
}
wait 0.05; wait 0.05;
} }
if ( !IsDefined( host.pers[ "team" ] ) ) if ( !IsDefined( host.pers[ "team" ] ) )
{
return; return;
}
for ( i = getDvarFloat( "bots_main_waitForHostTime" ); i > 0; i -= 0.05 ) for ( i = getDvarFloat( "bots_main_waitForHostTime" ); i > 0; i -= 0.05 )
{ {
if ( host.pers[ "team" ] == "allies" || host.pers[ "team" ] == "axis" ) if ( host.pers[ "team" ] == "allies" || host.pers[ "team" ] == "axis" )
{
break; break;
}
wait 0.05; wait 0.05;
} }
@ -701,7 +775,9 @@ botStopMove2( what )
self endon( "botStopMove" ); self endon( "botStopMove" );
if ( !what ) if ( !what )
{
return; return;
}
og = self.origin; og = self.origin;
@ -879,7 +955,9 @@ bot_onUsePlantObjectFix( player )
for ( index = 0; index < level.bombZones.size; index++ ) for ( index = 0; index < level.bombZones.size; index++ )
{ {
if ( level.bombZones[ index ] == self ) if ( level.bombZones[ index ] == self )
{
continue; continue;
}
level.bombZones[ index ] maps\mp\gametypes\_gameobjects::disableObject(); level.bombZones[ index ] maps\mp\gametypes\_gameobjects::disableObject();
} }
@ -940,7 +1018,9 @@ bot_bombPlanted( destroyedObj, player )
for ( index = 0; index < level.players.size; index++ ) for ( index = 0; index < level.players.size; index++ )
{ {
if ( isDefined( level.players[ index ].carryIcon ) ) if ( isDefined( level.players[ index ].carryIcon ) )
{
level.players[ index ].carryIcon destroyElem(); level.players[ index ].carryIcon destroyElem();
}
} }
trace = bulletTrace( player.origin + ( 0, 0, 20 ), player.origin - ( 0, 0, 2000 ), false, player ); 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(); destroyedObj.visuals[ 0 ] maps\mp\gametypes\_globallogic_utils::stopTickingSound();
if ( level.gameEnded || level.bombDefused ) if ( level.gameEnded || level.bombDefused )
{
return; return;
}
level.bombExploded = true; level.bombExploded = true;
@ -1012,7 +1094,9 @@ bot_bombPlanted( destroyedObj, player )
player maps\mp\gametypes\_persistence::statAddWithGameType( "DESTRUCTIONS", 1 ); player maps\mp\gametypes\_persistence::statAddWithGameType( "DESTRUCTIONS", 1 );
} }
else else
{
destroyedObj.visuals[ 0 ] radiusDamage( explosionOrigin, 512, 200, 20, undefined, "MOD_EXPLOSIVE", "briefcase_bomb_mp" ); destroyedObj.visuals[ 0 ] radiusDamage( explosionOrigin, 512, 200, 20, undefined, "MOD_EXPLOSIVE", "briefcase_bomb_mp" );
}
rot = randomfloat( 360 ); rot = randomfloat( 360 );
explosionEffect = spawnFx( level._effect[ "bombexplosion" ], explosionOrigin + ( 0, 0, 50 ), ( 0, 0, 1 ), ( cos( rot ), sin( rot ), 0 ) ); 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" ); // thread maps\mp\gametypes\_globallogic_audio::set_music_on_team( "SILENT", "both" );
if ( isDefined( destroyedObj.exploderIndex ) ) if ( isDefined( destroyedObj.exploderIndex ) )
{
exploder( destroyedObj.exploderIndex ); exploder( destroyedObj.exploderIndex );
}
for ( index = 0; index < level.bombZones.size; index++ ) for ( index = 0; index < level.bombZones.size; index++ )
{
level.bombZones[ index ] maps\mp\gametypes\_gameobjects::disableObject(); level.bombZones[ index ] maps\mp\gametypes\_gameobjects::disableObject();
}
defuseObject maps\mp\gametypes\_gameobjects::disableObject(); defuseObject maps\mp\gametypes\_gameobjects::disableObject();

View File

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