Skip to content

SkillTreeInstance ​

Inherits: RefCounted

Runtime instance tracking state of a skill tree for a player

Variables ​

SkillTreetree_definition
Dictionarynode_states{}
Stringsource_kind""
intsource_id0

Methods ​

SkillTreeInstancecreate_from_definition( tree_def: SkillTree ) static
intget_tree_id()
Stringget_tree_name()
boolis_node_unlocked( node_id: int )
intget_node_rank( node_id: int )
intget_node_choice( node_id: int )
intget_total_nodes_unlocked()
Array[int]get_unlocked_node_ids()
intget_total_points_spent()
intget_total_points_spent_from_pool( pool_id: int )
Dictionaryget_points_spent_by_pool()
Dictionaryget_availability( player: Player = null )
Dictionarycan_unlock_node( node_id: int, player: Player = null )
Array[SkillNode]get_available_nodes( player: Player )
boolunlock_node_rank( node_id: int, choice_index: int = -1, player: Player = null )
boolrefund_node_rank( node_id: int, player: Player = null, full_refund: bool = false )
Array[int]get_refund_cascade( node_id: int )
Dictionarycan_refund_node( node_id: int, full_refund: bool = false )
voidreset_all_nodes( player: Player = null )
boolchange_choice_node_selection( node_id: int, new_choice_index: int, player: Player )
boolapply_node_rewards( node_id: int, rank: int, player: Player )
boolunapply_node_rewards( node_id: int, rank: int, player: Player )
Dictionarycan_respec_node( node_id: int )
Dictionaryto_save_data()
voidrestore_from_save_data( save_data: Dictionary, player: Player = null )
SkillTreeInstancefrom_save_data( save_data: Dictionary, tree_def: SkillTree, player: Player = null ) static
Array[Dictionary]validate()
boolis_valid()

Variable descriptions ​

SkillTree tree_definition ​

The tree definition this instance tracks

Dictionary node_states = ​

Tracks the state of each node: node_id -> NodeUnlockState

String source_kind = "" ​

Where the tree comes from when it is not the character's own: "school" (a profession) or "faction", with the id of the craft school or the faction. Such a tree is open only while the profession is learned or the faction has met the party (SkillHolders.source_availability)

int source_id = 0 ​

The id of the owner of the tree (the profession or the faction), with source kind.

Method descriptions ​

SkillTreeInstance create_from_definition( tree_def: SkillTree ) ​

Factory method to create a new instance from a tree definition

int get_tree_id() ​

Get the tree ID this instance tracks

String get_tree_name() ​

Get the display name of this tree

bool is_node_unlocked( node_id: int ) ​

Check if a node has been unlocked

int get_node_rank( node_id: int ) ​

Get current rank of a node (0 = not unlocked)

int get_node_choice( node_id: int ) ​

Get the choice index selected for a ChoiceSkillNode (-1 = no choice made)

int get_total_nodes_unlocked() ​

Get total count of unlocked nodes

Array[int] get_unlocked_node_ids() ​

Get array of all unlocked node IDs

int get_total_points_spent() ​

Calculate total points spent across all nodes

int get_total_points_spent_from_pool( pool_id: int ) ​

Get total points spent from a specific pool in this tree

Dictionary get_points_spent_by_pool() ​

Get breakdown of points spent per pool in this tree

Dictionary get_availability( player: Player = null ) ​

Can the player spend points in this tree now? The requirements of the tree, and the dedication of its group (the first tree of the group that gets points is the one the player dedicates to: the others open when a tree of the group has the points the group asks for). Points already in a tree keep it open. Returns {"available": bool, "reason": String}. Without a player the tree is available

Dictionary can_unlock_node( node_id: int, player: Player = null ) ​

Check if a node can be unlocked Returns a dictionary with:

  • can_unlock: bool
  • reason: String (if can_unlock is false)

Array[SkillNode] get_available_nodes( player: Player ) ​

Get all nodes that can currently be unlocked

bool unlock_node_rank( node_id: int, choice_index: int = -1, player: Player = null ) ​

Unlock the next rank of a node For ChoiceSkillNode, choice_index must be provided on first unlock If player is provided, rewards will be automatically applied Returns true if successful

bool refund_node_rank( node_id: int, player: Player = null, full_refund: bool = false ) ​

Refund one rank from a node (or all ranks if full_refund is true) If player is provided, rewards will be automatically unapplied A node that goes back to rank 0 takes with it every unlocked node that needs it (a prerequisite, a required node), and the ones that need those: see get_refund_cascade. Nothing is refunded when can_refund_node says no. Returns true if successful

Array[int] get_refund_cascade( node_id: int ) ​

The unlocked nodes that go back with this one when it is refunded: every node that needs it (a prerequisite connection, or it is in the required nodes of the node), and the nodes that need those, deepest first. The node itself is not in the list

Dictionary can_refund_node( node_id: int, full_refund: bool = false ) ​

Check if a node can be refunded. full_refund: all its ranks (a node with one rank is always refunded whole) Returns a dictionary with:

  • can_refund: bool
  • reason: String (if can_refund is false)
  • also_refunded: Array[int] the nodes that go back with it (see get_refund_cascade), when it can

void reset_all_nodes( player: Player = null ) ​

Reset all nodes to unspent state (full tree respec) If player is provided, all rewards will be unapplied

bool change_choice_node_selection( node_id: int, new_choice_index: int, player: Player ) ​

Change the selected choice for an already-unlocked ChoiceSkillNode This is a respec operation - unapplies old choice rewards and applies new ones Returns true if successful

bool apply_node_rewards( node_id: int, rank: int, player: Player ) ​

Apply rewards for unlocking a node rank Called automatically by unlock_node_rank if player is provided Returns true if all rewards were successfully applied

bool unapply_node_rewards( node_id: int, rank: int, player: Player ) ​

Unapply rewards when refunding a node rank Called automatically by refund_node_rank if player is provided Returns true if all rewards were successfully removed

Dictionary can_respec_node( node_id: int ) ​

Check if a node can be fully refunded (all rewards support unapply) Returns a Dictionary with:

  • "can_respec": bool
  • "reason": String (if can_respec is false)
  • "non_reversible_rewards": Array[String] (summaries of rewards that can't be removed)

Dictionary to_save_data() ​

Convert instance to save data

void restore_from_save_data( save_data: Dictionary, player: Player = null ) ​

Restore state from save data into this existing instance Use this instead of from_save_data() when instance already exists

SkillTreeInstance from_save_data( save_data: Dictionary, tree_def: SkillTree, player: Player = null ) ​

Create instance from save data (legacy/factory method) Prefer using restore_from_save_data() on existing instances

Array[Dictionary] validate() ​

Validate the instance state

bool is_valid() ​

Check if instance is in a valid state