This is a safe and combination script that is easily modifyable, Multiplayer-friendly, and free to use! (with credit)
The Strife HUD font in the sample WAD is sorta weird, but it's only a sample WAD, not a masterpiece, so don't mind it.

Most of my description is in the code below. but I'll summarize it.
Basically, this uses stored variables changed by a repeatable line, that changes texture accordingly. The door checks if the 3 exact variables match, and if they do, it opens. The code:
Code: Select all
//This is a copy of the scripts lump found in the demo map I included.
#include "zcommon.acs"
//Int a, b, and c are for the first, second, and third digits of the combination.
int a = 0;
int b = 0;
int c = 0;
//This switches the texture (I used a Strife HUD font) to use on the linedef (there are 3).
//It also changes the matching variable to the number on the texture.
//Each time it is used, the number changes, once it reaches 0, it restarts to 1.
script 3 (void)
{
setlinetexture(1, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK1");
a = 1;
suspend;
setlinetexture(1, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK2");
a = 2;
suspend;
setlinetexture(1, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK3");
a = 3;
suspend;
setlinetexture(1, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK4");
a = 4;
suspend;
setlinetexture(1, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK5");
a = 5;
suspend;
setlinetexture(1, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK6");
a = 6;
suspend;
setlinetexture(1, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK7");
a = 7;
suspend;
setlinetexture(1, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK8");
a = 8;
suspend;
setlinetexture(1, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK9");
a = 9;
suspend;
setlinetexture(1, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK0");
a = 0;
suspend;
restart;
}
//Repeat for next scripts.
script 4 (void)
{
setlinetexture(2, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK1");
b = 1;
suspend;
setlinetexture(2, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK2");
b = 2;
suspend;
setlinetexture(2, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK3");
b = 3;
suspend;
setlinetexture(2, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK4");
b = 4;
suspend;
setlinetexture(2, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK5");
b = 5;
suspend;
setlinetexture(2, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK6");
b = 6;
suspend;
setlinetexture(2, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK7");
b = 7;
suspend;
setlinetexture(2, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK8");
b = 8;
suspend;
setlinetexture(2, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK9");
b = 9;
suspend;
setlinetexture(2, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK0");
b = 0;
suspend;
restart;
}
script 5 (void)
{
setlinetexture(3, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK1");
c = 1;
suspend;
setlinetexture(3, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK2");
c = 2;
suspend;
setlinetexture(3, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK3");
c = 3;
suspend;
setlinetexture(3, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK4");
c = 4;
suspend;
setlinetexture(3, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK5");
c = 5;
suspend;
setlinetexture(3, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK6");
c = 6;
suspend;
setlinetexture(3, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK7");
c = 7;
suspend;
setlinetexture(3, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK8");
c = 8;
suspend;
setlinetexture(3, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK9");
c = 9;
suspend;
setlinetexture(3, SIDE_FRONT, TEXTURE_MIDDLE, "LOCK0");
c = 0;
suspend;
restart;
}
//This is executed when using the safe door itself.
//If all 3 variables are correct, the door opens.
script 1 (void)
{
if (a == 8 && b == 9)
{
if (c == 2)
{
ceiling_raiseinstant(1, 0, 48);
print(s:"Safe opened.");
}
}
}
//This is a script that leaves the map, activated by a locked linedef.
script 2 (void)
{
Teleport_NewMap(2, 0);
}
//These are just the instructions for the demo map.
script 6 ENTER
{
Print(s:"Use the numbers to change the code,\n use the door to attempt to open it, \n and pick up armor bonus to show code.");
}
//This executes when you pick up the armor bonus.
//It tells the code.
script 7 (void)
{
Print(s:"Code is 892.");
}
//And lastly, this executes when you get the red key from the safe.
//It tells you where to use the key to exit.
script 8 (void)
{
Print(s:"Use the DOORSTOP texture to exit level.");
}
//Hopefully you will find this useful! :)
[spoiler]
And finally, a download link containning the WAD and a .txt of the code:
Download
Enjoy!
