bot_wait_for_host

This commit is contained in:
INeedBots 2020-12-20 22:05:36 -06:00
parent ebdf5a2268
commit 28da2ce20b
2 changed files with 60 additions and 0 deletions

View File

@ -686,6 +686,8 @@ addBots()
{ {
level endon("game_ended"); level endon("game_ended");
bot_wait_for_host();
for(;;) for(;;)
{ {
wait 1.5; wait 1.5;

View File

@ -530,6 +530,64 @@ notifyAfterDelay(delay, not)
self notify(not); self notify(not);
} }
/*
Gets a player who is host
*/
GetHostPlayer()
{
for (i = 0; i < level.player.size; i++)
{
player = level.players[i];
if (!player is_host())
continue;
return player;
}
return undefined;
}
/*
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;
}
}
/* /*
Pezbot's line sphere intersection. Pezbot's line sphere intersection.
http://paulbourke.net/geometry/circlesphere/raysphere.c http://paulbourke.net/geometry/circlesphere/raysphere.c