HUD

Warsow's Official Wiki

Jump to: navigation, search

Contents

Introduction

You can open and edit the *.hud files with a simple texteditor. The hud parser uses a simple script language to include and interpret hudscripts and hudcommands. You cant write your own functions nor create dynamic varibles or jump to a specific point in your script. The scriptparser traverses the hud files from top to bottom and executes it line by line, just like a batch file. Warsow lays out hud elements on a virtual grid of 800x600 units size. The constants #WIDTH and #HEIGHT store this predefined grid size.

Warsow's default hud can be found inside data0_05.pk3 which can be opened with your favourite zip archiver. Make sure you do not modify any of the pk3 files that come with the game.
Your HUD files can be located inside the /basewsw/huds/ folder. Create that directory if it does not yet exist.
To change the HUD in game, go to the “player setup” menu and select it in the “client HUD” option or type cg_clientHUD "hud_name" in the console.

Default files

Here is a list of the default HUD files, their directories, and a short description of what they do.

(~/ is for default Warsow huds directory)

directory ~/

default.hud
  This a HUD script that tells what other files to include in the HUD
  The HUDs name will be it's filename without the extension

directory ~/inc/

ammo.hud
  Draws the current weapons icon, strong ammo, and weak ammo

armor.hud
  Draws the armor bar, armor icon, and armor left

awards.hud
  Draws the award notice

chasing.hud
  Draws the player name you spectate if you spectate

clock.hud
  Draws the clock at the top of the HUD

crosshair.hud
  Draws the crosshair in the center of the screen

damage_indicator_screen.hud
  Draws the directional damage indicator that paints the screen borders red

download.hud
  Shows the download progress bar (server-demo downloads)

fps.hud
  Draws the frames per second

frags.hud
  Draws the word "frags" and the number of frags
  By default, this also changes the word from "frags" to "points" or "spread," depending on what game type you are playing

health.hud
  Draws the health bar, icon, and numbers

help_message.hud
  Draws the help message if cg_showhelp is 1

item_timers.hud
  Draws the item timers for spectators
 
keystate.hud
  Draws the keys pressed
   *note - uses images stored in data0.pk3 in directory "gfx/hud/keys/"

minimap.hud
 Displays the minimap 

net.hud
  Draws the connection icon if your connection to the server is temporary lost 
   *note - uses one image stored in data0.pk3 in directory "gfx/hud/"

obituaries.hud
  Draws the little entries for who killed who, and how in the upper right corner

picked_up_items.hud
  Draws the message for items that the player picks up

pointing.hud
  Draws the name of the player in the crosshair

powerups.hud
  Draws the timer for power up items.. (Quad Damage and War Shell)
 
scores.hud
  Draws the scores of alpha and beta teams

speed.hud
  Draws the speed in units per second

team_info.hud
  Draws the team information screen plus the gametype dependant icons and text

times.hud
  Displays time in race and other gametypes

weaponlist.hud
  Draws the ammunition for each weapon
  This file lists the starting points (x,y) for weapon icons, and weapon ammo
  *note - weaponlist.hud is executed only on the initial spawn of the player, and when the player picks up a new weapon

zoom.hud
  Draws the screen effect while using zoom

HUD Script Commands

Capitalisation of the command names does not matter.

setCursor (arguments: 2)
  Changes cursor position on the hud parsers virtual grid
  Parameters: horizontal position, vertical position

moveCursor (arguments: 2)
  Moves the cursor position relative to current position
  Parameters: horizontal offset, vertical offset

setAlign (arguments: 2)
  Changes alignment of things like images or text
  Parameters: horizontal alignment (#LEFT|#CENTER|#RIGHT), vertical alignment (#TOP|#MIDDLE|#BOTTOM)

setSize (arguments: 2)
  Sets width and height. Used in various hudcommands for pictures, models and containers

setFont (arguments: 1)
  Sets font by font name. available fonts are: 
  bitstream_7, bitstream_8, bitstream_9, bitstream_10, bitstream_12, bitstream_16, 
  electrofield_16, electrofield_18, electrofield_20, elements24, entersansman18,
  entersansman20, entersansman22, hemihead_14, hemihead_16, hemihead_18, hemihead_20,
  hemihead_22, hemihead_24, hemihead_26, kimberley18, kimberley20, speedwaystar18, 
  virtue_8, virtue_9, virtue_10, virtue_12, virtue_16, virtue_22, virtue_28,
  zerotwos18, zerotwos20, zerotwos24
     
  Accepts 'con_fontsystemsmall', 'con_fontsystemmedium' and 'con_fontsystembig' as shortcut to default game fonts

setColor (arguments: 4)
  Sets color setting in RGBA mode. Used to change colors of boxes, bars, text and images

 setColorToTeamColor (arguments: 1)
  Sets cursor color to the color of the team provided in the argument

setColorAlpha (arguments: 1)
  Changes the alpha value of the current color

setRotationSpeed (arguments: 3)
  Sets rotation speeds as vector. Used for models

setCustomWeaponIcons (arguments: 3)
  modifies an individual image on the graphical weaponlist
  1st argument specifies the weapon it should affect (either by id, or better use #ITEM_GUNBLADE etc constants)
  2nd argument tells if you want to replace the NOGUN icon (0) or the regular weapon icon (1)
  3rd argument is the path to the graphic you want to use as a replacement

setCustomWeaponSelect (arguments: 1)
  modifies the image around current selected weapon on the list of weapons
  the only and required argument is a file path to a valid graphic

drawObituaries (arguments: 2)
  Draws graphical death messages. Arguments: horizontal alignment, iconsize

drawAwards
  Draws award messages

drawClock
  Draws a clock that shows remaining play time

drawHelpString
  Draws the help message

drawPlayername (arguments: 1)
  Draws the name of the player with id provided by the argument

drawPointing
  Draws the name of a player that is being pointed at (the player under the crosshair)

drawStatString (arguments: 1)
  Draws configstring of argument id

drawItemName (arguments: 1)
  Draws the name of the thing that is given as argument in form of item index

drawString (arguments: 1)
  Draws the text in argument at cursor position using currently set font and color

drawStringNum (arguments: 1)
  Can be used to output referenced numbers as text, using currently set font, position and color

drawNum (arguments: 1)
  Draws numbers of given character size. Use setSize to set character size

drawStretchNum (arguments: 1)
  Draws numbers stretched inside a given size

drawBar (arguments: 2)
  Draws a bar of size setting, the bar's longest dimension, or its width if it's a square, is filled in proportion to the arguments
  Arguments: value, maxvalue 

drawPicBar (arguments: 3)
  Draws an image bar of size setting, is filled in proportion to the arguments.
  Arguments: value, maxvalue, imagefile

drawCrosshair
  Draws the game crosshair

drawKeyState (arguments: 1)
  Draws icons showing if the argument key is pressed. Possible arg: forward, backward, left, right, fire, jump, crouch, special
  Use setSize to scale and setCursor to position each element.

drawNetIcon
  Draws the disconnection icon

drawPicByIndex (arguments: 1)
  Draws a pic with argument as imageIndex

drawPicByItemIndex (arguments: 1)
  Draws a item icon pic with argument as itemIndex

drawPicByName (arguments: 1)
  Draws a pic with argument being the file path

drawModelByIndex (arguments: 1)
  Draws a model with argument being the modelIndex

drawModelByName (arguments: 2)
  Draws a model with argument being the path to the model file

drawModelByItemIndex (arguments: 1)
  Draws an item model with argument being the item index

drawWeaponIcons (arguments: 4)
  Draws the icons of weapon/ammo owned by the player, arguments are offset x, offset y, size x, size y

drawCaptureAreas (arguments: 3)
  Draws capture area HUD icons. arguments are icon-width, icon-height and alignment (either horizontal or vertical)

drawMiniMap (arguments: 2)
  Shows miniature map overview for spectators. arguments are playernames (0|1), itemnames (0|1)

drawWeaponWeakAmmo (arguments: 3)
  Draws the amount of weak ammo owned by the player, arguments are offset x, offset y, fontsize

drawWeaponStrongAmmo (arguments: 3)
  Draws the amount of strong ammo owned by the player, arguments are offset x, offset y, fontsize

drawTeamInfo
  Draws the Team Info (locations) box

drawTimer (arguments: 1)
  Draws a digital clock using currently set font. The only argument is a timer variable or integer

drawPicVar (arguments: 6)
Draws a picture from a sequence, depending on the value of a given parameter
Parameters: value, minval, maxval, firstimg, lastimg, imagename## 
(replacing ## by the picture number, no leading zeros, starting at 0)

if (arguments: 1)
  Conditional expression. Argument accepts operands >, <, ==, >=, <=, etc

endif
  End of conditional expression block

NOTE: Warsow hudscript does not know of "else" or a "switch" type statement

HUD Script Operators

+   Add operator

-   Subtract operator

*   Multiply operator

/   Divide operator

&   AND operator

|   OR operator

ˆ   XOR operator

==  Equals operator

!=  Not equals operator

>   Bigger than operator

>=  Bigger than or equal to operator

<   Smaller than or equal to operator

<=  Smaller than or equal to operator

NOTE: Hudcode is parsed from right to left. Keep that in mind if you plan to do multiple operations in a single line.

HUD scripts REFERENCE names

Reference names must be written UPPER CASE

  •  %HEALTH
  •  %ARMOR
  •  %WEAPON_ITEM
  •  %PENDING_WEAPON
  •  %PICKUP_ITEM
  •  %SCORE
  •  %TEAM
  •  %REALTEAM
  •  %TEAM_ENEMY
  •  %RESPAWN_TIME
  •  %POINTED_PLAYER
  •  %POINTED_TEAMPLAYER
  •  %TEAM_ALPHA_SCORE
  •  %TEAM_BETA_SCORE
  •  %PROGRESS_SELF
  •  %PROGRESS_OTHER
  •  %PROGRESS_ALPHA
  •  %PROGRESS_BETA
  •  %IMAGE_SELF
  •  %IMAGE_OTHER
  •  %IMAGE_ALPHA
  •  %IMAGE_BETA
  •  %TIME_SELF
  •  %TIME_BEST
  •  %TIME_RECORD
  •  %TIME_ALPHA
  •  %TIME_BETA
  •  %MESSAGE_SELF
  •  %MESSAGE_OTHER
  •  %MESSAGE_ALPHA
  •  %MESSAGE_BETA
  •  %AMMO_ITEM
  •  %AMMO
  •  %WEAK_AMMO
  •  %CHASING
  •  %ARMOR_ITEM
  •  %SPEED
  •  %SPEED_VERTICAL
  •  %FPS
  •  %MATCH_STATE
  •  %MATCH_TIME
  •  %MATCH_DURATION
  •  %OVERTIME
  •  %INSTAGIB
  •  %TEAMBASED
  •  %INDIVIDUAL
  •  %RACE
  •  %PAUSED
  •  %ZOOM
  •  %VIDWIDTH
  •  %VIDHEIGHT
  •  %STUNNED
  •  %POWERUP_QUAD_TIME
  •  %POWERUP_WARSHELL_TIME
  •  %DAMAGE_INDICATOR_TOP
  •  %DAMAGE_INDICATOR_RIGHT
  •  %DAMAGE_INDICATOR_BOTTOM
  •  %DAMAGE_INDICATOR_LEFT
  •  %SHOW_FPS
  •  %SHOW_OBITUARIES
  •  %SHOW_PICKUP
  •  %SHOW_POINTED_PLAYER
  •  %SHOW_PRESSED_KEYS
  •  %SHOW_SPEED
  •  %SHOW_TEAM_LOCATIONS
  •  %SHOW_TIMER
  •  %SHOW_AWARDS
  •  %SHOW_ZOOM_EFFECT
  •  %SHOW_R_SPEEDS
  •  %SHOW_ITEM_TIMERS
  •  %DOWNLOAD_IN_PROGRESS
  •  %DOWNLOAD_PERCENT
  •  %ITEM_TIMER0
  •  %ITEM_TIMER0_COUNT
  •  %ITEM_TIMER0_LOCATION
  •  %ITEM_TIMER0_TEAM
  •  %ITEM_TIMER1
  •  %ITEM_TIMER1_COUNT
  •  %ITEM_TIMER1_LOCATION
  •  %ITEM_TIMER1_TEAM
  •  %ITEM_TIMER2
  •  %ITEM_TIMER2_COUNT
  •  %ITEM_TIMER2_LOCATION
  •  %ITEM_TIMER2_TEAM
  •  %ITEM_TIMER3
  •  %ITEM_TIMER3_COUNT
  •  %ITEM_TIMER3_LOCATION
  •  %ITEM_TIMER3_TEAM
  •  %ITEM_TIMER4
  •  %ITEM_TIMER4_COUNT
  •  %ITEM_TIMER4_LOCATION
  •  %ITEM_TIMER4_TEAM
  •  %ITEM_TIMER5
  •  %ITEM_TIMER5_COUNT
  •  %ITEM_TIMER5_LOCATION
  •  %ITEM_TIMER5_TEAM
  •  %ITEM_TIMER6
  •  %ITEM_TIMER6_COUNT
  •  %ITEM_TIMER6_LOCATION
  •  %ITEM_TIMER6_TEAM
  •  %ITEM_TIMER7
  •  %ITEM_TIMER7_COUNT
  •  %ITEM_TIMER7_LOCATION
  •  %ITEM_TIMER7_TEAM

HUD scripts CONSTANT names

Constant names must be written UPPER CASE

  • #ITEM_GUNBLADE
  • #ITEM_MACHINEGUN
  • #ITEM_RIOTGUN
  • #ITEM_GRENADE_LAUNCHER
  • #ITEM_ROCKET_LAUNCHER
  • #ITEM_PLASMAGUN
  • #ITEM_LASERGUN
  • #ITEM_ELECTROBOLT
  • #ITEM_INSTAGUN
  • #ITEM_CELLS
  • #ITEM_STRONG_BULLETS
  • #ITEM_SHELLS
  • #ITEM_GRENADES
  • #ITEM_ROCKETS
  • #ITEM_PLASMA
  • #ITEM_LASERS
  • #ITEM_BOLTS
  • #ITEM_INSTAS
  • #ITEM_BLADES
  • #ITEM_BULLETS
  • #ITEM_WEAK_SHELLS
  • #ITEM_WEAK_GRENADES
  • #ITEM_WEAK_ROCKETS
  • #ITEM_WEAK_PLASMA
  • #ITEM_WEAK_LASERS
  • #ITEM_WEAK_BOLTS
  • #ITEM_WEAK_INSTAS
  • #ITEM_GREEN_ARMOR
  • #ITEM_YELLOW_ARMOR
  • #ITEM_RED_ARMOR
  • #ITEM_ARMOR_SHARD
  • #ITEM_5_HEALTH
  • #ITEM_25_HEALTH
  • #ITEM_50_HEALTH
  • #ITEM_MEGA_HEALTH
  • #ITEM_ULTRA_HEALTH
  • #ITEM_QUAD_DAMAGE
  • #ITEM_WARSHELL
  • #ITEM_AMMO_PACK_WEAK
  • #ITEM_AMMO_PACK_STRONG
  • #ITEM_AMMO_PACK
  • #NOTSET
  • #TEAM_SPECTATOR
  • #TEAM_PLAYERS
  • #TEAM_ALPHA
  • #TEAM_BETA
  • #LEFT
  • #CENTER
  • #RIGHT
  • #TOP
  • #MIDDLE
  • #BOTTOM
  • #WIDTH
  • #HEIGHT
  • #MATCH_STATE_NONE
  • #MATCH_STATE_WARMUP
  • #MATCH_STATE_COUNTDOWN
  • #MATCH_STATE_PLAYTIME
  • #MATCH_STATE_POSTMATCH
  • #MATCH_STATE_WAITEXIT
  • #WEAP_GUNBLADE
  • #WEAP_MACHINEGUN
  • #WEAP_RIOTGUN
  • #WEAP_GRENADELAUNCHER
  • #WEAP_ROCKETLAUNCHER
  • #WEAP_PLASMAGUN
  • #WEAP_LASERGUN
  • #WEAP_ELECTROBOLT
  • #NOGUN
  • #GUN

Hudscript examples

running a command

this example says Hello Warsowland!

drawString "Hello Warsowland!"

calls the command drawString and supplies the argument "Hello Warsowland!" to it.
but the command will output "Hello Warsowland!" somewhere on the screen in some color. to set a color and a position that makes sense, you must run setColor and setCursor commands before you call drawString.

multiple arguments and mathematical calculations

this example will draw a big number 4

setColor 1, 1, 1, 0.8
setSize #WIDTH / 4, 150
drawNum 4

the 1st line calls setColor with 4 arguments and sets a white color that is also 20% transparent. drawNum in 3rd line will use this color
the 2nd line runs setSize and defines the size to 1/4th of the gridwidth horizontaly, and 150units on the grid vertically, drawNum in the next line will make use this size setting
the last line calls drawNum and simply gives the number 4 as argument to it. you cant do any calculations while calling certain commands like drawNum, drawTimer or drawString.

conditional expressions

An example that will show the words You have been blessed on screen everytime you pick up ultrahealth

if %PICKUP_ITEM == #ITEM_ULTRA_HEALTH           // the next line is only executed if the statement is true
 drawString "You have been blessed"
endif

if
Starts a conditional expression


%PICKUP_ITEM
a variable reference name that holds the id of the actual picked up item


==
a logic operator that says: "is the same as"


#ITEM_ULTRA_HEALTH
a predefined constant to compare with


// the next line is only executed if the statement is true
a comment


drawString
a command with the single argument "You have been blessed"


endif
Ends the conditional expression block

complex expressions

this is more a theoretical part for freaks rather than something usefull :>

if 0 == %SHOW_POINTED_PLAYER & 512

means: if console variable cg_showPointedPlayer does not have the 10th bit set
what you need to know to understand it:

  • hudscript is parsed per line and from right to left
  •  %SHOW_POINTED_PLAYER is a readout of cg_showPointedPlayer user-set console variable
  • & is a bitwise AND operator