@q
@program whospec2.muf
1 99999 d
i
(  WhoSpecies Clone 1.1   Kahz@FurToonia    2/11/95 )
(  Ruffin patch 11/28/95 - _wsdark?:yes shows ws in dark room )
(  Ruffin patch 29 Mar 96 - Add IC/OOC column )
$include $lib/strings
$def   SPECIES "info"
$def  PSPECIES "species_prop"
$def  SEEDOING "_wsseedoing"
$def     DOING "_wsdoing"
$def OBJECTION "_wsobjector"
$def  IDLETIME "_wsidle"
$def   PWSDARK "_wsdark?"  (Ruffin)
$def   DEFIDLE 120
lvar DidHeader
lvar DoDoDaDoing
lvar IdleAfter
lvar IsPuppet
lvar Tmp
: wstell
  "WS: " swap strcat .tell
;
: do_help
  "WhoSpecies Clone 1.1   Kahz@FurToonia    30 Mar 96" .tell
  " " .tell
  "This command displays the name, awake or idle status, sex, species, and Doing" .tell
  "messages of players, zombies, and puppets in the current room." .tell
  " " .tell
  "ws               - Show all players, zombies, and puppets in the current room." .tell
  "ws <player>      - Show just the specified player in the current room." .tell
  "ws #far <player> - Show the specified player, who can be anywhere, but must" .tell
  "                   not be objecting to this command." .tell
  "ws #idle <time>  - Sets what you consider to be the minimum time before a" .tell
  "                   player is displayed as being idle. Default is " DEFIDLE intostr strcat " seconds." strcat .tell
  "ws #doing        - You will see Doing messages, if any." .tell
  "ws #!doing       - You will not see Doing messages." .tell
  "ws do: <message> - Set your Doing message. Same as 'ws doing:'" .tell
  "ws #object       - You object to someone using 'ws #far' on you." .tell
  "ws #!object      - You don't object to someone using 'ws #far' on you." .tell
  "ws #stat         - Shows your current ws settings." .tell
  "ic / ooc / noic  - Set IC? to IC, OOC, or blank." .tell
  "           IC is 'in character' (role playing), OOC is 'out of character'" .tell
;
: idle_time
  9999999 Tmp !
  descriptors begin dup while
    swap descrcon conidle dup Tmp @ < if
      Tmp !
    else
      pop
    then
  1 - repeat pop
  Tmp @ IdleAfter @ < if "" exit then
  "[Idle "
  Tmp @ dup 86400 > if
    86400 / intostr strcat "d"
  else
    dup 3600 > if
      3600 / intostr strcat "h"
    else
      60 / intostr strcat "m"
    then
  then
  strcat "]" strcat
;
: do_stat
  "You will " Me @ SEEDOING getpropstr .yes? not if
     "NOT " strcat
  then
  "see any Doing lines." strcat wstell
  "You consider someone to be idle after "
  Me @ IDLETIME getpropstr dup if
    atoi
  else
    pop "the DEFAULT time of " strcat DEFIDLE
  then
  intostr strcat " seconds." strcat wstell
  "You are " Me @ OBJECTION getpropstr "far" stringcmp if
     "NOT " strcat
  then
  "objecting to someone doing a 'ws #far' on you." strcat wstell
  Me @  DOING getpropstr dup if
    "Doing: " swap strcat 75 strcut pop wstell
  else
    "No Doing message." wstell
  then
;
: do_header
  DidHeader @ not if
    "Name                    Sex        IC?  Info" .tell
    1 DidHeader !
  then
;
: get_species
  dup PSPECIES getpropstr dup not if
    pop SPECIES
  then
  getpropstr
;
: is_dark
  "d" flag? Me @ "w" flag? not and
;
: is_asleep
  dup awake? not swap is_dark or
;
: do_one
  do_header
  dup thing? if
    "[" over name 20 strcut pop strcat "]" strcat
  else
    dup name
  then
  over player? if
    over is_asleep if
      "[asleep]" strcat
    else
      over idle_time strcat
    then
  then
  23 strcut pop 24 STRleft
  IsPuppet @ if
    over owner name "Owner: " swap strcat strcat .tell
    exit
  then
  over "sex" getpropstr dup not if
    pop over "gender" getpropstr dup not if
      pop "-Unknown-"
    then
  then
  strcat 34 strcut pop 35 STRleft
  ( Ruffin section )
  over "IC?" getpropstr strip dup
  "ic" stringcmp not if pop "IC" else
     dup "ooc" stringcmp not if pop "OOC" else
       pop "" then then
  "    " strcat 4 strcut pop strcat " " strcat
  over get_species dup not if
    pop "-Unknown-"
  then
  strcat
 ( check for zombie, add owner's name at end )
  over thing? if
    over owner dup name " | " swap strcat swap is_asleep if
      "[asleep]" strcat
    then
    dup Tmp ! strlen 79 swap - strcut pop
    Tmp @ strcat
  then
  79 strcut pop .tell
  DoDoDaDoing @ if
    dup DOING getpropstr dup if
      "    Doing: " swap strcat 79 strcut pop .tell
    else
      pop
    then
  then
;
: do_one_nd
  dup is_dark if exit then
  do_one
;
: do_whole_room
  dup is_dark if
    dup PWSDARK getpropstr "yes" strcmp if  (Ruffin)
      "It's too dark in here.  You don't see anyone." wstell exit
    then (Ruffin)
  then
  preempt
  contents begin dup ok? while
    0 IsPuppet !
    dup player? if
      do_one_nd
    else
      dup thing? if
        dup "z" flag? if
          do_one_nd
        else
          dup dup "_puppet" getpropstr .yes? swap "_puppet?" getpropstr .yes? or if
            1 IsPuppet !
            do_one_nd
          then
        then
      then
    then
  next repeat
  pop
;
: setic ( sval snotify sother -- ; set ic/ooc/noic; Ruffin )
  me @ "IC?" getpropstr 4 pick stringcmp not if
    pop swap pop "You are already " swap strcat .tell exit then
  me @ "IC?" 5 rotate setprop
  loc @ 0 me @ name " goes " strcat 5 rotate strcat notify_exclude
  "(Your other choices are " swap strcat ".)" strcat .tell
;
: main
  0 DidHeader !
  "me" match me ! ( Ruffin )
  ( Ruffin - moved this here )
  dup "#help" stringcmp not if
    do_help exit
  then
  ( Ruffin section - brute force, yay! )
  command @
  dup "ic" stringcmp not if
    "IC" "in character (IC)." "'OOC' or 'NOIC'" setic exit
  then
  dup "ooc" stringcmp not if
    "OOC" "out of character (OOC)." "'IC' or 'NOIC'" setic exit
  then
  dup "noic" stringcmp not if
    "" "outside the bounds of OOC/IC." "'IC' or 'OOC'" setic exit
  else pop then
  Me @ SEEDOING getpropstr .yes? DoDoDaDoing !
  Me @ IDLETIME getpropstr atoi dup 60 < if
    pop DEFIDLE
  then
  IdleAfter !
 ( all players, zombies, and puppets in a room )
  dup not if
    Loc @ do_whole_room exit
  then
  dup " " instr dup if
    strcut Tmp ! dup strlen 1 - strcut pop
  else
    pop 0 Tmp !
  then
  dup dup "do:" stringcmp swap "doing:" stringcmp and not if
    Tmp @ if
      Me @ DOING Tmp @ 0 addprop
    else
      Me @ DOING remove_prop
    then
    do_stat exit
  then
  dup "#far" stringcmp not if
    Tmp @ dup if
      .pmatch dup player? if
        dup OBJECTION getpropstr "far" stringcmp not if
          "That players won't allow 'ws #far'." wstell
        else
          do_one
        then
      else
        "I don't see anyone with that name." wstell
      then
      exit
    else
      pop
    then
  then
  dup "#idle" stringcmp not if
    Me @ IDLETIME
    Tmp @ atoi dup 60 > if
      intostr 0 addprop
    else
      pop remove_prop
    then
  do_stat exit
  then
  Tmp @ if
    do_help exit
  then
 ( handle a player name )
  dup 1 strcut pop "#" strcmp if
    dup "*" strcat
    Loc @ contents begin dup ok? while dup player? if
      dup name 3 pick smatch if
        Tmp @ if
          "I don't know which one you mean!" wstell exit
        then
        dup Tmp !
      then
    then
    next repeat
    Tmp @ dup if
      dup is_dark not if
        do_one exit
      then
    then
    pop "I don't see that player here." wstell exit
  then
  dup "#doing" stringcmp not if
    Me @ SEEDOING "yes" 0 addprop
    do_stat
    exit
  then
  dup "#!doing" stringcmp not if
    Me @ SEEDOING remove_prop
    do_stat
    exit
  then
  dup "#object" stringcmp not if
    Me @ OBJECTION "far" 0 addprop
    do_stat exit
  then
  dup "#!object" stringcmp not if
    Me @ OBJECTION remove_prop
    do_stat exit
  then
  dup "#stat" stringcmp not if
    do_stat exit
  then
  Me @ "w" flag? if
    dup 1 strcut swap pop dup number? if
      atoi dbref dup room? if
        "Remote scan of " over name strcat "..." strcat wstell
        do_whole_room
        "Done." wstell
        exit
      else
        "Not a room." wstell
      then
    exit
    else
      pop
    then
  then
  "Type 'ws #help' for help." .tell
;
.
c
q