Difference between revisions of "Doors (Programming)"

From Hellmoo Wiki Archive
Jump to navigation Jump to search
imported>Marvin
m
imported>Spunky
Line 1: Line 1:
-- Main.NecAnthrope - 07 May 2004
Doors are an extension of the generic exit.  Like $exit, a $door object is a member of a virtual pair of objects, each one a $door that is resident in a $room.  They link to each other via their .otherside property, which points to the opposite member of the pair.  They are corified as $door.  The basic idea behind doors is to emulate thier real-world function - to provide a method of access control between physical areas.
 
A can contain a lock, rope, or grappling hook, but will not allow anything else.


[ Note that if you already have a working exit and you want to easily doorify it, @make-door exit in the room (ie @make-door south) -- Main.WoodChuck - 02 Sep 2006 ]
[ Note that if you already have a working exit and you want to easily doorify it, @make-door exit in the room (ie @make-door south) -- Main.WoodChuck - 02 Sep 2006 ]


This document is intended to give a programmer's specification of door objects within Hellmoo.
==Properties==
 
Some of the more important properties defined on a $door are as follows:
 
* $door.open       
** The current state of the door (open == 1)
** Type INT (Boolean)
** Set by $door:_open() and $door:_close() (see Verbs section, below)
 
* $door.lock
** The lock installed in this door (if any)
** Type OBJ
 
* $door.operational     
** Whether or not the door can open (operational == 1)
** Type INT (Boolean)
 
* $door.open_action     
** The action used to open the door (see [[Actions (Programming)]])
** Type OBJ
 
* $door.close_action     
** The action used to close the door
** Type OBJ
 
* $door.health 
** Type INT
** How much damage the door can take


Doors are an extension of the generic exit.  Like $exit, a $door object is a member of a virtual pair of objects, each one a $door that is resident in a $room. They link to each other via their .otherside property, which points to the opposite member of the pair.  They are corified as $door.  The basic idea behind doors is to emulate thier real-world function - to provide a method of access control between physical areas.
* $door.health_max     
** The maxiumum amount of damage capacity possessed by the door
** Type INT


A door is a container, but only descendants of $lock (see ProgLocks) are allowed to reside inside them.
* $door.armor       
** Any inherent armor the door possesses due to its composition (i.e. wood, steel, etc)
** Type LIST
** Structured similarly to the .armor property in $clothing (See [[Clothing (Programming)]])
** Example: {{#269,2,4},{#277,4,8}} - Deflects 2-4 points of beating and 4-8 points of slashing
** Type {{cmd|@tree $damage with kids}} to see damage type objects


The properties defined on a $door are as follows:
* $door.squeals       
** The message set used in messages when the door is bashed (See [[Squeals (Programming)]])
** Type OBJ


  * $door.open       
* $door.default_attenuation
      * The current state of the door (open == 1)
** The amount of 'sound reduction' for the door when it is closed. (See [[Exits (Programming)]])
      * Type INT
** Type NUM
      * Boolean
      * Set by $door:_open() and $door:_close() (see Verbs section, below)
  * $door.operational     
      * Whether or not the door can open (operational == 1)
      * Type INT
      * Boolean
  * $door.open_action     
      * The action used to open the door (see ProgActions)
      * Type OBJ
  * $door.close_action     
      * The action used to close the door (see ProgActions)
      * Type OBJ
  * $door.autoopen_on_unlock 
      * Whether or not the door automatically opens when it is unlocked.  Default is 0
      * Type INT
      * Boolean
      * Set by $door:autoopen_on_unlock() (see Verbs section, below)
  * $door.autoclose_on_lock 
      * Whether or not the door automatically closes when it is locked.  Default is 1
      * Type INT
      * Boolean
      * Set by $door:autoclose_on_lock() (see Verbs section, below)
  * $door.lock_installable 
      * Whether or not locks can be installed in a door.  Default is 1
      * Type INT
      * Boolean
      * Set by $door:lock_installable() (see Verbs section, below)
  * $door.health 
      * Type INT     
      * How much damage the door can take
  * $door.health_max     
      * The maxiumum amount of damage capacity possessed by the door
      * Type INT
  * $door.armor       
      * Any inherent armor the door possesses due to its composition (i.e. wood, steel, etc)
      * Type LIST
      * Structured similarly to the .armor property in $clothing (See ProgClothing)
      * Example: {{#269,2,4},{#277,4,8}} - Deflects 2-4 points of beating and 4-8 points of slashing
      * Type '@tree $damage with kids' to see damage type objects
  * $door.squeals       
      * The message set used in messages when the door is bashed (See ProgSqueals)
      * Type OBJ
  * $door.autoclose
      * Whether or not to close automatically after being opened for a short period
      * Type NUM
      * Used by $door:_autoclose() (see Verbs section, below)
  * $door.systems
      * The objrefs for security system objects that can change the door's state
      * Type LIST
      * Used by Security System API (see Verbs section, below)
  * $door.default_attenuation
      * The amount of 'sound reduction' for the door when it is closed. (See ProgExit)
      * Type NUM


==Verbs==


The verbs defined on a $door are as follows:
The verbs defined on a $door are as follows:


  * open/close
* open/close
      * Top level, user-invoked verb for changing the door's open state.  Queues events that invoke _open or _close after sanity checks.
** Top level, user-invoked verb for changing the door's open state.  Queues events that invoke _open or _close after sanity checks.
  * _open
 
      * Checks the door's operational status and lock state, invokes _do_open, and announces appropriate messages.
* _open
  * _close
** Checks the door's operational status and lock state, invokes _do_open, and announces appropriate messages.
      * Check's the door's operational status, invokes _do_open, and announces appropriate messages.
 
  * _do_open
* _close
      * Actually changes the door's state, and the state of the door's .otherside, to open.
** Check's the door's operational status, invokes _do_open, and announces appropriate messages.
      * Sets the door's .attenuation to that of a standard exit (-3) (See ProgExit)
 
  * _do_close
* _do_open
      * Actually changes the door's state, and the state of the door's .otherside, to closed.
** Actually changes the door's state, and the state of the door's .otherside, to open.
      * Sets the door's .attenuation to it's own .default_attenuation (See ProgExit)
** Sets the door's .attenuation to that of a standard exit (-3)
  * lock/unlock
 
      * Top level, user-invoked verb for changing the door's lock state.  Queues actions that invoke _lock or _unlock after sanity checks.
* _do_close
      * Also checks if the door's .autoopen_on_unlock or .autoclose_on_lock props are set.
** Actually changes the door's state, and the state of the door's .otherside, to closed.
        * If so, closes the door if it is being locked, or opens the door if it is being unlocked, respectively.
** Sets the door's .attenuation to it's own .default_attenuation (See ProgExit)
  * _lock/_unlock
 
      * Iterates through the door's contents, which should only be descendents of $lock.
* lock/unlock
      * Invokes logic on each lock to attempt to change its state (see ProgLocks).
** Top level, user-invoked verb for changing the door's lock state.  Queues actions that invoke _lock or _unlock after sanity checks.
  * knock
 
      * Top level, user-invoked verb.  Simulates knocking on doors.  Queues an event that invokes _knock.
* _lock/_unlock
  * _knock
** Iterates through the door's contents, which should only be descendents of $lock.
      * Announces messages on either side of the door indicating someone is knocking.
** Invokes logic on each lock to attempt to change its state (see ProgLocks).
  * pick
 
      * Top level, user-invoked verb.  Matches on a particular $lock and queues an event that invokes that $lock's _pick verb.  (see ProgLocks)
* knock
** Top level, user-invoked verb.  Simulates knocking on doors.  Queues an event that invokes _knock.
 
* _knock
** Announces messages on either side of the door indicating someone is knocking.
 
* pick
** Top level, user-invoked verb.  Matches on a particular $lock and queues an event that invokes that $lock's _pick verb.  (see ProgLocks)
 
* _announce
** Announces messages on both sides of the door.
** Invoked by _open/_close, _lock/_unlock, and _pick.
 
* look_self
** Returns text to be printed to the player when someone looks at the door.
 
* _move
** Checks if a door is open, does not allow movement through it if it is closed
** Extends verb on $exit (see ProgExit)
 
* try_me
** Checks if a door is open, does not allow movement through it if it is closed
** Overrides verb on $exit
 
* invoke
** If player's unlockdoors pref is set, queue door unlock action
** If player's opendoors pref is set, queue door open action
** Overrides verb on $exit
 
* allows
** Checks if a door is open, does not allow movement through it if it is closed
** Extends verb on $exit
 
* throws_to
** Checks if a door is open, does not allow objexts to be thrown through it if it is closed
** Extends verb on $exit
 
* acceptable
** Only allows children of $lock to be placed inside a $door
** Extends verb on $exit


  * _announce
* go_fail_msg/go_fail_open_msg
      * Announces messages on both sides of the door.
** Returns $door.(verb)
      * Invoked by _open/_close, _lock/_unlock, and _pick.


  * look_self
* hear_event_say
      * Returns text to be printed to the player when someone looks at the door.
** Passes args to lock's :hear_event_say (if it exists)
  * keyholes
** Included to emulated voice-activated electronic locks
      * Iterates through all $locks in a door, makes a pretty list of those $lock's .keyhole_msg properties, and returns it
      * Invoked by look_self


* app*raise
** Top level, user invoked verb for tellling players information about the door
** Calls tell_appraise


  * _move
* tell_appraise
      * Checks if a door is open, does not allow movement through it if it is closed
** Called by appraise
      * Extends verb on $exit (see ProgExit)
** Determines information on locks and armor values of door
  * try_me
      * Checks if a door is open, does not allow movement through it if it is closed
      * Overrides verb on $exit (see ProgExit)
  * invoke
      * If player's unlockdoors pref is set, queue door unlock action (see ProgActions)
      * If player's opendoors pref is set, queue door open action (see ProgActions)
      * Overrides verb on $exit (see ProgExit)
  * allows
      * Checks if a door is open, does not allow movement through it if it is closed
      * Extends verb on $exit (see ProgExit)
  * throws_to
      * Checks if a door is open, does not allow objexts to be thrown through it if it is closed
      * Extends verb on $exit (see ProgExit)
  * acceptable
      * Only allows children of $lock to be placed inside a $door
      * Extends verb on $exit (see ProgExit)


  * go_fail_msg/go_fail_open_msg
* uninstall
      * Returns $door.(verb)
** Invokes the specified $lock's _uninstall
** Determines which lock via matching logic


  * hear_event_say
* take_damage
      * Passes args to all installed $locks' :hear_event_say (if it exists) (see ProgActions)
** Applies damage from weapons
      * Included to emulated voice-activated electronic locks
** Calls :die() if door is out of health
  * app*raise
      * Top level, user invoked verb for tellling players information about the door
      * Calls tell_appraise
  * tell_appraise
      * Called by appraise
      * Determines information on locks and armor values of door
  * uninstall
      * Invokes the specified $lock's _uninstall (see ProgLocks)
      * Determines which lock via matching logic
  * take_damage
      * Applies damage from weapons
      * Calls :die() if door is out of health
  * squeal_msg
      * Return this object's reaction to receiving this damage, based on the damage actually done after armor
      * Defaults to .squeals (see ProgSqueals)
  * die
      * Called when $door's health is reduced below zero by weapons
      * Sets $door.operational to 0
      * Sets $door.otherside.operational to 0
      * Opens door
      * Sets all $locks' .operational to 0
      * Sets all $locks' .otherside.operational to 0
      * Unlocks all locks
  * _repair
      * Sets $door.operational to 1
      * Sets $door.otherside.operational to 1
      * Closes door
      * Sets all $locks' .operational to 1
      * Sets all $locks' .otherside.operational to 1
      * Locks all locks
      * Designed to be called by 'repairman' NPCs
  * on_reset
      * Identical functionality to $door:_repair
      * Designed to be called by $area:on_reset (See ProgArea)
  * _repair_check
      * Makes skill check against player/NPC's repair skill
  * is_broken
      * returns inverse of $door.operational
  * lock_installable
      * Toggles $door.lock_installable (see above)


  * autoopen_on_unlock
* squeal_msg
      * Toggles $door.autoopen_on_unlock (see above)
** Return this object's reaction to receiving this damage, based on the damage actually done after armor
  * autoclose_on_lock
** Defaults to .squeals (see [[Squeals (Programming)]])
      * Toggles $door.autoclose_on_lock (see above)
  * _autoclose
      * Automatically closes the door 30 seconds after it is opened.
      * Invoked only if $door.autoclose is set to 1.
      * This is intended for NPCs only - there is no method that allows players to use this functionality at present.


<B>NPC API:</B><br />
* die
(These verbs are intended to be used by NPCs for programming door related operations)
** Called when $door's health is reduced below zero by weapons
** Sets $door.operational to 0
** Sets $door.otherside.operational to 0
** Opens door
** Sets the lock's .operational to 0
** Sets the lock's .otherside.operational to 0
** Unlocks the lock


  * _is_locked
* _repair
      * Polls all locks installed in the door
** Sets $door.operational to 1
        * If any of the locks are engaged, return 1
** Sets $door.otherside.operational to 1
        * If all locks are disengaged, return 0
** Closes door
  * _can_be_unlocked_by
** Sets the lock's .operational to 1
      * Polls all locks installed in the door
** Sets all $locks' .otherside.operational to 1
        * If ALL of the locks can be unlocked by args[1], return 1
** Locks all locks
        * If ANY of the locks cannot be unlocked by args[1], return 0
** Designed to be called by 'repairman' NPCs
  * _open
      * See above.
  * _close
      * See above.
  * _lock/_unlock
      * See above.


<B>Security System API</B><br />
* on_reset
(These verbs are intended to be used by security systems for programming door related operations)
** Identical functionality to $door:_repair
** Designed to be called by $area:on_reset


  * _security_autoopen
* _repair_check
      * Opens door, prints appropriate messages on both sides
** Makes skill check against player/NPC's repair skill
      * Messages printed are .otherside_* messages, which do not indicate a user
  * _security_autounlock
      * Unlocks all locks in door, prints appropriate messages on both sides
      * Invokes $lock:_security_autounlock on all locks (see ProgLocks)
      * Messages printed are .otherside_* messages, which do not indicate a user
  * _security_autoclose
      * Closes door, prints appropriate messages on both sides
      * Messages printed are .otherside_* messages, which do not indicate a user
  * _security_autolock
      * Locks all locks in door, prints appropriate messages on both sides
      * Invokes $lock:_security_autounlock on all locks (see ProgLocks)
      * Messages printed are .otherside_* messages, which do not indicate a user


<B>Gang API:</B><br />
* is_broken
(These verbs are intended to be used by gangs for programming door related operations)<br />
** returns inverse of $door.operational
<B>n.b.: These verbs are ONLY present on children of biometric locks.</B>
** lock_installable
** Toggles $door.lock_installable (see above)


  * add_lock_user
* _is_locked
      * Adds an object to the lock's .keyed_to property.
** Polls the lock in the door
  * remove_lock_user
** If lock is engaged, return 1
      * Removes an object to the lock's .keyed_to property.
** If all locks are disengaged, return 0
  * set_lock_users
      * Resets the lock's .keyed_to property to the specified list of objects.


[[Category:Needs work]] [[Category:Programming]]
[[Category:Needs work]] [[Category:Programming]]

Revision as of 05:39, 17 January 2009

Doors are an extension of the generic exit. Like $exit, a $door object is a member of a virtual pair of objects, each one a $door that is resident in a $room. They link to each other via their .otherside property, which points to the opposite member of the pair. They are corified as $door. The basic idea behind doors is to emulate thier real-world function - to provide a method of access control between physical areas.

A can contain a lock, rope, or grappling hook, but will not allow anything else.

[ Note that if you already have a working exit and you want to easily doorify it, @make-door exit in the room (ie @make-door south) -- Main.WoodChuck - 02 Sep 2006 ]

Properties

Some of the more important properties defined on a $door are as follows:

  • $door.open
    • The current state of the door (open == 1)
    • Type INT (Boolean)
    • Set by $door:_open() and $door:_close() (see Verbs section, below)
  • $door.lock
    • The lock installed in this door (if any)
    • Type OBJ
  • $door.operational
    • Whether or not the door can open (operational == 1)
    • Type INT (Boolean)
  • $door.close_action
    • The action used to close the door
    • Type OBJ
  • $door.health
    • Type INT
    • How much damage the door can take
  • $door.health_max
    • The maxiumum amount of damage capacity possessed by the door
    • Type INT
  • $door.armor
    • Any inherent armor the door possesses due to its composition (i.e. wood, steel, etc)
    • Type LIST
    • Structured similarly to the .armor property in $clothing (See Clothing (Programming))
    • Example: {{#269,2,4},{#277,4,8}} - Deflects 2-4 points of beating and 4-8 points of slashing
    • Type @tree $damage with kids to see damage type objects
  • $door.squeals
  • $door.default_attenuation
    • The amount of 'sound reduction' for the door when it is closed. (See Exits (Programming))
    • Type NUM

Verbs

The verbs defined on a $door are as follows:

  • open/close
    • Top level, user-invoked verb for changing the door's open state. Queues events that invoke _open or _close after sanity checks.
  • _open
    • Checks the door's operational status and lock state, invokes _do_open, and announces appropriate messages.
  • _close
    • Check's the door's operational status, invokes _do_open, and announces appropriate messages.
  • _do_open
    • Actually changes the door's state, and the state of the door's .otherside, to open.
    • Sets the door's .attenuation to that of a standard exit (-3)
  • _do_close
    • Actually changes the door's state, and the state of the door's .otherside, to closed.
    • Sets the door's .attenuation to it's own .default_attenuation (See ProgExit)
  • lock/unlock
    • Top level, user-invoked verb for changing the door's lock state. Queues actions that invoke _lock or _unlock after sanity checks.
  • _lock/_unlock
    • Iterates through the door's contents, which should only be descendents of $lock.
    • Invokes logic on each lock to attempt to change its state (see ProgLocks).
  • knock
    • Top level, user-invoked verb. Simulates knocking on doors. Queues an event that invokes _knock.
  • _knock
    • Announces messages on either side of the door indicating someone is knocking.
  • pick
    • Top level, user-invoked verb. Matches on a particular $lock and queues an event that invokes that $lock's _pick verb. (see ProgLocks)
  • _announce
    • Announces messages on both sides of the door.
    • Invoked by _open/_close, _lock/_unlock, and _pick.
  • look_self
    • Returns text to be printed to the player when someone looks at the door.
  • _move
    • Checks if a door is open, does not allow movement through it if it is closed
    • Extends verb on $exit (see ProgExit)
  • try_me
    • Checks if a door is open, does not allow movement through it if it is closed
    • Overrides verb on $exit
  • invoke
    • If player's unlockdoors pref is set, queue door unlock action
    • If player's opendoors pref is set, queue door open action
    • Overrides verb on $exit
  • allows
    • Checks if a door is open, does not allow movement through it if it is closed
    • Extends verb on $exit
  • throws_to
    • Checks if a door is open, does not allow objexts to be thrown through it if it is closed
    • Extends verb on $exit
  • acceptable
    • Only allows children of $lock to be placed inside a $door
    • Extends verb on $exit
  • go_fail_msg/go_fail_open_msg
    • Returns $door.(verb)
  • hear_event_say
    • Passes args to lock's :hear_event_say (if it exists)
    • Included to emulated voice-activated electronic locks
  • app*raise
    • Top level, user invoked verb for tellling players information about the door
    • Calls tell_appraise
  • tell_appraise
    • Called by appraise
    • Determines information on locks and armor values of door
  • uninstall
    • Invokes the specified $lock's _uninstall
    • Determines which lock via matching logic
  • take_damage
    • Applies damage from weapons
    • Calls :die() if door is out of health
  • squeal_msg
    • Return this object's reaction to receiving this damage, based on the damage actually done after armor
    • Defaults to .squeals (see Squeals (Programming))
  • die
    • Called when $door's health is reduced below zero by weapons
    • Sets $door.operational to 0
    • Sets $door.otherside.operational to 0
    • Opens door
    • Sets the lock's .operational to 0
    • Sets the lock's .otherside.operational to 0
    • Unlocks the lock
  • _repair
    • Sets $door.operational to 1
    • Sets $door.otherside.operational to 1
    • Closes door
    • Sets the lock's .operational to 1
    • Sets all $locks' .otherside.operational to 1
    • Locks all locks
    • Designed to be called by 'repairman' NPCs
  • on_reset
    • Identical functionality to $door:_repair
    • Designed to be called by $area:on_reset
  • _repair_check
    • Makes skill check against player/NPC's repair skill
  • is_broken
    • returns inverse of $door.operational
    • lock_installable
    • Toggles $door.lock_installable (see above)
  • _is_locked
    • Polls the lock in the door
    • If lock is engaged, return 1
    • If all locks are disengaged, return 0