Solarus quests
1.6
Quest maker's reference
|
A destructible object is an entity that can be cut or lifted by the hero and that may hide a pickable treasure.
This type of map entity can be declared in the map data file. It can also be created dynamically with map:create_destructible().
Destructible objects can be customized in various ways. You can allow the hero to lift them or to cut them. The ones that can be lifted may require a minimum level of the "lift"
ability. Their size is always 16x16 pixels (like the hero).
Destructible objects are particular map entities. Therefore, they inherit all methods from the type map entity.
See Methods of all entity types to know these methods.
The following methods are specific to destructible objects.
Returns what pickable treasure this object will drop when being lifted, when being cut or when exploding.
nil
means no item (in this case, other return values are nil
too).1
means the first variant).nil
means that the treasure is not saved.Sets the pickable treasure that this object will drop when being lifted, when being cut or when exploding.
item_name
(string, optional): Name of an equipment item. nil
or no value means no item.variant
(number, optional): Variant of this equipment item (1
means the first variant). The default value is 1
.savegame_variable
(string, optional): Name of the boolean value that stores in the savegame whether the treasure dropped is found. nil
or no value means that the treasure is not saved.Returns the sound to be played when this object is cut or broken.
nil
means that no sound will be played.Sets the sound to be played when this object is cut or broken.
destruction_sound_id
(string): Id of the destruction sound. nil
means that no sound will be played.Returns whether this object can be cut by the sword.
true
if this object can be cut by the sword.Sets whether this object can be cut by the sword.
can_be_cut
(boolean, optional): true
to allow the player to cut this object with the sword. No value means true
.Returns whether this object explodes when it is hit or after a delay when it is lifted.
true
if this object can explode.Sets whether this object explodes when it is hit or after a delay when it is lifted.
can_explode
(boolean, optional): true
to make the object able to explode. No value means true
.Returns whether this object regenerates after a delay when it is destroyed.
true
if this object can regenerate.Sets whether this object regenerates after a delay when it is destroyed.
can_regenerate
(boolean, optional): true
to make the object able to regenerate. No value means true
.Returns the number of life points that an enemy loses when the hero throws this object at it.
0
means that enemies will ignore this object.Sets the number of life points that an enemy loses when the hero throws this object at it.
damage_on_enemies
(number): The number of life points to remove to an enemy hit by this object. 0
means that enemies will ignore this object.Returns the ground defined by this destructible object on the map.
The presence of a destructible object can modify the ground of the map. The ground is usually "wall"
, but it may sometimes be "traversable"
, or for example "grass"
to make the destructible object traversable too but with an additional grass sprite below the hero.
Events are callback methods automatically called by the engine if you define them.
Destructible objects are particular map entities. Therefore, they inherit all events from the type map entity.
See Events of all entity types to know these events.
The following events are specific to destructible objects.
Called when the hero looks this destructible object, that is, when the player presses the action key but is not allowed to lift the object.
By default, nothing happens in this case. You can for example show a dialog to give the player a hint like "This is too heavy".
Called when the hero has just cut this destructible object.
Called when this destructible object is exploding.
If destructible:get_can_explode() is true
, the destructible object explodes when there is an explosion nearby or when the hero lifts it, after a delay.
Called when this destructible object regenerates.
If destructible:get_can_regenerate() is true
, the destructible object regenerates after a delay when it was lifted or exploded.