Forum

Spawning Bots Using PutClientInServer();

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Spawning Bots Using PutClientInServer();

Postby Junrall » Mon Jan 18, 2010 2:23 am

Ok... maybe I'm hopping in way over my head...

Back in the day a person would spawn a bot using something similar to spawning monsters. Now days I've noticed that people are creating bots by using:
SetNewParms();
ClientConnect();
PutClientInServer();

I've tried dissecting FrikaBot... wow, is my head swimming. (No worries Frika... I didn't scratch or dent him!)
As you probably know, using the three functions above, by themselves, just causes you to respawn elsewhere in the level. Well, respawn is probably not right... I assume that you are just re-created as a new player then spawned at the next spawning spot.

Should I be looking the Rankings code borrowed from Alan Kivlin?

Is there any info on this stuff that a fellow can look over? A tutorial or maybe some of you can break it down for me?

Sorry for the lack of AI on my part... I've been out of the scene since 1998!
Good God! You shot my leg off!
User avatar
Junrall
 
Posts: 191
Joined: Mon Sep 21, 2009 12:27 am
Location: North West Oregon, USA

Postby Sajt » Mon Jan 18, 2010 2:14 pm

The first thing you must know is about the "self" global variable. Those functions do a bunch of crap to "self". You have to make sure "self" is set to the proper entity before calling them. So you might spawn an entity, set self to point to it, then call those functions. But I have no idea if those functions are safe out-of-the-box to call on non-clients. FrikBot may have made modifications.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby c0burn » Mon Jan 18, 2010 2:23 pm

FrikBot uses actual client slots so they are safe to call.

Have a look at BotConnect() from bot.qc - in fact for a first bot I would recommend taking FrikBot and ripping the AI out to save you reinventing the wheel on the boring stuff.
c0burn
 
Posts: 208
Joined: Fri Nov 05, 2004 12:48 pm
Location: Liverpool, England

Postby Junrall » Tue Jan 19, 2010 5:29 am

c0burn wrote:FrikBot uses actual client slots so they are safe to call.

Have a look at BotConnect() from bot.qc - in fact for a first bot I would recommend taking FrikBot and ripping the AI out to save you reinventing the wheel on the boring stuff.


Yeah, I had thought about doing that.

My goal is to create a simple bot base/skeleton that is up to par with modern Quake bots... spawning as a client, using client physics, today's current ranking system, and directional movement code.
Besides creating a "modernized" bot base... I hope to learn something from the experience. And be able to contribute something to the Quake community here.

I know... I know... there are a few bots out there that are good as a simple bot base. Unfortunately they are outdated (but still good to look at) and I understand that FrikaBot is considered to be a good bot base... however, it has grown up quite a bit and is a bit beyond a simple bot base. Don't get me wrong... FrikaBot is a great bot... but is more of a plug-and-play bot now days.

Anyways, I'm open for tips, suggestions, or just general chatter on this subject.
Maybe FrikaC wouldn't mind me ripping his bot back down to something simpler... 'shudder' it'd be ugly and probably broken in a few places!
Good God! You shot my leg off!
User avatar
Junrall
 
Posts: 191
Joined: Mon Sep 21, 2009 12:27 am
Location: North West Oregon, USA

Postby c0burn » Tue Jan 19, 2010 6:06 am

MauveBot is a very basic DP only bot - and it uses spawnclient() builtin to avoid any messy stuff.

Maybe look into that.
c0burn
 
Posts: 208
Joined: Fri Nov 05, 2004 12:48 pm
Location: Liverpool, England

Postby Junrall » Tue Jan 19, 2010 6:27 am

c0burn wrote:MauveBot is a very basic DP only bot - and it uses spawnclient() builtin to avoid any messy stuff.

Maybe look into that.


I have been playing around with DP's bot spawning capabilities. I like this method very much as it is very easy.
The only downfall to a DP bot is that it will always require DP to run... though, it would provide less code to look
through for someone new to bot programming.
I myself lean towards the freedom to use a bot on any engine.
Good God! You shot my leg off!
User avatar
Junrall
 
Posts: 191
Joined: Mon Sep 21, 2009 12:27 am
Location: North West Oregon, USA

Postby Junrall » Thu Jan 21, 2010 6:45 am

Well, I've been picking apart the FrikaBot bot connection and client checking code and am puzzling it out! Slowly but surely! :P

I do have a few of questions though...

If there are 16 slots available when I alone enter Quake, which slot do I fill... Slot 1 or slot 16?

I noticed that nextent() was used to cycle through entities. Does this cycle through all entities or just the player entities?

The following code suggests that nextent() only cycles through player entities OR player entities are at the end of an "entity list" and nextent() cycles backwards through that list. Are either of these thoughts correct? Or do I need to keep digging?

Code: Select all
   ent = nextent(world);
   max_clients = 0;

   while(ent != world)
   {
      max_clients = max_clients + 1;
      ent = nextent(ent);
   }
   if (max_clients > 16)
      max_clients = 16;
Good God! You shot my leg off!
User avatar
Junrall
 
Posts: 191
Joined: Mon Sep 21, 2009 12:27 am
Location: North West Oregon, USA

Postby c0burn » Thu Jan 21, 2010 7:42 am

On a listen server, you're slot 1. The world is slot 0. The rest of the clients/bots are 2-16.

Nextent cycles through all entities, but that code is called from worldspawn() if I'm remembering rightly so at that time there are only the world and client entities created by the engine. It's just Frik taking advantage of that knowledge so he can count how many client slots there are (you can't read "maxplayers" from QC as it's a command not a cvar).
c0burn
 
Posts: 208
Joined: Fri Nov 05, 2004 12:48 pm
Location: Liverpool, England

Postby Junrall » Thu Jan 21, 2010 7:50 pm

Thanks c0burn... that totally makes sense and clears up the muddy water a bit!
Good God! You shot my leg off!
User avatar
Junrall
 
Posts: 191
Joined: Mon Sep 21, 2009 12:27 am
Location: North West Oregon, USA


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest