Bloody HUD

Post your example zscripts/ACS scripts/etc here.

Bloody HUD

Postby Hey Doomer » Sat Oct 23, 2021 3:21 pm

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.
You do not have the required permissions to view the files attached to this post.
Hey Doomer
 
Joined: 25 Sep 2021
Operating System: Windows 11
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD with Vulkan Support

Return to Script Library

Who is online

Users browsing this forum: No registered users and 1 guest