Quake3World.com Forums
     Programming Discussion
        how do you detect what team a player is on that threw a gren


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




Print view Previous topic | Next topic 
Topic Starter Topic: how do you detect what team a player is on that threw a gren

Grunt
Grunt

Joined: 25 Nov 2009
Posts: 64
PostPosted: 09-03-2011 10:41 PM           Profile Send private message  E-mail  Edit post Reply with quote


(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.




Top
                 

Cool #9
Cool #9

Joined: 01 Dec 2000
Posts: 36787
PostPosted: 09-04-2011 01:16 AM           Profile   Send private message  E-mail  Edit post Reply with quote


ent->client->sess.sessionTeam

this gives you an int which matches any value in the team_t enum:
Code:
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.



_________________
Get mods & maps at Engines of Creation


Top
                 

Recruit
Recruit

Joined: 06 Sep 2011
Posts: 1
PostPosted: 09-06-2011 10:41 AM           Profile Send private message  E-mail  Edit post Reply with quote


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:
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:
if( s1->generic1 == TEAM_BLUE ) {
   ent.customShader = cgs.media.grenadeShaderBlueSmoke; //Or something...
} else {
   ....and something   
}




Top
                 
Quake3World.com | Forum Index | Programming Discussion


Post new topic Reply to topic


cron
Quake3World.com
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group