Doors (Programming)

From HellWiki
Jump to: navigation, search

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 door can contain a lock, rope, or grappling hook, but will not allow anything else inside it.

Making Doors

If you already have a working exit and you want to easily doorify it, use the @make-door <exit> when you are in the room with that exit (ie @make-door south). If you need to make a new type of door you can create one the old fashioned way (@create $door named ...).

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