Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. # encoding: utf-8
  2. #===============================================================================
  3. # ■ Hidden Skill Switch
  4. #-------------------------------------------------------------------------------
  5. # 2019/12/15 Ruたん
  6. #-------------------------------------------------------------------------------
  7. # If specified switch is ON, certain skill/ item won't show in the list (unusable)
  8. # Possible to create hidden skill/items with a switch through note tag
  9. #
  10. # <Usage>
  11. # Put the following tag in the Note box for skill or item
  12. #
  13. # <hidskill: 1>
  14. #
  15. #  Or
  16. #
  17. # <hiditem: 1>
  18. #
  19. # By using this tag,
  20. # When switch ID: 1 is ON, the item won't show in the list.
  21. # (If you want to change the switch ID, change 1)
  22. #-------------------------------------------------------------------------------
  23. # 【Changelog】
  24. # 2019/12/15 Released
  25. #-------------------------------------------------------------------------------
  26.  
  27. module Torigoya
  28.   module HiddenSkillSwitch
  29.     module Config
  30.       # [Advanced setting] Regular expression in Note box
  31.       # Play here if you want to change the setting method
  32.       NOTE_REGEXP = /<(?:HiddenSkillSwitch|HiddenItemSwitch|hidskill|hiditem):\s*(?<switch_id>\d+)\s*>/
  33.     end
  34.   end
  35. end
  36.  
  37. class RPG::BaseItem
  38.   #--------------------------------------------------------------------------
  39.   # ● Are item switchable in the list?
  40.   #--------------------------------------------------------------------------
  41.   def torigoya_visible_in_list?
  42.     unless instance_variable_defined?(:@torigoya_visible_in_list_switch)
  43.       match = note.match(Torigoya::HiddenSkillSwitch::Config::NOTE_REGEXP)
  44.       @torigoya_visible_in_list_switch = match ? match[:switch_id].to_i : 0
  45.     end
  46.     @torigoya_visible_in_list_switch ? !$game_switches[@torigoya_visible_in_list_switch] : true
  47.   end
  48. end
  49.  
  50. class Game_BattlerBase
  51.   #--------------------------------------------------------------------------
  52.   # ● Skill/Item availability (alias)
  53.   #--------------------------------------------------------------------------
  54.   alias torigoya_hidden_skill_switch_usable? usable?
  55.   def usable?(item)
  56.     return false unless torigoya_hidden_skill_switch_usable?(item)
  57.     item.torigoya_visible_in_list?
  58.   end
  59. end
  60.  
  61. class Window_ItemList < Window_Selectable
  62.   #--------------------------------------------------------------------------
  63.   # ● Whether to include items in the list (alias)
  64.   #--------------------------------------------------------------------------
  65.   alias torigoya_hidden_skill_switch_include? include?
  66.   def include?(item)
  67.     return false unless torigoya_hidden_skill_switch_include?(item)
  68.     item && item.torigoya_visible_in_list?
  69.   end
  70. end
  71.  
  72. class Window_SkillList < Window_Selectable
  73.   #--------------------------------------------------------------------------
  74.   # ● Whether to include items in the list (alias)
  75.   #--------------------------------------------------------------------------
  76.   alias torigoya_hidden_skill_switch_include? include?
  77.   def include?(item)
  78.     return false unless torigoya_hidden_skill_switch_include?(item)
  79.     item && item.torigoya_visible_in_list?
  80.   end
  81. end