Disable HUD for cutscene

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Obo

Disable HUD for cutscene

Post by Obo »

Hi, I want to disable the HUD and automap while playing a cutscene. I couldn't find a function that does this so I guess the the way to do it is by creating a completely empty HUD with no automap, but after looking at the zscript wiki I have no clue how.
So how do I, a: create an empty HUD with no automap, and b: toggle the switch in ACS?
User avatar
BrickJove
Posts: 25
Joined: Thu May 27, 2021 7:54 am

Re: Disable HUD for cutscene

Post by BrickJove »

1. Create the HideHud Actor:

Code: Select all

ACTOR HideHud : Inventory
{
  States
  {
  Spawn:
    TNT1 A -1
    Stop
  }
2. Write the ACS Script:

Code: Select all

script 401 ENTER
{
GiveInventory("HideHud",1);
}
Obo

Re: Disable HUD for cutscene

Post by Obo »

Ok, and how do you make the hud switch trigger when the player gets the item?
User avatar
BrickJove
Posts: 25
Joined: Thu May 27, 2021 7:54 am

Re: Disable HUD for cutscene

Post by BrickJove »

You have to script it. I use the map editor, e.g., DoomBuilder.
User avatar
Enjay
 
 
Posts: 26697
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Disable HUD for cutscene

Post by Enjay »

I'm guessing that an approach might be to have the HUD created in ZScript (basically a clone of the default one) but have a conditional statement that, in effect, says "if you have this item, don't draw anything". Or maybe it should be the other way around: "if you have this item, draw the HUD"?

Then you could give and take the item via in-game scripts to show/hide the HUD.

Would that work?
Obo

Re: Disable HUD for cutscene

Post by Obo »

Enjay wrote:
> I'm guessing that an approach might be to have the HUD created in ZScript
> (basically a clone of the default one) but have a conditional statement
> that, in effect, says "if you have this item, don't draw
> anything". Or maybe it should be the other way around: "if you
> have this item, draw the HUD"?
>
> Then you could give and take the item via in-game scripts to show/hide the
> HUD.
>
> Would that work?

Yes, that's what I want. I just don't know how to create a hud in Zscript that can toggle itself based on the players inventory.
User avatar
BrickJove
Posts: 25
Joined: Thu May 27, 2021 7:54 am

Re: Disable HUD for cutscene

Post by BrickJove »

Sorry, I forgot to mention this: you need to define HideHud (InInventory "HideHud") in SBARINFO. Here's my code:

Code: Select all

statusbar normal, fullscreenoffsets Alpha 1.0 // Standard JUPITER3D Status bar
{
 InInventory "HideHud"
   {
       // anything you need to display for cutscenes like letterbox bars
   }
   else
   {
     
      // regular hud code here
   

drawimage "JHUD",0,-37;

drawnumber 3, GB_Font, untranslated, health, alignment(left), 38, -8;
drawnumber 3, GB_Font, untranslated, armor, alignment(left), 38, -15;

	drawnumber 3, GB_Font, untranslated, ammo1, alignment(left), 76, -8;

	//keys
	drawswitchableimage keyslot 1, "nullimage", "STKEYS0", 82, -16;
	drawswitchableimage keyslot 2, "nullimage", "STKEYS1", 89, -16;
	drawswitchableimage keyslot 3, "nullimage", "STKEYS2", 96, -16;

	//drawnumber 3, INDEXFONT_DOOM, untranslated, ammo(Clip), 288, 173;
	//drawnumber 3, INDEXFONT_DOOM, untranslated, ammo(Shell), 288, 179;
	//drawnumber 3, INDEXFONT_DOOM, untranslated, ammo(RocketAmmo), 288, 185;
	//drawnumber 3, INDEXFONT_DOOM, untranslated, ammo(Cell), 288, 191;

	//drawnumber 3, INDEXFONT_DOOM, untranslated, ammocapacity(Clip), 314, 173;
	//drawnumber 3, INDEXFONT_DOOM, untranslated, ammocapacity(Shell), 314, 179;
	//drawnumber 3, INDEXFONT_DOOM, untranslated, ammocapacity(RocketAmmo), 314, 185;
	//drawnumber 3, INDEXFONT_DOOM, untranslated, ammocapacity(Cell), 314, 191;
	gamemode deathmatch, teamgame
	{
		drawnumber 2, HUDFONT_DOOM, untranslated, frags, 138, 171;
	}
	gamemode cooperative, singleplayer
	{
		//drawimage "STARMS", 118, 168;
		drawswitchableimage weaponslot 2, "None", "TF_2", 64, -14;
		drawswitchableimage weaponslot 3, "None", "TF_3", 67, -14;
		drawswitchableimage weaponslot 4, "None", "TF_4", 70, -14;
		drawswitchableimage weaponslot 5, "None", "TF_5", 73, -14;
		drawswitchableimage weaponslot 6, "None", "TF_6", 76, -14;
		drawswitchableimage weaponslot 7, "None", "TF_7", 79, -14;
		drawswitchableimage weaponslot 8, "None", "TF_8", 82, -14; 


	
	}
	gamemode cooperative, deathmatch, teamgame
	{
		//drawimage translatable "STFBANY", 143, 169;
	}

    drawselectedinventory alternateonempty, INDEXFONT, 9, 169
    {
        drawmugshot 4, animatedgodmode, XDeathFace, 0, -35;
    }
}
}
User avatar
Enjay
 
 
Posts: 26697
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Disable HUD for cutscene

Post by Enjay »

So, you do need to do pretty much what I said. ;)

I only suggested ZScript because I thought the default HUDs were now done with ZScript. Checking in GZDoom.pk3, they still seem to be SBARINFO code.
So, aside from the fact that it can be done in SBARINFO rather than ZScript, you do need to define a HUD that only shows when you do not have the item in question.
Obo

Re: Disable HUD for cutscene

Post by Obo »

[quote=Enjay post_id=1257669 time=1736623213 user_id=16]
you do need to define a HUD that only shows when you do not have the item in question.
[/quote]Yes, and that was the part I couldn't figure out how to code. :mrgreen: But with Joves example I think I'll manage now. Thanks.
User avatar
Enjay
 
 
Posts: 26697
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Disable HUD for cutscene

Post by Enjay »

BrickJove also posted a link to a Doomworld thread (but that post has since been deleted for some reason). Kinsie's post there shows a slight variation on the method that BrickJove posted, and how to get it working in ZScript too.

https://www.doomworld.com/forum/topic/1 ... cutscenes/

I haven't done it in SBARINFO myself - though I'm sure both variants work perfectly. Kinsie's one is, arguably, slightly simpler but BrickJove's one shows how to include a section where you can define some HUD elements to appear only when the normal HUD is hidden. So, that's potentially useful. I'm sure it's pretty obvious how Kinsie's example could also be extended to do something similar.

I can certainly vouch for the fact that the ZScript version works. Though, unless you re-do your status bar in ZSCript (which I guess is unlikely - I mean, why would you) you won't need that.


Edit: Oh, another couple of considerations.

I *think* I'm right in saying that there is nothing like this that can be done for the alternative HUD. So, if a player is using that, then their HUD will not get hidden.

Remember, that even when the camera is away from the player, they can still do stuff - this includes moving, firing weapons and whatever. If you don't want that to happen, then look into things such as SetPlayerProperty (especially PROP_TOTALLYFROZEN). But, bear in mind, they are potentially still vulnerable during the cutscene too. So you might also want to make them invulnerable, or teleport them away to a safe location during the cutscene. Just remember to unfreeze them, make them vulnerable, and put them back where they came from before the cutscene ends. ;)
Obo

Re: Disable HUD for cutscene

Post by Obo »

Cheers, thanks. Yea I've come across that link while searching for this. And the ACS is no problem for me. It's just that I've never really done anything complex with the statusbar. And when it comes to Zscript, outside of making new actors, I'm completely clueless what makes it tick. I've been looking for examples just how to draw an image on the statusbar without having to define a new hud and I don't understand from the examples what is required to do this. It's things like that, that are my problems...
User avatar
Enjay
 
 
Posts: 26697
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Disable HUD for cutscene

Post by Enjay »

Yep, I totally get that. I'm no programmer, but I know enough to (usually) be able to follow and make sense of code that has already been written. That usually allows me enough insight to tweak things fir my needs.

I can do the simple stuff, but coming up with something complex from scratch is often beyond me. I'm sure that on the occasions when I have managed to get something working, the code is very clumsy and naïve to an experienced eye.

Fortunately, there is usually someone around here to help out. :)
Jarewill
 
 
Posts: 1845
Joined: Sun Jul 21, 2019 8:54 am

Re: Disable HUD for cutscene

Post by Jarewill »

I am not sure if the question was already answered or not, but you can do it pretty easily with ZScript without redefining the entire status bar:

Code: Select all

Class HideHUD : Inventory{}

Class HidingBar : DoomStatusBar{
	Override void Draw(int state, double TicFrac){
		If(CPlayer.mo && !CPlayer.mo.FindInventory("HideHUD")){
			Super.Draw(state,TicFrac);
		}
	}
}
Then in MAPINFO you just add this:

Code: Select all

GameInfo{
	StatusBarClass = "HidingBar"
}
And give the player the HideHUD item anytime you want to hide it.

Edit:
Enjay wrote: Sat Jan 11, 2025 5:13 pm I *think* I'm right in saying that there is nothing like this that can be done for the alternative HUD. So, if a player is using that, then their HUD will not get hidden.
Good point, I keep forgetting that the alternative HUD exists.
Anyway, here's how you can remove it too:

Code: Select all

//ZScript
Class HidingAltBar : AltHUD{
	Override void Draw(PlayerInfo CPlayer, int w, int h){
		If(CPlayer.mo && !CPlayer.mo.FindInventory("HideHUD")){
			Super.Draw(CPlayer,w,h);
		}
	}
}

//MAPINFO (add to the GameInfo block alongside StatusBarClass)
AltHudClass = "HidingAltBar"
Obo

Re: Disable HUD for cutscene

Post by Obo »

Oh, so you put the code on the actor class itself. I would never have guessed that. Thanks.
User avatar
Enjay
 
 
Posts: 26697
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Disable HUD for cutscene

Post by Enjay »

That's a nice simple solution Jarewill, and you covered the Alt-HUD too. Useful stuff. :thumb:

Return to “Scripting”