Difference between revisions of "Manual:DIL Manual/experience()"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
| + | = experience() = | ||
| + | '''Procedure.''' Gives a player experience points, or takes them away. | ||
| + | experience(amount : integer, pc : unitptr) | ||
| − | < | + | Adds <code>amount</code> to the player's experience (<code>pc.exp</code>); a negative amount takes experience away. The player doesn't gain a level from it: when the experience reaches the next level they are told "You can now raise a level by using the 'level' command!" and raise it themselves. |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | == Parameters == | |
| + | {| class="wikitable" | ||
| + | ! Name !! Type !! Meaning | ||
| + | |- | ||
| + | | amount || integer || Experience to add; negative to take away. | ||
| + | |- | ||
| + | | pc || unitptr || The player. | ||
| + | |} | ||
| + | |||
| + | == Notes == | ||
| + | * Only mortal players: on an NPC, an object, a room or null nothing happens, and a god (level <code>IMMORTAL_LEVEL</code>, 200, or more) keeps the experience they have. | ||
| + | * Every call on a player is logged in vme.log: "''name'' gained ''amount'' experience from unit ''symname''." | ||
| + | * Experience taken away never drops below what level 1 needs. | ||
| + | |||
| + | == Example == | ||
| + | <pre> | ||
| + | dilbegin quest_reward(pc : unitptr, xp : integer); | ||
| + | code | ||
| + | { | ||
| + | if (pc.type != UNIT_ST_PC) | ||
| + | return; | ||
| + | if (xp > 0) | ||
| + | { | ||
| + | experience(xp, pc); | ||
| + | act("You receive $2t experience points.", A_ALWAYS, pc, itoa(xp), null, TO_CHAR); | ||
| + | } | ||
| + | return; | ||
| + | } | ||
| + | dilend | ||
| + | </pre> | ||
| + | Rewards a player at the end of a quest. Adapted from quests.zon. | ||
| + | |||
| + | == See also == | ||
| + | * [[Manual:DIL Manual/exp|exp]] | ||
| + | * [[Manual:DIL Manual/exptol|exptol]] | ||
| + | * [[Manual:DIL Manual/level|level]] | ||
Latest revision as of 23:23, 14 November 2026
experience()
Procedure. Gives a player experience points, or takes them away.
experience(amount : integer, pc : unitptr)
Adds amount to the player's experience (pc.exp); a negative amount takes experience away. The player doesn't gain a level from it: when the experience reaches the next level they are told "You can now raise a level by using the 'level' command!" and raise it themselves.
Parameters
| Name | Type | Meaning |
|---|---|---|
| amount | integer | Experience to add; negative to take away. |
| pc | unitptr | The player. |
Notes
- Only mortal players: on an NPC, an object, a room or null nothing happens, and a god (level
IMMORTAL_LEVEL, 200, or more) keeps the experience they have. - Every call on a player is logged in vme.log: "name gained amount experience from unit symname."
- Experience taken away never drops below what level 1 needs.
Example
dilbegin quest_reward(pc : unitptr, xp : integer);
code
{
if (pc.type != UNIT_ST_PC)
return;
if (xp > 0)
{
experience(xp, pc);
act("You receive $2t experience points.", A_ALWAYS, pc, itoa(xp), null, TO_CHAR);
}
return;
}
dilend
Rewards a player at the end of a quest. Adapted from quests.zon.