|
|
[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.cIncludes
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.hMethod 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.
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()
|