mental image flashes periodically?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

mental image flashes periodically?

Post by Hidden Hands »

I've written up this code. When you walk over a linedef, it triggers a bloody image to flash on screen using the HUDMESSAGE function of ACS. It also plays a sounds to make the player jump. This is great, but what I really need is a way to have it repeatedly, but periodically play while in a certain area. Is there a way I can do this, and if so, could someone share an example please? My current code is this:

Code: Select all

//FEAR
str bludimage[8] =
{
	"TNT1A0",
	"BLUD1",
	"BLUD2",
	"BLUD3",
	"BLUD4",
	"BLUD5",
};

script 7 (void)
{
int blood = random(1,7);
ambientsound ("mental/blood", 255);
SetHudSize(800,600,TRUE);
SetFont(bludimage[blood]);
HudMessageBold(s:"A"; HUDMSG_FADEOUT, 253, 0, 400.0,300.0, 0.4, 0.3);
}
Thanks in advance.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: mental image flashes periodically?

Post by Jarewill »

You can try to make a While loop that will loop the script every few seconds as long as a variable is set.
Then you can unset the variable when the player exits the room.

Code: Select all

int bloodloop;
script 7 (void)
{
bloodloop=1;
While(bloodloop)
{
    int blood = random(1,7);
    ambientsound ("mental/blood", 255);
    SetHudSize(800,600,TRUE);
    SetFont(bludimage[blood]);
    HudMessageBold(s:"A"; HUDMSG_FADEOUT, 253, 0, 400.0,300.0, 0.4, 0.3);
    Delay(35*Random(30,120)); //Loop randomly every half minute / 2 minutes
}
}
Then you will also need a script that will set the variable to 0 when the player exits the room:

Code: Select all

Script 8 (void)
{
    bloodloop=0;
}
Post Reply

Return to “Scripting”