Bloody HUD

Post your example zscripts/ACS scripts/etc here.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
Hey Doomer
Posts: 283
Joined: Sat Sep 25, 2021 3:38 am

Bloody HUD

Post by Hey Doomer »

Blood splats on the HUD seem to be done a few ways. I like DAMAGEFX, but it breaks my little gray death mod. Here is a minimal bloody hud:

First an event handler that runs an ACS script with a random number attached to a graphic (BLD0, BLD1, etc.).

Code: Select all

class bh_EventHandler : EventHandler
{
  override
  void WorldThingDamaged(WorldEvent e)
  {
	if (e.thing && e.thing is "PlayerPawn")
	{
		e.thing.ACS_NamedExecuteAlways("bloodsplat", 0, Random(0,4), e.Damage, 0);
	}
  }
}
Here's the ACS. Arguments are the number of the image (can't send a string!) and the amount of damage taken.

Code: Select all

#library "bloodyhud"
#include "zcommon.acs"

script "bloodsplat" (int fnum, int dam)
{
    SetFont(StrParam(s:"BLD",d:fnum));
    HudMessage(s:"A"; HUDMSG_FADEOUT, 0, CR_UNTRANSLATED, Random(0, 1.0), Random(0, 1.0), Random(0.5, 1.0), Random(0.5, dam << 16));
}
I haven't thoroughly tested longer fades for more damage, resolutions, or other variations. And perhaps this can be done with less code. It seems like this should work with any mod, depending on how graphics are named. (Is the event priority the same as the load order? Hmm...)

I don't see that ZScript captures exceptions or queries image resources (I certainly could have missed something), so adding images means changing Random() args in the event handler. Easy enough I guess, but I'm open to suggestions.

Anyway, this works with the gray death mod.

Return to “Script Library”