Scripted doors prefab (doors opening with a button)


(Flippy) #1

Hey,

i made a little prefab yesterday about opening doors with a button (and a button only)

there are 4 types in there:

  1. Pressing button opens the door and it stays open. Pressing button again closes the door.

  2. Same as 1. But if you approach a closed door you get the ‘door is locked’ sound and icon.

  3. Pressing button opens door, waits 3,5 seconds, then closes again.

  4. Same as 3, but if you approach a closed door you get the ‘door is locked’ sound and icon.

The script is highly commented to show exaclty what does what and it should be easy to recreate…

Just a little side-note that i forgot to put in the readme:

if you want to copy a door from this map, you only need these things:

  • the button on the left of the door you want
  • the door (beware, in doors 2 and 4 there are actually 2 doors in eachother, make sure you get all of them)
  • the target_script_trigger linked to the button

you do NOT need the big trigger brushes and the red entities, they are target_prints and inform you about which door does what…

EDIT:
OOPS completely forgot the link :banghead: :blah:

http://www.fragland.org/nick/scriptdoor_prefab.rar

there you go :moo:

Hope it helps you… (saw a few questions about it)


(=PoW= Kernel 2.6.5) #2

This prefab has completely confused me.

I see that the doors are script_movers so my first question is:
How do the doors know to rotate on the origin brush like a func_door_rotating?
Why are path (or spline) entites not needed?

I’m trying to make a door that goes up and down.
I want to control it in script only since the door will be closed when a generator is working and open when the generator is destroyed.
I originally tried using func_door that were locked but could not figure out how to control the doors in scripting.

I have guessed that this will best be done with a script_mover.
I am currently reading everything I can find on script movers but the more I read the more confused I am becomming.


(Ifurita) #3

by the way, if anyone wants a set of prefab rolling doors (ala Fuel Dump) let me know. I have a set in the map Rochelle, which won’t ever get finished, but they’re there if anyone wants them.


(Flippy) #4

@kernel something,

Script_movers need path points or spline points if you want them to move. However, I just make them rotate, which is not moving. Their origin points (same place as normal func_door_rotating entities) stay in place.

The rotating is controlled via the script with “faceangles”

usage:


scriptname of script_mover
{
    trigger used
    {
        faceangles [x] [y] [z] [time it takes to rotate giving angle]
    }
}

If you want a door going up or down like you, you do need path_corners.

Basically, path_corners are the points where the origin of your script_mover will move to (if its told to move by the script).

If you want script_mover “door” to move to path_corner “doorpath_up”, the script part would be:

gotomarker doorpatch_up [speed] wait

an example of your script could be:


generator
{
	trigger destroyed
	{
		trigger door move_up
		// do other things
	}

	trigger constructed
	{
		trigger door move_down
		// do other things
	}
}

door
{
	trigger move_up
	{
		gotomarker doorpath_up 50 wait
	}

	trigger move_down
	{
		gotomarker doorpath_down 50 wait
	}
}

This will move your door up when the generator is destroyed and down when it’s constructed.
(entities:
script_mover with targetname/scriptname “door”
path_corner with targetname “doorpath_up” and “doorpath_down”
and the generator ofcourse)

Hope this clears some things up… its not hard :slight_smile:

Note, you can also use “setrotation” instead of “faceangles” but there are 2 major differnences… setrotation works with speed, while faceangles works with the time it takes to rotate the given angle, and when you use setrotation, the entity will not stop spinning if you don’t tell it to. Faceangles will rotate the given angle and then stop.


(=PoW= Kernel 2.6.5) #5

I think I’m starting to understand.
I found the gotomarker function on Chrucker’s site and read a LOT of mover tutorials last night.

I now have a (mostly) working script mover door using the path_corner entities and an origin bursh in the script_mover.
I’m working to get everything to line up a little better.

Now I see that those doors worked using the rotate function. Ah haaaa !!

Here’s one more question:
I see many script mover scripts calling up a sound.
Does this sound need a speaker or is it somehow automatically associated with the script_mover that is calling the sound?


(Flippy) #6

the standard maps (battery, the hatch that people use to go to the gun) use “playsound [soundfile]” just after “gotomarker” or “faceangles”.

However i dont know how this would compare to target_speakers… i think its just the entity playing the sound at it’s origin, and when you go further away from it you dont hear it anymore, but im not sure…

(Note that [soundfile] should be your wave file and the patch should start with “sounds/”… if you use a custom wave file, search some topics about it as its a bit tricky to make them work (they need to be mono, 16 hz if im not mistaken, and some other shit))

Oh and to actually answer your question, i dont think it requires a speaker…