This commit is contained in:
ineed bots
2024-01-04 16:07:04 -06:00
parent 929d19f3e6
commit 2ab4d43602
9 changed files with 3747 additions and 3741 deletions
+10 -4
View File
@@ -1,21 +1,27 @@
# try to mimic the original gsc provided # try to mimic the original gsc provided
# mode=ghc
mode=c mode=c
style=allman style=allman
indent=tab indent=force-tab=2
lineend=windows lineend=windows
pad-oper pad-oper
pad-paren-in pad-paren-in
pad-header pad-header
# pad-brackets-in
# delete-empty-lines fill-empty-lines
squeeze-lines=2
squeeze-ws
break-one-line-headers
add-braces
remove-comment-prefix
break-blocks break-blocks
# remove-braces
indent-switches indent-switches
indent-cases indent-cases
indent-after-parens indent-after-parens
indent-col1-comments
remove-comment-prefix remove-comment-prefix
+1 -1
View File
@@ -4,7 +4,7 @@ root = true
indent_style = tab indent_style = tab
indent_size = 2 indent_size = 2
charset = latin1 charset = latin1
trim_trailing_whitespace = true trim_trailing_whitespace = false
insert_final_newline = true insert_final_newline = true
[*.md] [*.md]
+189 -189
View File
File diff suppressed because it is too large Load Diff
+585 -585
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1618 -1618
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+225 -225
View File
File diff suppressed because it is too large Load Diff
+146 -146
View File
@@ -16,21 +16,21 @@ init()
{ {
setdvar( "bots_main_debug", 0 ); setdvar( "bots_main_debug", 0 );
} }
if ( !getdvarint( "bots_main_debug" ) ) if ( !getdvarint( "bots_main_debug" ) )
{ {
return; return;
} }
if ( !getdvarint( "developer" ) ) if ( !getdvarint( "developer" ) )
{ {
setdvar( "developer_script", 1 ); setdvar( "developer_script", 1 );
setdvar( "developer", 1 ); setdvar( "developer", 1 );
setdvar( "sv_mapRotation", "map " + getdvar( "mapname" ) ); setdvar( "sv_mapRotation", "map " + getdvar( "mapname" ) );
exitlevel( false ); exitlevel( false );
} }
setdvar( "bots_main", 0 ); setdvar( "bots_main", 0 );
setdvar( "bots_main_menu", 0 ); setdvar( "bots_main_menu", 0 );
setdvar( "bots_manage_fill_mode", 0 ); setdvar( "bots_manage_fill_mode", 0 );
@@ -38,32 +38,32 @@ init()
setdvar( "bots_manage_add", 0 ); setdvar( "bots_manage_add", 0 );
setdvar( "bots_manage_fill_kick", 1 ); setdvar( "bots_manage_fill_kick", 1 );
setdvar( "bots_manage_fill_spec", 1 ); setdvar( "bots_manage_fill_spec", 1 );
if ( getdvar( "bots_main_debug_distance" ) == "" ) if ( getdvar( "bots_main_debug_distance" ) == "" )
{ {
setdvar( "bots_main_debug_distance", 512.0 ); setdvar( "bots_main_debug_distance", 512.0 );
} }
if ( getdvar( "bots_main_debug_cone" ) == "" ) if ( getdvar( "bots_main_debug_cone" ) == "" )
{ {
setdvar( "bots_main_debug_cone", 0.65 ); setdvar( "bots_main_debug_cone", 0.65 );
} }
if ( getdvar( "bots_main_debug_minDist" ) == "" ) if ( getdvar( "bots_main_debug_minDist" ) == "" )
{ {
setdvar( "bots_main_debug_minDist", 32.0 ); setdvar( "bots_main_debug_minDist", 32.0 );
} }
if ( getdvar( "bots_main_debug_drawThrough" ) == "" ) if ( getdvar( "bots_main_debug_drawThrough" ) == "" )
{ {
setdvar( "bots_main_debug_drawThrough", false ); setdvar( "bots_main_debug_drawThrough", false );
} }
setdvar( "player_sustainAmmo", 1 ); setdvar( "player_sustainAmmo", 1 );
level.waypoints = []; level.waypoints = [];
level.waypointcount = 0; level.waypointcount = 0;
level waittill( "connected", player ); level waittill( "connected", player );
player thread onPlayerSpawned(); player thread onPlayerSpawned();
} }
@@ -71,7 +71,7 @@ init()
onPlayerSpawned() onPlayerSpawned()
{ {
self endon( "disconnect" ); self endon( "disconnect" );
for ( ;; ) for ( ;; )
{ {
self waittill( "spawned_player" ); self waittill( "spawned_player" );
@@ -83,11 +83,11 @@ startDev()
{ {
self endon( "disconnect" ); self endon( "disconnect" );
self endon( "death" ); self endon( "death" );
level.wptolink = -1; level.wptolink = -1;
level.autolink = false; level.autolink = false;
self.nearest = -1; self.nearest = -1;
self takeallweapons(); self takeallweapons();
self giveweapon( "m16_gl_mp" ); // to knife windows self giveweapon( "m16_gl_mp" ); // to knife windows
self giveweapon( "javelin_mp" ); // to mark jav spots self giveweapon( "javelin_mp" ); // to mark jav spots
@@ -100,7 +100,7 @@ startDev()
self maps\mp\perks\_perks::giveperk( "specialty_marathon" ); self maps\mp\perks\_perks::giveperk( "specialty_marathon" );
self maps\mp\perks\_perks::giveperk( "specialty_lightweight" ); self maps\mp\perks\_perks::giveperk( "specialty_lightweight" );
self freezecontrols( false ); self freezecontrols( false );
self thread watchAddWaypointCommand(); self thread watchAddWaypointCommand();
self thread watchDeleteAllWaypointsCommand(); self thread watchDeleteAllWaypointsCommand();
self thread watchDeleteWaypointCommand(); self thread watchDeleteWaypointCommand();
@@ -111,7 +111,7 @@ startDev()
self thread watchAutoLinkCommand(); self thread watchAutoLinkCommand();
self thread updateWaypointsStats(); self thread updateWaypointsStats();
self thread watchAstarCommand(); self thread watchAstarCommand();
self thread sayExtras(); self thread sayExtras();
} }
@@ -135,30 +135,30 @@ watchAstarCommand()
{ {
self endon( "disconnect" ); self endon( "disconnect" );
self endon( "death" ); self endon( "death" );
self notifyonplayercommand( "astar", "+gostand" ); self notifyonplayercommand( "astar", "+gostand" );
for ( ;; ) for ( ;; )
{ {
self waittill( "astar" ); self waittill( "astar" );
if ( 1 ) if ( 1 )
{ {
continue; continue;
} }
self iprintln( "Start AStar" ); self iprintln( "Start AStar" );
self.astar = undefined; self.astar = undefined;
astar = spawnstruct(); astar = spawnstruct();
astar.start = self.origin; astar.start = self.origin;
self waittill( "astar" ); self waittill( "astar" );
self iprintln( "End AStar" ); self iprintln( "End AStar" );
astar.goal = self.origin; astar.goal = self.origin;
astar.nodes = AStarSearch( astar.start, astar.goal, undefined, true ); astar.nodes = AStarSearch( astar.start, astar.goal, undefined, true );
self iprintln( "AStar size: " + astar.nodes.size ); self iprintln( "AStar size: " + astar.nodes.size );
self.astar = astar; self.astar = astar;
} }
} }
@@ -167,7 +167,7 @@ updateWaypointsStats()
{ {
self endon( "disconnect" ); self endon( "disconnect" );
self endon( "death" ); self endon( "death" );
self initHudElem( "TotalWps:", 102, 5 ); self initHudElem( "TotalWps:", 102, 5 );
totalWpsHud = self initHudElem( "", 180, 5 ); totalWpsHud = self initHudElem( "", 180, 5 );
self initHudElem( "NearestWP:", 102, 15 ); self initHudElem( "NearestWP:", 102, 15 );
@@ -178,93 +178,93 @@ updateWaypointsStats()
type = self initHudElem( "", 160, 35 ); type = self initHudElem( "", 160, 35 );
self initHudElem( "ToLink:", 102, 45 ); self initHudElem( "ToLink:", 102, 45 );
wpToLink = self initHudElem( "", 160, 45 ); wpToLink = self initHudElem( "", 160, 45 );
infotext = self initHudElem2(); infotext = self initHudElem2();
self initHudElem3(); self initHudElem3();
self initHudElem4(); self initHudElem4();
for ( time = 0;; time += 0.05 ) for ( time = 0;; time += 0.05 )
{ {
wait 0.05; wait 0.05;
totalWpsHud settext( level.waypointcount ); totalWpsHud settext( level.waypointcount );
closest = -1; closest = -1;
myEye = self geteye(); myEye = self geteye();
myAngles = self getplayerangles(); myAngles = self getplayerangles();
for ( i = 0; i < level.waypointcount; i++ ) for ( i = 0; i < level.waypointcount; i++ )
{ {
if ( closest == -1 || closer( self.origin, level.waypoints[ i ].origin, level.waypoints[ closest ].origin ) ) if ( closest == -1 || closer( self.origin, level.waypoints[ i ].origin, level.waypoints[ closest ].origin ) )
{ {
closest = i; closest = i;
} }
wpOrg = level.waypoints[ i ].origin + ( 0, 0, 25 ); 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" ) ) ) 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-- ) 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 ) ); 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" ) ) if ( getConeDot( wpOrg, myEye, myAngles ) > getdvarfloat( "bots_main_debug_cone" ) )
{ {
print3d( wpOrg, i, ( 1, 0, 0 ), 2 ); print3d( wpOrg, i, ( 1, 0, 0 ), 2 );
} }
if ( isdefined( level.waypoints[ i ].angles ) && level.waypoints[ i ].type != "stand" ) if ( isdefined( level.waypoints[ i ].angles ) && level.waypoints[ i ].type != "stand" )
{ {
line( wpOrg, wpOrg + anglestoforward( level.waypoints[ i ].angles ) * 64, ( 1, 1, 1 ) ); line( wpOrg, wpOrg + anglestoforward( level.waypoints[ i ].angles ) * 64, ( 1, 1, 1 ) );
} }
if ( isdefined( level.waypoints[ i ].jav_point ) ) if ( isdefined( level.waypoints[ i ].jav_point ) )
{ {
line( wpOrg, level.waypoints[ i ].jav_point, ( 0, 0, 0 ) ); line( wpOrg, level.waypoints[ i ].jav_point, ( 0, 0, 0 ) );
} }
} }
} }
self.nearest = closest; self.nearest = closest;
nearestWP settext( self.nearest ); nearestWP settext( self.nearest );
children settext( buildChildCountString( self.nearest ) ); children settext( buildChildCountString( self.nearest ) );
type settext( buildTypeString( self.nearest ) ); type settext( buildTypeString( self.nearest ) );
wpToLink settext( level.wptolink ); wpToLink settext( level.wptolink );
infotext.x = infotext.x - 2; infotext.x = infotext.x - 2;
if ( infotext.x <= -800 ) if ( infotext.x <= -800 )
{ {
infotext.x = 800; infotext.x = 800;
} }
if ( self usebuttonpressed() && time > 2 ) if ( self usebuttonpressed() && time > 2 )
{ {
time = 0; time = 0;
self iprintlnbold( self.nearest + " children: " + buildChildString( self.nearest ) ); self iprintlnbold( self.nearest + " children: " + buildChildString( self.nearest ) );
} }
if ( isdefined( self.astar ) ) if ( isdefined( self.astar ) )
{ {
print3d( self.astar.start + ( 0, 0, 35 ), "start", ( 0, 0, 1 ), 2 ); print3d( self.astar.start + ( 0, 0, 35 ), "start", ( 0, 0, 1 ), 2 );
print3d( self.astar.goal + ( 0, 0, 35 ), "goal", ( 0, 0, 1 ), 2 ); print3d( self.astar.goal + ( 0, 0, 35 ), "goal", ( 0, 0, 1 ), 2 );
prev = self.astar.start + ( 0, 0, 35 ); prev = self.astar.start + ( 0, 0, 35 );
for ( i = self.astar.nodes.size - 1; i >= 0; i-- ) for ( i = self.astar.nodes.size - 1; i >= 0; i-- )
{ {
node = self.astar.nodes[ i ]; node = self.astar.nodes[ i ];
line( prev, level.waypoints[ node ].origin + ( 0, 0, 35 ), ( 0, 1, 1 ) ); line( prev, level.waypoints[ node ].origin + ( 0, 0, 35 ), ( 0, 1, 1 ) );
prev = level.waypoints[ node ].origin + ( 0, 0, 35 ); prev = level.waypoints[ node ].origin + ( 0, 0, 35 );
} }
line( prev, self.astar.goal + ( 0, 0, 35 ), ( 0, 1, 1 ) ); line( prev, self.astar.goal + ( 0, 0, 35 ), ( 0, 1, 1 ) );
} }
} }
@@ -274,9 +274,9 @@ watchLoadWaypointsCommand()
{ {
self endon( "disconnect" ); self endon( "disconnect" );
self endon( "death" ); self endon( "death" );
self notifyonplayercommand( "[{+actionslot 2}]", "+actionslot 2" ); self notifyonplayercommand( "[{+actionslot 2}]", "+actionslot 2" );
for ( ;; ) for ( ;; )
{ {
self waittill( "[{+actionslot 2}]" ); self waittill( "[{+actionslot 2}]" );
@@ -288,9 +288,9 @@ watchAddWaypointCommand()
{ {
self endon( "disconnect" ); self endon( "disconnect" );
self endon( "death" ); self endon( "death" );
self notifyonplayercommand( "[{+smoke}]", "+smoke" ); self notifyonplayercommand( "[{+smoke}]", "+smoke" );
for ( ;; ) for ( ;; )
{ {
self waittill( "[{+smoke}]" ); self waittill( "[{+smoke}]" );
@@ -302,13 +302,13 @@ watchAutoLinkCommand()
{ {
self endon( "disconnect" ); self endon( "disconnect" );
self endon( "death" ); self endon( "death" );
self notifyonplayercommand( "[{+frag}]", "+frag" ); self notifyonplayercommand( "[{+frag}]", "+frag" );
for ( ;; ) for ( ;; )
{ {
self waittill( "[{+frag}]" ); self waittill( "[{+frag}]" );
if ( level.autolink ) if ( level.autolink )
{ {
self iprintlnbold( "Auto link disabled" ); self iprintlnbold( "Auto link disabled" );
@@ -328,9 +328,9 @@ watchLinkWaypointCommand()
{ {
self endon( "disconnect" ); self endon( "disconnect" );
self endon( "death" ); self endon( "death" );
self notifyonplayercommand( "[{+melee}]", "+melee" ); self notifyonplayercommand( "[{+melee}]", "+melee" );
for ( ;; ) for ( ;; )
{ {
self waittill( "[{+melee}]" ); self waittill( "[{+melee}]" );
@@ -342,9 +342,9 @@ watchunlinkWaypointCommand()
{ {
self endon( "disconnect" ); self endon( "disconnect" );
self endon( "death" ); self endon( "death" );
self notifyonplayercommand( "[{+reload}]", "+reload" ); self notifyonplayercommand( "[{+reload}]", "+reload" );
for ( ;; ) for ( ;; )
{ {
self waittill( "[{+reload}]" ); self waittill( "[{+reload}]" );
@@ -356,9 +356,9 @@ watchDeleteWaypointCommand()
{ {
self endon( "disconnect" ); self endon( "disconnect" );
self endon( "death" ); self endon( "death" );
self notifyonplayercommand( "[{+actionslot 3}]", "+actionslot 3" ); self notifyonplayercommand( "[{+actionslot 3}]", "+actionslot 3" );
for ( ;; ) for ( ;; )
{ {
self waittill( "[{+actionslot 3}]" ); self waittill( "[{+actionslot 3}]" );
@@ -370,9 +370,9 @@ watchDeleteAllWaypointsCommand()
{ {
self endon( "disconnect" ); self endon( "disconnect" );
self endon( "death" ); self endon( "death" );
self notifyonplayercommand( "[{+actionslot 4}]", "+actionslot 4" ); self notifyonplayercommand( "[{+actionslot 4}]", "+actionslot 4" );
for ( ;; ) for ( ;; )
{ {
self waittill( "[{+actionslot 4}]" ); self waittill( "[{+actionslot 4}]" );
@@ -384,72 +384,72 @@ watchSaveWaypointsCommand()
{ {
self endon( "death" ); self endon( "death" );
self endon( "disconnect" ); self endon( "disconnect" );
self notifyonplayercommand( "[{+actionslot 1}]", "+actionslot 1" ); self notifyonplayercommand( "[{+actionslot 1}]", "+actionslot 1" );
for ( ;; ) for ( ;; )
{ {
self waittill( "[{+actionslot 1}]" ); self waittill( "[{+actionslot 1}]" );
self checkForWarnings(); self checkForWarnings();
wait 1; wait 1;
logprint( "***********ABiliTy's WPDump**************\n\n" ); logprint( "***********ABiliTy's WPDump**************\n\n" );
logprint( "\n\n\n\n" ); logprint( "\n\n\n\n" );
mpnm = getMapName( getdvar( "mapname" ) ); mpnm = getMapName( getdvar( "mapname" ) );
logprint( "\n\n" + mpnm + "()\n{\n/*" ); logprint( "\n\n" + mpnm + "()\n{\n/*" );
logprint( "*/waypoints = [];\n/*" ); logprint( "*/waypoints = [];\n/*" );
for ( i = 0; i < level.waypointcount; i++ ) for ( i = 0; i < level.waypointcount; i++ )
{ {
logprint( "*/waypoints[ " + i + " ] = spawnstruct();\n/*" ); logprint( "*/waypoints[ " + i + " ] = spawnstruct();\n/*" );
logprint( "*/waypoints[ " + i + " ].origin = " + level.waypoints[ i ].origin + ";\n/*" ); logprint( "*/waypoints[ " + i + " ].origin = " + level.waypoints[ i ].origin + ";\n/*" );
logprint( "*/waypoints[ " + i + " ].type = \"" + level.waypoints[ i ].type + "\";\n/*" ); logprint( "*/waypoints[ " + i + " ].type = \"" + level.waypoints[ i ].type + "\";\n/*" );
for ( c = 0; c < level.waypoints[ i ].children.size; c++ ) for ( c = 0; c < level.waypoints[ i ].children.size; c++ )
{ {
logprint( "*/waypoints[ " + i + " ].children[ " + c + " ] = " + level.waypoints[ i ].children[ c ] + ";\n/*" ); logprint( "*/waypoints[ " + i + " ].children[ " + c + " ] = " + level.waypoints[ i ].children[ c ] + ";\n/*" );
} }
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" ) ) 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/*" ); logprint( "*/waypoints[ " + i + " ].angles = " + level.waypoints[ i ].angles + ";\n/*" );
} }
if ( isdefined( level.waypoints[ i ].jav_point ) && level.waypoints[ i ].type == "javelin" ) if ( isdefined( level.waypoints[ i ].jav_point ) && level.waypoints[ i ].type == "javelin" )
{ {
logprint( "*/waypoints[ " + i + " ].jav_point = " + level.waypoints[ i ].jav_point + ";\n/*" ); logprint( "*/waypoints[ " + i + " ].jav_point = " + level.waypoints[ i ].jav_point + ";\n/*" );
} }
} }
logprint( "*/return waypoints;\n}\n\n\n\n" ); logprint( "*/return waypoints;\n}\n\n\n\n" );
filename = "waypoints/" + getdvar( "mapname" ) + "_wp.csv"; filename = "waypoints/" + getdvar( "mapname" ) + "_wp.csv";
println( "********* Start Bot Warfare WPDump *********" ); println( "********* Start Bot Warfare WPDump *********" );
println( level.waypointcount ); println( level.waypointcount );
BotBuiltinFileWrite( filename, level.waypointcount + "\n", "write" ); BotBuiltinFileWrite( filename, level.waypointcount + "\n", "write" );
for ( i = 0; i < level.waypointcount; i++ ) for ( i = 0; i < level.waypointcount; i++ )
{ {
str = ""; str = "";
wp = level.waypoints[ i ]; wp = level.waypoints[ i ];
str += wp.origin[ 0 ] + " " + wp.origin[ 1 ] + " " + wp.origin[ 2 ] + ","; str += wp.origin[ 0 ] + " " + wp.origin[ 1 ] + " " + wp.origin[ 2 ] + ",";
for ( h = 0; h < wp.children.size; h++ ) for ( h = 0; h < wp.children.size; h++ )
{ {
str += wp.children[ h ]; str += wp.children[ h ];
if ( h < wp.children.size - 1 ) if ( h < wp.children.size - 1 )
{ {
str += " "; str += " ";
} }
} }
str += "," + wp.type + ","; str += "," + wp.type + ",";
if ( isdefined( wp.angles ) ) if ( isdefined( wp.angles ) )
{ {
str += wp.angles[ 0 ] + " " + wp.angles[ 1 ] + " " + wp.angles[ 2 ] + ","; str += wp.angles[ 0 ] + " " + wp.angles[ 1 ] + " " + wp.angles[ 2 ] + ",";
@@ -458,7 +458,7 @@ watchSaveWaypointsCommand()
{ {
str += ","; str += ",";
} }
if ( isdefined( wp.jav_point ) ) if ( isdefined( wp.jav_point ) )
{ {
str += wp.jav_point[ 0 ] + " " + wp.jav_point[ 1 ] + " " + wp.jav_point[ 2 ] + ","; str += wp.jav_point[ 0 ] + " " + wp.jav_point[ 1 ] + " " + wp.jav_point[ 2 ] + ",";
@@ -467,13 +467,13 @@ watchSaveWaypointsCommand()
{ {
str += ","; str += ",";
} }
println( str ); println( str );
BotBuiltinFileWrite( filename, str + "\n", "append" ); BotBuiltinFileWrite( filename, str + "\n", "append" );
} }
println( "\n\n\n\n\n\n" ); println( "\n\n\n\n\n\n" );
self iprintln( "Saved!!! to " + filename ); self iprintln( "Saved!!! to " + filename );
} }
} }
@@ -483,9 +483,9 @@ LoadWaypoints()
self DeleteAllWaypoints(); self DeleteAllWaypoints();
self iprintlnbold( "Loading WPS..." ); self iprintlnbold( "Loading WPS..." );
load_waypoints(); load_waypoints();
wait 1; wait 1;
self checkForWarnings(); self checkForWarnings();
} }
@@ -495,12 +495,12 @@ checkForWarnings()
{ {
self iprintln( "WARNING: waypointCount is " + level.waypointcount ); self iprintln( "WARNING: waypointCount is " + level.waypointcount );
} }
if ( level.waypointcount != level.waypoints.size ) if ( level.waypointcount != level.waypoints.size )
{ {
self iprintln( "WARNING: waypointCount is not " + level.waypoints.size ); self iprintln( "WARNING: waypointCount is not " + level.waypoints.size );
} }
for ( i = 0; i < level.waypointcount; i++ ) for ( i = 0; i < level.waypointcount; i++ )
{ {
if ( !isdefined( level.waypoints[ i ] ) ) if ( !isdefined( level.waypoints[ i ] ) )
@@ -508,7 +508,7 @@ checkForWarnings()
self iprintln( "WARNING: waypoint " + i + " is undefined" ); self iprintln( "WARNING: waypoint " + i + " is undefined" );
continue; continue;
} }
if ( level.waypoints[ i ].children.size <= 0 ) if ( level.waypoints[ i ].children.size <= 0 )
{ {
self iprintln( "WARNING: waypoint " + i + " childCount is " + level.waypoints[ i ].children.size ); self iprintln( "WARNING: waypoint " + i + " childCount is " + level.waypoints[ i ].children.size );
@@ -524,7 +524,7 @@ checkForWarnings()
for ( h = level.waypoints[ i ].children.size - 1; h >= 0; h-- ) for ( h = level.waypoints[ i ].children.size - 1; h >= 0; h-- )
{ {
child = level.waypoints[ i ].children[ h ]; child = level.waypoints[ i ].children[ h ];
if ( !isdefined( level.waypoints[ child ] ) ) if ( !isdefined( level.waypoints[ child ] ) )
{ {
self iprintln( "WARNING: waypoint " + i + " child " + child + " is undefined" ); self iprintln( "WARNING: waypoint " + i + " child " + child + " is undefined" );
@@ -536,43 +536,43 @@ checkForWarnings()
} }
} }
} }
if ( !isdefined( level.waypoints[ i ].type ) ) if ( !isdefined( level.waypoints[ i ].type ) )
{ {
self iprintln( "WARNING: waypoint " + i + " type is undefined" ); self iprintln( "WARNING: waypoint " + i + " type is undefined" );
continue; continue;
} }
if ( level.waypoints[ i ].type == "javelin" && !isdefined( level.waypoints[ i ].jav_point ) ) if ( level.waypoints[ i ].type == "javelin" && !isdefined( level.waypoints[ i ].jav_point ) )
{ {
self iprintln( "WARNING: waypoint " + i + " jav_point is undefined" ); 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" ) ) 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" ); self iprintln( "WARNING: waypoint " + i + " angles is undefined" );
} }
} }
// check reachability, assume bidirectional graph // check reachability, assume bidirectional graph
wpIdx = randomint( level.waypointcount ); wpIdx = randomint( level.waypointcount );
for ( i = 0; i < level.waypointcount; i++ ) for ( i = 0; i < level.waypointcount; i++ )
{ {
if ( i % 5 == 0 ) if ( i % 5 == 0 )
{ {
wait 0.05; wait 0.05;
} }
astar = AStarSearch( level.waypoints[ wpIdx ].origin, level.waypoints[ i ].origin, undefined, true ); astar = AStarSearch( level.waypoints[ wpIdx ].origin, level.waypoints[ i ].origin, undefined, true );
if ( astar.size <= 0 ) if ( astar.size <= 0 )
{ {
self iprintln( "WARNING: waypoint " + wpIdx + " has no path to waypoint " + i ); self iprintln( "WARNING: waypoint " + wpIdx + " has no path to waypoint " + i );
} }
} }
self iprintln( "Waypoint warnings check completed." ); self iprintln( "Waypoint warnings check completed." );
} }
@@ -584,17 +584,17 @@ UnLinkWaypoint( nwp )
level.wptolink = -1; level.wptolink = -1;
return; return;
} }
if ( level.wptolink == -1 || nwp == level.wptolink ) if ( level.wptolink == -1 || nwp == level.wptolink )
{ {
level.wptolink = nwp; level.wptolink = nwp;
self iprintln( "Waypoint unlink Started " + nwp ); self iprintln( "Waypoint unlink Started " + nwp );
return; return;
} }
level.waypoints[ nwp ].children = array_remove( level.waypoints[ nwp ].children, level.wptolink ); level.waypoints[ nwp ].children = array_remove( level.waypoints[ nwp ].children, level.wptolink );
level.waypoints[ level.wptolink ].children = array_remove( level.waypoints[ level.wptolink ].children, nwp ); level.waypoints[ level.wptolink ].children = array_remove( level.waypoints[ level.wptolink ].children, nwp );
self iprintln( "Waypoint " + nwp + " Broken to " + level.wptolink ); self iprintln( "Waypoint " + nwp + " Broken to " + level.wptolink );
level.wptolink = -1; level.wptolink = -1;
} }
@@ -607,33 +607,33 @@ LinkWaypoint( nwp )
level.wptolink = -1; level.wptolink = -1;
return; return;
} }
if ( level.wptolink == -1 || nwp == level.wptolink ) if ( level.wptolink == -1 || nwp == level.wptolink )
{ {
level.wptolink = nwp; level.wptolink = nwp;
self iprintln( "Waypoint Link Started " + nwp ); self iprintln( "Waypoint Link Started " + nwp );
return; return;
} }
weGood = true; weGood = true;
for ( i = level.waypoints[ level.wptolink ].children.size - 1; i >= 0; i-- ) for ( i = level.waypoints[ level.wptolink ].children.size - 1; i >= 0; i-- )
{ {
child = level.waypoints[ level.wptolink ].children[ i ]; child = level.waypoints[ level.wptolink ].children[ i ];
if ( child == nwp ) if ( child == nwp )
{ {
weGood = false; weGood = false;
break; break;
} }
} }
if ( weGood ) if ( weGood )
{ {
for ( i = level.waypoints[ nwp ].children.size - 1; i >= 0; i-- ) for ( i = level.waypoints[ nwp ].children.size - 1; i >= 0; i-- )
{ {
child = level.waypoints[ nwp ].children[ i ]; child = level.waypoints[ nwp ].children[ i ];
if ( child == level.wptolink ) if ( child == level.wptolink )
{ {
weGood = false; weGood = false;
@@ -641,17 +641,17 @@ LinkWaypoint( nwp )
} }
} }
} }
if ( !weGood ) if ( !weGood )
{ {
self iprintln( "Waypoint Link Cancelled " + nwp + " and " + level.wptolink + " already linked." ); self iprintln( "Waypoint Link Cancelled " + nwp + " and " + level.wptolink + " already linked." );
level.wptolink = -1; level.wptolink = -1;
return; return;
} }
level.waypoints[ level.wptolink ].children[ level.waypoints[ level.wptolink ].children.size ] = nwp; level.waypoints[ level.wptolink ].children[ level.waypoints[ level.wptolink ].children.size ] = nwp;
level.waypoints[ nwp ].children[ level.waypoints[ nwp ].children.size ] = level.wptolink; level.waypoints[ nwp ].children[ level.waypoints[ nwp ].children.size ] = level.wptolink;
self iprintln( "Waypoint " + nwp + " Linked to " + level.wptolink ); self iprintln( "Waypoint " + nwp + " Linked to " + level.wptolink );
level.wptolink = -1; level.wptolink = -1;
} }
@@ -663,16 +663,16 @@ DeleteWaypoint( nwp )
self iprintln( "No close enough waypoint to delete." ); self iprintln( "No close enough waypoint to delete." );
return; return;
} }
level.wptolink = -1; level.wptolink = -1;
for ( i = level.waypoints[ nwp ].children.size - 1; i >= 0; i-- ) for ( i = level.waypoints[ nwp ].children.size - 1; i >= 0; i-- )
{ {
child = level.waypoints[ nwp ].children[ i ]; child = level.waypoints[ nwp ].children[ i ];
level.waypoints[ child ].children = array_remove( level.waypoints[ child ].children, nwp ); level.waypoints[ child ].children = array_remove( level.waypoints[ child ].children, nwp );
} }
for ( i = 0; i < level.waypointcount; i++ ) for ( i = 0; i < level.waypointcount; i++ )
{ {
for ( h = level.waypoints[ i ].children.size - 1; h >= 0; h-- ) for ( h = level.waypoints[ i ].children.size - 1; h >= 0; h-- )
@@ -683,7 +683,7 @@ DeleteWaypoint( nwp )
} }
} }
} }
for ( entry = 0; entry < level.waypointcount; entry++ ) for ( entry = 0; entry < level.waypointcount; entry++ )
{ {
if ( entry == nwp ) if ( entry == nwp )
@@ -693,24 +693,24 @@ DeleteWaypoint( nwp )
level.waypoints[ entry ] = level.waypoints[ entry + 1 ]; level.waypoints[ entry ] = level.waypoints[ entry + 1 ];
entry++; entry++;
} }
level.waypoints[ entry ] = undefined; level.waypoints[ entry ] = undefined;
break; break;
} }
} }
level.waypointcount--; level.waypointcount--;
self iprintln( "DelWp " + nwp ); self iprintln( "DelWp " + nwp );
} }
AddWaypoint() AddWaypoint()
{ {
level.waypoints[ level.waypointcount ] = spawnstruct(); level.waypoints[ level.waypointcount ] = spawnstruct();
pos = self getorigin(); pos = self getorigin();
level.waypoints[ level.waypointcount ].origin = pos; level.waypoints[ level.waypointcount ].origin = pos;
if ( isdefined( self.javelintargetpoint ) ) if ( isdefined( self.javelintargetpoint ) )
{ {
level.waypoints[ level.waypointcount ].type = "javelin"; level.waypoints[ level.waypointcount ].type = "javelin";
@@ -735,25 +735,25 @@ AddWaypoint()
{ {
level.waypoints[ level.waypointcount ].type = self getstance(); level.waypoints[ level.waypointcount ].type = self getstance();
} }
level.waypoints[ level.waypointcount ].angles = self getplayerangles(); level.waypoints[ level.waypointcount ].angles = self getplayerangles();
level.waypoints[ level.waypointcount ].children = []; level.waypoints[ level.waypointcount ].children = [];
if ( level.waypoints[ level.waypointcount ].type == "javelin" ) if ( level.waypoints[ level.waypointcount ].type == "javelin" )
{ {
level.waypoints[ level.waypointcount ].jav_point = self.javelintargetpoint; level.waypoints[ level.waypointcount ].jav_point = self.javelintargetpoint;
} }
self iprintln( level.waypoints[ level.waypointcount ].type + " Waypoint " + level.waypointcount + " Added at " + pos ); self iprintln( level.waypoints[ level.waypointcount ].type + " Waypoint " + level.waypointcount + " Added at " + pos );
if ( level.autolink ) if ( level.autolink )
{ {
if ( level.wptolink == -1 ) if ( level.wptolink == -1 )
{ {
level.wptolink = level.waypointcount - 1; level.wptolink = level.waypointcount - 1;
} }
level.waypointcount++; level.waypointcount++;
self LinkWaypoint( level.waypointcount - 1 ); self LinkWaypoint( level.waypointcount - 1 );
} }
@@ -767,7 +767,7 @@ DeleteAllWaypoints()
{ {
level.waypoints = []; level.waypoints = [];
level.waypointcount = 0; level.waypointcount = 0;
self iprintln( "DelAllWps" ); self iprintln( "DelAllWps" );
} }
@@ -777,9 +777,9 @@ buildChildCountString ( wp )
{ {
return ""; return "";
} }
wpstr = level.waypoints[ wp ].children.size + ""; wpstr = level.waypoints[ wp ].children.size + "";
return wpstr; return wpstr;
} }
@@ -789,9 +789,9 @@ buildChildString( wp )
{ {
return ""; return "";
} }
wpstr = ""; wpstr = "";
for ( i = 0; i < level.waypoints[ wp ].children.size; i++ ) for ( i = 0; i < level.waypoints[ wp ].children.size; i++ )
{ {
if ( i != 0 ) if ( i != 0 )
@@ -803,7 +803,7 @@ buildChildString( wp )
wpstr = wpstr + level.waypoints[ wp ].children[ i ]; wpstr = wpstr + level.waypoints[ wp ].children[ i ];
} }
} }
return wpstr; return wpstr;
} }
@@ -813,7 +813,7 @@ buildTypeString( wp )
{ {
return ""; return "";
} }
return level.waypoints[ wp ].type; return level.waypoints[ wp ].type;
} }
@@ -829,9 +829,9 @@ initHudElem( txt, xl, yl )
hud = newclienthudelem( self ); hud = newclienthudelem( self );
hud settext( txt ); hud settext( txt );
hud.alignx = "left"; hud.alignx = "left";
hud.aligny = "top"; hud.aligny = "top";
hud.horzalign = "left"; hud.horzalign = "left";
hud.vertalign = "top"; hud.vertalign = "top";
hud.x = xl; hud.x = xl;
hud.y = yl; hud.y = yl;
hud.foreground = true; hud.foreground = true;
@@ -842,9 +842,9 @@ initHudElem( txt, xl, yl )
hud.glowcolor = ( 0, 0, 0 ); hud.glowcolor = ( 0, 0, 0 );
hud.glowalpha = 1; hud.glowalpha = 1;
hud.color = ( 1.0, 1.0, 1.0 ); hud.color = ( 1.0, 1.0, 1.0 );
self thread destroyOnDeath( hud ); self thread destroyOnDeath( hud );
return hud; return hud;
} }
@@ -866,9 +866,9 @@ initHudElem2()
infotext.glowcolor = ( 0, 0, 0 ); infotext.glowcolor = ( 0, 0, 0 );
infotext.glowalpha = 1; infotext.glowalpha = 1;
infotext.color = ( 1.0, 1.0, 1.0 ); infotext.color = ( 1.0, 1.0, 1.0 );
self thread destroyOnDeath( infotext ); self thread destroyOnDeath( infotext );
return infotext; return infotext;
} }
@@ -881,9 +881,9 @@ initHudElem3()
bar.vertalign = "bottom"; bar.vertalign = "bottom";
bar.y = 30; bar.y = 30;
bar.foreground = true; bar.foreground = true;
self thread destroyOnDeath( bar ); self thread destroyOnDeath( bar );
return bar; return bar;
} }
@@ -898,8 +898,8 @@ initHudElem4()
OptionsBG.vertalign = "top"; OptionsBG.vertalign = "top";
OptionsBG setshader( "black", 200, 60 ); OptionsBG setshader( "black", 200, 60 );
OptionsBG.alpha = 0.4; OptionsBG.alpha = 0.4;
self thread destroyOnDeath( OptionsBG ); self thread destroyOnDeath( OptionsBG );
return OptionsBG; return OptionsBG;
} }