Formula Definition - Grim-/Talented GitHub Wiki
This documentation covers how to configure and customize experience and talent point calculations in the Talented mod system.
Experience formulas determine how much experience is required for each level. The system uses ExperienceFormulaDef
to define these calculations.
Basic XML structure:
<Talented.ExperienceFormulaDef>
<defName>Basic_LinearXP</defName>
<experienceWorkerClass>Talented.LinearExperienceFormula</experienceWorkerClass>
<baseExperience>100</baseExperience>
</Talented.ExperienceFormulaDef>
Key properties:
-
defName
: Unique identifier for your formula definition -
experienceWorkerClass
: The C# class that implements the experience calculation logic -
baseExperience
: Base value used in experience calculations (default: 100)
To create a custom experience formula:
- Create a C# class that inherits from
ExperienceFormulaWorker
- Implement your custom calculation logic
- Create an XML def referencing your new class
- Reference your formula def in your UpgradeTreeDef
Talent point formulas control how many talent points are awarded at different levels. The system provides two built-in workers:
The StandardTalentPointWorker
awards one talent point per level gained.
<Talented.TalentPointFormulaDef>
<defName>PerLevel</defName>
<talentPointWorkerClass>Talented.StandardTalentPointWorker</talentPointWorkerClass>
</Talented.TalentPointFormulaDef>
The PeriodicTalentPointWorker
awards points based on configurable periods.
<Talented.TalentPointFormulaDef>
<defName>Periodic</defName>
<talentPointWorkerClass>Talented.PeriodicTalentPointWorker</talentPointWorkerClass>
<pointsPerPeriod>2</pointsPerPeriod>
<levelPeriod>5</levelPeriod>
</Talented.TalentPointFormulaDef>
Configuration options:
-
pointsPerPeriod
: Number of points awarded each period (default: 2) -
levelPeriod
: Number of levels between point awards (default: 5)
Example: With default settings, characters receive 2 talent points every 5 levels.
To create a custom talent point formula:
- Create a C# class that inherits from
TalentPointFormulaWorker
- Override the
GetTalentPointsForLevel(int levels)
method - Create an XML def referencing your new class
- Configure any custom properties your worker needs
<Talented.ExperienceFormulaDef>
<defName>Accelerated_XP</defName>
<experienceWorkerClass>MyMod.AcceleratingExperienceFormula</experienceWorkerClass>
<baseExperience>50</baseExperience>
</Talented.ExperienceFormulaDef>
<Talented.TalentPointFormulaDef>
<defName>Milestone_Rewards</defName>
<talentPointWorkerClass>MyMod.MilestoneTalentPointWorker</talentPointWorkerClass>
<pointsPerPeriod>5</pointsPerPeriod>
<levelPeriod>10</levelPeriod>
</Talented.TalentPointFormulaDef>
- Always provide clear
defName
values that indicate the formula's purpose - Test your formulas with various level ranges to ensure balanced progression
- Consider providing documentation for custom formulas
- Balance point acquisition rates with your mod's progression system
- All formula workers are instantiated using
Activator.CreateInstance
and as such any custom classes MUST contain a parameterless constructor. - Custom properties must be properly initialized in your worker classes
- Consider performance implications for complex calculations
- Ensure your formulas handle edge cases (negative levels, zero values, etc.)