Skip to content

Attributes

Webmilio edited this page Feb 19, 2019 · 10 revisions

What Are Attributes

Attributes are separated into two categories: the Primary Attributes and the Secondary Attributes.

These classes are immutable since they serve as a definition and have their corresponding Player classes.

Primary Attribute Definitions

Primary attribute definitions (the class PrimaryAttributeDefinition) are the Petals that display in the Power Flower automatically, f.e. Physique and Attunement. They are stored in the PrimaryAttributeDefinitionManager (see Managers). The class has the following properties:

  • Name : inherited from ICanBeManaged, this is both an identifier and the text displayed on the Power Flower, f.e. Physique and Attunement.
  • MaxLevel : the maximum level attainable for a specific Primary Attribute, f.e. 30 for the default Leveled Primary Attribute.
  • Color : the color for the Petal in the Power Flower.
  • CanBeRemoved : wether or not the element can be removed from its corresponding Manager; see Clearing a Manager for more information on its usage.

The class has the following methods:

  • PlayerPrimaryAttribute GetPlayerPrimaryAttribute(Player player) : bounces to GetPlayerPrimaryAttribute(LeveledPlayer leveledPlayer).
  • PlayerPrimaryAttribute GetPlayerPrimaryAttribute(ModPlayer modPlayer) : bounces to GetPlayerPrimaryAttribute(Player player).
  • PlayerPrimaryAttribute GetPlayerPrimaryAttribute(LeveledPlayer leveledPlayer) : returns the associated instance of PlayerPrimaryAttribute if the given player has the corresponding attribute; otherwise returns null.

For an example on its usage, check here!

PlayerPrimaryAttribute

Player primary attributes (the class PlayerPrimaryAttribute) are the things that contain the current level, points, etc. for the corresponding Power Flower. These (along with PlayerSecondaryAttribute) are the things you'll want to access when dealing with scaling or requirements most of the time. The class has the following properties:

  • PrimaryAttributeDefinition : used as a way to reference what its for.
  • Level : the level the player is in the corresponding attribute.
  • Points : the total amount of points has the player invested in the corresponding attribute.
  • RequiredPoints : the amount of points required for the next level. This is mostly used in the user interface.

Secondary Attribute Definitions

A NOTE BEFORE YOU GO IN: these classes are still under construction. What is written here reflects the goal of the API, not what the current state of it is. We are actively working on it.

Secondary attribute definitions (the class SecondaryAttributeDefinition) are the numbers that display (or not) on the left side of the Power Flower. These are the things for which you need to define custom scaling if you define and register a new PrimaryAttributeDefinition. They are stored in the SecondaryAttributeDefinitionManager (see Managers). The class has the following properties :

  • Name : inherited from ICanBeRegistered, this is both an identifier and the text displayed when you hover over the ShortName while in the Status Interface.
  • ShortName : the abbreviation for the Name, this text is displayed on the left of the Power Flower and in the Status Interface.
  • CalculateDuringPreMovement : wether or not the damage scaling (also known as the Action<PlayerSecondaryAttribute> calculate in MakeAttributeDefinition<T> should be calculated before the player's movements are applied (PreUpdateMovement in your ModPlayer class).
  • Reset : the method to use when resetting a stat; must be of delegate type Action<PlayerSecondaryAttribute>. You can usually just put att => att.AbilityMod = 0. This method could be considered of lesser importance compared to the PlayerSecondaryAttribute.Reset method.
  • Calculate : used to calculate the total value of the attribute; must be of delegate type Action<PlayerSecondaryAttribute>. You can usually just put att => att.Total = att.Base + att.Mod.
  • DefaultBase : the value at which the attribute starts when it has not been touched. All of Leveled's attributes use 1 as a default base value (except for LifePoints and ManaPoints, which use 15 and 5 respectively).
  • DefaultMod : the value at which the attribute's modifier starts when it has not been touched. All of Leveled's attributes use 0 as a default modifier.
  • DefaultAbilityMod : the value at which the attribute's ability modifier starts when it has not been touched. All of Leveled's attributes use 0 as a default ability modifier.
  • DefaultTotal : the total value for the attribute when it has not been touched. All of Leveled's attributes use 0 as a default total.
  • CanBeRemoved : wether or not the element can be removed from its corresponding Manager; see Clearing a Manager for more information on its usage. This is usually true, except for LifePoints and ManaPoints.

For more information regarding the various Default properties and how they're used, check the properties section in PlayerSecondaryAttribute.

The secondary attributes have custom scaling that you cannot access through a property. They are instead accessed through a method, which is as follows:

  • void AddPlayerStatCalculation<T>(Action<T> playerStatCalculation), where T is a child (extends) of ModPlayer. This adds a player statistic calculation, which is then called by the ApplyStatCalculation method. Unless the scalings have all been removed, Leveled scaling should be the first one to be called. Thus, if you want to add your own scaling, assuming it has been calculated by Leveled, you should use leveledPlayer.YourScaling.Base += or leveledPlayer.YourScaling.Base *= and so on, depending on what effect you want to have.

The remaining methods in the class are as follows:

  • void AffectPlayer(ModPlayer modPlayer) : executes all the player affections specified with the affectPlayer of type Action<T> when using the method MakeAttributeDefinition<T>(…) or affectPlayer of type Action<ModPlayer> if using the constructor. There is currently no way to have more than one "affection".
  • bool RequestRemoveScalings() : currently, this method simply removes all the scalings from the player stat calculations; always returns true.

To make an attribute, it is recommended to use the following method: SecondaryAttributeDefinition MakeAttributeDefinition<T>(string name, string shortName, Action<T> affectPlayer, Action<T> playerStatCalculation, Action<PlayerSecondaryAttribute> reset, Action<PlayerSecondaryAttribute> calculate, bool canBeRemoved = true, bool calculateDuringPreMovement = true, int defaultBase = 1, int defaultMod = 0, int defaultAbilityMod = 0, int defaultTotal = 0) : this method might not always be up to date, so its best to check the object browser for the correct signature (assuming you're running the latest version of Leveled).

This method creates a SecondaryAttributeDefinition and replaces the ModPlayer you'd use if using the constructor by the class of your choice, as long as it implements (or is) ModPlayer. This allows you to use your own attributes to scale your own damage, for example Symphonic damage from Thorium.

The arguments for using such a method are described by the properties with the same name in the Properties section of this class.

The remaining static methods are pretty much described by their name. They all take two PlayerPrimaryAttribute, one of them being the main scaling and the other one being the alt. This is due to the fact that most secondary attributes scale according to two seperate primary attributes, f.e. INTELLIGENCE (INT) scales according to mainly attunement and alternatively enhancement and SPIRIT (SPR) scales the opposite.

For an example on its usage, check here!

PlayerSecondaryAttribute

Player secondary attributes (the class PlayerSecondaryAttribute) are the things that contain the current base, modifier, ability modifier and total for the player. These (along with PlayerPrimaryAttribute) are the things you'll want to access when dealing with scalings most of the time. The class has the following properties: * SecondaryAttributeDefinition : used a way to reference what its for.

  • Base : the current base value of an attribute. This value, even though its name suggests otherwise, actually changes.
  • Mod : the current modifier (be it from armor or anything other statistic)
  • AbilityMod : the current modifier calculated from the Abilities.
  • Total : the current attribute's total value; usually calculated from the base and modifier.

The class' methods are simply shortcuts to their SecondaryAttributeDefinition, except for Reset(), which simply assigns the default value of each property from its corresponding SecondaryAttributeDefinition to the current values.

Clone this wiki locally