QuakeZone
MOD Coding Tutorials
Quake II Coding Tutorials!

Introduction
Pre-requisites
Code
Notes
Exercises
Quake II Coding Tutorials

19 Team Weapon on Player Screen

Introduction Introduction
Related Links

15 Teamplay Enhancements
16 Display Team Info on screen
18 Team Weapon

This tutorial buildon the previous tutorial, 18 Team Weapon, and shows how to display each team's weapon on the detahmatch scoreboard and the player's hud.

Pre-requisites Pre-requisites

  • 15 teamplay enhancements
  • 16 display team info on player screen
  • 18 team weapon enhancement
Code Code


q_shared.h

Add the folloiwng line as indicated:

#define STAT_TEAM_NAME          23	// PJT - team play - team name	  <-- locate this line
#define STAT_TEAM_WEAPON        24      // PJT - team rail - team weapon  <-- insert here

#define	MAX_STATS		32	
		

p_hud.c

Insert the following lines below as indicated:

1. in DeathmatchScoreboardMessage, make the following additions:

	char       *tag;
	char       *weapon;		// PJT - team rail - weapon string  <-- insert

	then locate the team 1 code......			

		// team 1

		// PJT - team rail - weapon  <-- insert here
		if (team_table[1].teamrail == 0)
			weapon = "[Rockets]";
		else
			weapon = "[Railgun]";
		// PJT                       <-- end of insert
		Com_sprintf(entry, sizeof(entry),
			"xv 32 yv -16 string \"%s\" "
			"xv 216 yv -16 string \"%4i\" "
			"xv 256 yv -16 string \"%s\" ",		// PJT - team weapon  <-- insert
			team_table[1].name,
			team_table[1].score,
			weapon);	

	then locate the team 2 code......

		// team 2

		// PJT - team rail - weapon	<-- start insert
		if (team_table[2].teamrail == 0)
			weapon = "[Rockets]";
		else
			weapon = "[Railgun]";
		// PJT				<-- end of insert
		Com_sprintf(entry, sizeof(entry),
			"xv 32 yv -8 string \"%s\" "
			"xv 216 yv -8 string \"%4i\" "
			"xv 256 yv -8 string \"%s\" ",		// PJT - team weapon  <-- insert
			team_table[2].name,
			team_table[2].score,
			weapon);				// PJT - team weapon  <-- insert
	
2. at the end of update_hud_rockets, add the following lines:

	// PJT - team rail - team weapon  <-- start of insert
	ent->client->ps.stats[STAT_TEAM_WEAPON] = CS_TR_STRINGS + 44 + ent->client->resp.teamrail;
	// PJT				  <-- end of insert
		
3. at the end of init_hud_rocket_strings, insert the following:

	// PJT - team play - team scores  <-- start of insert
	gi.configstring (CS_TR_STRINGS +44, "[Rockets]");
	gi.configstring (CS_TR_STRINGS +45, "[Railgun]");
	// PJT				  <-- end of insert

		

g_spawn.c

Add the following lines as indicated:

1. Locate the dm_statusbar string and amend and add the following lines as indicated:

// PJT - team play - team name(23)
"xr -300 "			// PJT team weapon	<-- amend this line
"yt 20 "
"string \"Team\" "
"xr -252 "			// PJT team weapon	<-- amend this line
"stat_string 23 "
// PJT

// PJT - team rail - team weapon(24)			<-- start of insert
"xr -100 "
"yt 20 "
"stat_string 24 "
// PJT							<-- end of insert
		
Notes Notes to code


q_shared.c
  • STAT_TEAM_WEAPON is a "slot" (24) reserved in the client data structures to hold a string that contains the team weapon

p_hud.c
  • DeathmatchScoreboardMessage was originally changed by a QDevels tutorial for a new format scoreboard that shows more players. This was then further amended by the teamplay enhancements tutorial (15) to show team scores and what teams players are on:
    • and both teams have been updated to show what weapon their players use
  • update_hud_rockets has been amended to store the name of the team's wepaons prior to being displayed on the hud, as specified in g_spawn.c, in the slot in the player's ps.stats structure reserved by STAT_TEAM_WEAPON.
  • init_hud_rocket_strings, at the start of a game, pre-defines all the constant strings to be displayed on the player's hud:
    • the strings for the team weapons are defined
    • CS_TR_STRINGS, created in reserves a set of "slots" in the client structure for constant strings we are adding

g_spawn.c
  • dm_statusbar is the string used by Quake engine to display a player's hud in deathmatch games. It was amended in tutorial 16, display team info, to display the name of the player's team:
    • start position of team name moved to left to make room for weapon name
    • and weapon name insert right after team name
    • "stat_string 24" correpsonds to the value in ps.stats reserved by STAT_TEAM_WEAPON.
Exercises Exercises

  • if in tutorial 18 you have added more team weapons, this tutorial will need to be modified to add the weapon names in here


Page last updated 6th April 2000