Manual:DIL Manual/set weight base
Jump to navigation
Jump to search
set_weight_base()
Procedure. Sets a unit's own weight.
set_weight_base(u : unitptr, weight : integer)
Sets the baseweight of u, its weight when empty.
Its weight (the base weight plus what is inside it) changes by the
same amount, and so does the weight of every unit it is in: the bag it is in, the player
carrying the bag, the room.
The baseweight and weight fields can't be assigned; this is how they
are changed.
Parameters
| Name | Type | Meaning |
|---|---|---|
| u | unitptr | The unit. |
| weight | integer | Its new base weight, in pounds. |
Notes
- Works on every kind of unit. With a null unit nothing happens.
- Nothing checks the value: a negative weight is accepted.
- A player may end up carrying more than they can; nothing makes them drop it.
Example
dilbegin make_light(pc : unitptr, item : unitptr);
code
{
if (item.type != UNIT_ST_OBJ)
return;
set_weight_base(item, item.baseweight / 2); // what holds it gets lighter too
act("$2n feels lighter.", A_ALWAYS, pc, item, null, TO_CHAR);
return;
}
dilend
Halves an object's weight.