Difference between revisions of "Manual:Game Mechanics/Skills"

From DikuMUD Wiki
Jump to navigation Jump to search
(checked against the current code (wiki review 2026-11-15))
 
Line 1: Line 1:
−
== Skills ==
+
This page explains how skills, spells and weapon skills are kept, raised and checked, with the checks the game makes for swimming, climbing, searching, picking locks and fleeing as examples. How to write a check of your own in DIL is in the section on the skill check. The players' side is in [[Help/Skills|help skills]].
−
It seems skill (spells et. al) checks got kind of lost in the mists of time. Here is the general idea:
 
  
−
Skills are all in [0..250]. Generally [0..100] for players.
+
== Four trees ==
 +
A character's knowledge is kept in four trees: abilities, skills (<code>SKI_*</code>), spells (<code>SPL_*</code>) and weapons (<code>WPN_*</code>). The constants are in <code>vme/include/values.h</code>; the names and the race and profession modifiers in <code>vme/etc/</code>: <code>abilities.def</code>, <code>spells.def</code>, <code>weapons.def</code>, and for skills <code>commands.def</code>. Spells and weapons are grouped in categories: the spell spheres (fire, frost, mind...) and the weapon families (axe and hammer, sword, club and mace, polearm, natural, special). See [[Manual:Zone Manual/Appendices/Skill definitions in values.h|skills]], [[Manual:Zone Manual/Appendices/Spell definitions in values.h|spells]] and [[Manual:Zone Manual/Appendices/weapon definitions in values.h|weapons]].
  
−
Players have a complete skill tree. NPCs have no skills, instead either an ability or their level is used based on the skill. As a rule of thumb a player's skill should roughly equal the player's level * 2 [??]. So a level 20 player should generally have a 40 [??] swim skill (some more, some less). An NPC would generally have a skill of 1 per level, often an ability is used in place of a skill.
+
=== Players ===
 +
A player has a value in every skill, spell and weapon, and trains them one at a time with skill points (see [[Manual:Game Mechanics/Levels#Training|Levels]]). A practice raises a skill by 5 while it is below 10, by 4 below 20, by 3 below 40, by 2 below 75 and by 1 from 75. Practised once every level, a skill reaches 40 after 11 practices, 75 after 29 and 100 after 53. A practice also raises the category above it (such as "sword" above "long sword") to half the new value, when the category is lower.
  
−
Skill checks are rolled open-ended 1d100.
+
=== Monsters ===
 +
A monster has no skills. Where a player would use a skill, a monster uses the ability that goes with it: in a climb, its dexterity; when it swims, its constitution. A monster has weapon and spell skills only by category: one value for all swords, one for all fire spells. They are set as percentages in the zone, see [[Manual:Game Mechanics/Monsters|Monsters]].
  
−
A general purpose table of the meaning of a skill level:
+
== What a value means ==
 +
Skills and difficulties use the same scale. As a rule of thumb for choosing a difficulty:
 +
{| class="wikitable"
 +
! Value !! Meaning
 +
|-
 +
| 0 || No idea how to do it.
 +
|-
 +
| 40 || An ordinary person, an ordinary swimmer.
 +
|-
 +
| 100 || The best a human could be.
 +
|-
 +
| 200 || Far beyond any human.
 +
|}
 +
A player can train a skill to about 110 at most, and much less in skills their race and profession don't suit (see [[Manual:Game Mechanics/Levels#How far a player can train|Levels]]); magic can add to it.
  
−
  0: You're completely incompetent. No idea how to perform this skill. You might even panic.
+
== The skill check ==
−
  40: An average person's skill (real world), for example an average swimmer
+
A check against a difficulty (see [[Manual:Game Mechanics/Introduction|Introduction]]):
−
100: is the best (real world) human skill.
 
−
200: is beyond what a human being could normally achieve, we're perhaps in the divine skill territory here.
 
  
−
Note that a char with a skill of N will fail half the time when the difficulty is N.
+
result = open-ended 1d100 + skill - difficulty - 50
  
 +
It succeeds when the result is above 0, which is half the time when skill and difficulty are equal. For a player, "skill" is (2 &times; skill + ability) / 3; for a monster it is the ability. The result is also a measure of how well or how badly it went.
  
−
=== Swim ===
+
In DIL, use the functions in <code>skills.zon</code>:
−
Let's use swim as an example. A characters proficiency in swim in 0..100. The table below is a rough translation of a swimming skill.
+
{| class="wikitable"
 +
! Function !! What it checks
 +
|-
 +
| <code>skillchecksa@skills(skill, ability, difficulty)</code> || <code>self</code> against a difficulty, as above.
 +
|-
 +
| <code>skillchecksau@skills(u, skill, ability, difficulty)</code> || the same for the character <code>u</code>.
 +
|-
 +
| <code>skillbattle1@skills(skill, ability, opponent, ability2)</code> || <code>self</code> against an opponent: roll + own ability + own skill - opponent's ability - opponent's skill (in the same skill) - 50. A monster's skill counts as its ability.
 +
|-
 +
| <code>skillbattle2@skills(skill, abil1, abil2, opponent, oabil1, oabil2)</code> || <code>self</code> against an opponent, each side with two abilities (two parts the first, one part the second), and for a player two parts skill to one part those abilities.
 +
|-
 +
| <code>skillresist@function(aa, ad, sa, sd)</code> || the opposed check from numbers: roll + aa + sa - ad - sd - 50.
 +
|}
 +
They all roll [[Manual:DIL Manual/openroll()|openroll(100, 5)]] and return the result; above 0 is a success. A check of your own, in a template put on a room:
 +
<pre>
 +
dilbegin lift_rock();
 +
external
 +
  integer skillchecksau@skills(u : unitptr, skillidx : integer, abiidx : integer, difficulty : integer);
 +
var
 +
  hm : integer;
 +
code
 +
{
 +
  :start:
 +
  wait(SFB_CMD, command("lift"));
 +
  block;
 +
  // the one who typed it: climbing skill and strength, against a difficulty of 60
 +
  hm := skillchecksau@skills(activator, SKI_CLIMB, ABIL_STR, 60);
 +
  if (hm > 0)
 +
      act("You lift the rock.", A_ALWAYS, activator, null, null, TO_CHAR);
 +
  else
 +
      act("The rock doesn't move.", A_ALWAYS, activator, null, null, TO_CHAR);
 +
  goto start;
 +
}
 +
dilend
 +
</pre>
 +
In a template on a room, <code>self</code> is the room, so use <code>skillchecksau@skills</code> with the character; <code>skillchecksa@skills</code> checks <code>self</code> and fits a template running on the character.
  
−
  0: You'll risk drowning in shallow water even if your feet can touch the bottom.  
+
== Difficulties on exits ==
−
  40: An average (real world) swimmer
+
An exit has one <code>difficulty</code>, 0 to 250, which every check through that exit uses: searching for it if it is hidden, climbing it, swimming through it and picking its lock.
−
100: is the best human swimmer in the (real) world.
+
<pre>
−
200: is the most divine swimmer.
+
west to cave difficulty 30 open {EX_OPEN_CLOSE, EX_CLOSED, EX_LOCKED, EX_HIDDEN}
 +
  keyword {"boulder"} key cave_key;
 +
</pre>
  
 +
== Examples from the game ==
  
−
Now imaging having swim in average conditions. If your skill is average (50) then the skill check
+
=== Swimming ===
−
is to see the result of (1d100 + skill) - 100. If the result is above 0 the swim was a success.
+
A character moving into or out of a room with <code>movement SECT_WATER_SWIM</code> must have <code>swim on</code> or use <code>swim &lt;direction&gt;</code>. Each move makes a check (<code>vme/src/act_movement.cpp</code>):
−
Therefore if your skill is 0 you always fail an average swim roll is > 100. If your skill is 75
 
−
for an average swim, you succeed 75% of the time. If your skill is 100 then you always
 
−
succeed. Remember that the open-ended roll can of course always offset even a sure success or
 
−
fail.
 
  
−
A room's swim difficulty could be:
+
roll + (2 &times; swimming + CON) / 3 - (difficulty of the exit - bonus) - 50
  
−
    0: Super easy.
+
The bonus is 50 for the arthropod races, 80 for an amphibian and 100 for a fish (the extras <code>$is_amphib</code> and <code>$is_fish</code>). A result below 0 means the swimmer flounders: they don't move, and lose a hit point for each full 10 points below 0; it can drown them. Rooms with <code>SECT_WATER_SAIL</code> are deep water: a character can't enter them without a boat, and swimming out of them to land adds 150 to the difficulty.
−
  30: Pretty easy for most characters, still rather challenging for newbies.
 
−
  70: Kinda hard - great for rapids in high-level areas.
 
−
  100: A super difficult swim. It would mean even the (real world's) best swimmer would fail half the time under these circumstances. Players with 200 skill succeed always (except OE).
 
−
  150: The world's best swimmer would probably fail a swim direction most of the time.
 
  
−
A character that fails a skill check might be swallowing water if the fail is [0..-20]. And might
+
A river can carry swimmers along with <code>watercurrent@basemove(direction, messages, beats)</code>: every 5 seconds it counts up, and after ''beats'' counts it carries everyone and everything in the room through the exit. Characters make the swimming check against that exit's difficulty first (in DIL, so with <code>openroll(100, 5)</code>); one who fails loses the hit points but is carried along all the same. From the forest of Haon-Dor in <code>haon_dor.zon</code>, shortened:
−
take one hp damage per 10 failure if the result is worse than -20.
+
<pre>
−
 
+
lightriver
−
The function skillcheck() captures precisely this setup.
 
−
 
 
−
As above, the swim skill works much the same way.
 
−
The player commands are swim on/off or swim <direction>.
 
−
The room should have the <code> SECT_WATER_SAIL flag </code>.
 
−
 
 
−
Notice in the example below, the difficulty for swimming east is 0. Because it's a very calm river in the light part of the forest. Swimming west is up-steam, but also into a dark cold part of the river. So it's set to 20. Swimming south to the toy zone is set to 5 because I figured you'd have to swim across the river.
 
−
In the following example notice how to denote a calm river, where the difficulty is 0. It's not a strong current and the area overall is a beginner's area. Swimming west from here is upstream so
 
−
you notice that the difficulty is higher whereas swimming south is kind of crossing the river and not as difficult.
 
−
 
 
−
There is also an optional dil for rooms with currents. It will move anything in the room downstream after time and replaces the legacy <code>force_move</code>.
 
−
 
 
−
<nowiki>lightriver
 
 
title "On the River in Haon-Dor"
 
title "On the River in Haon-Dor"
−
descr "The river slowly flows east towards the village of Udgaard. North you see a landing spot in the light part of the forest."
+
descr
−
 
+
"The river slowly flows east towards the village of Udgaard."
−
movement SECT_WATER_SAIL
+
movement SECT_WATER_SWIM
−
 
+
west to darkriver difficulty 20 descr
−
north to rn_6018;
+
  "Much further upstream the forest becomes more dense.";
−
west to darkriver2    difficulty 20 descr "Much further upstream the forest becomes more dense.";
+
east to river@udgaard difficulty 0 descr "The river continues to the east.";
−
east to river@udgaard difficulty 0 descr "The river continues to the east.";
+
dilcopy watercurrent@basemove(DIR_EAST,
−
south to river1@toy    difficulty 5  descr "The river forks and bends south.";
+
  {"The river current gently takes you east.", "$1n gently flows away to the east.",
−
 
+
    "You gently flow a little further eastwards.", "$1n flows in from the west."}, 5);
−
dilcopy watercurrent@basemove(DIR_EAST,{
+
end
−
          "The river current gently takes you east.",  
+
</pre>
−
          "$1n gently flows away to the east.",  
+
Swimming east with the current is easy (0); west, upstream, is harder (20). See [[Help/Swimming|help swimming]].
−
          "You gently flow a little further eastwards.",  
 
−
          "$1n flows in from the west."},
 
−
          5);
 
−
end</nowiki>
 
  
−
=== Flee ===
+
=== Climbing ===
 +
<code>climb &lt;direction&gt;</code> through an exit with <code>EX_CLIMB</code> checks the climb skill and dexterity against the exit's difficulty, with 5 more for each point the climber is drunk, and costs 6 endurance. A failed climber falls and takes 5 hit points for each full 10 points of failure (another number with an extra <code>$climb_&lt;direction&gt;</code> on the room). See [[Manual:Zone Manual/The Room Section/Climbing|Climbing]].
  
−
For a skill like flee, the difficulty could be an expression of the character's and opponent levels compared.
+
=== Searching ===
 +
<code>search &lt;direction or exit name&gt;</code> looks for an exit with <code>EX_HIDDEN</code>: a check of the search skill and brain against the exit's difficulty (<code>search_dil@basemove</code>). Each search costs 10 endurance (<code>SEARCH_DRAIN_AMOUNT</code>), and a player with less than 10 can't search. A found exit stays found for that player only. Gods always find it. See [[Manual:Game Mechanics/Rooms#Secret doors|Rooms]] and [[Help/Search|help search]].
  
−
  +5: For each level better than the opponent
+
=== Picking locks ===
−
  0: Same level, no modifier
+
<code>pick</code> checks the pick lock skill and dexterity against the exit's difficulty, or a container's own <code>difficulty</code>. A result below 0 fails and costs that much endurance. <code>EX_PICKPROOF</code> can't be picked, and a door without a key has no keyhole to pick.
−
  -5; For each level worse than the opponent
 
  
−
So a level 5 PC fighting a level 1 rabbit gets a +40 bonus to flee. Since an NPC does not have skills, generally its level can be used as its skill. So a level 50 NPC
+
=== Fleeing ===
−
has a flee skill of 50.
+
<code>flee</code> (<code>flee@skills</code>) needs 20 endurance and costs 20. It is an opposed check: the flee skill, dexterity and brain of the one fleeing against the dexterity and brain of their opponent (<code>skillbattle2</code>, so a monster's flee skill is its dexterity and brain). The result doesn't decide whether the flight succeeds, but how it goes:
 +
* above -35: a clean escape;
 +
* -35 or worse: the opponent gets a free blow as the character flees, with 50 minus the result added to its roll;
 +
* -50 or worse: in one case of five the character panics instead, and stays in the fight.
 +
The direction is random, among the exits that can be used; an extra made with <code>NO_FLEE_LEAVE</code> on the room blocks the directions it names. See [[Help/Fleeing|help fleeing]].
  
−
=== Search ===
+
== Weapon and spell skills ==
 +
A player's skill in a weapon is how well they attack with it; half of it is how well they defend against it. With a weapon they haven't practised, they use the skill of its family, and with neither they attack at -25. A monster attacks with its family skill and defends with half of it.
  
−
On any hidden item is a 'difficulty' rating on a scale of 0-100. It could technically go from 0-250 but that's just crazy.
+
Spells are much the same: a player casts with their skill in the spell itself, and resists a spell with half their skill in it or their skill in its sphere, whichever is higher; a monster casts with its sphere skill and resists with half of it. The numbers are on [[Manual:Game Mechanics/Combat|Combat]].
−
It is denoted in the zone file as below with X being a number between 0 and 100:<br>
 
−
<nowiki>open {EX_OPEN, EX_CLOSE, EX_HIDDEN} difficulty X; </nowiki>
 
−
<br>
 
−
Searching depends on the searcher's skill level in searching as well as their brain ability. Each search attempt costs 20 endurance so that the player knows something is there.
 
−
The difficulty you choose for hidden exits is also the same difficulty the door would need to be if the lock were pick-able as there cannot be more than one difficulty per exit.
 
−
If a player's skill is average (50) then the skill check is to see the result of <code>(1d100 + skill) - 100 </code>. Another way to note it would be <code>rnd(1,100) + skill - 100</code> If the result is above 0 the search will be successful. Therefore if your skill is 0 you always fail an average swim roll is > 100. If your skill is 75 for an average swim, you succeed 75% of the time. If your skill is 100 then you always succeed. Remember that the open-ended roll can of course always offset even a sure success or fail.
 

Latest revision as of 06:27, 15 November 2026

This page explains how skills, spells and weapon skills are kept, raised and checked, with the checks the game makes for swimming, climbing, searching, picking locks and fleeing as examples. How to write a check of your own in DIL is in the section on the skill check. The players' side is in help skills.

Four trees

A character's knowledge is kept in four trees: abilities, skills (SKI_*), spells (SPL_*) and weapons (WPN_*). The constants are in vme/include/values.h; the names and the race and profession modifiers in vme/etc/: abilities.def, spells.def, weapons.def, and for skills commands.def. Spells and weapons are grouped in categories: the spell spheres (fire, frost, mind...) and the weapon families (axe and hammer, sword, club and mace, polearm, natural, special). See skills, spells and weapons.

Players

A player has a value in every skill, spell and weapon, and trains them one at a time with skill points (see Levels). A practice raises a skill by 5 while it is below 10, by 4 below 20, by 3 below 40, by 2 below 75 and by 1 from 75. Practised once every level, a skill reaches 40 after 11 practices, 75 after 29 and 100 after 53. A practice also raises the category above it (such as "sword" above "long sword") to half the new value, when the category is lower.

Monsters

A monster has no skills. Where a player would use a skill, a monster uses the ability that goes with it: in a climb, its dexterity; when it swims, its constitution. A monster has weapon and spell skills only by category: one value for all swords, one for all fire spells. They are set as percentages in the zone, see Monsters.

What a value means

Skills and difficulties use the same scale. As a rule of thumb for choosing a difficulty:

Value Meaning
0 No idea how to do it.
40 An ordinary person, an ordinary swimmer.
100 The best a human could be.
200 Far beyond any human.

A player can train a skill to about 110 at most, and much less in skills their race and profession don't suit (see Levels); magic can add to it.

The skill check

A check against a difficulty (see Introduction):

result = open-ended 1d100 + skill - difficulty - 50

It succeeds when the result is above 0, which is half the time when skill and difficulty are equal. For a player, "skill" is (2 × skill + ability) / 3; for a monster it is the ability. The result is also a measure of how well or how badly it went.

In DIL, use the functions in skills.zon:

Function What it checks
skillchecksa@skills(skill, ability, difficulty) self against a difficulty, as above.
skillchecksau@skills(u, skill, ability, difficulty) the same for the character u.
skillbattle1@skills(skill, ability, opponent, ability2) self against an opponent: roll + own ability + own skill - opponent's ability - opponent's skill (in the same skill) - 50. A monster's skill counts as its ability.
skillbattle2@skills(skill, abil1, abil2, opponent, oabil1, oabil2) self against an opponent, each side with two abilities (two parts the first, one part the second), and for a player two parts skill to one part those abilities.
skillresist@function(aa, ad, sa, sd) the opposed check from numbers: roll + aa + sa - ad - sd - 50.

They all roll openroll(100, 5) and return the result; above 0 is a success. A check of your own, in a template put on a room:

dilbegin lift_rock();
external
   integer skillchecksau@skills(u : unitptr, skillidx : integer, abiidx : integer, difficulty : integer);
var
   hm : integer;
code
{
   :start:
   wait(SFB_CMD, command("lift"));
   block;
   // the one who typed it: climbing skill and strength, against a difficulty of 60
   hm := skillchecksau@skills(activator, SKI_CLIMB, ABIL_STR, 60);
   if (hm > 0)
      act("You lift the rock.", A_ALWAYS, activator, null, null, TO_CHAR);
   else
      act("The rock doesn't move.", A_ALWAYS, activator, null, null, TO_CHAR);
   goto start;
}
dilend

In a template on a room, self is the room, so use skillchecksau@skills with the character; skillchecksa@skills checks self and fits a template running on the character.

Difficulties on exits

An exit has one difficulty, 0 to 250, which every check through that exit uses: searching for it if it is hidden, climbing it, swimming through it and picking its lock.

west to cave difficulty 30 open {EX_OPEN_CLOSE, EX_CLOSED, EX_LOCKED, EX_HIDDEN}
   keyword {"boulder"} key cave_key;

Examples from the game

Swimming

A character moving into or out of a room with movement SECT_WATER_SWIM must have swim on or use swim <direction>. Each move makes a check (vme/src/act_movement.cpp):

roll + (2 × swimming + CON) / 3 - (difficulty of the exit - bonus) - 50

The bonus is 50 for the arthropod races, 80 for an amphibian and 100 for a fish (the extras $is_amphib and $is_fish). A result below 0 means the swimmer flounders: they don't move, and lose a hit point for each full 10 points below 0; it can drown them. Rooms with SECT_WATER_SAIL are deep water: a character can't enter them without a boat, and swimming out of them to land adds 150 to the difficulty.

A river can carry swimmers along with watercurrent@basemove(direction, messages, beats): every 5 seconds it counts up, and after beats counts it carries everyone and everything in the room through the exit. Characters make the swimming check against that exit's difficulty first (in DIL, so with openroll(100, 5)); one who fails loses the hit points but is carried along all the same. From the forest of Haon-Dor in haon_dor.zon, shortened:

lightriver
title "On the River in Haon-Dor"
descr
"The river slowly flows east towards the village of Udgaard."
movement SECT_WATER_SWIM
west to darkriver difficulty 20 descr
  "Much further upstream the forest becomes more dense.";
east to river@udgaard difficulty 0 descr "The river continues to the east.";
dilcopy watercurrent@basemove(DIR_EAST,
   {"The river current gently takes you east.", "$1n gently flows away to the east.",
    "You gently flow a little further eastwards.", "$1n flows in from the west."}, 5);
end

Swimming east with the current is easy (0); west, upstream, is harder (20). See help swimming.

Climbing

climb <direction> through an exit with EX_CLIMB checks the climb skill and dexterity against the exit's difficulty, with 5 more for each point the climber is drunk, and costs 6 endurance. A failed climber falls and takes 5 hit points for each full 10 points of failure (another number with an extra $climb_<direction> on the room). See Climbing.

Searching

search <direction or exit name> looks for an exit with EX_HIDDEN: a check of the search skill and brain against the exit's difficulty (search_dil@basemove). Each search costs 10 endurance (SEARCH_DRAIN_AMOUNT), and a player with less than 10 can't search. A found exit stays found for that player only. Gods always find it. See Rooms and help search.

Picking locks

pick checks the pick lock skill and dexterity against the exit's difficulty, or a container's own difficulty. A result below 0 fails and costs that much endurance. EX_PICKPROOF can't be picked, and a door without a key has no keyhole to pick.

Fleeing

flee (flee@skills) needs 20 endurance and costs 20. It is an opposed check: the flee skill, dexterity and brain of the one fleeing against the dexterity and brain of their opponent (skillbattle2, so a monster's flee skill is its dexterity and brain). The result doesn't decide whether the flight succeeds, but how it goes:

  • above -35: a clean escape;
  • -35 or worse: the opponent gets a free blow as the character flees, with 50 minus the result added to its roll;
  • -50 or worse: in one case of five the character panics instead, and stays in the fight.

The direction is random, among the exits that can be used; an extra made with NO_FLEE_LEAVE on the room blocks the directions it names. See help fleeing.

Weapon and spell skills

A player's skill in a weapon is how well they attack with it; half of it is how well they defend against it. With a weapon they haven't practised, they use the skill of its family, and with neither they attack at -25. A monster attacks with its family skill and defends with half of it.

Spells are much the same: a player casts with their skill in the spell itself, and resists a spell with half their skill in it or their skill in its sphere, whichever is higher; a monster casts with its sphere skill and resists with half of it. The numbers are on Combat.