Compare commits

...

5 Commits

Author SHA1 Message Date
ineed bots
cafee7d585 cleanup 2024-11-21 13:02:55 -06:00
ineed bots
42ce6638e7 fix root cause for many gsc leaks 2024-09-29 08:41:28 -06:00
ineed bots
3213c9a5ce just commit this 2024-09-22 18:02:05 -06:00
ineed bots
fab59a3fe8 fix 2024-07-25 16:42:40 -06:00
ineed bots
d507ee22bd update for latest pluto 2024-07-25 12:31:06 -06:00
3 changed files with 286 additions and 134 deletions

1
.gitignore vendored
View File

@ -8,3 +8,4 @@ mpStats
mpClassSets
*.exe
compiled/
console_mp.log*

View File

@ -14,7 +14,7 @@
*/
main()
{
level.bw_version = "1.1.1";
level.bw_version = "1.2.0";
if ( getdvar( "bots_main" ) == "" )
{
@ -33,6 +33,13 @@ main()
// fix bot grenade launcher usage
BotBuiltinReplaceFunc( BotBuiltinGetFunction( "maps/mp/bots/_bot_combat", "bot_should_hip_fire" ), ::bot_should_hip_fire_replaced );
// FIX LEAKw
BotBuiltinReplaceFunc( BotBuiltinGetFunction( "common_scripts/utility", "_timeout" ), ::_timeout_fix );
BotBuiltinReplaceFunc( BotBuiltinGetFunction( "common_scripts/utility", "waittill_multiple" ), ::waittill_multiple_fix );
BotBuiltinReplaceFunc( BotBuiltinGetFunction( "common_scripts/utility", "waittill_multiple_ents" ), ::waittill_multiple_ents_fix );
BotBuiltinReplaceFunc( BotBuiltinGetFunction( "common_scripts/utility", "waittill_any_return" ), ::waittill_any_return_fix );
BotBuiltinReplaceFunc( BotBuiltinGetFunction( "common_scripts/utility", "waittill_any_array_return" ), ::waittill_any_array_return_fix );
}
/*
@ -157,6 +164,246 @@ init()
thread handleBots();
}
/*
FIX THE UAV LEAK
*/
waittill_multiple_ents_fix_hack( ent )
{
self endon( "death" );
ent endon( "die" );
while ( ent.threads )
{
ent waittill( "returned" );
ent.threads--;
}
ent notify( "die" );
}
/*
FIX THE UAV LEAK
*/
waittill_multiple_ents_fix( ent1, string1, ent2, string2, ent3, string3, ent4, string4 )
{
self endon( "death" );
ent = spawnstruct();
ent.threads = 0;
if ( isdefined( ent1 ) )
{
assert( isdefined( string1 ) );
ent1 thread waittill_string( string1, ent );
ent.threads++;
}
if ( isdefined( ent2 ) )
{
assert( isdefined( string2 ) );
ent2 thread waittill_string( string2, ent );
ent.threads++;
}
if ( isdefined( ent3 ) )
{
assert( isdefined( string3 ) );
ent3 thread waittill_string( string3, ent );
ent.threads++;
}
if ( isdefined( ent4 ) )
{
assert( isdefined( string4 ) );
ent4 thread waittill_string( string4, ent );
ent.threads++;
}
self thread waittill_multiple_ents_fix_hack( ent );
ent waittill( "die" );
}
/*
FIX THE UAV LEAK
*/
waittill_multiple_fix_hack( ent )
{
self endon( "death" );
ent endon( "die" );
while ( ent.threads )
{
ent waittill( "returned" );
ent.threads--;
}
ent notify( "die" );
}
/*
FIX THE UAV LEAK
*/
waittill_multiple_fix( string1, string2, string3, string4, string5 )
{
self endon( "death" );
ent = spawnstruct();
ent.threads = 0;
if ( isdefined( string1 ) )
{
self thread waittill_string( string1, ent );
ent.threads++;
}
if ( isdefined( string2 ) )
{
self thread waittill_string( string2, ent );
ent.threads++;
}
if ( isdefined( string3 ) )
{
self thread waittill_string( string3, ent );
ent.threads++;
}
if ( isdefined( string4 ) )
{
self thread waittill_string( string4, ent );
ent.threads++;
}
if ( isdefined( string5 ) )
{
self thread waittill_string( string5, ent );
ent.threads++;
}
self thread waittill_multiple_fix_hack( ent );
ent waittill( "die" );
}
/*
FIX THE UAV LEAK
*/
waittill_any_return_fix_hack( ent, string1, string2, string3, string4, string5, string6, string7 )
{
if ( ( !isdefined( string1 ) || string1 != "death" ) && ( !isdefined( string2 ) || string2 != "death" ) && ( !isdefined( string3 ) || string3 != "death" ) && ( !isdefined( string4 ) || string4 != "death" ) && ( !isdefined( string5 ) || string5 != "death" ) && ( !isdefined( string6 ) || string6 != "death" ) && ( !isdefined( string7 ) || string7 != "death" ) )
{
self endon( "death" );
}
ent endon( "die" );
ent waittill( "returned", msg );
ent notify( "die", msg );
}
/*
FIX THE UAV LEAK
*/
waittill_any_return_fix( string1, string2, string3, string4, string5, string6, string7 )
{
if ( ( !isdefined( string1 ) || string1 != "death" ) && ( !isdefined( string2 ) || string2 != "death" ) && ( !isdefined( string3 ) || string3 != "death" ) && ( !isdefined( string4 ) || string4 != "death" ) && ( !isdefined( string5 ) || string5 != "death" ) && ( !isdefined( string6 ) || string6 != "death" ) && ( !isdefined( string7 ) || string7 != "death" ) )
{
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 );
}
if ( isdefined( string6 ) )
{
self thread waittill_string( string6, ent );
}
if ( isdefined( string7 ) )
{
self thread waittill_string( string7, ent );
}
self thread waittill_any_return_fix_hack( ent, string1, string2, string3, string4, string5, string6, string7 );
ent waittill( "die", msg );
return msg;
}
/*
FIX THE UAV LEAK
*/
_timeout_fix( delay )
{
self endon( "die" );
wait( delay );
self notify( "returned", "timeout" );
self notify( "die" );
}
/*
FIX THE UAV LEAK
*/
waittill_any_array_return_fix_hack( s_tracker, a_notifies )
{
if ( isinarray( a_notifies, "death" ) )
{
self endon( "death" );
}
s_tracker endon( "die" );
s_tracker waittill( "returned", msg );
s_tracker notify( "die", msg );
}
/*
FIX THE UAV LEAK
*/
waittill_any_array_return_fix( a_notifies )
{
if ( isinarray( a_notifies, "death" ) )
{
self endon( "death" );
}
s_tracker = spawnstruct();
foreach ( str_notify in a_notifies )
{
if ( isdefined( str_notify ) )
{
self thread waittill_string( str_notify, s_tracker );
}
}
self thread waittill_any_array_return_fix_hack( s_tracker, a_notifies );
s_tracker waittill( "die", msg );
return msg;
}
/*
Fixes gl usage
*/
@ -824,8 +1071,8 @@ onBotSpawned()
for ( ;; )
{
self waittill( "spawned_player" );
self BotBuiltinClearOverrides( true );
self BotBuiltinWeaponOverride( self getcurrentweapon() );
self BotBuiltinBotClearOverride( false );
self BotBuiltinBotWeaponOverride( self getcurrentweapon() );
self thread watch_for_override_stuff();
self thread watch_for_melee_override();
@ -948,9 +1195,9 @@ watch_for_melee_override()
if ( self isonground() && self getstance() != "prone" && dist < getdvarfloat( "aim_automelee_range" ) && ( getConeDot( threat.origin, self.origin, self getplayerangles() ) > 0.9 || dist < 10 ) )
{
self BotBuiltinBotMeleeParams( threat getentitynumber(), dist );
self BotBuiltinButtonOverride( "melee", "enable" );
self BotBuiltinAimOverride();
self BotBuiltinBotMeleeParamsOverride( threat getentitynumber(), dist );
self BotBuiltinBotButtonOverride( "+melee" );
self BotBuiltinBotAimOverride( true );
time_left = 1;
once = false;
@ -964,17 +1211,17 @@ watch_for_melee_override()
if ( !once )
{
once = true;
self BotBuiltinClearButtonOverride( "melee" );
self BotBuiltinBotButtonOverride( "~melee" );
}
}
if ( !once )
{
self BotBuiltinClearButtonOverride( "melee" );
self BotBuiltinBotButtonOverride( "~melee" );
}
self BotBuiltinClearMeleeParams();
self BotBuiltinClearAimOverride();
self BotBuiltinBotMeleeParamsOverride( false );
self BotBuiltinBotAimOverride( false );
wait 1;
break;
}
@ -1047,13 +1294,13 @@ watch_for_override_stuff()
last_jump_time = time;
// drop shot
self BotBuiltinMovementOverride( 0, 0 );
self BotBuiltinButtonOverride( "prone", "enable" );
self BotBuiltinBotMovementOverride( 0, 0 );
self BotBuiltinBotButtonOverride( "+prone" );
wait 1.5;
self BotBuiltinClearMovementOverride();
self BotBuiltinClearButtonOverride( "prone" );
self BotBuiltinBotMovementOverride( false );
self BotBuiltinBotButtonOverride( "~prone" );
}
}
else
@ -1061,9 +1308,9 @@ watch_for_override_stuff()
last_jump_time = time;
// jump shot
self BotBuiltinButtonOverride( "gostand", "enable" );
self BotBuiltinBotButtonOverride( "+gostand" );
wait 0.1;
self BotBuiltinClearButtonOverride( "gostand" );
self BotBuiltinBotButtonOverride( "~gostand" );
}
}
@ -1463,7 +1710,7 @@ BotBuiltinPrintConsole( s )
/*
*/
BotBuiltinMovementOverride( a, b )
BotBuiltinBotMovementOverride( a, b )
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botmovementoverride" ] ) )
{
@ -1473,57 +1720,27 @@ BotBuiltinMovementOverride( a, b )
/*
*/
BotBuiltinClearMovementOverride()
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botclearmovementoverride" ] ) )
{
self [[ level.bot_builtins[ "botclearmovementoverride" ] ]]();
}
}
/*
*/
BotBuiltinClearButtonOverride( a )
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botclearbuttonoverride" ] ) )
{
self [[ level.bot_builtins[ "botclearbuttonoverride" ] ]]( a );
}
}
/*
*/
BotBuiltinButtonOverride( a, b )
BotBuiltinBotButtonOverride( a )
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botbuttonoverride" ] ) )
{
self [[ level.bot_builtins[ "botbuttonoverride" ] ]]( a, b );
self [[ level.bot_builtins[ "botbuttonoverride" ] ]]( a );
}
}
/*
*/
BotBuiltinClearOverrides( a )
BotBuiltinBotClearOverride( a )
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botclearoverrides" ] ) )
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botclearoverride" ] ) )
{
self [[ level.bot_builtins[ "botclearoverrides" ] ]]( a );
self [[ level.bot_builtins[ "botclearoverride" ] ]]( a );
}
}
/*
*/
BotBuiltinClearWeaponOverride()
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botclearweaponoverride" ] ) )
{
self [[ level.bot_builtins[ "botclearweaponoverride" ] ]]();
}
}
/*
*/
BotBuiltinWeaponOverride( a )
BotBuiltinBotWeaponOverride( a )
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botweaponoverride" ] ) )
{
@ -1533,52 +1750,22 @@ BotBuiltinWeaponOverride( a )
/*
*/
BotBuiltinClearButtonOverrides()
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botclearbuttonoverrides" ] ) )
{
self [[ level.bot_builtins[ "botclearbuttonoverrides" ] ]]();
}
}
/*
*/
BotBuiltinAimOverride()
BotBuiltinBotAimOverride( a )
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botaimoverride" ] ) )
{
self [[ level.bot_builtins[ "botaimoverride" ] ]]();
}
}
/*
*/
BotBuiltinClearAimOverride()
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botclearaimoverride" ] ) )
{
self [[ level.bot_builtins[ "botclearaimoverride" ] ]]();
self [[ level.bot_builtins[ "botaimoverride" ] ]]( a );
}
}
/*
Sets melee params
*/
BotBuiltinBotMeleeParams( entNum, dist )
BotBuiltinBotMeleeParamsOverride( entNum, dist )
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botmeleeparams" ] ) )
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botmeleeparamsoverride" ] ) )
{
self [[ level.bot_builtins[ "botmeleeparams" ] ]]( entNum, dist );
}
}
/*
*/
BotBuiltinClearMeleeParams()
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "clearbotmeleeparams" ] ) )
{
self [[ level.bot_builtins[ "clearbotmeleeparams" ] ]]();
self [[ level.bot_builtins[ "botmeleeparamsoverride" ] ]]( entNum, dist );
}
}

View File

@ -2,17 +2,11 @@ main()
{
level.bot_builtins[ "printconsole" ] = ::do_printconsole;
level.bot_builtins[ "botmovementoverride" ] = ::do_botmovementoverride;
level.bot_builtins[ "botclearmovementoverride" ] = ::do_botclearmovementoverride;
level.bot_builtins[ "botclearbuttonoverride" ] = ::do_botclearbuttonoverride;
level.bot_builtins[ "botbuttonoverride" ] = ::do_botbuttonoverride;
level.bot_builtins[ "botclearoverrides" ] = ::do_botclearoverrides;
level.bot_builtins[ "botclearweaponoverride" ] = ::do_botclearweaponoverride;
level.bot_builtins[ "botclearoverride" ] = ::do_botclearoverride;
level.bot_builtins[ "botweaponoverride" ] = ::do_botweaponoverride;
level.bot_builtins[ "botclearbuttonoverrides" ] = ::do_botclearbuttonoverrides;
level.bot_builtins[ "botaimoverride" ] = ::do_botaimoverride;
level.bot_builtins[ "botclearaimoverride" ] = ::do_botclearaimoverride;
level.bot_builtins[ "botmeleeparams" ] = ::do_botmeleeparams;
level.bot_builtins[ "clearbotmeleeparams" ] = ::do_clearbotmeleeparams;
level.bot_builtins[ "botmeleeparamsoverride" ] = ::do_botmeleeparamsoverride;
level.bot_builtins[ "getfunction" ] = ::do_getfunction;
level.bot_builtins[ "replacefunc" ] = ::do_replacefunc;
level.bot_builtins[ "disabledetouronce" ] = ::do_disabledetouronce;
@ -28,29 +22,14 @@ do_botmovementoverride( a, b )
self botmovementoverride( a, b );
}
do_botclearmovementoverride()
do_botbuttonoverride( a )
{
self botclearmovementoverride();
self botbuttonoverride( a );
}
do_botclearbuttonoverride( a )
do_botclearoverride( a )
{
self botclearbuttonoverride( a );
}
do_botbuttonoverride( a, b )
{
self botbuttonoverride( a, b );
}
do_botclearoverrides( a )
{
self botclearoverrides( a );
}
do_botclearweaponoverride()
{
self botclearweaponoverride();
self botclearoverride( a );
}
do_botweaponoverride( a )
@ -58,19 +37,14 @@ do_botweaponoverride( a )
self botweaponoverride( a );
}
do_botclearbuttonoverrides()
do_botaimoverride( a )
{
self botclearbuttonoverrides();
self botaimoverride( a );
}
do_botaimoverride()
do_botmeleeparamsoverride( entNum, dist )
{
self botaimoverride();
}
do_botclearaimoverride()
{
self botclearaimoverride();
self botmeleeparamsoverride( entNum, dist );
}
do_getfunction( a, b )
@ -87,13 +61,3 @@ do_disabledetouronce( a )
{
disabledetouronce( a );
}
do_botmeleeparams( entNum, dist )
{
self botmeleeparams( entNum, dist );
}
do_clearbotmeleeparams()
{
self botclearmeleeparams();
}