Home

[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 /std/living/living.c, /std/living/response_mon.c, /global/events.c, /std/living/mon_actions.c and /global/guild-race.c

Includes

This class includes the following files /include/playtesters.h, /include/shops/bank.h, /include/move_failures.h, /include/living.h, /include/player.h, /include/command.h, /include/money.h, /include/top_ten_tables.h, /include/map.h, /include/combat.h, /include/magic.h, /include/armoury.h, /include/route.h, /include/wander.h, /include/monster.h and /include/skills.h

Method index

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

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


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 intelligence. 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 queue_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
varargs void expand_mon_string(mixed str,
                               int no_convert)

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.
  • # - A call_other will be generated. The parameters are separated by ':'s, so "#frog:bing:fred:chicken" would call
    this_object()->frog("bing", "fred", "chicken");
    
    .
      ', ", : - These will generate a 'say', 'lsay' or 'emote'.
        @ - This will run the passed in command. Eg: "@frog" would cause the soul command frog to be used.
          Anything else will be used as a message to be sent to everyone in the room.


        Parameters:
        str - the thing to execute
        no_convert - whether or not convert_message() expansion will be done later in expand_string().

        See also:
        expand_string()


        expand_string
        varargs string expand_string(string in_str,
                                     object on,
                                     int no_convert)
        

        This method is used to expand the message strings used in the npc messages. It is used for chat strings and such things like that. The strings it expands are of the form:
        $lname$, $mname$, $aname$, ...
        The first letter determines the type of object being referenced. They are:
        m
        Me! The npc itself.
        l
        A living object, choose a random living object in the npcs environment.
        a
        Chooses a random attacker from those attacking the npc.
        o
        Choose a random non-living object in the environment of the npc.
        i
        Choose a random object in the inventory of the npc.
        After the first letter is a type of information being request.
        name
        The name of the selected object.
        cname
        The capitalised name of the selected object.
        gender
        The gender string of the selected object (male, female, neuter).
        poss
        The possessive string of the selected object.
        obj
        The objective string of the selected object.
        pronoun
        The pronoun string of the selected object.
        gtitle
        The guild title of the selected object (only useful on livings).
        ashort
        The a_short() call.
        possshort
        The poss_short() call.
        theshort
        The the_short() call.
        oneshort
        The one_short() call.


        Parameters:
        in_str - the input string
        on - the object to use for the 'o' matching

        See also:
        set_chat_string() and expand_mon_string()


        get_next_route_direction
        string get_next_route_direction()
        

        This method gets the next direction to go in the route which is currently being followed. It will remove this direction off the array.

        Returns:
        the next direction to go down

        See also:
        query_last_route_direction(), query_following_route() and do_route_move()


        init_command
        varargs void init_command(string str,
                                  int tim)
        

        This method allows you submit delayed commands to the npc via a call_out.

        See also:
        do_command(), queue_command() and delay_command()


        init_equip
        void init_equip()
        

        This method makes the npc initialise all their equipment, like hold it and stuff.

        See also:
        do_command()


        load_a_chat
        void load_a_chat(int chance,
                         mixed * c_s)
        

        This method loads up the set of chat strings to use while in combat.

        Parameters:
        chance - the chance of the chat occuring
        c_s - the chat string to use

        See also:
        load_chat(), query_achat_chance() and query_achat_string()


        load_chat
        void load_chat(int chance,
                       mixed * c_s)
        

        This method loads up the chat strings for the npc. This will be an array containing pairs of elements, the first pair is the weighting of the chat and the second is the chat to use.

        All the weights in the array are added up and then a random number is chosen in the weighting. Then that element is looked up in the array. This way you can control a chat and make it rare.

        If the chat string is an array then this a story, the story will be executed one after another and no other chats will be executed in between. If the first parameter of the story array is a number it will be used as a 1/1000 chance of the next story line being displayed. Special strings can be used which will replace with object names, see expand_mon_string() for further information.

        The chat chance is a chance (in 1000) of the chat occuring. You will need to play with this yourself to see which frequency of chatting you wish for your npcs.

        Parameters:
        chance - the chance in 1000 of a chat working every 2 seconds
        c_s - the chat string to use

        See also:
        expand_mon_string(), load_a_chat(), query_chat_chance() and query_chat_string()

        Example:
        load_chat(60,
           ({
              1, "'I am a chicken!",
              // Make this one more likely to occur.
              2, ":clucks like a chicken."
              1, ":pecks at $lpossshort$ foot."
            }));

        load_chat(100,
           ({
              1, "'I am a simple farmer."
              1, ":waves $mposs$ pitchfork around."
              // A story, they will always occur in this order
              1, ({
                  500,
                   "'Once upon a time there was a rabbit.",
                   "'It was a nice rabbit and hung around in bars.",
                   "'It sung little songs about fruit.",
                  }),
             }));

        move_me_to
        varargs void move_me_to(string dest,
                                int delay)
        

        This method will move the npc to the specified destination. The npc will walk from where they currently are to the destination using the time delay specified between the movements.

        If the location is reached then the function "stopped_route" will be called on the npc. The first arguement to the function will be 0 if the npc did not reach its destination and 1 if it did.

        Parameters:
        dest - the destination to go to
        delay - the time delay between each move

        See also:
        get_next_route_direction(), got_the_route(), query_last_route_direction(), query_following_route() and do_route_move()

        Example:
        inherit "/obj/monster";
        
        void go_home() {
           move_me_to(HOME_LOCATION, 2);
        } /* go_home() */
        
        void stopped_route(int success) {
           if (success) {
              do_command("emote jumps for joy.");
           } else {
              do_command("emote looks sad and lost.");
           }
        } /* stopped_route() */

        print_monster_chat
        varargs void print_monster_chat(int chance)
        
        print_monster_chat_int
        void print_monster_chat_int(mixed * chats,
                                    int chance,
                                    int t)
        
        print_monster_fighting_chat
        varargs void print_monster_fighting_chat(int chance)
        
        query_achat_chance
        int query_achat_chance()
        

        This method returns the current chat chance for attack messages on the npc.

        Returns:
        the current attack message chat chance

        See also:
        set_achat_chance(), load_chat() and load_achat()


        query_achat_string
        string * query_achat_string()
        

        This method queries the current chat string for attack messages on the npc. See load_chat() for a longer description of how the chat string is formatted.

        Returns:
        the current attack message chat string

        See also:
        load_chat(), load_achat() and set_chat_string()


        query_aggressive
        int query_aggressive()
        

        This method returns the current aggressive level of the npc. If the aggressive is set to 1, then the npc will attack all players that enter its environment. If the aggressive is set to 2 then the npc will attack everything (including other npcs).

        See the function start_attack() for information about things you can do to stop aggressive npcs attacking things.

        Returns:
        the aggressive level of the npc

        See also:
        set_aggressive() and start_attack()


        query_always_return_to_default_position
        int 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. The flag specified the length of time to wait before causing the default position to be restored.

        Returns:
        the time to wait before the position is restored

        See also:
        /std/living/living->return_to_default_position() and set_always_return_to_default_position()


        query_cannot_change_position
        int query_cannot_change_position()
        

        This method returns the current value of the unable to change position flag.

        Returns:
        the unable to change position flag

        See also:
        /std/living/living->set_default_position()


        query_cap_name
        string query_cap_name()
        

        This method returns the current capitalized name of the npc.

        Returns:
        the current capitalized name

        See also:
        set_cap_name()


        query_chat_chance
        int query_chat_chance()
        

        This method returns the current chat chance for messages on the npc

        Returns:
        the current chat chance

        See also:
        set_chat_chance() and load_chat()


        query_chat_string
        string * query_chat_string()
        

        This method queries the current chat string for messages on the npc. See load_chat() for a longer description of how the chat string is formatted.

        Returns:
        the current chat string

        See also:
        load_chat() and query_chat_string()


        query_combat_actions
        mixed * query_combat_actions()
        

        This method returns the current array of combat actions on the npc.

        The array will have the format of:

           ({
               action1_chance,
               action1_name,
               action1_action,
               ...
            })
        


        Returns:
        the combat action array

        See also:
        add_combat_action(), remove_combat_actions() and /std/effects/fighting/combat.c


        query_death_xp
        nomask int query_death_xp()
        

        This method returns the amount of death experiecne that would be gained by killing the npc. This function is nomask because its really really bad when NPCs unilaterally modify their death xp.

        Returns:
        the amount of death experience for the npc


        query_enter_commands
        string * query_enter_commands()
        

        This method returns the current array of enter commands.

        Returns:
        the current array of enter commands

        See also:
        reset_enter_commands() and add_enter_commands()


        query_fight_type
        int query_fight_type()
        

        This method returns the flag which allows the npc to join into fights.

        Returns:
        1 if the npc is to join fights, 0 if not

        See also:
        set_join_fights() and query_join_fight_type()


        query_follow_speed
        int query_follow_speed()
        

        This method queries the speed at which the npc will follow after a player when they leave combat.

        Returns:
        the current follow speed

        See also:
        set_follow_speed()


        query_following_route
        string * query_following_route()
        

        This method returns the current array of directions we are following as a route.

        See also:
        get_next_route_direction(), query_last_route_direction() and do_route_move()


        query_guild
        string query_guild()
        

        This method returns the current guild of the npc.

        Returns:
        this current guild of the npc

        See also:
        query_race(), set_guild() and set_level()


        query_guild_ob
        mixed query_guild_ob()
        

        This returns the guild object associated with the npc.

        Returns:
        the guild object associated with the npc

        See also:
        set_guild(), set_guild_ob() and set_level()


        query_join_fights
        string query_join_fights()
        

        This method returns the message to use when joining into fights.

        Returns:
        the message to print when joining a fight

        See also:
        set_join_fights() and set_join_fight_type()


        query_last_route_direction
        int query_last_route_direction()
        

        This method tells us if the npc is currently following a route.

        Returns:
        1 if there are route directions to follow still

        See also:
        get_next_route_direction(), query_following_route() and do_route_move()


        query_level
        int query_level()
        

        This method returns the current guild level of the npc. This is a pass through call to a function on the guild object associated with this npc.

        Returns:
        the current guild level of the object

        See also:
        set_guild()


        query_move_after
        mixed query_move_after()
        

        This method returns the current move after values. It returns an array of the form:
           ({
             after,
             rand,
            })
        


        Returns:
        the move after values

        See also:
        set_move_after()


        query_move_zones
        string * query_move_zones()
        

        This method returns the current list of move zones on the npc

        Returns:
        the current list of move zones

        See also:
        add_move_zone(), remove_move_zones() and set_move_after()


        query_ok_turn_off_heart_beat
        int query_ok_turn_off_heart_beat()
        

        This method returns 1 if it is ok to turn of the npc's heart beat. THis can be overridden for times when the heart beat needs to be kept on for some reason.

        Returns:
        1 if the heart beat should go off, 0 if it should stay on


        query_queued_commands
        int query_queued_commands()
        

        You can use this function to see if there are any commands queued for this NPC.

        See also:
        init_equip(), init_command(), delay_command(), do_command() and queue_command()


        query_race
        string query_race()
        

        This method returns the current race of the npc.

        Returns:
        the current race of the object

        See also:
        set_race(), query_guild() and set_level()


        query_race_ob
        mixed query_race_ob()
        

        This returns the race object associated with the npc.

        Returns:
        the race object associated with the npc

        See also:
        set_race(), set_race_ob() and set_level()


        query_spell_actions
        mapping query_spell_actions()
        

        This method returns the list of spell actions present on the npc.

        Returns:
        the list of spell actions


        query_throw_out
        mixed * query_throw_out()
        

        This method returns the current throw out array. The array consists of
        ({
          hps,
          chance,
          their_mess,
          everyone_mess
        })
        
        The parameters are the same as used in the set_throw_out function.

        Returns:
        the throw out array

        See also:
        set_throw_out()


        queue_command
        varargs int queue_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. If there are no commands pending the command is executed immediately. This function is 100% compatible with delay_command() and init_command().

        Parameters:
        words - the action to perform
        interval - to wait before processing another command. If omitted defaults to 2 seconds as per players

        See also:
        delay_command(), query_queued_commands(), init_command() and do_command()

        Example:
        ob = clone_object(NICE_HAIRY_APE);
        ob->queue_command("'I am a hairy ape!");
        ob->queue_command("emote apes around the room.",5);
        ob->queue_command("get banana",10);
        ob->delay_command("emote get apple.",3);
        Right away it says "I am a hairy ape",
        2 seconds later it apes around the room,
        5 seconds after that it gets a banana
        and 13 seconds (10+3) after that it gets an apple.
        

        rand_num
        int rand_num(int no,
                     int type)
        

        This method generates a random number. It used to setup the random stats.

        Parameters:
        no - the number of times to roll the dice
        type - the size of the dice

        Returns:
        the randomly generate number

        See also:
        set_random_stats()


        remove_achat_string
        void remove_achat_string(mixed chat)
        

        This method attempts to remove the given chat string from the current list of attack message chat strings. The chat message is checked to see if it exists in the array, the weighting of the string is ignored.

        Parameters:
        chat - the chat string to remove

        See also:
        add_achat_string(), load_chat() and load_achat()


        remove_chat_string
        void remove_chat_string(mixed chat)
        

        This method attempts to remove the given chat string from the current list of chat strings. The chat message is checked to see if it exists in the array, the weighting of the string is ignored.

        Parameters:
        chat - the chat string to remove

        See also:
        add_chat_string() and load_chat()


        remove_combat_action
        int remove_combat_action(string name)
        

        This method will remove the combat action with the specified name.

        Returns:
        1 if it is found and removed, 0 if not

        See also:
        add_combat_action(), query_combat_actions() and /std/effects/fighting/combat.c


        remove_event_enter_action
        void remove_event_enter_action(int id)
        
        remove_move_zone
        void remove_move_zone(mixed zone)
        

        This method removes a move zone from the npc.

        Parameters:
        zone - the zone to remove

        See also:
        add_move_zone(), query_move_zones() and set_move_after()


        remove_spell_action
        int remove_spell_action(string name)
        

        This method removes the specified spell action.

        Parameters:
        name - the name of the spell to remove

        Returns:
        1 if successful, 0 if not


        reset_enter_commands
        void reset_enter_commands()
        

        This method resets the array of enter commands back to nothing.

        See also:
        add_enter_commands() and add_enter_commands()


        reset_move_after
        void reset_move_after()
        

        This method resets move after to 0, i.e. that they will not move.
        run_away
        int run_away()
        

        This method is used to make the npc run away. This will be called by the combat code for wimpy when the npc is bellow the number of points used to trigger the wimpy action.

        Returns:
        1 if successfuly ran away


        set_achat_chance
        void set_achat_chance(int i)
        

        This method sets the current chat chance for attack messages on the npc.

        Parameters:
        i - the attack message chat chance

        See also:
        load_chat(), load_achat() and query_achat_chance()


        set_achat_string
        void set_achat_string(string * chat)
        

        This method sets the current chat string for attack messages on the npc. See load_chat() for a longer description of how the chat string is formatted.

        Parameters:
        chat - the new chat attack message strings.

        See also:
        load_chat(), load_achat() and query_achat_string()


        set_aggressive
        void set_aggressive(int a)
        

        This method sets the current aggressive level of the npc. If the aggressive is set to 1, then the npc will attack all players that enter its environment. If the aggressive is set to 2 then the npc will attack everything (including other npcs).

        See the function start_attack() for information about things you can do to stop aggressive npcs attacking things.

        Parameters:
        a - the new aggressive level

        See also:
        query_aggressive(), start_attack(), set_join_fights() and set_throw_out()


        set_always_return_to_default_position
        void set_always_return_to_default_position(int tim)
        

        This method sets the status of the flag that makes the npc return to the default position if its position is changed. The flag specified the length of time to wait before causing the default position to be restored.

        Parameters:
        tim - the time to wait before the position is restored

        See also:
        /std/living/living->return_to_default_position() and query_always_return_to_default_position()


        set_cannot_change_position
        void set_cannot_change_position(int flag)
        

        This method sets the value of the unable to change position flag. This flag will be checked by the soul, and by anything else which deliberatly changes someones position.

        Parameters:
        flag - the unable to change position flag

        See also:
        /std/living/living->set_default_position()


        set_cap_name
        void set_cap_name(string s)
        

        This method set the current capitalized name of the npc.

        Parameters:
        s - the capitalized name of the npc

        See also:
        query_cap_name()


        set_chat_chance
        void set_chat_chance(int i)
        

        This method sets the current chat chance for messages on the npc.

        Parameters:
        i - the chat chance

        See also:
        load_chat() and query_chat_chance()


        set_chat_string
        void set_chat_string(string * chat)
        

        This method sets the current chat string for messages on the npc. See load_chat() for a longer description of how the chat string is formatted.

        Parameters:
        chat - the new chat strings.

        See also:
        load_chat() and query_chat_string()


        set_follow_speed
        void set_follow_speed(int f)
        

        This method sets the speed at which the npc will follow after a player when they leave combat.

        Returns:
        the current follow speed

        See also:
        set_follow_speed()


        set_guild
        int set_guild(string str)
        

        This method is deprecated. Use basic_setup() instead. This method sets the current guild of the npc to the passed in value. The guild should be one of the guilds listed in the /std/race.c object. This is used in conjuction with the race when set_level is called to setup the default attributes for the npc. This should only be called *before* set_level() is called.

        Parameters:
        str - the new guild for the npc

        See also:
        query_race(), query_guild(), set_guild() and set_level()

        Example:
        ob = clone_object("/obj/monster");
        ob->set_guild("fighter");

        inherit "/obj/monster";
        
        void setup() {
           ...
           set_race("fighter");
           ...
           set_level(12);
        } /* setup() */

        set_guild_ob
        void set_guild_ob(mixed g)
        

        This method sets the guild object associated with the npc. This will probably not do what you expect and cannot be used in conjucton with set_level to set the guild. It is called by /std/race.c when set_level() is called.

        Parameters:
        g - the new guild object

        See also:
        set_level(), set_guild() and /std/race.c


        set_join_fight_type
        void set_join_fight_type(int i)
        

        This method sets the flag which allows the npc to join into fights. If this is set to a non-zero value then the npc will join into fights in progress using the fight joining message.

        Parameters:
        i - 1 if the npc is to join fights, 0 if not

        See also:
        set_join_fights() and query_join_fight_type()


        set_join_fights
        void set_join_fights(string str)
        

        This method sets the message to use when joining into fights.

        Parameters:
        str - the message to print when joining a fight

        See also:
        query_join_fights() and set_join_fight_type()


        set_level
        void set_level(int i)
        

        This function is deprecated. Use basic_setup() instead. This method sets the level of the npc. This should only be called *after* the race and guild are set. If this is called before that the results will be unexpected.

        Parameters:
        i - the level to set the npc to

        See also:
        set_race(), set_guild() and basic_setup()


        set_move_after
        void set_move_after(int after,
                            int rand)
        

        This method sets the speed at which the npc will randomly wander around. The npc will wander at the speed:
        speed = after + random(rand)
        
        This is called every time the npc sets up for its next move.

        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.

        Parameters:
        after - the fixed amount of time
        rand - the random amount of time

        See also:
        remove_move_zone(), query_move_zones() and add_move_zone()


        set_race
        int set_race(string str)
        

        This function is deprecated. Use basic_setup() instead. This method sets the race of the npc. The race should be one of the races listed in the /std/race.c object. This is used in conjuction with the guild when set_level is called to setup the default attributes for the npc. This should only be called *before* set_level() is called.

        Parameters:
        str - the race to set

        Returns:
        always returns 1

        See also:
        query_race(), query_guild(), set_guild(), set_level() and basic_setup()

        Example:
        ob = clone_object("/obj/monster");
        ob->set_race("fish");

        inherit "/obj/monster";
        
        void setup() {
           ...
           set_race("fish");
           ...
           set_level(12);
        } /* setup() */

        set_race_ob
        void set_race_ob(mixed r)
        

        This method sets the race object associated with the npc. This will probably not do what you expect and cannot be used in conjucton with set_level to set the race. It is called by /std/race.c when set_level() is called.

        Parameters:
        r - the new race object

        See also:
        set_level(), set_race() and /std/race.c


        set_random_stats
        void set_random_stats(int no,
                              int type)
        

        This method sets the stats for the npc to some exciting random values.

        Parameters:
        no - the number of times to roll the dice
        type - the size of the dice

        See also:
        rand_num()


        set_throw_out
        void set_throw_out(int hps,
                           int chance,
                           string their_mess,
                           string everyone_mess)
        

        This method is used to determine when to throw people out of a room. This is what detritus uses to throw people out of the mended drum when it gets a bit rowdy.

        The hps is the level of hps at which the npc will start throwing people out with the chance of it occuring (chance is a percentage).

        People will be thrown into a random room, if the property

        "no throw out"
        is specified on the room then they will not be thrown into that room.

        Parameters:
        hps - the number of hps at which to start throwing people out
        chance - the percentage chance of being thrown out
        their_mess - the message to show them
        everyone_mess - the message to show everyone else

        See also:
        set_aggressive(), query_throw_out(), set_join_fights() and expand_string()


        set_virtual_move
        void set_virtual_move(int number)
        

        This method sets the current virual move ability of the npc. NB: This is obsolete

        Parameters:
        number - 1 for virtual moving, 0 for not

        See also:
        query_virtual_move()


        setup_nationality
        void setup_nationality(string nationality,
                               string region)
        

        This method sets up a nationality and sets up a region in the nationality for the npc.

        Parameters:
        nationality - the nationality to set
        region - the region in the nationality


        start_attack
        void start_attack(object who)
        

        This method check to see if the npc should start attacking someone when they enter the npcs environment. It is called from inside init(). It will only attack if the agressive is set and the person is visible to be attacked. The property
        "no attack"
        can be set on the npc (or player) to stop them being attacked.

        Parameters:
        who - the person to potentially start attacking

        See also:
        set_aggressive()


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()


Valid HTML 4.01 Transitional
Valid CSS!
Read More