Advertisement
roninator2

Yanfly Learn Skill Addon - Hide until Conditions met

Dec 8th, 2024
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.31 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Learn Skill Engine v1.01 - addon
  4. # -- Last Updated: 2012.01.08
  5. # -- Level: Normal, Hard
  6. # -- Requires: n/a
  7. # # Mod by Roninator2
  8. # scan code by TheoAllen
  9. # scan check by Sixth
  10. #==============================================================================
  11. #==============================================================================
  12. # ▼ Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2019.04.16 - Mod addon
  15. # 2019.04.18 - Completed
  16. #==============================================================================
  17. # ▼ Introduction
  18. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  19. # an alternative for actors to learn skills outside of leveling,
  20. # Skills can be hidden until certain requirements are met
  21. #==============================================================================
  22. # -----------------------------------------------------------------------------
  23. # Skill Notetags - These notetags go in the skill notebox in the database.
  24. # -----------------------------------------------------------------------------
  25. # <learn require actor level: x, y>
  26. # x = actor ID, y = actor level
  27. # Sets the skill to require the actor x's current level to be y before the skill
  28. # will show up in the actor's skill learning window.
  29. #==============================================================================
  30.  
  31. class RPG::Skill < RPG::UsableItem
  32.  
  33.   #--------------------------------------------------------------------------
  34.   # public instance variables
  35.   #--------------------------------------------------------------------------
  36.   attr_accessor :learn_require_actor_level
  37.  
  38.   #--------------------------------------------------------------------------
  39.   # common cache: load_notetags_lse
  40.   #--------------------------------------------------------------------------
  41.   alias r2_load_notetags_r2_skill_927   load_notetags_lse
  42.   def load_notetags_lse
  43.    r2_load_notetags_r2_skill_927
  44.    @learn_require_actor_level = {}
  45.    @learn_require_subclass_level = {}
  46.    note.split(/[\r\n]+/).each do |line|
  47.      if line =~ /<learn require actor level\s*:\s*(\d+)\s*,\s*(\d+)>/i
  48.        @learn_require_actor_level[$1.to_i] = $2.to_i
  49.      end
  50.    end
  51.   end
  52.  
  53. end # RPG::Skill
  54.  
  55. class Window_LearnSkillList < Window_SkillList
  56.   #--------------------------------------------------------------------------
  57.   # meet_requirements?
  58.   #--------------------------------------------------------------------------
  59.   def meet_requirements?(item)
  60.     return false if @actor.nil?
  61.     return false unless meet_level_requirements?(item)
  62.     return false unless meet_actor_level_requirements?(item)
  63.     return false unless meet_skill_requirements?(item)
  64.     return false unless meet_switch_requirements?(item)
  65.     return false unless meet_eval_requirements?(item)
  66.     return true
  67.   end
  68.  
  69.   #--------------------------------------------------------------------------
  70.   # meet_level_requirements?
  71.   #--------------------------------------------------------------------------
  72.   def meet_actor_level_requirements?(item)
  73.     return false unless item.learn_require_actor_level[@actor.id]
  74.     return @actor.level >= item.learn_require_actor_level[@actor.id]
  75.   end
  76.  
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement