Jump to content

Gas in the room effect


Recommended Posts

So, i've been trying to create a room that starts poisoning you until you exit. script 37 is activated when you enter the room, and is terminated by script 38 when you exit the room. The problem I'm having is that the damage is not working at all. Also, I'm using "fadeto" to make the screen go green as you die, but after i make it go back to normal with the second script, it goes full green again seconds after it's restored.

Also it says "runway script 37" after a few seconds since it was activated

script 37 (void)
{
FadeTo (0, 255, 0, 0.8, 30.0);
delay (105);
while (ThingCount(T_NONE, 4));
{
delay(8);
DamageThing(5, MOD_UNKNOWN);
}
}

script 38 (void)
{
ACS_terminate (37, 0);
FadeTo (0, 0, 0, 0, 2.0);
}

EDIT: the thing with TID 4 is a random prop i assigned so that the poisoning won't stop until the script is terminated

Share this post


Link to post

1. Make sure that you activate script 37 by "ACS_Execute" linedef action, and NOT "ACS_ExecuteAlways", because scripts activated by this action cannot be terminated by "ACS_Terminate". This will bring side effects in multiplayer, though, because it means that the script cannot run more than one instance at a time. You might need to find a workaround, for example using a map scope variable. Script 37 will set the variable to 1, and then constantly check whether it is still 1 while looping, and if not, it will terminate itself. Script 38 will set the variable to 0, to tell script 37 that it should terminate itself.

2. That "ThingCount" gimmick is bad out of principle. Moreso, it always evaluates as false! It's because "ThingCount" only counts living monsters. Use "while(1)", it will loop forever. Or use "while(GetActorProperty(0,APROP_Health)>0)", it will loop until the script activator (=player) dies.

3. An already running FadeTo is (probably?) not automatically cancelled by calling another FadeTo over it. It doesn't matter that you terminated the script the first FadeTo was called from, the action will continue. You should call CancelFade right before every call of FadeTo in both your scripts. The wiki page gives you usage example similar to what you're achieving here.

Share this post


Link to post

Thank you. So, I solved the fading issue, but it still says "runway script 37 terminated" and the damage doesn't apply for some reason. The multiplayer thing is not a problem since this map is not going to have multiplayer support.

I tried putting the fadeto in a different script than the damage loop, to see if it was somehow affecting it, but that was not the problem. This is the code as it is now.

script 37 (void) //start gas
{
FadeTo (0, 255, 0, 0.45, 20.0);
ACS_execute (39, 0);
}

script 38 (void) //end gas
{
ACS_terminate (39, 0);
FadeTo (0, 0, 0, 0, 2.0);
delay (70);
CancelFade();
}

script 39 (void) // gas damage
{
while (1);
{
delay(8);
DamageThing(5, MOD_UNKNOWN);
}
}

Share this post


Link to post

Remove the semicolon after while(1). It causes to infinitely loop an empty command, instead of the actual damage loop in brackets. The engine automatically terminates the script then.

Share this post


Link to post

This is what I get for trying to use a derivate programming language without any proper knowledge of actual programming. thanks!

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...