TrainerLesson ​
Inherits: Resource
One thing a trainer teaches, with its price and who may take it.
Description ​
A lesson teaches an ability, a rank of an ability, levels of a proficiency, a profession, levels of a profession, a tier of a proficiency or profession, a specialization, a recipe, or gives any list of rewards. It builds ordinary rewards and gives them with Player.grant_reward(reward, true), so what a lesson gives is saved like what a quest gives. Ranks and levels are sold one step at a time: the lesson always sells the next one, and shows "known" at the highest the trainer teaches. See docs/systems/skill-trainers.md, section 3.2.
Properties ​
Teaches | teaches | Teaches.ABILITY |
String | display_name | "": |
String | description | "": |
Texture2D | icon | |
int | target_id | 0 |
TargetKind | target_kind | TargetKind.PROFICIENCY |
int | tier_index | 1 |
int | specialization_id | 0 |
Array[Reward] | rewards | [] |
int | up_to | 0 |
int | amount | 1 |
LessonCost | cost | |
CalculationFormula | price_formula | |
float | price_multiplier | 1.0 |
Array[Requirement] | requirements | [] |
bool | hide_until_requirements_met | false |
Methods ​
String | get_lesson_name() |
String | get_lesson_description() |
Texture2D | get_lesson_icon() |
Dictionary | get_steps( player: Player ) |
Array[Requirement] | get_implicit_requirements() |
float | get_price_multiplier( from_step: int, to_step: int, trainer: TrainerDefinition = null, system_hub: GameHost.SystemHub = null ) |
Dictionary | get_offer( player: Player, trainer: TrainerDefinition = null, system_hub: GameHost.SystemHub = null ) |
Array[Reward] | build_rewards( from_step: int, to_step: int ) |
Dictionary | learn( player: Player, trainer: TrainerDefinition = null, system_hub: GameHost.SystemHub = null ) |
Array[Dictionary] | validate() |
Enumerations ​
enum Teaches ​
What the lesson teaches
- ABILITY =
0- An ability (the character gets it) - ABILITY_RANK =
1- The next rank of an ability the character has - PROFICIENCY_LEVEL =
2- The next level (or levels) of a proficiency - PROFESSION =
3- A profession (a craft school) that is not learned from the start - PROFESSION_LEVEL =
4- The next level (or levels) of a profession the character has learned - SKILL_TIER =
5- A tier of a proficiency or a profession (Journeyman, Expert, Master) - SPECIALIZATION =
6- A specialization of a proficiency or a profession - RECIPE =
7- A crafting recipe - REWARDS =
8- Any list of rewards: the way to teach anything else. It can be bought again and again: limit it with requirements
enum TargetKind ​
What a tier or a specialization belongs to
- PROFICIENCY =
0 - PROFESSION =
1
enum Status ​
Where the lesson stands for one character
- AVAILABLE =
0- It can be bought now (check the price too) - LOCKED =
1- A requirement is not met: the reason says which - KNOWN =
2- The character has all it teaches
Property descriptions ​
Teaches teaches = Teaches.ABILITY ​
What the lesson teaches
String display_name = "": ​
The name in the list (empty = the name of what it teaches)
String description = "": ​
A line about the lesson (empty = the description of what it teaches)
Texture2D icon ​
An icon (empty = the icon of what it teaches)
What it teaches
int target_id = 0 ​
The ability, the proficiency, the profession or the recipe: its id. For a tier or a specialization it is the id of the proficiency or of the profession (see Target kind)
TargetKind target_kind = TargetKind.PROFICIENCY ​
For a tier or a specialization: is the target a proficiency or a profession?
int tier_index = 1 ​
For a tier: the tier it trains (a number from 0: the first tier). The character must be in the tier before it, at the cap of its level
int specialization_id = 0 ​
For a specialization: its id
Array[Reward] rewards = [] ​
For "rewards": the rewards that are given
int up_to = 0 ​
For ranks and levels: the highest the trainer teaches (0 = as far as it goes)
int amount = 1 ​
For levels: how many levels one purchase gives
Price
LessonCost cost ​
What it costs. Empty = free
CalculationFormula price_formula ​
What the cost is multiplied by, from the step the lesson ends at (rank 3 costs 3x): a formula of the step. Empty = 1 (the number of steps for levels)
float price_multiplier = 1.0 ​
Another multiplier on the whole price
Who can take it
Array[Requirement] requirements = [] ​
What a character needs, besides what the lesson itself needs (the tier before, the ability before)
bool hide_until_requirements_met = false ​
Not met = the lesson is not listed at all. Off: it is listed, greyed, with the reason
Method descriptions ​
String get_lesson_name() ​
The name for the list
String get_lesson_description() ​
The text of the lesson: the one set, else one made from what it teaches.
Texture2D get_lesson_icon() ​
The icon of the lesson: the one set, else the icon of what it teaches.
Dictionary get_steps( player: Player ) ​
The steps: where the character is, how far the lesson goes, and why they cannot go further now. {"current", "ceiling", "blocker"}
Array[Requirement] get_implicit_requirements() ​
The requirements that come from what the lesson teaches (the tier's own, the specialization's own), on top of the ones of the lesson
float get_price_multiplier( from_step: int, to_step: int, trainer: TrainerDefinition = null, system_hub: GameHost.SystemHub = null ) ​
The multiplier of the price for this purchase: the formula of the lesson (or the number of steps), the multiplier of the lesson, and the standing with the trainer
Dictionary get_offer( player: Player, trainer: TrainerDefinition = null, system_hub: GameHost.SystemHub = null ) ​
Everything the panel shows about the lesson for this character: {"status", "reason", "name", "description", "icon", "from_step", "to_step", "multiplier", "cost_text", "affordable", "visible"}
Array[Reward] build_rewards( from_step: int, to_step: int ) ​
The rewards that give what the lesson teaches, for a purchase from a step to a step
Dictionary learn( player: Player, trainer: TrainerDefinition = null, system_hub: GameHost.SystemHub = null ) ​
Buys the lesson for the character: checks that it can be bought, takes the cost, gives what it teaches. All or nothing: if what it teaches cannot be given, what was taken is given back. Returns {"success", "reason"}
Array[Dictionary] validate() ​
========== CHECKS FOR THE EDITOR ==========