Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Rycky91

Hexen Books Open Door

Recommended Posts

I am stuck again, and have another dumb question.
Okay i want a door to open when i place books on the shelf like in the gibbet. MAP23
Does anyone see the error?

#include "common.acs"

int mapvar0;

script 1 (void)
{
    Door_Open(4,32);
}

script 2 (void)
    {
    mapvar0 = 0;   
    setlinetexture(1, SIDE_FRONT, TEXTURE_BOTTOM, "BOOKS04");
    mapvar0++;
    }

script 3 (void)
    {
    setlinetexture(2, SIDE_FRONT, TEXTURE_BOTTOM, "BOOKS04");
    mapvar0++;
    }

script 4 OPEN
    {
    setlinespecial(1, 129, 2, 2, 0, 0, 0);
    setlinespecial(2, 129, 3, 3, 0, 0, 0);
    }
    
script 5 OPEN
    {
    while(mapvar0 == 2)
        {
    delay(const: 25);
    Door_Open(5,32);
        }
    }

script 6 (void)
    {
    Floor_LowerInstant(6, 0, 16);
    thingsound(80, "GlassShatter", 127);
    }

script 7 (void)
    {
    Floor_LowerInstant(7, 0, 16);
    thingsound(80, "GlassShatter", 127);
    }
I also have a door and glass breaking in there
the scripts compiled without errors, i think its the mapvar0
I know its a variable, but what exactly does mapvar0++ mean?
Is it +1?
I'm confused and I don't want links to zdoom acs
I need help straight up.

Share this post


Link to post

How do you call scripts 2 and 3?

Why is script 5 constantly opening the door? Don't you want rather to have something like this?

script 5 OPEN
{
    while(mapvar0 == 2)
    {
        delay(const: 25);
    }
    Door_Open(5,32);
}

Share this post


Link to post

Cool! I liked that idea. But remember to always place a trap behind another door that opens as well, and a reward inside with another trap!

Share this post


Link to post

Well, I have tried the if statement ,that doesn't seem to work. and the door isn't opening at all. scripts 2 and 3 are called when i place the puzzle items daemon codex and libera obscura in the bookshelf, the linedefs of said bookshelf are action line identification and trigger player presses use. I will try out your script though
i really need to pay more attention to my brace placement too

Thanks for the input

Share this post


Link to post

Here is the new code

#include "common.acs"

int mapvar0;

script 1 (void)
{
    Door_Open(4,32);
}

script 2 (void)
    {
    mapvar0 = 0;   
    setlinetexture(1, SIDE_FRONT, TEXTURE_BOTTOM, "BOOKS04");
    mapvar0++;
    }

script 3 (void)
    {
    setlinetexture(2, SIDE_FRONT, TEXTURE_BOTTOM, "BOOKS04");
    mapvar0++;
    }

script 4 OPEN
    {
    setlinespecial(1, 129, 2, 2, 0, 0, 0);
    setlinespecial(2, 129, 3, 3, 0, 0, 0);
    }
    
script 5 OPEN
{
    while(mapvar0 == 2)
    {
        delay(const: 25);
    }
    Door_Open(5,32);
}

script 6 (void)
    {
    Floor_LowerInstant(6, 0, 16);
    thingsound(80, "GlassShatter", 127);
    }

script 7 (void)
    {
    Floor_LowerInstant(7, 0, 16);
    thingsound(80, "GlassShatter", 127);
    }
Now when I start the map the door is already open.
How do you control variables?
What is mapvar0++?
I thought that mapvar0 starts out as 0 then scripts 2 and 3 both add 1 to mapvar0

Share this post


Link to post

EDIT: My version of script 5 is dense. Use Dragonfly's or Gez's version for anything that replicates script 5.

Script 5 is the culprit.

script 5 OPEN
{
    while(mapvar0 == 2)
    {
        delay(const: 25);
    }
    Door_Open(5,32);
}
The door is open because that's what script 5 does. At the map start it waits 25 tics if mapvar0 == 2 (which it doesn't) and then it opens the door because the that's the thing to do after the loop.

I think you were aiming for something that polls mapvar0 every 25 tics and then opens the door. That would look like:
script 5 OPEN
{
    while(1)
    {
        if (mapvar0 == 2)
        {
            Door_Open(5,32);
            break;
        }
        delay(const: 25);
    }
}
You can do the same thing with less code. Why not just have either script involving the puzzle open the door when the last book is placed? That would look like the following (I'm ignoring scripts 1, 6, and 7 because I don't know what they're for.)
#include "common.acs"

int booksPlaced = 0; //let's use a name that indicates what it's counting

//only need one script if we use args to specify which self
script 2 (int shelfTag)
{
	setlinetexture(shelfTag, SIDE_FRONT, TEXTURE_BOTTOM, "BOOKS04");
	booksPlaced++;
	if (booksPlaced == 2)
	{
		delay(25); //assuming you might have wanted a 25-tic delay for some reason
		Door_Open(5, 32);
	}
}

//Why can't these line specials just be set in the editor?
script 4 OPEN
{
	setlinespecial(1, 129, 7, 2, 1, 0, 0); //Daemon Codex is 7
	setlinespecial(2, 129, 8, 2, 2, 0, 0); //Liber Oscura is 8 
}

Share this post


Link to post

The line specials probably aren't set in the editor because Hexen map format is in use, so the lines have to be set with Line_SetId...

Share this post


Link to post
Rycky91 said:

How do you control variables?
What is mapvar0++?
I thought that mapvar0 starts out as 0 then scripts 2 and 3 both add 1 to mapvar0

Control? You can either assign their value via = or += or ++ or similar operator, or compare them via < or > or <= or >= or similar operator within a conditional statement.

"mapvar0++" is an equivalent of "mapvar0 = mapvar0 + 1".

If you want "mapvar0" to start out as 0, you should declare it as "int mapvar0 = 0;".

Scripts of type OPEN will be executed automatically at the start of the map before any other scripts, while scripts of type (void) must be explicitly called during the map. That's why your scripts 2 and 3 (which assign mapvar0) will be called after script 5 (which checks value of mapvar0).

Share this post


Link to post

I changed script 5 type to void. i thought it would work, but nothing happened.
My new code

#include "common.acs"

int books = 0;

script 2 (void)
    {
    setlinetexture(1, SIDE_FRONT, TEXTURE_BOTTOM, "BOOKS04");
    books++;
    }

script 3 (void)
    {
    setlinetexture(2, SIDE_FRONT, TEXTURE_BOTTOM, "BOOKS04");
    books++;
    }

script 4 OPEN
    {
    setlinespecial(1, 129, 2, 2, 0, 0, 0);
    setlinespecial(2, 129, 3, 3, 0, 0, 0);
    }
    
script 5 OPEN
{
    if(books == 2)
    {
        Door_Open(5,32);
    }
}
I don't think books is being changed at all.
I used the delay because of the while statement. I didn't intend the door wait 25 tics. I replaced it with if. Still not working.

Share this post


Link to post
Rycky91 said:

I changed script 5 type to void. i thought it would work, but nothing happened.

Did you actually call the script? As I said, if it's (void), it won't be called automatically, but it's your responsibility to call it via ACS_Execute or another ACS special at some point.

In your newest script, script 5 is OPEN again, which means that it compares "books" with "2" before anything else can happen at all, which obviously won't work as you intend.

Share this post


Link to post

I would prefer the WAD file so I can test if things work properly. But your problem lies in the fact you're checking only once on the map's opening if the variable is equal to 2, rather than waiting until it equals 2. I believe the below would fix your issue but like I said, without the WAD it's hard to really say.

Please PM a link to the wad file if this doesn't work, I'd be happy to help.

Script 5 OPEN {
    While(books != 2) {
        Delay(35);
    }
    Door_Open(5,32);
}

Share this post


Link to post

Awesome I have placed an ACSExe in the script, and it worked!!

#include "common.acs"

int books = 0;

script 2 (void)
    {
    setlinetexture(1, SIDE_FRONT, TEXTURE_BOTTOM, "BOOKS04");
    books++;
    }

script 3 (void)
    {
    setlinetexture(2, SIDE_FRONT, TEXTURE_BOTTOM, "BOOKS04");
    books++;
    ACS_Execute(5,6,0,0,0);
   }
    

script 4 OPEN
    {
    setlinespecial(1, 129, 2, 2, 0, 0, 0);
    setlinespecial(2, 129, 3, 3, 0, 0, 0);
    }
    
script 5 (void)
{
    if(books > 1)
    {
        Door_Open(5,32);
    }
}
Works fine
Thanks everyone!!

Share this post


Link to post

What you want is something like this:

script 5 OPEN
{
    while (books < 2)
    {
        Delay(35);
    }
    Door_Open(5,32);
}
What it does: it's an open script, so it starts running when the map is loaded. As long as books isn't 2, it waits. Once books is 2, it no longer waits and opens the door.

Share this post


Link to post
Quasar said:

OK and what happens when you press the lines in the opposite order?


This is why my answer & Gez's answer is more reliable. If you were to press the buttons in the opposite order script 5 would fire without the required value set to the books variable.

Share this post


Link to post

If only Rycky91 placed the ACS_Execute command into both script 2 and script 3, his solution would work too - and it wouldn't require any continually running script. That's what I see as preferable solution.

Share this post


Link to post

You are right scifista42
I have placed the acs exe in both scripts 2 and 3.
I think its better this way.
At first I used descript to decompile my HEXEN.WAD so I could see how the books work
and I copied the code from MAP23. It confused me a bit

Thanks again for the help everyone!!

Share this post


Link to post

I prefer the adage about giving a fish or teaching how to fish when it comes to programming, hence my terse question earlier. It is a prompt to think, rather than to depend on people for answers. That's the only way to become independent when doing ACS scripting - it's not an activity that would involve any guesses or trial and error changes once you understand the basic rules it is based on, like how to keep a script running using a while loop, and what basic operators mean.

Share this post


Link to post

numbers 2 and 3 are script numbers. I did have them set to 7 and 8, but when i placed the books it said p_startscript: unknown script.
UsePuzzleItem / item / script / s_arg1 / s_arg2 / s_arg3
It's weird because 7 and 8 are books 1 and 2

As for what Quasar said, You are absolutely right on. But my main area is mapping
I do not like scripting. That's why i ask the experts. I get the basic concept of acs.
I would like to find a doom builder 2 tutorial strictly for Hexen or a text based one.

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
×