Hey there,
I have recently modded my engine (WinQuake) showing my current used Shotgun clip (STAT_AMMO) and the restammo using STAT_SHELLS...
Its drawn with Sbar_DrawNum and works like a charm...
But now i have a question for some tricky stuff...
I have made many custom ammos using .float ammo_SMG, .float ammo_whatever and so on, and i want them on my hud too...
Can anybody help me how i can do that in the engine?
Greetz
Showing new ammovalues on the HUD??
Re: Showing new ammovalues on the HUD??
I made that previously on an older thread (with altammo and recording problem), so here's what you globally have to do:
(I modified some things in order to be a bit "lazyier" for future weapon modifications, but it does work on stock engines)
==============================
ENGINE MODIFICATION
==============================
1) Add a new define for your weapon stat in your Quakedef.h:
(Look that I enumed this, and added Ammo stats at the end in order to modify less things later)
Also, add too a new IT_NEWAMMO line :
==============================
CLIENT SIDE MODIFICATION
==============================
2) in cl_parse.c, search this :
And replace it with :
============================
SERVER SIDE MODIFICATION
=============================
3) In your Progsdef.q1 , add below
this:
4) Do the same on the QuakeC side (with progdefs.h)
5) In void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
Add below
this
========================
HUD DRAWING
===========================
6) In sbar.c , find
And replace it with :
-------------
Find
and add below
-------------
Find
And add below
======================
QUAKE C MODIFICATION
======================
All you will have to do is to link your ammo_flags with your IT_ and your new STAT_ ... But best is to leave that to you!
Once it is done, careful though. Compile your QC code first, get the new CRC , and paste it to your progdefs.q1 CRC .
There may be errors, I did it without compiling it, but I hope that will help...
(I modified some things in order to be a bit "lazyier" for future weapon modifications, but it does work on stock engines)
==============================
ENGINE MODIFICATION
==============================
1) Add a new define for your weapon stat in your Quakedef.h:
(Look that I enumed this, and added Ammo stats at the end in order to modify less things later)
Code: Select all
enum
{
STAT_HEALTH = 0, // HEALTH
STAT_FRAGS = 1, // FRAGS
STAT_WEAPON = 2, // CURRENT WEAPON
STAT_AMMO = 3, // CURRENT AMMO
STAT_ARMOR = 4,
STAT_WEAPONFRAME = 5,
STAT_ACTIVEWEAPON = 6,
STAT_TOTALSECRETS = 7,
STAT_TOTALMONSTERS = 8,
STAT_SECRETS = 9,
STAT_MONSTERS = 10,
STAT_SHELLS = 11,
STAT_NAILS = 12,
STAT_ROCKETS = 13,
STAT_CELLS = 14,
STAT_NEWAMMO = 15 // --> New Ammo type
};
#define TOTAL_AMMO_STATS 5 // Maximum Ammo Stats available
Code: Select all
#define WEAPON_AXE (1<<0)
#define IT_SHOTGUN (1<<1)
#define IT_SUPER_SHOTGUN (1<<2)
#define IT_NAILGUN (1<<3)
#define IT_SUPER_NAILGUN (1<<4)
#define IT_GRENADE_LAUNCHER (1<<5)
#define IT_ROCKET_LAUNCHER (1<<6)
#define IT_LIGHTNING (1<<7)
#define IT_SUPER_LIGHTNING (1<<8)
#define IT_SHELLS (1<<9)
#define IT_NAILS (1<<10)
#define IT_ROCKETS (1<<11)
#define IT_CELLS (1<<12)
#define IT_NEWAMMO (1<<13) // I AM HERE !
#define IT_ARMOR1 (1<<14)
#define IT_ARMOR2 (1<<15)
#define IT_ARMOR3 (1<<16)
#define IT_SUPERHEALTH (1<<17)
#define IT_KEY1 (1<<18)
#define IT_KEY2 (1<<19)
#define IT_INVISIBILITY (1<<20)
#define IT_INVULNERABILITY (1<<21)
#define IT_SUIT 2097152
#define IT_QUAD 4194304
#define IT_SIGIL1 (1<<28)
#define IT_SIGIL2 (1<<29)
#define IT_SIGIL3 (1<<30)
#define IT_SIGIL4 (1<<31)
CLIENT SIDE MODIFICATION
==============================
2) in cl_parse.c, search this :
Code: Select all
for (i=0 ; i<4 ; i++)
{
j = MSG_ReadByte ();
if (cl.stats[STAT_SHELLS+i] != j)
{
cl.stats[STAT_SHELLS+i] = j;
Sbar_Changed ();
}
}
Code: Select all
for (i=0 ; i<TOTAL_AMMO_STATS ; i++)
{
j = MSG_ReadByte ();
if (cl.stats[STAT_SHELLS+i] != j)
{
cl.stats[STAT_SHELLS+i] = j;
Sbar_Changed ();
}
}
============================
SERVER SIDE MODIFICATION
=============================
3) In your Progsdef.q1 , add below
Code: Select all
float ammo_cells;
this:
Code: Select all
float ammo_newammo;
5) In void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
Add below
Code: Select all
MSG_WriteByte (msg, ent->v.ammo_cells);
Code: Select all
MSG_WriteByte (msg, ent->v.ammo_newammo);
HUD DRAWING
===========================
6) In sbar.c , find
Code: Select all
qpic_t *sb_ammo[4];
Code: Select all
qpic_t *sb_ammo[TOTAL_AMMO_STATS ];
Find
Code: Select all
sb_ammo[3] = Draw_PicFromWad ("sb_cells");
Code: Select all
sb_ammo[4] = Draw_PicFromWad ("sb_newammo"); // Of course, modify it with your image
Find
Code: Select all
else if (cl.items & IT_CELLS)
Sbar_DrawPic (224, 0, sb_ammo[3]);
Code: Select all
else if (cl.items & IT_NEWAMMO)
Sbar_DrawPic (224, 0, sb_ammo[4]);
QUAKE C MODIFICATION
======================
All you will have to do is to link your ammo_flags with your IT_ and your new STAT_ ... But best is to leave that to you!
Once it is done, careful though. Compile your QC code first, get the new CRC , and paste it to your progdefs.q1 CRC .
There may be errors, I did it without compiling it, but I hope that will help...
Re: Showing new ammovalues on the HUD??
thanks, i will test it
look trickier than i thought
look trickier than i thought
Re: Showing new ammovalues on the HUD??
sbar.c can be fun to hack! One time I totally ripped off Duke3D's status bar, in a day, with ammo counters for 9 weapons, being lit when selected appropriately.
i should not be here