Manual:DIL Manual/fits()
Jump to navigation
Jump to search
fits()
Function (string). Tells whether an object is the right size for a character.
fits(ch : unitptr, obj : unitptr, pos : integer)
Compares the size (height) of obj with that of ch for
wearing it in position pos, and returns "" when it fits or a few words
saying why not.
Parameters
| Name | Type | Meaning |
|---|---|---|
| ch | unitptr | The character (PC or NPC) who would wear it. |
| obj | unitptr | The object. |
| pos | integer | A WEAR_* position from vme.h, or -1 for the position the object is made for (from its manipulate flags).
|
Returns
String: "" when it fits, otherwise way too small, too small, too large
or way too large (and error when the character's height is 0). It fails when
ch is null or not a character, or obj is null or not an object.
Notes
- The object's height is taken as a percentage of the character's. For most positions it fits
from 50% to 150%: below 25% is way too small, above 225% way too large. Body armour
(WEAR_BODY) is stricter: 60% to 140%, way below 30% or above 210%.
- An object with no height (0) is way too small for everyone.
- Always
""for something not worn in that position: an object that can't be
worn with -1, a held object that isn't a weapon (WEAR_HOLD), or aposthat isn't aWEAR_*value.
- It only checks the size, not whether the position is free or the character may use it.
Example
dilbegin string fit_note(pc : unitptr, item : unitptr);
var
s : string;
code
{
s := fits(pc, item, -1);
if (s == "")
return("");
return("(" + s + " for you) ");
}
dilend
A note for a shop list when an item doesn't fit the customer, as the shops in function.zon show it.