1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00
Files
vcmi/docs/modders/Bonus/Bonus_Updaters.md

103 lines
2.5 KiB
Markdown
Raw Normal View History

2024-07-16 20:29:20 +02:00
# Bonus Updaters
2023-08-13 00:17:38 +03:00
Updaters come in two forms: simple and complex. Simple updaters take no
parameters and are specified as strings. Complex updaters do take
parameters (sometimes optional), and are specified as structs.
Check the files in `config/heroes/` for additional usage examples.
2023-08-13 00:17:38 +03:00
## GROWS_WITH_LEVEL
2025-06-11 17:53:16 +03:00
Effect: Updates val to `ceil(valPer20 * floor(heroLevel / stepSize) / 20)`
2023-08-13 00:17:38 +03:00
Example: The following updater will cause a bonus to grow by 6 for every 40 levels. At first level, rounding will cause the bonus to be 0.
2023-08-13 00:17:38 +03:00
```json
"updater" : {
2025-06-11 17:53:16 +03:00
"type" : "GROWS_WITH_LEVEL",
"valPer20" : 6,
"stepSize" : 2
}
```
2023-08-13 00:17:38 +03:00
Example: The following updater will cause a bonus to grow by 3 for every 20 levels. At first level, rounding will cause the bonus to be 1.
2023-08-13 00:17:38 +03:00
```json
"updater" : {
2025-06-11 17:53:16 +03:00
"type" : "GROWS_WITH_LEVEL",
"valPer20" : 3,
"stepSize" : 1
}
```
2023-08-13 00:17:38 +03:00
Remarks:
- The rounding rules are designed to match the attack/defense bonus progression for heroes with creature specialties in HMM3.
- There is no point in specifying val for a bonus with a GROWS_WITH_LEVEL updater.
2023-08-13 00:17:38 +03:00
## TIMES_HERO_LEVEL
2025-06-11 17:53:16 +03:00
Effect: Updates val to `val * heroLevel / stepSize`
2023-08-13 00:17:38 +03:00
Usage: `"updater" : "TIMES_HERO_LEVEL"`
2023-08-13 00:17:38 +03:00
2025-06-11 17:53:16 +03:00
Usage with stepSize greater than one:
```json
"updater" : {
"type" : "TIMES_HERO_LEVEL",
"stepSize" : 2
}
```
2023-08-13 00:17:38 +03:00
## TIMES_STACK_LEVEL
2025-06-11 17:53:16 +03:00
Updates val to `val * stackLevel`, where `stackLevel` is level of stack (Pikeman is level 1, Angel is level 7)
2023-08-13 00:17:38 +03:00
Usage:
`"updater" : "TIMES_STACK_LEVEL"`
2023-08-13 00:17:38 +03:00
Remark: The stack level for war machines is 0.
Better support for Adela specialty (+new modding functionality for it) Fixes Adela specialty that was apparently broken back in #1518 and replaced with logic that was clearly not tested - it was neither functional, nor it was following H3 behavior. - `HAS_ANOTHER_BONUS_LIMITER` now accepts `null` in place of bonus type, for cases when limiting is needed by bonus source or bonus subtype. This allows Adela Bless specialty to always work, irregardless of which bonuses are provided by Bless. - Implemented `DIVIDE_STACK_LEVEL` updater that functions same as `TIMES_STACK_LEVEL`, but it divides bonus value, instead of multiplying it (to make Adela specialty weaker for high-tier units, as in H3) - Implemented `TIMES_HERO_LEVEL_DIVIDE_STACK_LEVEL` updater that combines two existing updaters, to implement `val * heroLevel / unitLevel` formula needed for Adela specialty - Removed deprecated `ARMY_MOVEMENT` updater. Its functionality has already been removed in 1.6.X releases, and it was remaining only as a placeholder - Updated modding documentation to account for these changes & to remove some TODO's Fixed regression from #777 that could led to either duplicated bonuses or to multiple application of updaters. It introduced double-recursion - node parents were gathered recursively, and then bonuses were also collected recursively within each parent. This created situation where updater could be applied different number of times. For example, hero bonus that is propagated to unit in combat could be selected directly, or via hero->combat unit chain, or via hero->garrison unit->combat unit chains, leading to different calls to updaters if updater handles garrison unit node type
2025-04-11 15:04:30 +03:00
## DIVIDE_STACK_LEVEL
2023-08-13 00:17:38 +03:00
2025-06-11 17:53:16 +03:00
Updates val to `val / stackLevel`, where `stackLevel` is level of stack (Pikeman is level 1, Angel is level 7)
2023-08-13 00:17:38 +03:00
Better support for Adela specialty (+new modding functionality for it) Fixes Adela specialty that was apparently broken back in #1518 and replaced with logic that was clearly not tested - it was neither functional, nor it was following H3 behavior. - `HAS_ANOTHER_BONUS_LIMITER` now accepts `null` in place of bonus type, for cases when limiting is needed by bonus source or bonus subtype. This allows Adela Bless specialty to always work, irregardless of which bonuses are provided by Bless. - Implemented `DIVIDE_STACK_LEVEL` updater that functions same as `TIMES_STACK_LEVEL`, but it divides bonus value, instead of multiplying it (to make Adela specialty weaker for high-tier units, as in H3) - Implemented `TIMES_HERO_LEVEL_DIVIDE_STACK_LEVEL` updater that combines two existing updaters, to implement `val * heroLevel / unitLevel` formula needed for Adela specialty - Removed deprecated `ARMY_MOVEMENT` updater. Its functionality has already been removed in 1.6.X releases, and it was remaining only as a placeholder - Updated modding documentation to account for these changes & to remove some TODO's Fixed regression from #777 that could led to either duplicated bonuses or to multiple application of updaters. It introduced double-recursion - node parents were gathered recursively, and then bonuses were also collected recursively within each parent. This created situation where updater could be applied different number of times. For example, hero bonus that is propagated to unit in combat could be selected directly, or via hero->combat unit chain, or via hero->garrison unit->combat unit chains, leading to different calls to updaters if updater handles garrison unit node type
2025-04-11 15:04:30 +03:00
Usage:
`"updater" : "DIVIDE_STACK_LEVEL"`
Remark: The stack level for war machines is 0.
## TIMES_HERO_LEVEL_DIVIDE_STACK_LEVEL
2025-06-11 17:53:16 +03:00
Effect: Same effect as `TIMES_HERO_LEVEL` combined with `DIVIDE_STACK_LEVEL`: `val * heroLevel / stackLevel`
Better support for Adela specialty (+new modding functionality for it) Fixes Adela specialty that was apparently broken back in #1518 and replaced with logic that was clearly not tested - it was neither functional, nor it was following H3 behavior. - `HAS_ANOTHER_BONUS_LIMITER` now accepts `null` in place of bonus type, for cases when limiting is needed by bonus source or bonus subtype. This allows Adela Bless specialty to always work, irregardless of which bonuses are provided by Bless. - Implemented `DIVIDE_STACK_LEVEL` updater that functions same as `TIMES_STACK_LEVEL`, but it divides bonus value, instead of multiplying it (to make Adela specialty weaker for high-tier units, as in H3) - Implemented `TIMES_HERO_LEVEL_DIVIDE_STACK_LEVEL` updater that combines two existing updaters, to implement `val * heroLevel / unitLevel` formula needed for Adela specialty - Removed deprecated `ARMY_MOVEMENT` updater. Its functionality has already been removed in 1.6.X releases, and it was remaining only as a placeholder - Updated modding documentation to account for these changes & to remove some TODO's Fixed regression from #777 that could led to either duplicated bonuses or to multiple application of updaters. It introduced double-recursion - node parents were gathered recursively, and then bonuses were also collected recursively within each parent. This created situation where updater could be applied different number of times. For example, hero bonus that is propagated to unit in combat could be selected directly, or via hero->combat unit chain, or via hero->garrison unit->combat unit chains, leading to different calls to updaters if updater handles garrison unit node type
2025-04-11 15:04:30 +03:00
Intended to be used as hero bonus (such as specialty, skill, or artifact), for bonuses that affect units (Example: Adela Bless specialty)
Usage:
`"updater" : "TIMES_HERO_LEVEL_DIVIDE_STACK_LEVEL"`
2025-06-11 17:53:16 +03:00
## TIMES_STACK_SIZE
Effect: Updates val to `val = clamp(val * floor(stackSize / stepSize), minimum, maximum)`, where stackSize is total number of creatures in current unit stack
Parameters `minimum` and `maximum` are optional and can be dropped if not needed
Example:
```json
"updater" : {
"type" : "TIMES_STACK_SIZE",
"minimum" : 0,
"maximum" : 100,
"stepSize" : 2
}
```
## BONUS_OWNER_UPDATER
Helper updater for proper functionality of `OPPOSITE_SIDE` limiter