Manual:DIL Manual/UNIT ST PC
UNIT_ST_PC
Constant (integer, vme.h: 0x02).
A player character. u.type == UNIT_ST_PC is true for a player, also one who is switched into a monster (the monster itself stays UNIT_ST_NPC). The type of a unit is in its type field; the four unit types are bits, so they can be combined with |.
Fields
Players have the fields of all characters (see UNIT_ST_PC and UNIT_ST_NPC) and these, which only players have: acc_balance, acc_total, ability_costs, ability_levels, ability_points, birth, crimes, drunk, editing, full, guild, hometown, idx, info, lastroom, lifespan, pcflags, playtime, profession, prompt, quests, skill_costs, skill_levels, skill_points, skills, spell_costs, spell_levels, thirst, vlevel, weapon_costs, weapon_levels.
Notes
- Every unit, whatever its type, has the general fields: name, names, title, descr, outside_descr, inside_descr, extra, type, symname, nameidx, zoneidx, zone, key, outside, inside, next, gnext, gprevious, flags, manipulate, openflags, opendiff, weight, baseweight, capacity, height, light, bright, illum, minv, alignment, hp, max_hp, loadcount, hasfunc, spells.
- In the global list all players come first:
ghead()starts with them, and a walk with.gnextcan stop at the first unit that isn'tUNIT_ST_PC. - On a player,
level,vlevel,exp,max_hp,profession,lifespan,abilities,skills,spells,weaponsand their*_levelscan only be assigned by a program in a zone with access level 0 (the fourth column ofvme/etc/zonelist). Elsewhere they can be read, but an assignment stops the program with a type error in the log. - Reading a field the unit doesn't have fails, and a failed value is false in every comparison: test the type first.
Example
dilbegin hungry(pc : unitptr);
code
{
if (pc.type != UNIT_ST_PC)
return;
if (pc.full < 4)
sendtext("Your stomach rumbles.<br/>", pc);
return;
}
dilend
Tells a player who is getting hungry; full exists only on players.