thanks to ^misantropia^ i resolved this whole thing so i will post here the code i make
the next step (i'm working on it but suggetions are very welcome) is about:
put the client owned ammunitions next to the weapon select bar.
this is my code in order to have (using only console cvars ... hopefully later implemented inside the ui) a selectable classic, left side or right side weapon bar:
STEP ONE
mod cg_local.h inside cgame directory and add
STEP TWO
mod cg_main.c ever inside cgame directory and add
Code: Select all
vmCvar_t cg_AmmoBarStyle;
{ &cg_AmmoBarStyle, "cg_AmmoBarStyle", "0", CVAR_ARCHIVE}
so the default value for cvar cg_AmmoBarStyle will be 0 (classic quake 3 Arena ammo bar)
STEP THREE
let's open your cg_weapons.c ever in cgame directory (clientside because this "mods" will affects only the client and not the server or what other players will se)
that's my code:
Code: Select all
===================
CG_DrawWeaponSelect
===================
*/
void CG_DrawWeaponSelect( void ) {
int i;
int bits;
int count;
int x, y, w;
char *name;
float *color;
// don't display if dead
if ( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) {
return;
}
if (cg_AmmoBarStyle.integer <= 0) { //3X CODE classic bar only half size icons
color = CG_FadeColor( cg.weaponSelectTime, WEAPON_SELECT_TIME );
if ( !color ) {
return;
}
trap_R_SetColor( color );
// showing weapon select clears pickup item display, but not the blend blob
cg.itemPickupTime = 0;
// count the number of weapons owned
bits = cg.snap->ps.stats[ STAT_WEAPONS ];
count = 0;
for ( i = 1 ; i < 16 ; i++ ) {
if ( bits & ( 1 << i ) ) {
count++;
}
}
x = 320 - count * 20;
y = 380;
for ( i = 1 ; i < 16 ; i++ ) {
if ( !( bits & ( 1 << i ) ) ) {
continue;
}
CG_RegisterWeapon( i );
// draw weapon icon
CG_DrawPic( x, y, 32/2, 32/2, cg_weapons[i].weaponIcon );
// draw selection marker
if ( i == cg.weaponSelect ) {
CG_DrawPic( x-2, y-2, 40/2, 40/2, cgs.media.selectShader ); //3X CODE mod from -4 to -2 for half size icons
}
// no ammo cross on top
if ( !cg.snap->ps.ammo[ i ] ) {
CG_DrawPic( x, y, 32/2, 32/2, cgs.media.noammoShader );
}
x += 40/2;
}
// draw the selected name
if ( cg_weapons[ cg.weaponSelect ].item ) {
name = cg_weapons[ cg.weaponSelect ].item->pickup_name;
if ( name ) {
w = CG_DrawStrlen( name ) * BIGCHAR_WIDTH;
x = ( SCREEN_WIDTH - w ) / 2;
CG_DrawBigStringColor(x, y - 22, name, color);
}
}
trap_R_SetColor( NULL );
}
else if (cg_AmmoBarStyle.integer == 1) { //3X CODE left side modern bar
bits = cg.snap->ps.stats[ STAT_WEAPONS ];
count = 0;
for ( i = 1 ; i < 16 ; i++ ) {
if ( bits & ( 1 << i ) ) {
count++;
}
}
x = 4; //3X CODE put the x coordinate at 4 for the bar
y = 80; //3X CODE put the bar at 1/6 of y screeb resolution 640x480
for ( i = 1 ; i < 16 ; i++ ) {
if ( !( bits & ( 1 << i ) ) ) {
continue;
}
CG_RegisterWeapon( i );
// 3X CODE modify half size icons for modern display resolutions
CG_DrawPic( x, y, 32/2, 32/2, cg_weapons[i].weaponIcon );
// draw selection marker 3X CODE Modify for a more modern display halfsize
if ( i == cg.weaponSelect ) {
CG_DrawPic( x-4/2, y-4/2, 40/2, 40/2, cgs.media.selectShader );
}
// remove the no ammo cross because is useless if i add ammo owned for all weapons
y += 40/2; // 3X CODE halfsize for icons and use y axis for vertical ammo display
}
// draw the selected name 3X CODE remove this because is useless for old gamers of Q3A
trap_R_SetColor( NULL );
}
else if (cg_AmmoBarStyle.integer >= 2) { //3X CODE right side modern bar
bits = cg.snap->ps.stats[ STAT_WEAPONS ];
count = 0;
for ( i = 1 ; i < 16 ; i++ ) {
if ( bits & ( 1 << i ) ) {
count++;
}
}
x = 640-20; //3X CODE put the x coordinate at right side less the icon size for the bar
y = 80; //3X CODE put the bar at 1/6 of y screeb resolution 640x480
for ( i = 1 ; i < 16 ; i++ ) {
if ( !( bits & ( 1 << i ) ) ) {
continue;
}
CG_RegisterWeapon( i );
// 3X CODE modify half size icons for modern display resolutions
CG_DrawPic( x, y, 32/2, 32/2, cg_weapons[i].weaponIcon );
// draw selection marker 3X CODE Modify for a more modern display halfsize
if ( i == cg.weaponSelect ) {
CG_DrawPic( x-4/2, y-4/2, 40/2, 40/2, cgs.media.selectShader );
}
// remove the no ammo cross because is useless if i add ammo owned for all weapons
y += 40/2; // 3X CODE halfsize for icons and use y axis for vertical ammo display
}
// draw the selected name 3X CODE remove this because is useless for old gamers of Q3A
trap_R_SetColor( NULL );
}
}
what you obtain:
a new cvar cg_AmmoBarStyle (you can assign the value by console "cg_AmmoBarStyle 0 / 1 /2" one of these
with a cvar value integer 0 or less you will have the classic quake 3 arena ammo bar, icons will be half size i need to adjust some other things
with a cvar value equals 1 you will have left side bar(for now without ammo display, i'm trying to understand how to make it)
and a cvar 2 or more a right side ammo bar.
I usually don't post my code here, put sometimes the "big" problems are only made by a lack of accuracy.
Hope to help somebody else and also myself for my project
still thanks ^misantropia^ for his attention.
If somebody can help me with "all owned weapon ammo count" it will appreciated.
and hope to help somebody else.
Thanks