Пример #1
0
///////////////////////////////////////////////////////////////////////
// Spawn the bot
///////////////////////////////////////////////////////////////////////
void BOT_SpawnBot (char *team, char *name, char *skin, char *userinfo)
{
	edict_t	*bot;

	if( !nav.loaded ) {
		Com_Printf("Can't spawn bots without a valid navigation file\n");
		return;
	}
	
	bot = BOT_FindFreeClient ();
	
	if (!bot)
	{
		safe_bprintf (PRINT_MEDIUM, "Server is full, increase Maxclients.\n");
		return;
	}

	//init the bot
	bot->inuse = true;
	bot->yaw_speed = 100;

	// To allow bots to respawn
	if(userinfo == NULL)
		BOT_SetName(bot, name, skin, team);
	else
		ClientConnect (bot, userinfo);
	
	G_InitEdict (bot);
	G_SpawnAI(bot); //jabot092(2)
	bot->ai->is_bot = true;
	InitClientResp (bot->client);

	PutClientInServer(bot);
	BOT_StartAsSpectator (bot);

	//skill
	bot->ai->pers.skillLevel = (int)(random()*MAX_BOT_SKILL);
	if (bot->ai->pers.skillLevel > MAX_BOT_SKILL)	//fix if off-limits
		bot->ai->pers.skillLevel =  MAX_BOT_SKILL;
	else if (bot->ai->pers.skillLevel < 0)
		bot->ai->pers.skillLevel =  0;

	BOT_DMclass_InitPersistant(bot);
	AI_ResetWeights(bot);
	AI_ResetNavigation(bot);

	bot->think = BOT_JoinGame;
	bot->nextthink = level.time + (int)(random()*6.0);
	if( ctf->value && team != NULL )
	{
		if( !Q_stricmp( team, "blue" ) )
			bot->think = BOT_JoinBlue;
		else if( !Q_stricmp( team, "red" ) )
			bot->think = BOT_JoinRed;
	}
	
	AI_EnemyAdded (bot); // let the ai know we added another
}
Пример #2
0
//==========================================
// BOT_DoSpawnBot
// Spawn the bot
//==========================================
static void BOT_DoSpawnBot( void )
{
	char userinfo[MAX_INFO_STRING];
	int entNum;
	edict_t	*ent;
	static char fakeSocketType[] = "loopback";
	static char fakeIP[] = "127.0.0.1";
	int bot_pers;

	if( !nav.loaded )
	{
		Com_Printf( "AI: Can't spawn bots without a valid navigation file\n" );
		if( g_numbots->integer ) 
			trap_Cvar_Set( "g_numbots", "0" );
		return;
	}

	if( sv_botpersonality->integer )
		bot_pers = sv_botpersonality->integer % BOT_NUMCHARACTERS;
	else
		bot_pers = (int)brandom( 0, BOT_NUMCHARACTERS ) % BOT_NUMCHARACTERS;

	BOT_CreateUserinfo( userinfo, sizeof( userinfo ), bot_pers );

	entNum = trap_FakeClientConnect( userinfo, fakeSocketType, fakeIP );
	if( entNum < 1 )
	{          // 0 is worldspawn, -1 is error
		Com_Printf( "AI: Can't spawn the fake client\n" );
		return;
	}

	ent = &game.edicts[entNum];
	G_SpawnAI( ent );

	//init this bot

	ent->ai->pers.cha = bot_personalities[ bot_pers ];

	BOT_InitPersistant( ent );

	//set up for Spawn
	BOT_Respawn( ent );

	//stay as spectator, give random time for joining
	ent->nextThink = level.time + random() * 8000;
}
Пример #3
0
void M_default_Spawn (void)
{
	edict_t	*ent;
	vec3_t	spawn_origin, spawn_angles;//spawn at a spawnpoint
	vec3_t	mins = {-15, -15, -24};
	vec3_t	maxs = {15, 15, 32};

	ent = G_Spawn();

	G_SpawnAI (ent); //jabot092(2)

	//spawn at a spawnpoint
	SelectSpawnPoint (ent, spawn_origin, spawn_angles);
	spawn_origin[2] += 8;

	//-------------------------------------------------

	// clear entity values
	ent->groundentity = NULL;
	ent->takedamage = DAMAGE_AIM;
	ent->movetype = MOVETYPE_WALK;
	ent->viewheight = 22;
	ent->inuse = true;

	ent->classname = "monster";

	ent->mass = 200;
	ent->solid = SOLID_BBOX;
	ent->deadflag = DEAD_NO;
	ent->air_finished = level.time + 12;
	ent->clipmask = MASK_MONSTERSOLID;
	//ent->model = "models/monsters/infantry/tris.md2";//jalfixme
	ent->waterlevel = 0;
	ent->watertype = 0;
	ent->flags &= ~FL_NO_KNOCKBACK;

	ent->pain = M_default_pain;
	ent->die = M_default_die;

	VectorCopy (mins, ent->mins);
	VectorCopy (maxs, ent->maxs);
	VectorClear (ent->velocity);
	

	ent->s.modelindex = gi.modelindex("models/monsters/infantry/tris.md2");


	// clear entity state values
	ent->s.effects = 0;
	ent->s.frame = 0;

	VectorCopy (spawn_origin, ent->s.origin);
	VectorCopy (ent->s.origin, ent->s.old_origin);

	ent->s.angles[PITCH] = 0;
	ent->s.angles[YAW] = spawn_angles[YAW];
	ent->s.angles[ROLL] = 0;

	if (!KillBox (ent))
	{	// could't spawn in?
	}
	gi.linkentity (ent);

	//finish
	M_default_Start(ent);
}