Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

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

| Inside3d Forums Forum Index -> QuakeC Programming

View previous topic :: View next topic
Author | Message
--- | ---
Orion Joined: 12 Jan 2007 Posts: 414 Location: Brazil |

Posted: Fri Sep 18, 2009 5:53 pm Post subject: How to preserve a player's shirt color on QC? |

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 |

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

Posted: Fri Sep 18, 2009 5:59 pm Post subject: |

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 |

Orion Joined: 12 Jan 2007 Posts: 414 Location: Brazil |

Posted: Fri Sep 18, 2009 6:37 pm Post subject: |

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.
_________________
There's no signature here. Stop looking for one.

Back to top |

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

Posted: Fri Sep 18, 2009 7:02 pm Post subject: |

whats modelindex? _________________ QuakeDB - Quake ModDB Group

Back to top |

Spike Joined: 05 Nov 2004 Posts: 944 Location: UK |

Posted: Fri Sep 18, 2009 7:25 pm Post subject: |

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 |

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

Posted: Fri Sep 18, 2009 7:31 pm Post subject: |

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 |

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

Posted: Fri Sep 18, 2009 8:26 pm Post subject: |

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 |

Dr. Shadowborg Inside3D Staff Joined: 16 Oct 2004 Posts: 726 |

Posted: Sat Sep 19, 2009 3:33 am Post subject: |

Why not just use a player skin with all the shirt / pants colors substituted for white instead? _________________ "Roboto suggests Plasma Bazooka."

Back to top |

r00k Joined: 13 Nov 2004 Posts: 483 |

Posted: Sat Sep 19, 2009 4:56 am Post subject: |

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 |

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

Posted: Mon Sep 21, 2009 6:45 pm Post subject: |

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 |

r00k Joined: 13 Nov 2004 Posts: 483 |

Posted: Mon Sep 21, 2009 7:02 pm Post subject: |

So should it be ?

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

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

Back to top |

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

Posted: Mon Sep 21, 2009 7:11 pm Post subject: |

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

Back to top |

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

Posted: Mon Sep 21, 2009 8:54 pm Post subject: |

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

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 |

Display posts from previous:

| 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