Modding:Thing

From DoomRL Wiki

Revision as of 01:51, 5 September 2011 by Game Hunter (Talk | contribs)

Jump to: navigation, search

A thing in DoomRL is a base class that is inherited by beings and items (and the player). This means that beings and items are also things. The thing class is responsible for positioning, flags, resistances, and custom properties.

Properties

Thing
Byte id Determines the type of thing (e.g. former human, chaingun, etc) that this is. An item and a being may have the same id without being the same type of thing. This property is read-only.
String sid Ids and sids are in one-to-one correspondence. It is generally preferable to write out sids rather than ids to make code more readable. This property is read-only.
DWord uid Every instantiated thing has a distinct uid. (In theory, the game could run out of uids and be forced to repeat, but there are enough possibilities that this is inplausible.) This property is read-only.
Char picture The character used to represent the thing when it is on the map.
Color color The color used to draw the picture when the thing is on the map. This color is sometimes used in menus as well.
String name This string is used to describe the thing in various game messages.
String nameplural This is the plural of the name string, used in a few game messages.
Word sprite This determines the sprite that is used to represent the thing in the graphical version.
LongInt x This is the thing's x-coordinate on the map. Typically, this is 0 if the thing isn't on the map. This property is read-only.
LongInt y This is the thing's y-coordinate on the map. Typically, this is 0 if the thing isn't on the map. This property is read-only.
Integer res_bullet This is the bullet resistance associated with the thing.
Integer res_melee This is the melee resistance associated with the thing.
Integer res_shrapnel This is the shrapnel resistance associated with the thing.
Integer res_acid This is the acid resistance associated with the thing.
Integer res_fire This is the fire resistance associated with the thing.
Integer res_plasma This is the plasma resistance associated with the thing.
userdata __ptr This is a pointer to the pascal object representing the thing. When the pascal object is deallocated, this field is set to nil.

API

Thing
void thing.displace(Thing self, Coord where)
void thing.destroy(Thing self)
boolean thing.flags_get(Thing self, Flag flag)
void thing.flags_set(Thing self, Flag flag, boolean value)
value thing.property_get(Thing self, string property)
void thing.property_set(Thing self, string property, value value)
integer thing.res_get(Thing self, Resistance resistance)
void thing.res_set(Thing self, Resistance resistance, integer value)
Coord Thing:get_position()
integer Thing:distance_to(Thing or Coord other)
void Thing:add_property(string key, value value)
void Thing:remove_property(string key)
boolean Thing:has_property(string key)
value Thing:get_property(string key)
void Thing:set_property(string key, value value)

thing.displace(Thing self, Coord where)
Changes the thing's position to where. This doesn't do any collision checking, so be careful.

thing.destroy(Thing self)
Deallocates the memory associated with the thing. Generally, the item or being-specific versions should be used instead (although even these are rarely useful to modders).

thing.flags_get(Thing self, Flag flag) → boolean
Thing.flags[Flag flag] → boolean
Determines whether the given flag is present in the thing's flag set.

thing.flags_set(Thing self, Flag flag, boolean value)
Thing.flags[Flag flag] = boolean value
Sets or clears the given flag from the thing's flag set.

thing.property_get(Thing self, string property) → value
Gets value of the given built-in property. This should usually be avoided in favor of set_property.

thing.property_set(Thing self, string property, value value)
Sets the value of the given built-in property. This should usually be avoided in favor of get_property.

thing.res_get(Thing self, Resistance resistance) → integer
Thing.resistance[Resistance resistance] → integer
Gets the given resistance of the thing.

thing.res_set(Thing self, Resistance resistance, integer value)
Thing.resistance[Resistance resistance] = integer value
Sets the given resistance of the thing.

Thing:get_position() → Coord
Returns the thing's position. This is a newly allocated coord; it is independent of the thing.

Thing:distance_to(Thing or Coord other) → integer
Returns the distance from the thing to another position or thing.

Thing:add_property(string key, value value)
Adds a custom property to the thing with the given initial value. value is optional; it defaults to false.

Thing:remove_property(string key)
Removes the given custom property from the thing.

Thing:has_property(string key) → boolean
Determines whether the thing has a custom property with the given name.

Thing:get_property(string key) → value
Thing[string key] → value
Gets the value of the given built-in or custom property. Usually the dot notation for table indexing is used.

Thing:set_property(string key, value value)
Thing[string key] = value value
Sets the given built-in or custom property of the thing to the given value. Usually the dot notation for table indexing is used.
Personal tools