curly braces

This commit is contained in:
ineed bots
2023-12-22 01:28:59 -06:00
parent 6921651ab0
commit 8ec1385d18
7 changed files with 2774 additions and 4 deletions
+84
View File
@@ -13,10 +13,14 @@
init()
{
if ( getDvar( "bots_main_debug" ) == "" )
{
setDvar( "bots_main_debug", 0 );
}
if ( !getDVarint( "bots_main_debug" ) )
{
return;
}
if ( !getDVarint( "developer" ) )
{
@@ -36,16 +40,24 @@ init()
setDvar( "bots_manage_fill_spec", 1 );
if ( getDvar( "bots_main_debug_distance" ) == "" )
{
setDvar( "bots_main_debug_distance", 512.0 );
}
if ( getDvar( "bots_main_debug_cone" ) == "" )
{
setDvar( "bots_main_debug_cone", 0.65 );
}
if ( getDvar( "bots_main_debug_minDist" ) == "" )
{
setDvar( "bots_main_debug_minDist", 32.0 );
}
if ( getDvar( "bots_main_debug_drawThrough" ) == "" )
{
setDvar( "bots_main_debug_drawThrough", false );
}
setDvar( "player_sustainAmmo", 1 );
@@ -131,7 +143,9 @@ watchAstarCommand()
self waittill( "astar" );
if ( 1 )
{
continue;
}
self iprintln( "Start AStar" );
self.astar = undefined;
@@ -182,23 +196,33 @@ updateWaypointsStats()
for ( i = 0; i < level.waypointCount; i++ )
{
if ( closest == -1 || closer( self.origin, level.waypoints[i].origin, level.waypoints[closest].origin ) )
{
closest = i;
}
wpOrg = level.waypoints[i].origin + ( 0, 0, 25 );
if ( distance( level.waypoints[i].origin, self.origin ) < getDvarFloat( "bots_main_debug_distance" ) && ( bulletTracePassed( myEye, wpOrg, false, self ) || getDVarint( "bots_main_debug_drawThrough" ) ) )
{
for ( h = level.waypoints[i].children.size - 1; h >= 0; h-- )
{
line( wpOrg, level.waypoints[level.waypoints[i].children[h]].origin + ( 0, 0, 25 ), ( 1, 0, 1 ) );
}
if ( getConeDot( wpOrg, myEye, myAngles ) > getDvarFloat( "bots_main_debug_cone" ) )
{
print3d( wpOrg, i, ( 1, 0, 0 ), 2 );
}
if ( isDefined( level.waypoints[i].angles ) && level.waypoints[i].type != "stand" )
{
line( wpOrg, wpOrg + AnglesToForward( level.waypoints[i].angles ) * 64, ( 1, 1, 1 ) );
}
if ( isDefined( level.waypoints[i].jav_point ) )
{
line( wpOrg, level.waypoints[i].jav_point, ( 0, 0, 0 ) );
}
}
}
@@ -215,7 +239,9 @@ updateWaypointsStats()
infotext.x = infotext.x - 2;
if ( infotext.x <= -800 )
{
infotext.x = 800;
}
if ( self UseButtonPressed() && time > 2 )
{
@@ -386,10 +412,14 @@ watchSaveWaypointsCommand()
}
if ( isDefined( level.waypoints[i].angles ) && ( level.waypoints[i].type == "claymore" || level.waypoints[i].type == "tube" || ( level.waypoints[i].type == "crouch" && level.waypoints[i].children.size == 1 ) || level.waypoints[i].type == "climb" || level.waypoints[i].type == "grenade" ) )
{
logprint( "*/waypoints[" + i + "].angles = " + level.waypoints[i].angles + ";\n/*" );
}
if ( isDefined( level.waypoints[i].jav_point ) && level.waypoints[i].type == "javelin" )
{
logprint( "*/waypoints[" + i + "].jav_point = " + level.waypoints[i].jav_point + ";\n/*" );
}
}
logprint( "*/return waypoints;\n}\n\n\n\n" );
@@ -413,20 +443,30 @@ watchSaveWaypointsCommand()
str += wp.children[h];
if ( h < wp.children.size - 1 )
{
str += " ";
}
}
str += "," + wp.type + ",";
if ( isDefined( wp.angles ) )
{
str += wp.angles[0] + " " + wp.angles[1] + " " + wp.angles[2] + ",";
}
else
{
str += ",";
}
if ( isDefined( wp.jav_point ) )
{
str += wp.jav_point[0] + " " + wp.jav_point[1] + " " + wp.jav_point[2] + ",";
}
else
{
str += ",";
}
PrintLn( str );
BotBuiltinFileWrite( filename, str + "\n", "append" );
@@ -452,10 +492,14 @@ LoadWaypoints()
checkForWarnings()
{
if ( level.waypointCount <= 0 )
{
self iprintln( "WARNING: waypointCount is " + level.waypointCount );
}
if ( level.waypointCount != level.waypoints.size )
{
self iprintln( "WARNING: waypointCount is not " + level.waypoints.size );
}
for ( i = 0; i < level.waypointCount; i++ )
{
@@ -466,7 +510,9 @@ checkForWarnings()
}
if ( level.waypoints[i].children.size <= 0 )
{
self iprintln( "WARNING: waypoint " + i + " childCount is " + level.waypoints[i].children.size );
}
else
{
if ( !isDefined( level.waypoints[i].children ) || !isDefined( level.waypoints[i].children.size ) )
@@ -480,9 +526,13 @@ checkForWarnings()
child = level.waypoints[i].children[h];
if ( !isDefined( level.waypoints[child] ) )
{
self iprintln( "WARNING: waypoint " + i + " child " + child + " is undefined" );
}
else if ( child == i )
{
self iprintln( "WARNING: waypoint " + i + " child " + child + " is itself" );
}
}
}
}
@@ -494,10 +544,14 @@ checkForWarnings()
}
if ( level.waypoints[i].type == "javelin" && !isDefined( level.waypoints[i].jav_point ) )
{
self iprintln( "WARNING: waypoint " + i + " jav_point is undefined" );
}
if ( !isDefined( level.waypoints[i].angles ) && ( level.waypoints[i].type == "claymore" || level.waypoints[i].type == "tube" || ( level.waypoints[i].type == "crouch" && level.waypoints[i].children.size == 1 ) || level.waypoints[i].type == "climb" || level.waypoints[i].type == "grenade" ) )
{
self iprintln( "WARNING: waypoint " + i + " angles is undefined" );
}
}
// check reachability, assume bidirectional graph
@@ -507,12 +561,16 @@ checkForWarnings()
for ( i = 0; i < level.waypointCount; i++ )
{
if ( i % 5 == 0 )
{
wait 0.05;
}
astar = AStarSearch( level.waypoints[wpIdx].origin, level.waypoints[i].origin, undefined, true );
if ( astar.size <= 0 )
{
self iprintln( "WARNING: waypoint " + wpIdx + " has no path to waypoint " + i );
}
}
self iprintln( "Waypoint warnings check completed." );
@@ -620,7 +678,9 @@ DeleteWaypoint( nwp )
for ( h = level.waypoints[i].children.size - 1; h >= 0; h-- )
{
if ( level.waypoints[i].children[h] > nwp )
{
level.waypoints[i].children[h]--;
}
}
}
@@ -652,17 +712,29 @@ AddWaypoint()
level.waypoints[level.waypointCount].origin = pos;
if ( isDefined( self.javelinTargetPoint ) )
{
level.waypoints[level.waypointCount].type = "javelin";
}
else if ( self AdsButtonPressed() )
{
level.waypoints[level.waypointCount].type = "climb";
}
else if ( self AttackButtonPressed() && self UseButtonPressed() )
{
level.waypoints[level.waypointCount].type = "tube";
}
else if ( self AttackButtonPressed() )
{
level.waypoints[level.waypointCount].type = "grenade";
}
else if ( self UseButtonPressed() )
{
level.waypoints[level.waypointCount].type = "claymore";
}
else
{
level.waypoints[level.waypointCount].type = self getStance();
}
level.waypoints[level.waypointCount].angles = self getPlayerAngles();
@@ -678,7 +750,9 @@ AddWaypoint()
if ( level.autoLink )
{
if ( level.wpToLink == -1 )
{
level.wpToLink = level.waypointCount - 1;
}
level.waypointCount++;
self LinkWaypoint( level.waypointCount - 1 );
@@ -700,7 +774,9 @@ DeleteAllWaypoints()
buildChildCountString ( wp )
{
if ( wp == -1 )
{
return "";
}
wpstr = level.waypoints[wp].children.size + "";
@@ -710,16 +786,22 @@ buildChildCountString ( wp )
buildChildString( wp )
{
if ( wp == -1 )
{
return "";
}
wpstr = "";
for ( i = 0; i < level.waypoints[wp].children.size; i++ )
{
if ( i != 0 )
{
wpstr = wpstr + "," + level.waypoints[wp].children[i];
}
else
{
wpstr = wpstr + level.waypoints[wp].children[i];
}
}
return wpstr;
@@ -728,7 +810,9 @@ buildChildString( wp )
buildTypeString( wp )
{
if ( wp == -1 )
{
return "";
}
return level.waypoints[wp].type;
}