Interrupt / delverengine

Delver game engine and editor
zlib License
803 stars 81 forks source link

Alternative level templates not recognized #140

Closed PythooonUser closed 4 years ago

PythooonUser commented 4 years ago

Summary

Refactors the class SectionDefinition. Now picks a level template at random which fixes #114. A new property levelTemplateDistribution can be used in section.dat to alter the spawn probabilities. It refers to the index of a level template of the levelTemplates property. If levelTemplateDistribution is not given, the probabilities are equal.

The following example simulates a possible scenario of common, uncommon and rare level templates.

// section.dat
{
  ...,
  "levelTemplateDistribution": [0, 0, 0, 0, 1, 1, 2]
}

Could be useful to define an example section with this new feature in #118.

joshuaskelly commented 4 years ago

Conversely, what do you think about adding a levelTemplateWeight float field to the Level object?

PythooonUser commented 4 years ago

So the array approach is taken from the project, as I saw a lot of it being used. E.g. room and mainRooms in the room builders.

Having a levelTemplateWeight on the Level object might be confusing? It only serves a purpose in that particular szenario. So maybe a new class LevelTemplate might be interesting?

How would such a weighting be validated? The user needs to make sure everything adds up to 1f ideally. If it does not, which template probability gets adjusted? Or should the max/sum weight be taken and then each individual template weight be normalized?

Do you feel controlling the weights using an array is not conrete enough? Do you want to be able to set exact values?