Stat.cs
v4.0
Last updated
v4.0
Last updated
Stat
is a Scriptable Object which holds references to all the data set up with the Stats Module. It implements IHaveUid
and IHaveDictionaries
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.
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.
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.
Stats can be "Trainable", "Modifiable", or "Counter". There are bool
properties in the GameStat
for each of these.
Counter stats are those which are neither trainable or modifiable. Generally this means they're being used to count a value, such as "Money" or "Experience".
Stats which are Trainable or Modifiable may be both Trainable and Modifiable.
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".
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.
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.