level.bots

This commit is contained in:
INeedBots
2020-10-02 15:08:47 -06:00
parent 3d327af52d
commit cfd1d6e8e3
3 changed files with 37 additions and 29 deletions

View File

@ -94,6 +94,8 @@ init()
level.botPushOutDist = 30;
level.smokeRadius = 255;
level.bots = [];
level.bots_nonfullautoguns = [];
level.bots_nonfullautoguns["barrett"] = true;
@ -360,6 +362,16 @@ watchScrabler()
}
}
/*
When a bot disconnects.
*/
onDisconnect()
{
self waittill("disconnect");
level.bots = array_remove(level.bots, self);
}
/*
Called when a player connects.
*/
@ -388,6 +400,9 @@ connected()
self thread maps\mp\bots\_bot_internal::connected();
self thread maps\mp\bots\_bot_script::connected();
level.bots[level.bots.size] = self;
self thread onDisconnect();
level notify("bot_connected", self);
}

View File

@ -14,6 +14,9 @@ init()
{
if (getDvar("bots_main_menu") == "")
setDvar("bots_main_menu", true);
if (!getDvarInt("bots_main_menu"))
return;
thread watchPlayers();
}
@ -28,9 +31,6 @@ watchPlayers()
{
player = level.players[i];
if (!getDvarInt("bots_main_menu"))
continue;
if (!player is_host())
continue;
@ -107,8 +107,7 @@ doGreetings()
wait 1;
self iPrintln("Welcome to Bot Warfare "+self.name+"!");
wait 5;
if(getDvarInt("bots_main_menu"))
self iPrintln("Press [{+actionslot 2}] to open menu!");
self iPrintln("Press [{+actionslot 2}] to open menu!");
}
watchPlayerOpenMenu()
@ -122,11 +121,8 @@ watchPlayerOpenMenu()
self waittill( "bots_open_menu" );
if(!self.menuOpen)
{
if(getdvarint("bots_main_menu"))
{
self playLocalSound( "mouse_click" );
self thread OpenSub(self.SubMenu);
}
self playLocalSound( "mouse_click" );
self thread OpenSub(self.SubMenu);
}
else
{
@ -154,7 +150,7 @@ MenuSelect()
for(;;)
{
self waittill( "bots_select" );
if(self.MenuOpen && getdvarint("bots_main_menu"))
if(self.MenuOpen)
{
self playLocalSound( "mouse_click" );
if(self.SubMenu == "Main")