Compare commits

..

No commits in common. "cafee7d585160b046dc928f90798a611683e6cd1" and "3c1d16f4972f569a00df891e3fb8301bdbe66b39" have entirely different histories.

3 changed files with 134 additions and 286 deletions

1
.gitignore vendored
View File

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

View File

@ -14,7 +14,7 @@
*/ */
main() main()
{ {
level.bw_version = "1.2.0"; level.bw_version = "1.1.1";
if ( getdvar( "bots_main" ) == "" ) if ( getdvar( "bots_main" ) == "" )
{ {
@ -33,13 +33,6 @@ main()
// fix bot grenade launcher usage // fix bot grenade launcher usage
BotBuiltinReplaceFunc( BotBuiltinGetFunction( "maps/mp/bots/_bot_combat", "bot_should_hip_fire" ), ::bot_should_hip_fire_replaced ); 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 );
} }
/* /*
@ -164,246 +157,6 @@ init()
thread handleBots(); 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 Fixes gl usage
*/ */
@ -1071,8 +824,8 @@ onBotSpawned()
for ( ;; ) for ( ;; )
{ {
self waittill( "spawned_player" ); self waittill( "spawned_player" );
self BotBuiltinBotClearOverride( false ); self BotBuiltinClearOverrides( true );
self BotBuiltinBotWeaponOverride( self getcurrentweapon() ); self BotBuiltinWeaponOverride( self getcurrentweapon() );
self thread watch_for_override_stuff(); self thread watch_for_override_stuff();
self thread watch_for_melee_override(); self thread watch_for_melee_override();
@ -1195,9 +948,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 ) ) if ( self isonground() && self getstance() != "prone" && dist < getdvarfloat( "aim_automelee_range" ) && ( getConeDot( threat.origin, self.origin, self getplayerangles() ) > 0.9 || dist < 10 ) )
{ {
self BotBuiltinBotMeleeParamsOverride( threat getentitynumber(), dist ); self BotBuiltinBotMeleeParams( threat getentitynumber(), dist );
self BotBuiltinBotButtonOverride( "+melee" ); self BotBuiltinButtonOverride( "melee", "enable" );
self BotBuiltinBotAimOverride( true ); self BotBuiltinAimOverride();
time_left = 1; time_left = 1;
once = false; once = false;
@ -1211,17 +964,17 @@ watch_for_melee_override()
if ( !once ) if ( !once )
{ {
once = true; once = true;
self BotBuiltinBotButtonOverride( "~melee" ); self BotBuiltinClearButtonOverride( "melee" );
} }
} }
if ( !once ) if ( !once )
{ {
self BotBuiltinBotButtonOverride( "~melee" ); self BotBuiltinClearButtonOverride( "melee" );
} }
self BotBuiltinBotMeleeParamsOverride( false ); self BotBuiltinClearMeleeParams();
self BotBuiltinBotAimOverride( false ); self BotBuiltinClearAimOverride();
wait 1; wait 1;
break; break;
} }
@ -1294,13 +1047,13 @@ watch_for_override_stuff()
last_jump_time = time; last_jump_time = time;
// drop shot // drop shot
self BotBuiltinBotMovementOverride( 0, 0 ); self BotBuiltinMovementOverride( 0, 0 );
self BotBuiltinBotButtonOverride( "+prone" ); self BotBuiltinButtonOverride( "prone", "enable" );
wait 1.5; wait 1.5;
self BotBuiltinBotMovementOverride( false ); self BotBuiltinClearMovementOverride();
self BotBuiltinBotButtonOverride( "~prone" ); self BotBuiltinClearButtonOverride( "prone" );
} }
} }
else else
@ -1308,9 +1061,9 @@ watch_for_override_stuff()
last_jump_time = time; last_jump_time = time;
// jump shot // jump shot
self BotBuiltinBotButtonOverride( "+gostand" ); self BotBuiltinButtonOverride( "gostand", "enable" );
wait 0.1; wait 0.1;
self BotBuiltinBotButtonOverride( "~gostand" ); self BotBuiltinClearButtonOverride( "gostand" );
} }
} }
@ -1710,7 +1463,7 @@ BotBuiltinPrintConsole( s )
/* /*
*/ */
BotBuiltinBotMovementOverride( a, b ) BotBuiltinMovementOverride( a, b )
{ {
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botmovementoverride" ] ) ) if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botmovementoverride" ] ) )
{ {
@ -1720,27 +1473,57 @@ BotBuiltinBotMovementOverride( a, b )
/* /*
*/ */
BotBuiltinBotButtonOverride( a ) 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 )
{ {
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botbuttonoverride" ] ) ) if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botbuttonoverride" ] ) )
{ {
self [[ level.bot_builtins[ "botbuttonoverride" ] ]]( a ); self [[ level.bot_builtins[ "botbuttonoverride" ] ]]( a, b );
} }
} }
/* /*
*/ */
BotBuiltinBotClearOverride( a ) BotBuiltinClearOverrides( a )
{ {
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botclearoverride" ] ) ) if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botclearoverrides" ] ) )
{ {
self [[ level.bot_builtins[ "botclearoverride" ] ]]( a ); self [[ level.bot_builtins[ "botclearoverrides" ] ]]( a );
} }
} }
/* /*
*/ */
BotBuiltinBotWeaponOverride( a ) BotBuiltinClearWeaponOverride()
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botclearweaponoverride" ] ) )
{
self [[ level.bot_builtins[ "botclearweaponoverride" ] ]]();
}
}
/*
*/
BotBuiltinWeaponOverride( a )
{ {
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botweaponoverride" ] ) ) if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botweaponoverride" ] ) )
{ {
@ -1750,22 +1533,52 @@ BotBuiltinBotWeaponOverride( a )
/* /*
*/ */
BotBuiltinBotAimOverride( a ) BotBuiltinClearButtonOverrides()
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botclearbuttonoverrides" ] ) )
{
self [[ level.bot_builtins[ "botclearbuttonoverrides" ] ]]();
}
}
/*
*/
BotBuiltinAimOverride()
{ {
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botaimoverride" ] ) ) if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botaimoverride" ] ) )
{ {
self [[ level.bot_builtins[ "botaimoverride" ] ]]( a ); self [[ level.bot_builtins[ "botaimoverride" ] ]]();
}
}
/*
*/
BotBuiltinClearAimOverride()
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botclearaimoverride" ] ) )
{
self [[ level.bot_builtins[ "botclearaimoverride" ] ]]();
} }
} }
/* /*
Sets melee params Sets melee params
*/ */
BotBuiltinBotMeleeParamsOverride( entNum, dist ) BotBuiltinBotMeleeParams( entNum, dist )
{ {
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botmeleeparamsoverride" ] ) ) if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "botmeleeparams" ] ) )
{ {
self [[ level.bot_builtins[ "botmeleeparamsoverride" ] ]]( entNum, dist ); self [[ level.bot_builtins[ "botmeleeparams" ] ]]( entNum, dist );
}
}
/*
*/
BotBuiltinClearMeleeParams()
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "clearbotmeleeparams" ] ) )
{
self [[ level.bot_builtins[ "clearbotmeleeparams" ] ]]();
} }
} }

View File

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