How to disable SPECTATOR_FOLLOW on bots?

Locked
leo9949
Posts: 5
Joined: Thu Dec 03, 2015 1:15 pm

How to disable SPECTATOR_FOLLOW on bots?

Post by leo9949 »

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!!
User avatar
Eraser
Posts: 19174
Joined: Fri Dec 01, 2000 8:00 am

Re: How to disable SPECTATOR_FOLLOW on bots?

Post by Eraser »

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

Code: Select all

qboolean IsBot( gentity_t *self ) {
	return (self->r.svFlags & SVF_BOT);
}
leo9949
Posts: 5
Joined: Thu Dec 03, 2015 1:15 pm

Re: How to disable SPECTATOR_FOLLOW on bots?

Post by leo9949 »

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: Select all

// 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: Select all

	// 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)
User avatar
Eraser
Posts: 19174
Joined: Fri Dec 01, 2000 8:00 am

Re: How to disable SPECTATOR_FOLLOW on bots?

Post by Eraser »

Right, I also have this code:

Code: Select all

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.
leo9949
Posts: 5
Joined: Thu Dec 03, 2015 1:15 pm

Re: How to disable SPECTATOR_FOLLOW on bots?

Post by leo9949 »


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: Select all

[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 :)
User avatar
Eraser
Posts: 19174
Joined: Fri Dec 01, 2000 8:00 am

Re: How to disable SPECTATOR_FOLLOW on bots?

Post by Eraser »

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