Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
White

Switch Scripting Question

Recommended Posts

I was wondering if anyone could help me with this problem. I have a door and two switches. I want the player to have to flip both switches in order to open the door. I don't want the door to partially open or anything however. Upon clicking on the first switch it will seem as though nothing happens but after clicking the second the door will open. I'm naive when it comes to scripting, (as some of you can probably see), so I ask the populace of Doomworld for help. Thank you.

Black/White

Share this post


Link to post

I guess you're using ZDoom, if not... well blah. Anyways, I did not do any ACS for quite some time, but this script should work:

--- snip ---

int door_counter;

script 1 (void)
{
door_counter++;

if(door_counter >= 2) {
Door_Open(tag_id_of_your_door, 100);
}
}

--- snip ---

Then assign script 1 to both switches and make sure they can only be activated once (if you don't know how to do it, read it up in your editor's manual). tag_id_of_your_door is the... um... tag id of the sector that's supposed to be the door, for example 1. The second argument of Door_Open is the speed, I just took 100, I don't really know how fast it is :) Just play around with it a bit to get a good speed.

Share this post


Link to post

Or, if you want something like those switches in Quake, try this:

----start of code----

int switchcount;

script 2 (void)

{
switchcount++;
switch (switchcount)
{
case 1:
print(s:"only 1 more to go..");
break;
case 2:
print(s:"sequence completed!");
Door_Open (tag, speed);
}
}

----end of code----

The tag is the tag on your door.
As for speeds, 16 is normal door speed and 32 is turbo door speed.

The only disadvantage of this method is that it can only be used once in a map - I found that out by trying to have 3 of them in one of my maps.

(unless there is a way that I don't know about)

Share this post


Link to post

There is a way to use that more than once. Try this:


At the top, before the first script, put this in:

int mapvar0;

Then do this:

script 1 (int arg0)
{
mapvar0++;
if(mapvar0 == 1)
{
print(s:"only one more to go");
}
else if(mapvar0 == 2)
{
print(s:"sequence completed");
Door_Open(arg0, 15);
mapvar0 = 0;
}
}

Now, for both of the switch lines, set it to ACS_Execute, with the tags 1, 0, 1, 0, 0.
The first '1' is the script number, and the second '1' is the arg0 variable, which refers to the door that will be opened.

If you want to make another two switch door somewhere else in the map, all you need to do is make two more switch lines, but this time, change the second '1' to, say, '2':

ACS_Execute(1, 0, 2, 0, 0)

Share this post


Link to post
Ultimate DooMer said:

(unless there is a way that I don't know about)

This example, with 3 switches works just fine:

//////////////////////////////////////////////////////////////////////
// Script 8: Sets sequencer charges //
// Begins countdown to destroy ICF //
//////////////////////////////////////////////////////////////////////

int switchcount1;
script 8 (void)
{ switchcount1++;
switch(switchcount1)
{case 1:
print(s:"\ccOne of three sequencer charges has been set.");
Delay(105);
break;
case 2:
print(s:"\ccTwo of three sequencer charges have been set.");
Delay(105);
break;
case 3:
print(s:"\ccThree of three sequencer charges have been set.");
Delay(105);
print(s:"\ccProceed to evacuate the installation.");
Delay(105);
print(s:"\ccAuto-destruct of all major systems will occur...");
Delay(105);
print(s:"\cc...in one minute.");
Delay(35);
print(s:"\ccRepeat. Proceed to evacuate the installation.");
Delay(105);
sequencer=1;
Thing_Spawn(55,T_CACODEMON,90);
ACS_Execute(24,0,0,0,0);
break;
}
}

Share this post


Link to post

So Ichor, you would just use that script? You won't have to change arg0 to anything else? Just provide the arg0 in the script excution?

Share this post


Link to post

So with this I can have more than 1 switchcount in a map? (as I had a timed destruction sequence, a 2 switch door and a 6 switch secret in my map. But I had to modify the last two to leave the important one intact)

Share this post


Link to post

Yes, although you could change 'arg0' to 'door' to simplify things a bit.

Share this post


Link to post
Ultimate DooMer said:

So with this I can have more than 1 switchcount in a map?

Yes, indeed, you can have more than 1 switchcount as you've discovered.

Share this post


Link to post
Ichor said:

Yes, although you could change 'arg0' to 'door' to simplify things a bit.

So the linedef would still be set too:

ACSExcute (1,0,1,0,0);

?

Share this post


Link to post

Oh ok, cool. I just thought for stuff like this you'd have to use a new script over and over again, and never thought about having a parameter in there and yeah. This is cool. Thanks.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×