Manual:DIL Manual/profession
Jump to navigation
Jump to search
Contents
profession
Field (integer, read/write; units: PC).
pc.profession : integer
The player's profession: a PROFESSION_ constant from values.h, PROFESSION_FIGHTER (0) to PROFESSION_BARBARIAN (12); PROFESSION_MAX is one more than the last. A new player has none (-1) until choosing one. The profession's modifiers in the .def files (abilities.def, ...) count in training costs, and ProfessionName@professions gives its name.
Notes
- Players only. On an NPC, 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. - A player without a profession reads as -1 in most zones but as 255 in a zone with access level 0 (there the value is read as unsigned). Test for a real profession with
(p >= 0) and (p < PROFESSION_MAX), which works either way, as basis.zon does. - vmc also accepts it on a
cmdptr, but a command has no profession: the value is an error, which aniftakes as false (logging "DIL getbool error"). An assignment there stops the program.
Example
dilbegin string profession_text(pc : unitptr);
external
string ProfessionName@professions(prof_xxx : integer);
var
p : integer;
code
{
p := pc.profession;
if ((p < 0) or (p >= PROFESSION_MAX))
return ("You have not chosen a profession yet.");
return ("Your profession is: " + ProfessionName@professions(p) + ".");
}
dilend
Tells a player the profession, as the guild masters in guilds.zon do.