Inside3D!
     

How to preserve a player's shirt color on QC?

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
Orion



Joined: 12 Jan 2007
Posts: 414
Location: Brazil

PostPosted: Fri Sep 18, 2009 5:53 pm    Post subject: How to preserve a player's shirt color on QC? Reply with quote

I made a clan arena-style mod, and to indicate that a player is dead, it turns white by stuffcmd(). You can change your shirt color at any time, but you can't change your pants color.

I know that pants color is detected by using (self.team - 1), what about shirt color?

.colormap won't work, it just puts the colors of a specified client number into another entity.

For example, I enter the game on blue team with color 11(green shirt) and 13(blue pants).

As I don't know hot to preserve the shirt color, if you die and after some time the round ends, you'll return all blue using stuffcmd().
As I said above, if you die you'll go white.
_________________
There's no signature here. Stop looking for one.
Back to top
View user's profile Send private message
ceriux



Joined: 06 Sep 2008
Posts: 969
Location: Florida, USA

PostPosted: Fri Sep 18, 2009 5:59 pm    Post subject: Reply with quote

have you tried like self.shirt = x i think i did something like that once lemme see if i can find how i did it.


edit: i think the "shirt" comment was for dp only... but i looked through defs.qc and i see that you said "team" changes your pants color... have you tried using "colormap" ?

because right above team i see this :

.float colormap;
.float team;
_________________
QuakeDB - Quake ModDB Group
Back to top
View user's profile Send private message Yahoo Messenger
Orion



Joined: 12 Jan 2007
Posts: 414
Location: Brazil

PostPosted: Fri Sep 18, 2009 6:37 pm    Post subject: Reply with quote

No.
In fact, colormap stores you client number (1-16).

For example, you spawn a clone that kills enemies for you, and if you want him to use the same colors as you, you'd give it (clone.colormap = self.colormap;).

It doesn't work on glquake for non-client entities (except darkplaces), but works on gl quakeworld. Wink
_________________
There's no signature here. Stop looking for one.
Back to top
View user's profile Send private message
ceriux



Joined: 06 Sep 2008
Posts: 969
Location: Florida, USA

PostPosted: Fri Sep 18, 2009 7:02 pm    Post subject: Reply with quote

whats modelindex?
_________________
QuakeDB - Quake ModDB Group
Back to top
View user's profile Send private message Yahoo Messenger
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Fri Sep 18, 2009 7:25 pm    Post subject: Reply with quote

colormap is an index into a table. the only way to change the colours with it is to stuffcmd... not nice.
In unmodified quake, you only know the lower colour from the .team field.

in darkplaces, you can use .playercolors. its a bitfield (two parts, both 4 bits) that states the colours the player wants to use. just reset the lower colour to the correct team.
Course, that only works in darkplaces/FTE.

In Quakeworld you can stuffcmd a setinfo command to change their bottomcolor back to what it should have been.
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
ceriux



Joined: 06 Sep 2008
Posts: 969
Location: Florida, USA

PostPosted: Fri Sep 18, 2009 7:31 pm    Post subject: Reply with quote

Spike wrote:
colormap is an index into a table. the only way to change the colours with it is to stuffcmd... not nice.
In unmodified quake, you only know the lower colour from the .team field.

in darkplaces, you can use .playercolors. its a bitfield (two parts, both 4 bits) that states the colours the player wants to use. just reset the lower colour to the correct team.
Course, that only works in darkplaces/FTE.

In Quakeworld you can stuffcmd a setinfo command to change their bottomcolor back to what it should have been.


but, hes asking about the top color.
_________________
QuakeDB - Quake ModDB Group
Back to top
View user's profile Send private message Yahoo Messenger
LordHavoc



Joined: 05 Nov 2004
Posts: 243
Location: western Oregon, USA

PostPosted: Fri Sep 18, 2009 8:26 pm    Post subject: Reply with quote

Spike wrote:
colormap is an index into a table. the only way to change the colours with it is to stuffcmd... not nice.
In unmodified quake, you only know the lower colour from the .team field.

in darkplaces, you can use .playercolors. its a bitfield (two parts, both 4 bits) that states the colours the player wants to use. just reset the lower colour to the correct team.
Course, that only works in darkplaces/FTE.

In Quakeworld you can stuffcmd a setinfo command to change their bottomcolor back to what it should have been.


You mean .clientcolors

There is also the DP_SV_SETCOLOR extension which intercepts color change attempts and lets the qc do whatever it wants (such as preserving shirt color but forcing team color), it was added specifically for this purpose several years ago (I used to maintain a clanring ctf mod for my clan, and always wished it had this feature).

But in the Clan Arena mod I recall you chose team in the ingame menu, and then chose shirt color, it simply stuffed the command and waited for you to change (this actually held up the game if anyone was suffering heavy packet loss).
Back to top
View user's profile Send private message Visit poster's website
Dr. Shadowborg
Inside3D Staff


Joined: 16 Oct 2004
Posts: 726

PostPosted: Sat Sep 19, 2009 3:33 am    Post subject: Reply with quote

Why not just use a player skin with all the shirt / pants colors substituted for white instead?
_________________
"Roboto suggests Plasma Bazooka."
Back to top
View user's profile Send private message
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Sat Sep 19, 2009 4:56 am    Post subject: Reply with quote

DR, i think its implied for the scoreboard output?

Code:

void(entity ent, float clientshirt, float clientpants) setcolor =
{
   local float client;

   client = (ent.colormap - 1);

   msg_entity = ent;
   WriteByte (MSG_ALL, SVC_UPDATECOLORS);
   WriteByte (MSG_ALL, client);
   WriteByte (MSG_ALL, ((clientshirt * 16) + clientpants));
};

//JPG's HACK! REQUIRES ENGINE OFFSETS
//ie float CL_COLORS         = %2032;
float () get_top_color =
{
   local float tc;

   tc = floor((self.cl[CL_COLORS] / %1) / 16);

   return tc;
};
Back to top
View user's profile Send private message
LordHavoc



Joined: 05 Nov 2004
Posts: 243
Location: western Oregon, USA

PostPosted: Mon Sep 21, 2009 6:45 pm    Post subject: Reply with quote

r00k wrote:
Code:
//JPG's HACK! REQUIRES ENGINE OFFSETS


I don't think it's wise to even bring up the idea of engine hacks.

The DP_SV_SETCOLOR extension was created entirely for this purpose, and has been around for many years (2000 or 2001).

If you need a feature and an engine does not have it, complain to the author of that engine, or add it yourself.
Back to top
View user's profile Send private message Visit poster's website
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Mon Sep 21, 2009 7:02 pm    Post subject: Reply with quote

So should it be ?
Code:

shirt = floor((self.clientcolors / %1) / 16);


I'll have to look at the extension...
Back to top
View user's profile Send private message
LordHavoc



Joined: 05 Nov 2004
Posts: 243
Location: western Oregon, USA

PostPosted: Mon Sep 21, 2009 7:11 pm    Post subject: Reply with quote

r00k wrote:
So should it be ?
Code:

shirt = floor((self.clientcolors / %1) / 16);


I'll have to look at the extension...


No, that's part of the DP_SV_BOTCLIENT extension (which lets you spawn bots in client slots and make use of player physics, and display properly on the scoreboard of course), it's a much later extension, both are good though Smile
Back to top
View user's profile Send private message Visit poster's website
ceriux



Joined: 06 Sep 2008
Posts: 969
Location: Florida, USA

PostPosted: Mon Sep 21, 2009 8:54 pm    Post subject: Reply with quote

LordHavoc wrote:
r00k wrote:
So should it be ?
Code:

shirt = floor((self.clientcolors / %1) / 16);


I'll have to look at the extension...


No, that's part of the DP_SV_BOTCLIENT extension (which lets you spawn bots in client slots and make use of player physics, and display properly on the scoreboard of course), it's a much later extension, both are good though Smile


actually that should work. it worked for me, i assigned the shirt color through a menu, although the clientcolors are for the pants, you can if you just set pants it just changes the colors on the scoreboard. (maybe the same with the shirt) but like someone said earlier he could still set the score board color to the one he wants then make the change permanent with a skin =)

and actually i think i did this.

shirt = 1; i think and it seemed to work. i dont remember though.


//DP_SV_CLIENTCOLORS
//idea: LordHavoc
//darkplaces implementation: LordHavoc
//field definitions:
.float clientcolors; // colors of the client (format: pants + shirt * 16)
//description:
//allows qc to read and modify the client colors associated with a client entity (not particularly useful on other entities), and automatically sends out any appropriate network updates if changed
_________________
QuakeDB - Quake ModDB Group
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group