Skill System

The Gorilla3D Skill System provides a hierarchical skill tree framework for games. Skills are organized in groups, support leveling with interpolation, async leveling processes, multi-language names, and full XML serialization.

Table of Contents

Overview

Class Description
TGorillaSkillSystem Main component managing skill groups
TGorillaSkillGroup A category of skills
TGorillaSkill A single skill with level, value, and sub-skills
TGorillaSkillProcess An async leveling-up process

Core Concepts

Skills form a hierarchy: Groups contain Skills, and Skills can contain sub-skills (since TGorillaSkill extends TGorillaSkillGroup). This allows building complex skill trees.

SkillSystem
  ├── Group: "Combat"
  │   ├── Skill: "Swordsmanship" (Level 3, Value 1.5)
  │   │   ├── Sub-Skill: "Parry" (Level 1)
  │   │   └── Sub-Skill: "Riposte" (Level 0, Locked)
  │   └── Skill: "Archery" (Level 2, Value 1.2)
  └── Group: "Magic"
      └── Skill: "Fireball" (Level 5, Value 3.0)

Enabled vs Activated

  • Enabled: The skill is unlocked and available for activation
  • Activated: The skill is currently in use/active

Getting Started

uses Gorilla.Utils.SkillSystem;

var
  SkillSys: TGorillaSkillSystem;
begin
  SkillSys := TGorillaSkillSystem.Create(Self);
end;

Skill Groups

Groups organize skills into categories:

var LGroup := SkillSys.AddGroup(); // creates a TGorillaSkillGroup
LGroup.Name := 'Combat';
LGroup.Enabled := True;

Group Methods

function AddSkill(): TGorillaSkill;
function FindSkillByName(const ASkillName: String): TGorillaSkill;
function FindSkillByGUID(const AGUID: TGUID): TGorillaSkill;
procedure GetActivatedSkills(var AMap: TGorillaSkillMap);

Skills

Each skill has these key properties:

Property Type Default Description
Enabled Boolean — Whether the skill is unlocked
Activated Boolean False Whether the skill is currently active
Value Single 1.0 Main skill value (used for game effects)
Factor Single 1.0 Interpolation factor for level calculations
Interpolation TGorillaSkillLevelInterpolation Linear How value scales with level
Level Integer 0 Current skill level
MaxLevel Integer — Maximum achievable level
LevelingTime Integer — Time required to level up (ms)
Icon Integer — Index in a TImageList
Name String — Display name (current language)
Names[lang] String — Multi-language name access
GUID TGUID auto Unique identifier
Position TPointF — Flow chart position (for editor)

Level Interpolation

The value of a skill changes with its level according to the interpolation method:

Interpolation Description
LinearInterpolation Value = BaseValue + Level * Factor
LogarithmicInterpolation Logarithmic growth curve
ExponentialInterpolation Exponential growth curve
ExponentialMinus1Interpolation Exponential minus 1 curve

Leveling

Async Leveling Process

Skills support asynchronous leveling (e.g., training takes time):

// Start leveling up (targets first sub-skill)
var LProcess := SomeSkill.StartLevelingUp();

// Start leveling toward a specific sub-skill
var LProcess := SomeSkill.StartLevelingUp(TargetSubSkill);

TGorillaSkillProcess manages the async leveling operation.

Skill Switching

The system validates skill switching — ensuring that leveling constraints (like required sub-skills being activated) are respected.

Serialization

Skills serialize to and from XML:

// Save
SkillSys.ToXml(ParentXmlElement);

// Load
SkillSys.FromXml(XmlNode);

The skill system integrates with the Assets Manager as SKILLS asset type.

Best Practices

  • Use groups to categorize skills (Combat, Magic, Crafting)
  • Use sub-skills for skill specializations (Swordsmanship → Parry, Riposte)
  • Set Enabled := False for locked skills; unlock via game logic
  • Use Activated to track which skills the player has chosen to use
  • Choose the appropriate interpolation method for balanced progression
  • Set MaxLevel to cap skill progression
  • Use LevelingTime for time-gated skill upgrades
  • Store skill trees in asset packages for easy content management
  • Use GUID for reliable cross-references instead of names