Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 30.02 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  2. # Blacksmith Shop
  3. # Author: ForeverZer0
  4. # Type: Custom Shop System
  5. # Date: 4.21.2010
  6. # Version: v.1.0
  7. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  8. #
  9. # Explanation:
  10. #   Will allow you to create a complete blacksmithing system. Requires player
  11. #   to use items to forge weapons/armors in addition to gold.
  12. #
  13. # Features:
  14. #   - Completely configurable item requirements for every weapon and armor.
  15. #   - Configurable blacksmith 'fees' for every weapon/armor
  16. #   - Can use as many different items, with different quantities for each piece
  17. #     of equipment.
  18. #   - Only have to use a single script call to for the Blacksmith's shop.
  19. #   - Can recycle old equipment by extracting items from weapons/armors
  20. #
  21. # Instructions:
  22. #   - Place script below debug and above main
  23. #   - Configuration and instructions for each are below
  24. #   - To call blacksmith shop, this script call:
  25. #
  26. #         w = [ WEAPON_IDS ]    (Use as many as needed, seperate with commas)
  27. #         a = [ ARMOR_IDS ]
  28. #         $scene = Scene_BlackSmith.new(w, a)
  29. #
  30. #   - All IDs that you included in the script call for the weapons/armors will
  31. #     be be available for forging in that shop.
  32. #
  33. # Credits/Thanks:
  34. #   - The Window_BlackSmithStatus script was originally written by RPG Advocate
  35. #     as a Window_ShopStatus, and was improved by Fantasist. I changed the
  36. #     name to prevent incompatibility issues with your Shop scene.
  37. #
  38. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  39. #   BEGIN CONFIGURATION
  40. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  41.  
  42. module Zer0_CFG
  43.  
  44.   FORGE_SE = '006-System06'
  45.   # SE played when a weapon/armor is forged
  46.   EXTRACT_SE = '020-Teleport03'
  47.   # SE played when a weapon/armor extraction is performed
  48.   BS_WINDOW_OPACITY = 160
  49.   # Opacity of the windows for the blacksmith shop
  50.  
  51. #-------------------------------------------------------------------------------
  52. #  EQUIPMENT MATERIALS DATABASE
  53. #-------------------------------------------------------------------------------
  54. #
  55. #   There are two sections, one for weapons, and one for armors. To set up a
  56. #   piece of equipment, follow this pattern:
  57. #
  58. #   when WEAPON/ARMOR then return [ [ITEM1_ID, QUANTITY], [ITEM2_ID, QUANTITY] ]
  59. #
  60. #   I suggest not to use more than 8 different items for a single weapon. It
  61. #   will not do anything horrible, it will just not display on the Materials
  62. #   screen at the blacksmith shop.
  63. #
  64. #   Any equipment that you do not include here will not be able to be be
  65. #   forged, or be available for extraction.
  66. #
  67. #   In the first example below, it means that Weapon(1) in the database will
  68. #   require 1 of Item(2), and 1 of Item(4) in the database.
  69. #
  70. #-------------------------------------------------------------------------------
  71.  
  72.   def self.blacksmith_weapon_materials(id)
  73.     case id
  74.     when 3 then  return [ [85,2], [66,1] ]
  75.     when 55 then return [ [85,1] ]
  76.     when 56 then return [ [85,2] ]
  77.     when 57 then return [ [85,1], [86,1] ]
  78.     when 58 then return [ [87,1], [88,1] ]
  79.     when 59 then return [ [85,2] ]
  80.     when 60 then return [ [85,3] ]
  81.     when 5 then return [ [1,1], [3,1], [5,1] ]
  82.     end
  83.     return []
  84.   end
  85.  
  86.   def self.blacksmith_armor_materials(id)
  87.     case id
  88.     when 25 then return [ [85,1] ]
  89.     when 26 then return [ [85,1] ]
  90.     when 3 then return [ [2,3] ]
  91.     end
  92.     return []
  93.   end
  94.  
  95. #-------------------------------------------------------------------------------
  96. #  GOLD PRICE DATABASE
  97. #-------------------------------------------------------------------------------
  98. #
  99. #   Define the fees the blacksmith will charge for forging/extracting your
  100. #   weapons and armors.
  101. #
  102. #-------------------------------------------------------------------------------
  103.  
  104.   def self.blacksmith_weapon_prices(id)
  105.     case id
  106.     when 1 then return 200
  107.     when 2 then return 150
  108.     end
  109.     return 0
  110.   end  
  111.  
  112.   def self.blacksmith_armor_prices(id)
  113.     case id
  114.     when 1 then return 200
  115.     when 2 then return 100
  116.     when 3 then return 200
  117.     end
  118.     return 0
  119.   end
  120.  
  121. end
  122.  
  123. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  124. #   END CONFIGURATION
  125. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  126.  
  127.  
  128. #-------------------------------------------------------------------------------
  129. # * Window_BlackSmithCommand
  130. #-------------------------------------------------------------------------------
  131.  
  132. class Window_BlackSmithCommand < Window_Selectable
  133.  
  134.   def initialize
  135.     super(0, 96, 480, 64)   # super(0, 64, 480, 64)
  136.     self.contents = Bitmap.new(width - 32, height - 32)
  137.     self.back_opacity = Zer0_CFG::BS_WINDOW_OPACITY
  138.     #@item_max = @column_max = 3
  139.     @item_max = @column_max = 2
  140.     @commands = ['Forge', 'Exit']
  141.     #@commands = ['Forge', 'Extract', 'Exit']
  142.     refresh
  143.     self.index = 0
  144.   end
  145.  
  146.   def refresh
  147.     self.contents.clear
  148.     (0...@item_max).each {|i| draw_item(i)}
  149.   end
  150.  
  151.   def draw_item(index)
  152.     #x = 4 + index * 160
  153.     x = 4 + index * 240
  154.     self.contents.draw_text(x, 0, 128, 32, @commands[index])
  155.   end
  156. end
  157.  
  158. #-------------------------------------------------------------------------------
  159. # * Window_BlackSmithForge
  160. #-------------------------------------------------------------------------------
  161.  
  162. class Window_BlackSmithForge < Window_Selectable
  163.  
  164.   def initialize(shop_goods)
  165.     super(0, 160, 368, 352)   # super(0, 128, 368, 352)
  166.     self.back_opacity = Zer0_CFG::BS_WINDOW_OPACITY
  167.     @data = shop_goods
  168.     refresh
  169.     self.index = 0
  170.   end
  171.  
  172.   def item
  173.     return @data[self.index]
  174.   end
  175.  
  176.   def refresh
  177.     if self.contents != nil
  178.       self.contents.dispose
  179.       self.contents = nil
  180.     end
  181.     @item_max = @data.size
  182.     if @item_max > 0
  183.       self.contents = Bitmap.new(width - 32, row_max * 32)
  184.       (0...@item_max).each {|i| draw_item(i)}
  185.     end
  186.   end
  187.  
  188.   def draw_item(index)
  189.     item = @data[index]
  190.     case item
  191.     when RPG::Weapon
  192.       number = $game_party.weapon_number(item.id)
  193.       @materials = Zer0_CFG.blacksmith_weapon_materials(item.id)
  194.       @price = Zer0_CFG.blacksmith_weapon_prices(item.id)
  195.     when RPG::Armor
  196.       number = $game_party.armor_number(item.id)
  197.       @materials = Zer0_CFG.blacksmith_armor_materials(item.id)
  198.       @price = Zer0_CFG.blacksmith_armor_prices(item.id)
  199.     end
  200.     if required_materials? && number < 99
  201.       self.contents.font.color = normal_color
  202.     else
  203.       self.contents.font.color = disabled_color
  204.     end
  205.     x = 4
  206.     y = index * 32
  207.     rect = Rect.new(x, y, self.width - 32, 32)
  208.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  209.     bitmap = RPG::Cache.icon(item.icon_name)
  210.     opacity = self.contents.font.color == normal_color ? 255 : 128
  211.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  212.     self.contents.draw_text(x + 28, y, 222, 32, item.name, 0) # width 212
  213.     #self.contents.draw_text(x + 240, y, 88, 32, @price.to_s, 2)
  214.   end
  215.  
  216.   def update_help
  217.     @help_window.set_text(self.item == nil ? '' : self.item.description)
  218.   end
  219.  
  220.   def required_materials?
  221.     @materials.each_index {|i|
  222.       if $game_party.item_number(@materials[i][0]) < @materials[i][1]
  223.         return false
  224.       end
  225.     }
  226.     return false if $game_party.gold < @price
  227.     return true
  228.   end
  229. end
  230.  
  231.  
  232. #-------------------------------------------------------------------------------
  233. # * Window_BlackSmithExtract
  234. #-------------------------------------------------------------------------------
  235.  
  236. class Window_BlackSmithExtract < Window_Selectable
  237.  
  238.   def initialize
  239.     super(0, 128, 368, 352)
  240.     self.back_opacity = Zer0_CFG::BS_WINDOW_OPACITY
  241.     refresh
  242.     self.index = 0
  243.   end
  244.  
  245.   def item
  246.     return @data[self.index]
  247.   end
  248.  
  249.   def refresh
  250.     if self.contents != nil
  251.       self.contents.dispose
  252.       self.contents = nil
  253.     end
  254.     @data = []
  255.     (1...$data_weapons.size).each {|i|
  256.       if $game_party.weapon_number(i) > 0
  257.         @data.push($data_weapons[i])
  258.       end
  259.     }
  260.     (1...$data_armors.size).each {|i|
  261.       if $game_party.armor_number(i) > 0
  262.         @data.push($data_armors[i])
  263.       end
  264.     }
  265.     @item_max = @data.size
  266.     if @item_max > 0
  267.       self.contents = Bitmap.new(width - 32, row_max * 32)
  268.       (0...@item_max).each {|i| draw_item(i)}
  269.     end
  270.   end
  271.  
  272.   def draw_item(index)
  273.     item = @data[index]
  274.     case item
  275.     when RPG::Weapon
  276.       number = $game_party.weapon_number(item.id)
  277.       materials = Zer0_CFG.blacksmith_weapon_materials(item.id)
  278.       price = Zer0_CFG.blacksmith_weapon_prices(item.id)
  279.     when RPG::Armor
  280.       number = $game_party.armor_number(item.id)
  281.       materials = Zer0_CFG.blacksmith_armor_materials(item.id)
  282.       price = Zer0_CFG.blacksmith_armor_prices(item.id)
  283.     end
  284.     if materials.size > 0
  285.       self.contents.font.color = normal_color
  286.     else
  287.       self.contents.font.color = disabled_color
  288.     end
  289.     x = 4
  290.     y = index * 32
  291.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  292.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  293.     bitmap = RPG::Cache.icon(item.icon_name)
  294.     opacity = self.contents.font.color == normal_color ? 255 : 128
  295.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  296.     self.contents.draw_text(x + 28, y, 222, 32, item.name, 0) # width 212
  297.     self.contents.draw_text(x + 240, y, 16, 32, ':', 1)
  298.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  299.   end
  300.  
  301.   def update_help
  302.     @help_window.set_text(self.item == nil ? '' : self.item.description)
  303.   end
  304. end
  305.  
  306. #-------------------------------------------------------------------------------
  307. # * Window_BlackSmithStatus
  308. #-------------------------------------------------------------------------------
  309.  
  310. class Window_BlackSmithStatus < Window_Base
  311.  
  312.   PLUS_COLOR = Color.new(128, 255, 128)
  313.   MINUS_COLOR = Color.new(255, 128, 128)
  314.  
  315.   SIGN_WIDTH = 8
  316.  
  317.   STAT_NAME_C1 = 32
  318.   STAT_NAME_C2 = 104
  319.   STAT_NAME_C3 = 176
  320.  
  321.   STAT_SIGN_C1 = STAT_NAME_C1 + 28
  322.   STAT_SIGN_C2 = STAT_NAME_C2 + 28
  323.   STAT_SIGN_C3 = STAT_NAME_C3 + 22
  324.  
  325.   STAT_VAL_C1 = STAT_SIGN_C1 + SIGN_WIDTH + 2
  326.   STAT_VAL_C2 = STAT_SIGN_C2 + SIGN_WIDTH + 2
  327.   STAT_VAL_C3 = STAT_SIGN_C3 + SIGN_WIDTH + 2
  328.  
  329.   def initialize
  330.     super(368, 160, 272, 320)   # super(368, 128, 272, 352)
  331.     self.back_opacity = Zer0_CFG::BS_WINDOW_OPACITY
  332.     self.contents = Bitmap.new(width-32, height-32)
  333.     @item = nil
  334.     @sprites = [Sprite.new, Sprite.new, Sprite.new, Sprite.new]
  335.     @sprites.each_with_index {|sprite, i|
  336.       sprite.x = 380
  337.       sprite.y = 194 + i * 64 + 32    # sprite.y = 194 + i * 64
  338.       sprite.z = self.z + 10
  339.     }
  340.     @walk = [false, false, false, false]
  341.     @count = 0
  342.     refresh
  343.   end
  344.  
  345.   def refresh
  346.     self.contents.clear
  347.     @sprites.each {|sprite| sprite.visible = false}
  348.     return if @item == nil
  349.     self.contents.font.size = Font.default_size + 3
  350.     number = case @item
  351.     when RPG::Item then $game_party.item_number(@item.id)
  352.     when RPG::Weapon then $game_party.weapon_number(@item.id)
  353.     when RPG::Armor then $game_party.armor_number(@item.id)
  354.     end
  355.     self.contents.font.color = system_color
  356.     self.contents.draw_text(4, 0, 200, 32, 'Possessed:')
  357.     self.contents.font.color = normal_color
  358.     self.contents.draw_text(204, 0, 32, 32, number.to_s, 2)
  359.     if @item.is_a?(RPG::Item)
  360.       @walk = [false, false, false, false]
  361.       return
  362.     end
  363.     (0...$game_party.actors.size).each do |i|
  364.       actor = $game_party.actors[i]
  365.       if @item.is_a?(RPG::Weapon)
  366.         item1 = $data_weapons[actor.weapon_id]
  367.       elsif @item.kind == 0
  368.         item1 = $data_armors[actor.armor1_id]
  369.       elsif @item.kind == 1
  370.         item1 = $data_armors[actor.armor2_id]
  371.       elsif @item.kind == 2
  372.         item1 = $data_armors[actor.armor3_id]
  373.       else
  374.         item1 = $data_armors[actor.armor4_id]
  375.       end
  376.       if !actor.equippable?(@item)
  377.         draw_actor_graphic(i, false)
  378.         self.contents.font.size = Font.default_size
  379.         self.contents.font.color = normal_color
  380.         self.contents.draw_text(32, 54 + 64 * i, 150, 32, 'Cannot Equip')
  381.       else
  382.         draw_actor_graphic(i, true)
  383.         str1 = item1 != nil ? item1.str_plus : 0
  384.         str2 = @item != nil ? @item.str_plus : 0
  385.         dex1 = item1 != nil ? item1.dex_plus : 0
  386.         dex2 = @item != nil ? @item.dex_plus : 0
  387.         agi1 = item1 != nil ? item1.agi_plus : 0
  388.         agi2 = @item != nil ? @item.agi_plus : 0
  389.         int1 = item1 != nil ? item1.int_plus : 0
  390.         int2 = @item != nil ? @item.int_plus : 0
  391.         pdf1 = item1 != nil ? item1.pdef : 0
  392.         pdf2 = @item != nil ? @item.pdef : 0
  393.         mdf1 = item1 != nil ? item1.mdef : 0
  394.         mdf2 = @item != nil ? @item.mdef : 0
  395.         atk1 = atk2 = eva1 = eva2 = 0
  396.         if @item.is_a?(RPG::Weapon)
  397.           atk1 = item1 != nil ? item1.atk : 0
  398.           atk2 = @item != nil ? @item.atk : 0
  399.         end
  400.         if @item.is_a?(RPG::Armor)
  401.           eva1 = item1 != nil ? item1.eva : 0
  402.           eva2 = @item != nil ? @item.eva : 0
  403.         end
  404.         str_change = str2 - str1
  405.         dex_change = dex2 - dex1
  406.         agi_change = agi2 - agi1
  407.         int_change = int2 - int1
  408.         pdf_change = pdf2 - pdf1
  409.         mdf_change = mdf2 - mdf1
  410.         atk_change = atk2 - atk1
  411.         eva_change = eva2 - eva1
  412.         name1 = item1 == nil ? '' : item1.name
  413.         name2 = @item == nil ? '' : @item.name
  414.         if str_change == 0 && dex_change == 0 && agi_change == 0 &&
  415.         pdf_change == 0 && mdf_change == 0 && atk_change == 0 &&
  416.         eva_change == 0 && int_change == 0 && name1 != name2
  417.           self.contents.font.size = Font.default_size
  418.           self.contents.font.color = normal_color
  419.           self.contents.draw_text(32, 54 + 64 * i, 150, 32, 'No Change')
  420.         end
  421.         if name1 == name2
  422.           self.contents.font.size = Font.default_size
  423.           self.contents.font.color = normal_color
  424.           self.contents.draw_text(32, 54 + 64 * i, 200, 32, 'Currently Equipped')
  425.         end
  426.         self.contents.font.size = (Font.default_size - 3)
  427.         self.contents.font.color = normal_color
  428.         if @item.is_a?(RPG::Weapon) && atk_change != 0
  429.           self.contents.draw_text(STAT_NAME_C1, 42 + 64 * i, 32, 32, 'ATK')
  430.         end
  431.         if @item.is_a?(RPG::Armor) && eva_change != 0
  432.           self.contents.draw_text(STAT_NAME_C1, 42 + 64 * i, 32, 32, 'EVA')
  433.         end
  434.         if pdf_change != 0
  435.           self.contents.draw_text(STAT_NAME_C1, 58 + 64 * i, 32 + 8, 32, 'PDEF')
  436.         end
  437.         if mdf_change != 0
  438.           self.contents.draw_text(STAT_NAME_C1, 74 + 64 * i, 32 + 8, 32, 'MDEF')
  439.         end
  440.         if str_change != 0
  441.           self.contents.draw_text(STAT_NAME_C2, 42 + 64 * i, 32, 32, 'Str')
  442.         end
  443.         if dex_change != 0
  444.           self.contents.draw_text(STAT_NAME_C2, 58 + 64 * i, 32, 32, 'Dex')
  445.         end
  446.         if agi_change != 0
  447.           self.contents.draw_text(STAT_NAME_C2, 74 + 64 * i, 32, 32, 'Agi')
  448.         end
  449.         if int_change != 0
  450.           self.contents.draw_text(STAT_NAME_C3, 42 + 64 * i, 32, 32, 'Int')
  451.         end
  452.         if @item.is_a?(RPG::Weapon) && atk_change > 0
  453.           self.contents.font.color = PLUS_COLOR
  454.           s = atk_change.abs.to_s
  455.           self.contents.draw_text(STAT_SIGN_C1 + 3, 42 + 64 * i, SIGN_WIDTH, 32, '+', 1)
  456.           self.contents.draw_text(STAT_VAL_C1, 42 + 64 * i, 24, 32, s) # STAT_CAL_C1 era 70
  457.         elsif @item.is_a?(RPG::Weapon) && atk_change < 0
  458.           self.contents.font.color = MINUS_COLOR
  459.           s = atk_change.abs.to_s
  460.           self.contents.draw_text(STAT_SIGN_C1 + 3, 42 + 64 * i, SIGN_WIDTH, 32, '-', 1)
  461.           self.contents.draw_text(STAT_VAL_C1 + 3, 42 + 64 * i, 24, 32, s)
  462.         end
  463.         if @item.is_a?(RPG::Armor) && eva_change > 0
  464.           self.contents.font.color = PLUS_COLOR
  465.           s = eva_change.abs.to_s
  466.           self.contents.draw_text(STAT_SIGN_C1, 42 + 64 * i, SIGN_WIDTH, 32, '+', 1)
  467.           self.contents.draw_text(STAT_VAL_C1, 42 + 64 * i, 24, 32, s)
  468.         elsif @item.is_a?(RPG::Armor) && eva_change < 0
  469.           self.contents.font.color = MINUS_COLOR
  470.           s = eva_change.abs.to_s
  471.           self.contents.draw_text(STAT_SIGN_C1, 42 + 64 * i, SIGN_WIDTH, 32, '-', 1)
  472.           self.contents.draw_text(STAT_VAL_C1, 42 + 64 * i, 24, 32, s)
  473.         end
  474.         if pdf_change > 0
  475.           self.contents.font.color = PLUS_COLOR
  476.           s = pdf_change.abs.to_s
  477.           self.contents.draw_text(STAT_SIGN_C1 + 10, 58 + 64 * i, SIGN_WIDTH, 32, '+', 1)
  478.           self.contents.draw_text(STAT_VAL_C1 + 10, 58 + 64 * i, 24, 32, s)
  479.         elsif pdf_change < 0
  480.           self.contents.font.color = MINUS_COLOR
  481.           s = pdf_change.abs.to_s
  482.           self.contents.draw_text(STAT_SIGN_C1 + 10, 58 + 64 * i, SIGN_WIDTH, 32, '-', 1)
  483.           self.contents.draw_text(STAT_VAL_C1 + 10, 58 + 64 * i, 24, 32, s)
  484.         end
  485.         if mdf_change > 0
  486.           self.contents.font.color = PLUS_COLOR
  487.           s = mdf_change.abs.to_s
  488.           self.contents.draw_text(STAT_SIGN_C1 + 10, 74 + 64 * i, SIGN_WIDTH, 32, '+', 1)
  489.           self.contents.draw_text(STAT_VAL_C1 + 10, 74 + 64 * i, 24, 32, s)
  490.         elsif mdf_change < 0
  491.           self.contents.font.color = MINUS_COLOR
  492.           s = mdf_change.abs.to_s
  493.           self.contents.draw_text(STAT_SIGN_C1 + 10, 74 + 64 * i, SIGN_WIDTH, 32, '-',1)
  494.           self.contents.draw_text(STAT_VAL_C1 + 10, 74 + 64 * i, 24, 32, s)
  495.         end
  496.         if str_change > 0
  497.           self.contents.font.color = PLUS_COLOR
  498.           s = str_change.abs.to_s
  499.           self.contents.draw_text(STAT_SIGN_C2, 42 + 64 * i, SIGN_WIDTH, 32, '+', 1)
  500.           self.contents.draw_text(STAT_VAL_C2, 42 + 64 * i, 24, 32, s)
  501.         elsif str_change < 0
  502.           self.contents.font.color = MINUS_COLOR
  503.           s = str_change.abs.to_s
  504.           self.contents.draw_text(STAT_SIGN_C2, 42 + 64 * i, SIGN_WIDTH, 32, '-', 1)
  505.           self.contents.draw_text(STAT_VAL_C2, 42 + 64 * i, 24, 32, s)
  506.         end
  507.         if dex_change > 0
  508.           self.contents.font.color = PLUS_COLOR
  509.           s = dex_change.abs.to_s
  510.           self.contents.draw_text(STAT_SIGN_C2, 58 + 64 * i, SIGN_WIDTH, 32, '+', 1)
  511.           self.contents.draw_text(STAT_VAL_C2, 58 + 64 * i, 24, 32, s)
  512.         elsif dex_change < 0
  513.           self.contents.font.color = MINUS_COLOR
  514.           s = dex_change.abs.to_s
  515.           self.contents.draw_text(STAT_SIGN_C2, 58 + 64 * i, SIGN_WIDTH, 32, '-', 1)
  516.           self.contents.draw_text(STAT_VAL_C2, 58 + 64 * i, 24, 32, s)
  517.         end
  518.         if agi_change > 0
  519.           self.contents.font.color = PLUS_COLOR
  520.           s = agi_change.abs.to_s
  521.           self.contents.draw_text(STAT_SIGN_C2, 74 + 64 * i, SIGN_WIDTH, 32, '+', 1)
  522.           self.contents.draw_text(STAT_VAL_C2, 74 + 64 * i, 24, 32, s)
  523.         elsif agi_change < 0
  524.           self.contents.font.color = MINUS_COLOR
  525.           s = agi_change.abs.to_s
  526.           self.contents.draw_text(STAT_SIGN_C2, 74 + 64 * i, SIGN_WIDTH, 32, '-', 1)
  527.           self.contents.draw_text(STAT_VAL_C2, 74 + 64 * i, 24, 32, s)
  528.         end
  529.         if int_change > 0
  530.           self.contents.font.color = PLUS_COLOR
  531.           s = int_change.abs.to_s
  532.           self.contents.draw_text(STAT_SIGN_C3, 42 + 64 * i, SIGN_WIDTH, 32, '+', 1)
  533.           self.contents.draw_text(STAT_VAL_C3, 42 + 64 * i, 24, 32, s)
  534.         elsif int_change < 0
  535.           self.contents.font.color = MINUS_COLOR
  536.           s = int_change.abs.to_s
  537.           self.contents.draw_text(STAT_SIGN_C3, 42 + 64 * i, SIGN_WIDTH, 32, '-', 1)
  538.           self.contents.draw_text(STAT_VAL_C3, 42 + 64 * i, 24, 32, s)
  539.         end
  540.       end
  541.     end
  542.   end
  543.  
  544.   def item=(item)
  545.     if @item != item
  546.       @item = item
  547.       refresh
  548.     end
  549.   end
  550.  
  551.   def draw_actor_graphic(id, equipable)
  552.     actor = $game_party.actors[id]
  553.     @sprites[id].bitmap = RPG::Cache.character(actor.character_name,
  554.     actor.character_hue)
  555.     @sprites[id].src_rect.set(0, 0, @sprites[id].bitmap.width / 4,
  556.     @sprites[id].bitmap.height / 4)   # (0, 0, ..., ...)
  557.     @walk[id] = equipable
  558.     @sprites[id].tone = Tone.new(0, 0, 0, equipable ? 0 : 255)
  559.     @sprites[id].visible = true
  560.   end
  561.  
  562.   def update
  563.     super
  564.     @count = (@count + 1) % 40
  565.     (0..3).each {|i|
  566.       next unless @walk[i]
  567.       if @sprites[i].bitmap != nil
  568.         w = @sprites[i].bitmap.width / 4
  569.         h = @sprites[i].bitmap.height / 4
  570.         x = (@count / 10) * w
  571.         @sprites[i].src_rect.set(x, 0, w, h)
  572.       end
  573.     }
  574.   end
  575.  
  576.   def visible=(val)
  577.     super
  578.     @sprites.each {|sprite| sprite.visible = val if sprite}
  579.   end
  580.  
  581.   def dispose
  582.     super
  583.     @sprites.each {|sprite| sprite.dispose if sprite}
  584.   end
  585.  
  586. end
  587.  
  588.  
  589. #-------------------------------------------------------------------------------
  590. # * Window_BlackSmithMaterials
  591. #-------------------------------------------------------------------------------
  592.  
  593. class Window_BlackSmithMaterials < Window_Base
  594.  
  595.   def initialize
  596.     super(0, 160, 368, 352)   # super(0, 128, 368, 352)
  597.     self.back_opacity = 160
  598.     self.contents = Bitmap.new(width - 32, height - 32)
  599.   end
  600.  
  601.   def refresh(forge_item, index = 0)
  602.     self.contents.clear
  603.     @item = forge_item
  604.     case @item
  605.     when RPG::Weapon
  606.       @materials = Zer0_CFG.blacksmith_weapon_materials(@item.id)
  607.       @price = Zer0_CFG.blacksmith_weapon_prices(@item.id)
  608.     when RPG::Armor
  609.       @materials = Zer0_CFG.blacksmith_armor_materials(@item.id)
  610.       @price = Zer0_CFG.blacksmith_armor_prices(@item.id)
  611.     end
  612.     self.contents.font.color = normal_color
  613.     #self.contents.draw_text(4, 0, 212, 32, 'Price:', 0)
  614.     bitmap = RPG::Cache.icon(@item.icon_name)
  615.     opacity = self.contents.font.color == normal_color ? 255 : 128
  616.     self.contents.blt(4, 0 + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  617.     self.contents.draw_text(32, 0, 212, 32, @item.name, 0)    
  618.     #self.contents.draw_text(244, 0, 88, 32, @price.to_s, 2)
  619.     if index == 0
  620.       self.contents.draw_text(4, 32, 368, 32, 'Required Materials:', 0)
  621.     else
  622.       self.contents.draw_text(4, 32, 368, 32, 'Extractable Materials:', 0)
  623.     end
  624.     @materials.each_index {|i|
  625.       item = $data_items[@materials[i][0]]
  626.       number = @materials[i][1]
  627.       x = 4
  628.       y = 64 + (i * 32)
  629.       if index == 0
  630.         if $game_party.item_number(@materials[i][0]) >= @materials[i][1]
  631.           self.contents.font.color = normal_color
  632.         else
  633.           self.contents.font.color = disabled_color
  634.         end
  635.       end
  636.       rect = Rect.new(x, y, self.width - 32, 32)
  637.       self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  638.       bitmap = RPG::Cache.icon(item.icon_name)
  639.       opacity = self.contents.font.color == normal_color ? 255 : 128
  640.       self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  641.       self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  642.       #self.contents.draw_text(x + 272, y, 48, 32, 'x', 0)
  643.       #self.contents.draw_text(x + 272, y, 48, 32, number.to_s, 2)
  644.       self.contents.draw_text(x + 248, y, 48, 32, '/', 2)
  645.       self.contents.draw_text(x + 262, y, 48, 32, number.to_s, 0)
  646.       self.contents.draw_text(x + 272, y, 48, 32, $game_party.item_number(@materials[i][0]).to_s, 2)
  647.     }
  648.   end
  649. end
  650.  
  651.  
  652. #-------------------------------------------------------------------------------
  653. # * Scene_BlackSmith
  654. #-------------------------------------------------------------------------------
  655.  
  656. class Scene_BlackSmith
  657.  
  658.   def initialize(weapons = [], armors = [])
  659.     @goods = []
  660.     weapons.each_index {|i| @goods.push($data_weapons[weapons[i]])}
  661.     armors.each_index {|i| @goods.push($data_armors[armors[i]])}
  662.   end
  663.  
  664.   def main
  665.     @map = Spriteset_Map.new
  666.     @command_window = Window_BlackSmithCommand.new
  667.     @forge_window = Window_BlackSmithForge.new(@goods)
  668.     @extract_window = Window_BlackSmithExtract.new
  669.     @materials_window = Window_BlackSmithMaterials.new
  670.     @status_window = Window_BlackSmithStatus.new
  671.     @forge_window.active = @forge_window.visible = false
  672.     @status_window.visible = @materials_window.visible = false
  673.     @extract_window.active = @extract_window.visible = false
  674.     @help_window = Window_Help.new
  675.     @forge_window.help_window = @extract_window.help_window = @help_window
  676.     @gold_window = Window_BlackSkill.new # @gold_window = Window_Gold.new
  677.     @gold_window.x, @gold_window.y = 480, 64
  678.     @help_window.back_opacity = @gold_window.back_opacity = Zer0_CFG::BS_WINDOW_OPACITY    
  679.     Graphics.transition
  680.     loop {Graphics.update; Input.update; update; break if $scene != self}
  681.     [@command_window, @forge_window, @status_window, @help_window, @gold_window,
  682.      @extract_window, @materials_window, @map].each {|w| w.dispose}
  683.   end
  684.  
  685.   def update
  686.     [@command_window, @forge_window, @status_window, @help_window, @gold_window,
  687.      @extract_window, @materials_window].each {|w| w.update}
  688.     if @command_window.active
  689.       update_command
  690.     elsif @forge_window.active
  691.       update_forge
  692.     elsif @extract_window.active
  693.       update_extract
  694.     elsif @materials_window.visible
  695.       update_materials
  696.     end
  697.   end
  698.  
  699.   def update_command
  700.     case @command_window.index
  701.     when 0
  702.       @help_window.set_text('Use materials to forge new weapons/armors.')
  703.     #when 1
  704.       #@help_window.set_text('Extract materials from weapons/armors.')
  705.     when 1 # era 2
  706.       @help_window.set_text('Exit the shop.')
  707.     end
  708.     if Input.trigger?(Input::B)
  709.       $game_system.se_play($data_system.cancel_se)
  710.       $scene = Scene_Map.new
  711.     end
  712.     if Input.trigger?(Input::C)
  713.       $game_system.se_play($data_system.decision_se)
  714.       case @command_window.index
  715.       when 0
  716.         @forge_window.refresh
  717.         @command_window.active = false
  718.         @forge_window.active = @forge_window.visible = true
  719.         @status_window.visible = true
  720.       #when 1
  721.         #@extract_window.refresh
  722.         #@command_window.active = false
  723.         #@extract_window.active = @extract_window.visible = true
  724.         #@status_window.visible = true
  725.       when 1 # era 2
  726.         $game_system.se_play($data_system.cancel_se)
  727.         $scene = Scene_Map.new
  728.       end
  729.     end
  730.   end
  731.  
  732.   def update_forge
  733.     @item = @status_window.item = @forge_window.item
  734.     if Input.trigger?(Input::B)
  735.       $game_system.se_play($data_system.cancel_se)
  736.       @command_window.active = true
  737.       @forge_window.active = @forge_window.visible = false
  738.       @status_window.visible = false
  739.     end
  740.     if Input.trigger?(Input::C)
  741.       $game_system.se_play($data_system.decision_se)
  742.       @materials_window.refresh(@item)
  743.       @forge_window.active = @forge_window.visible = false
  744.       @materials_window.visible = true
  745.     end
  746.   end
  747.  
  748.   def update_extract
  749.     @item = @status_window.item = @extract_window.item
  750.     if Input.trigger?(Input::B)
  751.       $game_system.se_play($data_system.cancel_se)
  752.       @command_window.active = true
  753.       @extract_window.active = @extract_window.visible = false
  754.       @status_window.visible = false
  755.     end
  756.     if Input.trigger?(Input::C)
  757.       $game_system.se_play($data_system.decision_se)
  758.       @materials_window.refresh(@item, 1)
  759.       @extract_window.active = @extract_window.visible = false
  760.       @materials_window.visible = true
  761.     end
  762.   end
  763.  
  764.   def update_materials
  765.     text = 'Press the Action Button to proceed. Press Cancel to go back'
  766.     @help_window.set_text(text)
  767.     if Input.trigger?(Input::B)
  768.       $game_system.se_play($data_system.cancel_se)
  769.       if @command_window.index == 0
  770.         @materials_window.visible = false
  771.         @forge_window.active = @forge_window.visible = true
  772.       else
  773.         @materials_window.visible = false
  774.         @extract_window.active = @extract_window.visible = true
  775.       end
  776.     end
  777.     if Input.trigger?(Input::C)
  778.       case @item
  779.       when RPG::Weapon
  780.         number = $game_party.weapon_number(@item.id)
  781.         @materials = Zer0_CFG.blacksmith_weapon_materials(@item.id)
  782.         @price = Zer0_CFG.blacksmith_weapon_prices(@item.id)
  783.       when RPG::Armor
  784.         number = $game_party.armor_number(@item.id)
  785.         @materials = Zer0_CFG.blacksmith_armor_materials(@item.id)
  786.         @price = Zer0_CFG.blacksmith_armor_prices(@item.id)
  787.       end
  788.       # Forging Procedure
  789.       if @command_window.index == 0        
  790.         if required_materials? && ($game_party.gold >= @price) && (number < 99)
  791.           Audio.se_play('Audio/SE/' + Zer0_CFG::FORGE_SE, 80, 100)
  792.           @materials.each_index {|i|
  793.             $game_party.lose_item(@materials[i][0], @materials[i][1])}
  794.           $game_party.lose_gold(@price)
  795.           case @item
  796.           when RPG::Weapon
  797.             $game_party.gain_weapon(@item.id, 1)
  798.           when RPG::Armor
  799.             $game_party.gain_armor(@item.id, 1)
  800.           end
  801.           @materials_window.visible = false
  802.           @forge_window.active = @forge_window.visible = true
  803.           $game_variables[35] += 1  # Increases Custom Variable to hold Skill
  804.         else
  805.           $game_system.se_play($data_system.buzzer_se)
  806.         end
  807.       else
  808.         if @materials.size > 0
  809.           Audio.se_play('Audio/SE/' + Zer0_CFG::EXTRACT_SE, 80, 100)
  810.           @materials.each_index {|i|
  811.             $game_party.gain_item(@materials[i][0], @materials[i][1])}
  812.           $game_party.lose_gold(@price)
  813.           case @item
  814.           when RPG::Weapon
  815.             $game_party.lose_weapon(@item.id, 1)
  816.           when RPG::Armor
  817.             $game_party.lose_armor(@item.id, 1)
  818.           end
  819.           @materials_window.visible = false
  820.           @extract_window.active = @extract_window.visible = true
  821.         else
  822.           $game_system.se_play($data_system.buzzer_se)
  823.         end
  824.       end
  825.       [@status_window, @gold_window, @extract_window, @forge_window].each {|w|
  826.         w.refresh}
  827.     end
  828.   end
  829.  
  830.   def required_materials?
  831.     @materials.each_index {|i|
  832.       if $game_party.item_number(@materials[i][0]) < @materials[i][1]
  833.         return false
  834.       end
  835.     }
  836.     return false if $game_party.gold < @price
  837.     return true
  838.   end
  839. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement