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

Includes

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

Class Index

Method index

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_event_exit_action
int add_event_exit_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,
int running)

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_enter
void event_enter(object mover,
string mess,
object from)
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.

Protected Functions

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

got_the_route
void got_the_route(mixed * 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()


Classes

These are nice data types for dealing with... Data!