@q
@program noises.muf
1 9999 d
i
(
noises.muf, by Verin, June 1993, modified March 1994
This program displays 'noises' in a room.  They are triggered by activity,
so rooms that are empty and unused do not use up any processor or disk
activity.  It tries to an absolute minimum of checking in the beginning,
so high activity rooms will bug out.  All in all, I expect it to be less
resourse consuming than a filter or puppet.
on room:
_listen:$noises  This calls this program upon something happening in a
                 room.
noise/nonetill:  maintained by program, no need to set.  is used to prevent
                 the noises from triggering themselves.
noise/delay:     number of seconds between events.  default is 180.
noise/chance:    chance of an event going off after between is up. if
                 20, there is a 1 in 20 chance of an event.  if 100, a
                 one in a hundred chance.  it must be 1 or greater.
noise/sleep:     number of seconds to sleep after trigger and before display.
                 this makes the events seem to just 'happen'
noise/list:      name of default list of events, as well as a way to specify
                 other lists of noises.  use lsedit to add and edit the lists.
                 'lsedit here = noise/list' for the default noise list, and
                 '@set here = noise/list:xxxxx' to set the list of noises to xxxxx
                 'lsedit here = xxxxx' to edit it the new list of noises.
                 xxxxx is just an example, use whatever you wish.
)
(we are using the list manager to handle the list of events)
$include $lib/lmgr
(variables used)
lvar theroom   (room noise happens in)
lvar thelist   (name of list to get noise from)
lvar thechance (chance for noise to happen)
lvar theevent  (the event to happen)
lvar thedelay
: main
  background
  (get theroom)
  trigger @ theroom !
  (if its not a room exit)
  theroom @ room? not if
    theroom @ owner
    "Please uninstall #81319 from #" theroom @ intostr strcat
    notify
    exit
  then
  (make sure we can do an event here yet)
  theroom @ "noise/nonetill" getpropstr atoi systime >= if exit then
  (see if an noise is going to happen)
  theroom @ "noise/chance" getpropstr atoi thechance !
  thechance @ 1 < if 1 thechance ! then
  random thechance @ % 0 = not if exit then
  (we have an event now)
  (get the delay and sleep)
  theroom @ "noise/delay" getpropstr atoi thedelay !
  thedelay @ 0 <= if 180 thedelay ! then
  theroom @ "noise/sleep" getpropstr atoi thedelay @ + thedelay !
  (find out if there is an alternate list name to display)
  theroom @ "noise/list" getpropstr thelist !
  thelist @ not if "noise/list" thelist ! then
  (find out if we have events to display)
  thelist @ theroom @ .lmgr-getcount theevent !
  theevent @ 0 <= if exit then
  (get a random event)
  random theevent @ % 1 + thelist @ theroom @ .lmgr-getelem theevent !
  (set the timestamp)
  theroom @ "noise/nonetill" systime thedelay @ + intostr 0 addprop
  (sleep)
  theroom @ "noise/sleep" getpropstr atoi sleep
  (send the event)
  theroom @ #-1 theevent @ .notify_nospam
  ;
.
c
q