Difference between revisions of "Manual:DIL Manual/UNIT ST PC"
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
| − | + | = UNIT_ST_PC = | |
| − | + | '''Constant''' (integer, vme.h: 0x02). | |
| − | + | A player character. <code>u.type == UNIT_ST_PC</code> is true for a player, also one who is switched into a monster (the monster itself stays <code>UNIT_ST_NPC</code>). The type of a unit is in its <code>type</code> field; the four unit types are bits, so they can be combined with <code>|</code>. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | < | ||
| − | |||
| − | + | == Fields == | |
| − | + | Players have the fields of all characters (see [[Manual:DIL Manual/UNIT ST PC and UNIT ST NPC|UNIT_ST_PC and UNIT_ST_NPC]]) and these, which only players have: [[Manual:DIL Manual/acc balance|acc_balance]], [[Manual:DIL Manual/acc total|acc_total]], [[Manual:DIL Manual/ability costs|ability_costs]], [[Manual:DIL Manual/ability levels|ability_levels]], [[Manual:DIL Manual/ability points|ability_points]], [[Manual:DIL Manual/birth|birth]], [[Manual:DIL Manual/crimes|crimes]], [[Manual:DIL Manual/drunk|drunk]], [[Manual:DIL Manual/editing|editing]], [[Manual:DIL Manual/full|full]], [[Manual:DIL Manual/guild|guild]], [[Manual:DIL Manual/hometown|hometown]], [[Manual:DIL Manual/idx|idx]], [[Manual:DIL Manual/info|info]], [[Manual:DIL Manual/lastroom|lastroom]], [[Manual:DIL Manual/lifespan|lifespan]], [[Manual:DIL Manual/pcflags|pcflags]], [[Manual:DIL Manual/playtime|playtime]], [[Manual:DIL Manual/profession|profession]], [[Manual:DIL Manual/prompt|prompt]], [[Manual:DIL Manual/quests|quests]], [[Manual:DIL Manual/skill costs|skill_costs]], [[Manual:DIL Manual/skill levels|skill_levels]], [[Manual:DIL Manual/skill points|skill_points]], [[Manual:DIL Manual/skills|skills]], [[Manual:DIL Manual/spell costs|spell_costs]], [[Manual:DIL Manual/spell levels|spell_levels]], [[Manual:DIL Manual/thirst|thirst]], [[Manual:DIL Manual/vlevel|vlevel]], [[Manual:DIL Manual/weapon costs|weapon_costs]], [[Manual:DIL Manual/weapon levels|weapon_levels]]. | |
| − | + | ||
| − | + | == Notes == | |
| − | + | * Every unit, whatever its type, has the general fields: [[Manual:DIL Manual/name|name]], [[Manual:DIL Manual/names|names]], [[Manual:DIL Manual/title|title]], [[Manual:DIL Manual/descr|descr]], [[Manual:DIL Manual/outside descr|outside_descr]], [[Manual:DIL Manual/inside descr|inside_descr]], [[Manual:DIL Manual/extra|extra]], [[Manual:DIL Manual/type|type]], [[Manual:DIL Manual/symname|symname]], [[Manual:DIL Manual/nameidx|nameidx]], [[Manual:DIL Manual/zoneidx|zoneidx]], [[Manual:DIL Manual/zone|zone]], [[Manual:DIL Manual/key|key]], [[Manual:DIL Manual/outside|outside]], [[Manual:DIL Manual/inside|inside]], [[Manual:DIL Manual/next|next]], [[Manual:DIL Manual/gnext|gnext]], [[Manual:DIL Manual/gprevious|gprevious]], [[Manual:DIL Manual/flags|flags]], [[Manual:DIL Manual/manipulate|manipulate]], [[Manual:DIL Manual/openflags|openflags]], [[Manual:DIL Manual/opendiff|opendiff]], [[Manual:DIL Manual/weight|weight]], [[Manual:DIL Manual/baseweight|baseweight]], [[Manual:DIL Manual/capacity|capacity]], [[Manual:DIL Manual/height|height]], [[Manual:DIL Manual/light|light]], [[Manual:DIL Manual/bright|bright]], [[Manual:DIL Manual/illum|illum]], [[Manual:DIL Manual/minv|minv]], [[Manual:DIL Manual/alignment|alignment]], [[Manual:DIL Manual/hp|hp]], [[Manual:DIL Manual/max hp|max_hp]], [[Manual:DIL Manual/loadcount|loadcount]], [[Manual:DIL Manual/hasfunc|hasfunc]], [[Manual:DIL Manual/spells|spells]]. | |
| − | + | * In the global list all players come first: <code>ghead()</code> starts with them, and a walk with <code>.gnext</code> can stop at the first unit that isn't <code>UNIT_ST_PC</code>. | |
| − | + | * On a player, <code>level</code>, <code>vlevel</code>, <code>exp</code>, <code>max_hp</code>, <code>profession</code>, <code>lifespan</code>, <code>abilities</code>, <code>skills</code>, <code>spells</code>, <code>weapons</code> and their <code>*_levels</code> can only be assigned by a program in a zone with access level 0 (the fourth column of <code>vme/etc/zonelist</code>). 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 == | |
| − | + | <pre> | |
| − | + | dilbegin hungry(pc : unitptr); | |
| − | + | code | |
| − | + | { | |
| − | + | if (pc.type != UNIT_ST_PC) | |
| − | + | return; | |
| − | + | if (pc.full < 4) | |
| − | + | sendtext("Your stomach rumbles.<br/>", pc); | |
| − | + | return; | |
| − | + | } | |
| − | + | dilend | |
| − | + | </pre> | |
| − | + | Tells a player who is getting hungry; <code>full</code> exists only on players. | |
| − | + | ||
| − | + | == See also == | |
| − | + | * [[Manual:DIL Manual/type|type]] | |
| − | + | * [[Manual:DIL Manual/Fields|Fields]] | |
| − | + | * [[Manual:DIL Manual/UNIT ST NPC|UNIT_ST_NPC]] | |
| − | + | * [[Manual:DIL Manual/UNIT ST PC and UNIT ST NPC|UNIT_ST_PC and UNIT_ST_NPC]] | |
| − | + | * [[Manual:DIL Manual/UNIT ST OBJ|UNIT_ST_OBJ]] | |
| − | + | * [[Manual:DIL Manual/UNIT ST ROOM|UNIT_ST_ROOM]] | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 23:24, 14 November 2026
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.