SBARINFO
From ZDoom Wiki
SBARINFO allows for custom status bars to be made without the need for ACS. Only the last SBARINFO lump will be read. If there is a need for more than one SBARINFO lump another can be included with the #include funtion. (#include syntax is identical to DECORATE.)
The syntax requires that all image names be in quotes. When something must have no image, for example the "off" sprite in a weapon indicator when you don't have that weapon, you can specify "" for "no image, leave it blank (unless otherwise noted)". The string "nullimage" can also be used for this. Note: an empty image cannot currently be used in place of the "default" argument of DrawMugShot.
As of r980, mugshot scripting may be used with the default Doom status bar. Simply do not define any status bars to use.
Where flags are specified the pipe operator ("|") can be used instead of commas.
Top Level Commands
Base <game>
Set the status bar to the specified game. As of right now the resulting status bar can not be modified. Valid games are Doom, Heretic, Hexen, Strife, and None.
Height <height>
Sets the height of the status bar. When set you will be expected to cover all the area between points (0, 200-height) and (320, 200). If the area is not covered a HOM will be drawn instead.
InterpolateHealth {true|false} [, <speed>]
Interpolates the value drawn for health. This is useful for drawing life bars so that the gem will smoothly move between positions like in Heretic and Hexen. Speed is by default set to 8 which is the same as used for Heretic (Hexen used 6). Speed is measured in hp per tic.
InterpolateArmor {true|false} [, <speed>] (development version only)
Similar to InterpolateHealth, interpolates the value drawn for armor. Speed is set to 8 by default.
CompleteBorder {true|false}
Continues drawing the border where the status bar is normally placed. Using this will remove the HOM.
MonospaceFonts {true|false}, <character> (development version only)
Monospaces all fonts to the specified character of their font.
LowerHealthCap {true|false} (development version only)
Sets whether health should go no lower than 0. Default is true.
CreatePopup <name>, <width>, <height>, <transition> [, transition args (see below)] (development version only)
Sets the transition effect for the specified popup (log, keys, status). Width and Height help the transition determine a starting point. For None this could technically be anything. The transition can be any of the following:
- None - Popup will appear instantly when activated. (No additional args)
- SlideInBottom - Popup will slide up from the bottom at the specified speed pixels per tic. (Args: <speed>)
- Fade - Popup will fade in to the translucency of the status bar. Both args are floats and represent the amount in time in seconds for the fade to complete. (Args: <fade-in speed>, <fade-out speed>)
StatusBar <stbar> [, <flags>...] [, <alpha>]
Begins the drawing routine for the specified status bar. Valid status bars are:
- None - Draws where there is supposed to be no statusbar. Should be used sparingly.
- Fullscreen - ZDoom's fullscreen hud.
- Normal - Standard status bar.
- Automap - Used for Hexen style auto map status bars.
- Inventory - Inventory bar drawn over the Normal status bar.
- InventoryFullscreen - Inventory bar drawn over the fullscreen hud.
- PopupLog - Strife popup for the log. (development version only)
- PopupKeys - Strife popup for keys. (development version only)
- PopupStatus - Strife popup for the stats. (development version only)
- forcescaled - Forces the status bar to be scaled even if the user has scaling off. This flag is ignored on the Inventory and InventoryFullscreen bars,
- fullscreenoffsets - Changes the coordinate system to be relative to a corner of the screen. Using positive or negative values will change which side of the screen the offset is from: a positive x value is from the left, a negative one is from the right; a positive y value is from the top, and a negative one from the bottom. For example, a y coordinate of 32 will position the bar 32 pixels from the top of the screen, while a y coordinate of -32 will position it 32 pixels from the bottom. (development version only)
Alpha is a value from 0.0 to 1.0 with 0.0 being invisible and 1.0 being opaque.
DrawImage [translatable] <image>, <x>, <y> [, {center|centerbottom}]
Draws "image" to the screen at the specified coordinates, which are absolute coordinates on a scaled screen. By default the coordinates are referenced by the top left corner of the image. Specifying center will change this behavior to be the vary center of the image (taking the image offsets into consideration).
If translatable is specified the image will translate itself to the player's color.
In addition to an image lump name a few special values can be used.
- playericon - Draws the player.scoreicon for the user's playerclass.
- armoricon - Draws an image of the currently in use armor type. If the amount of armor the player has is 0, nothing will be displayed.
- weaponicon - Draws the inventory.icon of the currently selected weapon.
- ammoicon1 - Draws the primary ammo icon.
- ammoicon2 - Draws the secondary ammo icon.
- sigil - Draws the proper icon for the Sigil. (development version only)'
- hexenarmor <armor>, <image> - Fades the image based on the availability of the specified Hexen armor (armor, shield, helm, amulet) (development version only)
DrawSwitchableImage weaponslot <#>, <image-off>, <image-on>, <x>, <y> [, {center|centerbottom}]
DrawSwitchableImage invulnerable, <image-on>, <image-off>, <x>, <y> [, {center|centerbottom}]
DrawSwitchableImage keyslot <#> [&& <#>, <image0>, <image1>], <image2>, <image3>, <x>, <y> [, {center|centerbottom}] (development version only)
Special cases of DrawSwitchableImage. See below.
DrawSwitchableImage <inventory-item> [&& <inventory-item>, <image0>, <image1>], <image2>, <image3>, <x>, <y> [, {center|centerbottom}]
Draws a particular image if the player as a particular item. The item may be any sub-class of Inventory. If a 2nd item is specified, an additional two images are required. If the player is carrying the item then image3 is drawn, else image 2 is drawn. If two items are specified, than image0 is drawn if the player is holding none of the items, image1 if the player is holding item1, image2 if the player is holding just the 2nd, and image3 if the player is holding both.
DrawNumber <size>, <font>, <color>, <value>, [flags, ...,] <x>, <y> [, <fontspacing>] [, <translation-low>, <low-value> [, <translation-high>, <high-value>]]
Draws a number at the specified location. The first argument specifies the size of the number in digits (Doom's statusbar is set to size 3, for three-digit numbers). The font must be a ZDoom font or defined in FONTDEFS. The font will be translated to color, which can be a color defined in TEXTCOLO. Fontspacing will put the specified amount of pixels between each character (default is 0). If a low translation is provided then that translation will be used if the value is less than or equal to the specified. If a high translation is provided then that translation will be used when the value is greater than or equal to the specified.
For number, you can either supply a constant number, an inventory item, or one of the following:
- Health - The player's current health level.
- Armor - The amount of armor the player is currently carrying.
- ArmorClass - Draws the Hexen armor class of the player. (development version only)
- Ammo1 - The amount of primary ammo for the current weapon.
- Ammo2 - The amount of secondary ammo for the current weapon.
- Frags - The number of frags the player has achieved.
- Kills - The number of monsters that have been killed.
- Monsters - The total number of monsters in the map.
- Items - Number of items picked up.
- TotalItems - Total number of items in the map.
- Secrets - Number of secrets found.
- TotalSecrets - Total number of secrets in the map.
- Ammo <AmmoType> - The amount of the specified ammo the player is holding.
- AmmoCapacity <AmmoType> - The maximum amount of the specified ammo the player can hold.
- PowerupTime <PowerupGiver> - Displays the amount of time left for a given powerup. (development version only)
- GlobalVar <num> - Prints the specified global variable in acs. (development version only)
- GlobalArray <num> - Prints the value in a global array with the index of the playernumber. (development version only)
Flags are: (development version only)
- fillzeros - Fills the number up to size with zeros. If the number is negative the negative sign will take the first digit's position and the size will be changed accordingly.
- whennotzero - Only draws the number if the value is not zero.
- drawshadow - Will also draw a translucent number two pixels to the right and two pixels down. (development version only)
Also keep in mind that for DrawNumber and DrawString, text will be right-justified, so coordinates specified should be the rightmost portion and not the leftmost like with images.
DrawMugShot <default>*, <accuracy> [, flags, ...], <x>, <y>
Draws a mug shot at the specified location. It will prefix the image to what is specified in default and will automatically adjust itself to skins. Accuracy can be a number 1-9 which specifies how many blood levels there are before death. Flags are:
- xdeathface - Will draw ***XDTH0-***XDTH5 when the player is gibed.
- animatedgodmode - ***GOD1 and ***GOD2 will also be displayed while in god mode.
- disablegrin - Disables the grin state. (development version only)
- disableouch - Disables the ouch state. (development version only)
- disablepain - Disables the pain state. (development version only)
- disablerampage - Disables the rampage state. (development version only)
* This argument is optional on the development versions and should no longer be used if possible. Use playerclass faces instead.
DrawInventoryBar <style> [, flags, ... ], <size>, <font>, <x>, <y> [, <counterx>, <countery> [, <translation> [, <fontspacing>]]]
Draws a inventory bar at x, y, with size item places. The font is used for the amounts. Flags are:
- alwaysshow - Draw the bar even if no items are present.
- noartibox - Will not draw atrifact boxes.
- noarrows - Will not draw the arrows telling the user there are more items to the left and/or right of the viewable items.
- alwaysshowcounter - Will show the amount even if the player is holding 1 of the said item.
- translucent - Draws the entire inventory bar with translucency. (development version only)
| Warning: In the latest development version the spacing is determined by the width (after scaling) of the ARTIBOX graphic plus 1 pixel for all styles but Strife. On the strife style the spacing is the scaled width of INVCURS minus 1 pixel. |
Style can be any of the following:
- Doom - Standard inventory bar.
- Heretic - Same as Doom but SELECTBO is drawn 29 pixels lower.
- Hexen - Same as Doom but SELECTBO is drawn 1 pixel higher. (development version only)
- Strife - SELECTBO is changed to INVCURS. INVCURS is drawn behind the icons. Each item is given 35 pixel spacing instead of 31 pixels. In addition INVCURS is drawn at (x-6, y-2). (development version only)
The final optional arguments deal with the font. Counterx and countery is where the numbers should start drawing. If these are not specified, the default is x+26 for counterx and y+22 for countery. See DrawNumber for information on translation and fontspacing.
DrawSelectedInventory [flags, ..., ] <font>, <x>, <y> [, <counterx>, <countery> [, <translation> [, <fontspacing>]]]
Draws the selected inventory item at the specified location with the specified font for the amount. See DrawInventorybar for the optional arguments. The default for counterx is x+30 and y+24 for countery. Flags are:
- alternateonempty - Executes a sub block if the player is holding no inventory items.
- artiflash - Displays a Heretic/Hexen style artifact flash when an item is used.
- alwaysshowcounter - Displays the counter even if the the player is only holding 1 of the item.
If alternateonempty is specified the semicolon must be removed and everything in the sub block will be executed.
DrawBar <fgimage>, <bgimage>, <number>, {horizontal|vertical}, [flags, ..., ] <x>, <y> [, <border>]
Draws a bar using a truncated form of fgimage over bgimage (or black if nullimage is used). Fgimage and bgimage must be the same size. Number can be any of the values from DrawNumber with the exception of AmmoCapacity, Monsters, TotalItems, and TotalSecrets. If health or armor is used you can optionally specify an inventory item to represent the max amount the player can hold. If border is supplied then the specified amount of pixels on each side from the foreground will always be drawn. Flags are as follows:
- reverse - Reverses the direction of the bar (see below for defaults).
If the bar is horizontal it will default to left to right. For vertical it defaults to bottom to top as in Hexen.
DrawGem [flags, ..., ] <chainimage>, <gemimage>, <leftpadding>, <rightpadding>, <chainsize>, <x>, <y>
Draws a Heretic style life gem. The gem can move anywhere on the chainimage unless paddings are specified. The chain will shift a maximum of chainsize pixels to the right while the gem is moving. Flags are:
- wiggle - Enable Heretic style wiggling.
- translatable - Add player color translations to the gem image.
- armor - Changes the value represented from health to armor. (development version only)
- reverse - Reverses the direction of the gem. (development version only)
DrawShader <width>, <height>, {horizontal|vertical}, [reverse, ] <x>, <y>
Draws a transparency gradient at the specified location. The default is to go from left to right (dark to bright) or bottom to top.
DrawString <font>, <translation>, <string>, <x>, <y> [, <spacing>*]
Draws the string at the specified coordinates. Like drawnumber, the coordinates specify the top right hand corner of the string.
* (development version only)
DrawKeyBar <size>, {vertical|horizontal}, [flags*, ..., ] <icon-size>, <x>, <y> [, <keyoffset>* [, <rowsize>*, <rowicon-size>*]]
Draws the inventory icon of all the keys the player is holding (up to the specified size). The icons will be placed icon-size pixels apart. On a vertical bar the keys start at the top and move to the bottom. On a horizontal they go left to right.
(development version only)
Icon sizes may be auto to have the bar space the icons automatically. Key offset will offset which keys are drawn. For example if the player has 6 keys and the first keybar hold 3 keys it will show key 1-3. If the second bar has an offset of 3, then it will show keys 4-6. Rowsize is how many keys should be displayed in a row/column. Rows/columns go left to right on vertical bars and top to bottom on horizontal bars. Rowicon-size specifies the spacing between rows/column.
The only flag is reverserows , which changes the rows to go right to left on vertical bars and bottom to top on horizontal bars.
* (development version only)
GameMode <gamemode> [, ...]
Executes the following sub block only if the user is playing one of the specified game modes. Valid game modes are singleplayer, cooperative, deathmatch, and teamgame.
PlayerClass <classname> [, <classname2> [, <classname3>]]
Executes the following sub block only if the player is one of the specified classes (represented by their display name).
AspectRatio {"4:3" | "5:4" | "16:9" | "16:10"} (development version only)
Executes the following sub block only if the player is using the specified aspect ratio.
UsesSecondaryAmmo [not] (development version only)
Checks if the current weapon has a secondary ammo type. If so it will execute the sub block. Adding "not" will invert the result.
HasWeaponPiece <weapon>, <piecenum> (development version only)
Executes the following sub block if the player is holding the specified piece for the specified weapon.
IsSelected [not] <weapon1> [, <weapon2>] (development version only)
Executes the following sub block only if the player is (not) using one of the two specified weapons.
WeaponAmmo [not] <ammo1> [{&& | ||} <ammo2>]
Executes the sub block only if the weapon uses the specified ammo (be it primary or secondary). If ammo2 is specified then the result will depend on the operator. If "&&" is used then both ammo types must match one or the other. If "||" is used then only one ammo type must match. If the weapon does not use any ammo then it will always evaluate to true. The "not" inverses the result.
InInventory [not] <item1> [{&& | ||} <item2>] (development version only)
Executes the following sub block if the specified items are (not) in the players inventory. You can optionally specify a 2nd item with a comparison operator. "Not" inverts the result.
Mug Shots
(development version only)
The mug shot can be scripted with a series of states. A list of states with a special purpose is given below:
- Normal - The default face when starting.
- Pain - When the player has been damaged.
- Ouch - Shown instead of pain when the player picks up health while being damaged.
- Rampage - Shown when the player holds down one of the fire buttons.
- Grin - Weapon pickup face.
- Death - Normal death.
- XDeath - Extreme death, this state must be enabled by a drawmugshot flag.
- God - Standard Invulnerability.
- GodAnimated - Invulnerability when "animatedgodmode" is set.
In addition you can also create pain, ouch, death, and xdeath states for any custom damage types that may be in use. The syntax for that is "State.DamageType".
mugshot "StateName"[, flags, ...]
{
frame duration;
// OR
{frame1[, ...]} duration;
}
Each frame may be 5 letters long (proper prefix will be added later) and may have a duration of -1 (infinite) or any positive number (except for 0). In addition you can list frame names in braces to have SBarInfo pick a random graphic from those named. Every frame must end in a semi-colon.
Now there are some flags (listed after the state name) that you can use to change how SBarInfo reads the frames. They are as follows:
- health - Makes the last character of every frame represent the health level. It works by adding the level to the character specified in the definition so you may use any style you want as long as the characters are consecutive (ST0A, ST0B, ST0C, etc would be fine as long as you specify ST0A in SBARINFO).
- health2 - Same as health except it applies the effect to the second character from the end.
- healthspecial - Applies health to the middle frame and health2 to all other frames.
- directional - Changes the meaning of frames in braces. Instead of picking a random frame it will pick one of three frames like so: {left, middle, right}. This is only useful for the pain or ouch states which calculate the direction of damage. Otherwise only the middle will be shown.
SBARINFO does support custom states of any name which can be called by the ACS function SetMugShotState.
Examples
The following creates a near perfect recreation of the original doom status bar. The full screen bar is not entirely accurate.
height 32;
statusbar fullscreen
{
drawimage "MEDIA0", 20, 196;
drawnumber 3, HUDFONT_DOOM, red, health, 80, 180;
drawimage armoricon, 20, 172;
drawnumber 3, HUDFONT_DOOM, red, armor, 80, 156;
drawimage ammoicon1, 306, 196;
drawnumber 3, HUDFONT_DOOM, red, ammo1, 295, 180;
drawimage ammoicon2, 306, 172;
drawnumber 3, HUDFONT_DOOM, red, ammo2, 295, 156;
gamemode deathmatch, teamgame
{
drawnumber 2, HUDFONT_DOOM, red, frags, 276, 1;
}
gamemode cooperative, singleplayer
{
drawswitchableimage BlueCard, "nullimage", "STKEYS0", 308, 2;
drawswitchableimage YellowCard, "nullimage", "STKEYS1", 308, 12;
drawswitchableimage RedCard, "nullimage", "STKEYS2", 308, 22;
drawswitchableimage BlueSkull, "nullimage", "STKEYS3", 298, 2;
drawswitchableimage YellowSkull, "nullimage", "STKEYS4", 298, 12;
drawswitchableimage RedSkull, "nullimage", "STKEYS5", 298, 22;
}
drawselectedinventory INDEXFON, 306, 148;
}
statusbar normal
{
drawimage "STBAR", 0, 168;
drawimage "STTPRCNT", 90, 171;
drawimage "STTPRCNT", 221, 171;
drawnumber 3, HUDFONT_DOOM, red, ammo1, 44, 171;
drawnumber 3, HUDFONT_DOOM, red, health, 90, 171;
drawnumber 3, HUDFONT_DOOM, red, armor, 221, 171;
//keys
drawswitchableimage BlueCard && BlueSkull, "nullimage", "STKEYS0", "STKEYS3", "STKEYS6", 239, 171;
drawswitchableimage YellowCard && YellowSkull, "nullimage", "STKEYS1", "STKEYS4", "STKEYS7", 239, 181;
drawswitchableimage RedCard && RedSkull, "nullimage", "STKEYS2", "STKEYS5", "STKEYS8", 239, 191;
drawnumber 3, INDEXFON, gold, ammo Clip, 288, 173;
drawnumber 3, INDEXFON, gold, ammo Shell, 288, 179;
drawnumber 3, INDEXFON, gold, ammo RocketAmmo, 288, 185;
drawnumber 3, INDEXFON, gold, ammo Cell, 288, 191;
drawnumber 3, INDEXFON, gold, ammocapacity Clip, 314, 173;
drawnumber 3, INDEXFON, gold, ammocapacity Shell, 314, 179;
drawnumber 3, INDEXFON, gold, ammocapacity RocketAmmo, 314, 185;
drawnumber 3, INDEXFON, gold, ammocapacity Cell, 314, 191;
gamemode deathmatch, teamgame
{
drawnumber 2, HUDFONT_DOOM, red, frags, 138, 171;
}
gamemode cooperative, singleplayer
{
drawimage "STARMS", 104, 168;
drawswitchableimage weaponslot 2, "STGNUM2", "STYSNUM2", 111, 172;
drawswitchableimage weaponslot 3, "STGNUM3", "STYSNUM3", 123, 172;
drawswitchableimage weaponslot 4, "STGNUM4", "STYSNUM4", 135, 172;
drawswitchableimage weaponslot 5, "STGNUM5", "STYSNUM5", 111, 182;
drawswitchableimage weaponslot 6, "STGNUM6", "STYSNUM6", 123, 182;
drawswitchableimage weaponslot 7, "STGNUM7", "STYSNUM7", 135, 182;
}
gamemode cooperative, deathmatch, teamgame
{
drawimage translatable "STFBANY", 144, 169;
}
drawselectedinventory alternateonempty, INDEXFON, 143, 168
{
drawmugshot "STF", 5, 143, 168;
}
}
statusbar inventory
{
drawinventorybar Doom, 7, INDEXFON, 50, 170;
}
statusbar inventoryfullscreen
{
drawinventorybar Doom, 7, INDEXFON, 50, 170;
}
Next is an example of mug shot definitions:
mugshot "Normal", health2
{
{ST00, ST01, ST02} 17;
}
Finally, an example of using the 'fullscreenoffsets' statusbar flag:
Statusbar FullScreen, FullScreenOffsets
{
//Bottom Left
//Lives from Inventory with Icon
DrawImage "LIFEA0", 14, -1;
DrawNumber 1, CONFONT, WHITE, Life, 35, -10;
//Top Right
//Keys
DrawKeyBar 2, vertical, 13, -8, 0;
//Bottom Right
//Points Variable from Global Array 0, index PlayerNumber()
DrawNumber 8, CONFONT, WHITE, GlobalArray 0 , -2, -25;
//Ammo and Icon
DrawImage AmmoIcon1, -105, -1;
DrawNumber 2, CONFONT, WHITE, Ammo1, -80, -10;
//Health and Icon
DrawImage "HLTHE0", -50, -1;
DrawNumber 3, CONFONT, WHITE, Health, -2, -10;
}

