func_scriptdoor
Description
Solid class. Script door. Opening and closing movement/rotation must be done with script threads. By default, doors must be used to open. Doors that touch are automatically teamed and operate as a single unit. Only doors of the same type that touch can be teamed.
Keys
|
angle:
|
determines the opening direction. The angle should point towards the "handle side" of the door (away from the hinge). This ensures that the door always opens away from the player.
|
origin:
|
optional alternative to the use of an origin brush as the center of rotation of the entity. Set this to the XYZ coordinate you want the entity to use as it's center of rotation.
|
targetname:
|
if this is set, the door can be operated by an activating trigger or script commands but also retains its default use mode or proximity (if AUTO_OPEN is set) mode of operation.
|
target:
|
point this to the func_areaportal within the door.
|
time:
|
time in seconds the door will take to open or close.
|
wait:
|
wait before returning (3 default, -1 = never return).
|
dmg:
|
damage to inflict to player when he blocks the door (0 default).
|
message:
|
text string to print on the screen every time the door is operated.
|
noise:
|
sound to play when "message" is printed. The "message" key must be set for sound to be heard (default none). Does the same thing as the "sound_message" key.
|
key:
|
name of item required to open door (default: none). This can be any Inventory_* type entity. Use the last part of the entity name (after "Inventory_"). The only exceptions are:
ChemBioSuit : use chemsuit instead
cookies : works but doesn't generate an icon
genericpulsepart : works but doesn't generate an icon
|
initthread:
|
name of the door initialization thread in the script. Gets called when the door is spawned. This thread is optional.
|
openthread:
|
name of the door opening thread in the script. This thread must be defined in the script and contain the door opening commands.
|
closethread:
|
name of the door closing thread in the script. This thread must be defined in the script and contain the door closing commands.
|
sound_stop:
|
path/name of wav file to play when door stops.
|
sound_move:
|
path/name of wav file to play when door is moving.
|
sound_message:
|
path/name of wav file to play when door displays a message.
|
sound_locked:
|
path/name of wav file to play when door is locked.
|
alpha:
|
sets the translucency of the entity (default 1.0). Warning: don't set this if the door targets an areaportal.
|
|
Spawnflags
|
4
|
DOOR_DONT_LINK
|
is for when you have two doors that are touching but you want them to operate independently. This prevents them from being automatically teamed*.
|
8
|
NOT_PLAYERS
|
players cannot open this door.
|
16
|
NOT_MONSTERS
|
monsters cannot open this door.
|
32
|
TOGGLE
|
causes the door to wait in both the start and end states for a trigger event.
|
64
|
AUTO_OPEN
|
causes the door to open when a player is near instead of waiting for the player to use the door.
|
128
|
TARGETED
|
door is only operational from triggers or script.
|
|
Notes
*Note: if two doors touch, they are assumed to be teamed and operate as a unit. If you want touching doors to operate independently from one another, you have to set the DOOR_DONT_LINK spawnflag on the team master which is the first door among those to spawn in the map. Unfortunately, determining which door is the team master is complicated at best. So to make sure they will operate independently, just set the DOOR_DONT_LINK spawnflag on all the doors that touch one another.
The func_scriptdoor entity is like a normal door except that it absolutely requires opening and closing script threads which contain the movement and/or rotation commands that tell it what to do when an open or close event occurs. This is accomplished through the use of the 3 additional keys: 'initthread', 'openthread' and 'closethread'. The initthread is optional and is not absolutely essential. It can be used to initialize a door's position and various other parameters. The openthread and closethread keys must be set and the threads they point to must exist in the script. A set of local variables are automatically defined when the door is spawned and a few others are defined when the openthread and closethread threads are called.
|
Defined at all times:
local.targetname:
local.startorigin:
local.startangles:
local.movedir:
local.doorsize:
|
the value of the targetname key (string variable).
the initial position of the door when spawned (vector variable).
the initial orientation of the door when spawned (vector variable).
a vector which is the direction of the door as it was setup in the editor (number variable).
the "width" of the door along the movedir vector. This is used for sliding doors (number variable).
|
Defined when the openthread is called:
local.self:
local.origin:
local.opendot:
|
the owner of the initthread, openthread and closethread threads (the scriptdoor itself - string variable).
the current position of the door (vector variable).
the dotproduct of the delta between the opener and the door (forms the first vector) and the value of local.movedir (the second vector). Used to determine which way to open the door. If the result of the product is negative, the door will rotate clockwise and if the result is positive, the door will rotate counter-clockwise (number variable).
|
The openthread must have a 'local.self dooropened' command at the end to generate the required event which tells the game that the door is fully opened.
|
Defined when the closethread is called:
local.self:
local.origin:
|
the owner of the closethread thread (the scriptdoor itself - string variable).
the current position of the door (vector variable).
|
The closethread must have a 'local.self doorclosed' command at the end to generate the required event which tells the game that the door is fully closed.
Info courtesy of Mark Dochterman and Charlie Wiederhold, Ritual Entertainment.
Clarifications by Zied of 2015.
|
There are a number of useful SinScript commands specific to doors that you can use to control them with.
Doors can be locked and unlocked by using the following commands:
$door1 lock
$door1 unlock
Doors can be opened and closed by using the following commands:
$door1 open <entity>
$door1 close
Please note that the optional <entity> argument following the "open" command is the targetname or entity sequence number of the entity that operates the door. This is required mainly for rotating doors so the door knows which way to open. For sliding doors, including the argument makes no difference other than avoiding an error message to be printed on the screen (provided developer mode is set to 1).
Although the targetname or sequence number of any entity (except the door itself) can be used, the most common one to use as the command argument is the player which is always has the entity sequence no. 1 in single player maps. Thus, the above command line's syntax would be:
$door1 open *1
For doors which have the TOGGLE spawnflag set, you can open or close the door with the command:
$door1 toggledoor <entity>
Here the optional <entity> argument follows the same principle as the "open" command and thus, the most common usage would be:
$door1 toggledoor *1
|