Manual:DIL Manual/getaffects()
Jump to navigation
Jump to search
getaffects()
Function (stringlist). Lists the affects on a unit, one string of numbers each.
getaffects(u : unitptr)
For each affect on u (spells, poison, transfers of abilities and skills from
equipment...), the list gets one string of six numbers separated by commas:
id,apf,data0,data1,data2,duration
id: the affect'sID_value (vme/include/vme.h).
Transfer affects, the ones equipment gives while worn, have it negative.
apf: theAPF_function that applies it (vme.h), such as
APF_ABILITY (0).
data0todata2: the affect's data, as given to
addaff(); for an ability transfer,data0is the ability anddata1the amount.
duration: the beats left (see addaff()), or -1 for an affect without end.
Take a string apart with split() and atoi().
Parameters
| Name | Type | Meaning |
|---|---|---|
| u | unitptr | Any unit: a character, an object or a room. |
Returns
Stringlist: one entry per affect, in the order the unit holds them; empty when there are none.
It fails when u is null.
Notes
- The old manual described two strings per affect with a text description first. That is no
longer so: one string each, numbers only.
- To test for one affect, isaff() is simpler.
Example
dilbegin show_affects(pc : unitptr, u : unitptr);
var
sl : stringlist;
parts : stringlist;
i : integer;
n : integer;
code
{
sl := getaffects(u);
n := length(sl);
i := 0;
while (i < n)
{
parts := split(sl.[i], ",");
sendtext("Affect " + parts.[0] + ", " + parts.[5] + " beats left.<br/>", pc);
i := i + 1;
}
quit;
}
dilend
Shows a player the id and time left of each affect on a unit; spells.zon's identify reads the same list to describe an item's transfers.