Advertisement
roninator2

Yanfly Learn Skill Addon - Hide until Conditions met - Subclass

Dec 8th, 2024
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.41 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Learn Skill Engine v1.00 - 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. # 2020.04.24 - Added support for yanfly class
  17. #==============================================================================
  18. # ▼ Introduction
  19. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  20. # an alternative for actors to learn skills outside of leveling,
  21. # Skills can be hidden until certain requirements are met
  22. #==============================================================================
  23. # -----------------------------------------------------------------------------
  24. # Skill Notetags - These notetags go in the skill notebox in the database.
  25. # -----------------------------------------------------------------------------
  26. # <learn require actor level: x, y>
  27. # <learn require subclass level: x, y> # yanfly class support
  28. # x = actor ID, y = actor level
  29. # Sets the skill to require the actor x's current level to be y before the skill
  30. # will show up in the actor's skill learning window.
  31. #==============================================================================
  32.  
  33. class RPG::Skill < RPG::UsableItem
  34.  
  35.   #--------------------------------------------------------------------------
  36.   # public instance variables
  37.   #--------------------------------------------------------------------------
  38.   attr_accessor :learn_require_actor_level
  39.   attr_accessor :learn_require_subclass_level
  40.   attr_accessor :learn_require_actor_id
  41.   attr_accessor :learn_require_subclass_id
  42.  
  43.   #--------------------------------------------------------------------------
  44.   # common cache: load_notetags_lse
  45.   #--------------------------------------------------------------------------
  46.   alias r2_load_notetags_r2_skill_927   load_notetags_lse
  47.   def load_notetags_lse
  48.    r2_load_notetags_r2_skill_927
  49.    @learn_require_actor_level = {}
  50.    @learn_require_subclass_level = {}
  51.    @learn_require_actor_id = {}
  52.    @learn_require_subclass_id = {}
  53.    note.split(/[\r\n]+/).each do |line|
  54.      if line =~ /<learn require actor level\s*:\s*(\d+)\s*,\s*(\d+)>/i
  55.        @learn_require_actor_level[$1.to_i] = $2.to_i
  56.        @learn_require_actor_id[$1.to_i] = $1.to_i
  57.      end
  58.      if line =~ /<learn require subclass level\s*:\s*(\d+)\s*,\s*(\d+)>/i
  59.        @learn_require_subclass_level[$1.to_i] = $2.to_i
  60.        @learn_require_subclass_id[$1.to_i] = $1.to_i
  61.      end
  62.    end
  63.   end
  64.  
  65. end # RPG::Skill
  66.  
  67. class Window_LearnSkillList < Window_SkillList
  68.   #--------------------------------------------------------------------------
  69.   # meet_requirements?
  70.   #--------------------------------------------------------------------------
  71.   def meet_requirements?(item)
  72.     return false if @actor.nil?
  73.     return false unless meet_level_requirements?(item)
  74.     return false unless meet_actor_level_requirements?(item)
  75.     return false unless meet_skill_requirements?(item)
  76.     return false unless meet_switch_requirements?(item)
  77.     return false unless meet_eval_requirements?(item)
  78.     return true
  79.   end
  80.  
  81.   #--------------------------------------------------------------------------
  82.   # meet_level_requirements?
  83.   #--------------------------------------------------------------------------
  84.   def meet_actor_level_requirements?(item)
  85.     if $imported["YEA-ClassSystem"]
  86.       actor = @actor
  87.       if actor.subclass.nil?
  88.         # actor alone
  89.         return false if item.learn_require_actor_id.empty? &&
  90.         !item.learn_require_subclass_id.empty?
  91.         return true if item.learn_require_actor_id.empty? &&
  92.         actor.class.learn_skills.include?(item.id) &&
  93.         !item.learn_require_subclass_id.empty?
  94.         return true if item.learn_require_actor_id.empty? &&
  95.         actor.class.learn_skills.include?(item.id) && !item.learn_cost.empty?
  96.         return false unless item.learn_require_actor_level[@actor.id]
  97.         return @actor.level >= item.learn_require_actor_level[@actor.id]
  98.       else
  99.         # actor with subclass
  100.         return true if item.learn_require_actor_id.empty? &&
  101.         actor.class.learn_skills.include?(item.id) &&
  102.         item.learn_require_subclass_id.empty?
  103.         # subclass
  104.         return true if item.learn_require_subclass_id.empty? &&
  105.         actor.subclass.learn_skills.include?(item.id)
  106.         return true if item.learn_require_subclass_id.empty? &&
  107.         actor.subclass.learn_skills.include?(item.id) &&
  108.         item.learn_require_actor_id.empty?
  109.         return true if item.learn_require_actor_id.empty? &&
  110.         item.learn_require_subclass_id.empty? && item.learn_cost.empty?
  111.         sublevel = actor.class_level(actor.subclass.id)
  112.         # combined
  113.         if !item.learn_require_actor_level[@actor.id].nil?
  114.           return @actor.level >= item.learn_require_actor_level[@actor.id]
  115.         end
  116.         if !item.learn_require_subclass_level[actor.subclass.id].nil?
  117.           return sublevel >= item.learn_require_subclass_level[actor.subclass.id]
  118.         end
  119.       end
  120.     end
  121.   end
  122. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement