Blink

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

Blink

Post by Hey Doomer »

Getting hurt should have real world consequences. This is my try at simulating blinking by calling FadeTo and FadeRange according to health when damaged or entering a level. Here's the ACS:

Code: Select all

#library "blink"
#include "zcommon.acs"

script "blinkEnter" ENTER
{
    int health = GetActorProperty(0, APROP_Health);

    if (health < 30)
    {
        ACS_NamedExecute("blinkVerySlow", 0, 0, 0, 0);
    }
    else if (health < 50)
    {
        ACS_NamedExecute("blinkSlow", 0, 0, 0, 0);
    }
    else
    {
        ACS_NamedExecute("blinkFast", 0, 0, 0, 0);
    }
}

script "blinkFast" (void)
{
    ACS_NamedExecuteWait("blinkOn", 0, 0, 0, 0);
    ACS_NamedExecuteWait("blinkOff", 0, 2, 0, 0);
    delay(35 * 2);
    ACS_NamedExecuteWait("blinkOn", 0, 0, 0, 0);
    ACS_NamedExecuteWait("blinkOff", 0, 1, 0, 0);
}
script "blinkSlow" (void)
{
    ACS_NamedExecuteWait("blinkOn", 0, 0, 0, 0);
    ACS_NamedExecuteWait("blinkOff", 0, 4, 0, 0);
    delay(35 * 4);
    ACS_NamedExecuteWait("blinkOn", 0, 1, 0, 0);
    ACS_NamedExecuteWait("blinkOff", 0, 2, 0, 0);
   
}
script "blinkVerySlow" (void)
{
    ACS_NamedExecuteWait("blinkOn", 0, 0, 0, 0);
    ACS_NamedExecuteWait("blinkOff", 0, 6, 0, 0);
    delay(35 * 6);
    ACS_NamedExecuteWait("blinkOn", 0, 2, 0, 0);
    ACS_NamedExecuteWait("blinkOff", 0, 4, 0, 0);
   
}
script "blinkOn" (int seconds)
{
    FadeTo (0, 0, 0, 1.0, seconds << 16);
}

script "blinkOff" (int seconds)
{
    FadeRange (0, 0, 0, 1.0, 0, 0, 0, 0.0, seconds << 16);
}
... and here's the event handler:

Code: Select all

class blink_EventHandler : EventHandler
{
	override
	void WorldThingDamaged(WorldEvent e)
	{
		if (e.thing && e.thing is "PlayerPawn")
		{
			if (e.thing.health < 30)
			{
				e.thing.ACS_NamedExecute("blinkVerySlow", 0, 0, 0, 0);
			}
			else if (e.thing.health < 50)
			{
				e.thing.ACS_NamedExecute("blinkSlow", 0, 0, 0, 0);
			}
			else
			{
				e.thing.ACS_NamedExecute("blinkFast", 0, 0, 0, 0);
			}
		}
	}
}
There are a few possibilities depending on how tough you think a space marine should be when shot in the face, torched by a fireball, dropped in lava, slammed by a rocket, or otherwise made to feel unloved. This works OK with "Bloody HUD:" the screen is bloody with eyes closed a moment. I've tested this minimally, and it seems to work so far as an idea.

Return to “Script Library”