Entities are constructed with a series of components that describe their behaviour. Since custom game settings are server-bound, this section only applies to server entity descriptions. For more general information about how entities are constructed, as well as a list of all the available components and their properties, check out the documentation for Entities.
In particular, there is a family of components with similar names: <i>badger:difficulty_modifier_...</i>
These components are the mechanism in which an entity's properties can be altered based on what difficulty is chosen by the player. Consider this example:
"badger:difficulty_modifier_damage": {
"difficulties": {
"Peaceful": {
"post_multiply": 0.5
},
"Easy": {
"post_multiply": 1.0
},
"Normal": {
"post_multiply": 1.5
},
"Hard": {
"post_multiply": 2.0
}
}
}
Since badger:difficulty_modifier_damage changes the damage of an entity's target actions, attaching this component to an entity would mean that the damage they deal through their target actions would increase as players choose harder difficulties. _See the documentation for these components for a complete description of these properties._
Custom game modes have their own 'Custom' difficulty as they don't rely on traditional difficulty options for modifications such as this, however the same machanism is used to modify entities. Rather than defining a static value for a traditional difficulty, a separate section "custom_game_settings" can be used instead or in tandem:
"badger:difficulty_modifier_damage": {
"difficulties": { ... },
"custom_game_settings": [
{
"setting_name": "unit_damage",
"numeric_modifier_type": "post_multiply",
"scaling_factor": 1.0
}
]
}
Comparing this to the previous example, if an entity in a custom game had this component in it's description, their target actions' damage would instead be modified by _multiplying_ their base damage (which is the damage in the specific target action) by the value set for the unit_damage custom game setting.
A description of each property is as follows:
| Property | Values | Description |
|---|---|---|
| setting_name | any valid custom setting id | The id of the custom game setting whose value you want to use for modifying the entity's property. |
| numeric_modifier_type | pre_add, post_add, pre_multiply, post_multiply | Descriptor for how the value of the custom game setting should be applied to the base value. |
| scaling_factor | any float between (0.0, 1.0] | Scales the value of the custom game setting before it is applied to the entity's base value. |
A special mention here for the "badger:template" component as well. This component can be used for specific entity descriptions to inherit the components from the descriptions of other entities. This can be really useful for custom game settings since we can define a single difficulty modifier elsewhere and apply it to any number of different entities. Just define the difficulty modifier on a generic entity and then include its identifier in the template component for your specific entity and it will be modified the same as if you added it directly. Note that if an entity inherits from another and they both define the same component, the resulting component will have a combination of both copmonents' properties, using the property of the inheriting entity's components when they're defined for both.