Advertisement
roninator2

Neon Black Effect Box - Feature hide

Nov 3rd, 2020 (edited)
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.69 KB | Source Code | 0 0
  1. # ╔═════════════════════════════════════╦════════════════════╗
  2. # ║ Title: Effect Box Feature hide      ║  Version: 1.00     ║
  3. # ║ Author: Roninator2                  ║                    ║
  4. # ╠═════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                           ║   Date Created     ║
  6. # ║ Neon Black Effect Box -             ╠════════════════════╣
  7. # ║ Hide Features from effect box       ║    01 Nov 2020     ║
  8. # ╚═════════════════════════════════════╩════════════════════╝
  9. # ╔══════════════════════════════════════════════════════════╗
  10. # ║ A mod to Neon Blacks Effect Box                          ║
  11. # ║ Allows to hide effects (features)                        ║
  12. # ║                                                          ║
  13. # ║ Use notetag on items, weapons, armours or skills         ║
  14. # ║ <no effect: X>                                           ║
  15. # ║ where X is the number for the effect                     ║
  16. # ║ *The first effect is 1 the second 2, etc.                ║
  17. # ║ Useful for things like calling common events             ║
  18. # ╚══════════════════════════════════════════════════════════╝
  19. # ╔═════════════════════════════════════╗
  20. # ║ Terms of use:                       ║
  21. # ║ Follow the Original Authors terms   ║
  22. # ╚═════════════════════════════════════╝
  23. # ╔══════════════════════════════════════════════════════════╗
  24. # ║ Notes                                                    ║
  25. # ║ If an item has no effects and an empty note box,         ║
  26. # ║ no effect box will be shown.                             ║
  27. # ║ If you have one effect and nothing in the note box,      ║
  28. # ║ then effect box will be shown even if you use            ║
  29. # ║ <no effect: 1> it will just be empty                     ║
  30. # ║ In those circumstances put the normal <effect note>      ║
  31. # ║ in the note box with some info, then it won't look as bad║
  32. # ╚══════════════════════════════════════════════════════════╝
  33.  
  34. # also fixed some bugs from the original script
  35.  
  36. module R2
  37.   module Effect_Box
  38.     Regex = /<no[-_ ]effect:[-_ ]\s*(\d+)\s*>/imx
  39.   end
  40. end
  41.  
  42. class Window_Selectable < Window_Base
  43.   def key_show_features_box
  44.     case CP::EFFECTS_WINDOW::SHOW_TYPE
  45.     when 0
  46.       return Input.press?(CP::EFFECTS_WINDOW::BOX_KEY)
  47.     when 1
  48.       @show = !@show if Input.trigger?(CP::EFFECTS_WINDOW::BOX_KEY)
  49.       return @show
  50.     when 2
  51.       return true
  52.     else
  53.       return false
  54.     end
  55.   end
  56. end
  57.  
  58. class Window_FeaturesShow < Window_Base
  59.  
  60.   def notes
  61.     @item.effect_desc
  62.   end
  63.  
  64.   def effects
  65.     if @item.is_a?(RPG::EquipItem)
  66.       @item.features
  67.     elsif @item.is_a?(RPG::UsableItem)
  68.       @item.effects
  69.     end
  70.   end
  71.  
  72.   def seps
  73.     i = 0
  74.     i += 1 unless effects.empty?
  75.     i += 1 unless notes.empty?
  76.     i += 1 unless stats.empty?
  77.     return [i, 0].max
  78.   end
  79.  
  80.   def draw_all_items
  81.     contents.clear
  82.     y = 0
  83.     notes.each do |l|
  84.       draw_text(1, y, contents.width, line_height, l)
  85.       y += line_height
  86.     end
  87.     y += line_height / 2 unless y == 0
  88.     unless stats.empty?
  89.       w = stats.collect{|s| contents.text_size(s).width}.max + 2
  90.       xt = contents.width / w
  91.       xw = contents.width / xt
  92.       xn = 0
  93.       y -= line_height
  94.       stats.each_with_index do |s, index|
  95.         y += line_height if index % xt == 0
  96.         case s
  97.         when /(.*)   (-?)(\d+)/i
  98.           draw_text(xw * (index % xt) + 1, y, xw, line_height, "#{$1.to_s}")
  99.           draw_text(xw * (index % xt) + 1, y, xw, line_height,
  100.                     "#{$2.to_s}#{$3.to_s}  ", 2)
  101.         end
  102.       end
  103.       y += line_height
  104.     end
  105.     y += line_height / 2 unless y == 0
  106.     # Start of my code
  107.     effcount = 1
  108.     effects.each_with_index do |e, effnum|
  109.       item = $data_items[@item.id]
  110.       results = item.note.scan(R2::Effect_Box::Regex)
  111.       results.each do |res|
  112.         effid = res[0].to_i - 1
  113.         if effnum == effid
  114.           effcount = 2
  115.           self.height -= line_height
  116.         end
  117.       end
  118.       item = $data_weapons[@item.id]
  119.       results = item.note.scan(R2::Effect_Box::Regex)
  120.       results.each do |res|
  121.         effid = res[0].to_i - 1
  122.         if effnum == effid
  123.           effcount = 2
  124.           self.height -= line_height
  125.         end
  126.       end
  127.       item = $data_armors[@item.id]
  128.       results = item.note.scan(R2::Effect_Box::Regex)
  129.       results.each do |res|
  130.         effid = res[0].to_i - 1
  131.         if effnum == effid
  132.           effcount = 2
  133.           self.height -= line_height
  134.         end
  135.       end
  136.       skill = $data_skills[@item.id]
  137.       results = skill.note.scan(R2::Effect_Box::Regex)
  138.       results.each do |res|
  139.         effid = res[0].to_i - 1
  140.         if effnum == effid
  141.           effcount = 2
  142.           self.height -= line_height
  143.         end
  144.       end
  145. #~       if item.class == RPG::Skill
  146. #~         @skill = item
  147. #~         data_id = @item.effects[effnum].data_id
  148. #~         if data_id == 0; self.height -= line_height; next; end
  149. #~       end
  150.       if effcount == 1
  151.           draw_text(1, y, contents.width, line_height, e.vocab)
  152.           y += line_height
  153.       else
  154.         effcount = 1
  155.       end
  156.     end
  157.   end
  158. end
  159.  
  160. class RPG::UsableItem < RPG::BaseItem
  161.  
  162.   def effect_desc
  163.     make_effect_desc if @effect_desc.nil?
  164.     return @effect_desc
  165.   end
  166.  
  167.   def make_effect_desc
  168.     @effect_desc = []
  169.     results = self.note.scan(/<effect[-_ ]*note>(.*?)<\/effect[-_ ]*note>/imx)
  170.     results.each do |res|
  171.       res[0].strip.split("\r\n").each do |line|
  172.       @effect_desc.push("#{line}")
  173.       end
  174.     end
  175.   end
  176.  
  177. end
  178.  
  179. class RPG::EquipItem < RPG::BaseItem
  180.  
  181.   def effect_desc
  182.     make_effect_desc if @effect_desc.nil?
  183.     return @effect_desc
  184.   end
  185.  
  186.   def make_effect_desc
  187.     @effect_desc = []
  188.     results = self.note.scan(/<effect[-_ ]*note>(.*?)<\/effect[-_ ]*note>/imx)
  189.     results.each do |res|
  190.       res[0].strip.split("\r\n").each do |line|
  191.       @effect_desc.push("#{line}")
  192.       end
  193.     end
  194.   end
  195.  
  196. end
  197.  
  198. class RPG::Skill < RPG::UsableItem
  199.  
  200.   def effect_desc
  201.     make_effect_desc if @effect_desc.nil?
  202.     return @effect_desc
  203.   end
  204.  
  205.   def make_effect_desc
  206.     @effect_desc = []
  207.     results = self.note.scan(/<effect[-_ ]*note>(.*?)<\/effect[-_ ]*note>/imx)
  208.     results.each do |res|
  209.       res[0].strip.split("\r\n").each do |line|
  210.       @effect_desc.push("#{line}")
  211.       end
  212.     end
  213.   end
  214.  
  215. end
  216.  
  217. ###--------------------------------------------------------------------------###
  218. #  End of script.                                                              #
  219. ###--------------------------------------------------------------------------###
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement