Comment on page




The Stats module allows you to easily set up and access "Stat" data for your project. Creatively used, this could easily even add more functionality if Stat classes are used for other things, such as skills and counters (Gold, Experience, Health, Points).
A main concept of Stats is that each Stat object could potentially affect or be affected by others Stat objects, or other Game Module objects. These values can be set up in the Inspector, and then utilized in your project in whatever way makes sense.
The final value of Stat objects can be affected by other Stats, Conditions, Item Objects, Item Attributes, and even Quests. All of this is handled automatically at runtime!
The system will automatically recalculate the final value of each Stat when the underlying data changes, meaning once it is set up in your code, the values will always remain up to date.
[EARLIER VERSION] Quickstart Video #1 - Creating some Stats, an Item Object and Item Attribute and linking them all up in a demo scene. The general logic has not changed, though the UI has, and there are new options now.

Final Stat Computation

Each GameStat (the in-game version of the Stat), will have three numbers:
  • Points: These provide a constant fixed amount. Generally this is used as a counter, with value being added or subtracted throughout the game.
  • Base Value: This is similar to Points, but will combined with "value" modifications from other objects.
  • Base Proficiency: This is a float default to 0.0f, meaning "no change". The final proficiency value may be modified by other objects.
The Final Stat is computed using Points, Value, and Proficiency. The Final Value is the sum of the Base Value and modifications from other objects which affect this stat -- Items, Quests, Conditions, other Stats, etc.
Final Proficiency is the sum of Base Proficiency and modifications from other objects. A value of 0f would mean "no effect".
The sum of Points + Final Value is then multiplied by 1 + Final Proficiency to get the Final Stat.
Example: Lets say our "Strength" stat has these values: Points: 10 Base Value: 0 Base Proficiency: 0 Without anything affecting this stat, the Final Stat is: (10 + 0) * (1 + 0) = 10 Lets say the Actor has the following modifications: "Sword of Strength": +3 Value "Bodybuilding" Stat: +0.2 Proficiency
"Elf" Character Race: -0.1 Proficiency These modifications are then included when computing the final stat. Note the "Proficiency" modifications are summed, so the final Proficiency modification is: 0.2 + -0.1 = 0.1 The Final Stat is: (10 + 3) * (1 + 0.1) = 13 * 1.1 = 14.3
If your Actors inherit from GameModulesActor, then all of this is handled automatically!!


As an example, you may set up a Stat called Experience which may hold the experience points a player has collected. You may also set up another Stat called Experience Mod which is modifyable, but not trainable.
"Experience Modifier" can be modified by other objects, and starts with a value of 0.
Finally, you may set up a trainable Stat called Learning, a skill which the player could learn, and then master / upgrade, throughout the game.
Learning could be set to modify Experience Mod per "skill point", a value which may be something players can advance throughout the game. Perhaps Learning provides 0.02 points per skill point to Experience Mod. (Thats 2% more)
Learning will modify Experience Modifier, at Novice level, by 0.09 plus 0.01 per "Point" added to the Learning stat. (That means a 10% boost to experience at the start!)
In the Inspector for Experience, you may choose to modify any "points" added to the Stat by the Experience Mod you set up.
Now, whenever points are added to the Experience stat, which is being used as a "counter", the value will be modified by the Final Value of Experience Modifier. A character with Learning at Novice level with 1 skill point will get a 10% boost. Adding 100 points to Experience would result in 110 points being added, automatically.
So instead of simply adding "100" to the Experience Stat, the following math is used automatically:
Points=Points+(100(1+[ExperienceModProficiency]))Points = Points + (100 * (1 + [ExperienceMod Proficiency]))
In this example, a player with 5 skill points on the Learning Stat would have a total modification to the Experience Mod of 0.1, and the 100 experience points will be worth 110 for this player.
The goal of the Stats module is to make all of this relatively complex connections more easy to set up and manage, with runtime operations as automatic as possible. Time setting it all up, and thinking about how various Stat objects can work together, can enable a very smooth operation later on.