mirror of
https://github.com/ineedbots/iw4_bot_warfare.git
synced 2025-04-22 22:05:44 +00:00
cleanup
This commit is contained in:
parent
af4d44c3a4
commit
13a6417a9d
@ -3,17 +3,6 @@
|
||||
Author: INeedGames
|
||||
Date: 09/26/2020
|
||||
The entry point and manager of the bots.
|
||||
|
||||
Non-canon bootstrapped from <searchpath>/scripts/*.gsc::init
|
||||
Non-canon bot behavior; controlled through gsc built-ins
|
||||
Non-canon built-ins:
|
||||
PrintConsole(<string>)
|
||||
FS_FileTest(<file name>) -> bool, base path is <searchpath>/scriptdata
|
||||
FS_FileRead(<file name>) -> string, base path is <searchpath>/scriptdata
|
||||
FS_FileWrite(<file name>, <contents>, <mode ("append", "write")>), base path is <searchpath>/scriptdata
|
||||
<client> botStop()
|
||||
<client> botAction(<action string (+ or - then action like frag or smoke)>)
|
||||
<client> botMovement(<int left>, <int forward>)
|
||||
*/
|
||||
|
||||
#include common_scripts\utility;
|
||||
@ -555,7 +544,7 @@ watchBotDebugEvent()
|
||||
|
||||
if ( msg == "debug" && GetDvarInt( "bots_main_debug" ) )
|
||||
{
|
||||
PrintConsole( "Bot Warfare debug: " + self.name + ": " + str );
|
||||
BotBuiltinPrintConsole( "Bot Warfare debug: " + self.name + ": " + str + "\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ resetBotVars()
|
||||
|
||||
self.bot.rand = randomInt( 100 );
|
||||
|
||||
self botStop();
|
||||
self BotBuiltinBotStop();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -360,7 +360,7 @@ watchUsingMinigun()
|
||||
{
|
||||
if ( self getCurrentWeapon() != "heli_remote_mp" )
|
||||
{
|
||||
self changeToWeap( "heli_remote_mp" );
|
||||
self switchToWeapon( "heli_remote_mp" );
|
||||
}
|
||||
|
||||
if ( isDefined( self.bot.target ) )
|
||||
@ -384,7 +384,7 @@ watchAc130Weapon()
|
||||
curWeap = self GetCurrentWeapon();
|
||||
|
||||
if ( curWeap != "ac130_105mm_mp" && curWeap != "ac130_40mm_mp" && curWeap != "ac130_25mm_mp" )
|
||||
self changeToWeap( "ac130_105mm_mp" );
|
||||
self switchToWeapon( "ac130_105mm_mp" );
|
||||
|
||||
if ( isDefined( self.bot.target ) )
|
||||
self thread pressFire();
|
||||
@ -402,11 +402,11 @@ watchUsingAc130()
|
||||
|
||||
while ( isDefined( level.ac130Player ) && level.ac130player == self )
|
||||
{
|
||||
self changeToWeap( "ac130_105mm_mp" );
|
||||
self switchToWeapon( "ac130_105mm_mp" );
|
||||
wait 1 + randomInt( 2 );
|
||||
self changeToWeap( "ac130_40mm_mp" );
|
||||
self switchToWeapon( "ac130_40mm_mp" );
|
||||
wait 2 + randomInt( 2 );
|
||||
self changeToWeap( "ac130_25mm_mp" );
|
||||
self switchToWeapon( "ac130_25mm_mp" );
|
||||
wait 3 + randomInt( 2 );
|
||||
}
|
||||
}
|
||||
@ -603,7 +603,7 @@ doBotMovement_loop( data )
|
||||
if ( self.bot.wantsprint && self.bot.issprinting )
|
||||
dir = ( 127, dir[1], 0 );
|
||||
|
||||
self botMovement( int( dir[0] ), int( dir[1] ) );
|
||||
self BotBuiltinBotMovement( int( dir[0] ), int( dir[1] ) );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2268,9 +2268,9 @@ getRandomLargestStafe( dist )
|
||||
holdbreath( what )
|
||||
{
|
||||
if ( what )
|
||||
self botAction( "+holdbreath" );
|
||||
self BotBuiltinBotAction( "+holdbreath" );
|
||||
else
|
||||
self botAction( "-holdbreath" );
|
||||
self BotBuiltinBotAction( "-holdbreath" );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2283,9 +2283,9 @@ sprint()
|
||||
self notify( "bot_sprint" );
|
||||
self endon( "bot_sprint" );
|
||||
|
||||
self botAction( "+sprint" );
|
||||
self BotBuiltinBotAction( "+sprint" );
|
||||
wait 0.05;
|
||||
self botAction( "-sprint" );
|
||||
self BotBuiltinBotAction( "-sprint" );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2301,9 +2301,9 @@ knife()
|
||||
self.bot.isknifing = true;
|
||||
self.bot.isknifingafter = true;
|
||||
|
||||
self botAction( "+melee" );
|
||||
self BotBuiltinBotAction( "+melee" );
|
||||
wait 0.05;
|
||||
self botAction( "-melee" );
|
||||
self BotBuiltinBotAction( "-melee" );
|
||||
|
||||
self.bot.isknifing = false;
|
||||
|
||||
@ -2322,9 +2322,9 @@ reload()
|
||||
self notify( "bot_reload" );
|
||||
self endon( "bot_reload" );
|
||||
|
||||
self botAction( "+reload" );
|
||||
self BotBuiltinBotAction( "+reload" );
|
||||
wait 0.05;
|
||||
self botAction( "-reload" );
|
||||
self BotBuiltinBotAction( "-reload" );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2340,14 +2340,14 @@ frag( time )
|
||||
if ( !isDefined( time ) )
|
||||
time = 0.05;
|
||||
|
||||
self botAction( "+frag" );
|
||||
self BotBuiltinBotAction( "+frag" );
|
||||
self.bot.isfragging = true;
|
||||
self.bot.isfraggingafter = true;
|
||||
|
||||
if ( time )
|
||||
wait time;
|
||||
|
||||
self botAction( "-frag" );
|
||||
self BotBuiltinBotAction( "-frag" );
|
||||
self.bot.isfragging = false;
|
||||
|
||||
wait 1.25;
|
||||
@ -2367,14 +2367,14 @@ smoke( time )
|
||||
if ( !isDefined( time ) )
|
||||
time = 0.05;
|
||||
|
||||
self botAction( "+smoke" );
|
||||
self BotBuiltinBotAction( "+smoke" );
|
||||
self.bot.issmoking = true;
|
||||
self.bot.issmokingafter = true;
|
||||
|
||||
if ( time )
|
||||
wait time;
|
||||
|
||||
self botAction( "-smoke" );
|
||||
self BotBuiltinBotAction( "-smoke" );
|
||||
self.bot.issmoking = false;
|
||||
|
||||
wait 1.25;
|
||||
@ -2394,12 +2394,12 @@ use( time )
|
||||
if ( !isDefined( time ) )
|
||||
time = 0.05;
|
||||
|
||||
self botAction( "+activate" );
|
||||
self BotBuiltinBotAction( "+activate" );
|
||||
|
||||
if ( time )
|
||||
wait time;
|
||||
|
||||
self botAction( "-activate" );
|
||||
self BotBuiltinBotAction( "-activate" );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2410,9 +2410,9 @@ fire( what )
|
||||
self notify( "bot_fire" );
|
||||
|
||||
if ( what )
|
||||
self botAction( "+fire" );
|
||||
self BotBuiltinBotAction( "+fire" );
|
||||
else
|
||||
self botAction( "-fire" );
|
||||
self BotBuiltinBotAction( "-fire" );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2428,12 +2428,12 @@ pressFire( time )
|
||||
if ( !isDefined( time ) )
|
||||
time = 0.05;
|
||||
|
||||
self botAction( "+fire" );
|
||||
self BotBuiltinBotAction( "+fire" );
|
||||
|
||||
if ( time )
|
||||
wait time;
|
||||
|
||||
self botAction( "-fire" );
|
||||
self BotBuiltinBotAction( "-fire" );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2444,9 +2444,9 @@ ads( what )
|
||||
self notify( "bot_ads" );
|
||||
|
||||
if ( what )
|
||||
self botAction( "+ads" );
|
||||
self BotBuiltinBotAction( "+ads" );
|
||||
else
|
||||
self botAction( "-ads" );
|
||||
self BotBuiltinBotAction( "-ads" );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2462,12 +2462,12 @@ pressADS( time )
|
||||
if ( !isDefined( time ) )
|
||||
time = 0.05;
|
||||
|
||||
self botAction( "+ads" );
|
||||
self BotBuiltinBotAction( "+ads" );
|
||||
|
||||
if ( time )
|
||||
wait time;
|
||||
|
||||
self botAction( "-ads" );
|
||||
self BotBuiltinBotAction( "-ads" );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2489,9 +2489,9 @@ jump()
|
||||
wait 1;
|
||||
}
|
||||
|
||||
self botAction( "+gostand" );
|
||||
self BotBuiltinBotAction( "+gostand" );
|
||||
wait 0.05;
|
||||
self botAction( "-gostand" );
|
||||
self BotBuiltinBotAction( "-gostand" );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2502,8 +2502,8 @@ stand()
|
||||
if ( self IsUsingRemote() )
|
||||
return;
|
||||
|
||||
self botAction( "-gocrouch" );
|
||||
self botAction( "-goprone" );
|
||||
self BotBuiltinBotAction( "-gocrouch" );
|
||||
self BotBuiltinBotAction( "-goprone" );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2514,8 +2514,8 @@ crouch()
|
||||
if ( self IsUsingRemote() )
|
||||
return;
|
||||
|
||||
self botAction( "+gocrouch" );
|
||||
self botAction( "-goprone" );
|
||||
self BotBuiltinBotAction( "+gocrouch" );
|
||||
self BotBuiltinBotAction( "-goprone" );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2526,16 +2526,8 @@ prone()
|
||||
if ( self IsUsingRemote() || self.hasRiotShieldEquipped )
|
||||
return;
|
||||
|
||||
self botAction( "-gocrouch" );
|
||||
self botAction( "+goprone" );
|
||||
}
|
||||
|
||||
/*
|
||||
Changes to the weap
|
||||
*/
|
||||
changeToWeap( weap )
|
||||
{
|
||||
self botWeapon( weap );
|
||||
self BotBuiltinBotAction( "-gocrouch" );
|
||||
self BotBuiltinBotAction( "+goprone" );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2655,11 +2647,3 @@ bot_lookat( pos, time, vel, doAimPredict )
|
||||
wait 0.05;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Bot change weap
|
||||
*/
|
||||
botWeapon( weap )
|
||||
{
|
||||
self switchToWeapon( weap );
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ connected()
|
||||
self thread onSpawned();
|
||||
|
||||
self thread onDeath();
|
||||
self thread onGiveLoadout();
|
||||
|
||||
self thread onKillcam();
|
||||
|
||||
@ -1473,35 +1472,6 @@ onDeath()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Watches when the bot is given a loadout
|
||||
*/
|
||||
onGiveLoadout_loop()
|
||||
{
|
||||
class = self.class;
|
||||
|
||||
if ( isDefined( self.bot_oma_class ) )
|
||||
class = self.bot_oma_class;
|
||||
|
||||
self botGiveLoadout( self.team, class, !isDefined( self.bot_oma_class ) );
|
||||
self.bot_oma_class = undefined;
|
||||
}
|
||||
|
||||
/*
|
||||
Watches when the bot is given a loadout
|
||||
*/
|
||||
onGiveLoadout()
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
self waittill( "giveLoadout" );
|
||||
|
||||
self onGiveLoadout_loop();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
When the bot spawns.
|
||||
*/
|
||||
@ -1849,7 +1819,7 @@ changeToWeapon( weap )
|
||||
if ( !self HasWeapon( weap ) )
|
||||
return false;
|
||||
|
||||
self BotChangeToWeapon( weap );
|
||||
self switchToWeapon( weap );
|
||||
|
||||
if ( self GetCurrentWeapon() == weap )
|
||||
return true;
|
||||
|
@ -3,12 +3,101 @@
|
||||
Author: INeedGames
|
||||
Date: 09/26/2020
|
||||
The shared functions for bots
|
||||
|
||||
Notes for engine
|
||||
obv the old bot behavior should be changed to use gsc built-ins to control bots
|
||||
isItemUnlocked should only check for levels for testclients, everything else should return true
|
||||
setSpawnWeapon and switchToWeapon should be modified to work for testclients
|
||||
*/
|
||||
|
||||
#include common_scripts\utility;
|
||||
#include maps\mp\_utility;
|
||||
#include maps\mp\gametypes\_hud_util;
|
||||
|
||||
/*
|
||||
Prints to console without dev script on
|
||||
*/
|
||||
BotBuiltinPrintConsole( s )
|
||||
{
|
||||
if ( isDefined( level.bot_builtins ) && isDefined( level.bot_builtins["printconsole"] ) )
|
||||
{
|
||||
[[ level.bot_builtins["printconsole" ]]]( s );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Writes to the file, mode can be "append" or "write"
|
||||
*/
|
||||
BotBuiltinFileWrite( file, contents, mode )
|
||||
{
|
||||
if ( isDefined( level.bot_builtins ) && isDefined( level.bot_builtins["filewrite"] ) )
|
||||
{
|
||||
[[ level.bot_builtins["filewrite" ]]]( file, contents, mode );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Returns the whole file as a string
|
||||
*/
|
||||
BotBuiltinFileRead( file )
|
||||
{
|
||||
if ( isDefined( level.bot_builtins ) && isDefined( level.bot_builtins["fileread"] ) )
|
||||
{
|
||||
return [[ level.bot_builtins["fileread" ]]]( file );
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/*
|
||||
Test if a file exists
|
||||
*/
|
||||
BotBuiltinFileExists( file )
|
||||
{
|
||||
if ( isDefined( level.bot_builtins ) && isDefined( level.bot_builtins["fileexists"] ) )
|
||||
{
|
||||
return [[ level.bot_builtins["fileexists" ]]]( file );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Bot action, does a bot action
|
||||
<client> botAction(<action string (+ or - then action like frag or smoke)>)
|
||||
*/
|
||||
BotBuiltinBotAction( action )
|
||||
{
|
||||
if ( isDefined( level.bot_builtins ) && isDefined( level.bot_builtins["botaction"] ) )
|
||||
{
|
||||
self [[ level.bot_builtins["botaction" ]]]( action );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Clears the bot from movement and actions
|
||||
<client> botStop()
|
||||
*/
|
||||
BotBuiltinBotStop()
|
||||
{
|
||||
if ( isDefined( level.bot_builtins ) && isDefined( level.bot_builtins["botstop"] ) )
|
||||
{
|
||||
self [[ level.bot_builtins["botstop" ]]]();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Sets the bot's movement
|
||||
<client> botMovement(<int left>, <int forward>)
|
||||
*/
|
||||
BotBuiltinBotMovement( left, forward )
|
||||
{
|
||||
if ( isDefined( level.bot_builtins ) && isDefined( level.bot_builtins["botmovement"] ) )
|
||||
{
|
||||
self [[ level.bot_builtins["botmovement" ]]]( left, forward );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Returns if player is the host
|
||||
*/
|
||||
@ -31,7 +120,7 @@ doHostCheck()
|
||||
|
||||
if ( getDvar( "bots_main_firstIsHost" ) != "0" )
|
||||
{
|
||||
PrintConsole( "WARNING: bots_main_firstIsHost is enabled\n" );
|
||||
BotBuiltinPrintConsole( "WARNING: bots_main_firstIsHost is enabled\n" );
|
||||
|
||||
if ( getDvar( "bots_main_firstIsHost" ) == "1" )
|
||||
{
|
||||
@ -93,14 +182,6 @@ BotSetStance( stance )
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Bot changes to the weap
|
||||
*/
|
||||
BotChangeToWeapon( weap )
|
||||
{
|
||||
self maps\mp\bots\_bot_internal::changeToWeap( weap );
|
||||
}
|
||||
|
||||
/*
|
||||
Bot presses the frag button for time.
|
||||
*/
|
||||
@ -884,7 +965,7 @@ getWaypointLinesFromFile( filename )
|
||||
result.lines = [];
|
||||
|
||||
// todo read line by line
|
||||
waypointStr = fs_fileread( filename );
|
||||
waypointStr = BotBuiltinFileRead( filename );
|
||||
|
||||
if ( !isDefined( waypointStr ) )
|
||||
return result;
|
||||
@ -919,7 +1000,7 @@ readWpsFromFile( mapname )
|
||||
waypoints = [];
|
||||
filename = "waypoints/" + mapname + "_wp.csv";
|
||||
|
||||
if ( !fs_testfile( filename ) )
|
||||
if ( !BotBuiltinFileExists( filename ) )
|
||||
return waypoints;
|
||||
|
||||
res = getWaypointLinesFromFile( filename );
|
||||
@ -927,7 +1008,7 @@ readWpsFromFile( mapname )
|
||||
if ( !res.lines.size )
|
||||
return waypoints;
|
||||
|
||||
PrintConsole( "Attempting to read waypoints from " + filename + "\n" );
|
||||
BotBuiltinPrintConsole( "Attempting to read waypoints from " + filename + "\n" );
|
||||
|
||||
waypointCount = int( res.lines[0] );
|
||||
|
||||
@ -961,7 +1042,7 @@ load_waypoints()
|
||||
if ( wps.size )
|
||||
{
|
||||
level.waypoints = wps;
|
||||
PrintConsole( "Loaded " + wps.size + " waypoints from csv.\n" );
|
||||
BotBuiltinPrintConsole( "Loaded " + wps.size + " waypoints from csv.\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -973,12 +1054,12 @@ load_waypoints()
|
||||
}
|
||||
|
||||
if ( level.waypoints.size )
|
||||
PrintConsole( "Loaded " + level.waypoints.size + " waypoints from script.\n" );
|
||||
BotBuiltinPrintConsole( "Loaded " + level.waypoints.size + " waypoints from script.\n" );
|
||||
}
|
||||
|
||||
if ( !level.waypoints.size )
|
||||
{
|
||||
PrintConsole( "No waypoints loaded!" );
|
||||
BotBuiltinPrintConsole( "No waypoints loaded!" );
|
||||
}
|
||||
|
||||
level.waypointCount = level.waypoints.size;
|
||||
@ -2446,357 +2527,3 @@ bombPlantedFix( destroyedObj, player )
|
||||
|
||||
maps\mp\gametypes\sd::sd_endGame( game["attackers"], game["strings"]["target_destroyed"] );
|
||||
}
|
||||
|
||||
/*
|
||||
Patches giveLoadout so that it doesn't use IsItemUnlocked
|
||||
*/
|
||||
botGiveLoadout( team, class, allowCopycat )
|
||||
{
|
||||
self endon( "death" );
|
||||
|
||||
self takeAllWeapons();
|
||||
|
||||
primaryIndex = 0;
|
||||
|
||||
// initialize specialty array
|
||||
self.specialty = [];
|
||||
|
||||
if ( !isDefined( allowCopycat ) )
|
||||
allowCopycat = true;
|
||||
|
||||
primaryWeapon = undefined;
|
||||
|
||||
if ( isDefined( self.pers["copyCatLoadout"] ) && self.pers["copyCatLoadout"]["inUse"] && allowCopycat )
|
||||
{
|
||||
self maps\mp\gametypes\_class::setClass( "copycat" );
|
||||
self.class_num = maps\mp\gametypes\_class::getClassIndex( "copycat" );
|
||||
|
||||
clonedLoadout = self.pers["copyCatLoadout"];
|
||||
|
||||
loadoutPrimary = clonedLoadout["loadoutPrimary"];
|
||||
loadoutPrimaryAttachment = clonedLoadout["loadoutPrimaryAttachment"];
|
||||
loadoutPrimaryAttachment2 = clonedLoadout["loadoutPrimaryAttachment2"] ;
|
||||
loadoutPrimaryCamo = clonedLoadout["loadoutPrimaryCamo"];
|
||||
loadoutSecondary = clonedLoadout["loadoutSecondary"];
|
||||
loadoutSecondaryAttachment = clonedLoadout["loadoutSecondaryAttachment"];
|
||||
loadoutSecondaryAttachment2 = clonedLoadout["loadoutSecondaryAttachment2"];
|
||||
loadoutSecondaryCamo = clonedLoadout["loadoutSecondaryCamo"];
|
||||
loadoutEquipment = clonedLoadout["loadoutEquipment"];
|
||||
loadoutPerk1 = clonedLoadout["loadoutPerk1"];
|
||||
loadoutPerk2 = clonedLoadout["loadoutPerk2"];
|
||||
loadoutPerk3 = clonedLoadout["loadoutPerk3"];
|
||||
loadoutOffhand = clonedLoadout["loadoutOffhand"];
|
||||
loadoutDeathStreak = "specialty_copycat";
|
||||
}
|
||||
else if ( isSubstr( class, "custom" ) )
|
||||
{
|
||||
class_num = maps\mp\gametypes\_class::getClassIndex( class );
|
||||
self.class_num = class_num;
|
||||
|
||||
loadoutPrimary = maps\mp\gametypes\_class::cac_getWeapon( class_num, 0 );
|
||||
loadoutPrimaryAttachment = maps\mp\gametypes\_class::cac_getWeaponAttachment( class_num, 0 );
|
||||
loadoutPrimaryAttachment2 = maps\mp\gametypes\_class::cac_getWeaponAttachmentTwo( class_num, 0 );
|
||||
loadoutPrimaryCamo = maps\mp\gametypes\_class::cac_getWeaponCamo( class_num, 0 );
|
||||
loadoutSecondaryCamo = maps\mp\gametypes\_class::cac_getWeaponCamo( class_num, 1 );
|
||||
loadoutSecondary = maps\mp\gametypes\_class::cac_getWeapon( class_num, 1 );
|
||||
loadoutSecondaryAttachment = maps\mp\gametypes\_class::cac_getWeaponAttachment( class_num, 1 );
|
||||
loadoutSecondaryAttachment2 = maps\mp\gametypes\_class::cac_getWeaponAttachmentTwo( class_num, 1 );
|
||||
loadoutSecondaryCamo = maps\mp\gametypes\_class::cac_getWeaponCamo( class_num, 1 );
|
||||
loadoutEquipment = maps\mp\gametypes\_class::cac_getPerk( class_num, 0 );
|
||||
loadoutPerk1 = maps\mp\gametypes\_class::cac_getPerk( class_num, 1 );
|
||||
loadoutPerk2 = maps\mp\gametypes\_class::cac_getPerk( class_num, 2 );
|
||||
loadoutPerk3 = maps\mp\gametypes\_class::cac_getPerk( class_num, 3 );
|
||||
loadoutOffhand = maps\mp\gametypes\_class::cac_getOffhand( class_num );
|
||||
loadoutDeathStreak = maps\mp\gametypes\_class::cac_getDeathstreak( class_num );
|
||||
}
|
||||
else
|
||||
{
|
||||
class_num = maps\mp\gametypes\_class::getClassIndex( class );
|
||||
self.class_num = class_num;
|
||||
|
||||
loadoutPrimary = maps\mp\gametypes\_class::table_getWeapon( level.classTableName, class_num, 0 );
|
||||
loadoutPrimaryAttachment = maps\mp\gametypes\_class::table_getWeaponAttachment( level.classTableName, class_num, 0, 0 );
|
||||
loadoutPrimaryAttachment2 = maps\mp\gametypes\_class::table_getWeaponAttachment( level.classTableName, class_num, 0, 1 );
|
||||
loadoutPrimaryCamo = maps\mp\gametypes\_class::table_getWeaponCamo( level.classTableName, class_num, 0 );
|
||||
loadoutSecondaryCamo = maps\mp\gametypes\_class::table_getWeaponCamo( level.classTableName, class_num, 1 );
|
||||
loadoutSecondary = maps\mp\gametypes\_class::table_getWeapon( level.classTableName, class_num, 1 );
|
||||
loadoutSecondaryAttachment = maps\mp\gametypes\_class::table_getWeaponAttachment( level.classTableName, class_num, 1, 0 );
|
||||
loadoutSecondaryAttachment2 = maps\mp\gametypes\_class::table_getWeaponAttachment( level.classTableName, class_num, 1, 1 );;
|
||||
loadoutSecondaryCamo = maps\mp\gametypes\_class::table_getWeaponCamo( level.classTableName, class_num, 1 );
|
||||
loadoutEquipment = maps\mp\gametypes\_class::table_getEquipment( level.classTableName, class_num, 0 );
|
||||
loadoutPerk1 = maps\mp\gametypes\_class::table_getPerk( level.classTableName, class_num, 1 );
|
||||
loadoutPerk2 = maps\mp\gametypes\_class::table_getPerk( level.classTableName, class_num, 2 );
|
||||
loadoutPerk3 = maps\mp\gametypes\_class::table_getPerk( level.classTableName, class_num, 3 );
|
||||
loadoutOffhand = maps\mp\gametypes\_class::table_getOffhand( level.classTableName, class_num );
|
||||
loadoutDeathstreak = maps\mp\gametypes\_class::table_getDeathstreak( level.classTableName, class_num );
|
||||
}
|
||||
|
||||
if ( loadoutPerk1 != "specialty_bling" )
|
||||
{
|
||||
loadoutPrimaryAttachment2 = "none";
|
||||
loadoutSecondaryAttachment2 = "none";
|
||||
}
|
||||
|
||||
if ( loadoutPerk1 != "specialty_onemanarmy" && loadoutSecondary == "onemanarmy" )
|
||||
loadoutSecondary = maps\mp\gametypes\_class::table_getWeapon( level.classTableName, 10, 1 );
|
||||
|
||||
//loadoutSecondaryCamo = "none";
|
||||
|
||||
// stop default class op'ness
|
||||
allowOp = ( getDvarInt( "bots_loadout_allow_op" ) >= 1 );
|
||||
|
||||
if ( !allowOp )
|
||||
{
|
||||
loadoutDeathstreak = "specialty_null";
|
||||
|
||||
if ( loadoutPrimary == "riotshield" )
|
||||
loadoutPrimary = "m4";
|
||||
|
||||
if ( loadoutSecondary == "at4" )
|
||||
loadoutSecondary = "usp";
|
||||
|
||||
if ( loadoutPrimaryAttachment == "gl" )
|
||||
loadoutPrimaryAttachment = "none";
|
||||
|
||||
if ( loadoutPerk2 == "specialty_coldblooded" )
|
||||
loadoutPerk2 = "specialty_null";
|
||||
|
||||
if ( loadoutPerk3 == "specialty_localjammer" )
|
||||
loadoutPerk3 = "specialty_null";
|
||||
}
|
||||
|
||||
|
||||
if ( level.killstreakRewards )
|
||||
{
|
||||
if ( getDvarInt( "scr_classic" ) == 1 )
|
||||
{
|
||||
loadoutKillstreak1 = "uav";
|
||||
loadoutKillstreak2 = "precision_airstrike";
|
||||
loadoutKillstreak3 = "helicopter";
|
||||
}
|
||||
else
|
||||
{
|
||||
loadoutKillstreak1 = self getPlayerData( "killstreaks", 0 );
|
||||
loadoutKillstreak2 = self getPlayerData( "killstreaks", 1 );
|
||||
loadoutKillstreak3 = self getPlayerData( "killstreaks", 2 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loadoutKillstreak1 = "none";
|
||||
loadoutKillstreak2 = "none";
|
||||
loadoutKillstreak3 = "none";
|
||||
}
|
||||
|
||||
secondaryName = maps\mp\gametypes\_class::buildWeaponName( loadoutSecondary, loadoutSecondaryAttachment, loadoutSecondaryAttachment2 );
|
||||
self _giveWeapon( secondaryName, int( tableLookup( "mp/camoTable.csv", 1, loadoutSecondaryCamo, 0 ) ) );
|
||||
|
||||
self.loadoutPrimaryCamo = int( tableLookup( "mp/camoTable.csv", 1, loadoutPrimaryCamo, 0 ) );
|
||||
self.loadoutPrimary = loadoutPrimary;
|
||||
self.loadoutSecondary = loadoutSecondary;
|
||||
self.loadoutSecondaryCamo = int( tableLookup( "mp/camoTable.csv", 1, loadoutSecondaryCamo, 0 ) );
|
||||
|
||||
self SetOffhandPrimaryClass( "other" );
|
||||
|
||||
// Action Slots
|
||||
//self _SetActionSlot( 1, "" );
|
||||
self _SetActionSlot( 1, "nightvision" );
|
||||
self _SetActionSlot( 3, "altMode" );
|
||||
self _SetActionSlot( 4, "" );
|
||||
|
||||
// Perks
|
||||
self _clearPerks();
|
||||
self maps\mp\gametypes\_class::_detachAll();
|
||||
|
||||
// these special case giving pistol death have to come before
|
||||
// perk loadout to ensure player perk icons arent overwritten
|
||||
if ( level.dieHardMode )
|
||||
self maps\mp\perks\_perks::givePerk( "specialty_pistoldeath" );
|
||||
|
||||
// only give the deathstreak for the initial spawn for this life.
|
||||
if ( loadoutDeathStreak != "specialty_null" && ( getTime() - self.spawnTime ) < 0.1 )
|
||||
{
|
||||
deathVal = int( tableLookup( "mp/perkTable.csv", 1, loadoutDeathStreak, 6 ) );
|
||||
|
||||
if ( self botGetPerkUpgrade( loadoutPerk1 ) == "specialty_rollover" || self botGetPerkUpgrade( loadoutPerk2 ) == "specialty_rollover" || self botGetPerkUpgrade( loadoutPerk3 ) == "specialty_rollover" )
|
||||
deathVal -= 1;
|
||||
|
||||
if ( self.pers["cur_death_streak"] == deathVal )
|
||||
{
|
||||
self thread maps\mp\perks\_perks::givePerk( loadoutDeathStreak );
|
||||
self thread maps\mp\gametypes\_hud_message::splashNotify( loadoutDeathStreak );
|
||||
}
|
||||
else if ( self.pers["cur_death_streak"] > deathVal )
|
||||
{
|
||||
self thread maps\mp\perks\_perks::givePerk( loadoutDeathStreak );
|
||||
}
|
||||
}
|
||||
|
||||
self botLoadoutAllPerks( loadoutEquipment, loadoutPerk1, loadoutPerk2, loadoutPerk3 );
|
||||
|
||||
self maps\mp\gametypes\_class::setKillstreaks( loadoutKillstreak1, loadoutKillstreak2, loadoutKillstreak3 );
|
||||
|
||||
if ( self hasPerk( "specialty_extraammo", true ) && getWeaponClass( secondaryName ) != "weapon_projectile" )
|
||||
self giveMaxAmmo( secondaryName );
|
||||
|
||||
// Primary Weapon
|
||||
primaryName = maps\mp\gametypes\_class::buildWeaponName( loadoutPrimary, loadoutPrimaryAttachment, loadoutPrimaryAttachment2 );
|
||||
self _giveWeapon( primaryName, self.loadoutPrimaryCamo );
|
||||
|
||||
// fix changing from a riotshield class to a riotshield class during grace period not giving a shield
|
||||
if ( primaryName == "riotshield_mp" && level.inGracePeriod )
|
||||
self notify ( "weapon_change", "riotshield_mp" );
|
||||
|
||||
if ( self hasPerk( "specialty_extraammo", true ) )
|
||||
self giveMaxAmmo( primaryName );
|
||||
|
||||
self setSpawnWeapon( primaryName );
|
||||
|
||||
primaryTokens = strtok( primaryName, "_" );
|
||||
self.pers["primaryWeapon"] = primaryTokens[0];
|
||||
|
||||
// Primary Offhand was given by givePerk (it's your perk1)
|
||||
|
||||
// Secondary Offhand
|
||||
offhandSecondaryWeapon = loadoutOffhand + "_mp";
|
||||
|
||||
if ( loadoutOffhand == "flash_grenade" )
|
||||
self SetOffhandSecondaryClass( "flash" );
|
||||
else
|
||||
self SetOffhandSecondaryClass( "smoke" );
|
||||
|
||||
self giveWeapon( offhandSecondaryWeapon );
|
||||
|
||||
if ( loadOutOffhand == "smoke_grenade" )
|
||||
self setWeaponAmmoClip( offhandSecondaryWeapon, 1 );
|
||||
else if ( loadOutOffhand == "flash_grenade" )
|
||||
self setWeaponAmmoClip( offhandSecondaryWeapon, 2 );
|
||||
else if ( loadOutOffhand == "concussion_grenade" )
|
||||
self setWeaponAmmoClip( offhandSecondaryWeapon, 2 );
|
||||
else
|
||||
self setWeaponAmmoClip( offhandSecondaryWeapon, 1 );
|
||||
|
||||
primaryWeapon = primaryName;
|
||||
self.primaryWeapon = primaryWeapon;
|
||||
self.secondaryWeapon = secondaryName;
|
||||
|
||||
self botPlayerModelForWeapon( self.pers["primaryWeapon"], getBaseWeaponName( secondaryName ) );
|
||||
|
||||
self.isSniper = ( weaponClass( self.primaryWeapon ) == "sniper" );
|
||||
|
||||
self maps\mp\gametypes\_weapons::updateMoveSpeedScale( "primary" );
|
||||
|
||||
// cac specialties that require loop threads
|
||||
self maps\mp\perks\_perks::cac_selector();
|
||||
|
||||
self notify ( "changed_kit" );
|
||||
self notify( "bot_giveLoadout", allowCopycat );
|
||||
}
|
||||
|
||||
/*
|
||||
Patches giveLoadout so that it doesn't use IsItemUnlocked
|
||||
*/
|
||||
botGetPerkUpgrade( perkName )
|
||||
{
|
||||
perkUpgrade = tablelookup( "mp/perktable.csv", 1, perkName, 8 );
|
||||
|
||||
if ( perkUpgrade == "" || perkUpgrade == "specialty_null" )
|
||||
return "specialty_null";
|
||||
|
||||
if ( !isDefined( self.pers["bots"]["unlocks"]["upgraded_" + perkName] ) || !self.pers["bots"]["unlocks"]["upgraded_" + perkName] )
|
||||
return "specialty_null";
|
||||
|
||||
return ( perkUpgrade );
|
||||
}
|
||||
|
||||
/*
|
||||
Patches giveLoadout so that it doesn't use IsItemUnlocked
|
||||
*/
|
||||
botLoadoutAllPerks( loadoutEquipment, loadoutPerk1, loadoutPerk2, loadoutPerk3 )
|
||||
{
|
||||
loadoutEquipment = maps\mp\perks\_perks::validatePerk( 1, loadoutEquipment );
|
||||
loadoutPerk1 = maps\mp\perks\_perks::validatePerk( 1, loadoutPerk1 );
|
||||
loadoutPerk2 = maps\mp\perks\_perks::validatePerk( 2, loadoutPerk2 );
|
||||
loadoutPerk3 = maps\mp\perks\_perks::validatePerk( 3, loadoutPerk3 );
|
||||
|
||||
self maps\mp\perks\_perks::givePerk( loadoutEquipment );
|
||||
self maps\mp\perks\_perks::givePerk( loadoutPerk1 );
|
||||
self maps\mp\perks\_perks::givePerk( loadoutPerk2 );
|
||||
self maps\mp\perks\_perks::givePerk( loadoutPerk3 );
|
||||
|
||||
perks[0] = loadoutPerk1;
|
||||
perks[1] = loadoutPerk2;
|
||||
perks[2] = loadoutPerk3;
|
||||
|
||||
perkUpgrd[0] = tablelookup( "mp/perktable.csv", 1, loadoutPerk1, 8 );
|
||||
perkUpgrd[1] = tablelookup( "mp/perktable.csv", 1, loadoutPerk2, 8 );
|
||||
perkUpgrd[2] = tablelookup( "mp/perktable.csv", 1, loadoutPerk3, 8 );
|
||||
|
||||
for ( i = 0; i < perkUpgrd.size; i++ )
|
||||
{
|
||||
upgrade = perkUpgrd[i];
|
||||
perk = perks[i];
|
||||
|
||||
if ( upgrade == "" || upgrade == "specialty_null" )
|
||||
continue;
|
||||
|
||||
if ( isDefined( self.pers["bots"]["unlocks"]["upgraded_" + perk] ) && self.pers["bots"]["unlocks"]["upgraded_" + perk] )
|
||||
self maps\mp\perks\_perks::givePerk( upgrade );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Patches giveLoadout so that it doesn't use IsItemUnlocked
|
||||
*/
|
||||
botPlayerModelForWeapon( weapon, secondary )
|
||||
{
|
||||
team = self.team;
|
||||
|
||||
|
||||
if ( isDefined( game[team + "_model"][weapon] ) )
|
||||
{
|
||||
[[game[team + "_model"][weapon]]]();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
weaponClass = tablelookup( "mp/statstable.csv", 4, weapon, 2 );
|
||||
|
||||
switch ( weaponClass )
|
||||
{
|
||||
case "weapon_smg":
|
||||
[[game[team + "_model"]["SMG"]]]();
|
||||
break;
|
||||
|
||||
case "weapon_assault":
|
||||
weaponClass = tablelookup( "mp/statstable.csv", 4, secondary, 2 );
|
||||
|
||||
if ( weaponClass == "weapon_shotgun" )
|
||||
[[game[team + "_model"]["SHOTGUN"]]]();
|
||||
else
|
||||
[[game[team + "_model"]["ASSAULT"]]]();
|
||||
|
||||
break;
|
||||
|
||||
case "weapon_sniper":
|
||||
if ( level.environment != "" && isDefined( self.pers["bots"]["unlocks"]["ghillie"] ) && self.pers["bots"]["unlocks"]["ghillie"] )
|
||||
[[game[team + "_model"]["GHILLIE"]]]();
|
||||
else
|
||||
[[game[team + "_model"]["SNIPER"]]]();
|
||||
|
||||
break;
|
||||
|
||||
case "weapon_lmg":
|
||||
[[game[team + "_model"]["LMG"]]]();
|
||||
break;
|
||||
|
||||
case "weapon_riot":
|
||||
[[game[team + "_model"]["RIOT"]]]();
|
||||
break;
|
||||
|
||||
default:
|
||||
[[game[team + "_model"]["ASSAULT"]]]();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ watchSaveWaypointsCommand()
|
||||
PrintLn( "********* Start Bot Warfare WPDump *********" );
|
||||
PrintLn( level.waypointCount );
|
||||
|
||||
fs_filewrite( filename, level.waypointCount + "\n", "write" );
|
||||
BotBuiltinFileWrite( filename, level.waypointCount + "\n", "write" );
|
||||
|
||||
for ( i = 0; i < level.waypointCount; i++ )
|
||||
{
|
||||
@ -429,7 +429,7 @@ watchSaveWaypointsCommand()
|
||||
str += ",";
|
||||
|
||||
PrintLn( str );
|
||||
fs_filewrite( filename, str + "\n", "append" );
|
||||
BotBuiltinFileWrite( filename, str + "\n", "append" );
|
||||
}
|
||||
|
||||
PrintLn( "\n\n\n\n\n\n" );
|
||||
|
Loading…
x
Reference in New Issue
Block a user