fabio-t / alone-rl

A free to use, survival open-world roguelike game
GNU Affero General Public License v3.0
38 stars 2 forks source link

Armor from bark or hides #37

Open fabio-t opened 6 years ago

fabio-t commented 6 years ago
fabio-t commented 6 years ago

Bark armour was easy; hide armour will be trickier.

In the former we simply set the protection values in the item yaml. For hides, we want the protection values to depend on the source creature.

This means that we'll probably need regex support in the crafting code. For example:

Hide:
    source_names: ["(\w)'s corpse"]
    name: "$1 hide"

The above would find the first corpse in the inventory with a name matching the source_names pattern, capturing the word between parentheses. The corresponding capture will then go to the object name. Eg, "a big buffalo's corpse" would create an object with tag "hide" and name "buffalo hide".

We then need a way of inheriting properties from the source. The problem here lies in which source to use. I can probably use a simple approach such as: only the first source is used to get properties.

Hide:
    source_names: ["(\w)'s corpse"]
    name: "$1 hide"
    inherit_properties: [Skin]

This should allow, with some Reflection trick, getting the component dynamically (if present) and passing it to the newly created object.