Starting Health & Armour Feature Type: Coding Tutorials     Added: 21/01  
  Author: Corven 

This is relatively easy to just add a snippet of code that will check for a starting health and armour value.

Code to be Added or Changed


Look down for the ClientSpawn function, this performs all the usually things as the client spawns into the arena, like setting their health amount.

About half way down that function you'll see a line of code which tells the game to give the player the max health plus 25, effectively 125.

ent->health = client->ps.stats[STAT_HEALTH] = client->ps.stats[STAT_MAX_HEALTH] + 25;

We want to replace that with whatever health amount we want, so in my example below I've setup a cvar called g_starthealth, and added the following code:

if ( g_starthealth.integer > 0 ) {
ent->health = client->ps.stats[STAT_HEALTH] = (int)(g_starthealth.integer);
} else {
ent->health = client->ps.stats[STAT_HEALTH] = client->ps.stats[STAT_MAX_HEALTH] + 25;

It now tells the game, if the cvar is set great than 0, basically an actual value, then make the starting health that value, else if the cvar is set to 0 meaning off, to give the player the default intended amount.

Just under that I also added another cvar for g_startarmor, it works just the same way, although there is no default starting armor, as in quake3 vanilla you dont get any armor to start with.

if ( g_startarmor.integer > 0 ) {
ent->health = client->ps.stats[STAT_ARMOR] = (int)(g_startarmor.integer);

Comments »

  Page 1

  Comments ( 0 )

  Features Index


Copyright 2001 MGON International AB - Privacy statement