How-tos
The tasks buyers come back for, each answered in steps, in Blueprint, with C++ where both apply. They build on the quickstart’s Hero track and tree and the words in Concepts.
Give XP for kills, quests or anything else
Add XP gives a track XP; it runs on the server only.
- Where the thing happens (an enemy’s death, say), on the server, call Get Progression Component with the player’s pawn, controller or PlayerState.
- Call Add XP with the track, the amount and, if you like, a Source tag such as
XP.Kill.Wolf.
The player levels up as far as the XP reaches, and the HUD shows it coming in.
#include "PTLibrary.h"
#include "PTProgressionComponent.h"
void AWolf::Die(AController* Killer)
{
if (UPTProgressionComponent* Progress = UPTLibrary::GetProgressionComponent(Killer))
{
Progress->AddXP(HeroTrack, 25, FGameplayTag::RequestGameplayTag("XP.Kill.Wolf"));
}
}
With heyheythere’s other plugins, the same node takes their events:
| From | Bind | Then |
|---|---|---|
| Quest & Dialogue System | On Quest State Changed on Get Quest Component | when New State is Completed, Add XP |
| Farming & Fishing System | On Harvested on the Farmer Component, On Fish Caught on its Get Fishing | Add XP to a Farming or Fishing track, by count or Size Cm |
Bind them in your character Blueprint’s Event Possessed, which runs on the server. To give each quest its own XP, keep a Map variable from quest to XP and look the completed quest up in it.
Have a character level and separate skills
A player can level up in any number of tracks at once.
- Make a track for each:
TK_Herofor the character level,TK_Farming,TK_Combat. - Make a tree for each and set its Track. A tree’s nodes cost its own track’s points.
- Add every tree to Default Trees in the settings, or give one later with Add Tree (on the server), when the player meets a trainer, say.
The HUD shows a bar for each track the player has, and the tree screen shows the trees side by side, each under its track’s level and points. A track the player has no XP in starts at level 1.
Grant a Gameplay Ability System ability from a talent
- In the node’s Rewards, add one with Type Ability and pick the ability class.
- For a passive bonus, add one with Type Effect and pick a Gameplay Effect.
Each rank grants the ability, or applies the effect, at the rank as its level; unlearning takes it away. The player needs an Ability System Component on the PlayerState or its pawn, as the Gameplay Ability System sets it up (on the pawn, if you put the Progression Component there).
Without the Gameplay Ability System, use an Event reward:
- Give the node a reward with Type Event and Event
Fireball. - Bind On Reward Event on Get Progression Component.
- When Event is
Fireball, turn your ability on if Rank is above 0, off if it’s 0. The event fires on the player’s machine as well as the server, so put the change behind Switch Has Authority if it is gameplay rather than a sound or an icon.
With GAS Ability & Status Effect System, that is Grant Ability on the character’s AS Ability System with your ability asset and the rank as its level, and Remove Ability at rank 0.
Make a stat drive movement, damage or health
Stat rewards add to named numbers on the player’s Stat Component; your Blueprints decide what each means.
- Give a node a reward with Type Stat, Stat
RunBonus, Op Add, Value100, or Op Multiply with0.1for +10% a rank. - Where your game uses the number, call Get Stat Component with the player and Get Stat
with
RunBonus.
For movement, set Max Walk Speed when the stat changes: bind On Stat Changed on the Stat
Component, or read it on Event Tick as the quickstart does.
For damage, multiply your hit by 1 + Get Stat (Damage). A stat no reward has given is 0.
A stat’s base is your game’s own number, set with Set Base Stat (a player’s gold, their health at level 1); rewards are modifiers on it (how they add up).
Lock content behind a level or a skill
| To check | Call |
|---|---|
| a track’s level | Get Level with the track |
| a node learned | Get Node Rank with the tree and node id, above 0 |
| a skill that gives a tag | Has Tag with the node’s Tag reward |
Tags are the easiest to share: give the node a Tag reward Skill.Lockpicking, and the door
checks Has Tag without knowing which tree gave it. The other way round, Add Tag from a quest
or a book lets a node’s Required Tags ask for it.
Let players respec
- Call Respec Node for one node, or Respec Tree for a tree, or for all with none.
- For a price, set the tree’s Respec Cost Stat (say
Gold) and Respec Cost Per Point, and show Get Respec Cost before the player confirms.
When a respec is refused, and why, is in the reference.
On the tree screen, R or Y on a gamepad respecs the selected node.
Use your own XP curve
A track’s XP from each level to the next comes from the first of these it has:
- Level XP: a table, the first entry being level 1 to 2.
- Level Curve: a float curve of the XP from level X to the next.
- Base XP and Growth: level X to the next takes Base XP × X ^ Growth.
Points Per Level and Starting Points set the points; Level Rewards give extra points or rewards at chosen levels. Get XP To Next Level on the track asset gives any level’s figure, to check a curve from a Blueprint.
Offer a choice between two paths
Give the two nodes the same Exclusive Group name. Once one is learned, the other is locked, and its tooltip says why. A respec of the learned one opens the choice again.
Boost XP for a weekend or a perk
- Source Multipliers on the track multiply XP from a source tag:
XP.Kill.Bossat 2. The most specific tag counts. - Multiplier Stat names a stat that multiplies every gain: set its base to 2 for the weekend, or give it from a node as a perk. Without a base it counts from 1, so a perk’s +0.5 Add alone is 1.5 times the XP.
Give the tree screen your own look
- Make a Widget Blueprint and pick PTTreeWidget as its parent class (or PTHudWidget for the bars).
- Leave its Designer empty, and under Look in its Details change the Title, Blur Strength, Node Size, Column Step, Row Step and zoom limits (the HUD’s Bar Width and Toast Seconds).
- Set it in Project Settings > Plugins > RPG Skill Tree & XP System.
For a screen entirely your own, lay out its Designer: the plugin’s isn’t built then. Read the player’s progress with the nodes in the reference, and use the widget’s own Select Node, Learn Selected and Close (all of them).
Show what the player can use
A PT Glint is a small sparkle on whatever the player can pick up, use or train on. The demo’s mushrooms, dummies, orb and respec stone each carry one.
- In the Blueprint of the item or prop, click Add and search
PT Glint. - Move it to where it should shine. Set Range to the distance it should show from.
- When the thing can’t be used any more, such as an item picked up, call Set Glint On with it unticked; tick it again when it can.
To turn glints off, untick the component’s Glint On for one, or Glints in Project Settings > Plugins > RPG Skill Tree & XP System for the whole game. In play, Set Glints Shown on Get Progression UI turns them all on or off, for an options menu.
Save progress with your own save game
- In your SaveGame Blueprint, add a variable of type PTSave Data.
- Before saving: Get Progression Component with the player, Get Save Data, and set your variable from it.
- After loading, on the server: Load Save Data with your variable.
// saving
SaveGame->Progress = UPTLibrary::GetProgressionComponent(PlayerController)->GetSaveData();
// loading, on the server
UPTLibrary::GetProgressionComponent(PlayerController)->LoadSaveData(SaveGame->Progress);
Rewards come back with their nodes; what the save holds is in the reference. A game without a save game of its own calls Save Progress To Slot and Load Progress From Slot.
Make it work in multiplayer
| Call | Where |
|---|---|
| Add XP, Set Level, Add Points, Add Tree, tags, stats, Load Save Data | the server only; on a client they log a warning and do nothing |
| Learn Node, Respec Node, Respec Tree | either; a client’s call asks the server, which checks it |
| Queries, the UI | either; a client sees changes a round trip later |
To stop clients from learning by themselves, untick Accept Client Requests on the Progression Component. What replicates to whom is in the reference.