Part of killstreaks

This commit is contained in:
INeedBots 2021-01-08 13:08:29 -06:00
parent 35a0799289
commit 5fbaac871e
4 changed files with 553 additions and 7 deletions

View File

@ -1243,6 +1243,7 @@ bot_get_killstreak_cost(ks)
*/ */
bot_giveKillstreaks() bot_giveKillstreaks()
{ {
self.killstreak = [];
self.killstreak[0] = self.pers["bot"]["killstreaks"][0]; self.killstreak[0] = self.pers["bot"]["killstreaks"][0];
self.killstreak[1] = self.pers["bot"]["killstreaks"][1]; self.killstreak[1] = self.pers["bot"]["killstreaks"][1];
self.killstreak[2] = self.pers["bot"]["killstreaks"][2]; self.killstreak[2] = self.pers["bot"]["killstreaks"][2];

View File

@ -262,21 +262,21 @@ bot_spawn()
if(!level.inPrematchPeriod) if(!level.inPrematchPeriod)
{ {
switch(GetDvar( #"bot_difficulty" )) switch(self GetBotDiffNum())
{ {
case "fu": case 3:
break; break;
case "easy": case 0:
self freeze_player_controls(true); self freeze_player_controls(true);
wait 0.6; wait 0.6;
self freeze_player_controls(false); self freeze_player_controls(false);
break; break;
case "normal": case 1:
self freeze_player_controls(true); self freeze_player_controls(true);
wait 0.4; wait 0.4;
self freeze_player_controls(false); self freeze_player_controls(false);
break; break;
case "hard": case 2:
self freeze_player_controls(true); self freeze_player_controls(true);
wait 0.2; wait 0.2;
self freeze_player_controls(false); self freeze_player_controls(false);
@ -289,9 +289,10 @@ bot_spawn()
wait ( 0.05 ); wait ( 0.05 );
} }
/*if (getDvarInt("bots_play_killstreak")) if (getDvarInt("bots_play_killstreak"))
self thread bot_killstreak_think(); self thread bot_killstreak_think();
/*
if (getDvarInt("bots_play_take_carepackages")) if (getDvarInt("bots_play_take_carepackages"))
{ {
self thread bot_watch_stuck_on_crate(); self thread bot_watch_stuck_on_crate();
@ -377,6 +378,431 @@ bots_watch_touch_obj(obj)
} }
} }
/*
Changes to the weap
*/
changeToWeapon(weap)
{
self endon("disconnect");
self endon("death");
level endon("game_ended");
if (!self HasWeapon(weap))
return false;
if (self GetCurrentWeapon() == weap)
return true;
self SwitchToWeapon(weap);
self waittill_any_timeout(5, "weapon_change");
return (self GetCurrentWeapon() == weap);
}
/*
Fires the bots weapon until told to stop
*/
fire_current_weapon()
{
self endon("death");
self endon("disconnect");
self endon("weapon_change");
self endon("stop_firing_weapon");
wait 0.5;
for (;;)
{
self PressAttackButton();
wait 0.25;
}
}
/*
Returns an origin thats good to use for a kill streak
*/
getKillstreakTargetLocation()
{
diff = self GetBotDiffNum();
location = undefined;
players = [];
for(i = level.players.size - 1; i >= 0; i--)
{
player = level.players[i];
if(player == self)
continue;
if(!isDefined(player.team))
continue;
if(level.teamBased && self.team == player.team)
continue;
if(player.sessionstate != "playing")
continue;
if(!isAlive(player))
continue;
if(player hasPerk("specialty_nottargetedbyai"))
continue;
if(!bulletTracePassed(player.origin, player.origin+(0,0,2048), false, player) && diff > 0)
continue;
players[players.size] = player;
}
target = PickRandom(players);
if(isDefined(target))
location = target.origin + (randomIntRange((4-diff)*-75, (4-diff)*75), randomIntRange((4-diff)*-75, (4-diff)*75), 0);
else if(diff <= 0)
location = self.origin + (randomIntRange(-512, 512), randomIntRange(-512, 512), 0);
return location;
}
/*
Bot will think to use rcbomb
*/
bot_rccar_think()
{
}
/*
Bot will think to use supply drop
*/
bot_use_supply_drop( weapon )
{
if (self GetBotDiffNum())
{
if (self GetLookaheadDist() < 96)
return;
view_angles = self GetPlayerAngles();
if ( view_angles[0] < 7 )
return;
dir = self GetLookaheadDir();
if ( !IsDefined( dir ) )
return;
dir = VectorToAngles( dir );
if ( abs( dir[1] - self.angles[1] ) > 2 )
return;
yaw = ( 0, self.angles[1], 0 );
dir = AnglesToForward( yaw );
dir = VectorNormalize( dir );
drop_point = self.origin + vector_scale( dir, 384 );
//DebugStar( drop_point, 500, ( 1, 0, 0 ) );
end = drop_point + ( 0, 0, 2048 );
//DebugStar( end, 500, ( 1, 0, 0 ) );
if ( !SightTracePassed( drop_point, end, false, undefined ) )
return;
if ( !SightTracePassed( self.origin, end, false, undefined ) )
return;
// is this point in mid-air?
end = drop_point - ( 0, 0, 32 );
//DebugStar( end, 500, ( 1, 0, 0 ) );
if ( BulletTracePassed( drop_point, end, false, undefined ) )
return;
}
self thread botStopMove(true);
if (self ChangeToWeapon(weapon))
{
self thread fire_current_weapon();
ret = self waittill_any_timeout( 5, "grenade_fire" );
self notify("stop_firing_weapon");
self thread changeToWeapon(self.lastNonKillstreakWeapon);
if (ret == "grenade_fire" && randomInt(100) < 80)
self waittill_any_timeout( 15, "bot_crate_landed" );
}
self thread botStopMove(false);
}
/*
Bot will think to use turret
*/
bot_turret_location( weapon )
{
}
/*
Bot will think to heli
*/
bot_control_heli(weapon)
{
if (!self ChangeToWeapon(weapon))
return;
self endon("heli_timeup");
wait 2.5;
if(!isDefined(self.heli))
return;
self.heli endon("death");
self.heli endon("heli_timeup");
while(isDefined(self.heli))
wait 0.25;
}
/*
Bots think to use killstreaks
*/
bot_killstreak_think()
{
self endon( "death" );
self endon( "disconnect" );
level endon ( "game_ended" );
myteam = self.pers[ "team" ];
otherTeam = getOtherTeam( myTeam );
wait( 1 );
for (;;)
{
wait( RandomIntRange( 1, 3 ) );
if (isDefined(self GetThreat()))
continue;
if ( self IsRemoteControlling() )
continue;
if(self UseButtonPressed())
continue;
if(self isDefusing() || self isPlanting() || self inLastStand())
continue;
weapon = self maps\mp\gametypes\_hardpoints::getTopKillstreak();
if ( !IsDefined( weapon ) || weapon == "none" )
continue;
killstreak = maps\mp\gametypes\_hardpoints::getKillStreakMenuName( weapon );
if ( !IsDefined( killstreak ) )
continue;
id = self maps\mp\gametypes\_hardpoints::getTopKillstreakUniqueId();
if ( !self maps\mp\_killstreakrules::isKillstreakAllowed( weapon, myteam ) )
{
wait( 5 );
continue;
}
diff = self GetBotDiffNum();
switch( killstreak )
{
case "killstreak_helicopter_comlink":
case "killstreak_napalm":
case "killstreak_airstrike":
case "killstreak_mortar":
num = 1;
if (killstreak == "killstreak_mortar")
num = 3;
if (!self ChangeToWeapon(weapon))
break;
self freeze_player_controls( true );
wait 1;
for (i = 0; i < num; i++)
{
origin = self getKillstreakTargetLocation();
if (!isDefined(origin))
break;
yaw = RandomIntRange( 0, 360 );
wait 0.25;
self notify( "confirm_location", origin, yaw );
}
self freeze_player_controls( false );
break;
case "killstreak_helicopter_gunner":
case "killstreak_helicopter_player_firstperson":
self bot_control_heli(weapon);
wait 1;
break;
case "killstreak_auto_turret":
case "killstreak_tow_turret":
self bot_turret_location( weapon );
wait 1;
break;
case "killstreak_auto_turret_drop":
case "killstreak_tow_turret_drop":
case "killstreak_m220_tow_drop":
case "killstreak_supply_drop":
if(killstreak == "killstreak_supply_drop")
weapon = "supplydrop_mp";
self bot_use_supply_drop( weapon );
wait 1;
break;
case "killstreak_rcbomb":
self bot_rccar_think();
wait 1;
break;
case "killstreak_spyplane":
if ( diff > 0 )
{
if(level.teamBased)
{
if(level.activeCounterUAVs[otherTeam])
continue;
if(level.activeSatellites[myTeam])
continue;
if(level.activeUAVs[myTeam])
continue;
}
else
{
shouldContinue = false;
players = get_players();
for (i = 0; i < players.size; i++)
{
player = players[i];
if(player == self)
continue;
if(!isDefined(player.team))
continue;
if(isDefined(level.activeCounterUAVs[player.entnum]) && level.activeCounterUAVs[player.entnum])
continue;
shouldContinue = true;
break;
}
if(shouldContinue)
continue;
if(level.activeSatellites[self.entnum])
continue;
if(level.activeUAVs[self.entnum])
continue;
}
}
if (!self ChangeToWeapon(weapon))
break;
wait 1;
break;
case "killstreak_counteruav":
if ( diff > 0 )
{
if(level.teamBased)
{
if(level.activeCounterUAVs[myTeam])
continue;
}
else
{
if(level.activeCounterUAVs[self.entnum])
continue;
}
}
if (!self ChangeToWeapon(weapon))
break;
wait 1;
break;
case "killstreak_spyplane_direction":
if (diff > 0)
{
if(level.teamBased)
{
if(level.activeCounterUAVs[otherTeam])
continue;
if(level.activeSatellites[myTeam])
continue;
}
else
{
shouldContinue = false;
players = get_players();
for (i = 0; i < players.size; i++)
{
player = players[i];
if(player == self)
continue;
if(!isDefined(player.team))
continue;
if(isDefined(level.activeCounterUAVs[player.entnum]) && level.activeCounterUAVs[player.entnum])
continue;
shouldContinue = true;
break;
}
if(shouldContinue)
continue;
if(level.activeSatellites[self.entnum])
continue;
}
}
case "killstreak_dogs":
default:
if (!self ChangeToWeapon(weapon))
break;
wait 1;
break;
}
if (weapon == "m220_tow_mp" || weapon == "m202_flash_mp" || weapon == "minigun_mp") // don't put away ks weapons
continue;
self thread changeToWeapon(self.lastNonKillstreakWeapon);
}
}
/* /*
Bots hang around the enemy's flag to spawn kill em Bots hang around the enemy's flag to spawn kill em
*/ */

View File

@ -70,6 +70,101 @@ PickRandom(arr)
return arr[randomInt(arr.size)]; return arr[randomInt(arr.size)];
} }
/*
If is defusing
*/
isDefusing()
{
return (isDefined(self.isDefusing) && self.isDefusing);
}
/*
If is defusing
*/
isPlanting()
{
return (isDefined(self.isPlanting) && self.isPlanting);
}
/*
If is defusing
*/
inLastStand()
{
return (isDefined(self.laststand) && self.laststand);
}
/*
Gets the bot's difficulty number
*/
GetBotDiffNum()
{
num = 0;
switch (getDvar("bot_difficulty"))
{
case "fu":
num = 3;
case "hard":
num = 2;
case "normal":
num = 1;
case "easy":
default:
num = 0;
break;
}
return 0;
}
/*
Taken from iw4 script
*/
waittill_any_timeout( timeOut, string1, string2, string3, string4, string5 )
{
if ( ( !isdefined( string1 ) || string1 != "death" ) &&
( !isdefined( string2 ) || string2 != "death" ) &&
( !isdefined( string3 ) || string3 != "death" ) &&
( !isdefined( string4 ) || string4 != "death" ) &&
( !isdefined( string5 ) || string5 != "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 );
ent thread _timeout( timeOut );
ent waittill( "returned", msg );
ent notify( "die" );
return msg;
}
/*
Used for waittill_any_timeout
*/
_timeout( delay )
{
self endon( "die" );
wait( delay );
self notify( "returned", "timeout" );
}
/* /*
Waits for a host player Waits for a host player
*/ */
@ -123,6 +218,30 @@ SetBotGoal(where, dist)
self notify("new_goal"); self notify("new_goal");
} }
/*
Freezes bot in place
*/
botStopMove(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));
self setOrigin(og);
wait 0.05;
}
}
/* /*
Matches a num to a char Matches a num to a char
*/ */

View File

@ -1 +1 @@
start "" "%~dp0BlackOpsMP.exe" +set dedicated "1" +set developer "1" +set developer_script "1" +set logfile "2" +set scr_game_spectatetype "2" +set thereisacow "1" +set sv_cheats "1" +set sv_maxclients "32" +set sv_licensenum "0" +set sv_ranked "0" +set fs_game "mods/mp_dev" +set sv_punkbuster "0" +set scr_tdm_scorelimit "0" +set net_port "28960" +devmap mp_nuked start "" "%~dp0BlackOpsMP.exe" +set dedicated "1" +set developer "1" +set developer_script "1" +set logfile "2" +set scr_game_spectatetype "2" +set thereisacow "1" +set sv_cheats "1" +set sv_maxclients "32" +set sv_licensenum "0" +set sv_ranked "0" +set fs_game "mods/mp_dev" +set sv_punkbuster "0" +set scr_tdm_scorelimit "0" +set net_port "28960" +set net_ip "192.168.1.136" +devmap mp_nuked