Skill Trees System

● ARCHIVED · READ-ONLY
Started by SomeFire 312 posts Page 15 of 16 View original ↗
  1. How would I reference the variables for a reseted skill? I'm not a super advanced javascript user :rswt
  2. gambitben said:
    How would I reference the variables for a reseted skill? I'm not a super advanced javascript user :rswt
    Replace this function
    Spoiler
    Code:
    SkillTreesSystem.resetSkillTree = function(actor, tree) {
        let points = 0;
    
        for (let skill of tree.skills) {
            if (!skill || skill.type !== "skill" || skill.level === 0)
                continue;
    
            for (let i = 0; i < skill.level; i++) {
                for (let req of skill.reqs[i]) {
                    if (req.type === "points")
                        points += req.price;
                }
    
                if (!skill.learnActions || !skill.learnActions[i])
                    continue;
    
                for (let learnAction of skill.learnActions[i]) {
                    if (learnAction.type === "game_variable") {
                        let oldVal = $gameVariables.value(learnAction.varId);
    
                        $gameVariables.setValue(learnAction.varId, oldVal - learnAction.inc)
                    }
                }
            }
    
            skill.forget(actor);
            skill.level = 0;
        }
    
        tree.points = 0;
    
        actor.refresh();
    
        return points;
    };
  3. Works like a charm, thank you! If I could like this post five times I would ;D
  4. Hey @SomeFire, is it possible for one tree to be wider than another tree? Like if an actor has 3 trees, but I want 1 of those trees to have/show more skills in the row. In referring to this parameter:
    1639039477086.png
    I basically need the 1st tree to show 11 skills in a row instead of 7.
  5. It requires some coding. You need to replace usages of SkillTreesSystem.skillWindowMaxCols and SkillTreesSystem.skillWindowDrawCols by condition with your tree. For example:
    Code:
    Skills_Window.prototype.maxCols = function() {
        return SkillTreesSystem.skillWindowMaxCols;
    };
    Skills_Window.prototype.maxCols = function() {
        if (this._tree != null && this._tree.symbol == `SymbolOfYourSpecificTree`) {
            return 11;
        }
        return SkillTreesSystem.skillWindowMaxCols;
    };
    
    Skills_Window.prototype.windowWidth = function() {
        return this.itemWidth() * SkillTreesSystem.skillWindowDrawCols + this.standardPadding() * 2;
    };
    Skills_Window.prototype.windowWidth = function() {
        if (this._tree != null && this._tree.symbol == `SymbolOfYourSpecificTree`) {
            this.itemWidth() * 11 + this.standardPadding() * 2;
        }
        return this.itemWidth() * SkillTreesSystem.skillWindowDrawCols + this.standardPadding() * 2;
    };
  6. @SomeFire Is there a way to add a custom background image for the skill trees? Thx.
  7. Frostorm said:
    @SomeFire Is there a way to add a custom background image for the skill trees? Thx.
    Use plugin SRD_MenuBackground
    add Scene_SkillTrees on custom Scene


    1643474949334.png
  8. Cool, but can it be a different image for each tree? For example, I only want to add a background to the section highlighted in red and I'd need it to be a different image for each tree. Thx

    1643482812539.png
  9. You can always try reducing the transparency of only that small window either manually or using something like SumRndmDde's Super Tools Engine, and then doing a show image command with the background you want right before the script call to open the skill tree scene, then an erase image command right after the script call
  10. Hi. Can someone provide more specific instructions? I am constantly getting different errors. In this case, I can completely change the skill and everything works, another time just change its name and catch the error. Maybe it's because of my low skills, but this plugin seems simple.
  11. Hi,It's me again. How could I make some variables related with the learned skillpoints or get the value when a new skill is learned , so that I can make the damage increasing while a skill is learned.:LZSsmile:thanks~
  12. So I'm trying to change the text shown for the skill requirements section near the bottom of the skill description window. I want it to say "x points spent in [name of tree]" instead. I know this is the code block to edit:
    JavaScript:
    class TreePointsRequirement extends Requirement {
        constructor(points) {
            if (!points)
                points = 1;
            else if (points < 1)
                throw new RangeError("Points must be an integer greater than 0.");
         
            super("tree_points");
            this.points = points;
        }
    
        meets(actor, tree) {
            return tree.points >= this.points;
        }
    
        text() {
            return this.points + " points in " + tree.symbol;
        }
    }

    But I'm getting an error cuz the "tree" in tree.symbol isn't defined. I just don't know what to put in order to reference the name/symbol of the current skill tree in question.
    1645916311476.png
  13. I found a solution!!
    JavaScript:
    class TreePointsRequirement extends Requirement {
        constructor(points) {
            if (!points)
                points = 1;
            else if (points < 1)
                throw new RangeError("Points must be an integer greater than 0.");
          
            super("tree_points");
            this.points = points;
        }
    
        meets(actor, tree) {
            this.treeSymbol = tree.symbol;
            return tree.points >= this.points;
        }
    
        text() {
            return this.points + " points in " + this.treeSymbol;
        }
    }

    Edit: But I have another issue. I want to get rid of the text that shows up stating how many points a skill costs. Since all the nodes in my skill trees always cost 1 point, it seems redundant/superfluous to have that line there. Here's what I'm talking about (the "1 Skill Point" text):

    1646183770350.png

    Edit2: I was able to remove the text, but the space where the text was remains...help!
    1646184586386.png
  14. Frostorm said:
    I found a solution!!
    JavaScript:
    class TreePointsRequirement extends Requirement {
        constructor(points) {
            if (!points)
                points = 1;
            else if (points < 1)
                throw new RangeError("Points must be an integer greater than 0.");
       
            super("tree_points");
            this.points = points;
        }
    
        meets(actor, tree) {
            this.treeSymbol = tree.symbol;
            return tree.points >= this.points;
        }
    
        text() {
            return this.points + " points in " + this.treeSymbol;
        }
    }

    Edit: But I have another issue. I want to get rid of the text that shows up stating how many points a skill costs. Since all the nodes in my skill trees always cost 1 point, it seems redundant/superfluous to have that line there. Here's what I'm talking about (the "1 Skill Point" text):

    View attachment 217940

    Edit2: I was able to remove the text, but the space where the text was remains...help!
    View attachment 217942
    Find this function in SkillTreesSystem.json and add condition to continue without drawing line.
    Spoiler
    Code:
    Description_Window.prototype.drawRequirements = function(reqs, y) {
        for (let i = 0; i < reqs.length; i++) {
            let req = reqs[i];
    
            if (req.text() == null)
                continue;
    
            if (req.meets(this._actor, this._tree))
                this.changeTextColor(this.powerUpColor());
            else
                this.changeTextColor(this.powerDownColor());
    
            this.drawText(req.text(), 0, y);
    
            y += this.lineHeight();
        }
    
        this.changeTextColor(this.normalColor());
    };
    vorfeed said:
    Hi,It's me again. How could I make some variables related with the learned skillpoints or get the value when a new skill is learned , so that I can make the damage increasing while a skill is learned.:LZSsmile:thanks~
    Check demo and see SkillTreesConfig.js. There is "guard2" skill, which increment game variable when learned.
    guard2
    Code:
    guard2 = skill('guard2', [2], [
        [cost(1), switchReq(1)], // Requires switch 1 to be true.
    ], [
        [changeVar(1, 2)] // On learn action, which increase the game variable 1 by 2.
    ]);
  15. SomeFire said:
    Check demo and see SkillTreesConfig.js. There is "guard2" skill, which increment game variable when learned.
    guard2
    Code:
    guard2 = skill('guard2', [2], [
        [cost(1), switchReq(1)], // Requires switch 1 to be true.
    ], [
        [changeVar(1, 2)] // On learn action, which increase the game variable 1 by 2.
    ]);
    cool! I get it ! Thanks very much!
    And How can I get the different Actor's learned skillpoints?
  16. I'm not sure that I correctly understand what do you want. Skillpoints can't be learned, they are "money" for skills.
  17. SomeFire said:
    I'm not sure that I correctly understand what do you want. Skillpoints can't be learned, they are "money" for skills.
    Sorry>.<
    I want to get one character's used skillpoints in a skilltree. Actually It is the value that has displayed,but i'm poor in the codes. I want to make a variable equal to the character's learnedskills points in a skilltree, or I could say that I want to get the value of “money” for the learned skills. *.*:LZSproud:
  18. Code:
    actor.skillTrees.getTree('tree_symbol').points
    Where actor is Game_Actor object, and 'tree_symbol' is tree identificator. This code can be used in scripts only. Not sure about formulas.
  19. Hi @SomeFire, is there any script call or command to show skill tress for a specific actor that is not at the party? something like this script SceneManager.push(Scene_SkillTrees) but for a specific actor.
  20. Holà,

    I've been looking through both the code of this plugin via VisualCode and the GitHub tutorial for hours on end but I just don't get it at all. I've got basically no experience with actual coding, so that really doesn't help there.

    So here's my main issue:
    I planned on each character in my game having a core "character tree" with exclusive skills, and then a bunch of more generic trees (Like supporting/defensive/aggressive ones) that are global to all characters, but I can't figure for the life of me how the trees are distributed by default, and how I can change them.
    For instance, my third character (By ID order) has basically every single sample tree unlocked but I just can't figure why and where I'm supposed to edit that. Meanwhile my 1st character only has 3?

    I'd be very grateful if anyone more experienced could guide me through this a bit,

    Thanks in advance!