Dump of #59000 (Generic Lockpickable LRPG Container)

@create #43001 named generic lockpickable RPG container:generic lockpickable RPG container
;;#59000.("oclose_msg") = "%n %<closes> %d."
;;#59000.("oopen_msg") = "%n %<opens> %d."
;;#59000.("open_key") = 0
;;#59000.("store_action") = "store"
;;#59000.("encumbrance") = 100
;;#59000.("manufactured") = 749722886
;;#59000.("worth") = -1
;;#59000.("condition") = 100
;;#59000.("odrop_failed_msg") = "%<tries> to drop %t but fails!"
;;#59000.("odrop_succeeded_msg") = "%<drops> %t."
;;#59000.("otake_succeeded_msg") = "%<picks> up %t."
"#59000.("key") => E_PERM (Permission denied)
;;#59000.("aliases") = {"generic lockpickable RPG container"}
;;#59000.("object_size") = {9127, 1141286565}

@verb #59000:"pick_lock" this none this
@program #59000:pick_lock
":pick_lock(thief, Resolve-result)  -- picked by a lockpick successfully.";
if (!$object_utils:isa(caller, this.lockpick))
  return E_PERM;
endif
{pc, result, @extra_args} = args;
if (this:locked())
  $local.rpg:say_action(this.opick_success_msg, pc, this, this.location);
  this:set_locked(0);
else
  return player:tell("It is already unlocked.");
endif
if (!this.reset_time)
  return;
endif
fork (this.reset_time)
  joe = (pc.location == this.location) ? pc | $no_one;
  if (!this:locked())
    $local.rpg:say_action(this.relock_msg, joe, this, this.location);
    this:set_locked(1);
  endif
  this:set_opened(0);
endfork
"TM 23-DEC-1995: changed line 6 to use the successful pick msg instead of the picking msg, also added a check to display relocking message only if container is still unlocked, and added check to not print the relock msg to the lockpicker if they're left the room.";
"THX (#105941) - Thu Feb  3, 2000 - Hannibal added a check to see if the lock was already picked before forking.  THX changed to a scatter assignment and from $you:say_action to $local.rpg:say_action.";
.

@verb #59000:"pick_msg pick_mod pick_failed locked" this none this
@program #59000:pick_msg
"You can customize to have :pick_failed fire some nasty traps at the would-be thief, heh, or whatever your cruel imagination can think of.";
return this.(verb);
.

@verb #59000:"make_fertile" this none this
@program #59000:make_fertile
"Copied from generic resting/sleeping dungeon (#5804):make_fertile by Quinn (#19845) Sat Sep 18 00:17:46 1993 PDT";
"If you'd like to make children of this room, I suggest you use the following sequence to create a room which will be the generic for all the rooms in your RPG-area.  Then, just make kids of that object.";
";foo:make_fertile();bar = create(foo)";
who = caller_perms();
if (#46:trust() && (this == #59000))
  if (this.f)
    who:tell(this.name, " (", this, ") is already fertile.");
  else
    this.f = 1;
    fork (0)
      this.f = 0;
    endfork
    who:tell(this.name, " (", this, ") is now fertile.");
  endif
endif
.

@verb #59000:"pu*t ins*ert st*ore ca*che" any in this rx
@program #59000:put
"Prevent transfer if container is locked";
if (this.locked)
  player:tell(this.name, " is locked.");
  return 0;
endif
pass(@args);
.

@verb #59000:"lock_msg olock_msg unlock_msg ounlock_msg no_key_msg" this none this rx
@program #59000:lock_msg
return (msg = this.(verb)) ? $string_utils:pronoun_sub(msg, @args) | "";
.

@verb #59000:"lock unlock" this none none
@program #59000:lock
":lock/unlock <this> - uses keys if desired; default only lets the owner manipulate.";
if (!(val = this:holds_key(player)))
  player:tell(this:no_key_msg());
  return 0;
elseif ((val == -1) && (!(player in {this.owner, @this.trusted})))
  player:tell(tostr("You aren't allowed to ", verb, " ", this.name, "."));
  return E_PERM;
elseif (this:locked())
  if (verb == "lock")
    player:tell("It is already locked.");
  else
    this:set_locked(0);
    player:tell(this:unlock_msg());
    player.location:announce_all_but({player}, this:ounlock_msg());
  endif
else
  if (verb == "unlock")
    player:tell("It is already unlocked.");
  else
    this:set_locked(1);
    this:set_opened(0);
    player:tell(this:lock_msg());
    player.location:announce_all_but({player}, this:olock_msg());
  endif
endif
.

@verb #59000:"re*move ex*tract rec*over ge*t ta*ke" any from this rx
@program #59000:remove
"Prevent transfer if container is locked";
if (this:locked())
  player:tell(this.name, " is locked.");
  return 0;
endif
pass(@args);
.

@verb #59000:"acceptable" this none this
@program #59000:acceptable
"Allow $local.rpg.equipment only if opened and unlocked";
return ((pass(@args) && (!this:locked())) || (caller_perms() in $local.rpg.grand_masters)) || $perm_utils:controls(caller_perms(), this);
"TM 23-DEC-1995 14:00 EST:  added $perm_utils check to help GMs teleporting stuff in without unlocking and opening first.";
.

@verb #59000:"set_locked" this none this
@program #59000:set_locked
if ((!$perm_utils:controls(caller.owner, this)) && (caller_perms() != this.lockpick.owner))
  return E_PERM;
endif
this.locked = locked = !(!args[1]);
return locked;
.

@verb #59000:"holds_key" this none this
@program #59000:holds_key
":holds_key(pc) ==> 1 if the pc holds a 'key' object for the container. Kudos to Quinn for the wonderful idea";
if ((typeof(key = this.key_obj) != OBJ) || (!valid(key)))
  return -1;
elseif (key.location == (pc = args[1]))
  return 1;
endif
return 0;
.

@verb #59000:"is_openable_by" this none this
@program #59000:is_openable_by
return (!this:locked()) || $perm_utils:controls(caller_perms(), this);
.

@verb #59000:"reset_lock" this none this
@program #59000:reset_lock
return;
":reset_lock ([OBJ lockpicking player]) - reset the lock on the container.";
pc = (length(args) > 1) ? args[1] | $no_one;
joe = (pc.location == this.location) ? pc | $no_one;
if (!this:locked())
  $local.rpg:say_action(this.relock_msg, joe, this, this.location);
  this:set_locked(1);
endif
this:set_opened(0);
"THX (#105941) - Thu Feb  3, 2000 - subst /$you/$local.rpg/g 1-$";
.

"***finished***