Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
II XII I III XI

ZDoom Scripting Question

Recommended Posts

I have a series of questions concerning scripts for one of my maps. If you could write an example script or point me to somewhere that explains how to do this I'd appreciate it.

First, is it possible to make a linedef impassable initially but passable later? Obviously I'm using ZDoom, and although I want a player to be able to jump, I don't want the player to be able to reach areas until they've done something else.

Second, how do I make four switches execute a script? I used the switchcount but for some reason it doesn't work.

Third, can I spawn an item in a previously tagged sector? I attempted spawning a soul-sphere in a floor_raise sector but to no avail.

And finally, is it possible to switch a texture sw1garg to another texture sw1satyr and make it an exit switch? The sw1garg previous is a switch that initiates a script. Later in the map however, I'd like the exact same switch to act as an exit switch.

Thank you for your time.

Share this post


Link to post

To do the 4-switch trigger thing, you need to do something to this effect:

#include "zcommon.acs"

int Switches=0;

Script 1 (void)

{

Switches=(Switches+1);

if Switches=4 then
Effect
Effect
Effect

}

This is mostly IIRC, mind you, my ACS Scripting knowhow is a little rusty. Some of it's probably falsified, but that's the gist of it.

As for you passable/impassable lines, you do this:
#include "zcommon.acs"

Script 1 (void) {

SetLineBlocking(666, FALSE);

}

I'm absolutely positive that's the right code. And, of course, where 666 is, your line number goes (NUMBER IN EDITOR, NOT TAG NUMBER!), and FALSE can be either TRUE or FALSE, which sets the Impassable flag.

And as for spawning an object in a sector, you can do one of the following:
//blah blah blah


Script 1 (void)

{

SpawnSpot("Ettin", 666);

}


//blah blah blah
Where Ettin is the name of your monster as you would summon it from ZDoom's console, and 666 is a tagged map spot where you want the monster to spawn.You can also move a tagged enemy directly to a map spot:
//blah blah blah

Script 1 (void)

{

Thing_Move(666, 667);

}

//blah blah blah
Where 666 is the monster's thing tag, and 667 is the map spot's tag.

Share this post


Link to post

Also, it's very much possible to make the same exact switch into an exit switch, and you don't need scripting to do it. When you want the switch to change, simply have a 1-unit thick sector with the floor/ceiling reach the ceiling/floor with any tag number set to lower/raise when one crosses a linedef.

Share this post


Link to post
II XII I III XI said:

And finally, is it possible to switch a texture sw1garg to another texture sw1satyr and make it an exit switch? The sw1garg previous is a switch that initiates a script. Later in the map however, I'd like the exact same switch to act as an exit switch.


http://www.zdoom.org/wiki/index.php?title=SetLineSpecial
http://www.zdoom.org/wiki/index.php?title=SetLineTexture

Darkhaven said:

#include "zcommon.acs"

int Switches=0;

Script 1 (void)

{

Switches=(Switches+1);

if Switches=4 then
Effect
Effect
Effect

}


With correct syntax:

#include "zcommon.acs"

int Switches=0; // not too sure if you can initialize with a value

script 1 (void)
{
   Switches++;

   if(Switches == 4) {
      // do something here
   }
}

Darkhaven said:

Also, it's very much possible to make the same exact switch into an exit switch, and you don't need scripting to do it. When you want the switch to change, simply have a 1-unit thick sector with the floor/ceiling reach the ceiling/floor with any tag number set to lower/raise when one crosses a linedef.

Hmm, it's probably better to make the first switch such a 1 unit wide sector and let it disappear, since you probably would trigger the new switch before the original one. Doom doesn't care if you actually see the switch, you can trigger it always. That's pretty clear in Doom2 map02 in that blue floor room, where you can still hit the switch to open the secret door even after the platforms lowerd into the ground.

Share this post


Link to post
boris said:

Hmm, it's probably better to make the first switch such a 1 unit wide sector and let it disappear, since you probably would trigger the new switch before the original one. Doom doesn't care if you actually see the switch, you can trigger it always. That's pretty clear in Doom2 map02 in that blue floor room, where you can still hit the switch to open the secret door even after the platforms lowerd into the ground.


Ah, good point. It's probably better to do it with scripting instead of my idea, but my way is one way to do it without scripting or if you think ACS scripts are a pain in the ass.

Share this post


Link to post
II XII I III XI said:

I have a series of questions concerning scripts for one of my maps. If you could write an example script or point me to somewhere that explains how to do this I'd appreciate it.

First, is it possible to make a linedef impassable initially but passable later? Obviously I'm using ZDoom, and although I want a player to be able to jump, I don't want the player to be able to reach areas until they've done something else.

Second, how do I make four switches execute a script? I used the switchcount but for some reason it doesn't work.

Third, can I spawn an item in a previously tagged sector? I attempted spawning a soul-sphere in a floor_raise sector but to no avail.

And finally, is it possible to switch a texture sw1garg to another texture sw1satyr and make it an exit switch? The sw1garg previous is a switch that initiates a script. Later in the map however, I'd like the exact same switch to act as an exit switch.

Thank you for your time.


1. Flag it impassible in the editor, and give it the Line_SetIdentification type. Then to make it passable later, do this:

script 1 (void)

{
setlineblocking (lineid, off)
}
lineid is the number you put in the box when you gave it the Line_SetIdentification.

2. Set all four switches to run this script:
int switchcount;

script 2 (void)

{
        switchcount++;
        switch (switchcount)
               {
		case 1:
				print(s:"3 more to go...");
				break;
		case 2:
				print(s:"2 more to go...");
				break;
		case 3:
				print(s:"1 more to go...");
				break;
                case 4:
                                print(s:"sequence complete");
                                Do_StuffHere
               }
}
3. You don't need to use sector tags to spawn things - place a mapspot in the sector, give that a tag and spawn it there.

4. Give the switch a lineid like before, and use this script to change the switch:
script 4 (void)

{
setlinetexture (lineid, SIDE_FRONT, TEXTURE_MIDDLE, "sw1satyr");
setlinespecial (lineid, 243, 0);
}

Share this post


Link to post
Darkhaven said:

but my way is one way to do it without scripting if you think ACS scripts are a pain in the ass.

... or if you don't have access to scripting, like in classic Doom.

Share this post


Link to post

hmm, i thought i couldn't do this scripting in zdoom, but now i see it's more or less identical to programming in C++....funky

Share this post


Link to post

I thank all of those whom responded. Everything works except for the soul-sphere spawn.

I previously did, indeed, use a mapspot, but the soul-sphere still fails to spawn in the floor_raise sector. I'm not sure why but I will explain it thoroughly in case something was missed.

-You are in a pit that has a floor height of 0 and a ceiling height of 160 with a switch directly in front of you with a floor height of 64. Once you activate the switch, it recesses into the pit floor (0) and goes on to lift the entire pit to 128 which is level with an outside room. I am attempting to spawn the soul-sphere on top of where the switch would have stood. The switch is tagged 1 and the pit-room surrounding it is 2. The soul-sphere / mapspot is tagged 8. I'm positive that the soul-sphere is tagged correctly (8,25,0) but it fails to work.

???

Share this post


Link to post
II XII I III XI said:

I thank all of those whom responded. Everything works except for the soul-sphere spawn.

I previously did, indeed, use a mapspot, but the soul-sphere still fails to spawn in the floor_raise sector. I'm not sure why but I will explain it thoroughly in case something was missed.

-You are in a pit that has a floor height of 0 and a ceiling height of 160 with a switch directly in front of you with a floor height of 64. Once you activate the switch, it recesses into the pit floor (0) and goes on to lift the entire pit to 128 which is level with an outside room. I am attempting to spawn the soul-sphere on top of where the switch would have stood. The switch is tagged 1 and the pit-room surrounding it is 2. The soul-sphere / mapspot is tagged 8. I'm positive that the soul-sphere is tagged correctly (8,25,0) but it fails to work.

???


Hmm.. I have only one suggestion: You could possibly make a gravity affected map spot instead? That might solve the problem with it not spawning.

Share this post


Link to post

I'll use this thread for any future ZDoom questions that I may have.

The question I have now regards screen-displayed text. Is it possible to change the color / size / location of messages? Suppose I have a script that operates after you open a door that says "Welcome to the UAC research facility"; could I make this appear as red or white/gray in the lower left hand corner rather than the yellow mid-screen default?

If you could direct me to a tutorial that would suffice. Thank you again for your time.

Share this post


Link to post
II XII I III XI said:

I'll use this thread for any future ZDoom questions that I may have.

The question I have now regards screen-displayed text. Is it possible to change the color / size / location of messages? Suppose I have a script that operates after you open a door that says "Welcome to the UAC research facility"; could I make this appear as red or white/gray in the lower left hand corner rather than the yellow mid-screen default?

If you could direct me to a tutorial that would suffice. Thank you again for your time.


For this specific question look here:

http://www.zdoom.org/wiki/index.php?title=HudMessage
and here
http://www.zdoom.org/wiki/index.php?title=SetFont

For questions in general, look here:

http://www.zdoom.org/wiki/index.php?title=Main_Page

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
×