ContextRankConfig - WittleWolfie/OwlcatModdingWiki GitHub Wiki

Last Updated For Game Version: 1.0.6

  • Code:
    • Kingmaker.UnitLogic.Mechanics.Components.ContextRankConfig
    • Kingmaker.UnitLogic.Mechanics.ContextValue
  • Supported Blueprints:
    • BlueprintAbility
    • BlueprintAbilityAreaEffect
    • BlueprintBuff
    • BlueprintFeature
    • BlueprintItemEnchantment
  • See also: WittleWolfie's ContextRankConfig Calculator

ContextRankConfig is used to define dynamic numerical values for use in other components. There are three primary fields used to configure them:

public ContextRankBaseValueType m_BaseValueType;

public ContextRankProgression m_Progression;

public AbilityRankType m_Type;
  • ContextRankBaseValueType specifies the initial value for the config. This is usually a property of the character such as their character level.
  • ContextRankProgression modifies the initial value to generate the final result. This can have a wide range of effects and is often used for bonuses that scale based on things like caster level.
  • AbilityRankType is an identifier that other components reference to get the value from a specific config.

ContextRankBaseValueType

This enum specifies the initial value as a character property. There are several other fields in ContextRankConfig, most of which are related to the value type. While some value types do not use any of the fields, others require specific fields to be populated.

  • CasterLevel, MaxCasterLevel, BaseAttack, CharacterLevel, MythicLevel - Simple value types with self explanatory names.

    • Required Fields: None
  • StatBonus, BaseStat - Uses the character's stat; the former uses its modifier and the latter uses its value.

    • Required Fields: m_Stat
  • CustomProperty - Uses a specified BlueprintUnitProperty.

    • Required Fields: m_CustomProperty
  • MaxCustomProperty - Uses the high value from an array of BlueprintUnitProperty.

    • Required Fields: m_CustomPropertyList
  • ClassLevel - Sums the character's levels in the specified classes.

    • Required Fields: m_Class
    • If m_ExceptClasses is true, class levels not in the specified classes are counted.
  • FeatureRank - Uses the character's rank in the specified feature.

    • Required Fields: m_Feature
  • FeatureList, FeatureListRanks - Counts the number of specified features the character has or sums their ranks.

    • Required Fields: m_FeatureList
  • MaxClassLevelWithArchetype, SummClassLevelWithArchetype, OwnerSummClassLevelWithArchetype - Uses either the max or sum of the character's levels in the specified classes, considering their archetypes as well. Owner references the owner of the blueprint as compared to the caster, e.g. the buffed target for a buff instead of the caster.

    • Required Fields: m_Class
    • Although these all support using Archetype to filter archetypes, it is not required.
    • One thing to note: these all add context.Params.RankBonus each time they add a relevant set of class levels. This seems to be a value specified in RuleCalculateAbilityParams called m_BonusCasterLevel; most likely it represents abilities that increase your effective caster level.
  • Bombs - Uses the same calculation as SummClassLevelWithArchetype, but divides it by 2 and adds the rank of the specified feature, minimum 1.

    • Required Fields: m_Class, m_Feature
  • CasterBuffRank, TargetBuffRank, MythicLevelPlusBuffRank - Uses the specified buff's ranks and the caster's mythic levels.

    • Required Fields: m_Buff
  • CasterCR - Based on the unit's CR as defined in its Experience component.

    • Required Fields: None
  • DungeonStage - References the stage of the current dungeon; a global state variable.

    • Required Fields: None

Units can have a "master" defined; if so the following value types use the attributes of the unit's master:

  • MasterMythicLevel

    • Required Fields: None
  • MasterFeatureRank

    • Required Fields: m_Feature

ContextRankProgression

This enum specifies a transformation which is applied to the initial value determined by the ContextRankBaseValueType. Don't trust the names, they are misleading. Example:

case ContextRankConfigProgression.OnePlusDiv2:
  return 1 + (value - 1) / 2;

If this were actually "one plus value divided by 2", when the value is 4 you'd expect to get 3. Instead you'll get 2. Keep in mind that these are integers and integer division is truncated, so a positive number always rounds down and a negative number always rounds up.

The formulas are short and straightforward to read in the code, but you can also use WittleWolfie's ContextRankConfig Calculator to quickly determine if the config matches your needs.

Depending on the formula you must specify the fields m_StepLevel and/or m_StartLevel.

One special case is ContextRankProgression.Custom. This requires the field m_CustomProgression to be populated with an array of ContextRankConfig.CustomProgressionItem. Each item is just a pair consisting of a value and a result. As a quick example (but not actual code):

m_CustomProgression = {
  [Value: 3, Result: 5],
  [Value: 4, Result: 6],
  [Value: 6, Result: 8],
  [Value: 10, Result: 20]
}

The initial value is compared to each item's value in order; the result from the first item with a value greater than or equal to the initial value is used. If the initial value is larger than all of the items, the result from the last item is used.

If the custom progression above were used with ContextRankBaseValueType.CharacterLevel the config would return:

Levels 1-3:  5
Level    4:  6
Levels 5-6:  8
Levels  7+: 20

AbilityRankType

If you look through the existing blueprints, you'll notice lots of abilities and features have multiple ContextRankConfig components. AbilityRankType is an enum used in ContextValue to reference a specific ContextRankConfig:

var components = new List<BlueprintComponent>();
components.Add(
  new ContextRankConfig {
    m_Type = AbilityRankType.DamageDice,
    m_BaseValueType = ContextRankBaseValueType.CharacterLevel
  });
var damageDice =
  new ContextValue {
    ValueType = ContextValueType.Rank,
    ValueRank = AbilityRankType.DamageDice
  };

components.Add(
  new ContextRankConfig {
    m_Type = AbilityRankType.StatBonus,
    m_BaseValueType = ContextRankBaseValueType.BaseAttack)
var statBonus =
  new ContextValue {
    ValueType = ContextValueType.Rank,
    ValueRank = AbilityRankType.StatBonus
  };

components.Add(
  new BuffAllSkillsBonus {
    Value = 1,
    Multiplier = damageDice
  });
components.Add(
  new SpellPenetrationBonus {
    Value = statBonus
  });

If you add these components to a buff, then while it is active the unit will add their character level to all skill checks and their base attack bonus to all spell penetration checks.

Notice that the names of the rank type, DamageDice and StatBonus are meaningless. The only thing that is important is that the ContextValue and ContextRankConfig reference the same type. You cannot use multiple ContextRankConfig components with the same rank type; one will overwrite the other.