Inside3D!
     

Bots QC Question

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Fri Jan 29, 2010 8:14 pm    Post subject: Bots QC Question Reply with quote

I'm starting to understand QuakeC more as time goes on.

FrikBot

I'd like to configure a server so that there are always 7 bots playing MINUS the total human players.

Issues:

1. First, I'd need a way to count the bots.
2. Second, how do you make it on changelevel so there is a "think" 10 seconds into the map to start adding bots.
3. I guess I'd also need to count the bots to keep them from affecting vote counts.

More or less, I'd need to always keep one slot open and limit the bots to maxplayers - realplayers -1.
_________________
Tomorrow Never Dies. I feel this Tomorrow knocking on the door ...
Back to top
View user's profile Send private message
ceriux



Joined: 06 Sep 2008
Posts: 969
Location: Florida, USA

PostPosted: Fri Jan 29, 2010 8:44 pm    Post subject: Reply with quote

why not just make a global for players and for bots

for example

maybe something like this?

Code:
void() ClientConnect =
{
   bprint (self.netname);
   bprint (" entered the game\n");
        self.playernum = numplayers;
        numplayers = numplayers +1;

   
// a client connecting during an intermission can cause problems
   if (intermission_running)
      ExitIntermission ();
};


Code:
/*
===========
PutClientInServer

called each time a player is spawned
============
*/
void() DecodeLevelParms;
void() PlayerDie;


void() PutClientInServer =
{
   local   entity spot;

   spot = SelectSpawnPoint ();

   self.classname = "player";
   self.health = 100;
   self.takedamage = DAMAGE_AIM;
   self.solid = SOLID_SLIDEBOX;
   self.movetype = MOVETYPE_WALK;
   self.show_hostile = 0;
   self.max_health = 100;
   self.flags = FL_CLIENT;
   self.air_finished = time + 12;
   self.dmg = 2;         // initial water damage
   self.super_damage_finished = 0;
   self.radsuit_finished = 0;
   self.invisible_finished = 0;
   self.invincible_finished = 0;
   self.effects = 0;
   self.invincible_time = 0;
        self.playernum = self.playernum;

   DecodeLevelParms ();
   
   W_SetCurrentAmmo ();

   self.attack_finished = time;
   self.th_pain = player_pain;
   self.th_die = PlayerDie;
   
   self.deadflag = DEAD_NO;
// paustime is set by teleporters to keep the player from moving a while
   self.pausetime = 0;
   
//   spot = SelectSpawnPoint ();

//   self.origin = spot.origin + '0 0 1';
   self.origin = self.oldorigin = spot.origin + '0 0 1';   // 1998-07-21 Respawning where player died fix by Robert Field
   self.angles = spot.angles;
   self.fixangle = TRUE;      // turn this way immediately

// oh, this is a hack!
   setmodel (self, "progs/eyes.mdl");
   modelindex_eyes = self.modelindex;

   setmodel (self, "progs/player.mdl");
   modelindex_player = self.modelindex;

   setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
   
   self.view_ofs = '0 0 22';
   
   self.velocity = '0 0 0';   // 1998-07-21 Player moves after respawn fix by Xian

   player_stand1 ();
   
   if (deathmatch || coop)
   {
      makevectors(self.angles);
      spawn_tfog (self.origin + v_forward*20);
   }

   spawn_tdeath (self.origin, self);
};



i *think* something like this should work. at least for counting th players.

basically if i did this right, playernum is the players number it gives him a numeric id. and playernums is a global that keeps track of how many players there are (in clientdisconnect id add numplayers -1) or something. this is probably wrong. but im sure im on track of what should be done to keep track of how many players there are in the server you may not even need to keep track of each players number so all you should need is player global "numplayers" and just have it increase and decrease on player connect and disconnect. for each player thats added call an impulse to remove 1 bot and visa versa. give me the src for frik bot and ill see what i can come up with if you want?
_________________
QuakeDB - Quake ModDB Group
Back to top
View user's profile Send private message Yahoo Messenger
Junrall



Joined: 21 Sep 2009
Posts: 136
Location: North West Oregon, USA

PostPosted: Sat Jan 30, 2010 3:38 am    Post subject: Re: Bots QC Question Reply with quote

Baker wrote:
I'm starting to understand QuakeC more as time goes on.

FrikBot

I'd like to configure a server so that there are always 7 bots playing MINUS the total human players.

Issues:

1. First, I'd need a way to count the bots.
2. Second, how do you make it on changelevel so there is a "think" 10 seconds into the map to start adding bots.
3. I guess I'd also need to count the bots to keep them from affecting vote counts.

More or less, I'd need to always keep one slot open and limit the bots to maxplayers - realplayers -1.



I have been slicing away at the Frikbot's innards for a few weeks now... I'm not a Frikbot specialist by no means! However, maybe I can point you in the right directions...

1. First, I'd need a way to count the bots.
First, look in the BotConnect function for self.ishuman = 2; I beleive that you can use this to determine which player is a bot. There are many instances throughout bot.qc that performs this check. Also, nextent is used often to cycle through the player entities for various checks.. such as performing certain tasks only on bots... check out the BotFrame function. So, you could cycle through the player entities with nextent and check each entity with if (self.ishuman == FALSE) to see if it is a bot... now I could be wrong here, but I think the self.ishuman = 2 from the BotConnect function gets changed to self.ishuman = FALSE right after the bot enters the level.

2. Second, how do you make it on changelevel so there is a "think" 10 seconds into the map to start adding bots.
Here is what I did... I'm not sure if this is this the best way... but it does work.
At the top of bot.qc add:
Code:
float botreturntime;

Then goto BotInit and at the top of that add:
Code:
botreturntime = time + 10;

And finally at the bottom of BotFrame... replace:
Code:
if (saved_bots)
      bot_return();

with:
Code:
if (saved_bots && time >= botreturntime)
      bot_return();

The botreturntime = time + 10; is what tells quake to wait for "time + 10" before spawning any bots. In this case 10 was about 30 seconds or so. You'll want to increase this for more time.

3. I guess I'd also need to count the bots to keep them from affecting vote counts.
As far as this one goes... again, you could use nextent and self.ishuman to count the bots.

Hope this helps!
_________________
Good God! You shot my leg off!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group