OBJECT
living
UPDATE
Pepel, 29-Jun-93, 01:10 MES DST
DESCRIPTION
This is the generic living object which 'lives', can move,
can fight.
Note that there is no /std/living to be inherited. The
Functionalities of the living are contained in /std/living/*
which are used by the /std/player and the /std/npc objects.
I.e. a living is either a player or a monster.
* Functionalities from living/attributes :
A living has a number of 'attributes' in the new system.
These include the former stats strength, dexterity,
intelligence and constitution.
These attributes determine the life functions and variables
like hitpoints and spellpoints, but also the ability to
perform certain actions like spellcasting or swordfighting.
Attributes can be set by using the functions
SetAttribute(string attribute, int value)
Sets <attribute> to <value>. Certain restrictions might
exist, and the requested attribute might not be set.
Attributes are integer values, and are in the range
of 1 (very bad) to 20 (excellent and highest possible
for a normal human).
int QueryAttribute(string attribute)
Returns value of <attribute>
See /doc/concepts/attributes for a detailed discussion!
* Functionalities from living/combat
P_AGGRESSIVE
SetAggressive(int aggressive)
Makes the monster aggressive, if <aggressive> is 1.
Without using this function the npc only fights back if it is
attacked. It won't attack npc's that don't have P_IS_PLAYER
set, and won't attack ghosts, and won't attack invisible
wizards.
P_ATTACK_CHANCE
SetAttackChance (int chance)
The chance that an aggressive monster will attack a selected
victim. The chance is given in promille and defaults to 1000
("attack always").
This is independant from P_AGGRESSIVE: an aggressive monster
will see a new living and decide, regarding the rules stated
before, if it's a legal victim. If yes, it checks the chance
and 'decides' to attack.
So an inaggressive monster will never attack, even with
chance 1000.
P_FRIEND_OBJ
SetFriendObj (object friend)
Whenever the npc wants to attack an <obj> on sight, it calls
a function 'IsFriend(<obj>)' in itself. If this call returns
non-zero, <obj> won't be attacked.
Now: if a friend-object is defined, the living ignores its
builtin 'IsFriend()' and instead uses 'friend-object->IsFriend ()'
in the same manner.
The default, npcs don't autoattack other npcs, and players don't
autoattack other players.
Weaponclass and armourclass are defined. Unless
a weapon is used, the wc is 0. Unless an armour is used,
the ac is 0. (P_WC and P_AC)
wieldme(object ob)
This function is called to wield the weapon ob. All necessary
checks are done, i. e. if the living is a ghost or if it has
not enogh weaponhands the wield-function will be abborted giving
a corresponding message and returning 0. If the weapon got
wielded successfully 1 is returned.
unwieldme(object ob)
This function is called to unwield a weapon given as objectpointer.
wearme(object ob)
This function is called to wear an armour ob given as objectpointer.
The armour-type gets tested if it is valid and a check is done, if
the living already wears an armour of the same type, which results
in an output to the player and the returned value 0.
If the armour has defined weaponshands, too, they will be checked.
On success 1 is returned.
removeme(object ob)
Removes a worn armour.
* Functionalities from living/life
A living creature has several needs just
because it is alive. The complex life functions are
reducced to some crucial factors.
P_HP
These are mainly determined by the constitution and give
the ability of the body to absorb damage. If the
hitpoints go below zero, the creature is dead.
P_SP
Spellpoints (sometimes called mana) describe the magical
(spiritual) capability of the creature. It is mainly
determined by Intelligence and Wisdom. It is up to the
creature how good it uses the spellpoint resource.
Spellpoints will go down when supernatural actions are
performed by the creature.
P_MAX_SP, P_MAX_HP
Readonly variable which are computed from attributes.
P_FOOD, P_DRINK, P_ALCOHOL, (P_POISON)
These three variables describe hunger, thirst and
intoxication by alcohol. The max is dependent on the
constitution of the living, and of the weight.
These variables automatically decrease with time.
When food or drink goes below zero, the creature
suffers hunger or thirst and will lose hitpoints.
P_MAX_FOOD, P_MAX_DRINK, P_MAX_ALCOHOL
Readonly variables which are computed from attributes.
P_WEIGHT, P_SIZE
These variables describe the physical proportions of
the creatures body. Both variables are standard properties
and are also used in normal objects.
P_MAX_WEIGHT
This is a readonly variable which describes how much
a living creature may carry around.
P_GENDER
This is obvious. Gender may be MALE, FEMALE or NEUTER,
as defined in <living.h>. Player gender may be only
MALE or FEMALE.
P_RACE
A string which defines the race.
P_ALIGNMENT
The alignment of the living, ranging frO
P_AGE
The age of the living creature in seconds
There are some properties defining move messages for living things
P_MSGIN
What others see when a living enters the room
P_MSGOUT
What others see when a living leaves the room
P_MMSGIN
What others see when a living teleports into the room
P_MMSGOUT
What others see when a living teleports out of the room
All these messages can be either a simple string, or an array
of two strings.
If a message is a string, the first is told to all livings who
can see, while the others see a default message provided by
the room.
If a message is an array, the first element string is told to
all livings who can see, the second to the others.
To distinguish simple livings, npc's, fighting pets, two mutually
exclusive flags may be set and queried:
P_IS_PLAYER
int SetIsPlayer (int yes)
int QueryIsPlayer ()
int QueryPlayer()
Is non-zero if the living is a player.
It can only be set, not reset.
P_IS_NPC
int SetIsNpc (int yes)
int QueryIsNpc()
int QueryNpc()
Is non-zero if the living is a npc.
This is automatically set by /std/npc. Reset it for fighting
pets.
* Functionality of living/moving
P_GOCHANCE
SetGoChance (int chance)
If the living is not under attack, it may go randomly with
every heartbeat. The go-chance, given in promille, is that
chance that it really moves at one heartbeat. Default is 0.
GoAway()
This is the basic function for automatic moves.
Collect a list of all exits and doors of the current room,
select randomly one and try to leave through it. If this
succeeds, return immediately with result 1.
Else try again with the next from the list (wrapping at the
end), until the complete list has been tried.
If no exit could be found, return 0.
run_away()
Called in combat from whimpy livings, this tries go GoAway()
and outputs according messages.
int move_player (string dir_dest)
int move_player (mixed dir, string|object dest)
Move living to <dest>, which is said to be in direction <dir>.
If only one argument is given, it must be a string of the
form "<dir>#<dest>".
A direction "X" is take as teleport.
NOTE: This function is for compatibility and just calls
either 'move (dest, M_GO, dir)' or 'move (dest, M_TELEPORT)'.
int move (string|object dest, void|int method, void|mixed extra)
Move the living to <dest> using <method>. This is done by
the normal thing/moving::move.
If the method is M_GO, M_TELEPORT or M_SPECIAL, and the
living is an interactive player, it is commanded to 'look'
after the move.
Normally, all moving messages are given by the room moved
into, and are taken from the (M)MSG{IN,OUT}-Properties.
Method M_SPECIAL uses the <extra>-Parameter for the
messages, which must be a string or an array of strings. It
can be empty though.
If <extra> = "<msg>" or <extra> = ({ msg1, msg2, "<msg>" }),
the living will see "You <msg>.\n".
void notify_leave (object dest, mixed method, mixed extra)
This performs the normal container/restrictions::notify_leave().
In case of methods M_GIVE, M_DROP and M_PUT the living, the
moved object and the environment are also told approbiate
messages of the action performed.
void notify_enter (object dest, mixed method, mixed extra)
This performs the normal container/restrictions::notify_enter().
In case of methods M_GET the living, the moved object and
the environment are also told approbiate messages of the
pickup.
void SetHBHook (void|int tval, void|string fun, void|object obj)
Set the heart_beat hook. This means that every <tval> heart_beats
the function <fun> in the object <obj> is called.
Defaults: tval = 150, fun = "player_hb_hook",
obj = previous_object().
The hook is cleared (desactivated) with every successful
move.
void ResetHBHook()
Clear any set heart_beat hook.
mixed QueryHBHook()
Return an array of the current heart_beat hook settings
( ({ tval, function, object }) ) or zero.
INHERITANCE TREE
living
|-thing/properties
|-living/description
| `-thing/description
|-container/restrictions
|-living/attributes
|-living/life
|-living/moving
| |-thing/moving
| `-container/restrictions
`-living/combat
SEE ALSO
properties(C), thing(C), container(C), units(C)