equippable HUD

Discuss anything ZDoom-related that doesn't fall into one of the other categories.
Post Reply
User avatar
cortlong50
Posts: 753
Joined: Mon Jun 24, 2013 7:12 pm
Location: UT-WA

equippable HUD

Post by cortlong50 »

is there any way to give a player a custom hud through a pickup?

i cant really figure it out in my head, if anyone has an idea let me know!
User avatar
ramon.dexter
Posts: 1520
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: equippable HUD

Post by ramon.dexter »

Well, the easiest way i can imagine is some sort of ACS script with Hudmessage, or some inventory item with overlay...

Or some zscript trick.
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: equippable HUD

Post by wildweasel »

The way I'd have done it back in the SBARINFO days is to enclose the entire HUD in an InInventory [tokenitem] block. For multiple HUDs, use multiple blocks and different token items.

You could presumably do this a lot more cleanly using CVARs and Zscript now, but that's not something I can easily explain.
User avatar
NeuralStunner
 
 
Posts: 12325
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: equippable HUD

Post by NeuralStunner »

wildweasel wrote:The way I'd have done it back in the SBARINFO days is to enclose the entire HUD in an InInventory [tokenitem] block.
This was how I implemented a ROTT-like gasmask overlay for one thing, because I hate HUDMessage for images so much.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: equippable HUD

Post by Matt »

wildweasel wrote:You could presumably do this a lot more cleanly using CVARs and Zscript now, but that's not something I can easily explain.
Not sure if this is more clean, but...

In any event, if you need to completely replace the hud with this pickup you'll have to override the existing HUD anyway, so where ZScript really shines compared to SBARINFO is that you can just say "else super.draw();" and that should get you the regular hud if the item is absent.
User avatar
cortlong50
Posts: 753
Joined: Mon Jun 24, 2013 7:12 pm
Location: UT-WA

Re: equippable HUD

Post by cortlong50 »

Matt wrote:
wildweasel wrote:You could presumably do this a lot more cleanly using CVARs and Zscript now, but that's not something I can easily explain.
Not sure if this is more clean, but...

In any event, if you need to completely replace the hud with this pickup you'll have to override the existing HUD anyway, so where ZScript really shines compared to SBARINFO is that you can just say "else super.draw();" and that should get you the regular hud if the item is absent.
hey thanks for the link *clicks link....stares at it for like ten minutes...closes link. eye balls bleeding* i think its safe to say ive got a ways to go before figuring out zscript...because that looks like japanese to me man. i seriously cant wrap my head around it. im barely getting there with ACS. getting there, but could be better. but the info is super appreciated. i wish it was easer to get realtime results from zscript like you can in ACS just starting out.
NeuralStunner wrote:
wildweasel wrote:The way I'd have done it back in the SBARINFO days is to enclose the entire HUD in an InInventory [tokenitem] block.
This was how I implemented a ROTT-like gasmask overlay for one thing, because I hate HUDMessage for images so much.
i guess thats kinda what im asking...if i give them a "giveHUD" token or whatever...would it actually work? lets say they walk over and equip it...will they actually be given it, and could they in theory take it off at any time? (thats another one i havent figured out...like jonny5s weeather how you can toggle it...ive never been able to toggle scripts with key presses for some reason.

because if so i can definitely do that.

im just huge on not forcing anything on anyone. like i LOVED dead air...but man i really wish i could play it with vanilla assets.
User avatar
ramon.dexter
Posts: 1520
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: equippable HUD

Post by ramon.dexter »

cortlong50 wrote:
i guess thats kinda what im asking...if i give them a "giveHUD" token or whatever...would it actually work?
Yep, that will work.

Take a look at this part of my SBARINFO:

Code: Select all

InInventory GrenadeExplosive, 1 || GrenadeFire, 1 //check if one of the two types of grenades in inventory; if so, draws whats in {}
	{
		Alpha 0.5
		DrawImage "GRNBCK", -54, 0; //background of grenade display
		DrawImage "GRNFRM", -54, 0; //frame of grenade display
		
		InInventory GrenadeExplosive, 1 //actual grenade icon&amount display
		{
			DrawImage "IGRAP", -54, 0;
			//number
			Drawnumber 3, HUDFONT_STRIFE_YELLOW, yellow, "GrenadeExplosive", 367, 95;
		}
		
		InInventory GrenadeFire, 1
		{
			DrawImage "IGRIN", -54, 0;
			//number
			Drawnumber 3, HUDFONT_STRIFE_YELLOW, yellow, "GrenadeFire", 367, 114;
		}
	}
So, based on this example, you can do your HUD this way:

Code: Select all

InInventory giveHUD, 1
{
  //your HUD goes here
}
User avatar
gwHero
Posts: 360
Joined: Mon May 08, 2017 3:23 am
Graphics Processor: Intel with Vulkan/Metal Support
Location: The Netherlands

Re: equippable HUD

Post by gwHero »

cortlong50 wrote: hey thanks for the link *clicks link....stares at it for like ten minutes...closes link. eye balls bleeding* i think its safe to say ive got a ways to go before figuring out zscript...because that looks like japanese to me man. i seriously cant wrap my head around it.
LOL
cortlong50 wrote:i wish it was easer to get realtime results from zscript like you can in ACS just starting out.
Don't worry about ZScript. Yes with ZScript you have more control, more possibilities, but what you say here is true - if you wanna start learning it's simply not as easy as with ACS. Like Wildweasel and Ramon say this can be done with SBARInfo and InInventory too. It's more limited than ZScript but if it can be done there's nothing wrong with that, I've used it for years. Perhaps it's a good thing to keep ZScript just for stuff that's really not possible with ACS and when that occurs I'm sure there are enough people here that wanna help you out.
User avatar
cortlong50
Posts: 753
Joined: Mon Jun 24, 2013 7:12 pm
Location: UT-WA

Re: equippable HUD

Post by cortlong50 »

does anyone have any info on how to add and take things away with a keypress?

its weird, i have an example from J5s weather...but i seriously cant get it to work for anything else.

Like a keypress that gives them a token (or removes it) and takes the hud away?

thats my REAL struggle even though id think it was the easiest part
User avatar
ramon.dexter
Posts: 1520
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: equippable HUD

Post by ramon.dexter »

cortlong, you can always bind a script to key. And then define the rest in the script. So basically. the keypress will cal the script, which will do the rest.

edit: Allright, here is some little example (I was writing on tablet, where I dont have any doom stuff):

Code: Select all

addmenukey "Toggle Flashlight" toggleflashlight_bind //adds new key to be used
alias toggleflashlight_bind "pukename toggleflashlight"  //binds action to the key. In this case, an acs script called by the console command pukename.
defaultbind "F" toggleflashlight_bind //default bind of the key. Not neccessary.
Post Reply

Return to “General”