how do you detect what team a player is on that threw a gren

Locked
bludshot
Posts: 65
Joined: Thu Nov 26, 2009 6:14 am

how do you detect what team a player is on that threw a gren

Post by bludshot »

(This seems very basic to me, but I haven't been able to find it in lots of searching)

In CG_Missile() in cg_ents.c, my mod has smoke grenades that you can throw. I need to do:

switch ( PlayerTeam ) {
case TEAM_RED:
etc...

But I don't know how to get the player's team? I tried to get clientnum and check from that but it seems to be the number of the grenade itself not the player.

I want the smoke to be blue when the player who threw the smoke grenade is on the blue team, and red when he's on the red team, and the only part I haven't figured out about that is knowing which team they are on.
User avatar
Eraser
Posts: 19174
Joined: Fri Dec 01, 2000 8:00 am

Re: how do you detect what team a player is on that threw a gren

Post by Eraser »

ent->client->sess.sessionTeam

this gives you an int which matches any value in the team_t enum:

Code: Select all

typedef enum {
	TEAM_FREE,
	TEAM_RED,
	TEAM_BLUE,
	TEAM_SPECTATOR,

	TEAM_NUM_TEAMS
} team_t;
A player's team is TEAM_FREE in non-team games.
MdQvack
Posts: 1
Joined: Tue Sep 06, 2011 6:17 pm

Re: how do you detect what team a player is on that threw a gren

Post by MdQvack »

I think this is what you're looking for:

1) In G_missile.c
At the end of *fire_grenade (right before 'return bolt;') add:

Code: Select all

if (self->client)
    bolt->s.generic1 = self->client->sess.sessionTeam;
2) In CG_ents.c
In function CG_missile (for example after 'ent.renderfx = weapon->missileRenderfx | RF_NOSHADOW;') add:

Code: Select all

if( s1->generic1 == TEAM_BLUE ) {
	ent.customShader = cgs.media.grenadeShaderBlueSmoke; //Or something...
} else {
	....and something	
}
Locked