Quake3World.com
https://www.quake3world.com/forum/

How to disable SPECTATOR_FOLLOW on bots?
https://www.quake3world.com/forum/viewtopic.php?f=16&t=51597
Page 1 of 1

Author:  leo9949 [ 12-06-2015 08:12 AM ]
Post subject:  How to disable SPECTATOR_FOLLOW on bots?

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!!

Author:  Eraser [ 12-07-2015 12:29 AM ]
Post subject:  Re: How to disable SPECTATOR_FOLLOW on bots?

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);
}

Author:  leo9949 [ 12-07-2015 04:43 AM ]
Post subject:  Re: How to disable SPECTATOR_FOLLOW on bots?

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)

Author:  Eraser [ 12-07-2015 05:20 AM ]
Post subject:  Re: How to disable SPECTATOR_FOLLOW on bots?

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.

Author:  leo9949 [ 12-07-2015 10:50 AM ]
Post subject:  Re: How to disable SPECTATOR_FOLLOW on bots?


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 :)

Author:  Eraser [ 12-08-2015 01:10 AM ]
Post subject:  Re: How to disable SPECTATOR_FOLLOW on bots?

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

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/