Manual:DIL Manual/fnpri
Jump to navigation
Jump to search
fnpri
Keyword. Option of dilbegin: where the program goes in its unit's list of programs.
dilbegin fnpri(n) name(...);
A unit can run several programs (and built-in special functions). They sit in a list sorted by priority, lowest number first, and every event is offered to them in that order. A program that does block stops the event from reaching the ones after it, and priority keeps the later ones from getting any event at all. fnpri sets the number; without it a template gets FN_PRI_CHORES (40).
Parameters
| Name | Type | Meaning |
|---|---|---|
| n | integer constant | 1 to 254. A number or a constant, with + or - another one: fnpri(FN_PRI_BLOCK-1).
|
The constants are in vme.h:
| Constant | Value | Meant for |
|---|---|---|
| FN_PRI_SYS | 1 | system programs |
| FN_PRI_DEATH | 2 | dealing with death |
| FN_PRI_BODY | 5 | the body: regaining hit points and the like |
| FN_PRI_COMBAT | 10 | moves in combat |
| FN_PRI_RESCUE | 20 | rescuing someone rather than passing by |
| FN_PRI_BLOCK | 25 | blocking commands |
| FN_PRI_MISSION | 30 | an NPC on an important mission |
| FN_PRI_CHORES | 40 | everything else (the default) |
Notes
- 0 and anything above 254 stop vmc with "Illegal priority value". The value must be known when compiling: variables and other expressions are not allowed.
- A new program goes after the ones with the same or a lower number, so among equals the oldest comes first.
- The order is only among one unit's programs. Which unit in a room hears an event first is a different matter.
- A program that should
blocka command before another program on the same unit acts on it needs the lower number. - The priority is stored with each copy. Changing
fnpriin the template doesn't move copies already saved on players' things.
Example
dilbegin fnpri(FN_PRI_BLOCK) guard_east();
code
{
:start:
wait(SFB_CMD, command("east") and (activator.type == UNIT_ST_PC));
act("$1n steps in front of you and shakes $1s head.",
A_ALWAYS, self, null, activator, TO_VICT);
block;
goto start;
}
dilend
On a guard NPC: stops players going east, ahead of the guard's other programs, which have the default priority.