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);
}
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);
}
}
}
}