@set $sys:writable-core=yes
@rehash-all
;$user.spawn("l2user")
@rename $user_l2user to $l2user
@program $l2user.emit_cmd() +access=pub
  arg cmdstr, cmd, what;
  var name;
  // Copyright AstroArch Consulting, Inc 1998
  // Right to use or modify is granted as long as this copyright remains.
  
  (> .perms(caller(), $user, $body) <);
  .location().announce(what);
  
.
@program $l2user.ooc_cmd() +access=pub
  arg cmdstr, cmd, what;
  var how, message;
  // Copyright AstroArch Consulting, Inc 1998
  // Right to use or modify is granted as long as this copyright remains.
  
  (> .perms(caller(), $user, $body) <);
  switch (what[1]) {
      case ":":
          if (what[2] == ":")
              message = what.subrange(3);
          else
              message = " " + what.subrange(2);
      case "%":
          message = " . o O ( " + what.subrange(2) + " )";
      case "!":
          message = " " + what.subrange(2);
      default:
          how = $code_lib.punctuation_type(what);
          message = " " + how + "s, \"" + what + "\"";
  }
  .location().announce("OOC: " + .name() + message);
.
@program $l2user.audit_cmd() +access=prot
  arg cmdstr, cmd, args;
  var str, full, o;
  // Copyright AstroArch Consulting, Inc 1998
  // Right to use or modify is granted as long as this copyright remains.
  
  (> .perms(caller(), $user) <);
  if(cmd != "@quota")
    str="+f ";
  else
    str="";
  o = $parse_lib.getopt(args, [["f?ull"]]);
  args = o[1].join();
  if(!args)
    str=str + "me";
  else
    str=str + args;
  cmd="@audit";
  cmdstr=cmd + " " + str;
  return pass(cmdstr, cmd, str);
.
@program $l2user.crowds_cmd() +access=pub
  arg cmdstr, cmd;
  var x, y, out, location, dict, f;
  // Copyright AstroArch Consulting, Inc 1998
  // Right to use or modify is granted as long as this copyright remains.

  (> .perms(caller(), $user) <);
  dict=#[];
  for x in ($user.descendants()) {
    location=x.location();
    if (location != $body_cave)
       dict = dict.add_elem(location.name(), x.name());
  }
  .tell("Players in crowds:");
  for x in (dict) {
     out="   "+x[1]+": ";
     f=0;
     for y in (x[2]) {
       if(f) {
         out += ", "+y;
       } else {
         out += y;
       }
       f++;
     }
     if(f > 1)
       .tell(out);
  }
  .tell("--- End List ---");
.
@program $l2user.time_cmd +access=pub
  arg cmdstr, cmd;
  var ti, fo, msg;
  // Copyright AstroArch Consulting, Inc 1998
  // Right to use or modify is granted as long as this copyright remains.

  (> .perms(caller(), $user) <);
  ti=localtime();
  fo = ti[11];  
  if(ti[11] == "   ") {
    fo = "CST";
  }
  .tell("Real time: "+ctime()+" "+fo);
  .tell("Game time: Not Implemented Yet");
.

;$l2user.add_flag('command_cache)
@ac "ooc|@ooc <any>" to $l2user.ooc_cmd
@ac "emit|@emit <any>" to $l2user.emit_cmd
@ac "@audit <any>" to $l2user.audit_cmd
@ac "@quota <any>" to $l2user.audit_cmd
@ac "help <any>" to $l2user.help_cmd
@ac "who <any>" to $l2user.who_cmd
@ac "crowds" to $l2user.crowds_cmd
@dc "uptime <any>" from $bad_commands.old_command_cmd
@ac "uptime|+uptime" to $l2user.status_cmd
@ac "date|+time" to $l2user.time_cmd
@as "p %1=%2" to "@page %1 with %2" on $l2user.remote_cmd
@as "page %1=%2" to "@page %1 with %2" on $l2user.remote_cmd
@as "p =%1" to "@page  with %1" on $l2user.remote_cmd
@ap $l2user to $player
@spawn $antisocial named $l2social
@ap $l2social to $l2user
@dc "fart <object>" from $antisocial.anti_cmd
;$builder.spawn("l2builder")
@rename $builder_l2builder to $l2builder
@ac "@recycle <list object>" to $l2builder.destroy_cmd
@ap $l2builder to $builder
@rehash-all