[ Package Index | Mudlib Index | Effect Index ]

File /obj/monster.c

This file contains all the information relevant to creating an npc (or monster).

Written by Pinkfish


Inherits

This class inherits the following classes /global/guild-race.c, /global/events.c, /std/living/mon_actions.c, /std/living/response_mon.c and /std/living/living.c

Includes

This class includes the following files /include/route.h, /include/playtesters.h, /include/skills.h, /include/move_failures.h, /include/top_ten_tables.h, /include/map.h, /include/combat.h, /include/player.h, /include/wander.h, /include/monster.h, /include/living.h and /include/config.h

Method index

 o add_achat_string(mixed, mixed)
This method adds a single chat string into the current list of attack message chat strings.
 o add_chat_string(mixed, mixed)
This method adds a single chat string into the current list of chat strings.
 o add_combat_action(int, string, mixed)
This method adds a combat action to the npc.
 o add_enter_commands(mixed)
This method adds a command to be called whenever the npc enters a room.
 o add_language(string)
This method adds a language to the npc.
 o add_move_zone(mixed)
This method adds a move zone onto the npc.
 o add_spell_action(string, int, string, mixed)
This method adds an action to the npc that will happen if a specified spell is cast.
 o attack_permission(object, object, string)
attack_permission function, added for use by the allow_attack simul.
 o basic_setup(string, string, int)
This method sets up the basic abilities and race of the critter.
 o check_anyone_here()
This method checks to see if there are any players in the environment of the npc.
 o cleaning_room()
 o combat_actions_call_back(object, object)
This is the call back from the combat effect to do something wonderful and wild.
 o command_override(function)
Use this function to set a function that is called with the NPCs input before command() gets it, return 1 from the function if the input needs no further parsing (ie the command is handled)
 o delay_command(string, int)
This method allows you to control the npc and get it to do actions where they are queued as for players.
 o delete_queued_commands()
This method throws away any queued commands.
 o do_combat_action(object, object, mixed)
This method does a combat action.
 o do_command(string)
This method allows you to control the npc and get it to do actions.
 o do_follow_move(string)
This method is used to make the npcs follow after attackers when they leave the room.
 o do_move(string)
This method causes the npc to move in the given direction.
 o do_move_after(int)
This is called when the npc decides it must continue down a certain route.
 o do_route_move()
This method moves the npc one more location along the route it is following.
 o do_spell_action(object, object *, mixed, mixed)
This method does a combat action.
 o drunk_check(string)
 o event_fight_in_progress(object, object)
This event is called when a fight is in progress.
 o event_npc_ritual_casting(object, object, object *, class spell_argument)
This is the event called when a ritual is being cast.
 o event_npc_spell_casting(object, object, object *, class spell_argument)
This is the event called when a spell is being cast.
 o expand_mon_string(mixed)
This method executes the string passed in.
 o expand_string(string, object)
This method is used to expand the message strings used in the npc messages.
 o get_next_route_direction()
This method gets the next direction to go in the route which is currently being followed.
 o give_money(int, int, string)
This method is used to give some startup money to the npc.
 o got_the_route(string *, int, string)
This method is called by the move_me_to function after the route handler has successfuly discovered the route to follow.
 o init_command(string, int)
This method allows you submit delayed commands to the npc via a call_out.
 o init_dynamic_arg(mapping, object)
 o init_equip()
This method makes the npc initialise all their equipment, like hold it and stuff.
 o init_static_arg(mapping)
 o load_a_chat(int, mixed *)
This method loads up the set of chat strings to use while in combat.
 o load_chat(int, mixed *)
This method loads up the chat strings for the npc.
 o move_me_to(string, int)
This method will move the npc to the specified destination.
 o query_achat_chance()
This method returns the current chat chance for attack messages on the npc.
 o query_achat_string()
This method queries the current chat string for attack messages on the npc.
 o query_aggressive()
This method returns the current aggressive level of the npc.
 o query_always_return_to_default_position()
This method returns the status of the flag that makes the npc return to the default position if its position is changed.
 o query_cannot_change_position()
This method returns the current value of the unable to change position flag.
 o query_cap_name()
This method returns the current capitalized name of the npc.
 o query_chat_chance()
This method returns the current chat chance for messages on the npc
 o query_chat_string()
This method queries the current chat string for messages on the npc.
 o query_combat_actions()
This method returns the current array of combat actions on the npc.
 o query_death_xp()
This method returns the amount of death experiecne that would be gained by killing the npc.
 o query_dynamic_auto_load()
 o query_enter_commands()
This method returns the current array of enter commands.
 o query_fight_type()
This method returns the flag which allows the npc to join into fights.
 o query_follow_speed()
This method queries the speed at which the npc will follow after a player when they leave combat.
 o query_following_route()
This method returns the current array of directions we are following as a route.
 o query_guild()
This method returns the current guild of the npc.
 o query_guild_ob()
This returns the guild object associated with the npc.
 o query_join_fights()
This method returns the message to use when joining into fights.
 o query_last_route_direction()
This method tells us if the npc is currently following a route.
 o query_level()
This method returns the current guild level of the npc.
 o query_move_after()
This method returns the current move after values.
 o query_move_zones()
This method returns the current list of move zones on the npc
 o query_ok_turn_off_heart_beat()
This method returns 1 if it is ok to turn of the npc's heart beat.
 o query_queued_commands()
This method returns the queued command list.
 o query_race()
This method returns the current race of the npc.
 o query_race_ob()
This returns the race object associated with the npc.
 o query_spell_actions()
This method returns the list of spell actions present on the npc.
 o query_throw_out()
This method returns the current throw out array.
 o query_true_location()
This method returns the true location of the npc.
 o query_virtual_move()
 o queue_command(string, int)
This method allows you to control the npc and get it to do actions where they are queued as for players.
 o rand_num(int, int)
This method generates a random number.
 o real_room(string)
This method moves the npc to room it is really supposed to be in.
 o remove_achat_string(mixed)
This method attempts to remove the given chat string from the current list of attack message chat strings.
 o remove_chat_string(mixed)
This method attempts to remove the given chat string from the current list of chat strings.
 o remove_combat_action(string)
This method will remove the combat action with the specified name.
 o remove_move_zone(mixed)
This method removes a move zone from the npc.
 o remove_spell_action(string)
This method removes the specified spell action.
 o reset_enter_commands()
This method resets the array of enter commands back to nothing.
 o run_away()
This method is used to make the npc run away.
 o set_achat_chance(int)
This method sets the current chat chance for attack messages on the npc.
 o set_achat_string(string *)
This method sets the current chat string for attack messages on the npc.
 o set_aggressive(int)
This method sets the current aggressive level of the npc.
 o set_always_return_to_default_position(int)
This method sets the status of the flag that makes the npc return to the default position if its position is changed.
 o set_cannot_change_position(int)
This method sets the value of the unable to change position flag.
 o set_cap_name(string)
This method set the current capitalized name of the npc.
 o set_chat_chance(int)
This method sets the current chat chance for messages on the npc.
 o set_chat_string(string *)
This method sets the current chat string for messages on the npc.
 o set_follow_speed(int)
This method sets the speed at which the npc will follow after a player when they leave combat.
 o set_guild(string)
This method is deprecated.
 o set_guild_ob(mixed)
This method sets the guild object associated with the npc.
 o set_join_fight_type(int)
This method sets the flag which allows the npc to join into fights.
 o set_join_fights(string)
This method sets the message to use when joining into fights.
 o set_level(int)
This function is deprecated.
 o set_move_after(int, int)
This method sets the speed at which the npc will randomly wander around.
 o set_race(string)
This function is deprecated.
 o set_race_ob(mixed)
This method sets the race object associated with the npc.
 o set_random_stats(int, int)
This method sets the stats for the npc to some exciting random values.
 o set_throw_out(int, int, string, string)
This method is used to determine when to throw people out of a room.
 o set_true_location(string)
This method sets the true location of the npc.
 o set_virtual_move(int)
This method sets the current virual move ability of the npc.
 o setup_nationality(string, string)
This method sets up a nationality and sets up a region in the nationality for the npc.
 o start_attack(object)
This method check to see if the npc should start attacking someone when they enter the npcs environment.

Public Functions

These are functions that everyone can access.

.
 * add_achat_string
void add_achat_string(mixed weight,
                      mixed chat)
This method adds a single chat string into the current list of attack message chat strings. See load_chat() for a longer description of the chat string.

Parameters:
weight - the weight of the chat
chat - the new chat string
See also:
load_chat(), load_achat() and remove_achat_string()
 * add_chat_string
void add_chat_string(mixed weight,
                     mixed chat)
This method adds a single chat string into the current list of chat strings. See load_chat() for a longer description of the chat string.

Parameters:
weight - the weight of the chat
chat - the new chat string
See also:
load_chat() and remove_chat_string()
 * add_combat_action
void add_combat_action(int chance,
                       string name,
                       mixed action)
This method adds a combat action to the npc. This is an action which has a chance of occuring during combat. The name is an identifier which can be used to remove the action with later. The action itself can be a string, then that command will be executed. If the action is a function pointer then it will be evaluated with two arguments, the first being the attacker, the second being the target.

If the action is an array, if it is one element then the function specified will be called on the attacked with the same arguements as above. If the size of the array is two then the function will be called on the specified object with the arguments as above.

See also:
remove_combat_action(), query_combat_actions() and /std/effects/fighting/combat.c
 * add_enter_commands
int add_enter_commands(mixed str)
This method adds a command to be called whenever the npc enters a room. If the command is a string, then it will be executed as if they had typed it. If it is a function then the function will be evaluated and one argument (the npc itself) will be passed in.

Parameters:
str - the enter commands to add
See also:
reset_enter_commands() and query_enter_commands()
 * add_language
void add_language(string str)
This method adds a language to the npc.

After the sun has died away
The stars come out and glow
Lighting the embers of good intentions
Ghostly white, unhappily bright
Time lost, the day done

Parameters:
str - the language to add
 * add_move_zone
void add_move_zone(mixed zone)
This method adds a move zone onto the npc. The move zones control which areas the npcs will wander into, a move zone is set on the room and the npcs will only enter rooms which have a matching move zone. If there is no move zone, then the npc will enter any room.

If the parameter is an array each of the elements of the array will be added as a move zone.

Parameters:
zone - the zone(s) to add
See also:
remove_move_zone(), query_move_zones() and set_move_after()
 * add_spell_action
void add_spell_action(string spell_object,
                      int chance,
                      string name,
                      mixed action)
This method adds an action to the npc that will happen if a specified spell is cast. This is an action which has a chance of occuring when a spell is being cast. The name is an identifier which can be used to remove the action with later. The action itself can be a string, then that command will be executed. If the action is a function pointer then it will be evaluated with two arguments, the first being the caster, the second being the target(s) array and the third being the magic arguments class.

If the action is an array, if it is one element then the function specified will be called on the attacked with the same arguements as above. If the size of the array is two then the function will be called on the specified object with an extra first argument being the npc which the effect is being called from.

Parameters:
spell_object - the spell to respond to
chance - the chance of it working
name - the name of the thing
action - the action to preform
 * attack_permission
int attack_permission(object ob1,
                      object ob2,
                      string stringy)
attack_permission function, added for use by the allow_attack simul.

Parameters:
object - The person performing the action
object - The object being acted on, this object usually.
string - Attack type, this will be one of "combat", "theft", or "magic", this lets you give your NPCs different responses for different attacks. As well as make them immune to theft and magic (as an example)
Returns:
int 1 if the action is denied, 0 is it can go through.
See also:
efun::allow_attack()
 * basic_setup
void basic_setup(string race,
                 string guild,
                 int level)
This method sets up the basic abilities and race of the critter. It is equivalent to calling set_race(), set_guild(), and then set_level() with the same parameters. But those latter three functions are deprecated and shouldn't be used.

Parameters:
race - this is the race of the character. It should be a race that's understood by the /std/race.c
guild - this is the guild, class, or profession of the NPC.
level - this is the base skill level of the NPC. The number is used by the race object to set ability scores, and base skills.
See also:
set_race(), set_guild() and set_level()
 * check_anyone_here
int check_anyone_here()
This method checks to see if there are any players in the environment of the npc. This should be used to determine when chats should be turned off and other things which should only work in the presence of players.

Returns:
1 if there is a player in the room, 0 otherwise
 * cleaning_room
int cleaning_room()
 * combat_actions_call_back
void combat_actions_call_back(object player,
                              object target)
This is the call back from the combat effect to do something wonderful and wild.

Parameters:
player - the player
target - the target
 * command_override
void command_override(function func)
Use this function to set a function that is called with the NPCs input before command() gets it, return 1 from the function if the input needs no further parsing (ie the command is handled)

Parameters:
func - = function in the players environment to call.
 * delay_command
int delay_command(string words,
                  int interval)
This method allows you to control the npc and get it to do actions where they are queued as for players. The command is always delayed by delay even if there are no commands pending unlike queue_command(). This function is 100% compatible with queue_command() and init_command().

Parameters:
words - the action to perform
interval - to wait before the command.
See also:
queue_command(), query_queued_commands(), init_command() and do_command()
Example:
ob = clone_object(NICE_HAIRY_APE);
ob->delay_command("'I am a hairy ape!",10);
ob->delay_command("emote apes around the room.",2);
ob->queue_command("emote get banana.",3);
ob->queue_command("emote get apple.");
After 10 seconds it says "I am a hariy ape",
2 seconds after that it apes around the room,
immediately following that it gets a banana
and 3 seconds after that it gets an apple.
 * delete_queued_commands
void delete_queued_commands()
This method throws away any queued commands. It doesn't remove the call_out however if no new commands are added there will be no effect.

See also:
init_equip(), init_command(), delay_command(), do_command() and queue_command()
 * do_combat_action
void do_combat_action(object player,
                      object target,
                      mixed action)
This method does a combat action.

Parameters:
target - the target of the action
 * do_command
int do_command(string words)
This method allows you to control the npc and get it to do actions. This can be used for npc control and inteligence. Be very careful with this command! This does not go through any command queue like players have and so NPCs can end up doing tons of commands in very short order. If you're trying to make your NPC act like a player use eue_command() instead

Parameters:
words - the action to preform
See also:
init_equip() and init_command()
Example:
ob = clone_object(NICE_HAIRY_APE);
ob->do_command("'I am a hairy ape!");
ob->do_command("emote apes around the room.");
 * do_follow_move
void do_follow_move(string dir)
This method is used to make the npcs follow after attackers when they leave the room.

Parameters:
dir - the dirction to follow them in
 * do_move
void do_move(string move)
This method causes the npc to move in the given direction.

Parameters:
move - the direction to move
 * do_move_after
void do_move_after(int running_away)
This is called when the npc decides it must continue down a certain route. This will be called by the wander handler and can be used to force the npc to wander along a route faster.

Parameters:
running_away - this is 1 if the npc is running away
See also:
set_move_after()
 * do_route_move
void do_route_move()
This method moves the npc one more location along the route it is following.

See also:
query_last_route_direction(), query_following_route() and get_next_route_direction()
 * do_spell_action
void do_spell_action(object caster,
                     object * targets,
                     mixed action,
                     mixed args)
This method does a combat action.

Parameters:
caster - the caster of the spell
targets - the targets of the spell
action - the action to do
args - the spell arguements
 * drunk_check
int drunk_check(string str)
 * event_fight_in_progress
void event_fight_in_progress(object me,
                             object him)
This event is called when a fight is in progress. It will be used for things like joining into currently running fights and initiating combat with spell casters.

Parameters:
me - the person initiating the attack
him - the person being attacked
 * event_npc_ritual_casting
void event_npc_ritual_casting(object ritual,
                              object caster,
                              object * targets,
                              class spell_argument args)
This is the event called when a ritual is being cast.

Parameters:
spell_ob - the ritual
caster - the caster of the ritual
targets - the targets of the ritual
args - the ritual arguements
 * event_npc_spell_casting
void event_npc_spell_casting(object spell,
                             object caster,
                             object * targets,
                             class spell_argument args)
This is the event called when a spell is being cast.

Parameters:
spell_ob - the spell object
caster - the caster of the spell
targets - the targets of the spell
args - the spell arguements
 * expand_mon_string
void expand_mon_string(mixed str)
This method executes the string passed in. It handles all the stuff which is needed from the chat_string stuff. If the input is a function pointer then it is evaluated with one parameter, being the npc. If the input is a string then the first letter determines what will be done with it. All these are passed through expand_string so that exciting things can be done.

Protected Functions

These are functions that only objects inheriting the class can access.

 * got_the_route
void got_the_route(string * route,
                   int delay,
                   string dest)
This method is called by the move_me_to function after the route handler has successfuly discovered the route to follow.

Parameters:
route - the route to follow
delay - the delay to follow it with
dest - route destination
See also:
move_me_to()

Discworld MUD's distribution world wide web pages.
brought to you by
Cut Me Own Throat Dibbler's Sensational Sausages; buy one while they are hot.
File last modified: Tue, 14 Oct 2003 18:00:43 GMT

Lost? Try Discworld's home page.