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

Scripting problem

Recommended Posts

Hello!

EDIT: I fixed the script! =)

I encountered an annoying problem a while ago while working on my single player project. I have tried to make a trap that gets triggered when the player has the blue keycard, but now I don't know what to do. I have tried the ZDoom Wiki, but to no avail.

Here is the script:

script 2 (void)

{
    if (CheckInventory ("BlueCard") )
            {
                        Door_Open (4, 16);
                        Door_Close (17, 64);
                        Floor_RaiseByValue (16, 128, 96);
                        ChangeFloor (16, "CEIL5_2");
                        ChangeCeiling (17, "CEIL5_2");
            }
}

Share this post


Link to post

Remove the check for the Blue Keycard and set the keycard's special to ACS_Execute, with script 2 as the first argument.

The check for the keycard will be unnecessary as picking up the keycard will trigger the script.

Share this post


Link to post

Mista_T said:
Remove the check for the Blue Keycard and set the keycard's special to ACS_Execute, with script 2 as the first argument.

The check for the keycard will be unnecessary as picking up the keycard will trigger the script.


No, that is not what I want. What I have in mind is to have the player trigger a trap when he/she HAS the keycard in his/her possesion, not when he/she aqcuires it.

Share this post


Link to post

You could set a variable with a script, eg int has_bluekey = 1 when the bluekey is picked up.
Then your script could be

script 2 (void)

{
    if ( has_bluekey = 1 )
            {
                  .....
            }
}
I'm not a programming guru, so the syntax may not be up to snuff.

Share this post


Link to post

Kappes Buur said:
You could set a variable with a script, eg int has_bluekey = 1 when the bluekey is picked up.
Then your script could be

    script 2 (void)

    {
        if ( has_bluekey = 1 )
                {
                      .....
                }
    }

I'm not a programming guru, so the syntax may not be up to snuff.


That didn't do anything. I only received errors when trying to compile the script. =/

Share this post


Link to post
CarpetolA said:

That didn't do anything. I only received errors when trying to compile the script. =/


If ACS uses '=' as equality, no wonder why it sucks! Try "==" instead of "="?

Share this post


Link to post

People, at least make sure you know wtf you are talking about before you try to give others advice. Jesus H.

Share this post


Link to post

There is not enough context to answer this question. Can you be more specific what the actual problem is? Is the script not compiling or do you not know how to make the script trigger under a certain condition? It's nice to know these things.

Once I have more information I can tell you what you need to do.

Share this post


Link to post

If you do not pick up the blue key, then the door will not open.
To make your trap work, flesh out script 3.

#include "zcommon.acs"

// ========================================================
// spawn the blue skull key
// ========================================================

script 100 open
{
    delay (35*3);
    Thing_Spawn ( 10, T_BLUEKEYCARD, 0, 0);
}

// ========================================================
// check for blue skull key
// ========================================================

script 2 (void)

{
    Print(s:"Switch is activated");
    if (CheckInventory("BlueCard") == 1)
    {
        delay (35);
        ACS_Execute ( 3,1,0,0,0);
    }
    else
    {
        Print(s:"You need the blue skull key");
    }
}

// ========================================================
// if you have the blue skull key, open the door
// ========================================================

script 3 (void)
{
    Door_Open ( 2, 8, 0 );
}

// ========================================================
// END OF SCRIPTS
// ========================================================
and the map http://files.drdteam.org/index.php/files/get/6Bj3KWgvVu/bluekey.7z

The idea with the variable did not pan out.

Share this post


Link to post

Never mind, I worked around the problem:

script 2 (void)

{
    if (CheckInventory ("BlueCard") == 1)
    Door_Open (4, 64);
}

script 3 (void)

{
    Door_Close (17, 64);
    Floor_RaiseByValue (16, 128, 96);
    ChangeFloor (16, "CEIL5_2");
    ChangeCeiling (17, "CEIL5_2");
    
    While (ThingCount (T_NONE, 18) > 0)
    Delay (70);
    
    Door_Open (17, 16);
    Floor_LowerByValue (16, 16, 96);
}
Script 2 opens a set of doors which will unleash monsters from hidden compartments IF he has the blue keycard. "Repeatable action" is therefore required if the player has to run across the script trigger multiple times for any reason, otherwise the script will not get triggered more than one time. Some of the monsters themselves will trigger script 3, activating the rest of the trap. When all monsters are dead, the trap is lifted.

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
×