There are currently 33 players online.
 
Warsow

 
 

HUDScripting

1. Introduction back to top


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_*.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.


All available commands can be seen by typing help_hud in the console.

2. Default files back to top


Here is a list of the default HUD files, their directories, and a short description of what they do.
directory huds:
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 huds/inc/default:
ammo.hud
Draws the current weapons icon, strong ammo, and weak ammo
ammo_warning.hud
Shows a warning, if ammo is low or empty
awards.hud
Draws the award notice
chasing.hud
Draws the player name you spectate if you spectate
chat.hud
Draws the chat window
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_armor.hud
Draws the health and armor bar, icon, and numbers
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
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)
race_records.hud
Draws personal and server best times for races
scores.hud
Draws the scores of alpha and beta teams
speed.hud
Draws the speed in units per second
strafe.hud
Draws a strafe helper
stunned.hud
Draws the "stunned" message
team_image.hud
Draws the gametype dependant icons
team_info.hud
Draws the team information screen
team_message.hud
Draws the team messages
team_progress.hud
Draws the team progress (for example flag unlocks in ctf)
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

3. HUD Script Commands back to top


Capitalisation of the command names does not matter.
setScale (arguments: 1)
Sets the scaling method for cursor and size commands.
Parameters: scaling method (#DEFAULTSCALE|#NOSCALE|#SCALEBYWIDTH|#SCALEBYHEIGHT)
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
setFontSize (arguments: 1)
Sets font size.
setFontFamily (arguments: 1)
Sets font Family.
Available arguments by default: Droid Sans, Droid Sans Mono, Hemi Head Rg, Kimberley Bl, warsow, Silhouette, Virtue.
setFontStyle (arguments: 1)
Sets font Style. Available arguments: Bold, Italic, Normal
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)
drawTeamMates (arguments: 0)
Draws indicators where team mates are
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
drawChat (arguments: 3)
Draws the game chat messages
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)
drawLocationName (arguments: 1)
Draws the location name with argument being location tag/index
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

4. HUD Script Operators back to top


+   Add operator
- Subtract operator
* Multiply operator
/ Divide operator
& Bitwise AND operator
| Bitwise 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
&& Logical AND operator
|| Logical OR operator

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

5. HUD scripts REFERENCE names back to top


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_DURATION
  • %OVERTIME
  • %INSTAGIB
  • %TEAMBASED
  • %INDIVIDUAL
  • %RACE
  • %PAUSED
  • %ZOOM
  • %VIDWIDTH
  • %VIDHEIGHT
  • %STUNNED
  • %POWERUP_QUAD_TIME
  • %POWERUP_WARSHELL_TIME
  • %POWERUP_REGEN_TIME
  • %DAMAGE_INDICATOR_TOP
  • %DAMAGE_INDICATOR_RIGHT
  • %DAMAGE_INDICATOR_BOTTOM
  • %DAMAGE_INDICATOR_LEFT
  • %MOUSE_X
  • %MOUSE_Y
  • %ACCELERATION
  • %MOVEANGLE
  • %STRAFEANGLE
  • %DIFF_ANGLE
  • %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
  • %SHOW_STRAFE
  • %DOWNLOAD_IN_PROGRESS
  • %DOWNLOAD_PERCENT
  • %CHAT_MODE
  • %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

6. HUD scripts CONSTANT names back to top


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_BULLETS
  • #ITEM_SHELLS
  • #ITEM_GRENADES
  • #ITEM_ROCKETS
  • #ITEM_PLASMA
  • #ITEM_LASERS
  • #ITEM_BOLTS
  • #ITEM_INSTAS
  • #ITEM_BLADES
  • #ITEM_STRONG_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_REGENERATION
  • #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
  • #DEFAULTSCALE
  • #NOSCALE
  • #SCALEBYWIDTH
  • #SCALEBYHEIGHT
  • #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

7. Hudscript examples back to top


7.1. running a command back to top


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.

7.2. multiple arguments and mathematical calculations back to top


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.

7.3. conditional expressions back to top


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

7.4. complex expressions back to top


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

7.5. drawing teamname back to top


Using the function drawStatString you can draw the team alpha and beta names (they are dependent on the clantags set).
In gametypes like duel and da, the teamnames take the form of: clan/name.
drawStatString 20

Draws the team Alpha name
drawStatString 21

Draws the team Beta name

8. Tips back to top


8.1. CFG script for reloading HUD back to top


Here is an example of cfg script, which can help you during HUD scripting process. Create a text file, rename it to cfg_hud.cfg and add the following:
bind H "+hud"
alias +hud "cg_clientHUD classic;cg_specHUD classic;clear"
alias -hud "cg_clientHUD your_hud_name;cg_specHUD your_hud_name;exec cfg_hud"

Save the file, load the Warsow and type /exec cfg_hud in console. After that you will need to press H key in game to reload the hud.

8.2. I would like to use my own font. How can I do it? back to top


You can use any font in .ttf or .otf format. You should place it in /basewsw/fonts.

8.3. Which font should I use for text outputs? back to top


You can use any font you like, but you should remember since Warsow has UI translation it is better to use fonts which have full set of symbols (not only Latin!). Otherwise your messages couldn't be seen on other languages except Latin-based.

8.4. Where I can find examples to make my own HUD based on them? back to top


  • You can find HUDs in Warsow 1.5\basewsw\data0_15.pk3. Extract huds folder from pk3-file to Warsow 1.5\basewsw\.
  • other wise you can use custom HUDs which can be found in this wiki or at our forum




RSSRSSRSSRSS

Copyright © 2016 Chasseur de bots

Warsow in social media