From ddc7e5fcc45e1139b1d36b517317831cc0647618 Mon Sep 17 00:00:00 2001 From: ineed bots Date: Thu, 4 Jan 2024 16:08:30 -0600 Subject: [PATCH] fmt --- .astylerc | 14 +- .editorconfig | 2 +- maps/mp/bots/_bot_loadout.gsc | 540 ++++---- maps/mp/bots/_bot_script.gsc | 2460 ++++++++++++++++----------------- maps/mp/bots/_bot_utility.gsc | 283 ++-- maps/mp/gametypes/_bot.gsc | 512 +++---- 6 files changed, 1908 insertions(+), 1903 deletions(-) diff --git a/.astylerc b/.astylerc index c0e7be1..4e00611 100644 --- a/.astylerc +++ b/.astylerc @@ -1,21 +1,27 @@ # try to mimic the original gsc provided +# mode=ghc mode=c style=allman -indent=tab +indent=force-tab=2 lineend=windows pad-oper pad-paren-in pad-header - -# delete-empty-lines +# pad-brackets-in +fill-empty-lines +squeeze-lines=2 +squeeze-ws +break-one-line-headers +add-braces +remove-comment-prefix break-blocks -# remove-braces indent-switches indent-cases indent-after-parens +indent-col1-comments remove-comment-prefix diff --git a/.editorconfig b/.editorconfig index bb97c78..be8eb14 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,7 +4,7 @@ root = true indent_style = tab indent_size = 2 charset = latin1 -trim_trailing_whitespace = true +trim_trailing_whitespace = false insert_final_newline = true [*.md] diff --git a/maps/mp/bots/_bot_loadout.gsc b/maps/mp/bots/_bot_loadout.gsc index f697fab..d0fa4c4 100644 --- a/maps/mp/bots/_bot_loadout.gsc +++ b/maps/mp/bots/_bot_loadout.gsc @@ -16,152 +16,152 @@ bot_give_loadout() { self bot_giveKillstreaks(); - + self clearperks(); - + 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"; self.bot[ "specialty3" ] = "specialty_null"; - + if ( self.pers[ "bot" ][ "class_perk1" ] != "" && getdvarint( #"scr_game_perks" ) ) { self.bot[ "specialty1" ] = self.pers[ "bot" ][ "class_perk1" ]; - + id = bot_perk_from_reference_full( self.pers[ "bot" ][ "class_perk1" ] ); tokens = strtok( id[ "reference" ], "|" ); - + for ( i = 0; i < tokens.size; i++ ) { self setperk( tokens[ i ] ); } } - + switch ( self.pers[ "bot" ][ "class_perk1" ] ) { case "perk_ghost": case "perk_ghost_pro": self.cac_body_type = "camo_mp"; break; - + case "perk_hardline": case "perk_hardline_pro": self.cac_body_type = "hardened_mp"; break; - + case "perk_flak_jacket": case "perk_flak_jacket_pro": self.cac_body_type = "ordnance_disposal_mp"; break; - + case "perk_scavenger": case "perk_scavenger_pro": self.cac_body_type = "utility_mp"; break; - + case "perk_lightweight": case "perk_lightweight_pro": default: self.cac_body_type = "standard_mp"; break; } - + self.cac_head_type = self maps\mp\gametypes\_armor::get_default_head(); self.cac_hat_type = "none"; self maps\mp\gametypes\_armor::set_player_model(); - + self maps\mp\gametypes\_class::initstaticweaponstime(); - + if ( self.pers[ "bot" ][ "class_perk2" ] != "" && getdvarint( #"scr_game_perks" ) ) { self.bot[ "specialty2" ] = self.pers[ "bot" ][ "class_perk2" ]; - + id = bot_perk_from_reference_full( self.pers[ "bot" ][ "class_perk2" ] ); 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" ) ) { self.bot[ "specialty3" ] = self.pers[ "bot" ][ "class_perk3" ]; - + id = bot_perk_from_reference_full( self.pers[ "bot" ][ "class_perk3" ] ); 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 ]; - + 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" ); self setactionslot( 4, "" ); - + if ( self.pers[ "bot" ][ "class_equipment" ] != "" && self.pers[ "bot" ][ "class_equipment" ] != "weapon_null_mp" && !getdvarint( #"scr_disable_equipment" ) ) { self giveweapon( self.pers[ "bot" ][ "class_equipment" ] ); - + self maps\mp\gametypes\_class::setweaponammooverall( self.pers[ "bot" ][ "class_equipment" ], 1 ); - + self setactionslot( 1, "weapon", self.pers[ "bot" ][ "class_equipment" ] ); } - + if ( self.pers[ "bot" ][ "class_lethal" ] != "" ) { self giveweapon( self.pers[ "bot" ][ "class_lethal" ] ); - + if ( self hasperk( "specialty_twogrenades" ) ) { self setweaponammoclip( self.pers[ "bot" ][ "class_lethal" ], 2 ); @@ -170,14 +170,14 @@ bot_give_loadout() { self setweaponammoclip( self.pers[ "bot" ][ "class_lethal" ], 1 ); } - + self switchtooffhand( self.pers[ "bot" ][ "class_lethal" ] ); } - + if ( self.pers[ "bot" ][ "class_tacticle" ] != "" ) { self giveweapon( self.pers[ "bot" ][ "class_tacticle" ] ); - + if ( self.pers[ "bot" ][ "class_tacticle" ] == "willy_pete_mp" ) { self setweaponammoclip( self.pers[ "bot" ][ "class_tacticle" ], 1 ); @@ -190,10 +190,10 @@ bot_give_loadout() { self setweaponammoclip( self.pers[ "bot" ][ "class_tacticle" ], 2 ); } - + self setoffhandsecondaryclass( self.pers[ "bot" ][ "class_tacticle" ] ); } - + self setspawnweapon( weap ); } @@ -204,23 +204,23 @@ bot_get_prestige() { p_dvar = getdvarint( "bots_loadout_prestige" ); p = 0; - + if ( p_dvar == -1 ) { for ( i = 0; i < level.players.size; i++ ) { player = level.players[ i ]; - + if ( !isdefined( player.team ) ) { continue; } - + if ( player is_bot() ) { continue; } - + p = player maps\mp\gametypes\_persistence::statget( "plevel" ); break; } @@ -233,7 +233,7 @@ bot_get_prestige() { p = p_dvar; } - + self.pers[ "bot" ][ "prestige" ] = p; } @@ -243,25 +243,25 @@ bot_get_prestige() bot_rank() { self endon( "disconnect" ); - + wait 0.05; - + self.pers[ "rankxp" ] = self.pers[ "bot" ][ "rankxp" ]; rankId = self maps\mp\gametypes\_rank::getrankforxp( self.pers[ "bot" ][ "rankxp" ] ); prestige = self.pers[ "bot" ][ "prestige" ]; - + self.pers[ "rank" ] = rankId; self.pers[ "prestige" ] = prestige; self.pers[ "plevel" ] = prestige; self setrank( rankId, prestige ); - + self maps\mp\gametypes\_rank::syncxpstat(); - + if ( !level.gameended ) { level waittill( "game_ended" ); } - + self.pers[ "bot" ][ "rankxp" ] = self.pers[ "rankxp" ]; } @@ -271,33 +271,33 @@ bot_rank() bot_set_class() { self.pers[ "bot" ][ "class_render_opts" ] = 0; - + self.pers[ "bot" ][ "class_primary" ] = ""; self.pers[ "bot" ][ "class_primary_opts" ] = 0; self.pers[ "bot" ][ "class_secondary" ] = ""; self.pers[ "bot" ][ "class_secondary_opts" ] = 0; - + self.pers[ "bot" ][ "class_lethal" ] = ""; self.pers[ "bot" ][ "class_tacticle" ] = ""; self.pers[ "bot" ][ "class_equipment" ] = ""; - + self.pers[ "bot" ][ "class_perk1" ] = ""; self.pers[ "bot" ][ "class_perk2" ] = ""; self.pers[ "bot" ][ "class_perk3" ] = ""; - + self.pers[ "bot" ][ "cod_points" ] = self.pers[ "bot" ][ "cod_points_org" ]; // refund prev payments for class - + rank = self maps\mp\gametypes\_rank::getrankforxp( self.pers[ "bot" ][ "rankxp" ] ); - + if ( !level.onlinegame ) { rank = level.maxrank; } - + if ( rank < 3 || ( randomint( 100 ) < 3 && !getdvarint( "bots_loadout_reasonable" ) ) ) { _class = ""; - + while ( _class == "" ) { switch ( randomint( 5 ) ) @@ -305,33 +305,33 @@ bot_set_class() case 0: _class = "CLASS_ASSAULT"; break; - + case 1: _class = "CLASS_SMG"; break; - + case 2: _class = "CLASS_CQB"; break; - + case 3: if ( rank >= 1 ) { _class = "CLASS_LMG"; } - + break; - + case 4: if ( rank >= 2 ) { _class = "CLASS_SNIPER"; } - + break; } } - + self.pers[ "bot" ][ "class_primary" ] = level.classweapons[ "axis" ][ _class ][ 0 ]; self.pers[ "bot" ][ "class_secondary" ] = level.classsidearm[ "axis" ][ _class ]; self.pers[ "bot" ][ "class_perk1" ] = level.default_perkicon[ _class ][ 0 ]; @@ -346,13 +346,13 @@ bot_set_class() self bot_get_random_perk( "1", rank ); self bot_get_random_perk( "2", rank ); self bot_get_random_perk( "3", rank ); - + self bot_get_random_weapon( "primary", rank ); self bot_get_random_weapon( "secondary", rank ); self bot_get_random_weapon( "primarygrenade", rank ); self bot_get_random_weapon( "specialgrenade", rank ); self bot_get_random_weapon( "equipment", rank ); - + if ( rank >= 21 ) { camo = self bot_random_camo(); @@ -361,7 +361,7 @@ bot_set_class() { camo = 0; } - + if ( rank >= 18 ) { tag = self bot_random_tag(); @@ -370,7 +370,7 @@ bot_set_class() { tag = 0; } - + if ( rank >= 15 ) { emblem = self bot_random_emblem(); @@ -379,7 +379,7 @@ bot_set_class() { emblem = 0; } - + if ( issubstr( self.pers[ "bot" ][ "class_primary" ], "_elbit_" ) || issubstr( self.pers[ "bot" ][ "class_primary" ], "_reflex_" ) ) { if ( rank >= 24 ) @@ -390,7 +390,7 @@ bot_set_class() { reticle = 0; } - + if ( rank >= 27 ) { lens = self bot_random_lens(); @@ -405,9 +405,9 @@ bot_set_class() lens = 0; reticle = 0; } - + self.pers[ "bot" ][ "class_primary_opts" ] = self calcweaponoptions( camo, lens, reticle, tag, emblem ); - + if ( rank >= 30 ) { face = self bot_random_face(); @@ -416,10 +416,10 @@ bot_set_class() { 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" ] = ""; @@ -435,62 +435,62 @@ bot_get_random_weapon( slot, rank ) { level.bot_weapon_ids = []; } - + if ( !isdefined( level.bot_weapon_ids[ slot ] ) ) { level.bot_weapon_ids[ slot ] = []; - + keys = getarraykeys( level.tbl_weaponids ); - + for ( i = 0; i < keys.size; i++ ) { key = keys[ i ]; 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 ) { level.bot_weapon_ids[ slot ][ level.bot_weapon_ids[ slot ].size ] = id; } } } - + reason = getdvarint( "bots_loadout_reasonable" ); 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 ) { switch ( id[ "reference" ] ) @@ -500,17 +500,17 @@ bot_get_random_weapon( slot, rank ) { continue; } - + break; - + case "camera_spike": if ( self.pers[ "bot" ][ "cod_points" ] >= 2500 ) { continue; } - + break; - + case "nightingale": case "tabun_gas": case "rottweil72": @@ -530,58 +530,58 @@ bot_get_random_weapon( slot, rank ) continue; } } - + if ( id[ "reference" ] == "hatchet" && randomint( 100 ) > 20 ) { continue; } - + if ( id[ "reference" ] == "willy_pete" && randomint( 100 ) > 20 ) { continue; } - + if ( id[ "reference" ] == "nightingale" && randomint( 100 ) > 20 ) { continue; } - + if ( id[ "reference" ] == "claymore" && diff <= 0 && randomint( 100 ) > 20 ) { continue; } - + if ( id[ "reference" ] == "scrambler" && diff <= 0 && randomint( 100 ) > 20 ) { continue; } - + 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 ); @@ -590,33 +590,33 @@ bot_get_random_weapon( slot, rank ) { weap = id[ "reference" ]; } - + weap = bot_validate_weapon( weap ); weap = weap + "_mp"; - + switch ( slot ) { case "equipment": self.pers[ "bot" ][ "class_equipment" ] = weap; break; - + case "primary": self.pers[ "bot" ][ "class_primary" ] = weap; break; - + case "secondary": self.pers[ "bot" ][ "class_secondary" ] = weap; break; - + case "primarygrenade": self.pers[ "bot" ][ "class_lethal" ] = weap; break; - + case "specialgrenade": self.pers[ "bot" ][ "class_tacticle" ] = weap; break; } - + break; } } @@ -627,40 +627,40 @@ bot_get_random_weapon( slot, rank ) bot_get_random_perk( slot, rank ) { reason = getdvarint( "bots_loadout_reasonable" ); - + for ( ;; ) { 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" ) @@ -668,15 +668,15 @@ bot_get_random_perk( slot, rank ) continue; } } - + self.pers[ "bot" ][ "cod_points" ] = self.pers[ "bot" ][ "cod_points" ] - cost; self.pers[ "bot" ][ "class_perk" + slot ] = id[ "reference_full" ]; break; } - + id = bot_perk_from_reference_full( self.pers[ "bot" ][ "class_perk" + slot ] + "_pro" ); cost = int( id[ "cost" ] ); - + if ( int( cost ) <= self.pers[ "bot" ][ "cod_points" ] && randomfloatrange( 0, 1 ) < ( ( rank / level.maxrank ) + 0.1 ) ) { self.pers[ "bot" ][ "cod_points" ] = self.pers[ "bot" ][ "cod_points" ] - cost; @@ -692,12 +692,12 @@ bot_random_face() for ( ;; ) { face = randomint( 25 ); - + if ( face == 0 ) { return face; } - + if ( face >= 17 ) { if ( face >= 21 ) // pres faces @@ -706,65 +706,65 @@ bot_random_face() { continue; } - + self.pers[ "bot" ][ "cod_points" ] -= 500; - + return face; } - + if ( face == 17 ) { if ( self.pers[ "bot" ][ "cod_points" ] < 1500 ) { continue; } - + self.pers[ "bot" ][ "cod_points" ] -= 1500; - + return face; } - + if ( face == 18 ) { if ( self.pers[ "bot" ][ "cod_points" ] < 3500 ) { continue; } - + self.pers[ "bot" ][ "cod_points" ] -= 3500; - + return face; } - + if ( face == 19 ) { if ( self.pers[ "bot" ][ "cod_points" ] < 5500 ) { continue; } - + self.pers[ "bot" ][ "cod_points" ] -= 5500; - + return face; } - + if ( self.pers[ "bot" ][ "cod_points" ] < 7500 ) { continue; } - + self.pers[ "bot" ][ "cod_points" ] -= 7500; - + return face; } - + if ( self.pers[ "bot" ][ "cod_points" ] < 500 ) { continue; } - + self.pers[ "bot" ][ "cod_points" ] -= 500; - + return face; } } @@ -777,19 +777,19 @@ bot_random_lens() for ( ;; ) { lens = randomint( 6 ); - + if ( lens == 0 ) { return lens; } - + if ( self.pers[ "bot" ][ "cod_points" ] < 500 ) { continue; } - + self.pers[ "bot" ][ "cod_points" ] -= 500; - + return lens; } } @@ -802,19 +802,19 @@ bot_random_reticle() for ( ;; ) { ret = randomint( 40 ); - + if ( ret == 0 ) { return ret; } - + if ( self.pers[ "bot" ][ "cod_points" ] < 500 ) { continue; } - + self.pers[ "bot" ][ "cod_points" ] -= 500; - + return ret; } } @@ -827,19 +827,19 @@ bot_random_tag() for ( ;; ) { tag = randomint( 2 ); - + if ( tag == 0 ) { return tag; } - + if ( self.pers[ "bot" ][ "cod_points" ] < 1000 ) { continue; } - + self.pers[ "bot" ][ "cod_points" ] -= 1000; - + return tag; } } @@ -852,19 +852,19 @@ bot_random_emblem() for ( ;; ) { emblem = randomint( 2 ); - + if ( emblem == 0 ) { return emblem; } - + if ( self.pers[ "bot" ][ "cod_points" ] < 1000 ) { continue; } - + self.pers[ "bot" ][ "cod_points" ] -= 1000; - + return emblem; } } @@ -877,31 +877,31 @@ bot_random_camo() for ( ;; ) { 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; - + return camo; } - + if ( self.pers[ "bot" ][ "cod_points" ] < 250 ) { continue; } - + self.pers[ "bot" ][ "cod_points" ] -= 250; - + return camo; } } @@ -913,32 +913,32 @@ doTheCheck_() bot_weapon_cost( id ) { cost = int( id[ "cost" ] ); - + if ( id[ "classified" ] != 0 ) { 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" ] ); } } - + return cost; } @@ -953,34 +953,34 @@ bot_weapon_unlocked( id, rank ) { case "weapon_pistol": return ( rank >= 17 ); - + case "weapon_smg": return ( rank >= 40 ); - + case "weapon_assault": return ( rank >= 43 ); - + case "weapon_lmg": return ( rank >= 20 ); - + case "weapon_sniper": return ( rank >= 26 ); - + case "weapon_cqb": return ( rank >= 23 ); - + default: return false; } } - + unlock = int( id[ "unlock_level" ] ); - + if ( unlock <= 3 ) { return true; } - + return ( rank >= unlock ); } @@ -993,10 +993,10 @@ bot_attachment_cost( att ) { case "upgradesight": return 250; - + case "snub": return 500; - + case "elbit": case "extclip": case "dualclip": @@ -1009,17 +1009,17 @@ bot_attachment_cost( att ) case "speed": case "dw": return 1000; - + case "ir": case "silencer": case "vzoom": case "auto": return 2000; - + case "gl": case "rf": return 3000; - + default: return 0; } @@ -1031,39 +1031,39 @@ bot_attachment_cost( att ) bot_validate_weapon( weap ) { 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; } @@ -1075,24 +1075,24 @@ bot_random_attachments( weap, atts, num ) weapon = weap; attachments = strtok( atts, " " ); attachments[ attachments.size ] = ""; - + reason = getdvarint( "bots_loadout_reasonable" ); - + for ( ;; ) { if ( attachments.size <= 0 ) { return ( weapon ); } - + attachment = PickRandom( attachments ); attachments = array_remove( attachments, attachment ); - + if ( attachment == "" ) { return weapon; } - + if ( reason ) { switch ( attachment ) @@ -1106,7 +1106,7 @@ bot_random_attachments( weap, atts, num ) case "auto": continue; } - + if ( attachment == "silencer" ) { switch ( weap ) @@ -1117,41 +1117,41 @@ 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; } - + for ( ;; ) { if ( attachments.size <= 0 ) { return ( weapon ); } - + _attachment = PickRandom( attachments ); attachments = array_remove( attachments, _attachment ); - + if ( _attachment == "" ) { return weapon; } - + if ( reason ) { switch ( _attachment ) @@ -1165,7 +1165,7 @@ bot_random_attachments( weap, atts, num ) case "auto": continue; } - + if ( attachment == "silencer" ) { switch ( weap ) @@ -1176,29 +1176,29 @@ 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; return weapon; @@ -1211,18 +1211,18 @@ bot_random_attachments( weap, atts, num ) bot_perk_from_reference_full( reference_full ) { keys = getarraykeys( level.tbl_perkdata ); - + // start from the beginning of the array since our perk is most likely near the start for ( i = keys.size - 1; i >= 0; i-- ) { key = keys[ i ]; - + if ( level.tbl_perkdata[ key ][ "reference_full" ] == reference_full ) { return level.tbl_perkdata[ key ]; } } - + return undefined; } @@ -1236,34 +1236,34 @@ bot_get_cod_points() self.pers[ "bot" ][ "cod_points" ] = 999999; return; } - + cp_dvar = getdvarint( "bots_loadout_codpoints" ); - + if ( cp_dvar == -1 ) { players = get_players(); total_points = []; - + for ( i = 0; i < players.size; i++ ) { if ( players[ i ] is_bot() ) { continue; } - + 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" ]; } - + if ( !total_points.size ) { total_points[ total_points.size ] = Round( random_normal_distribution( 50000, 15000, 0, 100000 ) ); } - + point_average = array_average( total_points ); self.pers[ "bot" ][ "cod_points" ] = int( point_average * randomfloatrange( 0.6, 0.8 ) ); } @@ -1284,27 +1284,27 @@ bot_get_rank() { rank = 1; rank_dvar = getdvarint( "bots_loadout_rank" ); - + if ( rank_dvar == -1 ) { players = get_players(); - + ranks = []; bot_ranks = []; human_ranks = []; - + for ( i = 0; i < players.size; i++ ) { if ( players[ i ] == self ) { continue; } - + if ( !isdefined( players[ i ].pers[ "rank" ] ) ) { continue; } - + if ( players[ i ] is_bot() ) { bot_ranks[ bot_ranks.size ] = players[ i ].pers[ "rank" ]; @@ -1314,26 +1314,26 @@ bot_get_rank() human_ranks[ human_ranks.size ] = players[ i ].pers[ "rank" ]; } } - + if ( !human_ranks.size ) { human_ranks[ human_ranks.size ] = Round( random_normal_distribution( 35, 20, 0, level.maxrank ) ); } - + human_avg = array_average( human_ranks ); - + while ( bot_ranks.size + human_ranks.size < 5 ) { // add some random ranks for better random number distribution rank = human_avg + randomintrange( -10, 10 ); human_ranks[ human_ranks.size ] = rank; } - + ranks = array_combine( human_ranks, bot_ranks ); - + avg = array_average( ranks ); s = array_std_deviation( ranks, avg ); - + rank = Round( random_normal_distribution( avg, s, 0, level.maxrank ) ); } else if ( rank_dvar == 0 ) @@ -1344,7 +1344,7 @@ bot_get_rank() { rank = Round( random_normal_distribution( rank_dvar, 5, 0, level.maxrank ) ); } - + self.pers[ "bot" ][ "rankxp" ] = maps\mp\gametypes\_rank::getrankinfominxp( rank ); } @@ -1354,11 +1354,11 @@ bot_get_rank() bot_setKillstreaks() { allowed_killstreaks = []; - + allowed_killstreaks[ 0 ] = "killstreak_spyplane"; allowed_killstreaks[ 1 ] = "killstreak_supply_drop"; allowed_killstreaks[ 2 ] = "killstreak_helicopter_comlink"; - + if ( self maps\mp\gametypes\_rank::getrankforxp( self.pers[ "bot" ][ "rankxp" ] ) >= 9 || !level.onlinegame ) { allowed_killstreaks[ 3 ] = "killstreak_auto_turret_drop"; @@ -1374,40 +1374,40 @@ bot_setKillstreaks() allowed_killstreaks[ 13 ] = "killstreak_helicopter_gunner"; allowed_killstreaks[ 14 ] = "killstreak_helicopter_player_firstperson"; } - + used_levels = []; - + self.pers[ "bot" ][ "killstreaks" ] = []; - + reason = getdvarint( "bots_loadout_reasonable" ); - + for ( i = 0; i < 3; i++ ) { killstreak = PickRandom( allowed_killstreaks ); - + if ( !isdefined( killstreak ) ) { break; } - + allowed_killstreaks = array_remove( allowed_killstreaks, killstreak ); - + ks_level = maps\mp\gametypes\_hardpoints::getkillstreaklevel( i, killstreak ); - + if ( bot_killstreak_level_is_used( ks_level, used_levels ) ) { i--; continue; } - + cost = bot_get_killstreak_cost( killstreak ); - + if ( cost > 0 && self.pers[ "bot" ][ "cod_points" ] < cost ) { i--; continue; } - + if ( reason ) { switch ( killstreak ) @@ -1421,7 +1421,7 @@ bot_setKillstreaks() continue; } } - + self.pers[ "bot" ][ "cod_points" ] = self.pers[ "bot" ][ "cod_points" ] - cost; used_levels[ used_levels.size ] = ks_level; self.pers[ "bot" ][ "killstreaks" ][ i ] = killstreak; @@ -1438,40 +1438,40 @@ bot_get_killstreak_cost( ks ) { case "killstreak_auto_turret_drop": return 3200; - + case "killstreak_tow_turret_drop": return 1600; - + case "killstreak_napalm": return 2400; - + case "killstreak_counteruav": return 1600; - + case "killstreak_mortar": return 3200; - + case "killstreak_spyplane_direction": return 4500; - + case "killstreak_airstrike": return 4500; - + case "killstreak_dogs": return 6000; - + case "killstreak_rcbomb": return 1200; - + case "killstreak_helicopter_gunner": return 5000; - + case "killstreak_helicopter_player_firstperson": return 6000; - + case "killstreak_m220_tow_drop": return 4000; - + default: return 0; } @@ -1500,6 +1500,6 @@ bot_killstreak_level_is_used( ks_level, used_levels ) return true; } } - + return false; } diff --git a/maps/mp/bots/_bot_script.gsc b/maps/mp/bots/_bot_script.gsc index 46294f4..04940ee 100644 --- a/maps/mp/bots/_bot_script.gsc +++ b/maps/mp/bots/_bot_script.gsc @@ -16,17 +16,17 @@ added() { self endon( "disconnect" ); - + self.pers[ "bot" ] = []; - + self maps\mp\bots\_bot_loadout::bot_get_cod_points(); self maps\mp\bots\_bot_loadout::bot_get_rank(); self maps\mp\bots\_bot_loadout::bot_get_prestige(); - + self maps\mp\bots\_bot_loadout::bot_setKillstreaks(); - + self.pers[ "bot" ][ "cod_points_org" ] = self.pers[ "bot" ][ "cod_points" ]; // killstreaks cannot be set again - + self maps\mp\bots\_bot_loadout::bot_set_class(); } @@ -36,16 +36,16 @@ added() connected() { self endon( "disconnect" ); - + self thread classWatch(); self thread teamWatch(); - + self thread maps\mp\bots\_bot_loadout::bot_rank(); self thread bot_skip_killcam(); - + self thread bot_on_spawn(); self thread bot_on_death(); - + self thread bot_watch_rcbomb(); } @@ -56,11 +56,11 @@ bot_on_death() { self endon( "disconnect" ); level endon( "game_ended" ); - + for ( ;; ) { self waittill( "death" ); - + self.wantsafespawn = true; // force bots to spawn when force respawn is false } } @@ -72,18 +72,18 @@ bot_skip_killcam() { level endon( "game_ended" ); self endon( "disconnect" ); - + for ( ;; ) { wait 1; - + if ( isdefined( self.killcam ) ) { self BotNotifyBotEvent( "killcam", "start" ); - + self notify( "end_killcam" ); self clientnotify( "fkce" ); - + self BotNotifyBotEvent( "killcam", "stop" ); } } @@ -103,23 +103,23 @@ chooseRandomClass() classWatch() { self endon( "disconnect" ); - + for ( ;; ) { while ( !isdefined( self.pers[ "team" ] ) || !allowClassChoice() ) { wait .05; } - + wait 0.5; - + if ( !maps\mp\gametypes\_globallogic_utils::isvalidclass( self.class ) || !isdefined( self.bot_change_class ) ) { self notify( "menuresponse", game[ "menu_changeclass" ], self chooseRandomClass() ); } - + self.bot_change_class = true; - + while ( isdefined( self.pers[ "team" ] ) && maps\mp\gametypes\_globallogic_utils::isvalidclass( self.class ) && isdefined( self.bot_change_class ) ) { wait .05; @@ -133,21 +133,21 @@ classWatch() teamWatch() { self endon( "disconnect" ); - + for ( ;; ) { while ( !isdefined( self.pers[ "team" ] ) || !allowTeamChoice() ) { wait .05; } - + wait 0.1; - + if ( self.team != "axis" && self.team != "allies" ) { self notify( "menuresponse", game[ "menu_team" ], getdvar( "bots_team" ) ); } - + while ( isdefined( self.pers[ "team" ] ) ) { wait .05; @@ -162,18 +162,18 @@ bot_on_spawn() { self endon( "disconnect" ); level endon( "game_ended" ); - + for ( ;; ) { self waittill( "spawned_player" ); self BotBuiltinClearOverrides( true ); self BotBuiltinWeaponOverride( self getcurrentweapon() ); - + self.bot_lock_goal = false; self.help_time = undefined; self.bot_was_follow_script_update = undefined; self.bot_attacking_plane = false; - + // grenade c4 watcher self thread bot_spawn(); } @@ -188,63 +188,63 @@ bot_damage_callback( eAttacker, iDamage, sMeansOfDeath, sWeapon, eInflictor, sHi { return; } - + self.killerlocation = undefined; self.lastkiller = undefined; - + if ( !isdefined( self ) || !isdefined( self.team ) ) { return; } - + if ( !isalive( self ) ) { return; } - + if ( sMeansOfDeath == "MOD_FALLING" || sMeansOfDeath == "MOD_SUICIDE" ) { return; } - + if ( iDamage <= 0 ) { return; } - + if ( !isdefined( eAttacker ) || !isdefined( eAttacker.team ) ) { return; } - + if ( eAttacker == self ) { return; } - + if ( level.teambased && eAttacker.team == self.team ) { return; } - + if ( !isdefined( eInflictor ) || eInflictor.classname != "player" ) { return; } - + if ( !isalive( eAttacker ) ) { return; } - + self.killerlocation = eAttacker.origin; self.lastkiller = eAttacker; - + if ( !issubstr( sWeapon, "_silencer_" ) ) { self bot_cry_for_help( eAttacker ); } - + self setattacker( eAttacker ); } @@ -268,57 +268,57 @@ bot_cry_for_help( attacker ) { return; } - + theTime = gettime(); - + if ( isdefined( self.help_time ) && theTime - self.help_time < 1000 ) { return; } - + self.help_time = theTime; - + for ( i = level.players.size - 1; i >= 0; i-- ) { player = level.players[ i ]; - + if ( !player is_bot() ) { continue; } - + if ( !isdefined( player.team ) ) { continue; } - + if ( !isalive( player ) ) { continue; } - + if ( player == self ) { continue; } - + if ( player.team != self.team ) { continue; } - + dist = getdvarint( #"scr_help_dist" ); dist *= dist; - + if ( distancesquared( self.origin, player.origin ) > dist ) { continue; } - + if ( randomint( 100 ) < 50 ) { self setattacker( attacker ); - + if ( randomint( 100 ) > 70 ) { break; @@ -335,36 +335,36 @@ bot_spawn() self endon( "death" ); self endon( "disconnect" ); level endon( "game_ended" ); - + if ( randomint( 100 ) < 1 ) { self maps\mp\bots\_bot_loadout::bot_set_class(); } - + if ( getdvarint( "bots_play_obj" ) ) { self thread bot_dom_cap_think(); } - + if ( !level.inprematchperiod ) { switch ( self GetBotDiffNum() ) { case 3: break; - + case 0: self BotFreezeControls( true ); wait 0.8; self BotFreezeControls( false ); break; - + case 1: self BotFreezeControls( true ); wait 0.5; self BotFreezeControls( false ); break; - + case 2: self BotFreezeControls( true ); wait 0.25; @@ -379,32 +379,32 @@ bot_spawn() wait ( 0.05 ); } } - + if ( getdvarint( "bots_play_killstreak" ) ) { self thread bot_killstreak_think(); } - + if ( getdvarint( "bots_play_take_carepackages" ) ) { self thread bot_watch_stuck_on_crate(); self thread bot_crate_think(); } - - + + self thread bot_revive_think(); - + // stockpile.gsc // hotel.gsc // kowloon.gsc self thread bot_radiation_think(); - + if ( getdvarint( "bots_play_nade" ) ) { self thread bot_use_equipment_think(); self thread bot_watch_think_mw2(); } - + if ( getdvarint( "bots_play_target_other" ) ) { self thread bot_target_vehicle(); @@ -412,39 +412,39 @@ bot_spawn() self thread bot_turret_think(); self thread bot_dogs_think(); } - + if ( getdvarint( "bots_play_camp" ) ) { /* self thread bot_think_follow(); self thread bot_think_camp();*/ } - - + + self thread bot_uav_think(); self thread bot_weapon_think(); // reload cancel self thread bot_listen_to_steps(); self thread bot_revenge_think(); self thread follow_target(); - + if ( getdvarint( "bots_play_obj" ) ) { self thread bot_dom_def_think(); self thread bot_dom_spawn_kill_think(); - + self thread bot_cap(); self thread bot_hq(); - + self thread bot_sab(); - + self thread bot_sd_defenders(); self thread bot_sd_attackers(); - + self thread bot_dem_attackers(); self thread bot_dem_defenders(); } - + self thread watch_for_override_stuff(); self thread watch_for_melee_override(); } @@ -457,21 +457,21 @@ bot_inc_bots( obj, unreach ) { level endon( "game_ended" ); self endon( "bot_inc_bots" ); - + if ( !isdefined( obj ) ) { return; } - + if ( !isdefined( obj.bots ) ) { obj.bots = 0; } - + obj.bots++; - + ret = self waittill_any_return( "death", "disconnect", "bad_path", "goal", "new_goal" ); - + if ( isdefined( obj ) && ( ret != "bad_path" || !isdefined( unreach ) ) ) { obj.bots--; @@ -488,17 +488,17 @@ bots_watch_touch_obj( obj ) self endon ( "bad_path" ); self endon ( "goal" ); self endon ( "new_goal" ); - + for ( ;; ) { wait 0.5; - + if ( !isdefined( obj ) ) { self notify( "bad_path" ); return; } - + if ( self istouching( obj ) ) { self notify( "goal" ); @@ -517,22 +517,22 @@ bot_escort_obj( obj, carrier ) self endon( "goal" ); self endon( "bad_path" ); self endon( "new_goal" ); - + for ( ;; ) { wait 0.5; - + if ( !isdefined( obj ) ) { break; } - + if ( !isdefined( obj.carrier ) || carrier == obj.carrier ) { break; } } - + self notify( "goal" ); } @@ -546,22 +546,22 @@ bot_get_obj( obj ) self endon( "goal" ); self endon( "bad_path" ); self endon( "new_goal" ); - + for ( ;; ) { wait 0.5; - + if ( !isdefined( obj ) ) { break; } - + if ( isdefined( obj.carrier ) ) { break; } } - + self notify( "goal" ); } @@ -576,17 +576,17 @@ bot_defend_site( site ) self endon( "goal" ); self endon( "bad_path" ); self endon( "new_goal" ); - + for ( ;; ) { wait 0.5; - + if ( !site isInUse() ) { break; } } - + self notify( "bad_path" ); } @@ -601,22 +601,22 @@ bot_go_plant( plant ) self endon( "goal" ); self endon( "bad_path" ); self endon( "new_goal" ); - + for ( ;; ) { wait 1; - + if ( level.bombplanted ) { break; } - + if ( self istouching( plant.trigger ) ) { break; } } - + if ( level.bombplanted ) { self notify( "bad_path" ); @@ -638,22 +638,22 @@ bot_go_defuse( plant ) self endon( "goal" ); self endon( "bad_path" ); self endon( "new_goal" ); - + for ( ;; ) { wait 1; - + if ( !level.bombplanted ) { break; } - + if ( self istouching( plant.trigger ) ) { break; } } - + if ( !level.bombplanted ) { self notify( "bad_path" ); @@ -698,16 +698,16 @@ bot_do_random_action_for_objective( obj_target ) self endon( "disconnect" ); self notify( "bot_do_random_action_for_objective" ); self endon( "bot_do_random_action_for_objective" ); - + if ( !isdefined( self.bot_random_obj_action ) ) { self.bot_random_obj_action = true; - + if ( randomint( 100 ) < 80 ) { self thread BotUseRandomEquipment(); } - + if ( randomint( 100 ) < 75 ) { self thread BotLookAtRandomThing( obj_target ); @@ -724,7 +724,7 @@ bot_do_random_action_for_objective( obj_target ) self thread BotLookAtRandomThing( obj_target ); } } - + wait 2; self.bot_random_obj_action = undefined; } @@ -738,7 +738,7 @@ fire_c4() self endon( "disconnect" ); self endon( "weapon_change" ); self endon( "stop_firing_weapon" ); - + for ( ;; ) { // self thread BotPressAds( 0.05 ); @@ -773,21 +773,21 @@ changeToWeapon( weap ) self endon( "disconnect" ); self endon( "death" ); level endon( "game_ended" ); - + if ( !self hasweapon( weap ) ) { return false; } - + self switchtoweapon( weap ); - + if ( self getcurrentweapon() == weap ) { return true; } - + self waittill_any_timeout( 5, "weapon_change" ); - + return ( self getcurrentweapon() == weap ); } @@ -800,9 +800,9 @@ fire_current_weapon() self endon( "disconnect" ); self endon( "weapon_change" ); self endon( "stop_firing_weapon" ); - + wait 0.5; - + for ( ;; ) { self pressattackbutton(); @@ -816,54 +816,54 @@ fire_current_weapon() getKillstreakTargetLocation() { diff = self GetBotDiffNum(); - + location = undefined; players = []; - + for ( i = level.players.size - 1; i >= 0; i-- ) { player = level.players[ i ]; - + if ( player == self ) { continue; } - + if ( !isdefined( player.team ) ) { continue; } - + if ( level.teambased && self.team == player.team ) { continue; } - + if ( player.sessionstate != "playing" ) { continue; } - + if ( !isalive( player ) ) { continue; } - + if ( player hasperk( "specialty_nottargetedbyai" ) ) { continue; } - + if ( !bullettracepassed( player.origin, player.origin + ( 0, 0, 2048 ), false, player ) && diff > 0 ) { continue; } - + players[ players.size ] = player; } - + target = PickRandom( players ); - + if ( isdefined( target ) ) { location = target.origin + ( randomintrange( ( 4 - diff ) * -75, ( 4 - diff ) * 75 ), randomintrange( ( 4 - diff ) * -75, ( 4 - diff ) * 75 ), 0 ); @@ -872,7 +872,7 @@ getKillstreakTargetLocation() { location = self.origin + ( randomintrange( -512, 512 ), randomintrange( -512, 512 ), 0 ); } - + return location; } @@ -882,40 +882,40 @@ getKillstreakTargetLocation() bot_rccar_think( weapon, killstreak ) { diff = self GetBotDiffNum(); - + if ( diff > 0 ) { if ( self getlookaheaddist() < 128 ) { return; } - + dir = self getlookaheaddir(); - + if ( !isdefined( dir ) ) { return; } - + dir = vectortoangles( dir ); - + if ( abs( dir[ 1 ] - self.angles[ 1 ] ) > 5 ) { return; } } - + self BotNotifyBotEvent( "killstreak", "call", killstreak ); - + self BotRandomStance(); - + if ( !self changeToWeapon( weapon ) ) { return; } - + wait 2; - + while ( isdefined( self.rcbomb ) ) { wait 1; @@ -928,16 +928,16 @@ bot_rccar_think( weapon, killstreak ) bot_watch_rcbomb() { self endon( "disconnect" ); - + for ( ;; ) { wait 2; - + if ( !isdefined( self.rcbomb ) ) { continue; } - + self bot_watch_rccar(); } } @@ -949,20 +949,20 @@ bot_watch_rccar() { self endon( "weapon_object_destroyed" ); self endon( "rcbomb_done" ); - + diff = self GetBotDiffNum(); stuck_time = 0; last_org = self.origin; - + for ( ;; ) { wait 0.5; - + if ( !isdefined( self.rcbomb ) ) { return; } - + if ( distancesquared( self.rcbomb.origin, last_org ) < 4 * 4 ) { stuck_time += 0.5; @@ -971,40 +971,40 @@ bot_watch_rccar() { stuck_time = 0; } - + last_org = self.rcbomb.origin; - + players = get_players(); - + for ( i = 0; i < players.size; i++ ) { player = players[ i ]; - + if ( player == self ) { continue; } - + if ( !isdefined( player.team ) ) { continue; } - + if ( !isalive( player ) ) { continue; } - + if ( level.teambased && player.team == self.team ) { continue; } - + if ( !sighttracepassed( self.rcbomb.origin, player.origin, false, self.rcbomb ) ) { continue; } - + if ( diff == 0 ) { if ( distancesquared( self.rcbomb.origin, player.origin ) < 512 * 512 ) @@ -1024,7 +1024,7 @@ bot_watch_rccar() self pressattackbutton(); } } - + if ( stuck_time > 3 ) { self pressattackbutton(); @@ -1043,77 +1043,77 @@ bot_use_supply_drop( weapon, killstreak ) { return; } - + view_angles = self getplayerangles(); - + if ( view_angles[ 0 ] < 7 ) { return; } - + dir = self getlookaheaddir(); - + if ( !isdefined( dir ) ) { return; } - + dir = vectortoangles( dir ); - + if ( abs( dir[ 1 ] - self.angles[ 1 ] ) > 2 ) { return; } - + yaw = ( 0, self.angles[ 1 ], 0 ); dir = anglestoforward( yaw ); - + dir = vectornormalize( dir ); drop_point = self.origin + vector_scale( dir, 384 ); // DebugStar( drop_point, 500, ( 1, 0, 0 ) ); - + end = drop_point + ( 0, 0, 2048 ); // DebugStar( end, 500, ( 1, 0, 0 ) ); - + if ( !sighttracepassed( drop_point, end, false, undefined ) ) { return; } - + if ( !sighttracepassed( self.origin, end, false, undefined ) ) { return; } - + // is this point in mid-air? end = drop_point - ( 0, 0, 32 ); - + // DebugStar( end, 500, ( 1, 0, 0 ) ); if ( bullettracepassed( drop_point, end, false, undefined ) ) { return; } } - + self BotNotifyBotEvent( "killstreak", "call", killstreak ); - + self botStopMove( true ); - + if ( self changeToWeapon( weapon ) ) { self thread fire_current_weapon(); - + ret = self waittill_any_timeout( 5, "grenade_fire" ); self notify( "stop_firing_weapon" ); - + self thread changeToWeapon( self.lastnonkillstreakweapon ); - + if ( ret == "grenade_fire" && randomint( 100 ) < 80 && !self hasscriptgoal() && !self.bot_lock_goal ) { self waittill_any_timeout( 15, "bot_crate_landed", "new_goal" ); } } - + self botStopMove( false ); } @@ -1128,63 +1128,63 @@ bot_turret_location( weapon, killstreak ) { return; } - + dir = self getlookaheaddir(); - + if ( !isdefined( dir ) ) { return; } - + dir = vectortoangles( dir ); - + if ( abs( dir[ 1 ] - self.angles[ 1 ] ) > 5 ) { return; } - + yaw = ( 0, self.angles[ 1 ], 0 ); dir = anglestoforward( yaw ); dir = vectornormalize( dir ); - + goal = self.origin + vector_scale( dir, 32 ); - + if ( weapon == "autoturret_mp" ) { eye = self.origin + ( 0, 0, 60 ); goal = eye + vector_scale( dir, 1024 ); - + if ( !sighttracepassed( self.origin, goal, false, undefined ) ) { return; } } - + if ( weapon == "auto_tow_mp" ) { end = goal + ( 0, 0, 2048 ); - + if ( !sighttracepassed( goal, end, false, undefined ) ) { return; } } } - + self BotNotifyBotEvent( "killstreak", "call", killstreak ); - + self botStopMove( true ); - + if ( self changeToWeapon( weapon ) ) { self thread fire_current_weapon(); - + wait 1.5; self notify( "stop_firing_weapon" ); - + self thread changeToWeapon( self.lastnonkillstreakweapon ); } - + self botStopMove( false ); } @@ -1194,26 +1194,26 @@ bot_turret_location( weapon, killstreak ) bot_control_heli( weapon, killstreak ) { self BotNotifyBotEvent( "killstreak", "call", killstreak ); - + self BotRandomStance(); - + if ( !self changeToWeapon( weapon ) ) { return; } - + self endon( "heli_timeup" ); - + wait 2.5; - + if ( !isdefined( self.heli ) ) { return; } - + self.heli endon( "death" ); self.heli endon( "heli_timeup" ); - + while ( isdefined( self.heli ) ) { wait 0.25; // TODO do it @@ -1227,58 +1227,58 @@ bot_killstreak_think_loop() { myTeam = self.pers[ "team" ]; otherTeam = getotherteam( myTeam ); - + curWeap = self getcurrentweapon(); - + if ( ( isdefined( self.carryingturret ) && self.carryingturret ) || issubstr( curWeap, "drop_" ) ) { self pressattackbutton(); } - + if ( isdefined( self getthreat() ) ) { return; } - + if ( self isremotecontrolling() ) { return; } - + if ( self usebuttonpressed() || self BotIsFrozen() ) { return; } - + if ( self isDefusing() || self isPlanting() || self inLastStand() ) { return; } - + weapon = self maps\mp\gametypes\_hardpoints::gettopkillstreak(); - + if ( !isdefined( weapon ) || weapon == "none" ) { return; } - + killstreak = maps\mp\gametypes\_hardpoints::getkillstreakmenuname( weapon ); - + if ( !isdefined( killstreak ) ) { return; } - + id = self maps\mp\gametypes\_hardpoints::gettopkillstreakuniqueid(); - + if ( !self maps\mp\_killstreakrules::iskillstreakallowed( weapon, myTeam ) ) { wait( 5 ); return; } - + diff = self GetBotDiffNum(); - + switch ( killstreak ) { case "killstreak_helicopter_comlink": @@ -1286,54 +1286,54 @@ bot_killstreak_think_loop() case "killstreak_airstrike": case "killstreak_mortar": num = 1; - + if ( killstreak == "killstreak_mortar" ) { num = 3; } - + self BotNotifyBotEvent( "killstreak", "call", killstreak ); - + if ( !self changeToWeapon( weapon ) ) { break; } - + self BotFreezeControls( true ); - + wait 1; - + for ( i = 0; i < num; i++ ) { origin = self getKillstreakTargetLocation(); - + if ( !isdefined( origin ) ) { break; } - + yaw = randomintrange( 0, 360 ); - + wait 0.25; self notify( "confirm_location", origin, yaw ); } - + self BotFreezeControls( false ); - + break; - + case "killstreak_helicopter_gunner": case "killstreak_helicopter_player_firstperson": self bot_control_heli( weapon, killstreak ); wait 1; break; - + case "killstreak_auto_turret": case "killstreak_tow_turret": self bot_turret_location( weapon, killstreak ); wait 1; break; - + case "killstreak_auto_turret_drop": case "killstreak_tow_turret_drop": case "killstreak_m220_tow_drop": @@ -1342,17 +1342,17 @@ bot_killstreak_think_loop() { weapon = "supplydrop_mp"; } - - + + self bot_use_supply_drop( weapon, killstreak ); wait 1; break; - + case "killstreak_rcbomb": self bot_rccar_think( weapon, killstreak ); wait 1; break; - + case "killstreak_spyplane": if ( diff > 0 ) { @@ -1362,12 +1362,12 @@ bot_killstreak_think_loop() { return; } - + if ( level.activesatellites[ myTeam ] ) { return; } - + if ( level.activeuavs[ myTeam ] ) { return; @@ -1376,59 +1376,59 @@ bot_killstreak_think_loop() else { shouldContinue = false; - + players = get_players(); - + for ( i = 0; i < players.size; i++ ) { player = players[ i ]; - + if ( player == self ) { continue; } - + if ( !isdefined( player.team ) ) { continue; } - + if ( isdefined( level.activecounteruavs[ player.entnum ] ) && level.activecounteruavs[ player.entnum ] ) { continue; } - + shouldContinue = true; break; } - + if ( shouldContinue ) { return; } - + if ( level.activesatellites[ self.entnum ] ) { return; } - + if ( level.activeuavs[ self.entnum ] ) { return; } } } - + self BotNotifyBotEvent( "killstreak", "call", killstreak ); - + if ( !self changeToWeapon( weapon ) ) { break; } - + wait 1; break; - + case "killstreak_counteruav": if ( diff > 0 ) { @@ -1447,17 +1447,17 @@ bot_killstreak_think_loop() } } } - + self BotNotifyBotEvent( "killstreak", "call", killstreak ); - + if ( !self changeToWeapon( weapon ) ) { break; } - + wait 1; break; - + case "killstreak_spyplane_direction": if ( diff > 0 ) { @@ -1467,7 +1467,7 @@ bot_killstreak_think_loop() { return; } - + if ( level.activesatellites[ myTeam ] ) { return; @@ -1476,62 +1476,62 @@ bot_killstreak_think_loop() else { shouldContinue = false; - + players = get_players(); - + for ( i = 0; i < players.size; i++ ) { player = players[ i ]; - + if ( player == self ) { continue; } - + if ( !isdefined( player.team ) ) { continue; } - + if ( isdefined( level.activecounteruavs[ player.entnum ] ) && level.activecounteruavs[ player.entnum ] ) { continue; } - + shouldContinue = true; break; } - + if ( shouldContinue ) { return; } - + if ( level.activesatellites[ self.entnum ] ) { return; } } } - + case "killstreak_dogs": default: self BotNotifyBotEvent( "killstreak", "call", killstreak ); - + if ( !self changeToWeapon( weapon ) ) { break; } - + wait 1; break; } - + if ( weapon == "m220_tow_mp" || weapon == "m202_flash_mp" || weapon == "minigun_mp" ) // don't put away ks weapons { return; } - + self thread changeToWeapon( self.lastnonkillstreakweapon ); } @@ -1543,13 +1543,13 @@ bot_killstreak_think() self endon( "death" ); self endon( "disconnect" ); level endon ( "game_ended" ); - + wait( 1 ); - + for ( ;; ) { wait( randomintrange( 1, 3 ) ); - + self bot_killstreak_think_loop(); } } @@ -1562,23 +1562,23 @@ bot_turret_attack( enemy ) enemy endon( "turret_carried" ); enemy endon( "turret_deactivated" ); enemy endon( "death" ); - + wait_time = randomintrange( 7, 10 ); - + for ( i = 0; i < wait_time; i++ ) { wait( 1 ); - + if ( !isdefined( enemy ) ) { return; } - + if ( !isalive( enemy ) ) { return; } - + if ( !bullettracepassed( self geteye(), enemy.origin + ( 0, 0, 15 ), false, enemy ) ) { return; @@ -1596,9 +1596,9 @@ turret_death_monitor( turret ) self endon( "goal" ); self endon( "bad_path" ); self endon ( "new_goal" ); - + turret waittill_any( "turret_carried", "turret_deactivated", "death" ); - + self notify( "bad_path" ); } @@ -1612,27 +1612,27 @@ bot_go_hack_turret( turret ) self endon( "new_goal" ); self endon( "goal" ); self endon( "bad_path" ); - + for ( ;; ) { wait 0.5; - + if ( !isdefined( turret ) ) { break; } - + if ( !isdefined( turret.hackertrigger ) ) { break; } - + if ( self istouching( turret.hackertrigger ) ) { break; } } - + if ( !isdefined( turret ) || !isdefined( turret.hackertrigger ) ) { self notify( "bad_path" ); @@ -1650,170 +1650,170 @@ bot_turret_think_loop() { myTeam = self.pers[ "team" ]; turrets = getentarray( "auto_turret", "classname" ); - + if ( turrets.size == 0 ) { wait( randomintrange( 3, 5 ) ); return; } - + if ( isdefined( self getthreat() ) || self isremotecontrolling() || self usebuttonpressed() || self BotIsFrozen() ) { return; } - + turret = undefined; myEye = self geteye(); - + for ( i = turrets.size - 1; i >= 0; i-- ) { tempTurret = turrets[ i ]; - + if ( !isdefined( tempTurret ) || !isdefined( tempTurret.damagetaken ) ) { continue; } - + if ( tempTurret.damagetaken >= tempTurret.health ) { continue; } - + if ( tempTurret.carried ) { continue; } - + if ( level.teambased && tempTurret.team == myTeam ) { continue; } - + if ( isdefined( tempTurret.owner ) && tempTurret.owner == self ) { continue; } - + if ( !bullettracepassed( myEye, tempTurret.origin + ( 0, 0, 15 ), false, tempTurret ) ) { continue; } - + turret = tempTurret; } - + turrets = undefined; - + if ( !isdefined( turret ) ) { return; } - + forward = anglestoforward( turret.angles ); forward = vectornormalize( forward ); - + delta = self.origin - turret.origin; delta = vectornormalize( delta ); - + dot = vectordot( forward, delta ); - + facing = true; - + if ( dot < 0.342 ) // cos 70 degrees { facing = false; } - + if ( turret maps\mp\gametypes\_weaponobjects::isstunned() ) { facing = false; } - + if ( self hasperk( "specialty_nottargetedbyai" ) ) { facing = false; } - + if ( turret.turrettype == "tow" ) { facing = false; } - + if ( facing && !bullettracepassed( myEye, turret.origin + ( 0, 0, 15 ), false, turret ) ) { return; } - + if ( !isdefined( turret.bots ) ) { turret.bots = 0; } - + if ( turret.bots >= 2 ) { return; } - + if ( !facing && !self hasscriptgoal() && !self.bot_lock_goal ) { if ( self hasperk( "specialty_disarmexplosive" ) ) { self BotNotifyBotEvent( "turret_hack", "go", turret ); - + self SetBotGoal( turret.origin, 32 ); self thread bot_inc_bots( turret, true ); self thread turret_death_monitor( turret ); self thread bot_go_hack_turret( turret ); - + path = self waittill_any_return( "goal", "bad_path", "new_goal" ); - + if ( path != "new_goal" ) { self ClearBotGoal(); } - + if ( path != "goal" || !isdefined( turret ) || !isdefined( turret.hackertrigger ) || !self istouching( turret.hackertrigger ) ) { return; } - + self BotNotifyBotEvent( "turret_hack", "start", turret ); - + // we will be frozen already hackTime = getdvarfloat( #"perk_disarmExplosiveTime" ); self thread BotPressUse( hackTime + 0.5 ); wait( hackTime + 0.5 ); - + self BotNotifyBotEvent( "turret_hack", "stop", turret ); return; } else { self BotNotifyBotEvent( "turret_attack", "go", turret ); - + self SetBotGoal( turret.origin, 32 ); self thread bot_inc_bots( turret, true ); self thread turret_death_monitor( turret ); self thread bots_watch_touch_obj( turret ); - + if ( self waittill_any_return( "bad_path", "goal", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } } } - + if ( !isdefined( turret ) ) { return; } - + self BotNotifyBotEvent( "turret_attack", "start", turret ); - + self setscriptenemy( turret ); self bot_turret_attack( turret ); self clearscriptenemy(); - + self BotNotifyBotEvent( "turret_attack", "stop", turret ); } @@ -1825,11 +1825,11 @@ bot_turret_think() self endon( "death" ); self endon( "disconnect" ); level endon ( "game_ended" ); - + for ( ;; ) { wait( 1 ); - + self bot_turret_think_loop(); } } @@ -1841,13 +1841,13 @@ bot_equipment_attack( equ ) { equ endon( "death" ); equ endon( "hacked" ); - + wait_time = randomintrange( 7, 10 ); - + for ( i = 0; i < wait_time; i++ ) { wait( 1 ); - + if ( !isdefined( equ ) ) { return; @@ -1861,138 +1861,138 @@ bot_equipment_attack( equ ) bot_equipment_kill_think_loop() { myTeam = self.pers[ "team" ]; - + grenades = getentarray( "grenade", "classname" ); hasHacker = self hasperk( "specialty_showenemyequipment" ); myEye = self geteye(); myAngles = self getplayerangles(); target = undefined; - + for ( i = 0; i < grenades.size; i++ ) { item = grenades[ i ]; - + if ( !isdefined( item ) ) { continue; } - + if ( !isdefined( item.name ) ) { continue; } - + if ( !isdefined( item.owner ) ) { continue; } - + if ( level.teambased && item.owner.team == myTeam ) { continue; } - + if ( item.owner == self ) { continue; } - + if ( !isweaponequipment( item.name ) ) { continue; } - + if ( !isdefined( item.bots ) ) { item.bots = 0; } - + if ( item.bots >= 2 ) { continue; } - + if ( !hasHacker && !bullettracepassed( myEye, item.origin, false, item ) ) { continue; } - + if ( getConeDot( item.origin, self.origin, myAngles ) < 0.6 ) { continue; } - + if ( distancesquared( item.origin, self.origin ) < 512 * 512 ) { target = item; break; } } - + grenades = undefined; - + if ( !isdefined( target ) ) { players = get_players(); - + for ( i = 0; i < players.size; i++ ) { player = players[ i ]; - + if ( player == self ) { continue; } - + if ( !isdefined( player.team ) ) { continue; } - + if ( level.teambased && player.team == myTeam ) { continue; } - + if ( !isdefined( player.tacticalinsertion ) ) { continue; } - + if ( !isdefined( player.tacticalinsertion.bots ) ) { player.tacticalinsertion.bots = 0; } - + if ( player.tacticalinsertion.bots >= 2 ) { continue; } - + if ( !hasHacker && !bullettracepassed( myEye, player.tacticalinsertion.origin, false, player.tacticalinsertion ) ) { continue; } - + if ( getConeDot( player.tacticalinsertion.origin, self.origin, myAngles ) < 0.6 ) { continue; } - + if ( distancesquared( player.tacticalinsertion.origin, self.origin ) < 512 * 512 ) { target = player.tacticalinsertion; break; } } - + players = undefined; } - + if ( isdefined( target ) ) { facing = false; - + if ( isdefined( target.name ) && target.name == "claymore_mp" && !target maps\mp\gametypes\_weaponobjects::isstunned() ) { if ( vectordot( vectornormalize( anglestoforward( target.angles ) ), vectornormalize( self.origin - target.origin ) ) >= 0.342 ) // cos 70 degrees @@ -2000,44 +2000,44 @@ bot_equipment_kill_think_loop() facing = true; } } - + if ( ( ( self hasperk( "specialty_disarmexplosive" ) && !facing ) || isdefined( target.enemytrigger ) ) && !self hasscriptgoal() && !self.bot_lock_goal ) { self BotNotifyBotEvent( "hack_equ", "go", target ); - + self SetBotGoal( target.origin, 32 ); self thread bot_inc_bots( target, true ); self thread bots_watch_touch_obj( target ); - + path = self waittill_any_return( "bad_path", "goal", "new_goal" ); - + if ( path != "new_goal" ) { self ClearBotGoal(); } - + if ( path != "goal" || !isdefined( target ) || ( isdefined( target.hackertrigger ) && !self istouching( target.hackertrigger ) ) || ( isdefined( target.enemytrigger ) && !self istouching( target.enemytrigger ) ) ) { return; } - + self BotNotifyBotEvent( "hack_equ", "start", target ); - + // you get frozen already hackTime = getdvarfloat( #"perk_disarmExplosiveTime" ); self thread BotPressUse( hackTime + 0.5 ); wait( hackTime + 0.5 ); - + self BotNotifyBotEvent( "hack_equ", "stop", target ); return; } - + self BotNotifyBotEvent( "attack_equ", "start", target ); - + self setscriptenemy( target ); self bot_equipment_attack( target ); self clearscriptenemy(); - + self BotNotifyBotEvent( "attack_equ", "stop", target ); } } @@ -2050,16 +2050,16 @@ bot_equipment_kill_think() self endon( "death" ); self endon( "disconnect" ); level endon ( "game_ended" ); - + for ( ;; ) { wait randomintrange( 1, 3 ); - + if ( isdefined( self getthreat() ) || self isremotecontrolling() || self usebuttonpressed() || self BotIsFrozen() ) { continue; } - + self bot_equipment_kill_think_loop(); } } @@ -2071,22 +2071,22 @@ bot_watch_stuck_on_crate_loop() { radius = getdvarfloat( #"player_useRadius" ); crates = getentarray( "care_package", "script_noteworthy" ); - + for ( i = 0; i < crates.size; i++ ) { crate = crates[ i ]; - + if ( !isdefined( crate ) || !isdefined( crate.origin ) ) { continue; } - + if ( distancesquared( self.origin, crate.origin ) < radius * radius ) { self BotNotifyBotEvent( "crate_cap", "start", crate ); - + self BotRandomStance(); - + // holding use freeze our controls already if ( isdefined( crate.owner ) && crate.owner == self ) { @@ -2098,9 +2098,9 @@ bot_watch_stuck_on_crate_loop() self thread BotPressUse( level.cratenonownerusetime / 1000 + 0.5 ); wait level.cratenonownerusetime / 1000 + 0.5; } - + self BotNotifyBotEvent( "crate_cap", "stop", crate ); - + break; } } @@ -2114,21 +2114,21 @@ bot_watch_stuck_on_crate() self endon( "death" ); self endon( "disconnect" ); level endon( "game_ended" ); - + for ( ;; ) { wait( 3 ); - + if ( isdefined( self getthreat() ) ) { continue; } - + if ( self usebuttonpressed() || self BotIsFrozen() ) { continue; } - + self bot_watch_stuck_on_crate_loop(); } } @@ -2139,7 +2139,7 @@ bot_watch_stuck_on_crate() bot_crate_think_loop( data ) { ret = "bot_crate_landed"; - + if ( data.first ) { data.first = false; @@ -2148,59 +2148,59 @@ bot_crate_think_loop( data ) { ret = self waittill_any_timeout( randomintrange( 3, 5 ), "bot_crate_landed" ); } - + myTeam = self.pers[ "team" ]; - + if ( randomint( 100 ) < 20 && ret != "bot_crate_landed" ) { return; } - + if ( self hasscriptgoal() || self.bot_lock_goal ) { return; } - + if ( self isDefusing() || self isPlanting() ) { return; } - + if ( self inLastStand() ) { return; } - + if ( self isremotecontrolling() ) { return; } - + if ( self usebuttonpressed() || self BotIsFrozen() ) { return; } - + crates = getentarray( "care_package", "script_noteworthy" ); - + if ( crates.size == 0 ) { return; } - + wantsClosest = randomint( 2 ); - + crate = undefined; - + for ( i = crates.size - 1; i >= 0; i-- ) { tempCrate = crates[ i ]; - + if ( !isdefined( tempCrate ) || !isdefined( tempCrate.friendlyobjid ) ) { continue; } - + if ( myTeam == tempCrate.team ) { if ( randomint( 100 ) > 30 && isdefined( tempCrate.owner ) && tempCrate.owner != self ) @@ -2212,17 +2212,17 @@ bot_crate_think_loop( data ) { continue; } - + if ( !isdefined( tempCrate.bots ) ) { tempCrate.bots = 0; } - + if ( tempCrate.bots >= 3 ) { continue; } - + if ( isdefined( crate ) ) { if ( wantsClosest ) @@ -2240,55 +2240,55 @@ bot_crate_think_loop( data ) } } } - + crate = tempCrate; } - + crates = undefined; - + if ( !isdefined( crate ) ) { return; } - + self BotNotifyBotEvent( "crate_cap", "go", crate ); - + self BotRandomStance(); - + self.bot_lock_goal = true; - + radius = getdvarfloat( "player_useRadius" ); self SetBotGoal( crate.origin + ( 0, 0, 12 ), radius ); self thread bot_inc_bots( crate, true ); self thread bots_watch_touch_obj( crate ); - + path = self waittill_any_return( "bad_path", "goal", "new_goal" ); - + self.bot_lock_goal = false; - + if ( path != "new_goal" ) { self ClearBotGoal(); } - + if ( path != "goal" || !isdefined( crate ) || distancesquared( self.origin, crate.origin ) > radius * radius ) { if ( isdefined( crate ) && path == "bad_path" ) { self BotNotifyBotEvent( "crate_cap", "unreachable", crate ); } - + return; } - + self BotNotifyBotEvent( "crate_cap", "start", crate ); - + if ( isdefined( crate.cratetype.hint_gambler ) && self hasperk( "specialty_gambler" ) && randomint( 3 ) ) { crate notify( "trigger_use_doubletap", self ); wait 1; } - + // holding use freeze our controls already if ( isdefined( crate ) && isdefined( crate.owner ) && crate.owner == self ) { @@ -2300,7 +2300,7 @@ bot_crate_think_loop( data ) self thread BotPressUse( level.cratenonownerusetime / 1000 + 1 ); wait( level.cratenonownerusetime / 1000 + 1.5 ); } - + self BotNotifyBotEvent( "crate_cap", "stop", crate ); } @@ -2312,10 +2312,10 @@ bot_crate_think() self endon( "death" ); self endon( "disconnect" ); level endon( "game_ended" ); - + data = spawnstruct(); data.first = true; - + for ( ;; ) { self bot_crate_think_loop( data ); @@ -2328,22 +2328,22 @@ bot_crate_think() getRocketAmmo() { answer = self getLockonAmmo(); - + if ( isdefined( answer ) ) { return answer; } - + if ( self getammocount( "minigun_mp" ) ) { return "minigun_mp"; } - + if ( self getammocount( "rpg_mp" ) ) { return "rpg_mp"; } - + return undefined; } @@ -2356,17 +2356,17 @@ getLockonAmmo() { return "m72_law_mp"; } - + if ( self getammocount( "strela_mp" ) ) { return "strela_mp"; } - + if ( self getammocount( "m202_flash_mp" ) ) { return "m202_flash_mp"; } - + return undefined; } @@ -2376,7 +2376,7 @@ getLockonAmmo() bot_array_nearest_curorigin( array ) { result = undefined; - + for ( i = 0; i < array.size; i++ ) { if ( !isdefined( result ) || distancesquared( self.origin, array[ i ].curorigin ) < distancesquared( self.origin, result.curorigin ) ) @@ -2384,7 +2384,7 @@ bot_array_nearest_curorigin( array ) result = array[ i ]; } } - + return result; } @@ -2394,21 +2394,21 @@ bot_array_nearest_curorigin( array ) bot_vehicle_attack( enemy ) { wait_time = randomintrange( 7, 10 ); - + for ( i = 0; i < wait_time; i++ ) { wait( 1 ); - + if ( !isdefined( enemy ) ) { return; } - + if ( !isalive( enemy ) ) { return; } - + if ( !isdefined( enemy.targetname ) || enemy.targetname != "rcbomb" ) { if ( !isdefined( self getRocketAmmo() ) ) @@ -2416,7 +2416,7 @@ bot_vehicle_attack( enemy ) return; } } - + if ( !bullettracepassed( self.origin, enemy.origin, false, enemy ) ) { return; @@ -2434,19 +2434,19 @@ do_bot_plane_combat( plane, weap ) plane endon( "leaving" ); self endon( "weapon_change" ); self endon( "missile_fire" ); - + time = 7; self BotBuiltinAimOverride(); - + while ( time > 0 && isdefined( plane ) && isalive( plane ) && self getcurrentweapon() == weap && !self inLastStand() && !isdefined( self getthreat() ) ) { myeye = self geteye(); - + if ( bullettracepassed( myeye, plane.origin, false, plane ) ) { self thread bot_lookat( plane.origin, 0.3 ); self BotBuiltinButtonOverride( "ads", "enable" ); - + if ( isdefined( self.stingerlockfinalized ) && self.stingerlockfinalized ) { self pressattackbutton(); @@ -2456,7 +2456,7 @@ do_bot_plane_combat( plane, weap ) { self BotBuiltinButtonOverride( "ads", "disable" ); } - + time -= 0.05; wait 0.05; } @@ -2468,24 +2468,24 @@ do_bot_plane_combat( plane, weap ) bot_plane_attack( plane ) { weap = self getLockonAmmo(); - + if ( !isdefined( weap ) ) { return; } - + self botStopMove( true ); self.bot_attacking_plane = true; - + if ( self changeToWeapon( weap ) ) { self do_bot_plane_combat( plane, weap ); - + self notify( "bots_aim_overlap" ); self BotBuiltinClearAimOverride(); self BotBuiltinClearButtonOverride( "ads" ); } - + self botStopMove( false ); self.bot_attacking_plane = false; self notify( "bot_force_check_switch" ); @@ -2497,26 +2497,26 @@ bot_plane_attack( plane ) bot_target_vehicle_loop() { myTeam = self.pers[ "team" ]; - + airborne_enemies = getentarray( "script_vehicle", "classname" ); target = undefined; myEye = self geteye(); rocketAmmo = self getRocketAmmo(); - + for ( i = 0; i < airborne_enemies.size; i++ ) { enemy = airborne_enemies[ i ]; - + if ( !isdefined( enemy ) ) { continue; } - + if ( !isalive( enemy ) ) { continue; } - + if ( level.teambased ) { if ( enemy.team == myTeam ) @@ -2524,12 +2524,12 @@ bot_target_vehicle_loop() continue; } } - + if ( enemy.owner == self ) { continue; } - + if ( !isdefined( enemy.targetname ) || enemy.targetname != "rcbomb" ) { if ( !isdefined( rocketAmmo ) ) @@ -2537,18 +2537,18 @@ bot_target_vehicle_loop() continue; } } - + if ( !bullettracepassed( myEye, enemy.origin, false, enemy ) ) { continue; } - + target = enemy; break; } - + airborne_enemies = undefined; - + if ( !isdefined( target ) ) { if ( isdefined( self getLockonAmmo() ) ) @@ -2556,17 +2556,17 @@ bot_target_vehicle_loop() for ( i = 0; i < level.bot_planes.size; i++ ) { enemy = level.bot_planes[ i ]; - + if ( !isdefined( enemy ) ) { continue; } - + if ( !isalive( enemy ) ) { continue; } - + if ( level.teambased ) { if ( enemy.team == myTeam ) @@ -2574,31 +2574,31 @@ bot_target_vehicle_loop() continue; } } - + if ( enemy.owner == self ) { continue; } - + if ( !bullettracepassed( myEye, enemy.origin, false, enemy ) ) { continue; } - + target = enemy; break; } } } - + if ( !isdefined( target ) ) { wait( randomintrange( 3, 5 ) ); return; } - + self BotNotifyBotEvent( "attack_vehicle", "start", target ); - + if ( isdefined( target.bot_plane ) ) { self bot_plane_attack( target ); @@ -2609,7 +2609,7 @@ bot_target_vehicle_loop() self bot_vehicle_attack( target ); self clearscriptenemy(); } - + self BotNotifyBotEvent( "attack_vehicle", "stop", target ); } @@ -2621,16 +2621,16 @@ bot_target_vehicle() self endon( "death" ); self endon( "disconnect" ); level endon ( "game_ended" ); - + for ( ;; ) { wait( 1 ); - + if ( isdefined( self getthreat() ) || self isremotecontrolling() || self usebuttonpressed() || self BotIsFrozen() ) { continue; } - + self bot_target_vehicle_loop(); } } @@ -2642,7 +2642,7 @@ bot_use_equipment_think_loop() { weapon = self.pers[ "bot" ][ "class_equipment" ]; diff = self GetBotDiffNum(); - + if ( diff > 0 ) { if ( weapon == "camera_spike_mp" ) @@ -2651,9 +2651,9 @@ bot_use_equipment_think_loop() { return; } - + view_angles = self getplayerangles(); - + if ( view_angles[ 0 ] < -5 ) { return; @@ -2667,67 +2667,67 @@ bot_use_equipment_think_loop() } } } - + dir = self getlookaheaddir(); - + if ( !isdefined( dir ) ) { return; } - + dir = vectortoangles( dir ); - + if ( abs( dir[ 1 ] - self.angles[ 1 ] ) > 5 ) { return; } - + dir = vectornormalize( anglestoforward( self.angles ) ); dir = vector_scale( dir, 32 ); goal = self.origin + dir; - + if ( randomint( 100 ) > 35 ) { return; } - + grenades = getentarray( "grenade", "classname" ); anyEquNear = false; - + for ( i = 0; i < grenades.size; i++ ) { item = grenades[ i ]; - + if ( !isdefined( item.name ) ) { continue; } - + if ( !isweaponequipment( item.name ) ) { continue; } - + if ( distancesquared( item.origin, goal ) < 128 * 128 ) { anyEquNear = true; } } - + grenades = undefined; - + if ( anyEquNear && diff > 0 ) { return; } - + self BotNotifyBotEvent( "equ", "start", goal, weapon ); - + lastWeap = self getcurrentweapon(); - + self botStopMove( true ); wait 1; - + if ( self changeToWeapon( weapon ) ) { if ( weapon == "satchel_charge_mp" ) @@ -2738,13 +2738,13 @@ bot_use_equipment_think_loop() { self thread fire_current_weapon(); } - + self waittill_any_timeout( 5, "grenade_fire", "weapon_change" ); self notify( "stop_firing_weapon" ); - + self thread changeToWeapon( lastWeap ); } - + self botStopMove( false ); } @@ -2756,47 +2756,47 @@ bot_use_equipment_think() self endon( "death" ); self endon( "disconnect" ); level endon ( "game_ended" ); - + if ( self.pers[ "bot" ][ "class_equipment" ] == "" || self.pers[ "bot" ][ "class_equipment" ] == "weapon_null_mp" ) { return; } - + // decoys? for ( ;; ) { wait( randomintrange( 1, 3 ) ); - + if ( !self hasweapon( self.pers[ "bot" ][ "class_equipment" ] ) ) { return; } - + if ( self BotIsFrozen() ) { continue; } - + if ( !self getammocount( self.pers[ "bot" ][ "class_equipment" ] ) ) { continue; } - + if ( self isremotecontrolling() ) { continue; } - + if ( isdefined( self getthreat() ) ) { continue; } - + if ( self._is_sprinting ) { continue; } - + self bot_use_equipment_think_loop(); } } @@ -2812,27 +2812,27 @@ bot_go_revive( revive ) self endon( "goal" ); self endon( "bad_path" ); self endon( "new_goal" ); - + for ( ;; ) { wait 1; - + if ( !isdefined( revive ) ) { break; } - + if ( !isdefined( revive.revivetrigger ) ) { break; } - + if ( self istouching( revive.revivetrigger ) ) { break; } } - + if ( !isdefined( revive ) || !isdefined( revive.revivetrigger ) ) { self notify( "bad_path" ); @@ -2849,87 +2849,87 @@ bot_go_revive( revive ) bot_revive_think_loop() { reviveplayer = undefined; - + for ( i = 0; i < level.players.size; i++ ) { player = level.players[ i ]; - + if ( !isdefined( player.pers[ "team" ] ) ) { continue; } - + if ( player == self ) { continue; } - + if ( self.pers[ "team" ] != player.pers[ "team" ] ) { continue; } - + if ( !isdefined( player.revivetrigger ) ) { continue; } - + if ( isdefined( player.currentlybeingrevived ) && player.currentlybeingrevived ) { continue; } - + if ( !isdefined( player.revivetrigger.bots ) ) { player.revivetrigger.bots = 0; } - + if ( player.revivetrigger.bots > 2 ) { continue; } - + reviveplayer = player; } - + if ( !isdefined( reviveplayer ) ) { return; } - + self BotNotifyBotEvent( "revive", "go", reviveplayer ); - + self.bot_lock_goal = true; - + self SetBotGoal( reviveplayer.origin, 1 ); self thread bot_inc_bots( reviveplayer.revivetrigger, true ); self thread bot_go_revive( reviveplayer ); - + event = self waittill_any_return( "goal", "bad_path", "new_goal" ); - + if ( event != "new_goal" ) { self ClearBotGoal(); } - + if ( event != "goal" || !isdefined( reviveplayer ) || ( isdefined( reviveplayer.currentlybeingrevived ) && reviveplayer.currentlybeingrevived ) || !self istouching( reviveplayer.revivetrigger ) || self inLastStand() ) { self.bot_lock_goal = false; return; } - + self BotNotifyBotEvent( "revive", "start", reviveplayer ); - + self SetBotGoal( self.origin, 64 ); self bot_wait_stop_move(); - + reviveTime = getdvarint( #"revive_time_taken" ); self thread BotPressUse( reviveTime + 1 ); wait( reviveTime + 1.5 ); - + self ClearBotGoal(); self.bot_lock_goal = false; - + self BotNotifyBotEvent( "revive", "stop", reviveplayer ); } @@ -2941,41 +2941,41 @@ bot_revive_think() self endon( "death" ); self endon( "disconnect" ); level endon( "game_ended" ); - + if ( !level.teambased ) { return; } - + for ( ;; ) { wait( randomintrange( 3, 5 ) ); - + if ( self hasscriptgoal() || self.bot_lock_goal ) { continue; } - + if ( self isDefusing() || self isPlanting() ) { continue; } - + if ( self inLastStand() ) { continue; } - + if ( self isremotecontrolling() ) { continue; } - + if ( self usebuttonpressed() || self BotIsFrozen() ) { continue; } - + self bot_revive_think_loop(); } } @@ -2986,23 +2986,23 @@ bot_revive_think() bot_dog_attack( dog ) { dog endon( "death" ); - + wait_time = randomintrange( 7, 10 ); - + for ( i = 0; i < wait_time; i++ ) { wait( 1 ); - + if ( !isdefined( dog ) ) { return; } - + if ( !isalive( dog ) ) { return; } - + if ( !bullettracepassed( self.origin, dog.origin, false, dog ) ) { return; @@ -3016,21 +3016,21 @@ bot_dog_attack( dog ) bot_dogs_think_loop() { myTeam = self.pers[ "team" ]; - + for ( i = 0; i < level.dogs.size; i++ ) { dog = level.dogs[ i ]; - + if ( !isdefined( dog ) ) { continue; } - + if ( !isalive( dog ) ) { continue; } - + if ( level.teambased ) { if ( dog.aiteam == myTeam ) @@ -3038,25 +3038,25 @@ bot_dogs_think_loop() continue; } } - + if ( isdefined( dog.script_owner ) && dog.script_owner == self ) { continue; } - + if ( distancesquared( self.origin, dog.origin ) < 1024 * 1024 ) { if ( !bullettracepassed( self.origin, dog.origin, false, dog ) ) { continue; } - + self BotNotifyBotEvent( "attack_dog", "start", dog ); - + self setscriptenemy( dog ); self bot_dog_attack( dog ); self clearscriptenemy(); - + self BotNotifyBotEvent( "attack_dog", "stop", dog ); break; } @@ -3071,26 +3071,26 @@ bot_dogs_think() self endon( "death" ); self endon( "disconnect" ); level endon ( "game_ended" ); - + if ( level.no_dogs ) { return; } - + for ( ;; ) { wait( 0.25 ); - + if ( !isdefined( level.dogs ) || level.dogs.size <= 0 ) { level waittill( "called_in_the_dogs" ); } - + if ( isdefined( self getthreat() ) ) { continue; } - + self bot_dogs_think_loop(); } } @@ -3105,9 +3105,9 @@ stop_go_target_on_death( tar ) self endon( "new_goal" ); self endon( "bad_path" ); self endon( "goal" ); - + tar waittill_either( "death", "disconnect" ); - + self ClearBotGoal(); } @@ -3117,32 +3117,32 @@ stop_go_target_on_death( tar ) follow_target_loop() { threat = self getthreat(); - + if ( !isdefined( threat ) ) { return; } - + if ( !isplayer( threat ) ) { return; } - + if ( randomint( 100 ) > 50 ) { return; } - + self BotNotifyBotEvent( "follow_threat", "start", threat ); - + self SetBotGoal( threat.origin, 64 ); self thread stop_go_target_on_death( threat ); - + if ( self waittill_any_return( "new_goal", "goal", "bad_path" ) != "new_goal" ) { self ClearBotGoal(); } - + self BotNotifyBotEvent( "follow_threat", "stop", threat ); } @@ -3153,16 +3153,16 @@ follow_target() { self endon( "death" ); self endon( "disconnect" ); - + for ( ;; ) { wait 1; - + if ( self hasscriptgoal() || self.bot_lock_goal ) { continue; } - + self follow_target_loop(); } } @@ -3173,7 +3173,7 @@ follow_target() bot_watch_think_mw2_loop() { tube = self getValidTube(); - + if ( !isdefined( tube ) ) { if ( self getammocount( "m72_law_mp" ) ) @@ -3189,17 +3189,17 @@ bot_watch_think_mw2_loop() return; } } - + if ( self getcurrentweapon() == tube ) { return; } - + if ( randomint( 100 ) > 35 ) { return; } - + self thread changeToWeapon( tube ); } @@ -3211,36 +3211,36 @@ bot_watch_think_mw2() self endon( "disconnect" ); self endon( "death" ); level endon( "game_ended" ); - + for ( ;; ) { wait randomintrange( 1, 4 ); - + if ( self BotIsFrozen() ) { continue; } - + if ( self isDefusing() || self isPlanting() ) { continue; } - + if ( self isremotecontrolling() ) { continue; } - + if ( self inLastStand() ) { continue; } - + if ( isdefined( self getthreat() ) ) { continue; } - + self bot_watch_think_mw2_loop(); } } @@ -3251,51 +3251,51 @@ bot_watch_think_mw2() bot_weapon_think_loop( data ) { ret = self waittill_any_timeout( randomintrange( 2, 4 ), "bot_force_check_switch" ); - + if ( self BotIsFrozen() ) { return; } - + if ( self isDefusing() || self isPlanting() ) { return; } - + if ( self isremotecontrolling() ) { return; } - + if ( self inLastStand() ) { return; } - + curWeap = self getcurrentweapon(); threat = self getthreat(); - + if ( self.bot_attacking_plane || ( isdefined( threat ) && !isplayer( threat ) && !isai( threat ) && ( !isdefined( threat.targetname ) || threat.targetname != "rcbomb" ) ) ) { rocketAmmo = self getRocketAmmo(); - + if ( isdefined( rocketAmmo ) ) { if ( curWeap != rocketAmmo ) { self thread changeToWeapon( rocketAmmo ); } - + return; } } - + force = ( ret == "bot_force_check_switch" ); - + if ( data.first ) { data.first = false; - + if ( randomint( 100 ) > 10 ) { return; @@ -3309,7 +3309,7 @@ bot_weapon_think_loop( data ) { return; } - + if ( isdefined( threat ) ) { return; @@ -3320,39 +3320,39 @@ bot_weapon_think_loop( data ) force = true; } } - + weaponslist = self getweaponslistall(); weap = ""; - + while ( weaponslist.size ) { weapon = weaponslist[ randomint( weaponslist.size ) ]; weaponslist = array_remove( weaponslist, weapon ); - + if ( !self getammocount( weapon ) && !force ) { continue; } - + if ( !maps\mp\gametypes\_weapons::isprimaryweapon( weapon ) && !maps\mp\gametypes\_weapons::issidearm( weapon ) && !isWeaponAltmode( weapon ) ) { continue; } - + if ( curWeap == weapon || weapon == "none" || weapon == "" || weapon == "strela_mp" ) { continue; } - + weap = weapon; break; } - + if ( weap == "" ) { return; } - + self thread changeToWeapon( weap ); } @@ -3364,10 +3364,10 @@ bot_weapon_think() self endon( "death" ); self endon( "disconnect" ); level endon( "game_ended" ); - + data = spawnstruct(); data.first = true; - + for ( ;; ) { self bot_weapon_think_loop( data ); @@ -3382,19 +3382,19 @@ bot_uav_think_loop( data ) myTeam = self.pers[ "team" ]; otherTeam = getotherteam( myTeam ); diff = self GetBotDiffNum(); - + hasCam = isdefined( self.cameraspike ); - + if ( self.bot_scrambled && !hasCam ) { return; } - + players = get_players(); - + hasUAV = false; hasSR = false; - + // check for counter spyplane if ( level.teambased ) { @@ -3402,146 +3402,146 @@ bot_uav_think_loop( data ) { return; } - + hasSR = level.activesatellites[ myTeam ]; hasUAV = level.activeuavs[ myTeam ]; } else { shouldContinue = false; - + for ( i = 0; i < players.size; i++ ) { player = players[ i ]; - + if ( player == self ) { continue; } - + if ( !isdefined( player.team ) ) { continue; } - + if ( isdefined( level.activecounteruavs[ player.entnum ] ) && level.activecounteruavs[ player.entnum ] ) { continue; } - + shouldContinue = true; break; } - + if ( shouldContinue && !hasCam ) { return; } - + hasSR = level.activesatellites[ self.entnum ]; hasUAV = level.activeuavs[ self.entnum ]; } - + if ( level.hardcoremode && !hasUAV && !hasSR && !hasCam ) { return; } - + dist = getdvarint( #"scr_help_dist" ); dist = dist * dist * 8; - + // decoys if ( !data.wasfooled && level.bot_decoys.size && !hasCam && !self hasscriptgoal() && !self.bot_lock_goal ) { shouldContinue = false; - + for ( i = 0; i < level.bot_decoys.size; i++ ) { g = level.bot_decoys[ i ]; - + if ( isdefined( g.owner ) && g.owner == self ) { continue; } - + if ( level.teambased && g.team == myTeam ) { continue; } - + if ( distancesquared( self.origin, g.origin ) > dist ) { continue; } - + if ( lengthsquared( g getvelocity() ) > 10000 ) { continue; } - + if ( diff > 0 ) { data.wasfooled = true; } - + self SetBotGoal( g.origin, 128 ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + shouldContinue = true; break; } - + if ( shouldContinue ) { return; } } - + if ( diff <= 0 ) { return; } - + for ( i = 0; i < players.size; i++ ) { player = players[ i ]; - + if ( player == self ) { continue; } - + if ( !isdefined( player.team ) ) { continue; } - + if ( player.sessionstate != "playing" ) { continue; } - + if ( level.teambased && player.team == myTeam ) { continue; } - + if ( !isalive( player ) ) { continue; } - + distFromPlayer = distancesquared( self.origin, player.origin ); - + if ( distFromPlayer > dist ) { continue; } - + if ( hasCam ) { if ( !self.cameraspike maps\mp\gametypes\_weaponobjects::isstunned() && !self hasscriptgoal() && !self.bot_lock_goal && !player hasperk( "specialty_nottargetedbyai" ) ) @@ -3549,14 +3549,14 @@ bot_uav_think_loop( data ) if ( vectordot( vectornormalize( anglestoforward( self.cameraspike.camerahead.angles ) ), vectornormalize( player.origin - self.cameraspike.origin ) ) >= 0.342 && sighttracepassed( player.origin + ( 0, 0, 5 ), self.cameraspike.origin + ( 0, 0, 5 ), false, self.cameraspike ) ) // cos 70 degrees { self BotNotifyBotEvent( "cam_target", "start", player ); - + self SetBotGoal( player.origin, 128 ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self BotNotifyBotEvent( "cam_target", "stop", player ); break; } @@ -3565,28 +3565,28 @@ bot_uav_think_loop( data ) else if ( hasSR || ( !issubstr( player getcurrentweapon(), "_silencer_" ) && player.bot_firing ) || ( hasUAV && !player hasperk( "specialty_gpsjammer" ) ) || ( isdefined( self.acousticsensor ) && !self.acousticsensor maps\mp\gametypes\_weaponobjects::isstunned() && !player hasperk( "specialty_nomotionsensor" ) && distance2d( self.acousticsensor.origin, player.origin ) < 666 ) ) { self BotNotifyBotEvent( "uav_target", "start", player ); - + distSq = getdvarint( #"scr_help_dist" ); distSq *= distSq; - + if ( distFromPlayer < distSq && bullettracepassed( self geteye(), player gettagorigin( "j_spineupper" ), false, player ) ) { self setattacker( player ); } - + if ( !self hasscriptgoal() && !self.bot_lock_goal ) { self SetBotGoal( player.origin, 128 ); self thread stop_go_target_on_death( player ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self BotNotifyBotEvent( "uav_target", "stop", player ); } - + break; } } @@ -3600,19 +3600,19 @@ bot_uav_think() self endon( "death" ); self endon( "disconnect" ); level endon( "game_ended" ); - + data = spawnstruct(); data.wasfooled = false; - + for ( ;; ) { wait 0.75; - + if ( self isremotecontrolling() ) { continue; } - + self bot_uav_think_loop( data ); } } @@ -3624,12 +3624,12 @@ bot_revenge_think() { self endon( "death" ); self endon( "disconnect" ); - + if ( self GetBotDiffNum() <= 0 ) { return; } - + if ( isdefined( self.lastkiller ) && isalive( self.lastkiller ) ) { if ( bullettracepassed( self geteye(), self.lastkiller gettagorigin( "j_spineupper" ), false, self.lastkiller ) ) @@ -3637,37 +3637,37 @@ bot_revenge_think() self setattacker( self.lastkiller ); } } - + if ( !isdefined( self.killerlocation ) ) { return; } - + loc = self.killerlocation; - + for ( ;; ) { wait( randomintrange( 1, 5 ) ); - + if ( self hasscriptgoal() || self.bot_lock_goal ) { return; } - + if ( randomint( 100 ) < 75 ) { return; } - + self BotNotifyBotEvent( "revenge", "start", loc, self.lastkiller ); - + self SetBotGoal( loc, 64 ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self BotNotifyBotEvent( "revenge", "stop", loc, self.lastkiller ); } } @@ -3678,89 +3678,89 @@ bot_revenge_think() bot_listen_to_steps_loop() { dist = 100; - + if ( self hasperk( "specialty_loudenemies" ) ) { dist *= 1.4; } - + dist *= dist; - + heard = undefined; - + for ( i = level.players.size - 1 ; i >= 0; i-- ) { player = level.players[ i ]; - + if ( player == self ) { continue; } - + if ( !isdefined( player.team ) ) { continue; } - + if ( level.teambased && self.team == player.team ) { continue; } - + if ( player.sessionstate != "playing" ) { continue; } - + if ( !isalive( player ) ) { continue; } - + if ( lengthsquared( player getvelocity() ) < 20000 ) { continue; } - + if ( distancesquared( player.origin, self.origin ) > dist ) { continue; } - + if ( player hasperk( "specialty_quieter" ) ) { continue; } - + heard = player; break; } - + if ( !isdefined( heard ) ) { return; } - + self BotNotifyBotEvent( "heard_target", "start", heard ); - + if ( bullettracepassed( self geteye(), heard gettagorigin( "j_spineupper" ), false, heard ) ) { self setattacker( heard ); return; } - + if ( self hasscriptgoal() || self.bot_lock_goal ) { return; } - + self SetBotGoal( heard.origin, 64 ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self BotNotifyBotEvent( "heard_target", "stop", heard ); } @@ -3771,16 +3771,16 @@ bot_listen_to_steps() { self endon( "disconnect" ); self endon( "death" ); - + for ( ;; ) { wait 1; - + if ( self GetBotDiffNum() <= 0 ) { continue; } - + self bot_listen_to_steps_loop(); } } @@ -3793,34 +3793,34 @@ bot_radiation_think_loop() origins = []; origins[ 0 ] = ( 813, 5, 267 ); origins[ 1 ] = ( -811, 30, 363 ); - + origin = random( origins ); - + if ( distancesquared( self.origin, origin ) < 512 * 512 ) { self SetBotGoal( origin, 32 ); - + event = self waittill_any_return( "goal", "bad_path", "new_goal" ); - + if ( event != "new_goal" ) { self ClearBotGoal(); } - + if ( event != "goal" ) { return; } - + self botStopMove( true ); self bot_wait_stop_move(); - + self thread BotPressUse( 3 ); wait( 3 ); - + self botStopMove( false ); } - + wait( randomintrange( 5, 10 ) ); } @@ -3832,36 +3832,36 @@ bot_radiation_think() self endon( "death" ); self endon( "disconnect" ); level endon ( "game_ended" ); - + if ( level.script != "mp_radiation" ) { return; } - + if ( level.wagermatch ) { return; } - + for ( ;; ) { wait( randomintrange( 8, 15 ) ); - + if ( self hasscriptgoal() || self BotIsFrozen() ) { continue; } - + if ( self isremotecontrolling() || self.bot_lock_goal ) { continue; } - + if ( self usebuttonpressed() ) { continue; } - + self bot_radiation_think_loop(); } } @@ -3874,52 +3874,52 @@ bot_dom_spawn_kill_think_loop() myTeam = self.pers[ "team" ]; otherTeam = getotherteam( myTeam ); myFlagCount = maps\mp\gametypes\dom::getteamflagcount( myTeam ); - + if ( myFlagCount == level.flags.size ) { return; } - + otherFlagCount = maps\mp\gametypes\dom::getteamflagcount( otherTeam ); - + if ( myFlagCount <= otherFlagCount || otherFlagCount != 1 ) { return; } - + flag = undefined; - + for ( i = 0; i < level.flags.size; i++ ) { if ( level.flags[ i ] maps\mp\gametypes\dom::getflagteam() == myTeam ) { continue; } - + flag = level.flags[ i ]; } - + if ( !isdefined( flag ) ) { return; } - + if ( distancesquared( self.origin, flag.origin ) < 2048 * 2048 ) { return; } - + self BotNotifyBotEvent( "dom", "start", "spawnkill", flag ); - + self SetBotGoal( flag.origin, 1024 ); - + self thread bot_dom_watch_flags( myFlagCount, myTeam ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self BotNotifyBotEvent( "dom", "stop", "spawnkill", flag ); } @@ -3930,31 +3930,31 @@ bot_dom_spawn_kill_think() { self endon( "death" ); self endon( "disconnect" ); - + if ( level.gametype != "dom" ) { return; } - + for ( ;; ) { wait( randomintrange( 10, 20 ) ); - + if ( randomint( 100 ) < 20 ) { continue; } - + if ( self hasscriptgoal() || self.bot_lock_goal ) { continue; } - + if ( !isdefined( level.flags ) || level.flags.size == 0 ) { continue; } - + self bot_dom_spawn_kill_think_loop(); } } @@ -3969,17 +3969,17 @@ bot_dom_watch_flags( count, myTeam ) self endon( "goal" ); self endon( "bad_path" ); self endon( "new_goal" ); - + for ( ;; ) { wait 0.5; - + if ( maps\mp\gametypes\dom::getteamflagcount( myTeam ) != count ) { break; } } - + self notify( "bad_path" ); } @@ -3990,42 +3990,42 @@ bot_dom_def_think_loop() { myTeam = self.pers[ "team" ]; flag = undefined; - + for ( i = 0; i < level.flags.size; i++ ) { if ( level.flags[ i ] maps\mp\gametypes\dom::getflagteam() != myTeam ) { continue; } - + if ( !level.flags[ i ].useobj.objpoints[ myTeam ].isflashing ) { continue; } - + if ( !isdefined( flag ) || distancesquared( self.origin, level.flags[ i ].origin ) < distancesquared( self.origin, flag.origin ) ) { flag = level.flags[ i ]; } } - + if ( !isdefined( flag ) ) { return; } - + self BotNotifyBotEvent( "dom", "start", "defend", flag ); - + self SetBotGoal( flag.origin, 128 ); - + self thread bot_dom_watch_for_flashing( flag, myTeam ); self thread bots_watch_touch_obj( flag ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self BotNotifyBotEvent( "dom", "stop", "defend", flag ); } @@ -4036,31 +4036,31 @@ bot_dom_def_think() { self endon( "death" ); self endon( "disconnect" ); - + if ( level.gametype != "dom" ) { return; } - + for ( ;; ) { wait( randomintrange( 1, 3 ) ); - + if ( randomint( 100 ) < 35 ) { continue; } - + if ( self hasscriptgoal() || self.bot_lock_goal ) { continue; } - + if ( !isdefined( level.flags ) || level.flags.size == 0 ) { continue; } - + self bot_dom_def_think_loop(); } } @@ -4075,22 +4075,22 @@ bot_dom_watch_for_flashing( flag, myTeam ) self endon( "goal" ); self endon( "bad_path" ); self endon( "new_goal" ); - + for ( ;; ) { wait 0.5; - + if ( !isdefined( flag ) ) { break; } - + if ( flag maps\mp\gametypes\dom::getflagteam() != myTeam || !flag.useobj.objpoints[ myTeam ].isflashing ) { break; } } - + self notify( "bad_path" ); } @@ -4101,16 +4101,16 @@ bot_dom_cap_think_loop() { myTeam = self.pers[ "team" ]; otherTeam = getotherteam( myTeam ); - + myFlagCount = maps\mp\gametypes\dom::getteamflagcount( myTeam ); - + if ( myFlagCount == level.flags.size ) { return; } - + otherFlagCount = maps\mp\gametypes\dom::getteamflagcount( otherTeam ); - + if ( game[ "teamScores" ][ myTeam ] >= game[ "teamScores" ][ otherTeam ] ) { if ( myFlagCount < otherFlagCount ) @@ -4135,20 +4135,20 @@ bot_dom_cap_think_loop() } } } - + flag = undefined; flags = []; - + for ( i = 0; i < level.flags.size; i++ ) { if ( level.flags[ i ] maps\mp\gametypes\dom::getflagteam() == myTeam ) { continue; } - + flags[ flags.size ] = level.flags[ i ]; } - + if ( randomint( 100 ) > 30 ) { for ( i = 0; i < flags.size; i++ ) @@ -4163,53 +4163,53 @@ bot_dom_cap_think_loop() { flag = PickRandom( flags ); } - + if ( !isdefined( flag ) ) { return; } - + self BotNotifyBotEvent( "dom", "go", "cap", flag ); - + self.bot_lock_goal = true; self SetBotGoal( flag.origin, 64 ); - + self thread bot_dom_go_cap_flag( flag, myTeam ); - + event = self waittill_any_return( "goal", "bad_path", "new_goal" ); - + if ( event != "new_goal" ) { self ClearBotGoal(); } - + if ( event != "goal" ) { self.bot_lock_goal = false; return; } - + self BotNotifyBotEvent( "dom", "start", "cap", flag ); - + self SetBotGoal( self.origin, 64 ); - + while ( flag maps\mp\gametypes\dom::getflagteam() != myTeam && self istouching( flag ) ) { cur = flag.useobj.curprogress; wait 0.5; - + if ( flag.useobj.curprogress == cur ) { break; // some enemy is near us, kill him } - + self thread bot_do_random_action_for_objective( flag ); } - + self BotNotifyBotEvent( "dom", "stop", "cap", flag ); - + self ClearBotGoal(); - + self.bot_lock_goal = false; } @@ -4220,26 +4220,26 @@ bot_dom_cap_think() { self endon( "death" ); self endon( "disconnect" ); - + if ( level.gametype != "dom" ) { return; } - + for ( ;; ) { wait( randomintrange( 3, 12 ) ); - + if ( self.bot_lock_goal ) { continue; } - + if ( !isdefined( level.flags ) || level.flags.size == 0 ) { continue; } - + self bot_dom_cap_think_loop(); } } @@ -4254,27 +4254,27 @@ bot_dom_go_cap_flag( flag, myTeam ) self endon( "goal" ); self endon( "bad_path" ); self endon( "new_goal" ); - + for ( ;; ) { wait randomintrange( 2, 4 ); - + if ( !isdefined( flag ) ) { break; } - + if ( flag maps\mp\gametypes\dom::getflagteam() == myTeam ) { break; } - + if ( self istouching( flag ) ) { break; } } - + if ( flag maps\mp\gametypes\dom::getflagteam() == myTeam ) { self notify( "bad_path" ); @@ -4292,11 +4292,11 @@ bot_hq_loop() { myTeam = self.pers[ "team" ]; otherTeam = getotherteam( myTeam ); - + radio = level.radio; gameobj = radio.gameobject; origin = ( radio.origin[ 0 ], radio.origin[ 1 ], radio.origin[ 2 ] + 5 ); - + // if neut or enemy if ( gameobj.ownerteam != myTeam ) { @@ -4306,69 +4306,69 @@ bot_hq_loop() { return; } - + if ( distancesquared( origin, self.origin ) <= 1024 * 1024 ) { return; } - + self SetBotGoal( origin, 256 ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + return; } - + // capture it - + self BotNotifyBotEvent( "hq", "go", "cap" ); - + self.bot_lock_goal = true; self SetBotGoal( origin, 64 ); self thread bot_hq_go_cap( gameobj, radio ); - + event = self waittill_any_return( "goal", "bad_path", "new_goal" ); - + if ( event != "new_goal" ) { self ClearBotGoal(); } - + if ( event != "goal" ) { self.bot_lock_goal = false; return; } - + if ( !self istouching( gameobj.trigger ) || level.radio != radio ) { self.bot_lock_goal = false; return; } - + self BotNotifyBotEvent( "hq", "start", "cap" ); - + self SetBotGoal( self.origin, 64 ); - + while ( self istouching( gameobj.trigger ) && gameobj.ownerteam != myTeam && level.radio == radio ) { cur = gameobj.curprogress; wait 0.5; - + if ( cur == gameobj.curprogress ) { break; // no prog made, enemy must be capping } - + self thread bot_do_random_action_for_objective( gameobj.trigger ); } - + self ClearBotGoal(); self.bot_lock_goal = false; - + self BotNotifyBotEvent( "hq", "stop", "cap" ); } else // we own it @@ -4376,34 +4376,34 @@ bot_hq_loop() if ( gameobj.objpoints[ myTeam ].isflashing ) // underattack { self BotNotifyBotEvent( "hq", "start", "defend" ); - + self.bot_lock_goal = true; self SetBotGoal( origin, 64 ); self thread bot_hq_watch_flashing( gameobj, radio ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self.bot_lock_goal = false; - + self BotNotifyBotEvent( "hq", "stop", "defend" ); return; } - + if ( self hasscriptgoal() ) { return; } - + if ( distancesquared( origin, self.origin ) <= 1024 * 1024 ) { return; } - + self SetBotGoal( origin, 256 ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); @@ -4418,31 +4418,31 @@ bot_hq() { self endon( "death" ); self endon( "disconnect" ); - + if ( level.gametype != "koth" ) { return; } - + for ( ;; ) { wait( randomintrange( 3, 5 ) ); - + if ( self.bot_lock_goal ) { continue; } - + if ( !isdefined( level.radio ) ) { continue; } - + if ( !isdefined( level.radio.gameobject ) ) { continue; } - + self bot_hq_loop(); } } @@ -4457,27 +4457,27 @@ bot_hq_go_cap( obj, radio ) self endon( "goal" ); self endon( "bad_path" ); self endon( "new_goal" ); - + for ( ;; ) { wait randomintrange( 2, 4 ); - + if ( !isdefined( obj ) ) { break; } - + if ( self istouching( obj.trigger ) ) { break; } - + if ( level.radio != radio ) { break; } } - + if ( level.radio != radio ) { self notify( "bad_path" ); @@ -4498,29 +4498,29 @@ bot_hq_watch_flashing( obj, radio ) self endon( "goal" ); self endon( "bad_path" ); self endon( "new_goal" ); - + myTeam = self.team; - + for ( ;; ) { wait 0.5; - + if ( !isdefined( obj ) ) { break; } - + if ( !obj.objpoints[ myTeam ].isflashing ) { break; } - + if ( level.radio != radio ) { break; } } - + self notify( "bad_path" ); } @@ -4531,18 +4531,18 @@ bot_sab_loop() { myTeam = self.pers[ "team" ]; otherTeam = getotherteam( myTeam ); - + bomb = level.sabbomb; bombteam = bomb.ownerteam; carrier = bomb.carrier; timeleft = maps\mp\gametypes\_globallogic_utils::gettimeremaining() / 1000; - + // the bomb is ours, we are on the offence if ( bombteam == myTeam ) { site = level.bombzones[ otherTeam ]; origin = ( site.curorigin[ 0 ] + 50, site.curorigin[ 1 ] + 50, site.curorigin[ 2 ] + 32 ); - + // protect our planted bomb if ( level.bombplanted ) { @@ -4550,41 +4550,41 @@ bot_sab_loop() if ( site isInUse() ) // somebody is defusing our bomb we planted { self BotNotifyBotEvent( "sab", "start", "defuser" ); - + self.bot_lock_goal = true; self SetBotGoal( origin, 64 ); - + self thread bot_defend_site( site ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self.bot_lock_goal = false; - + self BotNotifyBotEvent( "sab", "stop", "defuser" ); return; } - + // else hang around the site if ( distancesquared( origin, self.origin ) <= 1024 * 1024 ) { return; } - + self.bot_lock_goal = true; self SetBotGoal( origin, 256 ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self.bot_lock_goal = false; return; } - + // we are not the carrier if ( !self isBombCarrier() ) { @@ -4593,76 +4593,76 @@ bot_sab_loop() { return; } - + origin = carrier.origin; - + if ( distancesquared( origin, self.origin ) <= 1024 * 1024 ) { return; } - + self SetBotGoal( origin, 256 ); self thread bot_escort_obj( bomb, carrier ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + return; } - + // we are the carrier of the bomb, lets check if we need to plant timepassed = maps\mp\gametypes\_globallogic_utils::gettimepassed() / 1000; - + if ( timepassed < 120 && timeleft >= 90 && randomint( 100 ) < 98 ) { return; } - + self BotNotifyBotEvent( "sab", "go", "plant" ); - + self.bot_lock_goal = true; self SetBotGoal( origin, 1 ); - + self thread bot_go_plant( site ); event = self waittill_any_return( "goal", "bad_path", "new_goal" ); - + if ( event != "new_goal" ) { self ClearBotGoal(); } - + if ( event != "goal" || level.bombplanted || !self istouching( site.trigger ) || site isInUse() || self inLastStand() || isdefined( self getthreat() ) ) { self.bot_lock_goal = false; return; } - + self BotNotifyBotEvent( "sab", "start", "plant" ); - + self BotRandomStance(); self SetBotGoal( self.origin, 64 ); self bot_wait_stop_move(); - + waitTime = ( site.usetime / 1000 ) + 2.5; self thread BotPressUse( waitTime ); wait waitTime; - + self ClearBotGoal(); self.bot_lock_goal = false; - + self BotNotifyBotEvent( "sab", "stop", "plant" ); } else if ( bombteam == otherTeam ) // the bomb is theirs, we are on the defense { site = level.bombzones[ myTeam ]; - + if ( !isdefined( site.bots ) ) { site.bots = 0; } - + // protect our site from planters if ( !level.bombplanted ) { @@ -4673,50 +4673,50 @@ bot_sab_loop() { return; } - + if ( carrier hasperk( "specialty_gpsjammer" ) ) { return; } - + origin = carrier.origin; - + self SetBotGoal( origin, 64 ); self thread bot_escort_obj( bomb, carrier ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + return; } - + // protect bomb site origin = ( site.curorigin[ 0 ] + 50, site.curorigin[ 1 ] + 50, site.curorigin[ 2 ] + 32 ); - + self thread bot_inc_bots( site ); - + if ( site isInUse() ) // somebody is planting { self BotNotifyBotEvent( "sab", "start", "planter" ); - + self.bot_lock_goal = true; self SetBotGoal( origin, 64 ); self thread bot_inc_bots( site ); - + self thread bot_defend_site( site ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self.bot_lock_goal = false; self BotNotifyBotEvent( "sab", "stop", "planter" ); return; } - + // else hang around the site if ( distancesquared( origin, self.origin ) <= 1024 * 1024 ) { @@ -4725,23 +4725,23 @@ bot_sab_loop() site.bots--; return; } - + self.bot_lock_goal = true; self SetBotGoal( origin, 256 ); self thread bot_inc_bots( site ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self.bot_lock_goal = false; return; } - + // bomb is planted we need to defuse origin = ( site.curorigin[ 0 ] + 50, site.curorigin[ 1 ] + 50, site.curorigin[ 2 ] + 32 ); - + // someone else is defusing, lets just hang around if ( site.bots > 1 ) { @@ -4749,76 +4749,76 @@ bot_sab_loop() { return; } - + if ( distancesquared( origin, self.origin ) <= 1024 * 1024 ) { return; } - + self SetBotGoal( origin, 256 ); self thread bot_go_defuse( site ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + return; } - + // lets go defuse self BotNotifyBotEvent( "sab", "go", "defuse" ); - + self.bot_lock_goal = true; - + self SetBotGoal( origin, 1 ); self thread bot_inc_bots( site ); self thread bot_go_defuse( site ); - + event = self waittill_any_return( "goal", "bad_path", "new_goal" ); - + if ( event != "new_goal" ) { self ClearBotGoal(); } - + if ( event != "goal" || !level.bombplanted || site isInUse() || !self istouching( site.trigger ) || self inLastStand() || isdefined( self getthreat() ) ) { self.bot_lock_goal = false; return; } - + self BotNotifyBotEvent( "sab", "start", "defuse" ); - + self BotRandomStance(); self SetBotGoal( self.origin, 64 ); self bot_wait_stop_move(); - + waitTime = ( site.usetime / 1000 ) + 2.5; self thread BotPressUse( waitTime ); wait waitTime; - + self ClearBotGoal(); self.bot_lock_goal = false; - + self BotNotifyBotEvent( "sab", "stop", "defuse" ); } else // we need to go get the bomb! { origin = ( bomb.curorigin[ 0 ], bomb.curorigin[ 1 ], bomb.curorigin[ 2 ] + 32 ); - + self BotNotifyBotEvent( "sab", "start", "bomb" ); - + self.bot_lock_goal = true; self SetBotGoal( origin, 64 ); - + self thread bot_get_obj( bomb ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self.bot_lock_goal = false; self BotNotifyBotEvent( "sab", "stop", "bomb" ); return; @@ -4833,36 +4833,36 @@ bot_sab() self endon( "death" ); self endon( "disconnect" ); level endon( "game_ended" ); - + if ( level.gametype != "sab" ) { return; } - + for ( ;; ) { wait( randomintrange( 3, 5 ) ); - + if ( self isremotecontrolling() || self.bot_lock_goal ) { continue; } - + if ( !isdefined( level.sabbomb ) ) { continue; } - + if ( !isdefined( level.bombzones ) || !level.bombzones.size ) { continue; } - + if ( self isPlanting() || self isDefusing() ) { continue; } - + self bot_sab_loop(); } } @@ -4874,69 +4874,69 @@ bot_sd_defenders_loop( data ) { myTeam = self.pers[ "team" ]; otherTeam = getotherteam( myTeam ); - + // bomb not planted, lets protect our sites if ( !level.bombplanted ) { timeleft = maps\mp\gametypes\_globallogic_utils::gettimeremaining() / 1000; - + if ( timeleft >= 90 ) { return; } - + // check for a bomb carrier, and camp the bomb if ( !level.multibomb && isdefined( level.sdbomb ) ) { bomb = level.sdbomb; carrier = level.sdbomb.carrier; - + if ( !isdefined( carrier ) ) { origin = ( bomb.curorigin[ 0 ], bomb.curorigin[ 1 ], bomb.curorigin[ 2 ] + 32 ); - + // hang around the bomb if ( self hasscriptgoal() ) { return; } - + if ( distancesquared( origin, self.origin ) <= 1024 * 1024 ) { return; } - + self SetBotGoal( origin, 256 ); - + self thread bot_get_obj( bomb ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + return; } } - + // pick a site to protect if ( !isdefined( level.bombzones ) || !level.bombzones.size ) { return; } - + sites = []; - + for ( i = 0; i < level.bombzones.size; i++ ) { sites[ sites.size ] = level.bombzones[ i ]; } - + if ( !sites.size ) { return; } - + if ( data.rand > 50 ) { site = self bot_array_nearest_curorigin( sites ); @@ -4945,67 +4945,67 @@ bot_sd_defenders_loop( data ) { site = PickRandom( sites ); } - + if ( !isdefined( site ) ) { return; } - + origin = ( site.curorigin[ 0 ] + 50, site.curorigin[ 1 ] + 50, site.curorigin[ 2 ] + 32 ); - + if ( site isInUse() ) // somebody is planting { self BotNotifyBotEvent( "sd", "start", "planter", site ); - + self.bot_lock_goal = true; self SetBotGoal( origin, 64 ); - + self thread bot_defend_site( site ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self.bot_lock_goal = false; - + self BotNotifyBotEvent( "sd", "stop", "planter", site ); return; } - + // else hang around the site if ( distancesquared( origin, self.origin ) <= 1024 * 1024 ) { return; } - + self.bot_lock_goal = true; self SetBotGoal( origin, 256 ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self.bot_lock_goal = false; return; } - + // bomb is planted, we need to defuse if ( !isdefined( level.defuseobject ) ) { return; } - + defuse = level.defuseobject; - + if ( !isdefined( defuse.bots ) ) { defuse.bots = 0; } - + origin = ( defuse.curorigin[ 0 ], defuse.curorigin[ 1 ], defuse.curorigin[ 2 ] + 32 ); - + // someone is going to go defuse ,lets just hang around if ( defuse.bots > 1 ) { @@ -5013,57 +5013,57 @@ bot_sd_defenders_loop( data ) { return; } - + if ( distancesquared( origin, self.origin ) <= 1024 * 1024 ) { return; } - + self SetBotGoal( origin, 256 ); self thread bot_go_defuse( defuse ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + return; } - + // lets defuse self BotNotifyBotEvent( "sd", "go", "defuse" ); - + self.bot_lock_goal = true; self SetBotGoal( origin, 1 ); self thread bot_inc_bots( defuse ); self thread bot_go_defuse( defuse ); - + event = self waittill_any_return( "goal", "bad_path", "new_goal" ); - + if ( event != "new_goal" ) { self ClearBotGoal(); } - + if ( event != "goal" || !level.bombplanted || defuse isInUse() || !self istouching( defuse.trigger ) || self inLastStand() || isdefined( self getthreat() ) ) { self.bot_lock_goal = false; return; } - + self BotNotifyBotEvent( "sd", "start", "defuse" ); - + self BotRandomStance(); self SetBotGoal( self.origin, 64 ); self bot_wait_stop_move(); - + waitTime = ( defuse.usetime / 1000 ) + 2.5; self thread BotPressUse( waitTime ); wait waitTime; - + self ClearBotGoal(); self.bot_lock_goal = false; - + self BotNotifyBotEvent( "sd", "stop", "defuse" ); } @@ -5075,34 +5075,34 @@ bot_sd_defenders() self endon( "death" ); self endon( "disconnect" ); level endon( "game_ended" ); - + if ( level.gametype != "sd" ) { return; } - + if ( self.team == game[ "attackers" ] ) { return; } - + data = spawnstruct(); data.rand = randomint( 100 ); - + for ( ;; ) { wait( randomintrange( 3, 5 ) ); - + if ( self isremotecontrolling() || self.bot_lock_goal ) { continue; } - + if ( self isPlanting() || self isDefusing() ) { continue; } - + self bot_sd_defenders_loop( data ); } } @@ -5120,15 +5120,15 @@ bot_sd_attackers_loop( data ) { wait( randomintrange( 3, 5 ) ); } - + if ( self isremotecontrolling() || self.bot_lock_goal ) { return; } - + myTeam = self.pers[ "team" ]; otherTeam = getotherteam( myTeam ); - + // bomb planted if ( level.bombplanted ) { @@ -5136,53 +5136,53 @@ bot_sd_attackers_loop( data ) { return; } - + site = level.defuseobject; - + origin = ( site.curorigin[ 0 ], site.curorigin[ 1 ], site.curorigin[ 2 ] + 32 ); - + if ( site isInUse() ) // somebody is defusing { self BotNotifyBotEvent( "sd", "start", "defuser" ); - + self.bot_lock_goal = true; - + self SetBotGoal( origin, 64 ); - + self thread bot_defend_site( site ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self.bot_lock_goal = false; - + self BotNotifyBotEvent( "sd", "stop", "defuser" ); return; } - + // else hang around the site if ( distancesquared( origin, self.origin ) <= 1024 * 1024 ) { return; } - + self.bot_lock_goal = true; self SetBotGoal( origin, 256 ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self.bot_lock_goal = false; return; } - + timeleft = maps\mp\gametypes\_globallogic_utils::gettimeremaining() / 1000; timepassed = maps\mp\gametypes\_globallogic_utils::gettimepassed() / 1000; - + // dont have a bomb if ( !self isBombCarrier() && !level.multibomb ) { @@ -5190,10 +5190,10 @@ bot_sd_attackers_loop( data ) { return; } - + bomb = level.sdbomb; carrier = level.sdbomb.carrier; - + // bomb is picked up if ( isdefined( carrier ) ) { @@ -5202,32 +5202,32 @@ bot_sd_attackers_loop( data ) { return; } - + origin = carrier.origin; - + if ( distancesquared( origin, self.origin ) <= 1024 * 1024 ) { return; } - + self SetBotGoal( origin, 256 ); self thread bot_escort_obj( bomb, carrier ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + return; } - + if ( !isdefined( bomb.bots ) ) { bomb.bots = 0; } - + origin = ( bomb.curorigin[ 0 ], bomb.curorigin[ 1 ], bomb.curorigin[ 2 ] + 32 ); - + // hang around the bomb if other is going to go get it if ( bomb.bots > 1 ) { @@ -5235,66 +5235,66 @@ bot_sd_attackers_loop( data ) { return; } - + if ( distancesquared( origin, self.origin ) <= 1024 * 1024 ) { return; } - + self SetBotGoal( origin, 256 ); - + self thread bot_get_obj( bomb ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + return; } - + // go get the bomb self BotNotifyBotEvent( "sd", "start", "bomb" ); - + self.bot_lock_goal = true; self SetBotGoal( origin, 64 ); self thread bot_inc_bots( bomb ); self thread bot_get_obj( bomb ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self.bot_lock_goal = false; - + self BotNotifyBotEvent( "sd", "stop", "bomb" ); return; } - + // check if to plant if ( timepassed < 120 && timeleft >= 90 && randomint( 100 ) < 98 ) { return; } - + if ( !isdefined( level.bombzones ) || !level.bombzones.size ) { return; } - + sites = []; - + for ( i = 0; i < level.bombzones.size; i++ ) { sites[ sites.size ] = level.bombzones[ i ]; } - + if ( !sites.size ) { return; } - + if ( data.rand > 50 ) { plant = self bot_array_nearest_curorigin( sites ); @@ -5303,46 +5303,46 @@ bot_sd_attackers_loop( data ) { plant = PickRandom( sites ); } - + if ( !isdefined( plant ) ) { return; } - + origin = ( plant.curorigin[ 0 ] + 50, plant.curorigin[ 1 ] + 50, plant.curorigin[ 2 ] + 32 ); - + self BotNotifyBotEvent( "sd", "go", "plant", plant ); - + self.bot_lock_goal = true; self SetBotGoal( origin, 1 ); self thread bot_go_plant( plant ); - + event = self waittill_any_return( "goal", "bad_path", "new_goal" ); - + if ( event != "new_goal" ) { self ClearBotGoal(); } - + if ( event != "goal" || level.bombplanted || plant.visibleteam == "none" || !self istouching( plant.trigger ) || self inLastStand() || isdefined( self getthreat() ) || plant isInUse() ) { self.bot_lock_goal = false; return; } - + self BotNotifyBotEvent( "sd", "start", "plant", plant ); - + self BotRandomStance(); self SetBotGoal( self.origin, 64 ); self bot_wait_stop_move(); - + waitTime = ( plant.usetime / 1000 ) + 2.5; self thread BotPressUse( waitTime ); wait waitTime; - + self ClearBotGoal(); self.bot_lock_goal = false; - + self BotNotifyBotEvent( "sd", "stop", "plant", plant ); } @@ -5354,21 +5354,21 @@ bot_sd_attackers() self endon( "death" ); self endon( "disconnect" ); level endon( "game_ended" ); - + if ( level.gametype != "sd" ) { return; } - + if ( self.team != game[ "attackers" ] ) { return; } - + data = spawnstruct(); data.rand = randomint( 100 ); data.first = true; - + for ( ;; ) { self bot_sd_attackers_loop( data ); @@ -5382,36 +5382,36 @@ bot_cap_loop() { myTeam = self.pers[ "team" ]; otherTeam = getotherteam( myTeam ); - + myflag = level.teamflags[ myTeam ]; myzone = level.teamflagzones[ myTeam ]; - + theirflag = level.teamflags[ otherTeam ]; theirzone = level.teamflagzones[ otherTeam ]; - + if ( myflag maps\mp\gametypes\_gameobjects::isobjectawayfromhome() ) { carrier = myflag.carrier; - + if ( !isdefined( carrier ) ) // someone doesnt has our flag { if ( !isdefined( theirflag.carrier ) && distancesquared( self.origin, theirflag.curorigin ) < distancesquared( self.origin, myflag.curorigin ) ) // no one has their flag and its closer { self BotNotifyBotEvent( "cap", "start", "their_flag", theirflag ); - + self bot_cap_get_flag( theirflag ); - + self BotNotifyBotEvent( "cap", "stop", "their_flag", theirflag ); } else // go get it { self BotNotifyBotEvent( "cap", "start", "my_flag", myflag ); - + self bot_cap_get_flag( myflag ); - + self BotNotifyBotEvent( "cap", "stop", "my_flag", myflag ); } - + return; } else @@ -5420,9 +5420,9 @@ bot_cap_loop() { // take their flag self BotNotifyBotEvent( "cap", "start", "their_flag", theirflag ); - + self bot_cap_get_flag( theirflag ); - + self BotNotifyBotEvent( "cap", "stop", "their_flag", theirflag ); } else @@ -5431,14 +5431,14 @@ bot_cap_loop() { return; } - + if ( !isdefined( theirzone.bots ) ) { theirzone.bots = 0; } - + origin = theirzone.curorigin; - + if ( theirzone.bots > 2 || randomint( 100 ) < 45 ) { // kill carrier @@ -5446,22 +5446,22 @@ bot_cap_loop() { return; } - + origin = carrier.origin; - + self SetBotGoal( origin, 64 ); self thread bot_escort_obj( myflag, carrier ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + return; } - + self thread bot_inc_bots( theirzone ); - + // camp their zone if ( distancesquared( origin, self.origin ) <= 1024 * 1024 ) { @@ -5470,11 +5470,11 @@ bot_cap_loop() theirzone.bots--; return; } - + self SetBotGoal( origin, 256 ); self thread bot_inc_bots( theirzone ); self thread bot_escort_obj( myflag, carrier ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); @@ -5488,57 +5488,57 @@ bot_cap_loop() { // go cap origin = myzone.curorigin; - + self BotNotifyBotEvent( "cap", "start", "cap" ); - + self.bot_lock_goal = true; self SetBotGoal( origin, 32 ); - + self thread bot_get_obj( myflag ); evt = self waittill_any_return( "goal", "bad_path", "new_goal" ); - + wait 1; - + if ( evt != "new_goal" ) { self ClearBotGoal(); } - + self.bot_lock_goal = false; - + self BotNotifyBotEvent( "cap", "stop", "cap" ); return; } - + carrier = theirflag.carrier; - + if ( !isdefined( carrier ) ) // if no one has enemy flag { self BotNotifyBotEvent( "cap", "start", "their_flag", theirflag ); - + self bot_cap_get_flag( theirflag ); - + self BotNotifyBotEvent( "cap", "stop", "their_flag", theirflag ); return; } - + // escort them - + if ( self hasscriptgoal() ) { return; } - + origin = carrier.origin; - + if ( distancesquared( origin, self.origin ) <= 1024 * 1024 ) { return; } - + self SetBotGoal( origin, 256 ); self thread bot_escort_obj( theirflag, carrier ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); @@ -5554,31 +5554,31 @@ bot_cap() self endon( "death" ); self endon( "disconnect" ); level endon( "game_ended" ); - + if ( level.gametype != "ctf" ) { return; } - + for ( ;; ) { wait( randomintrange( 3, 5 ) ); - + if ( self isremotecontrolling() || self.bot_lock_goal ) { continue; } - + if ( !isdefined( level.teamflagzones ) ) { continue; } - + if ( !isdefined( level.teamflags ) ) { continue; } - + self bot_cap_loop(); } } @@ -5589,12 +5589,12 @@ bot_cap() getCarrierEntNum() { carrierNum = -1; - + if ( isdefined( self.carrier ) ) { carrierNum = self.carrier getentitynumber(); } - + return carrierNum; } @@ -5604,43 +5604,43 @@ getCarrierEntNum() bot_cap_get_flag( flag ) { origin = flag.curorigin; - + // go get it - + self.bot_lock_goal = true; self SetBotGoal( origin, 32 ); - + self thread bot_get_obj( flag ); - + evt = self waittill_any_return( "goal", "bad_path", "new_goal" ); - + if ( evt != "new_goal" ) { self ClearBotGoal(); } - + if ( evt != "goal" ) { self.bot_lock_goal = false; return; } - + self SetBotGoal( self.origin, 64 ); curCarrier = flag getCarrierEntNum(); - + while ( curCarrier == flag getCarrierEntNum() && self istouching( flag.trigger ) ) { cur = flag.curprogress; wait 0.5; - + if ( flag.curprogress == cur ) { break; // some enemy is near us, kill him } } - + self ClearBotGoal(); - + self.bot_lock_goal = false; } @@ -5655,22 +5655,22 @@ bot_dem_go_plant( plant ) self endon( "goal" ); self endon( "bad_path" ); self endon( "new_goal" ); - + for ( ;; ) { wait 0.5; - + if ( ( plant.label == "_b" && level.bombbplanted ) || ( plant.label == "_a" && level.bombaplanted ) ) { break; } - + if ( self istouching( plant.trigger ) ) { break; } } - + if ( ( plant.label == "_b" && level.bombbplanted ) || ( plant.label == "_a" && level.bombaplanted ) ) { self notify( "bad_path" ); @@ -5692,20 +5692,20 @@ bot_dem_attack_spawnkill() self endon( "goal" ); self endon( "bad_path" ); self endon( "new_goal" ); - + l1 = level.bombaplanted; l2 = level.bombbplanted; - + for ( ;; ) { wait 0.5; - + if ( l1 != level.bombaplanted || l2 != level.bombbplanted ) { break; } } - + self notify( "bad_path" ); } @@ -5716,21 +5716,21 @@ bot_dem_attackers_loop() { myTeam = self.pers[ "team" ]; otherTeam = getotherteam( myTeam ); - + bombs = []; // sites with bombs sites = []; // sites to bomb at bombed = 0; // exploded sites - + for ( i = 0; i < level.bombzones.size; i++ ) { bomb = level.bombzones[ i ]; - + if ( isdefined( bomb.bombexploded ) && bomb.bombexploded ) { bombed++; continue; } - + if ( bomb.label == "_a" ) { if ( level.bombaplanted ) @@ -5741,10 +5741,10 @@ bot_dem_attackers_loop() { sites[ sites.size ] = bomb; } - + continue; } - + if ( bomb.label == "_b" ) { if ( level.bombbplanted ) @@ -5755,15 +5755,15 @@ bot_dem_attackers_loop() { sites[ sites.size ] = bomb; } - + continue; } } - + timeleft = maps\mp\gametypes\_globallogic_utils::gettimeremaining() / 1000; - + shouldLet = ( game[ "teamScores" ][ myTeam ] > game[ "teamScores" ][ otherTeam ] && timeleft < 90 && bombed == 1 ); - + // spawnkill conditions // if we have bombed one site or 1 bomb is planted with lots of time left, spawn kill // if we want the other team to win for overtime and they do not need to defuse, spawn kill @@ -5773,129 +5773,129 @@ bot_dem_attackers_loop() { return; } - + spawnPoints = maps\mp\gametypes\_spawnlogic::getspawnpointarray( "mp_dem_spawn_defender_start" ); - + if ( !spawnPoints.size ) { return; } - + spawnpoint = maps\mp\gametypes\_spawnlogic::getspawnpoint_random( spawnPoints ); - + if ( distancesquared( spawnpoint.origin, self.origin ) <= 2048 * 2048 ) { return; } - + self SetBotGoal( spawnpoint.origin, 1024 ); - + self thread bot_dem_attack_spawnkill(); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + return; } - + // let defuse conditions // if enemy is going to lose and lots of time left, let them defuse to play longer // or if want to go into overtime near end of the extended game if ( ( ( bombs.size + bombed == 2 && timeleft >= 90 ) || ( shouldLet && bombs.size ) ) && randomint( 100 ) < 95 ) { spawnPoints = maps\mp\gametypes\_spawnlogic::getspawnpointarray( "mp_dem_spawn_attacker_start" ); - + if ( !spawnPoints.size ) { return; } - + spawnpoint = maps\mp\gametypes\_spawnlogic::getspawnpoint_random( spawnPoints ); - + if ( distancesquared( spawnpoint.origin, self.origin ) <= 1024 * 1024 ) { return; } - + self.bot_lock_goal = true; self SetBotGoal( spawnpoint.origin, 512 ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self.bot_lock_goal = false; return; } - + // defend bomb conditions // if time is running out and we have a bomb planted if ( bombs.size && timeleft < 90 && ( !sites.size || randomint( 100 ) < 95 ) ) { site = self bot_array_nearest_curorigin( bombs ); origin = ( site.curorigin[ 0 ] + 50, site.curorigin[ 1 ] + 50, site.curorigin[ 2 ] + 32 ); - + if ( site isInUse() ) // somebody is defusing { self BotNotifyBotEvent( "dem", "start", "defuser", site ); - + self.bot_lock_goal = true; self SetBotGoal( origin, 64 ); - + self thread bot_defend_site( site ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self.bot_lock_goal = false; - + self BotNotifyBotEvent( "dem", "stop", "defuser", site ); return; } - + // else hang around the site if ( distancesquared( origin, self.origin ) <= 1024 * 1024 ) { return; } - + self.bot_lock_goal = true; self SetBotGoal( origin, 256 ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self.bot_lock_goal = false; return; } - + // else go plant if ( !sites.size ) { return; } - + plant = self bot_array_nearest_curorigin( sites ); - + if ( !isdefined( plant ) ) { return; } - + if ( !isdefined( plant.bots ) ) { plant.bots = 0; } - + origin = ( plant.curorigin[ 0 ] + 50, plant.curorigin[ 1 ] + 50, plant.curorigin[ 2 ] + 32 ); - + // hang around the site if lots of time left if ( plant.bots > 1 && timeleft >= 60 ) { @@ -5903,58 +5903,58 @@ bot_dem_attackers_loop() { return; } - + if ( distancesquared( origin, self.origin ) <= 1024 * 1024 ) { return; } - + self SetBotGoal( origin, 256 ); self thread bot_dem_go_plant( plant ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + return; } - + self BotNotifyBotEvent( "dem", "go", "plant", plant ); - + self.bot_lock_goal = true; - + self SetBotGoal( origin, 1 ); self thread bot_inc_bots( plant ); self thread bot_dem_go_plant( plant ); - + event = self waittill_any_return( "goal", "bad_path", "new_goal" ); - + if ( event != "new_goal" ) { self ClearBotGoal(); } - + if ( event != "goal" || ( plant.label == "_b" && level.bombbplanted ) || ( plant.label == "_a" && level.bombaplanted ) || plant isInUse() || !self istouching( plant.trigger ) || self inLastStand() || isdefined( self getthreat() ) ) { self.bot_lock_goal = false; return; } - + self BotNotifyBotEvent( "dem", "start", "plant", plant ); - + self BotRandomStance(); self SetBotGoal( self.origin, 64 ); self bot_wait_stop_move(); - + waitTime = ( plant.usetime / 1000 ) + 2.5; self thread BotPressUse( waitTime ); wait waitTime; - + self ClearBotGoal(); - + self.bot_lock_goal = false; - + self BotNotifyBotEvent( "dem", "stop", "plant", plant ); } @@ -5966,31 +5966,31 @@ bot_dem_attackers() self endon( "death" ); self endon( "disconnect" ); level endon( "game_ended" ); - + if ( level.gametype != "dem" ) { return; } - + if ( self.team != game[ "attackers" ] ) { return; } - + for ( ;; ) { wait( randomintrange( 3, 5 ) ); - + if ( self isremotecontrolling() || self.bot_lock_goal ) { continue; } - + if ( !isdefined( level.bombzones ) || !level.bombzones.size ) { continue; } - + self bot_dem_attackers_loop(); } } @@ -6002,21 +6002,21 @@ bot_dem_defenders_loop() { myTeam = self.pers[ "team" ]; otherTeam = getotherteam( myTeam ); - + bombs = []; // sites with bombs sites = []; // sites to bomb at bombed = 0; // exploded sites - + for ( i = 0; i < level.bombzones.size; i++ ) { bomb = level.bombzones[ i ]; - + if ( isdefined( bomb.bombexploded ) && bomb.bombexploded ) { bombed++; continue; } - + if ( bomb.label == "_a" ) { if ( level.bombaplanted ) @@ -6027,10 +6027,10 @@ bot_dem_defenders_loop() { sites[ sites.size ] = bomb; } - + continue; } - + if ( bomb.label == "_b" ) { if ( level.bombbplanted ) @@ -6041,15 +6041,15 @@ bot_dem_defenders_loop() { sites[ sites.size ] = bomb; } - + continue; } } - + timeleft = maps\mp\gametypes\_globallogic_utils::gettimeremaining() / 1000; - + shouldLet = ( timeleft < 60 && ( ( bombed == 0 && bombs.size != 2 ) || ( game[ "teamScores" ][ myTeam ] > game[ "teamScores" ][ otherTeam ] && bombed == 1 ) ) && randomint( 100 ) < 98 ); - + // spawnkill conditions // if nothing to defuse with a lot of time left, spawn kill // or letting a bomb site to explode but a bomb is planted, so spawnkill @@ -6059,131 +6059,131 @@ bot_dem_defenders_loop() { return; } - + spawnPoints = maps\mp\gametypes\_spawnlogic::getspawnpointarray( "mp_dem_spawn_attacker_start" ); - + if ( !spawnPoints.size ) { return; } - + spawnpoint = maps\mp\gametypes\_spawnlogic::getspawnpoint_random( spawnPoints ); - + if ( distancesquared( spawnpoint.origin, self.origin ) <= 2048 * 2048 ) { return; } - + self SetBotGoal( spawnpoint.origin, 1024 ); - + self thread bot_dem_defend_spawnkill(); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + return; } - + // let blow up conditions // let enemy blow up at least one to extend play time // or if want to go into overtime after extended game if ( shouldLet ) { spawnPoints = maps\mp\gametypes\_spawnlogic::getspawnpointarray( "mp_dem_spawn_defender_start" ); - + if ( !spawnPoints.size ) { return; } - + spawnpoint = maps\mp\gametypes\_spawnlogic::getspawnpoint_random( spawnPoints ); - + if ( distancesquared( spawnpoint.origin, self.origin ) <= 1024 * 1024 ) { return; } - + self.bot_lock_goal = true; self SetBotGoal( spawnpoint.origin, 512 ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self.bot_lock_goal = false; return; } - + // defend conditions // if no bombs planted with little time left if ( !bombs.size && timeleft < 60 && randomint( 100 ) < 95 && sites.size ) { site = self bot_array_nearest_curorigin( sites ); origin = ( site.curorigin[ 0 ] + 50, site.curorigin[ 1 ] + 50, site.curorigin[ 2 ] + 32 ); - + if ( site isInUse() ) // somebody is planting { self BotNotifyBotEvent( "dem", "start", "planter", site ); - + self.bot_lock_goal = true; self SetBotGoal( origin, 64 ); - + self thread bot_defend_site( site ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self.bot_lock_goal = false; - + self BotNotifyBotEvent( "dem", "stop", "planter", site ); return; } - + // else hang around the site - + if ( distancesquared( origin, self.origin ) <= 1024 * 1024 ) { return; } - + self.bot_lock_goal = true; self SetBotGoal( origin, 256 ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + self.bot_lock_goal = false; return; } - + // else go defuse - + if ( !bombs.size ) { return; } - + defuse = self bot_array_nearest_curorigin( bombs ); - + if ( !isdefined( defuse ) ) { return; } - + if ( !isdefined( defuse.bots ) ) { defuse.bots = 0; } - + origin = ( defuse.curorigin[ 0 ] + 50, defuse.curorigin[ 1 ] + 50, defuse.curorigin[ 2 ] + 32 ); - + // hang around the site if not in danger of losing if ( defuse.bots > 1 && bombed + bombs.size != 2 ) { @@ -6191,59 +6191,59 @@ bot_dem_defenders_loop() { return; } - + if ( distancesquared( origin, self.origin ) <= 1024 * 1024 ) { return; } - + self SetBotGoal( origin, 256 ); - + self thread bot_dem_go_defuse( defuse ); - + if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) { self ClearBotGoal(); } - + return; } - + self BotNotifyBotEvent( "dem", "go", "defuse", defuse ); - + self.bot_lock_goal = true; - + self SetBotGoal( origin, 1 ); self thread bot_inc_bots( defuse ); self thread bot_dem_go_defuse( defuse ); - + event = self waittill_any_return( "goal", "bad_path", "new_goal" ); - + if ( event != "new_goal" ) { self ClearBotGoal(); } - + if ( event != "goal" || ( defuse.label == "_b" && !level.bombbplanted ) || ( defuse.label == "_a" && !level.bombaplanted ) || defuse isInUse() || !self istouching( defuse.trigger ) || self inLastStand() || isdefined( self getthreat() ) ) { self.bot_lock_goal = false; return; } - + self BotNotifyBotEvent( "dem", "start", "defuse", defuse ); - + self BotRandomStance(); self SetBotGoal( self.origin, 64 ); self bot_wait_stop_move(); - + waitTime = ( defuse.usetime / 1000 ) + 2.5; self thread BotPressUse( waitTime ); wait waitTime; - + self ClearBotGoal(); - + self.bot_lock_goal = false; - + self BotNotifyBotEvent( "dem", "stop", "defuse", defuse ); } @@ -6255,31 +6255,31 @@ bot_dem_defenders() self endon( "death" ); self endon( "disconnect" ); level endon( "game_ended" ); - + if ( level.gametype != "dem" ) { return; } - + if ( self.team == game[ "attackers" ] ) { return; } - + for ( ;; ) { wait( randomintrange( 3, 5 ) ); - + if ( self isremotecontrolling() || self.bot_lock_goal ) { continue; } - + if ( !isdefined( level.bombzones ) || !level.bombzones.size ) { continue; } - + self bot_dem_defenders_loop(); } } @@ -6295,22 +6295,22 @@ bot_dem_go_defuse( defuse ) self endon( "goal" ); self endon( "bad_path" ); self endon( "new_goal" ); - + for ( ;; ) { wait 0.5; - + if ( self istouching( defuse.trigger ) ) { break; } - + if ( ( defuse.label == "_b" && !level.bombbplanted ) || ( defuse.label == "_a" && !level.bombaplanted ) ) { break; } } - + if ( ( defuse.label == "_b" && !level.bombbplanted ) || ( defuse.label == "_a" && !level.bombaplanted ) ) { self notify( "bad_path" ); @@ -6332,17 +6332,17 @@ bot_dem_defend_spawnkill() self endon( "goal" ); self endon( "bad_path" ); self endon( "new_goal" ); - + for ( ;; ) { wait 0.5; - + if ( level.bombbplanted || level.bombaplanted ) { break; } } - + self notify( "bad_path" ); } @@ -6353,64 +6353,64 @@ watch_for_melee_override() { self endon( "disconnect" ); self endon( "death" ); - + // dedi doesnt have this registered if ( getdvar( "aim_automelee_enabled" ) == "" ) { setdvar( "aim_automelee_enabled", 1 ); } - + for ( ;; ) { threat = self getthreat(); - + while ( !isdefined( threat ) || ( !isplayer( threat ) && !isai( threat ) ) || self BotIsFrozen() || self isremotecontrolling() || !self hasweapon( "knife_mp" ) || !getdvarint( "aim_automelee_enabled" ) ) { wait 0.05; threat = self getthreat(); } - + thisThreat = self getthreat(); - + while ( isdefined( thisThreat ) && isdefined( threat ) && thisThreat == threat && !self BotIsFrozen() ) { dist = distance( self.origin, threat.origin ); - + if ( self isonground() && self getstance() != "prone" && !self inLastStand() && dist < getdvarfloat( "aim_automelee_range" ) && ( getConeDot( threat.origin, self.origin, self getplayerangles() ) > 0.9 || dist < 10 ) ) { angles = vectortoangles( threat.origin - self.origin ); - + self BotBuiltinBotMeleeParams( angles[ 1 ], dist ); self BotBuiltinButtonOverride( "melee", "enable" ); self BotBuiltinAimOverride(); - + time_left = 1; once = false; - + while ( time_left > 0 && isdefined( threat ) && isalive( threat ) ) { self setplayerangles( vectortoangles( threat gettagorigin( "j_spine4" ) - self geteye() ) ); time_left -= 0.05; wait 0.05; - + if ( !once ) { once = true; self BotBuiltinClearButtonOverride( "melee" ); } } - + if ( !once ) { self BotBuiltinClearButtonOverride( "melee" ); } - + self BotBuiltinClearMeleeParams(); self BotBuiltinClearAimOverride(); wait 1; break; } - + wait 0.05; thisThreat = self getthreat(); } @@ -6424,14 +6424,14 @@ watch_for_override_stuff() { self endon( "disconnect" ); self endon( "death" ); - + NEAR_DIST = 80; LONG_DIST = 1000; SPAM_JUMP_TIME = 5000; - + diff = self GetBotDiffNum(); chance = 0; - + if ( diff == 1 ) { chance = 25; @@ -6444,42 +6444,42 @@ watch_for_override_stuff() { chance = 80; } - + last_jump_time = 0; need_to_clear_mantle_override = false; - + if ( !getdvarint( "bots_play_jumpdrop" ) ) { return; } - + for ( ;; ) { threat = self getthreat(); - + while ( !isdefined( threat ) || !isplayer( threat ) || self isremotecontrolling() || self BotIsFrozen() ) { wait 0.05; threat = self getthreat(); } - + dist = distance( threat.origin, self.origin ); time = gettime(); weap = self getcurrentweapon(); - + if ( need_to_clear_mantle_override && ( time - last_jump_time ) > 3000 ) { need_to_clear_mantle_override = false; self BotBuiltinClearMantleOverride(); } - + weapon_is_good = true; - + if ( weap == "none" || !self getweaponammoclip( weap ) ) { weapon_is_good = false; } - + if ( weapon_is_good && ( dist > NEAR_DIST ) && ( dist < LONG_DIST ) && ( randomint( 100 ) < chance ) && ( ( time - last_jump_time ) > SPAM_JUMP_TIME ) ) { if ( randomint( 2 ) ) @@ -6489,13 +6489,13 @@ watch_for_override_stuff() last_jump_time = time; need_to_clear_mantle_override = true; self BotBuiltinMantleOverride(); - + // drop shot self BotBuiltinMovementOverride( 0, 0 ); self BotBuiltinButtonOverride( "prone", "enable" ); - + wait 1.5; - + self BotBuiltinClearMovementOverride(); self BotBuiltinClearButtonOverride( "prone" ); } @@ -6505,16 +6505,16 @@ watch_for_override_stuff() last_jump_time = time; need_to_clear_mantle_override = true; self BotBuiltinMantleOverride(); - + // jump shot self BotBuiltinButtonOverride( "gostand", "enable" ); wait 0.1; self BotBuiltinClearButtonOverride( "gostand" ); } } - + thisThreat = self getthreat(); - + while ( isdefined( thisThreat ) && isdefined( threat ) && thisThreat == threat ) { wait 0.05; diff --git a/maps/mp/bots/_bot_utility.gsc b/maps/mp/bots/_bot_utility.gsc index 1dc3a70..7598e2f 100644 --- a/maps/mp/bots/_bot_utility.gsc +++ b/maps/mp/bots/_bot_utility.gsc @@ -20,7 +20,7 @@ wait_for_builtins() { return true; } - + if ( i < 18 ) { waittillframeend; @@ -30,7 +30,7 @@ wait_for_builtins() wait 0.05; } } - + return false; } @@ -197,19 +197,19 @@ getBotArray() { result = []; playercount = level.players.size; - + for ( i = 0; i < playercount; i++ ) { player = level.players[ i ]; - + if ( !player is_bot() ) { continue; } - + result[ result.size ] = player; } - + return result; } @@ -231,7 +231,7 @@ getGoodMapAmount() Round( x ) { y = int( x ); - + if ( abs( x ) - abs( y ) > 0.5 ) { if ( x < 0 ) @@ -258,7 +258,7 @@ PickRandom( arr ) { return undefined; } - + return arr[ randomint( arr.size ) ]; } @@ -332,27 +332,27 @@ allowTeamChoice() GetBotDiffNum() { num = 0; - + switch ( getdvar( "bot_difficulty" ) ) { case "fu": num = 3; break; - + case "hard": num = 2; break; - + case "normal": num = 1; break; - + case "easy": default: num = 0; break; } - + return num; } @@ -365,7 +365,7 @@ isWeaponAltmode( weap ) { return true; } - + return false; } @@ -380,57 +380,57 @@ bot_lookat( pos, time, vel, doAimPredict ) self endon( "death" ); self endon( "spawned_player" ); 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 - + if ( doAimPredict ) { myEye += ( self getvelocity() * 0.05 ) * ( steps - 1 ); // account for our velocity - + pos += ( vel * 0.05 ) * ( steps - 1 ); // add the velocity vector } - + myAngle = self getplayerangles(); angles = vectortoangles( ( pos - myEye ) - anglestoforward( myAngle ) ); - + X = angleclamp180( angles[ 0 ] - myAngle[ 0 ] ); X = X / steps; - + Y = angleclamp180( angles[ 1 ] - myAngle[ 1 ] ); Y = Y / steps; - + for ( i = 0; i < steps; i++ ) { myAngle = ( angleclamp180( myAngle[ 0 ] + X ), angleclamp180( myAngle[ 1 ] + Y ), 0 ); @@ -445,12 +445,12 @@ bot_lookat( pos, time, vel, doAimPredict ) getweaponslistall() { weaps = self getweaponslist(); - + for ( i = 0; i < weaps.size; i++ ) { weap = weaps[ i ]; toks = strtok( weap, "_" ); - + if ( issubstr( weap, "_gl_" ) ) { weaps[ weaps.size ] = "gl_" + toks[ 0 ] + "_mp"; @@ -464,7 +464,7 @@ getweaponslistall() weaps[ weaps.size ] = "mk_" + toks[ 0 ] + "_mp"; } } - + return weaps; } @@ -474,22 +474,22 @@ getweaponslistall() getValidTube() { weaps = self getweaponslistall(); - + for ( i = 0; i < weaps.size; i++ ) { weap = weaps[ i ]; - + if ( !self getammocount( weap ) ) { continue; } - + if ( ( issubstr( weap, "gl_" ) && !issubstr( weap, "_gl_" ) ) || weap == "china_lake_mp" ) { return weap; } } - + return undefined; } @@ -502,36 +502,36 @@ waittill_any_timeout( timeOut, string1, string2, string3, string4, string5 ) { 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 ); - + ent waittill( "returned", msg ); ent notify( "die" ); return msg; @@ -543,7 +543,7 @@ waittill_any_timeout( timeOut, string1, string2, string3, string4, string5 ) _timeout( delay ) { self endon( "die" ); - + wait( delay ); self notify( "returned", "timeout" ); } @@ -554,27 +554,27 @@ _timeout( delay ) getBotToKick() { bots = getBotArray(); - + if ( !isdefined( bots ) || !isdefined( bots.size ) || bots.size <= 0 || !isdefined( bots[ 0 ] ) ) { return undefined; } - + tokick = undefined; axis = 0; allies = 0; team = getdvar( "bots_team" ); - + // count teams for ( i = 0; i < bots.size; i++ ) { bot = bots[ i ]; - + if ( !isdefined( bot ) || !isdefined( bot.team ) ) { continue; } - + if ( bot.team == "allies" ) { allies++; @@ -588,7 +588,7 @@ getBotToKick() return bot; } } - + // search for a bot on the other team if ( team == "custom" || team == "axis" ) { @@ -598,7 +598,7 @@ getBotToKick() { // get the team with the most bots team = "allies"; - + if ( axis > allies ) { team = "axis"; @@ -608,43 +608,43 @@ getBotToKick() { team = "axis"; } - + // get the bot on this team with lowest skill for ( i = 0; i < bots.size; i++ ) { 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++ ) { bot = bots[ i ]; - + if ( !isdefined( bot ) || !isdefined( bot.team ) ) { continue; } - + tokick = bot; } - + return tokick; } @@ -654,51 +654,51 @@ getBotToKick() 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; } } @@ -770,17 +770,17 @@ botStopMove2( what ) self endon( "disconnect" ); self endon( "death" ); level endon( "game_ended" ); - + self notify( "botStopMove" ); self endon( "botStopMove" ); - + if ( !what ) { return; } - + og = self.origin; - + for ( ;; ) { self setvelocity( ( 0, 0, 0 ) ); @@ -803,122 +803,122 @@ BotNotifyBotEvent( msg, a, b, c, d, e, f, g ) keyCodeToString( a ) { b = ""; - + switch ( a ) { case 0: b = "a"; break; - + case 1: b = "b"; break; - + case 2: b = "c"; break; - + case 3: b = "d"; break; - + case 4: b = "e"; break; - + case 5: b = "f"; break; - + case 6: b = "g"; break; - + case 7: b = "h"; break; - + case 8: b = "i"; break; - + case 9: b = "j"; break; - + case 10: b = "k"; break; - + case 11: b = "l"; break; - + case 12: b = "m"; break; - + case 13: b = "n"; break; - + case 14: b = "o"; break; - + case 15: b = "p"; break; - + case 16: b = "q"; break; - + case 17: b = "r"; break; - + case 18: b = "s"; break; - + case 19: b = "t"; break; - + case 20: b = "u"; break; - + case 21: b = "v"; break; - + case 22: b = "w"; break; - + case 23: b = "x"; break; - + case 24: b = "y"; break; - + case 25: b = "z"; break; - + case 26: b = "."; break; - + case 27: b = " "; break; } - + return b; } @@ -950,7 +950,7 @@ bot_onUsePlantObjectFix( player ) { level thread bot_bombPlanted( self, player ); player logstring( "bomb planted: " + self.label ); - + // disable all bomb zones except this one for ( index = 0; index < level.bombzones.size; index++ ) { @@ -958,28 +958,28 @@ bot_onUsePlantObjectFix( player ) { continue; } - + level.bombzones[ index ] maps\mp\gametypes\_gameobjects::disableobject(); } - + thread playsoundonplayers( "mus_sd_planted" + "_" + level.teampostfix[ player.pers[ "team" ] ] ); -// removed plant audio until finalization of assest TODO : new plant sounds when assests are online -// player playsound( "mpl_sd_bomb_plant" ); + // removed plant audio until finalization of assest TODO : new plant sounds when assests are online + // player playsound( "mpl_sd_bomb_plant" ); player notify ( "bomb_planted" ); - + level thread maps\mp\_popups::displayteammessagetoall( &"MP_EXPLOSIVES_PLANTED_BY", player ); - + if ( isdefined( player.pers[ "plants" ] ) ) { player.pers[ "plants" ]++; player.plants = player.pers[ "plants" ]; } - + player maps\mp\_medals::saboteur(); player maps\mp\gametypes\_persistence::stataddwithgametype( "PLANTS", 1 ); - + maps\mp\gametypes\_globallogic_audio::leaderdialog( "bomb_planted" ); - + maps\mp\gametypes\_globallogic_score::giveplayerscore( "plant", player ); // player thread [[ level.onxpevent ]]( "plant" ); } @@ -992,19 +992,19 @@ bot_bombPlanted( destroyedObj, player ) { maps\mp\gametypes\_globallogic_utils::pausetimer(); level.bombplanted = true; - + destroyedObj.visuals[ 0 ] thread maps\mp\gametypes\_globallogic_utils::playtickingsound( "mpl_sab_ui_suitcasebomb_timer" ); // Play suspense music level thread maps\mp\gametypes\sd::bombplantedmusicdelay(); - + // thread maps\mp\gametypes\_globallogic_audio::actionmusicset(); - + level.tickingobject = destroyedObj.visuals[ 0 ]; - + level.timelimitoverride = true; setgameendtime( int( gettime() + ( level.bombtimer * 1000 ) ) ); setmatchflag( "bomb_timer", 1 ); - + if ( !level.multibomb ) { level.sdbomb maps\mp\gametypes\_gameobjects::allowcarry( "none" ); @@ -1014,7 +1014,7 @@ bot_bombPlanted( destroyedObj, player ) } else { - + for ( index = 0; index < level.players.size; index++ ) { if ( isdefined( level.players[ index ].carryicon ) ) @@ -1022,19 +1022,19 @@ bot_bombPlanted( destroyedObj, player ) level.players[ index ].carryicon destroyelem(); } } - + trace = bullettrace( player.origin + ( 0, 0, 20 ), player.origin - ( 0, 0, 2000 ), false, player ); - + tempAngle = randomfloat( 360 ); forward = ( cos( tempAngle ), sin( tempAngle ), 0 ); forward = vectornormalize( forward - vector_scale( trace[ "normal" ], vectordot( forward, trace[ "normal" ] ) ) ); dropAngles = vectortoangles( forward ); - + level.sdbombmodel = spawn( "script_model", trace[ "position" ] ); level.sdbombmodel.angles = dropAngles; level.sdbombmodel setmodel( "prop_suitcase_bomb" ); } - + destroyedObj maps\mp\gametypes\_gameobjects::allowuse( "none" ); destroyedObj maps\mp\gametypes\_gameobjects::setvisibleteam( "none" ); /* @@ -1044,7 +1044,7 @@ bot_bombPlanted( destroyedObj, player ) destroyedObj maps\mp\gametypes\_gameobjects::set3dicon( "enemy", undefined ); */ label = destroyedObj maps\mp\gametypes\_gameobjects::getlabel(); - + // create a new object to defuse with. trigger = destroyedObj.bombdefusetrig; trigger.origin = level.sdbombmodel.origin; @@ -1064,28 +1064,27 @@ bot_bombPlanted( destroyedObj, player ) defuseObject.onenduse = maps\mp\gametypes\sd::onenduse; defuseObject.onuse = maps\mp\gametypes\sd::onusedefuseobject; defuseObject.useweapon = "briefcase_bomb_defuse_mp"; - + level.defuseobject = defuseObject; // every cod... - + player.isbombcarrier = false; - + maps\mp\gametypes\sd::bombtimerwait(); setmatchflag( "bomb_timer", 0 ); - + destroyedObj.visuals[ 0 ] maps\mp\gametypes\_globallogic_utils::stoptickingsound(); - + if ( level.gameended || level.bombdefused ) { return; } - + level.bombexploded = true; - - - + + explosionOrigin = level.sdbombmodel.origin + ( 0, 0, 12 ); level.sdbombmodel hide(); - + if ( isdefined( player ) ) { destroyedObj.visuals[ 0 ] radiusdamage( explosionOrigin, 512, 200, 20, player, "MOD_EXPLOSIVE", "briefcase_bomb_mp" ); @@ -1097,29 +1096,29 @@ bot_bombPlanted( destroyedObj, player ) { 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 ) ); triggerfx( explosionEffect ); - + thread playsoundinspace( "mpl_sd_exp_suitcase_bomb_main", explosionOrigin ); // 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(); - + setgameendtime( 0 ); - + wait 3; - + maps\mp\gametypes\sd::sd_endgame( game[ "attackers" ], game[ "strings" ][ "target_destroyed" ] ); } diff --git a/maps/mp/gametypes/_bot.gsc b/maps/mp/gametypes/_bot.gsc index 600f678..a19f979 100644 --- a/maps/mp/gametypes/_bot.gsc +++ b/maps/mp/gametypes/_bot.gsc @@ -16,179 +16,179 @@ init() { level.bw_version = "1.1.1"; - + 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(); thread bot_watch_planes(); - + thread handleBots(); - + thread doNonDediBots(); } @@ -200,7 +200,7 @@ onPlayerConnect() for ( ;; ) { level waittill( "connected", player ); - + player thread watch_shoot(); player thread watch_grenade(); player thread connected(); @@ -215,21 +215,21 @@ handleBots() thread diffBots(); thread teamBots(); addBots(); - + while ( !level.intermission ) { wait 0.05; } - + setdvar( "bots_manage_add", getBotArray().size ); - + if ( !getdvarint( "bots_main_kickBotsAtEnd" ) ) { return; } - + bots = getBotArray(); - + for ( i = 0; i < bots.size; i++ ) { kick( bots[ i ] getentitynumber() ); @@ -242,7 +242,7 @@ handleBots() onDisconnect() { self waittill( "disconnect" ); - + level.bots = array_remove( level.bots, self ); } @@ -252,19 +252,19 @@ onDisconnect() connected() { self endon( "disconnect" ); - + if ( !self is_bot() ) { return; } - + self thread maps\mp\bots\_bot_script::connected(); - + level.bots[ level.bots.size ] = self; self thread onDisconnect(); - + level notify( "bot_connected", self ); - + self thread watchBotDebugEvent(); } @@ -274,45 +274,45 @@ connected() watchBotDebugEvent() { self endon( "disconnect" ); - + for ( ;; ) { self waittill( "bot_event", msg, str, b, c, d, e, f, g ); - + if ( getdvarint( "bots_main_debug" ) >= 2 ) { 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 ); } else if ( msg == "debug" && getdvarint( "bots_main_debug" ) ) @@ -330,15 +330,15 @@ diffBots() for ( ;; ) { wait 1.5; - + // we dont use 'bots_skill' so that we can still use the .menu dvar - + if ( getdvar( "bots_skill" ) != "" ) { setdvar( "bot_difficulty", getdvar( "bots_skill" ) ); setdvar( "bots_skill", "" ); } - + bot_set_difficulty( getdvar( #"bot_difficulty" ) ); } } @@ -352,48 +352,48 @@ doNonDediBots() { 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" ); - + bot_enemies += getdvarint( "bot_enemies_extra" ); bot_friends += getdvarint( "bot_friends_extra" ); - + bot_wait_for_host(); host = gethostplayer(); - + 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 ); setdvar( "bots_manage_fill_mode", 0 ); setdvar( "bots_manage_fill_kick", true ); setdvar( "bots_manage_fill_spec", false ); - + setdvar( "bots_team", "custom" ); - + if ( team == "axis" ) { setdvar( "bots_team_amount", bot_friends ); @@ -402,7 +402,7 @@ doNonDediBots() { setdvar( "bots_team_amount", bot_enemies ); } - + setdvar( "bots_team_force", true ); setdvar( "bots_team_mode", 0 ); } @@ -414,85 +414,85 @@ bot_set_difficulty( difficulty ) { if ( difficulty == "fu" ) { - setdvar( "sv_botMinDeathTime", "250" ); - setdvar( "sv_botMaxDeathTime", "500" ); - setdvar( "sv_botMinFireTime", "100" ); - setdvar( "sv_botMaxFireTime", "300" ); - setdvar( "sv_botYawSpeed", "14" ); - setdvar( "sv_botYawSpeedAds", "14" ); - setdvar( "sv_botPitchUp", "-5" ); - setdvar( "sv_botPitchDown", "10" ); - setdvar( "sv_botFov", "160" ); - setdvar( "sv_botMinAdsTime", "3000" ); - setdvar( "sv_botMaxAdsTime", "5000" ); - setdvar( "sv_botMinCrouchTime", "100" ); - setdvar( "sv_botMaxCrouchTime", "400" ); + setdvar( "sv_botMinDeathTime", "250" ); + setdvar( "sv_botMaxDeathTime", "500" ); + setdvar( "sv_botMinFireTime", "100" ); + setdvar( "sv_botMaxFireTime", "300" ); + setdvar( "sv_botYawSpeed", "14" ); + setdvar( "sv_botYawSpeedAds", "14" ); + setdvar( "sv_botPitchUp", "-5" ); + setdvar( "sv_botPitchDown", "10" ); + setdvar( "sv_botFov", "160" ); + setdvar( "sv_botMinAdsTime", "3000" ); + setdvar( "sv_botMaxAdsTime", "5000" ); + setdvar( "sv_botMinCrouchTime", "100" ); + setdvar( "sv_botMaxCrouchTime", "400" ); setdvar( "sv_botTargetLeadBias", "2" ); setdvar( "sv_botMinReactionTime", "30" ); setdvar( "sv_botMaxReactionTime", "100" ); - setdvar( "sv_botStrafeChance", "1" ); - setdvar( "sv_botMinStrafeTime", "3000" ); - setdvar( "sv_botMaxStrafeTime", "6000" ); - setdvar( "scr_help_dist", "512" ); - setdvar( "sv_botAllowGrenades", "1" ); + setdvar( "sv_botStrafeChance", "1" ); + setdvar( "sv_botMinStrafeTime", "3000" ); + setdvar( "sv_botMaxStrafeTime", "6000" ); + setdvar( "scr_help_dist", "512" ); + setdvar( "sv_botAllowGrenades", "1" ); setdvar( "sv_botMinGrenadeTime", "1500" ); setdvar( "sv_botMaxGrenadeTime", "4000" ); setdvar( "sv_botSprintDistance", "512" ); - setdvar( "sv_botMeleeDist", "80" ); + setdvar( "sv_botMeleeDist", "80" ); } else if ( difficulty == "hard" ) { - setdvar( "sv_botMinDeathTime", "250" ); - setdvar( "sv_botMaxDeathTime", "500" ); - setdvar( "sv_botMinFireTime", "400" ); - setdvar( "sv_botMaxFireTime", "600" ); - setdvar( "sv_botYawSpeed", "8" ); - setdvar( "sv_botYawSpeedAds", "10" ); - setdvar( "sv_botPitchUp", "-5" ); - setdvar( "sv_botPitchDown", "10" ); - setdvar( "sv_botFov", "100" ); - setdvar( "sv_botMinAdsTime", "3000" ); - setdvar( "sv_botMaxAdsTime", "5000" ); - setdvar( "sv_botMinCrouchTime", "100" ); - setdvar( "sv_botMaxCrouchTime", "400" ); + setdvar( "sv_botMinDeathTime", "250" ); + setdvar( "sv_botMaxDeathTime", "500" ); + setdvar( "sv_botMinFireTime", "400" ); + setdvar( "sv_botMaxFireTime", "600" ); + setdvar( "sv_botYawSpeed", "8" ); + setdvar( "sv_botYawSpeedAds", "10" ); + setdvar( "sv_botPitchUp", "-5" ); + setdvar( "sv_botPitchDown", "10" ); + setdvar( "sv_botFov", "100" ); + setdvar( "sv_botMinAdsTime", "3000" ); + setdvar( "sv_botMaxAdsTime", "5000" ); + setdvar( "sv_botMinCrouchTime", "100" ); + setdvar( "sv_botMaxCrouchTime", "400" ); setdvar( "sv_botTargetLeadBias", "2" ); setdvar( "sv_botMinReactionTime", "400" ); setdvar( "sv_botMaxReactionTime", "700" ); - setdvar( "sv_botStrafeChance", "0.9" ); - setdvar( "sv_botMinStrafeTime", "3000" ); - setdvar( "sv_botMaxStrafeTime", "6000" ); - setdvar( "scr_help_dist", "384" ); - setdvar( "sv_botAllowGrenades", "1" ); + setdvar( "sv_botStrafeChance", "0.9" ); + setdvar( "sv_botMinStrafeTime", "3000" ); + setdvar( "sv_botMaxStrafeTime", "6000" ); + setdvar( "scr_help_dist", "384" ); + setdvar( "sv_botAllowGrenades", "1" ); setdvar( "sv_botMinGrenadeTime", "1500" ); setdvar( "sv_botMaxGrenadeTime", "4000" ); setdvar( "sv_botSprintDistance", "512" ); - setdvar( "sv_botMeleeDist", "80" ); + setdvar( "sv_botMeleeDist", "80" ); } else if ( difficulty == "easy" ) { - setdvar( "sv_botMinDeathTime", "1000" ); - setdvar( "sv_botMaxDeathTime", "2000" ); - setdvar( "sv_botMinFireTime", "900" ); - setdvar( "sv_botMaxFireTime", "1000" ); - setdvar( "sv_botYawSpeed", "2" ); - setdvar( "sv_botYawSpeedAds", "2.5" ); - setdvar( "sv_botPitchUp", "-20" ); - setdvar( "sv_botPitchDown", "40" ); - setdvar( "sv_botFov", "50" ); - setdvar( "sv_botMinAdsTime", "3000" ); - setdvar( "sv_botMaxAdsTime", "5000" ); - setdvar( "sv_botMinCrouchTime", "4000" ); - setdvar( "sv_botMaxCrouchTime", "6000" ); + setdvar( "sv_botMinDeathTime", "1000" ); + setdvar( "sv_botMaxDeathTime", "2000" ); + setdvar( "sv_botMinFireTime", "900" ); + setdvar( "sv_botMaxFireTime", "1000" ); + setdvar( "sv_botYawSpeed", "2" ); + setdvar( "sv_botYawSpeedAds", "2.5" ); + setdvar( "sv_botPitchUp", "-20" ); + setdvar( "sv_botPitchDown", "40" ); + setdvar( "sv_botFov", "50" ); + setdvar( "sv_botMinAdsTime", "3000" ); + setdvar( "sv_botMaxAdsTime", "5000" ); + setdvar( "sv_botMinCrouchTime", "4000" ); + setdvar( "sv_botMaxCrouchTime", "6000" ); setdvar( "sv_botTargetLeadBias", "8" ); setdvar( "sv_botMinReactionTime", "1200" ); setdvar( "sv_botMaxReactionTime", "1600" ); - setdvar( "sv_botStrafeChance", "0.1" ); - setdvar( "sv_botMinStrafeTime", "3000" ); - setdvar( "sv_botMaxStrafeTime", "6000" ); - setdvar( "scr_help_dist", "256" ); - setdvar( "sv_botAllowGrenades", "0" ); + setdvar( "sv_botStrafeChance", "0.1" ); + setdvar( "sv_botMinStrafeTime", "3000" ); + setdvar( "sv_botMaxStrafeTime", "6000" ); + setdvar( "scr_help_dist", "256" ); + setdvar( "sv_botAllowGrenades", "0" ); setdvar( "sv_botSprintDistance", "1024" ); - setdvar( "sv_botMeleeDist", "40" ); + setdvar( "sv_botMeleeDist", "40" ); } else // 'normal' difficulty { @@ -500,53 +500,53 @@ bot_set_difficulty( difficulty ) { return; } - - setdvar( "sv_botMinDeathTime", "500" ); - setdvar( "sv_botMaxDeathTime", "1000" ); - setdvar( "sv_botMinFireTime", "600" ); - setdvar( "sv_botMaxFireTime", "800" ); - setdvar( "sv_botYawSpeed", "4" ); - setdvar( "sv_botYawSpeedAds", "5" ); - setdvar( "sv_botPitchUp", "-10" ); - setdvar( "sv_botPitchDown", "20" ); - setdvar( "sv_botFov", "70" ); - setdvar( "sv_botMinAdsTime", "3000" ); - setdvar( "sv_botMaxAdsTime", "5000" ); - setdvar( "sv_botMinCrouchTime", "2000" ); - setdvar( "sv_botMaxCrouchTime", "4000" ); + + setdvar( "sv_botMinDeathTime", "500" ); + setdvar( "sv_botMaxDeathTime", "1000" ); + setdvar( "sv_botMinFireTime", "600" ); + setdvar( "sv_botMaxFireTime", "800" ); + setdvar( "sv_botYawSpeed", "4" ); + setdvar( "sv_botYawSpeedAds", "5" ); + setdvar( "sv_botPitchUp", "-10" ); + setdvar( "sv_botPitchDown", "20" ); + setdvar( "sv_botFov", "70" ); + setdvar( "sv_botMinAdsTime", "3000" ); + setdvar( "sv_botMaxAdsTime", "5000" ); + setdvar( "sv_botMinCrouchTime", "2000" ); + setdvar( "sv_botMaxCrouchTime", "4000" ); setdvar( "sv_botTargetLeadBias", "4" ); setdvar( "sv_botMinReactionTime", "800" ); setdvar( "sv_botMaxReactionTime", "1200" ); - setdvar( "sv_botStrafeChance", "0.6" ); - setdvar( "sv_botMinStrafeTime", "3000" ); - setdvar( "sv_botMaxStrafeTime", "6000" ); - setdvar( "scr_help_dist", "256" ); - setdvar( "sv_botAllowGrenades", "1" ); + setdvar( "sv_botStrafeChance", "0.6" ); + setdvar( "sv_botMinStrafeTime", "3000" ); + setdvar( "sv_botMaxStrafeTime", "6000" ); + setdvar( "scr_help_dist", "256" ); + setdvar( "sv_botAllowGrenades", "1" ); setdvar( "sv_botMinGrenadeTime", "1500" ); setdvar( "sv_botMaxGrenadeTime", "4000" ); setdvar( "sv_botSprintDistance", "512" ); - setdvar( "sv_botMeleeDist", "80" ); + setdvar( "sv_botMeleeDist", "80" ); difficulty = "normal"; } - + if ( level.gametype == "oic" && difficulty == "fu" ) { - setdvar( "sv_botMinReactionTime", "400" ); - setdvar( "sv_botMaxReactionTime", "500" ); - setdvar( "sv_botMinAdsTime", "1000" ); - setdvar( "sv_botMaxAdsTime", "2000" ); + setdvar( "sv_botMinReactionTime", "400" ); + setdvar( "sv_botMaxReactionTime", "500" ); + setdvar( "sv_botMinAdsTime", "1000" ); + setdvar( "sv_botMaxAdsTime", "2000" ); } - + if ( level.gametype == "oic" && ( difficulty == "hard" || difficulty == "fu" ) ) { setdvar( "sv_botSprintDistance", "256" ); } - + if ( !getdvarint( "bots_play_nade" ) ) { - setdvar( "sv_botAllowGrenades", "0" ); + setdvar( "sv_botAllowGrenades", "0" ); } - + if ( !getdvarint( "bots_play_aim" ) ) { setdvar( "sv_botYawSpeed", "0" ); @@ -554,7 +554,7 @@ bot_set_difficulty( difficulty ) setdvar( "sv_botPitchUp", "0" ); setdvar( "sv_botPitchDown", "0" ); } - + setdvar( "bot_difficulty", difficulty ); setdvar( "scr_bot_difficulty", difficulty ); setdvar( "splitscreen_botDifficulty", difficulty ); @@ -567,23 +567,23 @@ teamBots_loop() { teamAmount = getdvarint( "bots_team_amount" ); toTeam = getdvar( "bots_team" ); - + alliesbots = 0; alliesplayers = 0; axisbots = 0; axisplayers = 0; - + playercount = level.players.size; - + for ( i = 0; i < playercount; i++ ) { player = level.players[ i ]; - + if ( !isdefined( player.pers[ "team" ] ) ) { continue; } - + if ( player is_bot() ) { if ( player.pers[ "team" ] == "allies" ) @@ -607,16 +607,16 @@ teamBots_loop() } } } - + allies = alliesbots; axis = axisbots; - + if ( !getdvarint( "bots_team_mode" ) ) { allies += alliesplayers; axis += axisplayers; } - + if ( toTeam != "custom" ) { if ( getdvarint( "bots_team_force" ) ) @@ -626,37 +626,37 @@ teamBots_loop() if ( abs( axis - allies ) > 1 ) { toTeam = "axis"; - + if ( axis > allies ) { toTeam = "allies"; } } } - + if ( toTeam != "autoassign" ) { playercount = level.players.size; - + for ( i = 0; i < playercount; i++ ) { 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 ]](); @@ -669,7 +669,7 @@ teamBots_loop() { player thread [[ level.spectator ]](); } - + break; } } @@ -678,21 +678,21 @@ teamBots_loop() else { playercount = level.players.size; - + for ( i = 0; i < playercount; i++ ) { player = level.players[ i ]; - + if ( !isdefined( player.pers[ "team" ] ) ) { continue; } - + if ( !player is_bot() ) { continue; } - + if ( player.pers[ "team" ] == "axis" ) { if ( axis > teamAmount ) @@ -736,47 +736,47 @@ teamBots() addBots_loop() { botsToAdd = getdvarint( "bots_manage_add" ); - + if ( botsToAdd > 0 ) { setdvar( "bots_manage_add", 0 ); - + if ( botsToAdd > 64 ) { botsToAdd = 64; } - + for ( ; botsToAdd > 0; botsToAdd-- ) { level add_bot(); wait 0.25; } } - + fillMode = getdvarint( "bots_manage_fill_mode" ); - + if ( fillMode == 2 || fillMode == 3 ) { setdvar( "bots_manage_fill", getGoodMapAmount() ); } - + fillAmount = getdvarint( "bots_manage_fill" ); - + players = 0; bots = 0; spec = 0; - + playercount = level.players.size; - + for ( i = 0; i < playercount; i++ ) { player = level.players[ i ]; - + if ( player isdemoclient() ) { continue; } - + if ( player is_bot() ) { bots++; @@ -790,28 +790,28 @@ addBots_loop() players++; } } - + if ( fillMode == 4 ) { axisplayers = 0; alliesplayers = 0; - + playercount = level.players.size; - + for ( i = 0; i < playercount; i++ ) { player = level.players[ i ]; - + if ( player is_bot() ) { continue; } - + if ( !isdefined( player.pers[ "team" ] ) ) { continue; } - + if ( player.pers[ "team" ] == "axis" ) { axisplayers++; @@ -821,9 +821,9 @@ addBots_loop() alliesplayers++; } } - + result = fillAmount - abs( axisplayers - alliesplayers ) + bots; - + if ( players == 0 ) { if ( bots < fillAmount ) @@ -839,10 +839,10 @@ addBots_loop() result = fillAmount; } } - + bots = result; } - + if ( !randomint( 999 ) ) { setdvar( "testclients_doreload", true ); @@ -850,19 +850,19 @@ addBots_loop() setdvar( "testclients_doreload", false ); doExtraCheck(); } - + 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 ); @@ -870,7 +870,7 @@ addBots_loop() else if ( amount > fillAmount && getdvarint( "bots_manage_fill_kick" ) ) { tempBot = getBotToKick(); - + if ( isdefined( tempBot ) ) { kick( tempBot getentitynumber(), "EXE_PLAYERKICKED" ); @@ -884,13 +884,13 @@ addBots_loop() addBots() { level endon ( "game_ended" ); - + bot_wait_for_host(); - + for ( ;; ) { wait 1.5; - + addBots_loop(); } } @@ -901,7 +901,7 @@ addBots() add_bot() { bot = addtestclient(); - + if ( isdefined( bot ) ) { bot.pers[ "isBot" ] = true; @@ -935,52 +935,52 @@ bot_is_idle() { return false; } - + if ( !isalive( self ) ) { return false; } - + if ( !self is_bot() ) { return false; } - + if ( self inLastStand() ) { return false; } - + if ( self hasscriptgoal() ) { return false; } - + if ( isdefined( self getthreat() ) ) { return false; } - + if ( self isremotecontrolling() || self.bot_lock_goal ) { return false; } - + if ( self usebuttonpressed() ) { return false; } - + if ( self isPlanting() ) { return false; } - + if ( self isDefusing() ) { return false; } - + return true; } @@ -990,18 +990,18 @@ bot_is_idle() watch_grenade() { self endon( "disconnect" ); - + self.bot_scrambled = false; - + for ( ;; ) { self waittill( "grenade_fire", g, name ); - + if ( !isdefined( g ) ) { continue; } - + if ( name == "scrambler_mp" ) { g thread watch_scrambler(); @@ -1019,11 +1019,11 @@ watch_grenade() watch_decoy( g ) { g.team = self.team; - + level.bot_decoys[ level.bot_decoys.size ] = g; - + g waittill( "death" ); - + for ( entry = 0; entry < level.bot_decoys.size; entry++ ) { if ( level.bot_decoys[ entry ] == g ) @@ -1033,7 +1033,7 @@ watch_decoy( g ) level.bot_decoys[ entry ] = level.bot_decoys[ entry + 1 ]; entry++; } - + level.bot_decoys[ entry ] = undefined; break; } @@ -1046,9 +1046,9 @@ watch_decoy( g ) watch_scrambler() { trig = spawn( "trigger_radius", self.origin + ( 0, 0, -1000 ), 0, 1000, 2000 ); - + self scramble_nearby( trig ); - + trig delete (); } @@ -1059,38 +1059,38 @@ scramble_nearby( trig ) { self endon( "death" ); self endon( "hacked" ); - + while ( !isdefined( self.owner ) || !isdefined( self.owner.team ) ) { wait 0.05; } - + self.team = self.owner.team; - + for ( ;; ) { 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(); } } @@ -1102,10 +1102,10 @@ scramble_player() { self notify( "scramble_nearby" ); self endon( "scramble_nearby" ); - + self.bot_scrambled = true; wait 0.1; - + if ( isdefined( self ) ) { self.bot_scrambled = false; @@ -1118,9 +1118,9 @@ scramble_player() watch_shoot() { self endon( "disconnect" ); - + self.bot_firing = false; - + for ( ;; ) { self waittill( "weapon_fired" ); @@ -1135,7 +1135,7 @@ doFiringThread() { self endon( "disconnect" ); self endon( "weapon_fired" ); - + self.bot_firing = true; wait 1; self.bot_firing = false; @@ -1147,21 +1147,21 @@ doFiringThread() bot_watch_planes_loop() { ents = getentarray( "script_model", "classname" ); - + for ( i = 0; i < ents.size; i++ ) { ent = ents[ i ]; - + if ( isdefined( ent.bot_plane ) ) { continue; } - + if ( ent.model != level.spyplanemodel ) { continue; } - + thread watch_plane( ent ); } } @@ -1174,7 +1174,7 @@ bot_watch_planes() for ( ;; ) { level waittill( "uav_update" ); - + bot_watch_planes_loop(); } } @@ -1185,11 +1185,11 @@ bot_watch_planes() watch_plane( ent ) { ent.bot_plane = true; - + level.bot_planes[ level.bot_planes.size ] = ent; - + ent waittill_any( "death", "delete", "leaving" ); - + for ( entry = 0; entry < level.bot_planes.size; entry++ ) { if ( level.bot_planes[ entry ] == ent ) @@ -1199,7 +1199,7 @@ watch_plane( ent ) level.bot_planes[ entry ] = level.bot_planes[ entry + 1 ]; entry++; } - + level.bot_planes[ entry ] = undefined; break; } @@ -1224,15 +1224,15 @@ fixGamemodes() if ( isdefined( level.bombzones ) && level.gametype == "sd" ) { level.iskillboosting = ::bot_killBoost; - + for ( i = 0; i < level.bombzones.size; i++ ) { level.bombzones[ i ].onuse = ::bot_onUsePlantObjectFix; } - + break; } - + wait 0.05; } }