• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

How do I make a talent tree?

  • Thread starter Deleted member 16767
  • Start date
D

Deleted member 16767

Guest
I want to make a talent tree but I don't know where to start. What is the most easy approach in making it and so that I won't have trouble with it in the future?
 

CloseRange

Member
Whats a talent tree? I'm guessing you're talking about making a tree of information, but you'll have to be more specific.
More than likely he is referring to talent trees in games not trees in Data Science.
In RPG's usually there are talent trees where the user can choose "talents" from a list that will help to improve the stats/skills of the player. Funny enough though you need a tree data structure usually to make one.

@mikix
I'm not sure how new to programming you are so I'll try a simpler approach.
Make an object called 'obj_talent'
it doesn't need any code it's just gonna be used for organization.
Though it should be set to persistent.

now create a script called addTalent:
Code:
/// addTalent(name, sprite, parent);
var o = instance_create(0, 0, obj_talent);
      o.name = argument[0]; // not needed but most talents will have names
      o.sprite = argument[1]; // also not needed but can be useful to have
      o.parent = argument[2]; // this is needed. Parent is what talent you need to already have learned to learn this talent.
      o.active = (o.parent == noone); // if the parent is noone then you will learn this skill by default (used for the base talent)
return o;
You can add more to this based on what else you need. Such as level requirements, gold requirements, description, ect.
Now I assume you have some object that is persistant and is at the begging of the room. This can be some sort of controller object or game object.
This is an object that is created at the start of the game and is persistant, if you don't have one make one (it can be one just for this talent tree or a global one)
I'll call it obj_controller
in it's create event do this:
Code:
base = addTalent("", 0, noone); // this is a base talent, this isn't a talent you can learn
skill1 = addTalent("Fire", spr_fire, base); // if the talent has a parent of 'base' that means you don't need to learn any other talents to learn this one
skill2 = addTalent("Fire2", spr_fire, skill1); // this one has a parent of skill1 so you need to learn skill1 before learning this one
skill3 = addTalent("Water", spr_water, base); // again this has a parent of 'base' so no other talents are needed to learn this
that's how you can create talents in the tree.
Create a script called talenLearnable:
Code:
/// talentLearnable(talent);
var t = argument[0];
return (t.parent == noone || t.parent.active);
with that script you can see if a talent is able to be learned or not like this:
Code:
if(talentLearnable(obj_controller.skill1)) { // if you can learn the skill
     obj_controller.skill1.active = true; // then learn the skill
}
as for drawing your talent tree and dealing with the interactions on it, I'll leave that to you.
 
D

Deleted member 16767

Guest
Hi again. I used an example from an old topic here on GM forums and it works great. It has draw with it too. Thanks for the help, though! :)
 
Top