PDA

View Full Version : bots wont join team



Ni3ls
8th July 2015, 15:21
Hi all,

I'm recreating a zom mod based on Paulus. To test I need some bots.
So I added this in Callback_StartGameType()

thread maps\mp\gametypes\_teams::addTestClients();

I thought that was the only thing needed to add bots with
set scr_testclients NUMBER.
However, they join the game, but don't pick a side. From default _teams.gsc

addTestClients()
{
wait 5;

for(;;)
{
if(getCvarInt("scr_testclients") > 0)
break;
wait 1;
}

testclients = getCvarInt("scr_testclients");
for(i = 0; i < testclients; i++)
{
ent[i] = addtestclient();

if(i & 1)
team = "axis";
else
team = "allies";

ent[i] thread TestClient(team);
}
}

TestClient(team)
{
while(!isdefined(self.pers["team"]))
wait .05;

self notify("menuresponse", game["menu_team"], team);
wait 0.5;

if(team == "allies")
self notify("menuresponse", game["menu_weapon_allies"], "m1carbine_mp");
else if(team == "axis")
self notify("menuresponse", game["menu_weapon_axis"], "mp40_mp");
}

However, I'm not using the default menu's for allies and axis anymore. So is there a way to spawn them instantly? I thought with setting their weapon, team and model manually, but no result and no error

IzNoGoD
8th July 2015, 15:58
have you tried calling the spawnplayer() function on them after setting team and weapon?

Mitch
8th July 2015, 17:16
I thought that was the only thing needed to add bots with
set scr_testclients NUMBER.
However, they join the game, but don't pick a side. From default _teams.gsc

However, I'm not using the default menu's for allies and axis anymore. So is there a way to spawn them instantly? I thought with setting their weapon, team and model manually, but no result and no error

You need to let your bots join a team via auto assign. This is the way you join a team in a zombie mod.


team = "autoassign";
self notify("menuresponse", game["menu_team"], team);

Edit: Also it might be easier to test if you can add and remove bots via ! commands.

Tally
8th July 2015, 19:08
have you tried calling the spawnplayer() function on them after setting team and weapon?

^THIS^

There is a common misconception that a bot has to necessarily pass through menus in order to spawn. This is not the case. The only thing a bot needs is: 1) to be assigned to a team (this is just a string such as "axis"); 2) given a weapon for the player weapon struct: i.e. self.pers["weapon"] = <weapon name> (this is necessary for the next step); and 3) to pass through the player spawn method as Izno points out. That is all they need. The only reason why the original Infinity Ward bot script passed them through menus is because that is an easy way to do it. But, as I say, it isn't the only way. In fact, it uses redundant methods to do something quite simple as my 3 step bot spawn.

Here is a bot spawn script using the 3 step method:


addTestClients()
{
wait 5;

for( ;; )
{
if( getCvarInt( "scr_testclients" ) > 0 )
break;
wait 1;
}

iNumBots = getCvarInt( "scr_testclients" );

for( i = 0; i < iNumBots; i++ )
{
ent[i] = addtestclient();
Bot = ent[i];
wait 0.5;

if( isPlayer( Bot ) )
{
if( i & 1 )
{
Bot.pers["team"] = "allies";
Bot.pers["weapon"] = "thompson_mp";
wait( 0.5 );
Bot maps\mp\gametypes\[gametype_name]::spawnPlayer();

}
else
{
Bot.pers["team"] = "axis";
Bot.pers["weapon"] = "mp40_mp";
wait( 0.5 );
Bot maps\mp\gametypes\[gametype_name]::spawnPlayer();
}
}
}
}


Replace [gametype_name] with the name of the gametype you are playing. As it is a zombie gametype, I would assume it would be "zom":


Bot maps\mp\gametypes\zom::spawnPlayer();

Ni3ls
9th July 2015, 09:27
Yeah i already tried that

addTestClients()
{
wait 5;

for(;;)
{
if(getCvarInt("scr_testclients") > 0)
break;
wait 1;
}

testclients = getCvarInt("scr_testclients");
for(i = 0; i < testclients; i++)
{
ent[i] = addtestclient();
team = "axis";
ent[i] thread TestClient(team);
}
}

TestClient(team)
{
while(!isdefined(self.pers["team"]))
wait .05;
self.pers["team"]="axis";
self.sessionteam = "axis";
self.pers["weapon"]="thompson_mp";
if(!isDefined(self.pers["savedmodel"]))
maps\mp\gametypes\_teams::model();
else
maps\mp\_utility::loadModel(self.pers["savedmodel"]);
self maps\mp\gametypes\evilzom::SpawnPlayer();
}

I will try to other codes and report back

EDIT:
Code of tally is working!