148 lines
8.8 KiB
Plaintext
148 lines
8.8 KiB
Plaintext
#using scripts\shared\array_shared;
|
|
#using scripts\shared\gameobjects_shared;
|
|
#using scripts\shared\math_shared;
|
|
#using scripts\shared\util_shared;
|
|
|
|
|
|
|
|
#using scripts\shared\bots\_bot;
|
|
#using scripts\shared\bots\_bot_combat;
|
|
#using scripts\shared\bots\bot_buttons;
|
|
#using scripts\mp\bots\_bot;
|
|
#using scripts\mp\bots\_bot_combat;
|
|
|
|
|
|
|
|
#namespace bot_dem;
|
|
|
|
|
|
|
|
|
|
|
|
function init()
|
|
{
|
|
level.botIdle = &bot_idle;
|
|
level.botCombat = &combat_think;
|
|
level.botThreatLost = &bot_threat_lost;
|
|
}
|
|
|
|
function bot_idle()
|
|
{
|
|
approachRadiusSq = 750 * 750;
|
|
|
|
// Check for Plant / Defuse
|
|
foreach( zone in level.bombZones )
|
|
{
|
|
if ( ( isdefined( zone.bombExploded ) && zone.bombExploded ) )
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if ( self IsTouching( zone.trigger ) )
|
|
{
|
|
if ( self can_plant( zone ) || self can_defuse( zone ) )
|
|
{
|
|
self bot::press_use_button();
|
|
return;
|
|
}
|
|
}
|
|
|
|
if ( DistanceSquared( self.origin, zone.trigger.origin ) < approachRadiusSq )
|
|
{
|
|
// Defuse / Plant nearby zone
|
|
if ( self can_plant( zone ) || self can_defuse( zone ) )
|
|
{
|
|
self bot::path_to_trigger( zone.trigger );
|
|
self bot::sprint_to_goal();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Shuffle zones
|
|
zones = array::randomize( level.bombZones );
|
|
|
|
// Check for zones to defuse
|
|
foreach( zone in zones )
|
|
{
|
|
if ( ( isdefined( zone.bombExploded ) && zone.bombExploded ) )
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if ( self can_defuse( zone ) && RandomInt( 100 ) < 70 )
|
|
{
|
|
self bot::approach_goal_trigger( zone.trigger, 750 );
|
|
self bot::sprint_to_goal();
|
|
return;
|
|
}
|
|
}
|
|
|
|
// Go to a random zone to plant / guard
|
|
foreach( zone in zones )
|
|
{
|
|
if ( ( isdefined( zone.bombExploded ) && zone.bombExploded ) )
|
|
{
|
|
continue;
|
|
}
|
|
|
|
// Defend the nearby point
|
|
if ( DistanceSquared( self.origin, zone.trigger.origin ) < approachRadiusSq &&
|
|
RandomInt( 100 ) < 70 )
|
|
{
|
|
triggerRadius = self bot::get_trigger_radius( zone.trigger );
|
|
self bot::approach_point( zone.trigger.origin, triggerRadius, 750 );
|
|
self bot::sprint_to_goal();
|
|
return;
|
|
}
|
|
}
|
|
|
|
self bot::bot_idle();
|
|
}
|
|
|
|
function can_plant( zone )
|
|
{
|
|
return !( isdefined( zone.bombPlanted ) && zone.bombPlanted ) && self.team != zone gameobjects::get_owner_team();
|
|
}
|
|
|
|
function can_defuse( zone )
|
|
{
|
|
return ( isdefined( zone.bombPlanted ) && zone.bombPlanted ) && self.team == zone gameobjects::get_owner_team();
|
|
}
|
|
|
|
|
|
function combat_think()
|
|
{
|
|
if ( ( isdefined( self.isPlanting ) && self.isPlanting ) ||
|
|
( isdefined( self.isDefusing ) && self.isDefusing ) )
|
|
{
|
|
return;
|
|
}
|
|
|
|
self bot_combat::combat_think();
|
|
}
|
|
|
|
function bot_threat_lost()
|
|
{
|
|
approachRadiusSq = 750 * 750;
|
|
|
|
// Don't chase enemies if near a plantable/defusable zone
|
|
foreach( zone in level.bombZones )
|
|
{
|
|
if ( ( isdefined( zone.bombExploded ) && zone.bombExploded ) )
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if ( DistanceSquared( self.origin, zone.trigger.origin ) < approachRadiusSq )
|
|
{
|
|
// Defuse / Plant nearby zone
|
|
if ( self can_plant( zone ) || self can_defuse( zone ) )
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
self bot_combat::chase_threat();
|
|
} |