diff --git a/main_shared/maps/mp/bots/_bot_script.gsc b/main_shared/maps/mp/bots/_bot_script.gsc index 0544d70..35f95dc 100644 --- a/main_shared/maps/mp/bots/_bot_script.gsc +++ b/main_shared/maps/mp/bots/_bot_script.gsc @@ -3209,6 +3209,136 @@ bot_equipment_attack( equ ) } } +/* + Bots do random stance +*/ +BotRandomStance() +{ + if ( randomInt( 100 ) < 80 ) + self BotSetStance( "prone" ); + else if ( randomInt( 100 ) < 60 ) + self BotSetStance( "crouch" ); + else + self BotSetStance( "stand" ); +} + +/* + Bots will use a random equipment +*/ +BotUseRandomEquipment() +{ + self endon( "death" ); + self endon( "disconnect" ); + + equ = undefined; + + if ( self GetAmmoCount( "mine_bouncing_betty_mp" ) ) + equ = "mine_bouncing_betty_mp"; + + if ( self GetAmmoCount( "satchel_charge_mp" ) ) + equ = "satchel_charge_mp"; + + if ( !isDefined( equ ) ) + return; + + curWeap = self GetCurrentWeapon(); + + if ( self changeToWeapon( equ ) ) + { + if ( equ != "satchel_charge_mp" ) + self thread fire_current_weapon(); + else + self thread fire_c4(); + + self waittill_any_timeout( 5, "grenade_fire", "weapon_change" ); + self notify( "stop_firing_weapon" ); + } + + self thread changeToWeapon( curWeap ); +} + +/* + Bots will look at a random thing +*/ +BotLookAtRandomThing( obj_target ) +{ + self endon( "death" ); + self endon( "disconnect" ); + + if ( self HasScriptAimPos() ) + return; + + rand = RandomInt( 100 ); + + nearestEnemy = undefined; + + for ( i = 0; i < level.players.size; i++ ) + { + player = level.players[i]; + + if ( !isDefined( player ) || !isDefined( player.team ) ) + continue; + + if ( !isAlive( player ) ) + continue; + + if ( level.teamBased && self.team == player.team ) + continue; + + if ( !isDefined( nearestEnemy ) || DistanceSquared( self.origin, player.origin ) < DistanceSquared( self.origin, nearestEnemy.origin ) ) + { + nearestEnemy = player; + } + } + + origin = ( 0, 0, self GetEyeHeight() ); + + if ( isDefined( nearestEnemy ) && DistanceSquared( self.origin, nearestEnemy.origin ) < 1024 * 1024 && rand < 40 ) + origin += ( nearestEnemy.origin[0], nearestEnemy.origin[1], self.origin[2] ); + else if ( isDefined( obj_target ) && rand < 50 ) + origin += ( obj_target.origin[0], obj_target.origin[1], self.origin[2] ); + else if ( rand < 85 ) + origin += self.origin + AnglesToForward( ( 0, self.angles[1] - 180, 0 ) ) * 1024; + else + origin += self.origin + AnglesToForward( ( 0, RandomInt( 360 ), 0 ) ) * 1024; + + self SetScriptAimPos( origin ); + wait 2; + self ClearScriptAimPos(); +} + +/* + Bots will do stuff while waiting for objective +*/ +bot_do_random_action_for_objective( obj_target ) +{ + self endon( "death" ); + 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 ); + } + else + { + if ( self GetStance() != "prone" && randomInt( 100 ) < 15 ) + self BotSetStance( "prone" ); + else if ( randomInt( 100 ) < 5 ) + self thread BotLookAtRandomThing( obj_target ); + } + + wait 2; + self.bot_random_obj_action = undefined; +} + /* Bots hang around the enemy's flag to spawn kill em */ @@ -3465,6 +3595,8 @@ bot_dom_cap_think_loop() if ( flag.useObj.curProgress == cur ) break;//some enemy is near us, kill him + + self thread bot_do_random_action_for_objective( flag ); } self ClearScriptGoal(); @@ -3593,6 +3725,8 @@ bot_hq_loop() if ( cur == gameobj.curProgress ) break;//no prog made, enemy must be capping + + self thread bot_do_random_action_for_objective( gameobj.trigger ); } self ClearScriptGoal(); @@ -3810,6 +3944,7 @@ bot_sab_loop() return; } + self BotRandomStance(); self SetScriptGoal( self.origin, 64 ); self bot_use_bomb_thread( site ); @@ -3927,6 +4062,7 @@ bot_sab_loop() return; } + self BotRandomStance(); self SetScriptGoal( self.origin, 64 ); self bot_use_bomb_thread( site ); @@ -4128,6 +4264,7 @@ bot_sd_defenders_loop( data ) return; } + self BotRandomStance(); self SetScriptGoal( self.origin, 64 ); self bot_use_bomb_thread( defuse ); @@ -4339,6 +4476,7 @@ bot_sd_attackers_loop( data ) return; } + self BotRandomStance(); self SetScriptGoal( self.origin, 64 ); self bot_use_bomb_thread( plant ); @@ -4643,6 +4781,8 @@ bot_war_loop( data ) if ( flag.useObj.curProgress == cur ) break;//some enemy is near us, kill him + + self thread bot_do_random_action_for_objective( flag ); } self ClearScriptGoal(); diff --git a/main_shared/maps/mp/bots/_bot_utility.gsc b/main_shared/maps/mp/bots/_bot_utility.gsc index 79661dc..220e88e 100644 --- a/main_shared/maps/mp/bots/_bot_utility.gsc +++ b/main_shared/maps/mp/bots/_bot_utility.gsc @@ -62,6 +62,27 @@ is_bot() return self isBot(); } +/* + Set the bot's stance +*/ +BotSetStance( stance ) +{ + switch ( stance ) + { + case "stand": + self maps\mp\bots\_bot_internal::stand(); + break; + + case "crouch": + self maps\mp\bots\_bot_internal::crouch(); + break; + + case "prone": + self maps\mp\bots\_bot_internal::prone(); + break; + } +} + /* Bot changes to the weap */