Advertisement
roninator2

Neon Black Effect Box addon

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