;;su = $string_utils; 
for vrb in (verbs(#162)) 
  player:tell(su:nn(#162), " ", vrb, " ",
  toliteral(verb_info(#162, vrb))); 
  cdlist = verb_code(#162, vrb, 1, 1); 
  for ln in (cdlist) 
    player:tell(ln); 
  endfor 
  player:tell("-----------------------"); 
endfor
Fire Inspector (#162) start {#181055, "rxd", "start"}
"";
" start ";
" Sends fire inspector to inspect stores.";
"";
insp = this;
player:tell("Fire Inspector Started.");
"Bail out if updates are running.";
if ($g.batch != 0)
  player:tell("Fire Inspector can't run now.");
  return;
endif
insp:initialize();
"";
" Select store for inspection.";
$g:inform_admin("Fire inspector reviews the ",
length(connected_players()), " currently connected players");
for playr in (connected_players())
  if (valid(playr:store()))
    if (playr.store:open_p())
      $g:inform_admin("Fire inspector considers inspecting ",
      $string_utils:nn(playr));
      if (insp:insp_due(playr.store) == 1)
        insp:inspect(playr.store);
      else
        $g:inform_admin("    But a fire inspection is not due");
      endif
    else
      $g:inform_admin("Fire inspector finds ",
      $string_utils:nn(playr), " is not open");
    endif
  else
    $g:inform_admin("Fire inspector finds ",
    $string_utils:nn(playr), " does not have a valid store");
  endif
endfor
"";
"All inspections complete.";
suspend(insp.idle);
move(insp, insp.home);
player:tell("Fire Inspector quits for now and goes back to ",
$string_utils:nn(insp.home));
-----------------------
Fire Inspector (#162) initialize {#181055, "rxd", "initialize"}
"";
" Initialize";
"";
insp = this;
"";
"Update inspection log to remove expired inspections";
for entry in (insp.logbook)
  if ($g.turn > (entry[2] + insp.insp_interval))
    insp.logbook = setremove(insp.logbook, entry);
  endif
endfor
"";
"Initialize properties that change during play.";
insp.inspect_stat = 0;
insp.busy = 1;
move(insp, insp.home);
player:tell("Fire Inspector Initialized");
-----------------------
Fire Inspector (#162) inspect {#181055, "rxd", "inspect"}
"";
" Inspect";
" Inspects a store";
"";
insp = this;
shop = args[1];
"";
"Go to the store's street.";
insp:setpos(200, 80, 3);
move(insp, st = shop:street());
suspend(insp.idle);
"Find the door and go in.";
for exit in (st.exits)
  if (exit.dest == shop)
    exit:move(insp);
  endif
endfor
"";
player:tell("Fire Inspector Enters ", shop.name);
suspend(2);
insp:say("I'm conducting a fire inspection.");
suspend(insp.idle);
insp:setpos(100, 65, 1);
insp:say("I'll just check your stock.");
suspend(insp.idle);
"";
"Check for too many crates - fire hazard.";
boxes = insp:count_crates(shop);
if (boxes > insp.crate_limit)
  $interface_messages:speak(insp, "You have ", boxes, " crates
  here.  This is a fire hazard.");
  insp.inspect_stat = 1;
else
  insp:say("Looks clean, no problems.");
endif
suspend(insp.idle);
"";
"All done, leave.";
insp:setpos(200, 65, 2);
insp:say("I'm all finished, any questions?");
insp.busy = 0;
insp:wait();
insp:setpos(396, 62, 2);
insp:say("Have a nice day.");
suspend(1);
exit = insp.location:match_exit("Street");
if (valid(exit))
  exit:move(insp);
endif
insp.busy = 1;
insp.inspect_stat = 0;
insp:setpos(200, 80, 3);
suspend(insp.idle);
move(insp, insp.home);
-----------------------
Fire Inspector (#162) count_crates {#181055, "rxd",
"count_crates"}
"";
"count_crates";
" Returns number of crates in store.";
"";
shop = args[1];
count = 0;
for object in (shop.contents)
  if (object.object_prefix == "#CRATE")
    count = count + 1;
  endif
  " Don't let the loop go too long.";
  if (count > 200)
    return200;
  endif
endfor
return count;
-----------------------
Fire Inspector (#162) respond {#181055, "rxd", "respond"}
"";
" respond ";
" Responds to player response choices.";
"";
who = args[2];
text = args[3];
insp = this;
"";
"Don't allow conversation during inspection.";
if (insp.busy)
  $interface_messages:speak(insp, "Not now, please");
  return;
endif
"";
" Reset wait time.";
insp.wait_timer = insp.wait_time;
"";
if (insp.responses[1] in text)
  insp:reply(1);
endif
if (insp.responses[2] in text)
  if (insp.inspect_stat)
    insp:reply(2);
  else
    insp:reply(3);
  endif
endif
if (insp.responses[3] in text)
  if (insp.inspect_stat)
    insp:reply(4);
  else
    insp:reply(5);
  endif
endif
"";
"Allow player to dismiss the inspector.";
if (insp.responses[4] in text)
  insp.wait_timer = 0;
endif
-----------------------
Fire Inspector (#162) wait {#181055, "rxd", "wait"}
"";
"wait";
"Pause to wait for each response.";
"";
insp = this;
"";
"Set timer and decrement at 5 second intervals.";
insp.wait_timer = insp.wait_time;
while (insp.wait_timer > 0)
  suspend(5);
  insp.wait_timer = insp.wait_timer - 5;
endwhile
-----------------------
Fire Inspector (#162) reply {#181055, "rxd", "reply"}
"";
" reply ";
" Reply to responses.";
"";
insp = this;
rep_num = args[1];
$interface_messages:speak(insp, insp.replies[rep_num]);
-----------------------
Fire Inspector (#162) insp_due {#181055, "rxd", "insp_due"}
"";
"insp_due";
"Checks logbook for recent inspection.";
"";
shop = args[1];
insp = this;
"";
"Return false if recent inspection found.";
for entry in (insp.logbook)
  if (entry[1] == shop)
    return 0;
  endif
endfor
"";
"Store not current. Update log and return true.";
insp.logbook = setadd(insp.logbook, {shop, $g.turn});
return 1;
-----------------------
@show #162
Object ID:  #162
Name:       Fire Inspector
Parent:     Atmosphere Agent (#965)
Location:   Fire House (#969)
Owner:      peravali (#181055)
Flags:     
Verb definitions:
    start
    initialize
    inspect
    count_crates
    respond
    wait
    reply
    insp_due
Property definitions:
    inspect_list
    inspect_stat
    wait_time
    wait_timer
    busy
    replies
    crate_limit
    logbook
    insp_interval
Properties:
    key: 0
    aliases: {"Fire Inspector", "firebug"}
    description: "A manic and slightly paranoid fire inspector."
    birth: 854986069
    object_prefix: "#PLAYER"
    pict: "Fire Inspector"
    actions: {{1000, "nothing"}, {10, "speak"}, {10, "feel"},
    {10, "walk"}, {10, "grab"}, {10, "dropsy"}, {10, "handout"}}
    phrases: {{10, "Hello"}, "My owner has not taught me much."}
    idle: 5
    awake: 1
    last_location: 0
    wanted: {}
    rooms_visited: {}
    responses: {"How are you doing?", "How did the inspection
    go?", "Is the store safe?", "Thank you, goodbye."}
    resp_curr_siblings: 1
    resp_curr: {}
    resp_list: {}
    npc_respond_args: {}
    gone_wandering: {#166, #217, #223, #163, #165, #199, #190,
    #189, #400, #188, #221, #160, #164, #162, #159}
    max_agents_allowed_out: 16
    master_switch: 1
    agents_waiting: {}
    turn_start_time: 917217968
    time_dispatched: 917218750
    agent_stop_list: {#963}
    debug: 1
    locked_stores: 0
    inspect_list: {#172108}
    inspect_stat: 0
    wait_time: 30
    wait_timer: 0
    busy: 1
    replies: {"Fine, fine ... just fine.", "There are some
    problems.", "Good.  Everything's fine.", "This place is a
    firetrap!", "Yes, it's OK."}
    crate_limit: 15
    logbook: {{#1453, 3405}, {#183278, 3427}, {#3869, 3427}}
    insp_interval: 30