Loading

N_X_LearnSkillOnJobLevel

  1. /*:
  2.  * @plugindesc v1.0 (Requires YEP_JobPoints, FoxJPLevels) Learn skills by JP level
  3.  * @author ThinkNathan
  4.  
  5.  * @help Learn skills based on JP level.
  6.  
  7.  * Requires YEP_JobPoints, FoxJPLevels
  8.  * Put this plugin BELOW all other plugins
  9.  
  10.  */
  11.  
  12. // Alias existing method from FoxJPLevels
  13. Game_Actor_gainJp = Game_Actor.prototype.gainJp;
  14. Game_Actor.prototype.gainJp = function(value, classId) {
  15.   Game_Actor_gainJp.call(this, value, classId);
  16.   this.jpLearnSkills(classId);
  17. }
  18.  
  19. // New method
  20. Game_Actor.prototype.jpLearnSkills = function(classId) {
  21.   this.currentClass().learnings.forEach(function(learning) {
  22.       if (this.jpLevel(classId) >= learning.level) {
  23.           this.learnSkill(learning.skillId);
  24.       }
  25.   }, this);
  26. }
  27.  
  28. // Overwrite Yanfly method from YEP_ClassChangeCore
  29. Game_Actor.prototype.updateLearnedSkills = function(classId) {
  30.     if (!Fox.JPLevels) return;
  31.     if (!$dataClasses[classId]) return;
  32.     $dataClasses[classId].learnings.forEach(function(learning) {
  33.         if (this.jpLevel(classId) >= learning.level) {
  34.           this.learnSkill(learning.skillId);
  35.         }
  36.     }, this);
  37. };