Custom Hud: Difference between revisions

393 bytes added ,  21 November 2025
m
no edit summary
No edit summary
mNo edit summary
 
(12 intermediate revisions by 8 users not shown)
{{warning|Creating HUDs with [[ACS]] should be considered [[Deprecation|deprecated]]. Authors are highly recommended to use [[ZScript]] HUD classes, such as '''{{class|BaseStatusBar}}'''.}}
{{TOCright}}
== Assumed Knowledge ==
== Scripting a Custom Hud ==
 
You can't disable or alterdisabled the built-in HUD, andby itfirst variesusing dependingSBARINFO onand how largeset the user has their screenheight setto to0. You have tocan have your script work around the existing HUD., Whatbut unless you canintend do,to thoughreuse parts, this is havenot recommended. To make your scriptHUD more user-friendly you should watch the value of the screenblocks CVAR (using [[GetCVar]]) and alter the HUD accordingly (try not to draw anything when the value is 12). The values correspond to the HUD as follows:<sup id="ref_hotwax">[[Custom Hud#endnote_hotwax|[1]]]</sup>
 
*3-9: There is a border around the player's view, and the status bar is displayed
 
'''1)''' If you use [[Doom Builder]], open MAP01 of your wad and select "Edit" from the "Scripts" menu. To display the new HUD bar, you use something like this:
 
<pre><nowiki>
Script 1 ENTER {{SType|Enter}}
{
[[SetHudSize]] (800, 600, 1{{const|TRUE}});
[[SetFont]]("HUDLUMP");
[[HudMessage]] (s: "a";{{const|HUDMSG_PLAIN}},1000,{{const|CR_UNTRANSLATED}},400.1,550.1,0.0);
}
 
</nowiki></pre>
In this script, SetFont tells Doom that the font to use is actually the lump name of your custom stat-bar graphic ("HUDLUMP"), and printing "a" in the HudMessage, as above, will display that graphic. Notice that it is also an "ENTER" script, because it needs to be activated by the player so that you can easily access their inventory and health information.<sup id="ref_cyrez">[[Custom Hud#endnote_cyrez|[2]]]</sup>
 
 
'''2)''' Next comes displaying the player information. We'll start with health:
 
<pre><nowiki>
[[SetHudSize]] (320, 200, 1{{const|TRUE}});
[[SetFont]]("BIGFONT");
[[HudMessage]] (i: [[GetActorProperty]](0,{{const|APROP_HEALTH}});
{{const|HUDMSG_PLAIN}},999,{{const|CR_UNTRANSLATED}},90.1,175.1,0.0);
 
</nowiki></pre>
Notice I've changed the sethudsize to accomodate the font "BIGFONT", and the HudMessage coordinates will vary as a result. Finally, notice that the HudMessage ID is ''lower'' than that of the stat-bar HudMessage ID so that the health count will display ''infront'' of the stat-bar.
 
 
Using other HudMessages such as:
<pre><nowiki>
HudMessage (i: CheckInventory("Armor");
HUDMSG_PLAIN,999,CR_UNTRANSLATED,175.1,175.1,0.0);
 
[[HudMessage]] (i: [[CheckInventory]]("Clip{{class|Armor}}");
{{const|HUDMSG_PLAIN}},999,{{const|CR_UNTRANSLATED}},175.1,175.1,0.0);
</nowiki></pre>
[[HudMessage]] (i: [[CheckInventory]]("Armor{{class|Clip}}");
{{const|HUDMSG_PLAIN}},999,{{const|CR_UNTRANSLATED}},175.1,175.1,0.0);
 
...you will also be able to figure out how to display the armor and ammo counts.
 
 
'''3)''' And finally, while this may sound tricky, it's actually very straightforward - turning your custom stat-bar on and off according to how the player has their HUD displayed, as discussed earlier.
 
<pre><nowiki>
if (getcvar[[GetCVar]] ("screenblocks") <= 10)
{ /*Do your Custom Hud Stuff here*/}
else
{ /*Turn it off with HudMessages that print nothing*/}
 
</nowiki></pre>
These are obviously the very basic concepts you need to be familiar with in order to script your own custom hud. Use what you've learnt here, and have a look through the example scripts posted below to try and understand more about it.
 
== Example Scriptsscripts ==
 
* [[Barista]]'s [http://wwwweb.archive.org/web/20080505052402/http://blended.planethalflife.gamespy.com/blended/barista/script_barista.lmp Barista's HudHUD Scriptscript]
* [http[:File://www.zdoom.org/wiki/images/3/3d/JonathansHud.acs Jonathon|Jonathan's HudHUD Script]]
 
==References==
== See Also ==
[[Tutorials]]
 
[[category:ACS guides]]