xFrednet / spaceship-factory

A Tower defense game where the tower to defend is actually a factory flying through space :)
2 stars 0 forks source link

Crate a loot table with key value keys #27

Closed xFrednet closed 4 years ago

xFrednet commented 4 years ago

Create a loot table thingy that can be referenced by meteoroids and other stuff to get items.

Possible steps:

xFrednet commented 4 years ago

Structure

{
    "loot_tables": {
        <loot_table_id>: [
            {
                "name": <pool_name>,
                "entries": [
                    {
                        "type": ("item"|"loot_table"),
                        "content_id": (<item_name>|<loot_table_id>),
                        "chance": (0.0-1.0),
                        "count_matrix": [<chance>, <count>]
                    }
                ]
            }
        ]
    }
}

Example

{
    "loot_tables": {
        "iron_meteoroid_destruction": [
            {
                "name": "default",
                "entries": [
                    {
                        "type": "item",
                        "content_id": "sf:item:iron_ore",
                        "chance": 1,
                        "count_matrix": [
                            0.5, 1,
                            0.3, 2,
                            0.2, 3
                        ]
                    },
                    {
                        "type": "item",
                        "content_id": "sf:item:iron_nugget",
                        "chance": 0.25,
                        "count_matrix": [
                            1, 1
                        ]
                    }
                ]
            }
        ]
    }
}
xFrednet commented 4 years ago

The loot tables cant be stored inside the ItemInfoManager because we need to use the manager to get the item ids. This would lead to a cyclic dependency (This is sadly blocked by GDScript)

xFrednet commented 4 years ago

Tests and LootTableManager.get_loot_table_item_entities() should be the last things to add before this can be merged and closed