Jump to content
  • 0

A dumb problem I'm having with ACS Scripts (UDMF)


Zulk RS

Question

Using scripts I made added an "elevator" to the map that gives the player the illusion of going down to a floor that runs below the map. I'm including the script below but I believe the problem is less with the script and more with player behavior.

 

SCRIPT 4 (void)
{
	If(GameType() == GAME_SINGLE_PLAYER)
	{
		Floor_LowerByValueTimes8(11,16,32);
		Ceiling_LowerByValueTimes8(11,16,32);
		Floor_RaiseByValueTimes8(12,64,32);
		Ceiling_RaiseByValueTimes8(12,64,32);
		Delay(35*1);
		Floor_LowerByValueTimes8(12,16,32);
		Ceiling_LowerByValueTimes8(12,16,32);
		Delay(35*1);
		Teleport_NoFog(0,0,12,1);
		Delay(35*2);
		Floor_RaiseByValueTimes8(11,64,32);
		Ceiling_RaiseByValueTimes8(11,64,32);
	}
	else
	{
		Teleport_NoFog(0,0,12,1);
		
	}
	
		
}

SCRIPT 5 (void)

{
	If(GameType() == GAME_SINGLE_PLAYER)
	{
		Floor_RaiseByValueTimes8(12,16,32);
		Ceiling_RaiseByValueTimes8(12,16,32);
		Floor_LowerByValueTimes8(11,64,32);
		Ceiling_LowerByValueTimes8(11,64,32);
		Delay(35*1);
		Floor_RaiseByValueTimes8(11,16,32);
		Ceiling_RaiseByValueTimes8(11,16,32);
		Delay(35*1);
		Teleport_NoFog(0,0,11,1);
		Delay(35*2);
		Floor_LowerByValueTimes8(12,64,32);
		Ceiling_RaiseByValueTimes8(12,64,32);
	}
	
	else
	{
		Teleport_NoFog(0,0,11,1);
	}
}

What the script is supposed to do is:

  1. Player enters a room, A and presses the switch.
  2. The whole room starts going down. Unseen by the player, the switch moves a different room, B, up.
  3. 1 second later, Room B starts moving down.
  4. When Room A gets halfway down player is teleported to Room B which is also going down
  5. Room B and Room A both stop with the player in room B.
  6. Room A is set back to the starting position.

 

This same effect happens in reverse when player goes to Room A from Room B. When Room B with the player in it has stopped, if the player waits a second or two and presses the switch in Room B, the following happens:

  1. The whole room B starts going up. Unseen by the Player, Room A moves down quickly.
  2. 1 Second later, Room A starts going up.
  3. When Room B is halfway up, player is teleported to Room A which is also going up.
  4. Room B and Room A both stop with the player in Room A
  5. Room B goes back to starting position

 

This works well. However, if the player spams use on the wall where Room B 's switch would appear as soon as they teleport into Room B, Script 5 executes before Script 4 can begin. Thus this conflicts with the motion of Room A and breaks the map. How to I prevent Script 5 from executing while Script 4 is running or vice-versa?

Share this post


Link to post

6 answers to this question

Recommended Posts

  • 1

If your problem is to be sure that only one of those two scripts runs at any given time you can proceed as follows:

 

First you have to declare a general variable, outside of any script (you can write it just under the zcommon.acs line), and give to it a boolean value. This variable will check if script 4 is running or not. For example:

 

Int check4 = TRUE;


After that you have to add another "if"  that contains the entirety of your script 5 code. This if will check the current status of script 4.

 

Script 5 (void)

{

      If != check4

          {

                your script 5 code

          }

}

 

Now script 5 will only execute if check4 is FALSE (since the previous if works with "not check4"), therefore when script 4 is not active.

The last thing that you have to do to make this thing work is to add a line at the end of your script 4 code that changes the value of check4:

 

Script 4 (void)

{

       your script 4 code

       delay (35*2);

       check4 = FALSE;

}

 

This way you can control the behaviour of script 5 using a variable that changes its value in script 4 after 2 seconds (you have said that the player has to wait 2 seconds to make everything work properly, so that's the reason of the delay).

However this works only one time and only for script 4. Now that the process is (hopefully) clear I will write in the spoiler below the complete procedure.

Spoiler

If you want to use the fake elevator more than once you have to check even if script 5 is running or not, or you will run in the exact same problem, this time with the switch that controls script 4.

 

You have to declare a second general variable in order to control script 5.

 

int check4 = TRUE;

int check5 = FALSE;

 

Now you want to change those two variables accordingly to the current status of your scripts:

 

Script 4 (void)

{

        If != check5

                {

                        your script 4 code

                        delay (35*2);

                        check4 = FALSE;

                        check5 = TRUE;

               }

}

 

Script 5 (void)

{

        If != check4

               {

                      your script 5 code

                      delay (35*2);

                      check4 = TRUE;

                      check5 = FALSE;

               }

}

 

Share this post


Link to post
  • 0

Look to Script control and Waiting for a possible solution

 

Instead of 

Floor_LowerByValueTimes8(11,16,32);
Ceiling_LowerByValueTimes8(11,16,32);

 

you could use 

FloorAndCeiling_LowerByValue ( 11, 16, 256);

 

and likewise for Raise
 

Edited by Kappes Buur

Share this post


Link to post
  • 0
12 hours ago, Kappes Buur said:

Look to Script control and Waiting for a possible solution

 

 

ScriptWait might be a good solution though I now need something to check if the other script is running or not. Is there anyway to have the script 4 check if script 5 is running and only run ScriptWait if it is?

Share this post


Link to post
  • 0

Final Update:

 

So I changed up my approach a bit and came up with a solution; not the best solution but A solution.

 

At the end of the day, I didn't really need to change floor and ceiling heights; I just needed to give the illusion of an elevator going up and down. So I redid the code to cause walls to scroll up and down instead of actually moving the floor and ceiling. The code now temporarily locks the player in the room, scrolls the walls to pretend that the room is moving down. teleports, then stops scrolling before opening the door.

 

If the player spams use on the buttons, it still breaks the script but it instead of locking the player in an inescapable room like it used to, it just teleports and opens the doors while the walls are still scrolling. This breaks the illusion but does not really effect game-play in any meaningful way aside from maybe reducing immersion.

 

SCRIPT 4 (void)
{
	If(GameType() == GAME_SINGLE_PLAYER)
	{
		
		Door_Close(13,64);
		Delay(35*1);
		Scroll_Texture_Both(14,0,0,0,64);
		Delay(35*3);
		Teleport_NoFog(0,0,12,1);
		Delay(35*2);
		Scroll_Texture_Both(14,0,0,0,0);
		Delay(35*1);
		Door_Open(13,64);


	}
	else
	{
		Teleport_NoFog(0,0,12,1);
		
	}
	
		
}

SCRIPT 5 (void)

{
	If(GameType() == GAME_SINGLE_PLAYER)
	{
		Door_Close(13,64);
		Delay(35*1);
		Scroll_Texture_Both(14,0,0,64,0);
		Delay(35*3);
		Teleport_NoFog(0,0,11,1);
		Delay(35*2);
		Scroll_Texture_Both(14,0,0,0,0);
		Delay(35*1);
		Door_Open(13,64);


	}
	
	else
	{
		Teleport_NoFog(0,0,11,1);
	}
}

 

Share this post


Link to post
  • 0

I have a bit of trouble understanding what you have in mind.

 

Is everything on the same height with just the illusion of an elevator?

 

Or does the player transition between two different heights as in an elevator?

Then you could use one of the elevator specials (245, 246, 247). 

 

Could you upload a map demonstrating the elevator?

Edited by Kappes Buur

Share this post


Link to post
  • 0

Uploading a map is going to be a bit of a hassle since it's part of a megawad. I'll do it tomorrow if needed.

 

For now, my solution was everything being on the same height with just the illusion of an elevator.

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
Answer this question...

×   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...