mirror of
https://github.com/ineedbots/t5_bot_warfare.git
synced 2025-06-25 22:01:55 +00:00
Lets go
This commit is contained in:
31
main_shared/maps/mp/bots/_bot_loadout.gsc
Normal file
31
main_shared/maps/mp/bots/_bot_loadout.gsc
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
_bot_loadout
|
||||
Author: INeedGames
|
||||
Date: 12/20/2020
|
||||
Loadout stuff
|
||||
*/
|
||||
|
||||
#include common_scripts\utility;
|
||||
#include maps\mp\_utility;
|
||||
#include maps\mp\gametypes\_hud_util;
|
||||
#include maps\mp\bots\_bot_utility;
|
||||
|
||||
/*
|
||||
Gives the bot loadout
|
||||
*/
|
||||
bot_give_loadout()
|
||||
{
|
||||
if (!isDefined(self.bot))
|
||||
self.bot = [];
|
||||
|
||||
self.bot[ "specialty1" ] = "specialty_null";
|
||||
self.bot[ "specialty2" ] = "specialty_null";
|
||||
self.bot[ "specialty3" ] = "specialty_null";
|
||||
|
||||
self.cac_body_type = "standard_mp";
|
||||
self.cac_head_type = self maps\mp\gametypes\_armor::get_default_head();
|
||||
self.cac_hat_type = "none";
|
||||
self maps\mp\gametypes\_armor::set_player_model();
|
||||
|
||||
self GiveWeapon( "ak47_mp", 0, 0 );
|
||||
}
|
76
main_shared/maps/mp/bots/_bot_script.gsc
Normal file
76
main_shared/maps/mp/bots/_bot_script.gsc
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
_bot_script
|
||||
Author: INeedGames
|
||||
Date: 12/20/2020
|
||||
Tells the bots what to do.
|
||||
*/
|
||||
|
||||
#include common_scripts\utility;
|
||||
#include maps\mp\_utility;
|
||||
#include maps\mp\gametypes\_hud_util;
|
||||
#include maps\mp\bots\_bot_utility;
|
||||
|
||||
/*
|
||||
When the bot is added to the game
|
||||
*/
|
||||
added()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
When the bot connects
|
||||
*/
|
||||
connected()
|
||||
{
|
||||
self thread classWatch();
|
||||
self thread teamWatch();
|
||||
}
|
||||
|
||||
/*
|
||||
Fired when the bot is damaged
|
||||
*/
|
||||
bot_damage_callback( eAttacker, iDamage, sMeansOfDeath, sWeapon, eInflictor, sHitLoc )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
Selects a class for the bot.
|
||||
*/
|
||||
classWatch()
|
||||
{
|
||||
self endon("disconnect");
|
||||
|
||||
for(;;)
|
||||
{
|
||||
while(!isdefined(self.pers["team"]) || level.oldschool)
|
||||
wait .05;
|
||||
|
||||
wait 0.5;
|
||||
|
||||
self notify("menuresponse", game["menu_changeclass"], "smg_mp");
|
||||
self.bot_change_class = true;
|
||||
|
||||
while(isdefined(self.pers["team"]) && isdefined(self.pers["class"]) && isDefined(self.bot_change_class))
|
||||
wait .05;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Makes sure the bot is on a team.
|
||||
*/
|
||||
teamWatch()
|
||||
{
|
||||
self endon("disconnect");
|
||||
|
||||
for(;;)
|
||||
{
|
||||
while(!isdefined(self.pers["team"]))
|
||||
wait .05;
|
||||
|
||||
wait 0.05;
|
||||
self notify("menuresponse", game["menu_team"], getDvar("bots_team"));
|
||||
|
||||
while(isdefined(self.pers["team"]))
|
||||
wait .05;
|
||||
}
|
||||
}
|
93
main_shared/maps/mp/bots/_bot_utility.gsc
Normal file
93
main_shared/maps/mp/bots/_bot_utility.gsc
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
_bot_utility
|
||||
Author: INeedGames
|
||||
Date: 12/20/2020
|
||||
The shared functions for bots
|
||||
*/
|
||||
|
||||
#include common_scripts\utility;
|
||||
#include maps\mp\_utility;
|
||||
#include maps\mp\gametypes\_hud_util;
|
||||
|
||||
/*
|
||||
Returns an array of all the bots in the game.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
Returns a good amount of players.
|
||||
*/
|
||||
getGoodMapAmount()
|
||||
{
|
||||
switch(getdvar("mapname"))
|
||||
{
|
||||
default:
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Picks a random thing
|
||||
*/
|
||||
PickRandom(arr)
|
||||
{
|
||||
if (!arr.size)
|
||||
return undefined;
|
||||
|
||||
return arr[randomInt(arr.size)];
|
||||
}
|
||||
|
||||
/*
|
||||
Waits for a host player
|
||||
*/
|
||||
bot_wait_for_host()
|
||||
{
|
||||
host = undefined;
|
||||
|
||||
for(i = 0; i < 100; i++)
|
||||
{
|
||||
host = GetHostPlayer();
|
||||
|
||||
if(isDefined(host))
|
||||
break;
|
||||
|
||||
wait 0.05;
|
||||
}
|
||||
|
||||
if(!isDefined(host))
|
||||
return;
|
||||
|
||||
for(i = 0; i < 100; i++)
|
||||
{
|
||||
if(IsDefined( host.pers[ "team" ] ))
|
||||
break;
|
||||
|
||||
wait 0.05;
|
||||
}
|
||||
|
||||
if(!IsDefined( host.pers[ "team" ] ))
|
||||
return;
|
||||
|
||||
for(i = 0; i < 100; i++)
|
||||
{
|
||||
if(host.pers[ "team" ] == "allies" || host.pers[ "team" ] == "axis")
|
||||
break;
|
||||
|
||||
wait 0.05;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user