@program RealKeys.muf 1 10000 d i $include $lib/alynna $def keyprop "/~key/" $def kp { keyprop rot }cat $def }tell }cat "Key" pretty tellme $def }otell }cat "Key" pretty tellhere $def sname name ";" split pop lvar param : key.help { "Super Locks and Keys - (C) 2003 Alynna Trypnotk" "\"You can unlock any door, if you only have the key.\" -- Jonathan Brisby" " " " keys List my keys" " lock Lock an exit I have a key for, noone can go" " in without unlocking it first." " unlock Unlock an exit I have a key for, anyone can" " go in, with or without a key" " autolock Sets Autolock for an exit which will allow" " anyone who has a key to go through without" " unlocking the door first, and will keep" " everyone else out. (Default state of locks)" " key/make Make a lock/key pair for a exit." " key/give = Give someone a key for an exit." " key/take = Take the key away." " key/trash <#key> Destroy one of the keys I have." " key/override Wiz only: Toggle lock overrides." }array atellme ; : getkey[ dbref:target str:prop -- result ] target @ { keyprop prop @ }cat getprop ; : setkey[ dbref:target str:prop value -- ] target @ { keyprop prop @ }cat value @ setprop ; : resolver[ str:target -- dbref:result ] var result target @ resolve result ! result @ int 0 < if #-1 result ! then result @ ; : permission-denied { "^RED^Permission denied.^NORMAL^" }tell ; : key.list var target var keys var cur param @ "#help" smatch if key.help exit then me @ mlevel 4 < if "" param ! then param @ not if "me" param ! then param @ resolver target ! target @ int 0 < if { "Ambiguous or unresolvable reference." }tell exit then { "Keychain on " target @ unparseobj }cat header tellme target @ "chain" kp array_get_reflist keys ! keys @ foreach cur ! pop { "^GREEN^" { "#" cur @ int }cat 8 lj "^YELLOW^" cur @ sname "^CYAN^ @ ^YELLOW^" cur @ location name "^NORMAL^" }cat tellme repeat { keys @ array_count " keys found." }cat footer tellme ; : key.lock var target param @ not if { "Syntax: lock " }tell exit then param @ resolver dup not if { "Cant find that exit." }tell exit then target ! target @ exit? not if { "Thats not an exit!" }tell exit then me @ "chain" kp target @ reflist_find not if { "You can lock any door, if you only have the key. Unfortunately, for this one, you don't." }tell exit then target @ "locked?" 1 setkey { "Exit " target @ sname " was ^RED^LOCKED^NORMAL^." }tell ; : key.unlock var target param @ not if { "Syntax: unlock " }tell exit then param @ resolver dup not if { "Cant find that exit." }tell exit then target ! target @ exit? not if { "Thats not an exit!" }tell exit then me @ "chain" kp target @ reflist_find not if { "You can unlock any door, if you only have the key. Unfortunately, for this one, you don't." }tell exit then target @ "locked?" -1 setkey { "Exit " target @ sname " was ^GREEN^UNLOCKED^NORMAL^." }tell ; : key.autolock var target param @ not if { "Syntax: autolock " }tell exit then param @ resolver dup not if { "Cant find that exit." }tell exit then target ! target @ exit? not if { "Thats not an exit!" }tell exit then me @ "chain" kp target @ reflist_find not if { "You can autolock any door, if you only have the key. Unfortunately, for this one, you don't." }tell exit then target @ "locked?" 0 setkey { "Exit " target @ sname " was ^YELLOW^AUTOLOCKED^NORMAL^." }tell ; : key.make var target param @ not if { "Syntax: key/make " }tell exit then param @ resolver dup not if { "Cant find that exit." }tell exit then target ! target @ exit? not if { "Thats not an exit!" }tell exit then me @ target @ controls not if { "This isnt your exit! Do you always go around making keys for other peoples doors?" }tell exit then target @ { "#" prog int }cat setlockstr me @ "chain" kp target @ reflist_add { "A key for " target @ sname " has been made, and added to your keychain." }tell ; : key.give var target var texit param @ not if { "Syntax: key/give =<#key>" }tell exit then param @ "=" split resolver dup not if { "Cant find that exit." }tell exit then texit ! resolver dup not if { "Cant find that player." }tell exit then target ! target @ player? not if { "Thats not a player!" }tell exit then texit @ exit? not if { "Thats not an exit!" }tell exit then me @ texit @ controls not if { "This isnt your exit! Do you always go around making keys for other peoples doors?" }tell exit then target @ "chain" kp texit @ reflist_add me @ { "A key for " texit @ sname " has been made, and added to " target @ unparseobj "'s keychain." }cat "Keys" pretty ansi_notify target @ { "A key for " texit @ sname " has been made, and added to " target @ unparseobj "'s keychain." }cat "Keys" pretty ansi_notify ; : key.take var target var texit param @ not if { "Syntax: key/take =<#key>" }tell exit then param @ "=" split resolver dup not if { "Cant find that exit." }tell exit then texit ! resolver dup not if { "Cant find that player." }tell exit then target ! target @ player? not if { "Thats not a player!" }tell exit then texit @ exit? not if { "Thats not an exit!" }tell exit then me @ texit @ controls not if { "You dont control that key! Do you always go around stealing other peoples keys?" }tell exit then target @ "chain" kp texit @ reflist_del me @ { "The key for " texit @ sname " has been removed from " target @ unparseobj "'s keychain." }cat "Keys" pretty ansi_notify target @ { "The key for " texit @ sname " has been removed from " target @ unparseobj "'s keychain." }cat "Keys" pretty ansi_notify ; : key.trash var target param @ not if { "Syntax: key/trash <#key>" }tell exit then param @ todbref target ! me @ "chain" kp target @ reflist_del { "The key for " target @ sname " has been removed from your keychain." }tell ; : key.override me @ mlevel 4 < if permission-denied exit then me @ "override" over over getkey not setkey { "Wizard lock override is now " me @ "override" getkey if "^GREEN^ON^NORMAL^" else "^RED^OFF^NORMAL^" then "." }tell ; : key.process ( Override on always passes ) me @ "override" getkey if 1 exit then ( Now for actual lock code ) trig "locked?" getkey case ( Locked hard. You must unlock with a key ) -1 = when 0 end ( Unlocked hard. Key not needed ) 1 = when 1 end ( Autolocked. If you have a key, then pass, else dont. ) default me @ "chain" kp trig reflist_find if 1 else 0 then end endcase ; : main param ! command @ tolower case "keys" smatch when key.list end "lock" smatch when key.lock end "unlock" smatch when key.unlock end "autolock" smatch when key.autolock end "key/make" smatch when key.make end "key/give" smatch when key.give end "key/take" smatch when key.take end "key/trash" smatch when key.trash end "key/override" smatch when key.override end default key.process end endcase ; . c q