Yanfly "Skill Learn System" Question

Discussion in 'Javascript/Plugin Support' started by MaxLionheart, Nov 15, 2015.

Thread Status:
Not open for further replies.
  1. MaxLionheart

    MaxLionheart Veteran Veteran

    Messages:
    91
    Likes Received:
    28
    Location:
    Québec
    First Language:
    French
    Hey guys,

    I know nothing in javascript, and I have a little question about how to achieve simple functions with the <Learn Cost Eval> function included in Yanfly's new plugin:

    <Learn Cost Eval>

    code

    code

    </Learn Cost Eval>

    For those who know JavaScript, you can have custom actions be performed

    after learning the skill through the learn skill menu.



    So, basically, what I would like to do is make a specific class forget a specific skill after learning another skill.

    Also, I would like to trigger a switch to on after learning the skill.

    Thanks!
     
    #1
    Yanfly and Fernyfer775 like this.
  2. Fernyfer775

    Fernyfer775 Veteran Veteran

    Messages:
    1,297
    Likes Received:
    800
    First Language:
    English
    I too would like to know how to do this! I'm going to ask around if I can figure it out, I'll return here and post the answer,

    Figured it out myself :D

    Tested and worked, woot, woot!

    Code:
    <Learn Cost Eval>$gameActors.actor(actorid).learnSkill(n);$gameActors.actor(actorud).forgetSkill(;</Learn Cost Eval>
     
    Last edited by a moderator: Nov 16, 2015
    #2
    Yanfly and MaxLionheart like this.
  3. John41617

    John41617 Warper Member

    Messages:
    3
    Likes Received:
    0
    Location:
    New York
    First Language:
    English
    That worked, but it also leaves the old skill in the "Learn Skill" menu, meaning you can learn it again, and then you're back to having both skills. I think we need just one more line of code that removes learned skills from the "Learn Skill" menu.
     
    #3
  4. MaxLionheart

    MaxLionheart Veteran Veteran

    Messages:
    91
    Likes Received:
    28
    Location:
    Québec
    First Language:
    French
    Good find Fernyfer :)

    Well, to avoid the problem of having the old skill remain in the skill list, we could open a switch at the start of the game that allows the basic skill to be learned, and once you learn the advance skill, you close that switch. With the proper notetag, that would prevent that skill from being shown in the list at all. So all we have to do is add another line to the code to flip off the switch.

    That shouldn't be too complicated. I'll give it a look tonight!
     
    #4
  5. kiriseo

    kiriseo Veteran Veteran

    Messages:
    229
    Likes Received:
    74
    First Language:
    German
    You could try something like this:

    <Learn Show Eval>if($gameActors.actor(actorid).isLearnedSkill(n)) {value = false;} else {value = true;}</Learn Show Eval>That has to be in the basic skill you want to "forget".
     
    Last edited by a moderator: Nov 17, 2015
    #5
  6. John41617

    John41617 Warper Member

    Messages:
    3
    Likes Received:
    0
    Location:
    New York
    First Language:
    English
    Hmm, I tried that, but it caused a syntax error when I tried opening the Skills menu.
     
    #6
  7. kiriseo

    kiriseo Veteran Veteran

    Messages:
    229
    Likes Received:
    74
    First Language:
    German
    Oh, sorry. I've forgotten one parenthesis after isLearnedSkill(n).
     
    #7
  8. KinRyuTen

    KinRyuTen Villager Member

    Messages:
    23
    Likes Received:
    1
    First Language:
    English
    This works very well so long as the skill in question requires a previous skill to work.

    Just use the Learn Require Skill notetag to require the player to have the previous skill learned to make sure the screen isn't loaded with useless skills.
     
    #8
  9. Fernyfer775

    Fernyfer775 Veteran Veteran

    Messages:
    1,297
    Likes Received:
    800
    First Language:
    English
    Here's an example of how I did it:

    This is the "default" level 1 skill: SNIPE

    <Learn Require Switch: 32><Learn Custom Text>Default Skill.</Learn Custom Text><Learn Cost Eval>$gameSwitches.setValue(34, true);$gameSwitches.setValue(33, true);</Learn Cost Eval><Learn Cost: 200 JP>This one is the upgraded version of SNIPE option #1:

    <Learn Require Switch: 33><Learn Cost: 150 JP><Learn Custom Text>Increase debuff duration byup to 2-3 turns.</Learn Custom Text><Learn Cost Eval>$gameSwitches.setValue(32, false);$gameSwitches.setValue(34, false);$gameActors.actor(1).learnSkill(20);$gameActors.actor(1).forgetSkill(19);</Learn Cost Eval>This one is the upgraded version of SNIPE option #2:

    <Learn Require Switch: 34><Learn Cost: 150 JP><Learn Custom Text>Increases TP gained from5 to 10 when using thisability.</Learn Custom Text><Learn Cost Eval>$gameSwitches.setValue(32, false);$gameSwitches.setValue(33, false);$gameActors.actor(1).learnSkill(21);$gameActors.actor(1).forgetSkill(19);</Learn Cost Eval>
    At the beginning of the game, I just make sure to turn on the switches for each of my learned skills (not the upgraded versions, just the default ones). Once the "default" skill is learned, the upgraded versions appear via turning on the switches for them. Once one of the upgraded versions of the skill is learned, it turns off all the appropriate switches and teaches the appropriate skill to the right user, this way only the most recently learned version of that skill shows up in the menu in the end.
     
    Last edited by a moderator: Nov 17, 2015
    #9
    cedric44 and MaxLionheart like this.
  10. MaxLionheart

    MaxLionheart Veteran Veteran

    Messages:
    91
    Likes Received:
    28
    Location:
    Québec
    First Language:
    French
    Awesome Fernyfer! I'll try this tonight! Thanks :)
     
    #10
    Fernyfer775 likes this.
  11. cedric44

    cedric44 Villager Member

    Messages:
    5
    Likes Received:
    2
    First Language:
    french
    thanks Fernyfer775 ! your a god! :p

    also thanks for the help Maxlionheart !
     
    #11
    Fernyfer775 and MaxLionheart like this.
  12. Yanfly

    Yanfly Developer

    Messages:
    1,696
    Likes Received:
    2,318
    #12
    MaxLionheart likes this.
  13. MaxLionheart

    MaxLionheart Veteran Veteran

    Messages:
    91
    Likes Received:
    28
    Location:
    Québec
    First Language:
    French
    Awesome Yan! Thanks :)
     
    #13
  14. wqrnm

    wqrnm Warper Member

    Messages:
    2
    Likes Received:
    4
    First Language:
    Chinese
    I found a problem.If your skills setting for one actor can use this method.However if your skill setting for more than one actor(Such as magic skill that many want to learn)you will meet problem that when one has learned others will meet the max level skill.
     
    #14
  15. StefSan

    StefSan Villager Member

    Messages:
    24
    Likes Received:
    6
    Location:
    Germany
    First Language:
    German, English
    Is it possible to make the Skill you can learn to "disable" but already visibile in the list?


    I wanna show the player which skill he can learn with later levels already and what level he needs to be able to learn the skill.


    The script itself is working splendid and I love it. I just try to figure out myself a bit too (not knowledge with JS xD) how to edit it.


    Thanks in advance if anyone can help.  :D
     
    #15
  16. kiriseo

    kiriseo Veteran Veteran

    Messages:
    229
    Likes Received:
    74
    First Language:
    German


    You mean something like this?


    [​IMG]


    To display the skill you'll need


    <Learn Show Eval>
    value = true;
    </Learn Show Eval>


    But this alone would allow the character to learn that skill at any level regardless of requirements.


    For a level requirement you have to use something like this, too:


    <Learn Require Eval>
    if (this._actor.level < 10) { value = false; }
    </Learn Require Eval>


    Now, the skill can't be learned as long as the actor isn't at least level 10.


    For the "Requires Level" text, you can use this tag:

    Code:
    <Learn Custom Text>
    Requires Level 10
    </Learn Custom Text>
     
    #16
    StefSan likes this.
  17. StefSan

    StefSan Villager Member

    Messages:
    24
    Likes Received:
    6
    Location:
    Germany
    First Language:
    German, English
    Thank you so much for the fast help!. Yes. It works and like I wanted.


    I only needed the Learn Require Eval code. thanks a lot  :D :D
     
    Last edited by a moderator: Feb 26, 2016
    #17
  18. staf00

    staf00 Veteran Veteran

    Messages:
    48
    Likes Received:
    5
    First Language:
    English
    Hi, I didn't want to start a new thread since I had a question regarding this plugin. Just not too sure of the terminology I should be using if I want a skill to be learn-able only if skill x is learned and skill y has NOT been learned. Thanks



      <Learn Require Eval>
       value = true;
       value = false;
      </Learn Require Eval>
     
    #18
  19. kiriseo

    kiriseo Veteran Veteran

    Messages:
    229
    Likes Received:
    74
    First Language:
    German


    Then try this:

    Code:
    <Learn Require Eval>
      if(this._actor.isLearnedSkill(X) && !this._actor.isLearnedSkill(Y)) { 
      	value = true; 
      } else {
      	value = false;
      }
    </Learn Require Eval
     
    #19
    Crimson10910 likes this.
  20. staf00

    staf00 Veteran Veteran

    Messages:
    48
    Likes Received:
    5
    First Language:
    English
    Thank you so much! Such an elegant piece of code too lol.
     
    Last edited by a moderator: Feb 28, 2016
    #20
Thread Status:
Not open for further replies.

Share This Page