Advertisement
roninator2

Yanfly Learn Skills - Specific level

Nov 3rd, 2020 (edited)
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.04 KB | Source Code | 0 0
  1. # ╔═════════════════════════════════════╦════════════════════╗
  2. # ║ Title: Learn Skill at this level    ║  Version: 1.00     ║
  3. # ║ Author: Roninator2                  ║                    ║
  4. # ╠═════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                           ║   Date Created     ║
  6. # ║ Yanfly Learn Skills -               ╠════════════════════╣
  7. # ║ Learn skill at specific level       ║    18 Apr 2019     ║
  8. # ╚═════════════════════════════════════╩════════════════════╝
  9. # ╔══════════════════════════════════════════════════════════╗
  10. # ║ A mod for Yanfly's Learn Skills script* Required         ║
  11. # ║ Lets you specify what skills each actor can learn,       ║
  12. # ║ and at which levels to learn them.                       ║
  13. # ║                                                          ║
  14. # ║ Use notetag on skills <learn require actor level: x, y>  ║
  15. # ║ Sets the skill to require the actor x's current          ║
  16. # ║ level to be y before the skill will show up in the       ║
  17. # ║ actor's skill learning window.                           ║
  18. # ║ x = actor ID, y = actor level                            ║
  19. # ╚══════════════════════════════════════════════════════════╝
  20. # ╔═════════════════════════════════════╗
  21. # ║ Terms of use:                       ║
  22. # ║ Follow the Original Authors terms   ║
  23. # ╚═════════════════════════════════════╝
  24.  
  25. class RPG::Skill < RPG::UsableItem
  26.  
  27.   #--------------------------------------------------------------------------
  28.   # public instance variables
  29.   #--------------------------------------------------------------------------
  30.   attr_accessor :learn_require_actor_level
  31.  
  32.   #--------------------------------------------------------------------------
  33.   # common cache: load_notetags_lse
  34.   #--------------------------------------------------------------------------
  35.   alias r2_load_notetags_r2_skill_927   load_notetags_lse
  36.   def load_notetags_lse
  37.     r2_load_notetags_r2_skill_927
  38.     @learn_require_actor_level = {}
  39.     note.split(/[\r\n]+/).each do |line|
  40.       if line =~ /<learn require actor level\s*:\s*(\d+)\s*,\s*(\d+)>/i
  41.         @learn_require_actor_level[$1.to_i] = $2.to_i
  42.       end
  43.     end
  44.   end
  45. end # RPG::Skill
  46.  
  47. class Window_LearnSkillList < Window_SkillList
  48.  
  49.   attr_accessor :learn_require_actor_level
  50.   #--------------------------------------------------------------------------
  51.   # meet_requirements?
  52.   #--------------------------------------------------------------------------
  53.   def meet_requirements?(item)
  54.     return false if @actor.nil?
  55.     return false unless meet_level_requirements?(item)
  56.     return false unless meet_actor_level_requirements?(item)
  57.     return false unless meet_skill_requirements?(item)
  58.     return false unless meet_switch_requirements?(item)
  59.     return false unless meet_eval_requirements?(item)
  60.     return true
  61.   end
  62.  
  63.   #--------------------------------------------------------------------------
  64.   # meet_level_requirements?
  65.   #--------------------------------------------------------------------------
  66.   def meet_actor_level_requirements?(item)
  67.     return false unless item.learn_require_actor_level[@actor.id]
  68.     return @actor.level >= item.learn_require_actor_level[@actor.id]
  69.   end  
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement