HUD Design Part II


Once you decide on the method of implementing your Hud, and have an idea about the layout, you have to determine just what is to be included in it. Some of the basic parts will be included in all Huds but other things depend on avalible screen space and game type.

Basic Hud

In the Basic Hud we would include the player's health, the amount of armor and the ammo for the current weapon. These would comprise the minimalist Hud. Other things that would probably be included are a graphic or model of the player's head and the player's score. Nothing in this group is game dependant and would be part of every Hud we create.

Intermediate Hud

For a little more advanced Hud some of the things that could be included are the item you are holding, the Powerups you have, the name of the last player to kill you and the frag/capture limit of the game. Like the Basic Hud, nothing here is game dependant. In fact, this is about all the information you can provide to the player in a nonteam game.

Team Game Hud

In team games the player has a need for more information than what is required in a nonteam game. Some of the things needed in a team game Hud are the player's location, the player's team, the player's status, information on the team or individual team members and team scores. These would be useful in all team games. Specific game types, such as CTF and variations, need to display information on flag status and the players currently holding them.

All of the above information can be provided in the scripts using ownerdraw commands. The following is a list of these commands broken down by Hud element.

Hud Element ownerdraw Command
Health CG_PLAYER_HEALTH
Armor CG_PLAYER_ARMOR_ICON
  CG_PLAYER_ARMOR_VALUE
  CG_PLAYER_ARMOR_ICON2D
Ammo CG_PLAYER_AMMO_ICON
  CG_PLAYER_AMMO_VALUE
  CG_PLAYER_AMMO_ICON2D
Player Head CG_PLAYER_HEAD
Player Score CG_PLAYER_SCORE
  CG_1STPLACE
  CG_2NDPLACE
Player Location CG_PLAYER_LOCATION
Player Status CG_PLAYER_STATUS
Last Killer CG_KILLER
Frag/Capture Limit CG_CAPFRAGLIMIT
Player's Team CG_TEAM_COLOR
Team Member CG_PLAYER_SELECTEDPLAYER_HEAD
  CG_PLAYER_SELECTEDPLAYER_NAME
  CG_PLAYER_SELECTEDPLAYER_LOCATION
  CG_PLAYER_SELECTEDPLAYER_STATUS
  CG_PLAYER_SELECTEDPLAYER_WEAPON
  CG_PLAYER_SELECTEDPLAYER_POWERUP
  CG_PLAYER_SELECTEDPLAYER_ARMOR
  CG_PLAYER_SELECTEDPLAYER_HEALTH
Team Info CG_TEAMINFO
Team Scores CG_BLUE_SCORE
  CG_RED_SCORE
CTF Flag Status CG_BLUE_FLAGHEAD
  CG_BLUE_FLAGSTATUS
  CG_BLUE_FLAGNAME
  CG_RED_FLAGHEAD
  CG_RED_FLAGSTATUS
  CG_RED_FLAGNAME
  CG_PLAYER_HASFLAG
  CG_PLAYER_HASFLAG2D
Player Item CG_PLAYER_ITEM
Powerups CG_AREA_POWERUP

We will be using these ownerdraw commands as we create our Hud in later sections and will take a closer look at them at that time.

Miscellaneous Design Information

1. You select which team member you wish to display information about (using the CG_PLAYER_SELECTEDPLAYER_?? commands) by moving through the team list using the keys bound to the nextTeamMember and the prevTeamMember cvars. When you reach the end of the list it switches from noteaminfo mode to teaminfo mode before wrapping around to the noteaminfo mode again with the first/last team member. This mode switch is what is checked by the ownerdrawflag CG_SHOW_TEAMINFO and the ownerdrawflag CG_SHOW_NOTEAMINFO commands and can be used to show Team Information rather than Team Member Information in the same screen area.

2. The ownerdraw CG_AREA_POWERUP command draws the powerup graphics with a width 0.75 of the item's width and a height equal to the height of the item. The item's window width and height must be the same for this command. The time remaining on the powerup is displayed 3 pixels to the right of the graphic and uses the value of the textscale command to determine the text size. The align and special commands must be included in the item to get proper spacing of the powerups. If align is set to HUD_VERTICAL the next powerup will be displayed below the previous one and will have space between them as set by the special command. If align is set to HUD_HORIZONTAL the next powerup will be displayed to the right of the previous one and will have space between them as set by the special command. There can be a maximum of 16 powerups displayed at once.

3. If you do not wish to use models as icons in the Hud then including the ownerdrawflag CG_SHOW_2DONLY in those items displaying icons will force them to use graphics only. Other ownerdrawflag commands can also be used in these items without problems.

4. The ownerdraw CG_TEAMINFO command displays information about team members, up to a maximum of 8 members. For each team member it displays the powerups the player has as a 12x12 graphic, a 12x12 health graphic whose color indicates health level, an optional 12x12 graphic indicating a pending order, the player's name and location. It uses the text formatting commands in the item to scale the text size and space each line apart. It will fit this information into the item's window width by trucating the name and location if necessary.

5. If you have a game type that is not one of those supported by the ownerdrawflag commands you can still make the Hud display items just for that game type. Instead of using the ownerdrawflag commands to make the item visible you can use the cvartest and showCvar commands. To make this work correctly you must make the item visible by default by including the visible MENU_TRUE command in the item. As an example, to make a Hud item visible only if the game type is 8 (see the Gameinfo.txt section for details about game types) you would include in the item the following :

  visible MENU_TRUE

  cvartest g_gametype 
  showCvar { "8" }

6. If you wish to have certain items in the Hud be displayed only if the game is a single player skirmish game you can also use the cvartest and showCvar commands with the ui_singlePlayerActive cvar. This cvar is set to 1 if the game is a single player skirmish game. For example, the name of the teams is only relevant in the single player game so you would use the following in the items displaying the team names :

  visible MENU_TRUE

  cvartest ui_singlePlayerActive 
  showCvar { "1" }

so they only appear in a single player game.

Return to Home Page