Difference between revisions of "Bonus system"
(→Bonus string constants) |
(→Propagation and inheritance) |
||
Line 8: | Line 8: | ||
== Propagation and inheritance == | == Propagation and inheritance == | ||
− | + | Each bonus originates from some node in the bonus system, and may have propagator and limiter objects attached to it. Bonuses are shared around as follows: | |
− | # | + | # Bonuses with propagator are propagated to "matching" descendants in the red DAG - which descendants match is determined by the propagator. Bonuses without a propagator will not be propagated. |
− | # | + | # Bonuses without limiters are inherited by all descendants in the black DAG. If limiters are present, they can restrict inheritance to certain nodes. |
+ | |||
+ | Inheritance is the default means of sharing bonuses. A typical example is an artefact granting a bonus to attack/defense stat, which is inherited by the hero wearing it, and then by creatures in the hero's army. | ||
+ | |||
+ | A common limiter is by creature - e.g. the hero Eric has a specialty that grants bonuses to attack, defense and speed, but only to griffins. | ||
+ | |||
+ | Propagation is used when bonuses need to be shared in a different direction than the black DAG for inheritance. E.g. Magi and Archmagi on the battlefield reduce the cost of spells for the controlling hero. | ||
== Operations on the graph == | == Operations on the graph == |
Revision as of 12:29, 15 September 2017
The bonus system of VCMI is a set of mechanisms that make handling of different bonuses for heroes, towns, players and units easier. The system consists of a set of nodes representing objects that can be a source or a subject of a bonus and two directed acyclic graphs (DAGs) representing inheritance and propagation of bonuses. Core of bonus system is defined in HeroBonus.h file.
Here is a brief sketch of the system (black arrows indicate the direction of inheritance and red arrows the direction of propagation):
Contents
Propagation and inheritance
Each bonus originates from some node in the bonus system, and may have propagator and limiter objects attached to it. Bonuses are shared around as follows:
- Bonuses with propagator are propagated to "matching" descendants in the red DAG - which descendants match is determined by the propagator. Bonuses without a propagator will not be propagated.
- Bonuses without limiters are inherited by all descendants in the black DAG. If limiters are present, they can restrict inheritance to certain nodes.
Inheritance is the default means of sharing bonuses. A typical example is an artefact granting a bonus to attack/defense stat, which is inherited by the hero wearing it, and then by creatures in the hero's army.
A common limiter is by creature - e.g. the hero Eric has a specialty that grants bonuses to attack, defense and speed, but only to griffins.
Propagation is used when bonuses need to be shared in a different direction than the black DAG for inheritance. E.g. Magi and Archmagi on the battlefield reduce the cost of spells for the controlling hero.
Operations on the graph
There are two basic types of operations that can be performed on the graph:
Adding a new node
When node is attached to a new black parent [1], the propagation system is triggered and works as follows:
- For the attached node and its all red ancestors
- For every bonus
- Call propagator giving the new descendant -> then attach appropriately bonuses to the red descendant of attached node (or the node itself).
- For every bonus
Deleting an existing node
Analogically to the adding a new node, just remove propagated bonuses instead of adding them. Then update the hierarchy.
Limiters
Propagators
Calculating the total value of a bonus
Bonus string constants
- List of all bonus types
- List of bonus value types
- List of bonus range types
- List of bonus duration types
- List of bonus sources
- List of bonus limiters
- List of bonus propagators
- List of bonus updaters
Additional links
- Bonus system
- Bonus Format
Automatic generation of bonus description
TBD
Notes
- ↑ the only possibility -> adding parent is the same as adding a child to it