Difference between revisions of "Manual:DIL Manual/set weight base"
Jump to navigation
Jump to search
(Created page with "= set_weight_base( u : unitptr, i : integer ) = ''' Parameters ''' u : the unit on which you wish to alter the weight. i : the new base weight ''' Description ''' Use th...") |
(checked against the compiler and the interpreter; example compiles) |
||
| (2 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
| − | = set_weight_base( | + | = set_weight_base() = |
| + | '''Procedure.''' Sets a unit's own weight. | ||
| − | + | set_weight_base(u : unitptr, weight : integer) | |
| − | |||
| − | |||
| − | ' | + | Sets the [[Manual:DIL Manual/baseweight|baseweight]] of <code>u</code>, its weight when empty. |
| − | + | Its [[Manual:DIL Manual/weight|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 <code>baseweight</code> and <code>weight</code> fields can't be assigned; this is how they | ||
| + | are changed. | ||
| + | |||
| + | == Parameters == | ||
| + | {| class="wikitable" | ||
| + | ! 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 == | ||
| + | <pre> | ||
| + | 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 | ||
| + | </pre> | ||
| + | Halves an object's weight. | ||
| + | |||
| + | == See also == | ||
| + | * [[Manual:DIL Manual/set weight|set_weight()]] | ||
| + | * [[Manual:DIL Manual/baseweight|baseweight]] | ||
| + | * [[Manual:DIL Manual/weight|weight]] | ||
| + | * [[Manual:DIL Manual/can carry()|can_carry()]] | ||
Latest revision as of 23:21, 14 November 2026
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.