OBJECT
/obj/lib/skills
SYNOPSIS
inherit "/obj/lib/skills"
#include <skills.h>
LAST UPDATE
Thragor, 14-Oct-96, 11:30 MET
DESCRIPTION
General
-------
Skills are used to allow the player to 'learn' how to handle
things. Skills may vary between 0% and 100%, where 100% is
absolutely perfect. If the skills are handled in a guild they
need to be accepted by the Archwizard of Guilds.
Detail
------
/obj/lib/skills is a file without create(), reset() or
anything else. So it should be easy just to add an additional
inherit to your file, which would like to use skills. E. g. if
you define a climbable tree, you just need to write:
inherit "/std/thing";
inherit "/obj/lib/skills";
Functions
---------
status CheckSkill(object player,string skill-name,int chance,
void|int percentage)
Mainly calls check_success() (see below). In addition it
validates the value of the skill-attribute. CheckSkill()
doesn't include learning! To do this, use UseSkill() (see
below).
player:
The player for whom to check the skill.
skill-name:
One of the SK_-values from <skills.h>.
chance:
The chance to stand the check (in promille).
percentage:
If called by reference ('&var' instead of 'var') it returns
how much percent someone failed or succeeded. For more
information see check_success().
status UseSkill(object player,string skill-name,int chance,
void|int percentage,void|int maxlearn)
Like CheckSkill() but additionally performs learning. You
may learn either when your fail-percentage is below a
certain value or if you had a success. To get to know more
about learning check learn_skill().
player:
The player for whom to check the skill.
skill-name:
One of the SK_-values from <skills.h> (this value should
be readable, as this is the name used in the learn-msg.
chance:
The chance to stand the check (in promille).
percentage:
If called by reference ('&var' instead of 'var') it returns
how much percent someone failed or succeeded. For more
information see check_success().
maxlearn:
The value which the player might reach at maximum using
this skill at this point. E. g. climbimg a small pole
wouldn't train you as good as climbimg the Rocky
Mountains.
void AdvanceSkill(object player,string skill-name)
Increases players skill 'skill-name', i. e. the SK_xxx. If
the skill is already at 100% nothing will be changed.
AdvanceSkill() also gives a message to the players, that
they learned to handle the skill a little bit better. In
combat this message is given after a small delay, because
otherwise it might disarrange the combat-messages.
player:
The object which should learn the skill (player or npc).
skill-name:
One of the SK_-values from <skills.h> (this value should
be readable, as this is the name used in the learn-msg.
status learn_skill(int value,void|int maxlearn)
This function is to check if players advance their
skills. The check is only done by several random-checks
which make it harder to learn the better the players are.
This function doesn't set any new values! (See AdvanceSkill
for more.)
value:
The actual value players have in that skill.
Query with: pl->QueryAttr(SK_xxx,1).
maxlearn:
If value is >= maxlearn then the function will always
return 0. This is to allow 'easy tasks' where you are not
able to advance your skill to 100%. It may also be used to
reduce the maximum amount of a skill players might get at
a certain level (a player at Lvl 1 with critical hit at
100% isn't quite useful).
int check_success(int value,int percent,int chance)
This is the basic function which checks, if the 'throw of
the 100-sided die' lead to a success.
value:
May vary between 0 and 100 (else it will be adjusted) and
shows the actual skill-value players have.
chance:
May vary between 0 and 1000 (else it will be adjusted) and
specifies the chance players have to be successful. Of
course a chance of 1000 is much better, while a chance
below 1 would immediately stop the test.
In formulas the chance reduces the actual value, which is
checked:
value = value*chance/1000
percent:
Give the chance as call-by-reference, i. e. call the
function with check_success(value,&percent,chance) and
<percent> will contain how much someone failed, or how
much someone had a success, given in % (0-100).
A short sketch to show what a percent of vary is:
s v f
0 success-throw value failure-throw 100
|----------|----------|----------|----------|
<----- success -------><----- failure ------>
<-------- v-0 --------X------- 100-v ------->
<--- v-s --X--- f-v -->
On success percent is calculated with:
(v-0)*percent/100 = v-s
i. e. it returns how much percent are left of the space
where the throw still would be a success.
On failure percent is calculated with:
(100-v)*percent/100 = f-v
i. e. it returns how much of the failure-space has been
used by the throw.
string get_skill(string skill-name)
Returns a description how good a skill is. These are the
defined descriptions:
100%: absolutely perfect
99%-95%: perfect
94%-88%: nearly perfect
87%-80%: very good
79%-70%: good
69%-60%: quite good
59%-50%: good average
49%-40%: avarage
39%-30%: ordinary
29%-20%: quite ordinary
19%-15%: very ordinary
14%-10%: bad
9%-4%: very bad
3%-0%: hopeless
int cmd_skills(string arg)
If added as command to e. g. an object, it will list all
general skills.
SEE ALSO
guild(S), guildobj(L)