CATCHING TELLS.

There is a LFUN for monsters called 'catch_tell' which will be called with
everything that will come on the 'screen' of the monster. So if someone kisses
one of the monsters you have made, catch_tell will receive the message:
Cashimor kisses you.
This can be used for a lot of purposes, some of them described here.

The function:

The function should be defined in every monster you want to have catching
tells. The function itself isn't complicated, programming what the monster
should do depending on the data coming in is. It is a lot easier to catch the
command 'kiss' with add_action instead of using catch_tell, but add_actions
aren't as beautiful (if there are other monsters using the add_action
construction, only one of them will work properly, and if extensions to souls
come up (like the extended soul) the output could be confusing). Ok, this is
how to define the function:

int bush_catching;          /* This should be  a global variable */

catch_tell(str) {
  if(busy_catching) return; /* This construction is needed because this */
  busy_catching=1;          /* function could be called while it is still */
                            /* executing. */
  <Here comes the programme you want to execute if catch_tell is invoked>

  busy_catching=0;
}

Using it as a spy:

Catch_tell can be used as a spy: a monster could be made invisible by doing
set_short(0), and the catch_tell in the monster could to a tell_object to
someone, or call a function in another room that will tell to everyone in that
room what is happening in the room the monster is in. Example:

This replaces the part between < & > in the previous example:

"players/cashimor/hall"->let_them_know(str);

And this routine should be in the room that the messages should go to (in this
case that is players/cashimor/hall):

let_them_know(str) {
  tell_room(this_object(),"Through the glass you can see that:\n"+str+"\n");
}

Easier use of catch_tell:

In monster.c some functions are defined to make life easier. To use these,
define the global variables:

string function,type,match;

And give these values. The function array should contain the functions that
should be called under certain circumstances defined by type and match (though
I do not know exactly how match works, I usually define it being ""). If a
function needs two types (for example: 'say' and 'tell'), then leave the
functionname for the second type open. The type is the text that will be looked
up in the 'str' received by the catch_tell. The values should be given in
reset(0). Example:

function=({"handle_say",0,"handle_arrival","handle_leaving","handle_giving",
           "check_fighting",0,0,0});
type=({"says:","tells you:","arrives","leaves","gives","hit","miss","smash",
       "massacre"});
match={(""," ","","","","","","",""});

This will call handle_say if the monster catches a sentence containing 'says:'
or 'tells you:', handle_arrival if it contained 'arrives', handle_leaving if
it contains 'leaves', handle_giving if it contained 'gives', and
check_fighting if it contained 'hit','miss','smash' or 'massacre'.

These functions will be called with a parameter str, which is the string from
the catch_tell. This is a better way of using the catch_tell.

Uses of these new monstercalls:

Monsters that follow players. This is not encouraged, but it is very useful to
explain the basic principles mentioned above. To make a monster that follows
players do:

string function,type,match;

function=({"handle_leaving"});
type=({"leaves"});
match=({""});

handle_leaving(str) {
string who,where;

  if(sscanf(str,"%s leaves %s.",who,where)!=2) return;
  init_command(where);
}

Example of input: someone uses the command north to go north near the monster
with this catch_tell construction:

catch_tell("Cashimor leaves north.") is invoked.
handle_leaving("Cashimor leaves north.") is invoked.
sscanf: "%s("Cashimor"=who) leaves %s("north"=where)."
init_command("north") is invoked.
Monster leaves north.

I hope this explains a lot. Of course, with this construction a lot of things
can be done to make the mud very interesting, by increasing the monster <->
player interaction.

Any BUGS (which will certainly be in here) can be mailed to Ethereal Cashimor.
I hope you enjoy these texts.

