This commit is contained in:
ineed bots 2024-01-04 16:05:38 -06:00
parent 8acd9a282e
commit 541b0832e3
10 changed files with 2808 additions and 2802 deletions

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

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]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

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,66 +38,66 @@ 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 );
} }
if ( getdvar( "bots_main_debug_commandWait" ) == "" ) if ( getdvar( "bots_main_debug_commandWait" ) == "" )
{ {
setdvar( "bots_main_debug_commandWait", 0.5 ); setdvar( "bots_main_debug_commandWait", 0.5 );
} }
if ( getdvar( "bots_main_debug_framerate" ) == "" ) if ( getdvar( "bots_main_debug_framerate" ) == "" )
{ {
setdvar( "bots_main_debug_framerate", 58 ); setdvar( "bots_main_debug_framerate", 58 );
} }
if ( getdvar( "bots_main_debug_lineDuration" ) == "" ) if ( getdvar( "bots_main_debug_lineDuration" ) == "" )
{ {
setdvar( "bots_main_debug_lineDuration", 3 ); setdvar( "bots_main_debug_lineDuration", 3 );
} }
if ( getdvar( "bots_main_debug_printDuration" ) == "" ) if ( getdvar( "bots_main_debug_printDuration" ) == "" )
{ {
setdvar( "bots_main_debug_printDuration", 3 ); setdvar( "bots_main_debug_printDuration", 3 );
} }
if ( getdvar( "bots_main_debug_debugRate" ) == "" ) if ( getdvar( "bots_main_debug_debugRate" ) == "" )
{ {
setdvar( "bots_main_debug_debugRate", 0.5 ); setdvar( "bots_main_debug_debugRate", 0.5 );
} }
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();
} }
onPlayerSpawned() onPlayerSpawned()
{ {
self endon( "disconnect" ); self endon( "disconnect" );
for ( ;; ) for ( ;; )
{ {
self waittill( "spawned_player" ); self waittill( "spawned_player" );
@ -109,12 +109,12 @@ beginDebug()
{ {
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.closest = -1; self.closest = -1;
self.command = undefined; self.command = undefined;
self clearperks(); self clearperks();
self takeallweapons(); self takeallweapons();
self.specialty = []; self.specialty = [];
@ -122,14 +122,14 @@ beginDebug()
self setactionslot( 3, "altMode" ); self setactionslot( 3, "altMode" );
self giveweapon( "frag_grenade_mp" ); self giveweapon( "frag_grenade_mp" );
self freezecontrols( false ); self freezecontrols( false );
self thread debug(); self thread debug();
self thread addWaypoints(); self thread addWaypoints();
self thread linkWaypoints(); self thread linkWaypoints();
self thread deleteWaypoints(); self thread deleteWaypoints();
self thread watchSaveWaypointsCommand(); self thread watchSaveWaypointsCommand();
self thread sayExtras(); self thread sayExtras();
self thread textScroll( "^1SecondaryOffhand - ^2Add Waypoint; ^3MeleeButton - ^4Link Waypoint; ^5FragButton - ^6delete Waypoint; ^7UseButton + AttackButton - ^8Save" ); self thread textScroll( "^1SecondaryOffhand - ^2Add Waypoint; ^3MeleeButton - ^4Link Waypoint; ^5FragButton - ^6delete Waypoint; ^7UseButton + AttackButton - ^8Save" );
} }
@ -145,56 +145,56 @@ debug()
{ {
self endon( "disconnect" ); self endon( "disconnect" );
self endon( "death" ); self endon( "death" );
self setclientdvar( "com_maxfps", getdvarint( "bots_main_debug_framerate" ) ); self setclientdvar( "com_maxfps", getdvarint( "bots_main_debug_framerate" ) );
for ( ;; ) for ( ;; )
{ {
wait getdvarfloat( "bots_main_debug_debugRate" ); wait getdvarfloat( "bots_main_debug_debugRate" );
if ( isdefined( self.command ) ) if ( isdefined( self.command ) )
{ {
continue; continue;
} }
closest = -1; closest = -1;
myEye = self gettagorigin( "j_head" ); myEye = self gettagorigin( "j_head" );
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 ), 1, 1, getdvarint( "bots_main_debug_lineDuration" ) ); line( wpOrg, level.waypoints[ level.waypoints[ i ].children[ h ] ].origin + ( 0, 0, 25 ), ( 1, 0, 1 ), 1, 1, getdvarint( "bots_main_debug_lineDuration" ) );
} }
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, 1, 6 ); print3d( wpOrg, i, ( 1, 0, 0 ), 2, 1, 6 );
} }
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 ), 1, 1, getdvarint( "bots_main_debug_lineDuration" ) ); line( wpOrg, wpOrg + anglestoforward( level.waypoints[ i ].angles ) * 64, ( 1, 1, 1 ), 1, 1, getdvarint( "bots_main_debug_lineDuration" ) );
} }
} }
} }
self.closest = closest; self.closest = closest;
if ( closest != -1 ) if ( closest != -1 )
{ {
stringChildren = ""; stringChildren = "";
for ( i = 0; i < level.waypoints[ closest ].children.size; i++ ) for ( i = 0; i < level.waypoints[ closest ].children.size; i++ )
{ {
if ( i != 0 ) if ( i != 0 )
@ -206,9 +206,9 @@ debug()
stringChildren = stringChildren + level.waypoints[ closest ].children[ i ]; stringChildren = stringChildren + level.waypoints[ closest ].children[ i ];
} }
} }
print3d( level.waypoints[ closest ].origin + ( 0, 0, 35 ), stringChildren, ( 0, 1, 0 ), 2, 1, getdvarint( "bots_main_debug_printDuration" ) ); print3d( level.waypoints[ closest ].origin + ( 0, 0, 35 ), stringChildren, ( 0, 1, 0 ), 2, 1, getdvarint( "bots_main_debug_printDuration" ) );
print3d( level.waypoints[ closest ].origin + ( 0, 0, 15 ), level.waypoints[ closest ].type, ( 0, 1, 0 ), 2, 1, getdvarint( "bots_main_debug_printDuration" ) ); print3d( level.waypoints[ closest ].origin + ( 0, 0, 15 ), level.waypoints[ closest ].type, ( 0, 1, 0 ), 2, 1, getdvarint( "bots_main_debug_printDuration" ) );
} }
} }
@ -218,28 +218,28 @@ addWaypoints()
{ {
self endon( "disconnect" ); self endon( "disconnect" );
self endon( "death" ); self endon( "death" );
for ( ;; ) for ( ;; )
{ {
while ( !self secondaryoffhandbuttonpressed() || isdefined( self.command ) ) while ( !self secondaryoffhandbuttonpressed() || isdefined( self.command ) )
{ {
wait 0.05; wait 0.05;
} }
pos = self getorigin(); pos = self getorigin();
self.command = true; self.command = true;
self iprintln( "Adding a waypoint..." ); self iprintln( "Adding a waypoint..." );
self iprintln( "ADS - climb; Attack + Use - tube" ); self iprintln( "ADS - climb; Attack + Use - tube" );
self iprintln( "Attack - grenade; Use - claymore" ); self iprintln( "Attack - grenade; Use - claymore" );
self iprintln( "Else(wait) - your stance" ); self iprintln( "Else(wait) - your stance" );
wait getdvarfloat( "bots_main_debug_commandWait" ); wait getdvarfloat( "bots_main_debug_commandWait" );
self addWaypoint( pos ); self addWaypoint( pos );
self.command = undefined; self.command = undefined;
while ( self secondaryoffhandbuttonpressed() ) while ( self secondaryoffhandbuttonpressed() )
{ {
wait 0.05; wait 0.05;
@ -251,20 +251,20 @@ linkWaypoints()
{ {
self endon( "disconnect" ); self endon( "disconnect" );
self endon( "death" ); self endon( "death" );
for ( ;; ) for ( ;; )
{ {
while ( !self meleebuttonpressed() || isdefined( self.command ) ) while ( !self meleebuttonpressed() || isdefined( self.command ) )
{ {
wait 0.05; wait 0.05;
} }
self.command = true; self.command = true;
self iprintln( "ADS - unlink; Else(wait) - Link" ); self iprintln( "ADS - unlink; Else(wait) - Link" );
wait getdvarfloat( "bots_main_debug_commandWait" ); wait getdvarfloat( "bots_main_debug_commandWait" );
if ( !self adsbuttonpressed() ) if ( !self adsbuttonpressed() )
{ {
self LinkWaypoint( self.closest ); self LinkWaypoint( self.closest );
@ -273,9 +273,9 @@ linkWaypoints()
{ {
self UnLinkWaypoint( self.closest ); self UnLinkWaypoint( self.closest );
} }
self.command = undefined; self.command = undefined;
while ( self meleebuttonpressed() ) while ( self meleebuttonpressed() )
{ {
wait 0.05; wait 0.05;
@ -287,21 +287,21 @@ deleteWaypoints()
{ {
self endon( "disconnect" ); self endon( "disconnect" );
self endon( "death" ); self endon( "death" );
for ( ;; ) for ( ;; )
{ {
while ( !self fragbuttonpressed() || isdefined( self.command ) ) while ( !self fragbuttonpressed() || isdefined( self.command ) )
{ {
wait 0.05; wait 0.05;
} }
self.command = true; self.command = true;
self iprintln( "Attack - deleteAll; ADS - Load" ); self iprintln( "Attack - deleteAll; ADS - Load" );
self iprintln( "Else(wait) - delete" ); self iprintln( "Else(wait) - delete" );
wait getdvarfloat( "bots_main_debug_commandWait" ); wait getdvarfloat( "bots_main_debug_commandWait" );
if ( self attackbuttonpressed() ) if ( self attackbuttonpressed() )
{ {
self deleteAllWaypoints(); self deleteAllWaypoints();
@ -314,9 +314,9 @@ deleteWaypoints()
{ {
self deleteWaypoint( self.closest ); self deleteWaypoint( self.closest );
} }
self.command = undefined; self.command = undefined;
while ( self fragbuttonpressed() ) while ( self fragbuttonpressed() )
{ {
wait 0.05; wait 0.05;
@ -328,81 +328,81 @@ watchSaveWaypointsCommand()
{ {
self endon( "death" ); self endon( "death" );
self endon( "disconnect" ); self endon( "disconnect" );
for ( ;; ) for ( ;; )
{ {
while ( !self usebuttonpressed() || !self attackbuttonpressed() || isdefined( self.command ) ) while ( !self usebuttonpressed() || !self attackbuttonpressed() || isdefined( self.command ) )
{ {
wait 0.05; wait 0.05;
} }
self.command = true; self.command = true;
self iprintln( "ADS - Autolink; Else(wait) - Save" ); self iprintln( "ADS - Autolink; Else(wait) - Save" );
wait getdvarfloat( "bots_main_debug_commandWait" ); wait getdvarfloat( "bots_main_debug_commandWait" );
if ( !self adsbuttonpressed() ) if ( !self adsbuttonpressed() )
{ {
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/*" );
} }
} }
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 );
f = BotBuiltinFileOpen( filename, "write" ); f = BotBuiltinFileOpen( filename, "write" );
if ( f > 0 ) if ( f > 0 )
{ {
BotBuiltinWriteLine( f, level.waypointcount ); BotBuiltinWriteLine( f, level.waypointcount );
} }
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 ] + ",";
@ -411,24 +411,24 @@ watchSaveWaypointsCommand()
{ {
str += ","; str += ",";
} }
str += ","; str += ",";
println( str ); println( str );
if ( f > 0 ) if ( f > 0 )
{ {
BotBuiltinWriteLine( f, str ); BotBuiltinWriteLine( f, str );
} }
} }
if ( f > 0 ) if ( f > 0 )
{ {
BotBuiltinFileClose( f ); BotBuiltinFileClose( f );
} }
println( "\n\n\n\n\n\n" ); println( "\n\n\n\n\n\n" );
self iprintln( "Saved!!! to " + filename ); self iprintln( "Saved!!! to " + filename );
} }
else else
@ -446,9 +446,9 @@ watchSaveWaypointsCommand()
level.wptolink = self.closest; level.wptolink = self.closest;
} }
} }
self.command = undefined; self.command = undefined;
while ( self usebuttonpressed() && self attackbuttonpressed() ) while ( self usebuttonpressed() && self attackbuttonpressed() )
{ {
wait 0.05; wait 0.05;
@ -461,9 +461,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();
} }
@ -473,12 +473,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 ] ) )
@ -486,7 +486,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 );
@ -502,7 +502,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" );
@ -514,13 +514,13 @@ 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 ( !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" );
@ -532,7 +532,7 @@ deleteAllWaypoints()
{ {
level.waypoints = []; level.waypoints = [];
level.waypointcount = 0; level.waypointcount = 0;
self iprintln( "DelAllWps" ); self iprintln( "DelAllWps" );
} }
@ -543,16 +543,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-- )
@ -563,7 +563,7 @@ deleteWaypoint( nwp )
} }
} }
} }
for ( entry = 0; entry < level.waypointcount; entry++ ) for ( entry = 0; entry < level.waypointcount; entry++ )
{ {
if ( entry == nwp ) if ( entry == nwp )
@ -573,23 +573,23 @@ 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( pos ) addWaypoint( pos )
{ {
level.waypoints[ level.waypointcount ] = spawnstruct(); level.waypoints[ level.waypointcount ] = spawnstruct();
level.waypoints[ level.waypointcount ].origin = pos; level.waypoints[ level.waypointcount ].origin = pos;
if ( self adsbuttonpressed() ) if ( self adsbuttonpressed() )
{ {
level.waypoints[ level.waypointcount ].type = "climb"; level.waypoints[ level.waypointcount ].type = "climb";
@ -610,20 +610,20 @@ addWaypoint( pos )
{ {
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 = [];
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 );
} }
@ -641,17 +641,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;
} }
@ -664,16 +664,16 @@ 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-- )
{ {
if ( level.waypoints[ level.wptolink ].children[ i ] == nwp ) if ( level.waypoints[ level.wptolink ].children[ i ] == nwp )
@ -682,7 +682,7 @@ LinkWaypoint( nwp )
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-- )
@ -694,17 +694,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;
} }
@ -721,15 +721,15 @@ textScroll( string )
self endon( "death" ); self endon( "death" );
self endon( "disconnect" ); self endon( "disconnect" );
// thanks ActionScript // thanks ActionScript
back = createbar( ( 0, 0, 0 ), 1000, 30 ); back = createbar( ( 0, 0, 0 ), 1000, 30 );
back setpoint( "CENTER", undefined, 0, 220 ); back setpoint( "CENTER", undefined, 0, 220 );
self thread destroyOnDeath( back ); self thread destroyOnDeath( back );
text = createfontstring( "default", 1.5 ); text = createfontstring( "default", 1.5 );
text settext( string ); text settext( string );
self thread destroyOnDeath( text ); self thread destroyOnDeath( text );
for ( ;; ) for ( ;; )
{ {
text setpoint( "CENTER", undefined, 1200, 220 ); text setpoint( "CENTER", undefined, 1200, 220 );

View File

@ -6,17 +6,17 @@
// Code Callback functions // Code Callback functions
/*================ /*================
Called by code after the level's main script function has run. Called by code after the level's main script function has run.
================*/ ================*/
CodeCallback_StartGameType() CodeCallback_StartGameType()
{ {
// If the gametype has not beed started, run the startup // If the gametype has not beed started, run the startup
if(!isDefined(level.gametypestarted) || !level.gametypestarted) if ( !isDefined( level.gametypestarted ) || !level.gametypestarted )
{ {
[[level.callbackStartGameType]](); [[level.callbackStartGameType]]();
level.gametypestarted = true; // so we know that the gametype has been started up level.gametypestarted = true; // so we know that the gametype has been started up
level thread scripts\bots_adapter_cod4x::init(); level thread scripts\bots_adapter_cod4x::init();
level thread scripts\bots_chat::init(); level thread scripts\bots_chat::init();
level thread scripts\bots_menu::init(); level thread scripts\bots_menu::init();
@ -26,89 +26,89 @@ CodeCallback_StartGameType()
} }
/*================ /*================
Called when a player begins connecting to the server. Called when a player begins connecting to the server.
Called again for every map change or tournement restart. Called again for every map change or tournement restart.
Return undefined if the client should be allowed, otherwise return Return undefined if the client should be allowed, otherwise return
a string with the reason for denial. a string with the reason for denial.
Otherwise, the client will be sent the current gamestate Otherwise, the client will be sent the current gamestate
and will eventually get to ClientBegin. and will eventually get to ClientBegin.
firstTime will be qtrue the very first time a client connects firstTime will be qtrue the very first time a client connects
to the server machine, but qfalse on map changes and tournement to the server machine, but qfalse on map changes and tournement
restarts. restarts.
================*/ ================*/
CodeCallback_PlayerConnect() CodeCallback_PlayerConnect()
{ {
self endon("disconnect"); self endon( "disconnect" );
[[level.callbackPlayerConnect]](); [[level.callbackPlayerConnect]]();
} }
/*================ /*================
Called when a player drops from the server. Called when a player drops from the server.
Will not be called between levels. Will not be called between levels.
self is the player that is disconnecting. self is the player that is disconnecting.
================*/ ================*/
CodeCallback_PlayerDisconnect() CodeCallback_PlayerDisconnect()
{ {
self notify("disconnect"); self notify( "disconnect" );
[[level.callbackPlayerDisconnect]](); [[level.callbackPlayerDisconnect]]();
} }
/*================ /*================
Called when a player has taken damage. Called when a player has taken damage.
self is the player that took damage. self is the player that took damage.
================*/ ================*/
CodeCallback_PlayerDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset) CodeCallback_PlayerDamage( eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset )
{ {
self endon("disconnect"); self endon( "disconnect" );
[[level.callbackPlayerDamage]](eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset); [[level.callbackPlayerDamage]]( eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset );
} }
/*================ /*================
Called when a player has been killed. Called when a player has been killed.
self is the player that was killed. self is the player that was killed.
================*/ ================*/
CodeCallback_PlayerKilled(eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration) CodeCallback_PlayerKilled( eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration )
{ {
self endon("disconnect"); self endon( "disconnect" );
[[level.callbackPlayerKilled]](eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration); [[level.callbackPlayerKilled]]( eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration );
} }
/*================ /*================
Called when a player has been killed, but has last stand perk. Called when a player has been killed, but has last stand perk.
self is the player that was killed. self is the player that was killed.
================*/ ================*/
CodeCallback_PlayerLastStand(eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration ) CodeCallback_PlayerLastStand( eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration )
{ {
self endon("disconnect"); self endon( "disconnect" );
[[level.callbackPlayerLastStand]](eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration ); [[level.callbackPlayerLastStand]]( eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration );
} }
//============================================================================= //=============================================================================
/*================ /*================
Setup any misc callbacks stuff like defines and default callbacks Setup any misc callbacks stuff like defines and default callbacks
================*/ ================*/
SetupCallbacks() SetupCallbacks()
{ {
SetDefaultCallbacks(); SetDefaultCallbacks();
// Set defined for damage flags used in the playerDamage callback // Set defined for damage flags used in the playerDamage callback
level.iDFLAGS_RADIUS = 1; level.iDFLAGS_RADIUS = 1;
level.iDFLAGS_NO_ARMOR = 2; level.iDFLAGS_NO_ARMOR = 2;
level.iDFLAGS_NO_KNOCKBACK = 4; level.iDFLAGS_NO_KNOCKBACK = 4;
level.iDFLAGS_PENETRATION = 8; level.iDFLAGS_PENETRATION = 8;
level.iDFLAGS_NO_TEAM_PROTECTION = 16; level.iDFLAGS_NO_TEAM_PROTECTION = 16;
level.iDFLAGS_NO_PROTECTION = 32; level.iDFLAGS_NO_PROTECTION = 32;
level.iDFLAGS_PASSTHRU = 64; level.iDFLAGS_PASSTHRU = 64;
} }
/*================ /*================
Called from the gametype script to store off the default callback functions. Called from the gametype script to store off the default callback functions.
This allows the callbacks to be overridden by level script, but not lost. This allows the callbacks to be overridden by level script, but not lost.
================*/ ================*/
SetDefaultCallbacks() SetDefaultCallbacks()
{ {
level.callbackStartGameType = maps\mp\gametypes\_globallogic::Callback_StartGameType; level.callbackStartGameType = maps\mp\gametypes\_globallogic::Callback_StartGameType;
@ -120,26 +120,26 @@ SetDefaultCallbacks()
} }
/*================ /*================
Called when a gametype is not supported. Called when a gametype is not supported.
================*/ ================*/
AbortLevel() AbortLevel()
{ {
println("Aborting level - gametype is not supported"); println( "Aborting level - gametype is not supported" );
level.callbackStartGameType = ::callbackVoid; level.callbackStartGameType = ::callbackVoid;
level.callbackPlayerConnect = ::callbackVoid; level.callbackPlayerConnect = ::callbackVoid;
level.callbackPlayerDisconnect = ::callbackVoid; level.callbackPlayerDisconnect = ::callbackVoid;
level.callbackPlayerDamage = ::callbackVoid; level.callbackPlayerDamage = ::callbackVoid;
level.callbackPlayerKilled = ::callbackVoid; level.callbackPlayerKilled = ::callbackVoid;
level.callbackPlayerLastStand = ::callbackVoid; level.callbackPlayerLastStand = ::callbackVoid;
setdvar("g_gametype", "dm"); setdvar( "g_gametype", "dm" );
exitLevel(false); exitLevel( false );
} }
/*================ /*================
================*/ ================*/
callbackVoid() callbackVoid()
{ {
} }