Manual:DIL Manual/exp

From DikuMUD Wiki
Jump to navigation Jump to search

exp

Field (integer, read/write; units: characters).

ch.exp : integer

On a player: the experience points gained in total. On an NPC: the experience it is worth, set with exp in the zone file; when it is killed, its killers share this amount, adjusted for their levels and group size (fight.cpp).

Notes

  • On an object, a room or null it fails.
  • Only a program in a zone with access level 0 (the fourth column of vme/etc/zonelist) can assign it; what counts is the zone of the program running on the unit, not that of a function it calls. Elsewhere vmc accepts the assignment, but at run time the program logs "DIL SERIOUS: ... Type error in lvalue assignemt" and stops. Reading works in every zone. This holds for NPCs as well as players.
  • To give or take experience in the normal way, use experience() from any zone: it logs the gain, tells the player when a new level can be raised, never takes them below the experience of level 1, and leaves gods and NPCs alone. Assigning the field sets the number and nothing else.
  • Stored as a signed 32-bit number.

Example

dilbegin show_exp(pc : unitptr);
code
{
   if (pc.type != UNIT_ST_PC)
      return;
   sendtext("You have " + itoa(pc.exp) + " experience points and you need " +
            itoa(pc.exptol) + " to the next level.<br/>", pc);
   return;
}
dilend

Shows a player's experience, as score does in commands.zon.

See also