Ability: container

Description:

Inherits ability containable.

This ability is used for objects which can contain other objects (rooms, bags, players, monsters). Every container is also containable, but you can make an uncontainable container with set_uncontainable().

A container has mass capacity and bulk capacity which specify how much it can hold. A container can be made infinitely capable with set_inifinite_capacity().

The mass of the container is calculated with the formula

mass = own_mass + (mass_factor * inventory_mass) / 100
where own_mass can be set with containable::set_mass(), inventory_mass is the total mass of the inventory and mass_factor expresses what percentage of the inventory mass should be taken into account.

The bulk is calcualted in analogous way.

If you need to make a container then you should probably inherit either class holder or class bag instead of directly inheriting container.

Usage:

#include <ability.h>

inherit CONTAINER;

Functions:

All function in ability containable.

int query_mass_capacity()
Return the mass capacity of the object.

void set_mass_capacity(int m)
Set the mass capacity of the object to m.

void set_infinite_capacity()
Make the capacity of the object infinite (no restrictions on what it can hold).

int query_bulk_capacity()
Return the bulk capacity of the object.

void set_bulk_capacity(int b)
Set the bulk capacity to b.

int query_mass_factor()
Return the mass factor. The mass factor expresses what percentage of the inventory mass should be taken into account.

void set_mass_factor(int f)
Set the mass factor to f.

int query_bulk_factor()
Return the bulk factor. The bulk factor expresses what percentage of the inventory bulk should be taken into account.

void set_bulk_factor(int f)
Set the bulk factor to f.

int query_inventory_mass()
Return the total mass of the inventory (not multpilied by the mass factor).

int query_mass()
Return the mass of the object. The mass is calculated as described above. To get the own mass of the object, use containable::query_mass().

int query_inventory_bulk()
Return the total bulk of the inventory (not multpilied by the bulk factor).

int query_bulk()
Return the bulk of the object. The bulk is calculated as described above. To get the own bulk of the object, use containable::query_bulk().

int move_to_p(object ob)
Return 1 if object ob is allowed to move into this object. Return 0 otherwise. Note that the move is not actually performed.

vararg void move_to(object ob, mixed msg)
Move object ob into this object. Note that no tests are performed on whether the move is allowed. This function does not actually set the environment of ob to this object.

The optional argument msg is the message that should be transmitted in this object (this only happens if this object is a sensor). If msg is a string, then message msg of type /visual/move is transmitted, otherwise raw msg is transmitted (see messages).

int move_from_p(object ob, object dest) {
Return 1 if object ob is allowed to be moved from this object to object dest. Return 0 otherwise. Note that the move is not actually performed.

void move_from(object ob, mixed msg)
Move object ob out of this object. Note that no tests are performed on whether the move is allowed. This function does not actually change the environment of ob.

The optional argument msg is the message that should be transmitted in this object (this only happens if this object is a sensor). If msg is a string, then message msg of type /visual/move is transmitted, otherwise raw msg is transmitted (see messages).

Source code:

/ability/container.c.

See also:

Ability: containable
Class: holder