Calculating stats

In this section, you will build a simple stats system for each attribute, obtaining the character’s base damage, max health, and dodge chance.

In this section, you will build a simple stats system for each attribute, obtaining the character’s base damage, max health, and dodge chance. For each one, we are going to use the following formulas:

Base damage=100+strength*100

Max health=100+constitution*100

Dodge chance=10+dexterity*5

Because you need to add formulas that depend on the state of other components in the diagram, you will need to create and combine registers and State Connections.

  1. Create three Registers and place each one to the right of one of the attribute pools.
Three attribute Pools, Strength, Constitution and Dexterity, each with a Register to its right, joined by a State Connection that reads Input as a. A Register with no input is outlined in red, so the connection is drawn here.Three attribute Pools, Strength, Constitution and Dexterity, each with a Register to its right, joined by a State Connection that reads Input as a. A Register with no input is outlined in red, so the connection is drawn here.
  1. Rename each Register by selecting them and entering the new name in the label at the top of the Properties panel with the following names: “Base damage”, “Max health” and “Dodge chance”.
The three Registers renamed Base damage, Max health and Dodge chance, still reading their pool as aThe three Registers renamed Base damage, Max health and Dodge chance, still reading their pool as a
  1. Every Register needs to get the amount of points allocated to their associated attribute pool, so you have to read the state of these pools. Add three State Connections, clicking first in one of the pools and then in its associated register.
  1. We recommend having descriptive names in the formulas of the State Connections. Thus, select the State Connections, and, with Type on “Formula input”, type into the box under it, depending on their corresponding attribute, one of the following names: “strength”, “cons”, and “dex”.
The Properties panel of a State Connection with Type “Formula input” and the name strength outlined in red.The Properties panel of a State Connection with Type “Formula input” and the name strength outlined in red.
  1. We need to add the associated formulas to each stat calculation. Select each Register at a time, and in the “Formula” field, type the following formulas:

5a. “Base damage” register: 100 + strength * 100

The Properties panel of the “Base damage” Register with the formula 100 + strength * 100 outlined in red.The Properties panel of the “Base damage” Register with the formula 100 + strength * 100 outlined in red.

5b. “Max health” register: 100 + cons * 100

The Properties panel of the “Max health” Register with the formula 100 + cons * 100 outlined in red.The Properties panel of the “Max health” Register with the formula 100 + cons * 100 outlined in red.

5c. “Dodge chance” register: 10 + dex * 5

The Properties panel of the “Dodge chance” Register with the formula 10 + dex * 5 outlined in red.The Properties panel of the “Dodge chance” Register with the formula 10 + dex * 5 outlined in red.
  1. Press “Play” and observe how the stats registers are automatically updated depending on the points allocated to each attribute.
With Strength 5, Constitution 4 and Dexterity 3, the registers show Base damage 600, Max health 500 and Dodge chance 25With Strength 5, Constitution 4 and Dexterity 3, the registers show Base damage 600, Max health 500 and Dodge chance 25