|
QuakeZone MOD Coding Tutorials
|
|
|
Introduction Code Notes Exercises |
|
| Introduction |
|
|
This tutorial demonstrates how to display currently selected rocket type (standard, nuclear, etc) and fire mode (standrad, homing, etc) on the status bar on the player's Head-Up Display, or HUD. This tutorial supplements the tutorials on nuclear rockets and blister rockets, which show
how to implement different rocket types and fire modes respectively.
|
| Code |
|
|
g_local.h Make sure the folloiwng fields exist at the end of structure client_persistant_t: qboolean nuke_state; // PJT - nuke rocket state qboolean homing_state; // PJT - homing missile state qboolean blister_state; // PJT - blister rocket state qboolean multi_state; // PJT - multiple rockets q_shared.h Add the following defines at the indicated position file: #define STAT_SPECTATOR 17 // <-- insert after here #define STAT_ROCKET_STRING 18 // PJT - rocket type string #define STAT_FIREMODE_MULTI 19 // PJT - rocket fire mode - multiple #define STAT_FIREMODE_HOMING 20 // PJT - rocket fire mode - homing #define STAT_FIREMODE_BLISTER 21 // PJT - rocket fire mode - blisterThen a further define at the next indicated location: #define MAX_CONFIGSTRINGS (CS_GENERAL+MAX_GENERAL) // <-- insert after here #define CS_TR_STRINGS (CS_ITEMS+200) // PJT - HUD strings p_hud.c Add the following statement at the end of procedure G_SetStats: // PJT - new Hud update_hud_rockets(ent);Then add the folloing code at the end of the file:
// PJT - new HUD (TR 1.1.0)
void update_hud_rockets (edict_t *ent)
{
//1. set rocket type
if (ent->client->pers.nuke_state > 4) // 4 is number of different rocket types
ent->client->pers.nuke_state = 0;
ent->client->ps.stats[STAT_ROCKET_STRING] = CS_TR_STRINGS + ent->client->pers.nuke_state;
//2. set fire mode
// : homing missiles
if (ent->client->pers.homing_state == 1)
ent->client->ps.stats[STAT_FIREMODE_HOMING] = CS_TR_STRINGS + 21;
else
ent->client->ps.stats[STAT_FIREMODE_HOMING] = CS_TR_STRINGS + 20;
// : multi rockets
if (ent->client->pers.multi_state == 1)
ent->client->ps.stats[STAT_FIREMODE_MULTI] = CS_TR_STRINGS + 22;
else
ent->client->ps.stats[STAT_FIREMODE_MULTI] = CS_TR_STRINGS + 20;
// : blister rockets
if (ent->client->pers.blister_state == 1)
ent->client->ps.stats[STAT_FIREMODE_BLISTER] = CS_TR_STRINGS + 23;
else
ent->client->ps.stats[STAT_FIREMODE_BLISTER] = CS_TR_STRINGS + 20;
// : new fire modes can be inserted here
}
// PJT - new HUD - define HUD strings
void init_hud_rocket_strings(void)
{
// rocket type names
gi.configstring (CS_TR_STRINGS +0, "Standard ");
gi.configstring (CS_TR_STRINGS +1, "Nuke ");
gi.configstring (CS_TR_STRINGS +2, "Gas ");
gi.configstring (CS_TR_STRINGS +3, "Positron ");
gi.configstring (CS_TR_STRINGS +4, "Earthquake ");
// add configstring statements for new rocket types here
// rocket fire modes
gi.configstring (CS_TR_STRINGS +20, " ");
gi.configstring (CS_TR_STRINGS +21, "Hom ");
gi.configstring (CS_TR_STRINGS +22, "Mul ");
gi.configstring (CS_TR_STRINGS +23, "Bli ");
// add configstring statements for new fire modes here
}
// PJT
g_spawn.c Add the following lines to the end of the definitions of both single_statusbar and dm_statusbar: // PJT - rocket type(18) "xv 0 " "yb -68 " "string \"Rocket\" " "xv 64 " "stat_string 18 " // PJT - fire modes multi(19) homing(20) blister(21) "xv 250 " "string \"Mode \" " "xv 314 " "stat_string 19 " "xv 346 " "stat_string 20 " "xv 378 " "stat_string 21 " // PJTThen, in procedure SP_worldspawn, add the following code at indicated position: // set configstrings for items SetItemNames (); // PJT - set configstrings for team rocket HUD (see p_hud.c) init_hud_rocket_strings(); |
| Notes |
|
|
g_local.h
q_shared.h
p_hud.c
q_spawn.c
|
| Exercises |
|
|