mirror of
https://github.com/JezuzLizard/t4sp_bot_warfare.git
synced 2025-10-29 08:56:56 +00:00
cleanup
This commit is contained in:
@@ -236,6 +236,14 @@ BotNotifyBotEvent( msg, a, b, c, d, e, f, g )
|
||||
self notify( "bot_event", msg, a, b, c, d, e, f, g );
|
||||
}
|
||||
|
||||
/*
|
||||
Does the bot have an objective?
|
||||
*/
|
||||
BotHasObjective()
|
||||
{
|
||||
return self maps\bots\objectives\_utility::HasBotObjective();
|
||||
}
|
||||
|
||||
/*
|
||||
Returns if the bot has a script goal.
|
||||
(like t5 gsc bot)
|
||||
@@ -312,6 +320,7 @@ SetPriorityObjective()
|
||||
ClearPriorityObjective()
|
||||
{
|
||||
self.bot.prio_objective = false;
|
||||
self notify( "kill_goal" );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -648,6 +657,9 @@ DistanceSquared2D( to, from )
|
||||
return DistanceSquared( to, from );
|
||||
}
|
||||
|
||||
/*
|
||||
Distance from box
|
||||
*/
|
||||
RectDistanceSquared( origin )
|
||||
{
|
||||
dx = 0;
|
||||
@@ -1071,6 +1083,9 @@ inLastStand()
|
||||
return self [[func]]();
|
||||
}
|
||||
|
||||
/*
|
||||
Is reviving player
|
||||
*/
|
||||
isReviving( revivee )
|
||||
{
|
||||
func = GetFunction( "maps/_laststand", "is_reviving" );
|
||||
@@ -1122,3 +1137,204 @@ isWeaponPrimary( weap )
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Checks whether the path generated by the ASTAR path finding is inaccessible
|
||||
*/
|
||||
GetPathIsInaccessible( from, to, team, best_effort )
|
||||
{
|
||||
if ( isDefined( best_effort ) )
|
||||
{
|
||||
path = generatePath( from, to, team, level.bot_allowed_negotiation_links, best_effort );
|
||||
}
|
||||
else
|
||||
{
|
||||
path = generatePath( from, to, team, level.bot_allowed_negotiation_links );
|
||||
}
|
||||
|
||||
return ( !isDefined( path ) || ( path.size <= 0 ) );
|
||||
}
|
||||
|
||||
/*
|
||||
Returns how long the path is
|
||||
*/
|
||||
get_path_dist( start, end, team )
|
||||
{
|
||||
path = generatePath( start, end, team, level.bot_allowed_negotiation_links, 192.0 );
|
||||
|
||||
if ( !isDefined( path ) || path.size <= 0 )
|
||||
{
|
||||
return 999999999;
|
||||
}
|
||||
|
||||
dist = 0;
|
||||
prev_node = undefined;
|
||||
|
||||
for ( i = 0; i < path.size; i++ )
|
||||
{
|
||||
if ( i == 0 )
|
||||
{
|
||||
prev_node = path[ i ];
|
||||
continue;
|
||||
}
|
||||
|
||||
dist += distance( prev_node.origin, path[ i ].origin );
|
||||
prev_node = path[ i ];
|
||||
}
|
||||
|
||||
return dist;
|
||||
}
|
||||
|
||||
/*
|
||||
Clamp lerp,
|
||||
*/
|
||||
ClampLerp( dist, min_dist, max_dist, max_bonus, min_bonus )
|
||||
{
|
||||
answer = 0;
|
||||
|
||||
if ( dist <= min_dist )
|
||||
{
|
||||
answer += max_bonus;
|
||||
}
|
||||
else if ( dist >= max_dist )
|
||||
{
|
||||
answer += min_bonus;
|
||||
}
|
||||
else
|
||||
{
|
||||
dist_multi = 1 - ( ( dist - min_dist ) / ( max_dist - min_dist ) );
|
||||
answer += min_bonus + ( ( max_bonus - min_bonus ) * dist_multi );
|
||||
}
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
/*
|
||||
Base an origin offset from an ent
|
||||
*/
|
||||
get_angle_offset_node( forward_size, angle_offset, offset )
|
||||
{
|
||||
if ( !isDefined( forward_size ) )
|
||||
{
|
||||
forward_size = 40;
|
||||
}
|
||||
|
||||
if ( !isDefined( angle_offset ) )
|
||||
{
|
||||
angle_offset = ( 0, 0, 0 );
|
||||
}
|
||||
|
||||
if ( !isDefined( offset ) )
|
||||
{
|
||||
offset = ( 0, 0, 0 );
|
||||
}
|
||||
|
||||
angles = ( 0, self.angles[ 1 ], 0 );
|
||||
angles += angle_offset;
|
||||
node = self.origin + ( AnglesToForward( angles ) * forward_size ) + offset;
|
||||
node = clamp_to_ground( node );
|
||||
|
||||
if ( getDvarInt( "bots_main_debug" ) )
|
||||
{
|
||||
self thread debug_offset_line( node );
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/*
|
||||
Draw the offset
|
||||
*/
|
||||
debug_offset_line( node )
|
||||
{
|
||||
self endon( "death" );
|
||||
self notify( "debug_offset_line" );
|
||||
self endon( "debug_offset_line" );
|
||||
|
||||
while ( isDefined( self ) )
|
||||
{
|
||||
line( self.origin, node );
|
||||
wait 0.05;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Is the point inside this use trigger?
|
||||
*/
|
||||
PointInsideUseTrigger( point )
|
||||
{
|
||||
if ( getDvarInt( "bots_main_debug" ) )
|
||||
{
|
||||
self thread debug_bounding_box_for_ent();
|
||||
}
|
||||
|
||||
mins = self getmins();
|
||||
maxs = self getmaxs();
|
||||
|
||||
box = spawnstruct();
|
||||
box.x0 = self.origin[0] + mins[0];
|
||||
box.x1 = self.origin[0] + maxs[0];
|
||||
box.y0 = self.origin[1] + mins[1];
|
||||
box.y1 = self.origin[1] + maxs[1];
|
||||
box.z0 = self.origin[2] + mins[2];
|
||||
box.z1 = self.origin[2] + maxs[2];
|
||||
|
||||
if ( box RectDistanceSquared( self.origin ) > 72 * 72 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !sightTracePassed( point, self.origin, false, undefined ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Draw the aabb of the ent
|
||||
*/
|
||||
debug_bounding_box_for_ent( color )
|
||||
{
|
||||
self endon( "death" );
|
||||
self notify( "debug_bounding_box_for_ent" );
|
||||
self endon( "debug_bounding_box_for_ent" );
|
||||
|
||||
if ( !isDefined( color ) )
|
||||
color = ( randomFloatRange( 0, 1 ), randomFloatRange( 0, 1 ), randomFloatRange( 0, 1 ) );
|
||||
|
||||
while ( isDefined( self ) )
|
||||
{
|
||||
mins = self getmins();
|
||||
maxs = self getmaxs();
|
||||
|
||||
line( self.origin + ( mins[0], mins[1], mins[2] ), self.origin + ( mins[0], mins[1], maxs[2] ), color );
|
||||
line( self.origin + ( mins[0], mins[1], mins[2] ), self.origin + ( mins[0], maxs[1], mins[2] ), color );
|
||||
line( self.origin + ( mins[0], mins[1], mins[2] ), self.origin + ( maxs[0], mins[1], mins[2] ), color );
|
||||
|
||||
line( self.origin + ( maxs[0], maxs[1], maxs[2] ), self.origin + ( maxs[0], maxs[1], mins[2] ), color );
|
||||
line( self.origin + ( maxs[0], maxs[1], maxs[2] ), self.origin + ( maxs[0], mins[1], maxs[2] ), color );
|
||||
line( self.origin + ( maxs[0], maxs[1], maxs[2] ), self.origin + ( mins[0], maxs[1], maxs[2] ), color );
|
||||
|
||||
line( self.origin + ( maxs[0], mins[1], mins[2] ), self.origin + ( maxs[0], maxs[1], mins[2] ), color );
|
||||
line( self.origin + ( maxs[0], mins[1], mins[2] ), self.origin + ( maxs[0], mins[1], maxs[2] ), color );
|
||||
|
||||
line( self.origin + ( mins[0], mins[1], maxs[2] ), self.origin + ( maxs[0], mins[1], maxs[2] ), color );
|
||||
line( self.origin + ( mins[0], mins[1], maxs[2] ), self.origin + ( mins[0], maxs[1], maxs[2] ), color );
|
||||
|
||||
line( self.origin + ( mins[0], maxs[1], mins[2] ), self.origin + ( maxs[0], maxs[1], mins[2] ), color );
|
||||
line( self.origin + ( mins[0], maxs[1], mins[2] ), self.origin + ( mins[0], maxs[1], maxs[2] ), color );
|
||||
|
||||
wait 0.05;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Clamp the origin to the ground
|
||||
*/
|
||||
clamp_to_ground( org )
|
||||
{
|
||||
trace = playerPhysicsTrace( org + ( 0, 0, 20 ), org - ( 0, 0, 2000 ) );
|
||||
return trace;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user