Stat.cs
v4.0
Stat is a Scriptable Object which holds references to all the data set up with the Stats Module. It implements IHaveUid and IHaveDictionaries
public string ObjectName
public string ObjectTypeSetup
Create a Stat by right-clicking to select the menu option.
/Create/Game Modules/Create/Stat
This will create a Stat Scriptable Object in your project. Select that and view the Inspector to begin setting up your data. The name of the Scriptable Object is saved as the objectName value.
Note that names of Stat objects must be unique. The console will provide a warning if there are multiple with the same name.
Remember that the "object type" of any Game Module object is the name of the folder the object is in.

Key concepts
The Stat has a few key concepts which are important to understand. The Final Value of a stat is made up of Points, Base Value, and Proficiency. Base Value and Proficiency can be affected by other Stat objects, or even ItemObject and ItemAttribute objects. The math looks like this:
A Proficiency of 0 means there will be no modification to the Final Base Value.
CanBeTrained & CanBeModified
Each Stat can also be optionally set to CanBeTrained and/or CanBeModified. These change how the system deals with the Stat, and how other objects can interact with it.
CanBeTrained refers to a Stat which can be improved upon during the game. You can set up MasteryLevels, any number of which can apply to a Stat or group of Stat objects. An example could be Novice, Expert, and Master levels. Each level may have different values, and may have different effects on other Stat objects.
You may have a Stat called "Learning", which affects the Proficiency of the Stat "Experience Mod" (which itself changes how points are allocated to the Stat "Experience".
You may set Learning to CanBeTrained, and change the affect it has on ExperienceMod for each Mastery Level. This way, as your player advances, the affect grows automatically.
CanBeModified sets the Stat as modifyable by other Stat objects, and ItemObject and ItemAttribute objects. Turning this on will allow you to select it when setting up the connections between objects. Objects which are not marked CanBeModified can still impact other Stat objects, but can not be impacted themselves.
Inspector
Select your new object and view it in the Inspector. Here is where you can manage all the details about this Stat. Note there are multiple tabs, each of which provide access to specific, and optional, information.

This is where you can set the main values for this Stat, including toggling on/off CanBeTrained and CanBeModified. Note that when CanBeTrained is true, the middle tab will be called "Mastery Levels", otherwise it will be called "Stats".
The Points, Base Value, and Base Proficiency values can be set as well.
Points are meant to be user-defined -- points that can go up or down throughout the game, such as assigned "Skill points", or "Experience points", or "Hit Points" etc. Other objects can not modify the Points value directly, the way they can Base Value and Base Proficiency.
The optional "Modified by this proficiency" will allow you to select another Stat object which will modifiy any changes to the Points value. In the screenshot, you can see that the selected Stat is "Experience" and it will be modified by "Experience Modifier", also a Stat.
You are also able to toggle a minimum and maximum value, so that after computing the result, the value will be clamped by these options.
Finally, you can choose whether to round the final value, and how to do so.

In this section, you can mark specific stats to automatically post their data to the main Blackboard, with the option to also send a notification. You can choose which aspects of the Stat to send, such as the Points or Final Stat.
The column on the right displays what the Blackboard Subject will be sent as. It will be the Stat name, with a dash ("-"), followed by "Points", "FinalValue", "FinalProficiency", or "FinalStat".

If a Stat is marked CanBeTrained, then you can select one of the MasteryLevel objects you've created from the drop down at the top. Stats which are not marked CanBeTrained will show options to modify other Stat objects, but there will be no additional tabs for various MasteryLevels.
Target and Source Stats
Stats Search for or select a Stat from the drop down which will be modified by this object. In this example, our Stat "Learning" will modify the Stat "Experience Modifier".
Base Value/Proficiency values set here will be constant affects. In this example, an object which has Stats will get a 0.09 increase to the Experience Modifier proficiency if they also have the Stat Learning.
Per Skill Point Value/Proficiency will be multiplied by the "point" value of the selected Stat, Learning. This means that at a "point" value of 1, the proficiency of Experience Modifier will be increased by 0.1, and if the "point" value was 5, the profiency would be increased by 0.14.
You can also add other Stat objects as additional Sources for modifying the Target Stats. More details on this can be found in the documentation on Items. ItemObject and ItemAttribute and other Game Module objects can also affect Stat objects, and use the same options. Each one has a single MasteryLevel, just like a Stat object which has CanBeTrained set false.

Here you can manage the values on the various Dictionaries key/value pairs set up. Each type added to a Dictionaries item is a List and you can add and re-order the entires as you'd like.
To expose values for modification, you will need to set up the Dictionaries key/value pairs by clicking the "Manage Stats" button at the top of the Inspector. Dictionaries keys are the same for all Stat objects of the same objectType.
Manage Stats
Selecting this button will open an Editor window with additional options which affect all Stat objects of the same objectType.

Here you can view and modify some of the common settings for each of the Stat objects of the same objectType, which you can select using the drop down near the top.

This panel will let you change the selected MasteryLevels which applies to all of the Stat objects of the selected objectType.
Changing this value may force data to be lost, if the number of levels on the new MasteryLevels object is less than the current one!!!

Here you can set up the keys available for all Stat objects of a specific objectType. Values and types can be set individually on each Stat.
Post to Blackboard
The Stat can be set to automatically post its values to the MainBlackboard, and optionally notify followers as well.

The column "BlackboardNote Subject" lists out what the "Subject" will be when the BlackboardNote is posted. The "Topic" will be the GameId() of the object which owns this Stat.
Keep in mind that ALL objects which have this stat will post the values toggled on here to the MainBlackboard. This may not always be ideal, such as if you have many many NPC Actors which have Stats, like enemies, as you may not want all of those posting notes to the Blackboard.
The GameStatList, which holds your Stats, has two bools, false by default: forcePostToBlackboard and forceNotifyOnPost.
If these are true, the stats inside the list will post to the blackboard, and notify, even if the toggles are false in the Inspector. This is useful when you want some Actors to post their stats, but not all.
Last updated
Was this helpful?