Jump to content
  • 0

How do I lower a floor using multiple switches?


Captain_Neko

Question

So I have 8 shootable switches (tagged as 19) and a floor sector (tagged as 10). I want the player to shoot all 8 switches so the floor lowers and the player can move onto the next area. I know I can do this throe scripts but I'm not exactly sure how.Capture1.PNG.532b3bc2bcc3c8216aea87209250a309.PNG

*the missing two switches are behind boxes

 

Capture2.PNG.e78590c03d382d9607f7a8c14a368bd0.PNG

Edited by Captain_Neko

Share this post


Link to post

24 answers to this question

Recommended Posts

  • 2

hi! imo, you don't need a script for this. just use a voodoo doll conveyor with floor=0mu, ceiling=64mu. the voodoo doll is blocked from moving with pillars (floor=0mu, ceiling=55mu) that corresponds to the same number of targets, arranged perpendicular to the direction of the conveyour. when a target is shot, a pillar is raised via door line action. only when all the targets are shot and all bars are raised, the voodoo doll could then start moving and trigger the linedef to lower the floor for map progression. anyway, good luck on your project :)

Edited by rita remton
wordings

Share this post


Link to post
  • 1
6 hours ago, Captain_Neko said:

FFS, more errors...

Capture5.PNG.81fdd6a6cbe0ed20cf5ca926c32ca156.PNG

 

I think you have to write #include zcommon.acs at the top for it to work.

Edited by OnionTaco22

Share this post


Link to post
  • 0

You need a script.

 

script 1 (int TID)

{

 while (ThingCount(T_NONE, TID) > 0)

  Delay(35);

  

  Floor_LowerByValue(SOMETHING, SOMETHING, SOMETHING);

}

 

TID is the switches', so make it 19.

Then edit the door action.

 

Edit

 

 

I did it from memory, so take it with a grain of salt

 

When you use it in a line, you can set the TID in there. This is a modular, reusable script.

Edited by FraggerX

Share this post


Link to post
  • 0

Also I think I should mention that the switches are animated textures.

I am unsure if this changes anything.

Capture4.PNG.b541ed333210aa35780aa9e97e15f857.PNG

Edited by Captain_Neko

Share this post


Link to post
  • 0

Your script has an error. You have "script 1 (int 19)" - Where it said (int TID), it meant you put in the variable name there such as "target", using letters.

 

 script 1 (int target)

{

 while (ThingCount(T_NONE, target) > 0)

  Delay(35);

  Floor_LowerByValue(SOMETHING, SOMETHING, SOMETHING);

} 

 

The value of 19 is passed in as an argument when the script action is called.

 

 

2 hours ago, FraggerX said:

You need a script.

 

A script is an easy way to do that, but by no means do you need a script to do something like that. Vanilla Doom has actions "G1 Floor Raise to Lowest ceiling" and "WR Floor Lower to highest Floor." I'll show how to do what you want.

 

"Floor Raise to Lowest Ceiling" will - if the lowest ceiling is below the current height of the floor - instantly lower the floor to that low value. "Floor Lower to Highest Floor" will lower the floor to the highest adjacent floor - you'll need to make sure that your gate you want to lower has at least one unit of space between it and the posts for this method.

 

In the example below, all the triangle-shaped sectors have their floor and ceiling set to the height of the ground around the gate. Each target will have its line given an individual tag (for example 19 through 26), an action of "G1 floor raise to lowest ceiling" and their floor height is set to the height of the closed gate. Take your gate sector and join it with the long rectangle touching sectors 19-26 and give it the tag of 27. All around your target range, put in some WR lines with the action "Floor Lower to highest Floor" and tag 27. Thus, you'll need to shoot all the target lines, which will lower one of the T19-26 sectors, but only after they're all down will passing over the "floor lower to highest floor" trigger.

multiple-trigger-switch-example.jpg

Share this post


Link to post
  • 0
22 minutes ago, Captain_Neko said:

FFS, more errors...

Capture5.PNG.81fdd6a6cbe0ed20cf5ca926c32ca156.PNG

 

 

It seems that there is no built-in function with that name. I don't know enough ACS scripting to tell you what the closest equivalent is, even after looking at the list.

Share this post


Link to post
  • 0

Hmmmm, I'm going to he honest comrades, I don't think I'm cut out for all this scripting nonsense. I think I'm going to try something else. Thanks for help anyway everyone

fsgfsdgvsdfg.PNG.92512b65b18f177a08909d5afbcd92d2.PNG

Share this post


Link to post
  • 0
1 hour ago, Captain_Neko said:

FFS, more errors...

Capture5.PNG.81fdd6a6cbe0ed20cf5ca926c32ca156.PNG

 

I dont think called functions should have spaces

 

Try wiriting it like this :

  Floor_LowerByValue(10, 100, -22);

Share this post


Link to post
  • 0
50 minutes ago, Captain_Neko said:

Hmmmm, I'm going to he honest comrades, I don't think I'm cut out for all this scripting nonsense. I think I'm going to try something else. Thanks for help anyway everyone

fsgfsdgvsdfg.PNG.92512b65b18f177a08909d5afbcd92d2.PNG

 

Yes, unfortunately, science has not yet perfected a device which fills the user's head with complete information on a subject with a single zero-effort press of a button. Until they do, though, you'll just have to do the same old-fashioned thing which every other mortal does, which is to put in time and effort researching and learning how to do things you want to do.

 

There is no "cut out for scripting" and "not cut out for scripting," everyone here once was just as uncertain and unknowledgeable, but they spent time and effort to learn and understand. They didn't just quit at the first setback.

 

In addition, you could also read my post above which contains detailed information on how to do what you want without any scripting at all.

Edited by Stabbey

Share this post


Link to post
  • 0
7 hours ago, Stabbey said:

Your script has an error. You have "script 1 (int 19)" - Where it said (int TID), it meant you put in the variable name there such as "target", using letters.

 


 script 1 (int target)

{

 while (ThingCount(T_NONE, target) > 0)

  Delay(35);

  Floor_LowerByValue(SOMETHING, SOMETHING, SOMETHING);

} 

 

The value of 19 is passed in as an argument when the script action is called.

 

 

 

A script is an easy way to do that, but by no means do you need a script to do something like that. Vanilla Doom has actions "G1 Floor Raise to Lowest ceiling" and "WR Floor Lower to highest Floor." I'll show how to do what you want.

 

"Floor Raise to Lowest Ceiling" will - if the lowest ceiling is below the current height of the floor - instantly lower the floor to that low value. "Floor Lower to Highest Floor" will lower the floor to the highest adjacent floor - you'll need to make sure that your gate you want to lower has at least one unit of space between it and the posts for this method.

 

In the example below, all the triangle-shaped sectors have their floor and ceiling set to the height of the ground around the gate. Each target will have its line given an individual tag (for example 19 through 26), an action of "G1 floor raise to lowest ceiling" and their floor height is set to the height of the closed gate. Take your gate sector and join it with the long rectangle touching sectors 19-26 and give it the tag of 27. All around your target range, put in some WR lines with the action "Floor Lower to highest Floor" and tag 27. Thus, you'll need to shoot all the target lines, which will lower one of the T19-26 sectors, but only after they're all down will passing over the "floor lower to highest floor" trigger.

multiple-trigger-switch-example.jpg

In my experience, any word works. 

Share this post


Link to post
  • 0
29 minutes ago, FraggerX said:

In my experience, any word works. 

 

Not any word, you don't want to use a keyword (such as "int") reserved for parsing the code.

Share this post


Link to post
  • 0
2 hours ago, Stabbey said:

 

Not any word, you don't want to use a keyword (such as "int") reserved for parsing the code.

I meant the word after "int". It shows as an argument. As in:

 

Script 1 (int TID, int Speed, int Height)

{

    Ceiling_RaiseByValue(TID,Speed,Height);

}

Share this post


Link to post
  • 0
6 hours ago, FraggerX said:

I meant the word after "int". It shows as an argument. As in:

 

Script 1 (int TID, int Speed, int Height)

{

    Ceiling_RaiseByValue(TID,Speed,Height);

}

 

I understand that. I meant that you don't want to use one of the reserved keywords as the word after int, because that would produce an error.

Share this post


Link to post
  • 0
3 hours ago, Stabbey said:

 

I understand that. I meant that you don't want to use one of the reserved keywords as the word after int, because that would produce an error.

Got it👍

Share this post


Link to post
  • 0

OK, I'm back. Finlay got the script to work, but its lowering the floor when I shoot one of the switches instead of waiting till all 8 are hit.

Capture1.PNG.e167c4aad6bc45af125e796074354dd3.PNG

Capture2.PNG.b3c333e648687fce33a1602fa37bbbec.PNG

 

Also on a side note, the switches themselves are an animated texture, do they need to be things instead for the script to work?

Capture3.PNG.c54079241d0cf1ded5f975d850f5b9b6.PNG

Share this post


Link to post
  • 0
int targets = 8;

script 1 (int target)
{
    targets--;

    while(targets > 0)
    {
        Delay(somearbitrarynumber);
    }
    Floor_LowerByValue(SOMETHING, SOMETHING, SOMETHING);
} 

^ That should work.

Edited by MFG38

Share this post


Link to post
  • 0
23 minutes ago, MFG38 said:

int targets = 8;

script 1 (int target)
{
	while (ThingCount(T_NONE, target) > 0)
	{	targets--;	}

	Floor_LowerByValue(SOMETHING, SOMETHING, SOMETHING);
} 

^ That should work.

 

Because they have the same tag, won't that just allow the player to shoot the same target 8 times? The targets are textures on a line, not things, which means they have no death state.

 

Share this post


Link to post
  • 0
11 minutes ago, Stabbey said:

Because they have the same tag, won't that just allow the player to shoot the same target 8 times?

 

Not unless the line actions themselves are flagged as repeatable.

Share this post


Link to post
  • 0
3 hours ago, rita remton said:

hi! imo, you don't need a script for this. just use a voodoo doll conveyor with floor=0mu, ceiling=64mu. the voodoo doll is blocked from moving with pillars (floor=0mu, ceiling=55mu) that corresponds to the same number of targets, arranged perpendicular to the direction of the conveyour. when a target is shot, a pillar is raised via door line action. only when all the targets are shot and all bars are raised, the voodoo doll could then start moving and trigger the linedef to lower the floor for map progression. anyway, good luck on your project :)

Wow! It works perfectly! Thanks! And thanks to everyone else for helping me out!

Share this post


Link to post
  • 0
On 4/7/2024 at 4:21 PM, Captain_Neko said:

OK, I'm back. Finlay got the script to work, but its lowering the floor when I shoot one of the switches instead of waiting till all 8 are hit.

Capture1.PNG.e167c4aad6bc45af125e796074354dd3.PNG

Capture2.PNG.b3c333e648687fce33a1602fa37bbbec.PNG

 

You've made a very simple error here. The shootable objects have been given an action to lower the floor when any of them are shot. They're not running the script.

Edited by Artinum

Share this post


Link to post
  • 0

Do we even need the while loops?  Set a global variable to 8 and have each target run this script when they are hit and if its the last one I think it should start lowering the sector floor.

#include "zcommon.acs"

int targetsLeftToHit = 8;

script 2 (void)
{
	targetsLeftToHit--;

	if (targetsLeftToHit < 1) {
		Floor_LowerByValue({TAG# of the sector}, 10, 128);
	}
}

 

Share this post


Link to post
  • 0

pretty much the same question was asked a few days ago. About doors... Anyway, my tuppence worth is similar to above, but uses an array of data so you can use for multiple doors (or platforms...)

 

See my last answer.

Edited by smeghammer

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