Monsters ~~~~~~~~ Monsters should be constructed with MONSTERER (std/monsterer): please "man monsterer" for usage. Once the monster has been constructed, you can use the following routines for extra customization. Bear in mind, however, that much of the below was written before we had a MONSTERER. You will never need to call most of these functions if you use the MONSTERER. For player-controlled monsters, see doc/build/npc! Functions: set_name(string n) Sets the name and short description to n. Sets long description to "You see nothing special.\n" set_level(int l) The monster gets the level l. Hit points and ep is set as the same as player of level l. Armor class to 0 and weapon class to that of hands. set_hp(int hp) Sets hit points to hp. set_race(r) string r. Adds an alternate generic name for the monster. set_short(string sh) Short description is set to sh. Long to short + "\n" if not already set. set_long(string long) Long description is set to long. set_wc(int wc) Sets the weapon class, how much the damage it will do, to wc. The damage inflicted is in the range 0..wc-1. Wielding a weapon overrides this innate wc. set_ac(int ac) Armor class is set to ac. Wearing armor overrides this innate ac. set_aggressive(int a) 0 means peaceful until attacked. 1 means attack everyone it sees. set_move_at_reset() If this routine is called the monster will do a random move at every reset. set_can_wander(int a) 1 by default. If you want your monster to guard stuff and not move, set this to 0. NOTE: THIS LEAVES THE MONSTER VERY VULNERABLE TO DISTANCE ATTACKS!! You should equip the monster with some form of unlimited-ammo distance attack. Note: wandering monsters pick up objects, too. set_wimpy() When monster gets low on hp it will flee. set_can_kill(int arg) If this is set to 1, the monster can attack other monsters. Otherwise it can only attack players. (Note that it can still attack other monsters if they attack him first.) regen_sp(int n) Set the monster to automatically regenerate n spell points every 30 seconds. init_command(string cmd) Force the monster to do a command. The force_us() function isn't always good, because it checks the level of the caller, and this function can be called by a room. set_dead_ob(object ob) The function 'monster_died' in 'ob' will be called just before the monster dies. The argument to 'monster_died' will be the nearly dead monster object. The return value from 'monster_died' determins the fate of the monster. A 1 means that the monster will survive, a 0 that it will die. set_init_ob(object ob) The function 'monster_init' in 'ob' will be called from init in the monster. The argument to 'monster_init' will be the the monster object. The return value from 'monster_init' determins if the monster will attack, if it's aggressive. A 1 means that the monster will not attack, a 0 that it will function as usual. set_desc_ob(object ob) If this is set, then the functions 'monster_id', 'monster_short', and 'monster_long' will be called in ob instead of using the standard functions. This allows monsters to have dynamic descriptions based on the current situation. Spell Functions: Spell functions are no longer used, having be replaced by add_attack (below). However, for history, they were: * set_spell_mess1(string m) This is the message that the other players in the room get when the monster casts a spell. * set_spell_mess2(string m) This is the message that the victim of the monster's spell gets. * set_chance(int c) This is the percent chance of casting a spell. * set_spell_dam(int d) How much damage the spell will do if it hits. The damage will be randomly 0 .. d-1. add_attack(cmd, msg, dam, dtype, chance, spcost) string cmd - the command that must be typed by the monster to call the spell (e.g. "fry" or "breathe fire"). string msg - the message broadcast when the monster uses this attack. Use $m for the monster name and $v for the victim (e.g. "$m breathes fire on $v!"). int dam - the maximum damage done (hp/2), e.g. 10. string dtype - the type of damage done (e.g. "magic") int chance - the % chance the monster will use this attack each combat round. Chance decreases if the monster is low on spell pts. int spcost - the spellpoint cost to the monster of using this attack. Note: You may wish to have the monster automatically regen spell points, with regen_sp(n). (e.g. 10). e.g. add_attack("bite","$m chomps $v!",10,"puncture",40,0); These are the chat functions: The chat options enables the monster to say something every heart beat. set_chat_chance(int c) Set the percent chance of saying something. load_chat(string/array str [,int chance]) Load a chat string or an array of chats. Can be called several times. The monster will then pick one of them to say. the optional arg chance is the chat_chance percentage. remove_chat(string str) Remove a chat string. Same as above, but used when to monster is under attack: set_a_chat_chance(c) load_a_chat(str) remove_a_chat(str) Here are the catch talk functions. Catch talk gives the the monster the possibility to act upon what it hears and sees. All messages streams that are sent to the monster are compared to a set of loadable strings. If a match occurs a function in a given object is called with the matching string as an argument. You can have one function per sentence or multiple senetence per function. set_object(object ob) Tells which object 'ob' that holds the functions. This object becomes the default object. set_function(string func) This is the function name that shall be called when a match occur. set_type(string type) This is the second word of sentence to match. If you want do catch the sentence 'Humhum gives flower to lady,' you should set type to 'gives'. set_match(string match) This is rest of the string to match. If you want do catch the sentence 'Humhum gives flower to lady,' you should set match to 'flower to lady'. remove_match(string match) Remove the match from catch talk. DANGER, DANGER WILL ROBINSON! THIS EXAMPLE IS OUT OF DATE! The monsterer should be used instead of all the lines up to the comment. EXAMPLE > dam = clone_object("obj/monster"); > call_other(dam, "set_name", "mary"); > call_other(dam, "set_alias", "lady"); > call_other(dam, "set_short", "An old lady is here"); > call_other(dam, "set_ac", 0); > call_other(dam, "set_level",5); > call_other(dam, "set_al",200); > call_other(dam, "set_hp",30); > call_other(dam, "set_wc",7); > call_other(dam, "set_aggressive", 0); >^--- Outdated section -----^ /* * This cathes 'name gives flower to Lady.' and * 'name gives flower to Ann.' and binds it to * the function 'gives' in the current object. */ call_other(dam, "set_object", this_object()); call_other(dam, "set_function", "give"); call_other(dam, "set_type", "gives"); call_other(dam, "set_match", "flower to Lady."); call_other(dam, "set_match", "flower to Ann."); /* * This cathes 'name say: daisy' and binds it to * the function 'tala' in the current object. */ call_other(dam, "set_function", "tala"); call_other(dam, "set_type", "says:"); call_other(dam, "set_match", "daisy"); . . give(str) { object giver; if(dam && living(dam)) { string who, rest; sscanf(str, "%s %s\n", who, rest); giver = present(lower_case(who),environment(this_player())); alig = call_other(giver,"query_alignment"); if(alig > 0 ) { say("Ann says: Oh thank you " + who + ".\n"); say("Ann says: You look like a fine young man.\n"); } else { say("Ann says: Oh thank you " + who + ".\n"); } } } tala(str) { if(dam && living(dam)) { string who, rest; sscanf(str, "%s %s\n", who, rest); say("Ann says: Sheeit " + who + ", ah' really likes daisys.\n"); } } NPC functions: query_NPC() Return 0 if the monster is under player control, else 1. query_owner() If under player control, return an array in the format: ({ "playername1", loyalty, "playername2", loyalty ... }) where the owner's name is a lowercase string and loyalty is an integer between 1 (almost no loyalty) and 100 (total loyalty). Note that there can be multiple owners. See also: doc/build/npc, doc/std/monsterer.