Advertisement
TheoAllen

YEA - Hide Menu Skill

Mar 30th, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.93 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Hide Menu Skills v1.01
  4. # -- Last Updated: 2011.12.11
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-HideMenuSkills"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2011.12.11 - Started Script and Finished.
  17. #            - Added <hide eval> notetags.
  18. #
  19. #==============================================================================
  20. # ▼ Introduction
  21. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. # Have some skills you want hidden until certain conditions are met? Well, now
  23. # you can! This script will only hide the skills from the default skill list
  24. # menus. Anything that displays otherwise may or may not hide them depending on
  25. # the script and what it bases off of.
  26. #
  27. #==============================================================================
  28. # ▼ Instructions
  29. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  30. # To install this script, open up your script editor and copy/paste this script
  31. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  32. #
  33. # -----------------------------------------------------------------------------
  34. # Skill Notetags - These notetags go in the skills notebox in the database.
  35. # -----------------------------------------------------------------------------
  36. # <hide always>
  37. # This skill will always be hidden from the default skill list windows.
  38. #
  39. # <hide in battle>
  40. # This skill will always be hidden from the default skill window in battle.
  41. #
  42. # <hide until usable>
  43. # This will require the skill to be usable before it appears in the window.
  44. #
  45. # <hide if switch: x>
  46. # This skill will be hidden if switch x is on. The skill will be shown if
  47. # switch x is off. This switch is considered part of the "any" category.
  48. #
  49. # <hide any switch: x>
  50. # <hide any switch: x, x>
  51. # This skill will be hidden if any of the switches x is on. Use multiple tags
  52. # or separate the switch ID's with commas.
  53. #
  54. # <hide all switch: x>
  55. # <hide all switch: x, x>
  56. # This skill will be hidden until all of the switches x are on. Use multiple
  57. # tags or separate the switch ID's with commas.
  58. #
  59. # <hide eval>
  60. #  string
  61. #  string
  62. # </hide eval>
  63. # For the more advanced users, replace string with lines of code to check for
  64. # whether or not to hide the skill. If multiple lines are used, they are all
  65. # considered part of the same line.
  66. #
  67. #==============================================================================
  68. # ▼ Compatibility
  69. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  70. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  71. # it will run with RPG Maker VX without adjusting.
  72. #
  73. #==============================================================================
  74. # ▼ Editting anything past this point may potentially result in causing
  75. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  76. # halitosis so edit at your own risk.
  77. #==============================================================================
  78.  
  79. module YEA
  80.   module REGEXP
  81.   module SKILL
  82.    
  83.     HIDE_ALWAYS     = /<(?:HIDE_ALWAYS|hide always)>/i
  84.     HIDE_IN_BATTLE  = /<(?:HIDE_IN_BATTLE|hide in battle)>/i
  85.     HIDE_IF_SWITCH  = /<(?:HIDE_IF_SWITCH|hide if switch):[ ](\d+)>/i
  86.     HIDE_UNTIL_USABLE = /<(?:HIDE_UNTIL_USABLE|hide until usable)>/i
  87.    
  88.     HIDE_ANY_SWITCH =
  89.       /<(?:HIDE_ANY_SWITCH|hide any switch):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  90.     HIDE_ALL_SWITCH =
  91.       /<(?:HIDE_ALL_SWITCH|hide all switch):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  92.    
  93.     HIDE_EVAL_ON  = /<(?:HIDE_EVAL|hide eval)>/i
  94.     HIDE_EVAL_OFF = /<\/(?:HIDE_EVAL|hide eval)>/i
  95.    
  96.   end # SKILL
  97.   end # REGEXP
  98. end # YEA
  99.  
  100. #==============================================================================
  101. # ■ DataManager
  102. #==============================================================================
  103.  
  104. module DataManager
  105.  
  106.   #--------------------------------------------------------------------------
  107.   # alias method: load_database
  108.   #--------------------------------------------------------------------------
  109.   class <<self; alias load_database_hms load_database; end
  110.   def self.load_database
  111.     load_database_hms
  112.     load_notetags_hms
  113.   end
  114.  
  115.   #--------------------------------------------------------------------------
  116.   # new method: load_notetags_hms
  117.   #--------------------------------------------------------------------------
  118.   def self.load_notetags_hms
  119.     groups = [$data_skills]
  120.     for group in groups
  121.       for obj in group
  122.         next if obj.nil?
  123.         obj.load_notetags_hms
  124.       end
  125.     end
  126.   end
  127.  
  128. end # DataManager
  129.  
  130. #==============================================================================
  131. # ■ RPG::Skill
  132. #==============================================================================
  133.  
  134. class RPG::Skill < RPG::UsableItem
  135.  
  136.   #--------------------------------------------------------------------------
  137.   # public instance variables
  138.   #--------------------------------------------------------------------------
  139.   attr_accessor :hide_always
  140.   attr_accessor :hide_in_battle
  141.   attr_accessor :hide_any_switch
  142.   attr_accessor :hide_all_switch
  143.   attr_accessor :hide_until_usable
  144.   attr_accessor :hide_eval
  145.  
  146.   #--------------------------------------------------------------------------
  147.   # common cache: load_notetags_hms
  148.   #--------------------------------------------------------------------------
  149.   def load_notetags_hms
  150.     @hide_eval = nil
  151.     @hide_any_switch = []
  152.     @hide_all_switch = []
  153.     #---
  154.     self.note.split(/[\r\n]+/).each { |line|
  155.       case line
  156.       #---
  157.       when YEA::REGEXP::SKILL::HIDE_ALWAYS
  158.         @hide_always = true
  159.       when YEA::REGEXP::SKILL::HIDE_IN_BATTLE
  160.         @hide_in_battle = true
  161.       when YEA::REGEXP::SKILL::HIDE_UNTIL_USABLE
  162.         @hide_until_usable = true
  163.       when YEA::REGEXP::SKILL::HIDE_IF_SWITCH
  164.         @hide_any_switch.push($1.to_i)
  165.       when YEA::REGEXP::SKILL::HIDE_ANY_SWITCH
  166.         $1.scan(/\d+/).each { |num|
  167.         @hide_any_switch.push(num.to_i) if num.to_i > 0 }
  168.       when YEA::REGEXP::SKILL::HIDE_ALL_SWITCH
  169.         $1.scan(/\d+/).each { |num|
  170.         @hide_all_switch.push(num.to_i) if num.to_i > 0 }
  171.       when YEA::REGEXP::SKILL::HIDE_EVAL_ON
  172.         @hide_eval_on = true
  173.       when YEA::REGEXP::SKILL::HIDE_EVAL_OFF
  174.         @hide_eval_on = false
  175.       else
  176.         next unless @hide_eval_on
  177.         @hide_eval = "" if @hide_eval.nil?
  178.         @hide_eval += line.to_s
  179.       #---
  180.       end
  181.     } # self.note.split
  182.     #---
  183.   end
  184.  
  185. end # RPG::Skill
  186.  
  187. #==============================================================================
  188. # ■ Window_SkillList
  189. #==============================================================================
  190.  
  191. class Window_SkillList < Window_Selectable
  192.  
  193.   #--------------------------------------------------------------------------
  194.   # overwrite method: include?
  195.   #--------------------------------------------------------------------------
  196.   def include?(item)
  197.     return false if hide_eval?(item)
  198.     return false if item.hide_always
  199.     return false if item.hide_in_battle && $game_party.in_battle
  200.     return false if hide_any_switch?(item)
  201.     return false if hide_all_switch?(item)
  202.     unless @actor.nil?
  203.       return false if item.hide_until_usable && !@actor.usable?(item)
  204.     end
  205.     return item && item.stype_id == @stype_id
  206.   end
  207.  
  208.   #--------------------------------------------------------------------------
  209.   # new method: hide_eval?
  210.   #--------------------------------------------------------------------------
  211.   def hide_eval?(item)
  212.     return false if item.hide_eval.nil?
  213.     return eval(item.hide_eval)
  214.   end
  215.  
  216.   #--------------------------------------------------------------------------
  217.   # new method: hide_any_switch?
  218.   #--------------------------------------------------------------------------
  219.   def hide_any_switch?(item)
  220.     for switch_id in item.hide_any_switch
  221.       return true if $game_switches[switch_id]
  222.     end
  223.     return false
  224.   end
  225.  
  226.   #--------------------------------------------------------------------------
  227.   # new method: hide_all_switch?
  228.   #--------------------------------------------------------------------------
  229.   def hide_all_switch?(item)
  230.     return false if item.hide_all_switch == []
  231.     for switch_id in item.hide_all_switch
  232.       return false unless $game_switches[switch_id]
  233.     end
  234.     return true
  235.   end
  236.  
  237. end # Window_SkillList
  238.  
  239. #==============================================================================
  240. #
  241. # ▼ End of File
  242. #
  243. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement