From the NannyMUD documentation
2001-09-08
monster - A simpler version of the state monster.
/std/simple_monster (read simple_monster further details)
/std/friend (read friend for further details)
/std/sequence (read sequence for more information)
add_response add_attack_chat add_soul set_use_parse_feeling
query_responses
remove_response remove_attack_chat
PROPERTY NAME
listen_to_npc - Makes the monster respond to NPCs.DESCRIPTION
Usually monsters respond only to messages coming from the players. Adding this property will make the monster respond to messages coming from NPCs as well. You can make NPCs interact with eachother this way.PROPERTY NAME
debug_level - Set debug information level.DESCRIPTION
Set this to a integer to see debug information that can be vital when debugging a monster.
FUNCTION
NAME
add_response - Add responses to the monster.SYNTAX
void add_response(string pattern,string response)SYNTAX
void add_response(string pattern,string response, string flag, int random, int shots)SYNTAX
void add_response(string pattern, string response, int random, int shots)DESCRIPTION
With this function you add a response. If thematches, the is executed. Please note that only one (1) is executed at any time. However if a has failed the monster tries to match a new . Therefore, if you have random, the order of the responses affect the chance that they will be carried out. Below is a detailed description of the different arguments: The pattern is a string which is passed to one of the matching routines. What matching routine should be used is determined by the . It defaults to our "normal" matching method. * Normal matching: Normal matching is very simple to learn and has a very nice bonus: it allows the variables to be expanded to what they are in the . There are only 9 variables, named %1 to %9. Example: "%1 smiles %2." If 'Taren smiles happily.' is shown in the same room as the monster, it evaluates %1 to "Taren" and %2 to "happily". You can then use the %1 and %2 in the . * Regexp matching: You use regexp to determine if it was a match or not. regexp is more powerful than the normal method but it doesn't generate the variables that can be substituted in . For further information about regexp see 'man regexp'. * Glob matching: You use glob to determine if it was a match or not. Glob is less powerful than regexp but faster. Doesn't generate the variables that can be substituted in , as Normal matching does. For further information about glob see 'man glob'. For convenience, some common matches have been grouped into 'events'. They have a special syntax. They currently are: ARRIVE( ) - Note: is lowercase. LEAVE( , ) SAY( , ) TELL( , ) GOT( , ) - Note: in this event, both and are the file names (with clone numbers) of the giver and the given object. Some examples using normal matching: ARRIVE(%1,north) - %1 is the name of the living that arrived. LEAVE(%1,%2) - %1 is the name, %2 is the direction. GOT(%1,%2) - %1 is the file name of the object, %2 is the file name of the giver. Note: For this reason, you cannot have a response like this: add_response("ALL","%1 arrives.","!smile %1"); Some examples using regexp matching: SAY(.*,.*) - Matches anyone saying anything. TELL(.*,.*) - Matches anyone telling anything. Some examples using glob matching: SAY(*,*) - Matches anyone saying anything. TELL(TA*,*) - Matches someone called TA* telling anything. The response is a string that is sent to eval. See basic. However the eval function is enhanced with a new calling procedure to allow multiple arguments. Example: "$example(%1,%2)" - this is evaluated to this function call, example(%1,%2). It behaves exactly the same as for normal evals when it comes to expanding what object it is called in. You can of course do, "$example(%1,word %1,%2)" or any such combinations. Note that any string returned from the function or eval is written to everyone in the room. Example: If "The Monster smiles." is a it is written to all in the same room as the monster. You can have a monster do an action with the ! syntax. Like this: "!smile" - The monster smiles, if it has a soul. "!east" - The monsters walks east, if there is an exit like that. Or you can perform some simple manipulation of the %-variable: "%L1" - The lower_case version of %1. "%U1" - The upper_case version of %1. "%C1" - The capitalized version of %1. "%P1" - The result of a present on %L1 in the monsters environment. There are also some special variables. "%P0" - The monster itself. "%0" - Is 0, an integer. "%," - Is a quoted comma. It is useful when you are writing function calls with the $ syntax. A string to determine what type of matching routine should be used on . Valid values for flag is "regexp", "glob" and "normal". Default is "normal", so unless you specifically want to use regexp, you don't need to send this flag. An integer that is used to determine if the should be executed. If random(100) < the is executed. Please note that if the fails the monster tries to match another . Random 0 means that the is always executed. An integer to determine how many times a can be executed before it is removed. If is 0 it is never removed. EXAMPLE
add_response("%1 smiles happily.","!smile %L1"); This will cause the monster to smile if someone smiles in the same room as the monster is in. Note that the %1 is always the exact match of the string. In this case it would be the players name capitalized. To be able to smile towards the monster we need to first convert it to lower_case thus the %L1 in the response.EXAMPLE
add_response("%1 massacred Theo.", "$/std/msg->msg(\bPRON cast\b$ a fireball on \b2PRON.\n,%P0,%P1)"); This makes "Theo casts a fireball on you." be typed to the player doing the massacre on Theo.
FUNCTION
NAME
add_attack_chat - Add an attack chat to the monster.SYNTAX
add_attack_chat(string msg,int chance)SYNTAX
add_attack_chat(string msg,int chance, int shots)DESCRIPTION
The attack chat is a chat the monster performs during combat.is used to determine if the should be selected If random(100) < the chat is selected. That chat is sent to eval and if the result of the eval is a string it is said to environment of the monster.
FUNCTION
NAME
add_soul - Add a soul to the monster.SYNTAX
void add_soul()DESCRIPTION
Add a soul to the monster thus enabling it to use feelings. The soul added is a normal one, just like the one given to the players.
FUNCTION
NAME
set_use_parse_feeling - Tell the monster if it should use parse_feeling.SYNTAX
void set_use_parse_feeling(int i)DESCRIPTION
If you want feelings transformed to the syntax described below you should set this to 1, it is 0 by default. "( ( , , ,..., , , ,..., ))" EXAMPLE
Taren smiles. -> "SMILE(taren,NONE)"EXAMPLE
Taren smiles happily at Theo. -> "SMILE(taren,theo)"EXAMPLE
Taren smiles smiles angrily, zoologically and theatrically at Theo. -> "SMILE(taren,theo,angrily,zoologically,theatrically)"EXAMPLE
Taren stomps on Theo's foot. -> "STOMP(taren,theo,on the foot)"EXAMPLE
Taren stomps on Theo's foot angrily. -> "STOMP(taren,theo,angrily,on the foot)"EXAMPLE
Suddenly, Taren stomps on Theo's foot angrily. -> "SUDDENLY(STOMP(taren,theo,angrily,on the foot))"
FUNCTION
NAME
remove_response - Remove a response.SYNTAX
void remove_response(string pattern)DESCRIPTION
If there is a response that match, it is removed.
FUNCTION
NAME
remove_attack_chat - Remove an attack chat.SYNTAX
int remove_attack_chat(string msg,int chance)SYNTAX
int remove_attack_chat(string msg,int chance,int shots)DESCRIPTION
If there is an attack_chat that matches it is removed.
FUNCTION
NAME
query_responses - Ask the monster what responses it has.SYNTAX
mapping query_responses()DESCRIPTION
This function is mainly used for debugging purposes. It returns a mapping with the entire response structure.