[Package Index | Mudlib Index | Effect Index]
Code originaly by nimmox@igor. Modified for discworld by Pinkfish.
See also:
/obj/monster.c
Written by Pinkfish
void add_only_respond_to(object person)
void add_respond_to_with(mixed * trigger, mixed response)
If response_mon_regexp is not set, the trigger consists of an array of words to be matched (in order) in the string. If there is an array instead of a single word at one point then any of the words in the array will be matched. If response_mon_regexp is set, the trigger is a single string, representing the regular expression to be matched in the string.
The response is either an array of things to execute (in which case a random one will be chosen each time) or a function pointer or a string. If it is a string then the command of that name will be executed, if the string starts with a '#' then the function named after that will be called on the npc. That was exciting wasn't it?
If the string is a function call (starts with a #) the associated function will be called with two arguments, the speaking object and the message string that triggered the response.
If the string is not a function call then the special string $hname$ will be replaced with the file name of the triggering object. $hcname$ or $short$ will likewise be replaced by the short of the triggering object.
NOTE: The NPC must explicitly know the language being spoken, even
if it's "common". I don't know why. That's just the way it is. See
add_language().
// Simple response
add_respond_to_with(({ "@say", "bing" }), "'Yes! Bing bing bing!");
// respond to someone saying 'frog' or 'toad'
add_respond_to_with(({ "@say", ({ "frog", "toad" }) }),
"'Frogs and toads are nice.");
// Randomly say something or bing back at them
add_respond_to_with(({ "@say", "bing" }),
({ "'Yes! Bing bing bing!", "bing $hname$" }));
// Call the function 'rabbit' on the npc.
add_respond_to_with(({ "@say", "bing" }), "#rabbit");
....
void rabbit( object speaker, string mess ) {}
// Do something cute with a function pointer
add_respond_to_with(({ "@bing" }),
(: do_command("'something wild for " + $1->a_short()) :));
// Triggers can also match entire categories of souls. See the "soulinfo"
// command for which categories are available and which souls they contain:
add_respond_to_with( ({ "%violent", "you" }), "cry" );int check_locality(object respondee)
void clear_respond_to_withs()
void disable_gossip()
varargs void do_gossip_say(string str)
void enable_gossip()
void event_person_sayto(object per, string mess, string lang, object * targets, string accent)
int gossip_enabled()
mixed * query_gossip_says()
object * query_only_respond_to()
mixed * query_respond_to_with()
({
trigger1,
response1,
trigger2,
response2,
...
})
int query_response_allowed(object ob, string * response)
int query_response_mon_debug_mode()
int query_response_mon_ignore_linked_rooms()
int query_response_mon_regexp()
string query_say_log()
int query_stop_responding()
void remove_only_respond_to(object person)
void set_gossip_chance(int i)
void set_respond_to_with(mixed map)
({
trigger1,
response1,
trigger2,
response2,
...
})
void set_response_mon_debug_mode(int flag)
void set_response_mon_ignore_linked_rooms(int i)
void set_response_mon_regexp(int flag)
void set_response_mon_understand_anything(int flag)
void set_say_log(string str)
void set_stop_responding(int i)
mixed * check_sub_sequence(mixed * words)
void exec_response(mixed rep, object per, string mess)
string remove_read_marks(string str)
void senddstr(string str, object per)
class response_data {
object last_ob;
string last_mess;
int stop_responding;
int use_regexp;
int last_count;
int last_time;
int understand_anything;
int ignore_linked_rooms;
object * only_respond_to;
}