SSTrihan

HorrorVale - Potion quickbrew update

Sep 28th, 2024 (edited)
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 24.07 KB | Source Code | 0 0
  1. #-------------------------------------------------------------------------------
  2. # Don't remove this header!
  3. #-------------------------------------------------------------------------------
  4. # Potion Brewing System Script
  5. # by Black Mage (https://burningwizard.wordpress.com/)
  6. #
  7. # Version : 1.4
  8. #
  9. # This script is commisioned by Batworks Software.
  10. #-------------------------------------------------------------------------------
  11.  
  12. #-------------------------------------------------------------------------------
  13. # Version History
  14. #-------------------------------------------------------------------------------
  15. # 1.4 - Added quickbrew menu (Trihan)
  16. #
  17. # 1.3 - Add compatibility fix for Theo Animated Battleback script.
  18. #
  19. # 1.0 - Initial design.
  20. #-------------------------------------------------------------------------------
  21.  
  22. #-------------------------------------------------------------------------------
  23. # All picture are located on Graphics/Menus folder.
  24. #
  25. # To call the Potion Brewing menu, simply put these on the script call:
  26. #
  27. #     SceneManager.call(Scene_Brewing)
  28. #
  29. # Put <base> on an item note to tag it as base ingredients for brewing.
  30. #
  31. # Put <second> on an item note to tag it as second ingredients for brewing.
  32. #-------------------------------------------------------------------------------
  33.  
  34. #-------------------------------------------------------------------------------
  35. # Settings.
  36. #-------------------------------------------------------------------------------
  37. module BLACK
  38.   module BREW
  39.     # Image for the scene background.
  40.     Background = "potionbg"
  41.  
  42.     # Image for the cursor.
  43.     Cursor_Name = "fingerpointer"
  44.  
  45.     # Position for help text.
  46.     Help_Text_Pos = [0,3]
  47.  
  48.     # Help text that will be displayed.
  49.     Help_Text = ["Select your ingredients!",     # This is shown if base
  50.                                                 # ingredients is empty.
  51.                  "Select your ingredients!",   # This is shown if second
  52.                                                 # ingredients is empty.
  53.                  "Time to brew!",  # This is shown if both
  54.                                    # ingredients already chosen.
  55.                  "Brew things you've made before!"
  56.                 ]                                  
  57.  
  58.     # Font name array. You can have multiple font inside the array, and the
  59.     # menu will use the first one that the game found.
  60.     Ing_Font_Name = ["myfont Regular"]
  61.  
  62.     # Font size.
  63.     Ing_Font_Size = 24
  64.  
  65.     # The position of base ingredients choices window.
  66.     Main_Pos = [0, 165]
  67.  
  68.     # The transparent window size where the base ingredients choices are written.
  69.     Main_Size = [250,250]
  70.  
  71.     # Icon position of selected base ingredient.
  72.     Item_1_Icn = [30,110]
  73.  
  74.     # Cursor position of base ingredient square.
  75.     Item_1_Pos = [75,160]
  76.  
  77.     # Starting cursor position of cursor inside base ingredients window.
  78.     Item_1_Ingr = [180,20]
  79.  
  80.     # Background for base ingredients window.
  81.     Item_1_Back = "backbrew1"
  82.  
  83.     # Background position for base ingredients window, relative to window
  84.     # position.
  85.     Item_1_BG_Off = [0,0]
  86.  
  87.     # The position of second ingredients choices window.
  88.     Sec_Pos = [200, 165]
  89.  
  90.     # The transparent window size where the second ingredients choices are
  91.     # written.
  92.     Sec_Size = [250,250]
  93.  
  94.     # Icon position of selected second ingredient.
  95.     Item_2_Icn = [170,110]
  96.  
  97.     # Cursor position of second ingredient square.
  98.     Item_2_Pos = [220,160]
  99.  
  100.     # Starting cursor position of cursor inside second ingredients window.
  101.     Item_2_Ingr = [180,20]
  102.  
  103.     # Background for second ingredients window.
  104.     Item_2_Back = "backbrew2"
  105.  
  106.     # Background position for second ingredients window, relative to window
  107.     # position.
  108.     Item_2_BG_Off = [0,0]
  109.  
  110.     # Cursor position of brew button.
  111.     Brew_But_Pos = [200,270]
  112.  
  113.     # Cursor position of back square.
  114.     Back_Pos = [70,360]
  115.    
  116.     # Cursor position of recipe book.
  117.     Recipe_Pos = [240,360]
  118.  
  119.     #          base ingredients, second ingredients, result
  120.     Recipe = [[41,43,174], #Holy Base
  121.              [45,117,175], #Salted Root
  122.               [66,114,124], #Death Potion
  123.               [66,115,243], #Necro Potion
  124.               [66,116,244], #Soul Potion
  125.               [66,117,245], #Mind Potion
  126.               [66,118,246], #Body Potion
  127.               [66,119,47], #Fealixer
  128.               [66,120,247], #Spirit Potion
  129.               [66,121,248], #HEART POTION
  130.               [66,122,126], #Purge Potion
  131.               [66,123,127], #Death's Brew
  132.               [66,171,172], #Shrinking Potion
  133.               [67,114,128], #Death Elixir
  134.               [67,115,129], #Endurance Elixir
  135.               [67,116,130], #Bravery Elixir
  136.               [67,117,131], #Agility Elixir
  137.               [67,118,132], #Terror Elixir
  138.               [67,119,133], #Fealixer X Elixir
  139.               [67,120,125], #Stability Elixir
  140.               [67,121,134], #Strength Elixir
  141.               [67,122,135], #Luck Elixir
  142.               [67,123,127], #Death's Brew
  143.               [67,171,172], #Shrinking Potion
  144.               [68,114,137], #Life Elixir
  145.               [68,115,138], #Fragile Elixir
  146.               [68,116,139], #Insecure Elixir
  147.               [68,117,140], #Slow Elixir
  148.               [68,118,141], #Meek Elixir
  149.               [68,119,146], #Fealixer+
  150.               [68,120,249], #Instability Elixir
  151.               [68,121,142], #Weak Elixir
  152.               [68,122,144], #Unlucky Elixir
  153.               [68,123,127], #Death's Brew
  154.               [68,171,172], #Shrinking Potion
  155.               [69,114,144], #Death Potion+
  156.               [69,115,250], #Purple Death Potion
  157.               [69,116,251], #Green Death Potion
  158.               [69,117,252], #Orange Death Potion
  159.               [69,118,253], #Yellow Death Potion
  160.               [69,119,254], #Pink Death Potion
  161.               [69,120,255], #Spirit Potion+
  162.               [69,121,256], #Red Death Potion
  163.               [69,122,147], #Immortality
  164.               [69,123,127], #Death's Brew
  165.               [69,171,172], #Shrinking Potion
  166.               [70,114,257], #Flesh Potion
  167.               [70,115,258], #Bone Potion
  168.               [70,116,259], #Ecto Potion
  169.               [70,117,260], #Nature Potion
  170.               [70,118,261], #Lightning Potion
  171.               [70,119,262], #Sugar Potion
  172.               [70,120,263], #Basic Potion
  173.               [70,121,264], #Blood Potion
  174.               [70,122,265], #ritical Potion
  175.               [70,123,127], #Death's Brew
  176.               [70,171,172], #Shrinking Potion
  177.               [155,43,156], #Banishing Potion
  178.               [174,175,44], #Spectralodium D
  179.  
  180.               ]
  181.  
  182.     # The ID of item that you got when you use wrong ingredients.
  183.     Failed_Item = 136
  184.  
  185.     # This text will be showed after you complete brewing. The format will be
  186.     #
  187.     #     left_text item_name right_text
  188.     #
  189.     # Ex. Suppose Text = ["You create ", "!"], then this will be showed:
  190.     #     You create item_name!
  191.  
  192.     Text = ["You brewed ",          "!"]
  193.  
  194.     # Position for text that showed after completing the brew.
  195.     Cre_Pos = [100,300]
  196.  
  197.     # Background name for text that showed after completing the brew.
  198.     Create_BG = "brewcreated"
  199.  
  200.     # Position for background for the text that showed after completing the brew.
  201.     Cre_BG_Pos = [0,0]
  202.  
  203.     # For the item icons that showed up inside the menu, we use another file
  204.     # with the same format as the regular icon picture, but different in size.
  205.     # The file must be placed on Graphics/System folder.
  206.     Icon_Name = "IconSet2"
  207.  
  208.     # Icon width and height.
  209.     Icon_W_H = 48
  210.  
  211.        # For the item icons that showed up inside the ingredients selection menu,
  212.     # we use another file with the same format as the regular icon picture, but
  213.     # different in size. The file must be placed on Graphics/System folder.
  214.     Icon2_Name = "IconSet3"
  215.  
  216.     # Icon width and height.
  217.     Icon2_W_H = 24    
  218. #-------------------------------------------------------------------------------    
  219.     # There's animation that shown upon creating a new items. Below are their
  220.     # settings
  221.  
  222.     # X and Y position of the animation.
  223.     Anim_X_Y = [0,0]
  224.  
  225.     # ID of animation that will be played upon creating item.
  226.     Anim_ID = 166
  227. #-------------------------------------------------------------------------------    
  228.   end
  229. end
  230.  
  231. #-------------------------------------------------------------------------------
  232. # * Beyond this is the sacred land of code. You need programming qualification
  233. #   to dwelve deeper, or it'll cause many unnecessary problems. Proceed on your
  234. #   own risk.
  235. #-------------------------------------------------------------------------------
  236.  
  237. # We define where we put the resources.
  238. module Cache; def self.menus(filename); load_bitmap("Graphics/Menus/", filename); end; end
  239.  
  240. # We make custom variable for tab.
  241. class Game_System
  242.   attr_accessor :brew_ing
  243.   attr_accessor :item_created
  244.   attr_accessor :recipe_book
  245.   attr_accessor :quickbrewing
  246.   alias b_brew_init initialize
  247.   def initialize; b_brew_init; @brew_ing = [nil,nil]; @recipe_book = []; @quickbrewing = false; end
  248. end
  249.  
  250. #-------------------------------------------------------------------------------
  251. # The brewing screen.
  252. #-------------------------------------------------------------------------------
  253. class Scene_Brewing < Scene_MenuBase
  254.   include BLACK::BREW
  255.   def start
  256.     super; create_command_window; create_item_window; create_quickbrew_window; create_pics
  257.     @create_window = Window_Create_Pot.new
  258.     $game_system.brew_ing = [nil,nil]
  259.     @recipe = []
  260.     Recipe.each do |r|
  261.       @recipe[r[0]] = [] if !@recipe[r[0]]; @recipe[r[0]][r[1]] = r[2]
  262.     end
  263.     @spriteset = Spriteset_Brew.new
  264.   end
  265.   def create_background
  266.     @background_sprite = Sprite.new
  267.     @background_sprite.bitmap = Cache.menus(Background)
  268.   end
  269.   def create_pics
  270.     @cursor = Sprite.new; @cursor.bitmap = Cache.menus(Cursor_Name)
  271.     @cursor.z = 200; update_cursor
  272.     @bg3 = Sprite.new; @bg3.bitmap = Cache.menus(Create_BG); @bg3.opacity = 0
  273.     @bg3.x = Cre_Pos[0] + Cre_BG_Pos[0]
  274.     @bg3.y = Cre_Pos[1] + Cre_BG_Pos[1]
  275.   end
  276.   def update
  277.     super; update_cursor
  278.     if @s_pause
  279.       @p_frame -= 1
  280.       if @p_frame <= 0
  281.         @s_pause = false
  282.         @command_window.deactivate
  283.         @item_window.refresh; @item_window_2.refresh
  284.         @create_window.show; @bg3.opacity = 255
  285.       end
  286.     end
  287.     @spriteset.update
  288.   end
  289.   def update_cursor
  290.     return if @cursor.nil? || @command_window.nil?
  291.     if @command_window.active
  292.       case @command_window.index
  293.       when 0; a = Item_1_Pos
  294.       when 1; a = Item_2_Pos
  295.       when 2; a = Brew_But_Pos
  296.       when 3; a = Back_Pos
  297.       when 4; a = Recipe_Pos
  298.       end
  299.     elsif @item_window.active; a = @item_window.i_pos
  300.     elsif @item_window_2.active; a = @item_window_2.i_pos
  301.     end
  302.     return if a.nil?
  303.     @cursor.x = a[0]; @cursor.y = a[1]
  304.   end
  305.   # We add more things to dispose instead of just background.
  306.   def dispose_background
  307.     @background_sprite.dispose
  308.     @cursor.dispose; @cursor = nil
  309.     @bg3.dispose; @bg3 = nil
  310.     @spriteset.dispose
  311.   end
  312.   # Create brew choices.
  313.   def create_command_window
  314.     @command_window = Window_Brew.new
  315.     @command_window.set_handler(:cancel,   method(:return_scene))
  316.     @command_window.set_handler(:ok,       method(:on_slot_ok))
  317.   end
  318.   def on_slot_ok
  319.     if @command_window.index == 0
  320.       @item_window.show; @item_window.activate; @item_window.select(0)
  321.     elsif @command_window.index == 1
  322.       @item_window_2.show; @item_window_2.activate; @item_window_2.select(0)
  323.     elsif @command_window.index == 4
  324.       @cursor.opacity = 0; $game_system.quickbrewing = true; @quickbrew_window.show; @quickbrew_window.activate; @quickbrew_window.select(0)
  325.     else
  326.       a = $game_system.brew_ing
  327.       if a[0] != nil && a[1] != nil
  328.         $game_party.lose_item($data_items[a[0].id], 1)
  329.         $game_party.lose_item($data_items[a[1].id], 1)
  330.         result = @recipe[a[0].id][a[1].id]
  331.         b = result.nil? ? Failed_Item : result
  332.         $game_system.recipe_book = [] if $game_system.recipe_book.nil?
  333.         $game_system.recipe_book.push([result, a[0].id, a[1].id]) if !result.nil?
  334.         $game_system.recipe_book.uniq!
  335.         $game_system.item_created = $data_items[b]
  336.         $game_party.gain_item($data_items[b], 1)
  337.         $game_system.brew_ing = [nil,nil]
  338.         @spriteset.enemy[0].battler.animation_id = Anim_ID
  339.         @s_pause = true; @p_frame = $data_animations[Anim_ID].frames.size
  340.       else
  341.         @command_window.activate
  342.       end
  343.     end
  344.   end
  345.   def activate_c_w
  346.     Sound.play_ok; @command_window.activate; @bg3.opacity = 0
  347.   end
  348.   def create_item_window
  349.     wx = Main_Pos[0]; wy = Main_Pos[1]; ww = Main_Size[0]; wh = Main_Size[1]
  350.     @item_window = Window_Ingredients.new(wx, wy, ww, wh)
  351.     @item_window.viewport = @viewport
  352.     @item_window.set_handler(:ok,     method(:on_item_ok))
  353.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  354.     wx = Sec_Pos[0]; wy = Sec_Pos[1]; ww = Sec_Size[0]; wh = Sec_Size[1]
  355.     @item_window_2 = Window_Ingredients_2.new(wx, wy, ww, wh)
  356.     @item_window_2.viewport = @viewport
  357.     @item_window_2.set_handler(:ok,     method(:on_item_ok))
  358.     @item_window_2.set_handler(:cancel, method(:on_item_cancel))
  359.     @item_window.hide; @item_window_2.hide
  360.     @item_window_3 = Window_Ingredients_3.new
  361.     @inst_window = Window_Instruction.new
  362.   end
  363.   def create_quickbrew_window
  364.     @quickbrew_window = Window_RecipeBook.new(0, 43, Graphics.width, Graphics.height - 43)
  365.     @quickbrew_window.set_handler(:ok, method(:on_quickbrew_ok))
  366.     @quickbrew_window.set_handler(:cancel, method(:on_quickbrew_cancel))
  367.     @quickbrew_window.hide
  368.   end
  369.   def on_item_ok
  370.     @command_window.activate; @command_window.refresh
  371.     if @command_window.index == 0
  372.       $game_system.brew_ing[0] = @item_window.item
  373.       @item_window.unselect; @item_window.refresh; @item_window.hide
  374.     else
  375.       $game_system.brew_ing[1] = @item_window_2.item
  376.       @item_window_2.unselect; @item_window_2.refresh; @item_window_2.hide
  377.     end
  378.   end
  379.   def on_item_cancel
  380.     @command_window.activate
  381.     @item_window.unselect; @item_window_2.unselect
  382.     @item_window.hide; @item_window_2.hide
  383.   end
  384.   def on_quickbrew_ok
  385.     @command_window.activate; @command_window.refresh; $game_system.quickbrewing = false
  386.     potion = @quickbrew_window.item[0]
  387.     ing1 = @quickbrew_window.item[1]
  388.     ing2 = @quickbrew_window.item[2]
  389.     $game_party.lose_item($data_items[ing1], 1)
  390.     $game_party.lose_item($data_items[ing2], 1)
  391.     result = @recipe[ing1][ing2]
  392.     b = result.nil? ? Failed_Item : result
  393.     $game_system.item_created = $data_items[b]
  394.     $game_party.gain_item($data_items[b], 1)
  395.     $game_system.brew_ing = [nil,nil]
  396.     @quickbrew_window.unselect
  397.     @quickbrew_window.hide
  398.     @spriteset.enemy[0].battler.animation_id = Anim_ID
  399.     @s_pause = true; @p_frame = $data_animations[Anim_ID].frames.size
  400.     @cursor.opacity = 255
  401.   end
  402.   def on_quickbrew_cancel
  403.     @command_window.activate
  404.     @quickbrew_window.unselect
  405.     @quickbrew_window.hide
  406.     $game_system.quickbrewing = false
  407.     @cursor.opacity = 255
  408.   end
  409. end
  410.  
  411. # The hidden choices of brewing.
  412. class Window_Brew < Window_Command
  413.   def initialize
  414.     super(0,0); self.openness = 0; open; self.opacity = 0; self.hide
  415.   end
  416.   def make_command_list
  417.     add_command("ing 1",  :ok)
  418.     add_command("ing 2",  :ok)
  419.     add_command("brew",   :ok)
  420.     add_command("back",   :cancel)
  421.     add_command("recipe", :recipebook)
  422.   end
  423.   def cursor_right(wrap = false)
  424.     if index < item_max - col_max || (wrap && col_max == 1)
  425.       select((index + col_max) % item_max)
  426.     end
  427.   end
  428.   def cursor_left(wrap = false)
  429.     if index >= col_max || (wrap && col_max == 1)
  430.       select((index - col_max + item_max) % item_max)
  431.     end
  432.   end
  433.   def item_window=(item_window); @item_window = item_window; update; end
  434.   def current_item_enabled?
  435.     a = $game_system.brew_ing
  436.     return true if @index != 2
  437.     return (a[0] != nil && a[1] != nil) ? true : false
  438.   end
  439. end
  440.  
  441. class Window_Ingredients < Window_ItemList
  442.   include BLACK::BREW
  443.   def initialize(x, y, width, height); super; @letter_timer = 0; @letter_skip = 0; refresh; end
  444.   def col_max; return 1; end
  445.   def item_height; Ing_Font_Size; end
  446.   def enable?(item); return true; end
  447.   def select_last; end
  448.   def include?(item)
  449.     return true if item == nil; return item.note =~ /<base>/ ? true : false
  450.   end
  451.   def i_pos
  452.     x = self.x + (@index % col_max * (item_width + spacing)) + Item_1_Ingr[0] - self.ox
  453.     y = self.y + (@index / col_max * item_height) + Item_1_Ingr[1] - self.oy
  454.     [x, y]
  455.   end
  456.   def draw_item_name(item, x, y, enabled = true, width = 172)
  457.     return unless item
  458.     draw_icon(item.icon_index, x, y, enabled)
  459.     change_color(normal_color, enabled)
  460.     contents.font.name = Ing_Font_Name; contents.font.size = Ing_Font_Size
  461.     if @data.index(item) == self.index && text_size(item.name).width > 174
  462.       @letter_skip = 0 if text_size(item.name.slice(@letter_skip, item.name.size)).width < 158
  463.       text = item.name.slice(@letter_skip, item.name.size)
  464.     else
  465.       text = item.name.clone
  466.     end
  467.     if text_size(text).width > 174
  468.       while text_size("#{text}...").width > 174
  469.         text.slice!(-1)
  470.       end
  471.       if @data.index(item) != self.index
  472.         text.concat("...")
  473.       end
  474.     end
  475.     draw_text(x + Icon2_W_H, y, width, item_height, text)
  476.   end
  477.   def draw_icon(icon_index, x, y, enabled = true)
  478.     a = Icon2_W_H; bitmap = Cache.system(Icon2_Name)
  479.     rect = Rect.new(icon_index % 16 * a, icon_index / 16 * a, a, a)
  480.     contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  481.   end
  482. end
  483. class Window_Ingredients_2 < Window_ItemList
  484.   include BLACK::BREW
  485.   def initialize(x, y, width, height); super; @letter_timer = 0; @letter_skip = 0; refresh; end
  486.   def col_max; return 1; end
  487.   def item_height; Ing_Font_Size; end
  488.   def enable?(item); return true; end
  489.   def select_last; end
  490.   def include?(item)
  491.     return true if item == nil; return item.note =~ /<second>/ ? true : false
  492.   end
  493.   def i_pos
  494.     x = self.x + (@index % col_max * (item_width + spacing)) + Item_2_Ingr[0] - self.ox
  495.     y = self.y + (@index / col_max * item_height) + Item_2_Ingr[1] - self.oy
  496.     [x, y]
  497.   end
  498.   def draw_item_name(item, x, y, enabled = true, width = 172)
  499.     return unless item
  500.     draw_icon(item.icon_index, x, y, enabled)
  501.     change_color(normal_color, enabled)
  502.     contents.font.name = Ing_Font_Name; contents.font.size = Ing_Font_Size
  503.     if @data.index(item) == self.index && text_size(item.name).width > 174
  504.       @letter_skip = 0 if text_size(item.name.slice(@letter_skip, item.name.size)).width < 158
  505.       text = item.name.slice(@letter_skip, item.name.size)
  506.     else
  507.       text = item.name.clone
  508.     end
  509.     if text_size(text).width > 174
  510.       while text_size("#{text}...").width > 174
  511.         text.slice!(-1)
  512.       end
  513.       if @data.index(item) != self.index
  514.         text.concat("...")
  515.       end
  516.     end
  517.     draw_text(x + Icon2_W_H, y, width, item_height, text)
  518.   end
  519.   def draw_icon(icon_index, x, y, enabled = true)
  520.     a = Icon2_W_H; bitmap = Cache.system(Icon2_Name)
  521.     rect = Rect.new(icon_index % 16 * a, icon_index / 16 * a, a, a)
  522.     contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  523.   end
  524. end
  525. class Window_Create_Pot < Window_Base
  526.   include BLACK::BREW
  527.   def initialize
  528.     a = 440; super(Cre_Pos[0],Cre_Pos[1],a,fitting_height(1))
  529.     self.opacity = 0; self.hide
  530.   end  
  531.   def update
  532.     super;
  533.     if Input.trigger?(:C) && self.visible
  534.       self.hide; SceneManager.scene.activate_c_w
  535.     end
  536.     self.refresh
  537.   end
  538.   def refresh
  539.     contents.clear
  540.     return if $game_system.item_created.nil?
  541.     item = $game_system.item_created
  542.     contents.font.name = Ing_Font_Name; contents.font.size = Ing_Font_Size
  543.     text = "\\c[0]#{Text[0]}\\i[#{item.icon_index}]\\c[22]#{item.name}\\c[0]#{Text[1]}"
  544.     draw_text_ex(6, 0, text)
  545.   end
  546.   def draw_icon(icon_index, x, y, enabled = true)
  547.     a = Icon2_W_H; bitmap = Cache.system(Icon2_Name)
  548.     rect = Rect.new(icon_index % 16 * a, icon_index / 16 * a, a, a)
  549.     contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  550.   end
  551. end
  552. class Window_Ingredients_3 < Window_Base
  553.   include BLACK::BREW
  554.   def initialize
  555.     super(0,0,Graphics.width,Graphics.height); self.opacity = 0
  556.   end
  557.   def update; super; self.refresh; end
  558.   def refresh
  559.     contents.clear
  560.     item = $game_system.brew_ing
  561.     draw_icon(item[0].icon_index, Item_1_Icn[0], Item_1_Icn[1]) if !item[0].nil?
  562.     draw_icon(item[1].icon_index, Item_2_Icn[0], Item_2_Icn[1]) if !item[1].nil?
  563.   end
  564.   def draw_icon(icon_index, x, y, enabled = true)
  565.     a = Icon_W_H; bitmap = Cache.system(Icon_Name)
  566.     rect = Rect.new(icon_index % 16 * a, icon_index / 16 * a, a, a)
  567.     contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  568.   end
  569. end
  570. class Window_RecipeBook < Window_Selectable
  571.   include BLACK::BREW
  572.   def initialize(x, y, width, height)
  573.     super
  574.     @recipe = []
  575.     Recipe.each do |r|
  576.       @recipe[r[0]] = [] if !@recipe[r[0]]; @recipe[r[0]][r[1]] = r[2]
  577.     end
  578.     @data = []
  579.     self.back_opacity = 230
  580.   end
  581.   def col_max
  582.     return 1
  583.   end
  584.   def item_max
  585.     @data ? @data.size : 1
  586.   end
  587.   def item
  588.     @data && index >= 0 ? @data[index] : nil
  589.   end
  590.   def current_item_enabled?
  591.     enable?(@data[index])
  592.   end
  593.   def include?(item)
  594.     true
  595.   end
  596.   def enable?(item)
  597.     return false if item.nil?
  598.     ing1 = $data_items[item[1]]
  599.     ing2 = $data_items[item[2]]
  600.     $game_party.has_item?(ing1) && $game_party.has_item?(ing2)
  601.   end
  602.   def make_item_list
  603.     $game_system.recipe_book = [] if $game_system.recipe_book.nil?
  604.     @data = $game_system.recipe_book
  605.   end
  606.   def draw_item(index)
  607.     item = $data_items[@data[index][0]]
  608.     if item
  609.       ing1 = $data_items[@data[index][1]]
  610.       ing2 = $data_items[@data[index][2]]
  611.       rect = item_rect(index)
  612.       rect.width -= 4
  613.       draw_item_name(item, rect.x, rect.y, enable?(@data[index]))
  614.       draw_icon(ing1.icon_index, rect.x + Graphics.width - 72, rect.y, $game_party.has_item?(ing1))
  615.       draw_icon(ing2.icon_index, rect.x + Graphics.width - 48, rect.y, $game_party.has_item?(ing2))
  616.     end
  617.   end
  618.   def draw_item_number(rect, item)
  619.     draw_text(rect, sprintf(":%2d", $game_party.item_number(item)), 2)
  620.   end
  621.   def refresh
  622.     make_item_list
  623.     create_contents
  624.     draw_all_items
  625.   end
  626.   def update; super; self.refresh; end
  627. end
  628. class Window_Instruction < Window_Base
  629.   include BLACK::BREW
  630.   def initialize
  631.     super(Help_Text_Pos[0],Help_Text_Pos[1],Graphics.width,Graphics.height)
  632.     self.opacity = 0
  633.   end  
  634.   def update; super; self.refresh; end
  635.   def refresh
  636.     contents.clear
  637.     a = $game_system.brew_ing
  638.     if $game_system.quickbrewing; b = Help_Text[3]
  639.     elsif a[0].nil?; b = Help_Text[0]
  640.     elsif a[1].nil?; b = Help_Text[1]
  641.     else b = Help_Text[2]
  642.     end
  643.     contents.font.name = Ing_Font_Name; contents.font.size = Ing_Font_Size
  644.     draw_text(6,0,640,Ing_Font_Size,b)
  645.   end
  646. end
  647.  
  648. class Spriteset_Brew < Spriteset_Battle
  649.   include BLACK::BREW
  650.   def initialize; create_viewports; create_enemies; update; end
  651.   def create_enemies
  652.     a = Sprite_Brew.new(@viewport1, Game_Enemy.new(1,1))
  653.     a.battler.screen_x = Anim_X_Y[0]; a.battler.screen_y = Anim_X_Y[1]
  654.     @enemy_sprites = [a]
  655.   end
  656.   def enemy; @enemy_sprites; end
  657.   def dispose; dispose_enemies; dispose_viewports; end
  658.   def dispose_enemies; @enemy_sprites.each {|sprite| sprite.dispose }; end
  659.   def update; update_enemies; update_viewports; end
  660.   def update_enemies; @enemy_sprites.each {|sprite| sprite.update }; end
  661.   def battler_sprites; @enemy_sprites; end
  662. end
  663.  
  664. class Sprite_Brew < Sprite_Battler
  665.   alias brew_u_e update_effect
  666.   def update_effect; brew_u_e; self.bitmap.clear; end
  667. end
  668.  
  669. # Fix for Theo Animated Battleback incompatibility.
  670. class Spriteset_Brew < Spriteset_Battle
  671.   def create_animbb; @animbb = Sprite.new; end
  672.   def dispose; dispose_enemies; dispose_viewports; @animbb.dispose; end
  673. end
Advertisement
Add Comment
Please, Sign In to add comment