Page 1 of 1

Bloody HUD

PostPosted: Sat Oct 23, 2021 3:21 pm
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 allExpand view
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 allExpand view
#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.