This commit is contained in:
ineed bots 2024-01-04 16:08:30 -06:00
parent 7105b397c3
commit ddc7e5fcc4
6 changed files with 1908 additions and 1903 deletions

View File

@ -1,21 +1,27 @@
# try to mimic the original gsc provided
# mode=ghc
mode=c
style=allman
indent=tab
indent=force-tab=2
lineend=windows
pad-oper
pad-paren-in
pad-header
# delete-empty-lines
# pad-brackets-in
fill-empty-lines
squeeze-lines=2
squeeze-ws
break-one-line-headers
add-braces
remove-comment-prefix
break-blocks
# remove-braces
indent-switches
indent-cases
indent-after-parens
indent-col1-comments
remove-comment-prefix

View File

@ -4,7 +4,7 @@ root = true
indent_style = tab
indent_size = 2
charset = latin1
trim_trailing_whitespace = true
trim_trailing_whitespace = false
insert_final_newline = true
[*.md]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@ wait_for_builtins()
{
return true;
}
if ( i < 18 )
{
waittillframeend;
@ -30,7 +30,7 @@ wait_for_builtins()
wait 0.05;
}
}
return false;
}
@ -197,19 +197,19 @@ getBotArray()
{
result = [];
playercount = level.players.size;
for ( i = 0; i < playercount; i++ )
{
player = level.players[ i ];
if ( !player is_bot() )
{
continue;
}
result[ result.size ] = player;
}
return result;
}
@ -231,7 +231,7 @@ getGoodMapAmount()
Round( x )
{
y = int( x );
if ( abs( x ) - abs( y ) > 0.5 )
{
if ( x < 0 )
@ -258,7 +258,7 @@ PickRandom( arr )
{
return undefined;
}
return arr[ randomint( arr.size ) ];
}
@ -332,27 +332,27 @@ allowTeamChoice()
GetBotDiffNum()
{
num = 0;
switch ( getdvar( "bot_difficulty" ) )
{
case "fu":
num = 3;
break;
case "hard":
num = 2;
break;
case "normal":
num = 1;
break;
case "easy":
default:
num = 0;
break;
}
return num;
}
@ -365,7 +365,7 @@ isWeaponAltmode( weap )
{
return true;
}
return false;
}
@ -380,57 +380,57 @@ bot_lookat( pos, time, vel, doAimPredict )
self endon( "death" );
self endon( "spawned_player" );
level endon ( "game_ended" );
if ( level.gameended || level.inprematchperiod || self BotIsFrozen() || !getdvarint( "bots_play_aim" ) )
{
return;
}
if ( !isdefined( pos ) )
{
return;
}
if ( !isdefined( doAimPredict ) )
{
doAimPredict = false;
}
if ( !isdefined( time ) )
{
time = 0.05;
}
if ( !isdefined( vel ) )
{
vel = ( 0, 0, 0 );
}
steps = int( time * 20 );
if ( steps < 1 )
{
steps = 1;
}
myEye = self geteye(); // get our eye pos
if ( doAimPredict )
{
myEye += ( self getvelocity() * 0.05 ) * ( steps - 1 ); // account for our velocity
pos += ( vel * 0.05 ) * ( steps - 1 ); // add the velocity vector
}
myAngle = self getplayerangles();
angles = vectortoangles( ( pos - myEye ) - anglestoforward( myAngle ) );
X = angleclamp180( angles[ 0 ] - myAngle[ 0 ] );
X = X / steps;
Y = angleclamp180( angles[ 1 ] - myAngle[ 1 ] );
Y = Y / steps;
for ( i = 0; i < steps; i++ )
{
myAngle = ( angleclamp180( myAngle[ 0 ] + X ), angleclamp180( myAngle[ 1 ] + Y ), 0 );
@ -445,12 +445,12 @@ bot_lookat( pos, time, vel, doAimPredict )
getweaponslistall()
{
weaps = self getweaponslist();
for ( i = 0; i < weaps.size; i++ )
{
weap = weaps[ i ];
toks = strtok( weap, "_" );
if ( issubstr( weap, "_gl_" ) )
{
weaps[ weaps.size ] = "gl_" + toks[ 0 ] + "_mp";
@ -464,7 +464,7 @@ getweaponslistall()
weaps[ weaps.size ] = "mk_" + toks[ 0 ] + "_mp";
}
}
return weaps;
}
@ -474,22 +474,22 @@ getweaponslistall()
getValidTube()
{
weaps = self getweaponslistall();
for ( i = 0; i < weaps.size; i++ )
{
weap = weaps[ i ];
if ( !self getammocount( weap ) )
{
continue;
}
if ( ( issubstr( weap, "gl_" ) && !issubstr( weap, "_gl_" ) ) || weap == "china_lake_mp" )
{
return weap;
}
}
return undefined;
}
@ -502,36 +502,36 @@ waittill_any_timeout( timeOut, string1, string2, string3, string4, string5 )
{
self endon( "death" );
}
ent = spawnstruct();
if ( isdefined( string1 ) )
{
self thread waittill_string( string1, ent );
}
if ( isdefined( string2 ) )
{
self thread waittill_string( string2, ent );
}
if ( isdefined( string3 ) )
{
self thread waittill_string( string3, ent );
}
if ( isdefined( string4 ) )
{
self thread waittill_string( string4, ent );
}
if ( isdefined( string5 ) )
{
self thread waittill_string( string5, ent );
}
ent thread _timeout( timeOut );
ent waittill( "returned", msg );
ent notify( "die" );
return msg;
@ -543,7 +543,7 @@ waittill_any_timeout( timeOut, string1, string2, string3, string4, string5 )
_timeout( delay )
{
self endon( "die" );
wait( delay );
self notify( "returned", "timeout" );
}
@ -554,27 +554,27 @@ _timeout( delay )
getBotToKick()
{
bots = getBotArray();
if ( !isdefined( bots ) || !isdefined( bots.size ) || bots.size <= 0 || !isdefined( bots[ 0 ] ) )
{
return undefined;
}
tokick = undefined;
axis = 0;
allies = 0;
team = getdvar( "bots_team" );
// count teams
for ( i = 0; i < bots.size; i++ )
{
bot = bots[ i ];
if ( !isdefined( bot ) || !isdefined( bot.team ) )
{
continue;
}
if ( bot.team == "allies" )
{
allies++;
@ -588,7 +588,7 @@ getBotToKick()
return bot;
}
}
// search for a bot on the other team
if ( team == "custom" || team == "axis" )
{
@ -598,7 +598,7 @@ getBotToKick()
{
// get the team with the most bots
team = "allies";
if ( axis > allies )
{
team = "axis";
@ -608,43 +608,43 @@ getBotToKick()
{
team = "axis";
}
// get the bot on this team with lowest skill
for ( i = 0; i < bots.size; i++ )
{
bot = bots[ i ];
if ( !isdefined( bot ) || !isdefined( bot.team ) )
{
continue;
}
if ( bot.team != team )
{
continue;
}
tokick = bot;
}
if ( isdefined( tokick ) )
{
return tokick;
}
// just kick lowest skill
for ( i = 0; i < bots.size; i++ )
{
bot = bots[ i ];
if ( !isdefined( bot ) || !isdefined( bot.team ) )
{
continue;
}
tokick = bot;
}
return tokick;
}
@ -654,51 +654,51 @@ getBotToKick()
bot_wait_for_host()
{
host = undefined;
while ( !isdefined( level ) || !isdefined( level.players ) )
{
wait 0.05;
}
for ( i = getdvarfloat( "bots_main_waitForHostTime" ); i > 0; i -= 0.05 )
{
host = gethostplayer();
if ( isdefined( host ) )
{
break;
}
wait 0.05;
}
if ( !isdefined( host ) )
{
return;
}
for ( i = getdvarfloat( "bots_main_waitForHostTime" ); i > 0; i -= 0.05 )
{
if ( isdefined( host.pers[ "team" ] ) )
{
break;
}
wait 0.05;
}
if ( !isdefined( host.pers[ "team" ] ) )
{
return;
}
for ( i = getdvarfloat( "bots_main_waitForHostTime" ); i > 0; i -= 0.05 )
{
if ( host.pers[ "team" ] == "allies" || host.pers[ "team" ] == "axis" )
{
break;
}
wait 0.05;
}
}
@ -770,17 +770,17 @@ botStopMove2( what )
self endon( "disconnect" );
self endon( "death" );
level endon( "game_ended" );
self notify( "botStopMove" );
self endon( "botStopMove" );
if ( !what )
{
return;
}
og = self.origin;
for ( ;; )
{
self setvelocity( ( 0, 0, 0 ) );
@ -803,122 +803,122 @@ BotNotifyBotEvent( msg, a, b, c, d, e, f, g )
keyCodeToString( a )
{
b = "";
switch ( a )
{
case 0:
b = "a";
break;
case 1:
b = "b";
break;
case 2:
b = "c";
break;
case 3:
b = "d";
break;
case 4:
b = "e";
break;
case 5:
b = "f";
break;
case 6:
b = "g";
break;
case 7:
b = "h";
break;
case 8:
b = "i";
break;
case 9:
b = "j";
break;
case 10:
b = "k";
break;
case 11:
b = "l";
break;
case 12:
b = "m";
break;
case 13:
b = "n";
break;
case 14:
b = "o";
break;
case 15:
b = "p";
break;
case 16:
b = "q";
break;
case 17:
b = "r";
break;
case 18:
b = "s";
break;
case 19:
b = "t";
break;
case 20:
b = "u";
break;
case 21:
b = "v";
break;
case 22:
b = "w";
break;
case 23:
b = "x";
break;
case 24:
b = "y";
break;
case 25:
b = "z";
break;
case 26:
b = ".";
break;
case 27:
b = " ";
break;
}
return b;
}
@ -950,7 +950,7 @@ bot_onUsePlantObjectFix( player )
{
level thread bot_bombPlanted( self, player );
player logstring( "bomb planted: " + self.label );
// disable all bomb zones except this one
for ( index = 0; index < level.bombzones.size; index++ )
{
@ -958,28 +958,28 @@ bot_onUsePlantObjectFix( player )
{
continue;
}
level.bombzones[ index ] maps\mp\gametypes\_gameobjects::disableobject();
}
thread playsoundonplayers( "mus_sd_planted" + "_" + level.teampostfix[ player.pers[ "team" ] ] );
// removed plant audio until finalization of assest TODO : new plant sounds when assests are online
// player playsound( "mpl_sd_bomb_plant" );
// removed plant audio until finalization of assest TODO : new plant sounds when assests are online
// player playsound( "mpl_sd_bomb_plant" );
player notify ( "bomb_planted" );
level thread maps\mp\_popups::displayteammessagetoall( &"MP_EXPLOSIVES_PLANTED_BY", player );
if ( isdefined( player.pers[ "plants" ] ) )
{
player.pers[ "plants" ]++;
player.plants = player.pers[ "plants" ];
}
player maps\mp\_medals::saboteur();
player maps\mp\gametypes\_persistence::stataddwithgametype( "PLANTS", 1 );
maps\mp\gametypes\_globallogic_audio::leaderdialog( "bomb_planted" );
maps\mp\gametypes\_globallogic_score::giveplayerscore( "plant", player );
// player thread [[ level.onxpevent ]]( "plant" );
}
@ -992,19 +992,19 @@ bot_bombPlanted( destroyedObj, player )
{
maps\mp\gametypes\_globallogic_utils::pausetimer();
level.bombplanted = true;
destroyedObj.visuals[ 0 ] thread maps\mp\gametypes\_globallogic_utils::playtickingsound( "mpl_sab_ui_suitcasebomb_timer" );
// Play suspense music
level thread maps\mp\gametypes\sd::bombplantedmusicdelay();
// thread maps\mp\gametypes\_globallogic_audio::actionmusicset();
level.tickingobject = destroyedObj.visuals[ 0 ];
level.timelimitoverride = true;
setgameendtime( int( gettime() + ( level.bombtimer * 1000 ) ) );
setmatchflag( "bomb_timer", 1 );
if ( !level.multibomb )
{
level.sdbomb maps\mp\gametypes\_gameobjects::allowcarry( "none" );
@ -1014,7 +1014,7 @@ bot_bombPlanted( destroyedObj, player )
}
else
{
for ( index = 0; index < level.players.size; index++ )
{
if ( isdefined( level.players[ index ].carryicon ) )
@ -1022,19 +1022,19 @@ bot_bombPlanted( destroyedObj, player )
level.players[ index ].carryicon destroyelem();
}
}
trace = bullettrace( player.origin + ( 0, 0, 20 ), player.origin - ( 0, 0, 2000 ), false, player );
tempAngle = randomfloat( 360 );
forward = ( cos( tempAngle ), sin( tempAngle ), 0 );
forward = vectornormalize( forward - vector_scale( trace[ "normal" ], vectordot( forward, trace[ "normal" ] ) ) );
dropAngles = vectortoangles( forward );
level.sdbombmodel = spawn( "script_model", trace[ "position" ] );
level.sdbombmodel.angles = dropAngles;
level.sdbombmodel setmodel( "prop_suitcase_bomb" );
}
destroyedObj maps\mp\gametypes\_gameobjects::allowuse( "none" );
destroyedObj maps\mp\gametypes\_gameobjects::setvisibleteam( "none" );
/*
@ -1044,7 +1044,7 @@ bot_bombPlanted( destroyedObj, player )
destroyedObj maps\mp\gametypes\_gameobjects::set3dicon( "enemy", undefined );
*/
label = destroyedObj maps\mp\gametypes\_gameobjects::getlabel();
// create a new object to defuse with.
trigger = destroyedObj.bombdefusetrig;
trigger.origin = level.sdbombmodel.origin;
@ -1064,28 +1064,27 @@ bot_bombPlanted( destroyedObj, player )
defuseObject.onenduse = maps\mp\gametypes\sd::onenduse;
defuseObject.onuse = maps\mp\gametypes\sd::onusedefuseobject;
defuseObject.useweapon = "briefcase_bomb_defuse_mp";
level.defuseobject = defuseObject; // every cod...
player.isbombcarrier = false;
maps\mp\gametypes\sd::bombtimerwait();
setmatchflag( "bomb_timer", 0 );
destroyedObj.visuals[ 0 ] maps\mp\gametypes\_globallogic_utils::stoptickingsound();
if ( level.gameended || level.bombdefused )
{
return;
}
level.bombexploded = true;
explosionOrigin = level.sdbombmodel.origin + ( 0, 0, 12 );
level.sdbombmodel hide();
if ( isdefined( player ) )
{
destroyedObj.visuals[ 0 ] radiusdamage( explosionOrigin, 512, 200, 20, player, "MOD_EXPLOSIVE", "briefcase_bomb_mp" );
@ -1097,29 +1096,29 @@ bot_bombPlanted( destroyedObj, player )
{
destroyedObj.visuals[ 0 ] radiusdamage( explosionOrigin, 512, 200, 20, undefined, "MOD_EXPLOSIVE", "briefcase_bomb_mp" );
}
rot = randomfloat( 360 );
explosionEffect = spawnfx( level._effect[ "bombexplosion" ], explosionOrigin + ( 0, 0, 50 ), ( 0, 0, 1 ), ( cos( rot ), sin( rot ), 0 ) );
triggerfx( explosionEffect );
thread playsoundinspace( "mpl_sd_exp_suitcase_bomb_main", explosionOrigin );
// thread maps\mp\gametypes\_globallogic_audio::set_music_on_team( "SILENT", "both" );
if ( isdefined( destroyedObj.exploderindex ) )
{
exploder( destroyedObj.exploderindex );
}
for ( index = 0; index < level.bombzones.size; index++ )
{
level.bombzones[ index ] maps\mp\gametypes\_gameobjects::disableobject();
}
defuseObject maps\mp\gametypes\_gameobjects::disableobject();
setgameendtime( 0 );
wait 3;
maps\mp\gametypes\sd::sd_endgame( game[ "attackers" ], game[ "strings" ][ "target_destroyed" ] );
}

File diff suppressed because it is too large Load Diff