Quake3World.com Forums
     Programming Discussion
        How to disable SPECTATOR_FOLLOW on bots?


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: How to disable SPECTATOR_FOLLOW on bots?

Recruit
Recruit
Joined: 03 Dec 2015
Posts: 5
PostPosted: 12-06-2015 08:12 AM           Profile Send private message  E-mail  Edit post Reply with quote


Hi!

Does anyone know how I could disable spectating a bot? (such as that using cmds /follow <clientnumber> or /follownext wouldn't allow SPECTATOR FOLLOW on the bot; following humanplayers should then still remain functional though).

If so, could they shed some light on this?

I've searched a lot of open-source q3 mods and forums for this, but yet haven't found the answer..

Is it perhaps simply in g_active.c "SpectatorClientEndFrame" section?


I'm asking this because I'm making a 'boss'-fight map, with the bot remaining in a 'hidden' area :)

The Goal I want to achieve: make it impossible to spectate bots

Thanks!!




Top
                 

Cool #9
Cool #9
Joined: 01 Dec 2000
Posts: 44131
PostPosted: 12-07-2015 12:29 AM           Profile   Send private message  E-mail  Edit post Reply with quote


Not sure how the spectating code works exactly, but you can check if a client is a bot like this:

Code:
qboolean IsBot( gentity_t *self ) {
   return (self->r.svFlags & SVF_BOT);
}




Top
                 

Recruit
Recruit
Joined: 03 Dec 2015
Posts: 5
PostPosted: 12-07-2015 04:43 AM           Profile Send private message  E-mail  Edit post Reply with quote


Thanks for the quick reply!

So far I've managed to disable speccing blue/red team (in team modes) in g_cmds.c (Cmd_Follow_f and Cmd_Follow_Cycle_f), by simply adding the lines:


Code:
// can't follow blue team
if ( level.clients[ i ].sess.sessionTeam == TEAM_BLUE ) {
      return;
   }


(I copied that from "can't follow spectator" part)

now, I guess I'm not too far from disabling speccing bots..

there's also this (right above previous code):


Code:
   // can't follow self
   if ( &level.clients[ i ] == ent->client ) {
      return;
   }


now, how do I replace ent->client with bot?

thx again! (only recently began learning c/ c++ code :D)

I also think your EntityPlus code is groundbreaking! (it further got me interested in coding, since I began as a mapper)




Top
                 

Cool #9
Cool #9
Joined: 01 Dec 2000
Posts: 44131
PostPosted: 12-07-2015 05:20 AM           Profile   Send private message  E-mail  Edit post Reply with quote


Right, I also have this code:

Code:
qboolean IsClientBot( gclient_t *client ) {
   gentity_t *ent;
   int i;

   for (i = 0; i < MAX_CLIENTS; i++) {
      ent = &g_entities[i];
      if ( ent->client->ps.clientNum == client->ps.clientNum )
         return IsBot( ent );
   }

   return qfalse;
}


But it looks like there's a bug in there. It's never called in my own code, so that's very well possible.
I think what's wrong here is that it iterates from 0 to MAX_CLIENTS, but I expect it should iterate to MAX_GENTITIES instead, otherwise it would only iterate through the first 64 entities while there's room for 1024 entities in there.




Top
                 

Recruit
Recruit
Joined: 03 Dec 2015
Posts: 5
PostPosted: 12-07-2015 10:50 AM           Profile Send private message  E-mail  Edit post Reply with quote



Hi! I managed to find the right place for the code, after a bit of trial-and-error.. First off let me clear up the fact that I'm coding/ mapping for Star Wars, Jedi Outcast MP 1.02, and not first and foremostly for Q3 1.32. :)

So that there are a few slight differences/ changes to functions etc. (after all, jk2 is an extensive Quake 3 'mod' after all, some might say..)

I don't know exactly how and where the 'qboolean isBot' is defined originally in jk2, but I reached my goal by simply adding these lines to
Cmd_Follow_f and Cmd_FollowCycle_f (yellow being the color of the lines I added):

Code:
[size=85]
/*
=================
Cmd_Follow_f
=================
*/
void Cmd_Follow_f( gentity_t *ent ) {
   int      i;
   char   arg[MAX_TOKEN_CHARS];
   qboolean   isBot;

...

   // can't follow bots
   if (!isBot) {
      return;
   }

........................

/*
=================
Cmd_FollowCycle_f
=================
*/
void Cmd_FollowCycle_f( gentity_t *ent, int dir ) {
   int      clientnum;
   int      original;
   qboolean   isBot;

...

      // can't follow bots
      if (!isBot) {
      return;
      }
[/size]

qboolean isBot;

...



// can't follow bots
if (!isBot) {
return;
}


Thanks for the help! Really wouldn't have minded to look in the right places without it!

It's good to be persistent in solving a problem sometimes, as it opens up new doors and ideas.. I also learned how to disable spectating a team in team-mode :)




Top
                 

Cool #9
Cool #9
Joined: 01 Dec 2000
Posts: 44131
PostPosted: 12-08-2015 01:10 AM           Profile   Send private message  E-mail  Edit post Reply with quote


Uh, the IsBot call is a call to the IsBot function I posted earlier. Both functions I posted are functions I wrote myself.




Top
                 
Quake3World.com | Forum Index | Programming Discussion


Post new topic Reply to topic


cron
Quake3World.com
© ZeniMax. Zenimax, QUAKE III ARENA, Id Software and associated trademarks are trademarks of the ZeniMax group of companies. All rights reserved.
This is an unofficial fan website without any affiliation with or endorsement by ZeniMax.
All views and opinions expressed are those of the author.