Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- # Blacksmith Shop
- # Author: ForeverZer0
- # Type: Custom Shop System
- # Date: 4.21.2010
- # Version: v.1.0
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- #
- # Explanation:
- # Will allow you to create a complete blacksmithing system. Requires player
- # to use items to forge weapons/armors in addition to gold.
- #
- # Features:
- # - Completely configurable item requirements for every weapon and armor.
- # - Configurable blacksmith 'fees' for every weapon/armor
- # - Can use as many different items, with different quantities for each piece
- # of equipment.
- # - Only have to use a single script call to for the Blacksmith's shop.
- # - Can recycle old equipment by extracting items from weapons/armors
- #
- # Instructions:
- # - Place script below debug and above main
- # - Configuration and instructions for each are below
- # - To call blacksmith shop, this script call:
- #
- # w = [ WEAPON_IDS ] (Use as many as needed, seperate with commas)
- # a = [ ARMOR_IDS ]
- # $scene = Scene_BlackSmith.new(w, a)
- #
- # - All IDs that you included in the script call for the weapons/armors will
- # be be available for forging in that shop.
- #
- # Credits/Thanks:
- # - The Window_BlackSmithStatus script was originally written by RPG Advocate
- # as a Window_ShopStatus, and was improved by Fantasist. I changed the
- # name to prevent incompatibility issues with your Shop scene.
- #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # BEGIN CONFIGURATION
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- module Zer0_CFG
- FORGE_SE = '006-System06'
- # SE played when a weapon/armor is forged
- EXTRACT_SE = '020-Teleport03'
- # SE played when a weapon/armor extraction is performed
- BS_WINDOW_OPACITY = 160
- # Opacity of the windows for the blacksmith shop
- #-------------------------------------------------------------------------------
- # EQUIPMENT MATERIALS DATABASE
- #-------------------------------------------------------------------------------
- #
- # There are two sections, one for weapons, and one for armors. To set up a
- # piece of equipment, follow this pattern:
- #
- # when WEAPON/ARMOR then return [ [ITEM1_ID, QUANTITY], [ITEM2_ID, QUANTITY] ]
- #
- # I suggest not to use more than 8 different items for a single weapon. It
- # will not do anything horrible, it will just not display on the Materials
- # screen at the blacksmith shop.
- #
- # Any equipment that you do not include here will not be able to be be
- # forged, or be available for extraction.
- #
- # In the first example below, it means that Weapon(1) in the database will
- # require 1 of Item(2), and 1 of Item(4) in the database.
- #
- #-------------------------------------------------------------------------------
- def self.blacksmith_weapon_materials(id)
- case id
- when 3 then return [ [85,2], [66,1] ]
- when 55 then return [ [85,1] ]
- when 56 then return [ [85,2] ]
- when 57 then return [ [85,1], [86,1] ]
- when 58 then return [ [87,1], [88,1] ]
- when 59 then return [ [85,2] ]
- when 60 then return [ [85,3] ]
- when 5 then return [ [1,1], [3,1], [5,1] ]
- end
- return []
- end
- def self.blacksmith_armor_materials(id)
- case id
- when 25 then return [ [85,1] ]
- when 26 then return [ [85,1] ]
- when 3 then return [ [2,3] ]
- end
- return []
- end
- #-------------------------------------------------------------------------------
- # GOLD PRICE DATABASE
- #-------------------------------------------------------------------------------
- #
- # Define the fees the blacksmith will charge for forging/extracting your
- # weapons and armors.
- #
- #-------------------------------------------------------------------------------
- def self.blacksmith_weapon_prices(id)
- case id
- when 1 then return 200
- when 2 then return 150
- end
- return 0
- end
- def self.blacksmith_armor_prices(id)
- case id
- when 1 then return 200
- when 2 then return 100
- when 3 then return 200
- end
- return 0
- end
- end
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # END CONFIGURATION
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- #-------------------------------------------------------------------------------
- # * Window_BlackSmithCommand
- #-------------------------------------------------------------------------------
- class Window_BlackSmithCommand < Window_Selectable
- def initialize
- super(0, 96, 480, 64) # super(0, 64, 480, 64)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.back_opacity = Zer0_CFG::BS_WINDOW_OPACITY
- #@item_max = @column_max = 3
- @item_max = @column_max = 2
- @commands = ['Forge', 'Exit']
- #@commands = ['Forge', 'Extract', 'Exit']
- refresh
- self.index = 0
- end
- def refresh
- self.contents.clear
- (0...@item_max).each {|i| draw_item(i)}
- end
- def draw_item(index)
- #x = 4 + index * 160
- x = 4 + index * 240
- self.contents.draw_text(x, 0, 128, 32, @commands[index])
- end
- end
- #-------------------------------------------------------------------------------
- # * Window_BlackSmithForge
- #-------------------------------------------------------------------------------
- class Window_BlackSmithForge < Window_Selectable
- def initialize(shop_goods)
- super(0, 160, 368, 352) # super(0, 128, 368, 352)
- self.back_opacity = Zer0_CFG::BS_WINDOW_OPACITY
- @data = shop_goods
- refresh
- self.index = 0
- end
- def item
- return @data[self.index]
- end
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- (0...@item_max).each {|i| draw_item(i)}
- end
- end
- def draw_item(index)
- item = @data[index]
- case item
- when RPG::Weapon
- number = $game_party.weapon_number(item.id)
- @materials = Zer0_CFG.blacksmith_weapon_materials(item.id)
- @price = Zer0_CFG.blacksmith_weapon_prices(item.id)
- when RPG::Armor
- number = $game_party.armor_number(item.id)
- @materials = Zer0_CFG.blacksmith_armor_materials(item.id)
- @price = Zer0_CFG.blacksmith_armor_prices(item.id)
- end
- if required_materials? && number < 99
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- x = 4
- y = index * 32
- rect = Rect.new(x, y, self.width - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- bitmap = RPG::Cache.icon(item.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
- self.contents.draw_text(x + 28, y, 222, 32, item.name, 0) # width 212
- #self.contents.draw_text(x + 240, y, 88, 32, @price.to_s, 2)
- end
- def update_help
- @help_window.set_text(self.item == nil ? '' : self.item.description)
- end
- def required_materials?
- @materials.each_index {|i|
- if $game_party.item_number(@materials[i][0]) < @materials[i][1]
- return false
- end
- }
- return false if $game_party.gold < @price
- return true
- end
- end
- #-------------------------------------------------------------------------------
- # * Window_BlackSmithExtract
- #-------------------------------------------------------------------------------
- class Window_BlackSmithExtract < Window_Selectable
- def initialize
- super(0, 128, 368, 352)
- self.back_opacity = Zer0_CFG::BS_WINDOW_OPACITY
- refresh
- self.index = 0
- end
- def item
- return @data[self.index]
- end
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- (1...$data_weapons.size).each {|i|
- if $game_party.weapon_number(i) > 0
- @data.push($data_weapons[i])
- end
- }
- (1...$data_armors.size).each {|i|
- if $game_party.armor_number(i) > 0
- @data.push($data_armors[i])
- end
- }
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- (0...@item_max).each {|i| draw_item(i)}
- end
- end
- def draw_item(index)
- item = @data[index]
- case item
- when RPG::Weapon
- number = $game_party.weapon_number(item.id)
- materials = Zer0_CFG.blacksmith_weapon_materials(item.id)
- price = Zer0_CFG.blacksmith_weapon_prices(item.id)
- when RPG::Armor
- number = $game_party.armor_number(item.id)
- materials = Zer0_CFG.blacksmith_armor_materials(item.id)
- price = Zer0_CFG.blacksmith_armor_prices(item.id)
- end
- if materials.size > 0
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- x = 4
- y = index * 32
- rect = Rect.new(x, y, self.width / @column_max - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- bitmap = RPG::Cache.icon(item.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
- self.contents.draw_text(x + 28, y, 222, 32, item.name, 0) # width 212
- self.contents.draw_text(x + 240, y, 16, 32, ':', 1)
- self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
- end
- def update_help
- @help_window.set_text(self.item == nil ? '' : self.item.description)
- end
- end
- #-------------------------------------------------------------------------------
- # * Window_BlackSmithStatus
- #-------------------------------------------------------------------------------
- class Window_BlackSmithStatus < Window_Base
- PLUS_COLOR = Color.new(128, 255, 128)
- MINUS_COLOR = Color.new(255, 128, 128)
- SIGN_WIDTH = 8
- STAT_NAME_C1 = 32
- STAT_NAME_C2 = 104
- STAT_NAME_C3 = 176
- STAT_SIGN_C1 = STAT_NAME_C1 + 28
- STAT_SIGN_C2 = STAT_NAME_C2 + 28
- STAT_SIGN_C3 = STAT_NAME_C3 + 22
- STAT_VAL_C1 = STAT_SIGN_C1 + SIGN_WIDTH + 2
- STAT_VAL_C2 = STAT_SIGN_C2 + SIGN_WIDTH + 2
- STAT_VAL_C3 = STAT_SIGN_C3 + SIGN_WIDTH + 2
- def initialize
- super(368, 160, 272, 320) # super(368, 128, 272, 352)
- self.back_opacity = Zer0_CFG::BS_WINDOW_OPACITY
- self.contents = Bitmap.new(width-32, height-32)
- @item = nil
- @sprites = [Sprite.new, Sprite.new, Sprite.new, Sprite.new]
- @sprites.each_with_index {|sprite, i|
- sprite.x = 380
- sprite.y = 194 + i * 64 + 32 # sprite.y = 194 + i * 64
- sprite.z = self.z + 10
- }
- @walk = [false, false, false, false]
- @count = 0
- refresh
- end
- def refresh
- self.contents.clear
- @sprites.each {|sprite| sprite.visible = false}
- return if @item == nil
- self.contents.font.size = Font.default_size + 3
- number = case @item
- when RPG::Item then $game_party.item_number(@item.id)
- when RPG::Weapon then $game_party.weapon_number(@item.id)
- when RPG::Armor then $game_party.armor_number(@item.id)
- end
- self.contents.font.color = system_color
- self.contents.draw_text(4, 0, 200, 32, 'Possessed:')
- self.contents.font.color = normal_color
- self.contents.draw_text(204, 0, 32, 32, number.to_s, 2)
- if @item.is_a?(RPG::Item)
- @walk = [false, false, false, false]
- return
- end
- (0...$game_party.actors.size).each do |i|
- actor = $game_party.actors[i]
- if @item.is_a?(RPG::Weapon)
- item1 = $data_weapons[actor.weapon_id]
- elsif @item.kind == 0
- item1 = $data_armors[actor.armor1_id]
- elsif @item.kind == 1
- item1 = $data_armors[actor.armor2_id]
- elsif @item.kind == 2
- item1 = $data_armors[actor.armor3_id]
- else
- item1 = $data_armors[actor.armor4_id]
- end
- if !actor.equippable?(@item)
- draw_actor_graphic(i, false)
- self.contents.font.size = Font.default_size
- self.contents.font.color = normal_color
- self.contents.draw_text(32, 54 + 64 * i, 150, 32, 'Cannot Equip')
- else
- draw_actor_graphic(i, true)
- str1 = item1 != nil ? item1.str_plus : 0
- str2 = @item != nil ? @item.str_plus : 0
- dex1 = item1 != nil ? item1.dex_plus : 0
- dex2 = @item != nil ? @item.dex_plus : 0
- agi1 = item1 != nil ? item1.agi_plus : 0
- agi2 = @item != nil ? @item.agi_plus : 0
- int1 = item1 != nil ? item1.int_plus : 0
- int2 = @item != nil ? @item.int_plus : 0
- pdf1 = item1 != nil ? item1.pdef : 0
- pdf2 = @item != nil ? @item.pdef : 0
- mdf1 = item1 != nil ? item1.mdef : 0
- mdf2 = @item != nil ? @item.mdef : 0
- atk1 = atk2 = eva1 = eva2 = 0
- if @item.is_a?(RPG::Weapon)
- atk1 = item1 != nil ? item1.atk : 0
- atk2 = @item != nil ? @item.atk : 0
- end
- if @item.is_a?(RPG::Armor)
- eva1 = item1 != nil ? item1.eva : 0
- eva2 = @item != nil ? @item.eva : 0
- end
- str_change = str2 - str1
- dex_change = dex2 - dex1
- agi_change = agi2 - agi1
- int_change = int2 - int1
- pdf_change = pdf2 - pdf1
- mdf_change = mdf2 - mdf1
- atk_change = atk2 - atk1
- eva_change = eva2 - eva1
- name1 = item1 == nil ? '' : item1.name
- name2 = @item == nil ? '' : @item.name
- if str_change == 0 && dex_change == 0 && agi_change == 0 &&
- pdf_change == 0 && mdf_change == 0 && atk_change == 0 &&
- eva_change == 0 && int_change == 0 && name1 != name2
- self.contents.font.size = Font.default_size
- self.contents.font.color = normal_color
- self.contents.draw_text(32, 54 + 64 * i, 150, 32, 'No Change')
- end
- if name1 == name2
- self.contents.font.size = Font.default_size
- self.contents.font.color = normal_color
- self.contents.draw_text(32, 54 + 64 * i, 200, 32, 'Currently Equipped')
- end
- self.contents.font.size = (Font.default_size - 3)
- self.contents.font.color = normal_color
- if @item.is_a?(RPG::Weapon) && atk_change != 0
- self.contents.draw_text(STAT_NAME_C1, 42 + 64 * i, 32, 32, 'ATK')
- end
- if @item.is_a?(RPG::Armor) && eva_change != 0
- self.contents.draw_text(STAT_NAME_C1, 42 + 64 * i, 32, 32, 'EVA')
- end
- if pdf_change != 0
- self.contents.draw_text(STAT_NAME_C1, 58 + 64 * i, 32 + 8, 32, 'PDEF')
- end
- if mdf_change != 0
- self.contents.draw_text(STAT_NAME_C1, 74 + 64 * i, 32 + 8, 32, 'MDEF')
- end
- if str_change != 0
- self.contents.draw_text(STAT_NAME_C2, 42 + 64 * i, 32, 32, 'Str')
- end
- if dex_change != 0
- self.contents.draw_text(STAT_NAME_C2, 58 + 64 * i, 32, 32, 'Dex')
- end
- if agi_change != 0
- self.contents.draw_text(STAT_NAME_C2, 74 + 64 * i, 32, 32, 'Agi')
- end
- if int_change != 0
- self.contents.draw_text(STAT_NAME_C3, 42 + 64 * i, 32, 32, 'Int')
- end
- if @item.is_a?(RPG::Weapon) && atk_change > 0
- self.contents.font.color = PLUS_COLOR
- s = atk_change.abs.to_s
- self.contents.draw_text(STAT_SIGN_C1 + 3, 42 + 64 * i, SIGN_WIDTH, 32, '+', 1)
- self.contents.draw_text(STAT_VAL_C1, 42 + 64 * i, 24, 32, s) # STAT_CAL_C1 era 70
- elsif @item.is_a?(RPG::Weapon) && atk_change < 0
- self.contents.font.color = MINUS_COLOR
- s = atk_change.abs.to_s
- self.contents.draw_text(STAT_SIGN_C1 + 3, 42 + 64 * i, SIGN_WIDTH, 32, '-', 1)
- self.contents.draw_text(STAT_VAL_C1 + 3, 42 + 64 * i, 24, 32, s)
- end
- if @item.is_a?(RPG::Armor) && eva_change > 0
- self.contents.font.color = PLUS_COLOR
- s = eva_change.abs.to_s
- self.contents.draw_text(STAT_SIGN_C1, 42 + 64 * i, SIGN_WIDTH, 32, '+', 1)
- self.contents.draw_text(STAT_VAL_C1, 42 + 64 * i, 24, 32, s)
- elsif @item.is_a?(RPG::Armor) && eva_change < 0
- self.contents.font.color = MINUS_COLOR
- s = eva_change.abs.to_s
- self.contents.draw_text(STAT_SIGN_C1, 42 + 64 * i, SIGN_WIDTH, 32, '-', 1)
- self.contents.draw_text(STAT_VAL_C1, 42 + 64 * i, 24, 32, s)
- end
- if pdf_change > 0
- self.contents.font.color = PLUS_COLOR
- s = pdf_change.abs.to_s
- self.contents.draw_text(STAT_SIGN_C1 + 10, 58 + 64 * i, SIGN_WIDTH, 32, '+', 1)
- self.contents.draw_text(STAT_VAL_C1 + 10, 58 + 64 * i, 24, 32, s)
- elsif pdf_change < 0
- self.contents.font.color = MINUS_COLOR
- s = pdf_change.abs.to_s
- self.contents.draw_text(STAT_SIGN_C1 + 10, 58 + 64 * i, SIGN_WIDTH, 32, '-', 1)
- self.contents.draw_text(STAT_VAL_C1 + 10, 58 + 64 * i, 24, 32, s)
- end
- if mdf_change > 0
- self.contents.font.color = PLUS_COLOR
- s = mdf_change.abs.to_s
- self.contents.draw_text(STAT_SIGN_C1 + 10, 74 + 64 * i, SIGN_WIDTH, 32, '+', 1)
- self.contents.draw_text(STAT_VAL_C1 + 10, 74 + 64 * i, 24, 32, s)
- elsif mdf_change < 0
- self.contents.font.color = MINUS_COLOR
- s = mdf_change.abs.to_s
- self.contents.draw_text(STAT_SIGN_C1 + 10, 74 + 64 * i, SIGN_WIDTH, 32, '-',1)
- self.contents.draw_text(STAT_VAL_C1 + 10, 74 + 64 * i, 24, 32, s)
- end
- if str_change > 0
- self.contents.font.color = PLUS_COLOR
- s = str_change.abs.to_s
- self.contents.draw_text(STAT_SIGN_C2, 42 + 64 * i, SIGN_WIDTH, 32, '+', 1)
- self.contents.draw_text(STAT_VAL_C2, 42 + 64 * i, 24, 32, s)
- elsif str_change < 0
- self.contents.font.color = MINUS_COLOR
- s = str_change.abs.to_s
- self.contents.draw_text(STAT_SIGN_C2, 42 + 64 * i, SIGN_WIDTH, 32, '-', 1)
- self.contents.draw_text(STAT_VAL_C2, 42 + 64 * i, 24, 32, s)
- end
- if dex_change > 0
- self.contents.font.color = PLUS_COLOR
- s = dex_change.abs.to_s
- self.contents.draw_text(STAT_SIGN_C2, 58 + 64 * i, SIGN_WIDTH, 32, '+', 1)
- self.contents.draw_text(STAT_VAL_C2, 58 + 64 * i, 24, 32, s)
- elsif dex_change < 0
- self.contents.font.color = MINUS_COLOR
- s = dex_change.abs.to_s
- self.contents.draw_text(STAT_SIGN_C2, 58 + 64 * i, SIGN_WIDTH, 32, '-', 1)
- self.contents.draw_text(STAT_VAL_C2, 58 + 64 * i, 24, 32, s)
- end
- if agi_change > 0
- self.contents.font.color = PLUS_COLOR
- s = agi_change.abs.to_s
- self.contents.draw_text(STAT_SIGN_C2, 74 + 64 * i, SIGN_WIDTH, 32, '+', 1)
- self.contents.draw_text(STAT_VAL_C2, 74 + 64 * i, 24, 32, s)
- elsif agi_change < 0
- self.contents.font.color = MINUS_COLOR
- s = agi_change.abs.to_s
- self.contents.draw_text(STAT_SIGN_C2, 74 + 64 * i, SIGN_WIDTH, 32, '-', 1)
- self.contents.draw_text(STAT_VAL_C2, 74 + 64 * i, 24, 32, s)
- end
- if int_change > 0
- self.contents.font.color = PLUS_COLOR
- s = int_change.abs.to_s
- self.contents.draw_text(STAT_SIGN_C3, 42 + 64 * i, SIGN_WIDTH, 32, '+', 1)
- self.contents.draw_text(STAT_VAL_C3, 42 + 64 * i, 24, 32, s)
- elsif int_change < 0
- self.contents.font.color = MINUS_COLOR
- s = int_change.abs.to_s
- self.contents.draw_text(STAT_SIGN_C3, 42 + 64 * i, SIGN_WIDTH, 32, '-', 1)
- self.contents.draw_text(STAT_VAL_C3, 42 + 64 * i, 24, 32, s)
- end
- end
- end
- end
- def item=(item)
- if @item != item
- @item = item
- refresh
- end
- end
- def draw_actor_graphic(id, equipable)
- actor = $game_party.actors[id]
- @sprites[id].bitmap = RPG::Cache.character(actor.character_name,
- actor.character_hue)
- @sprites[id].src_rect.set(0, 0, @sprites[id].bitmap.width / 4,
- @sprites[id].bitmap.height / 4) # (0, 0, ..., ...)
- @walk[id] = equipable
- @sprites[id].tone = Tone.new(0, 0, 0, equipable ? 0 : 255)
- @sprites[id].visible = true
- end
- def update
- super
- @count = (@count + 1) % 40
- (0..3).each {|i|
- next unless @walk[i]
- if @sprites[i].bitmap != nil
- w = @sprites[i].bitmap.width / 4
- h = @sprites[i].bitmap.height / 4
- x = (@count / 10) * w
- @sprites[i].src_rect.set(x, 0, w, h)
- end
- }
- end
- def visible=(val)
- super
- @sprites.each {|sprite| sprite.visible = val if sprite}
- end
- def dispose
- super
- @sprites.each {|sprite| sprite.dispose if sprite}
- end
- end
- #-------------------------------------------------------------------------------
- # * Window_BlackSmithMaterials
- #-------------------------------------------------------------------------------
- class Window_BlackSmithMaterials < Window_Base
- def initialize
- super(0, 160, 368, 352) # super(0, 128, 368, 352)
- self.back_opacity = 160
- self.contents = Bitmap.new(width - 32, height - 32)
- end
- def refresh(forge_item, index = 0)
- self.contents.clear
- @item = forge_item
- case @item
- when RPG::Weapon
- @materials = Zer0_CFG.blacksmith_weapon_materials(@item.id)
- @price = Zer0_CFG.blacksmith_weapon_prices(@item.id)
- when RPG::Armor
- @materials = Zer0_CFG.blacksmith_armor_materials(@item.id)
- @price = Zer0_CFG.blacksmith_armor_prices(@item.id)
- end
- self.contents.font.color = normal_color
- #self.contents.draw_text(4, 0, 212, 32, 'Price:', 0)
- bitmap = RPG::Cache.icon(@item.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.blt(4, 0 + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
- self.contents.draw_text(32, 0, 212, 32, @item.name, 0)
- #self.contents.draw_text(244, 0, 88, 32, @price.to_s, 2)
- if index == 0
- self.contents.draw_text(4, 32, 368, 32, 'Required Materials:', 0)
- else
- self.contents.draw_text(4, 32, 368, 32, 'Extractable Materials:', 0)
- end
- @materials.each_index {|i|
- item = $data_items[@materials[i][0]]
- number = @materials[i][1]
- x = 4
- y = 64 + (i * 32)
- if index == 0
- if $game_party.item_number(@materials[i][0]) >= @materials[i][1]
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- end
- rect = Rect.new(x, y, self.width - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- bitmap = RPG::Cache.icon(item.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
- self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
- #self.contents.draw_text(x + 272, y, 48, 32, 'x', 0)
- #self.contents.draw_text(x + 272, y, 48, 32, number.to_s, 2)
- self.contents.draw_text(x + 248, y, 48, 32, '/', 2)
- self.contents.draw_text(x + 262, y, 48, 32, number.to_s, 0)
- self.contents.draw_text(x + 272, y, 48, 32, $game_party.item_number(@materials[i][0]).to_s, 2)
- }
- end
- end
- #-------------------------------------------------------------------------------
- # * Scene_BlackSmith
- #-------------------------------------------------------------------------------
- class Scene_BlackSmith
- def initialize(weapons = [], armors = [])
- @goods = []
- weapons.each_index {|i| @goods.push($data_weapons[weapons[i]])}
- armors.each_index {|i| @goods.push($data_armors[armors[i]])}
- end
- def main
- @map = Spriteset_Map.new
- @command_window = Window_BlackSmithCommand.new
- @forge_window = Window_BlackSmithForge.new(@goods)
- @extract_window = Window_BlackSmithExtract.new
- @materials_window = Window_BlackSmithMaterials.new
- @status_window = Window_BlackSmithStatus.new
- @forge_window.active = @forge_window.visible = false
- @status_window.visible = @materials_window.visible = false
- @extract_window.active = @extract_window.visible = false
- @help_window = Window_Help.new
- @forge_window.help_window = @extract_window.help_window = @help_window
- @gold_window = Window_BlackSkill.new # @gold_window = Window_Gold.new
- @gold_window.x, @gold_window.y = 480, 64
- @help_window.back_opacity = @gold_window.back_opacity = Zer0_CFG::BS_WINDOW_OPACITY
- Graphics.transition
- loop {Graphics.update; Input.update; update; break if $scene != self}
- [@command_window, @forge_window, @status_window, @help_window, @gold_window,
- @extract_window, @materials_window, @map].each {|w| w.dispose}
- end
- def update
- [@command_window, @forge_window, @status_window, @help_window, @gold_window,
- @extract_window, @materials_window].each {|w| w.update}
- if @command_window.active
- update_command
- elsif @forge_window.active
- update_forge
- elsif @extract_window.active
- update_extract
- elsif @materials_window.visible
- update_materials
- end
- end
- def update_command
- case @command_window.index
- when 0
- @help_window.set_text('Use materials to forge new weapons/armors.')
- #when 1
- #@help_window.set_text('Extract materials from weapons/armors.')
- when 1 # era 2
- @help_window.set_text('Exit the shop.')
- end
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- $scene = Scene_Map.new
- end
- if Input.trigger?(Input::C)
- $game_system.se_play($data_system.decision_se)
- case @command_window.index
- when 0
- @forge_window.refresh
- @command_window.active = false
- @forge_window.active = @forge_window.visible = true
- @status_window.visible = true
- #when 1
- #@extract_window.refresh
- #@command_window.active = false
- #@extract_window.active = @extract_window.visible = true
- #@status_window.visible = true
- when 1 # era 2
- $game_system.se_play($data_system.cancel_se)
- $scene = Scene_Map.new
- end
- end
- end
- def update_forge
- @item = @status_window.item = @forge_window.item
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @command_window.active = true
- @forge_window.active = @forge_window.visible = false
- @status_window.visible = false
- end
- if Input.trigger?(Input::C)
- $game_system.se_play($data_system.decision_se)
- @materials_window.refresh(@item)
- @forge_window.active = @forge_window.visible = false
- @materials_window.visible = true
- end
- end
- def update_extract
- @item = @status_window.item = @extract_window.item
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @command_window.active = true
- @extract_window.active = @extract_window.visible = false
- @status_window.visible = false
- end
- if Input.trigger?(Input::C)
- $game_system.se_play($data_system.decision_se)
- @materials_window.refresh(@item, 1)
- @extract_window.active = @extract_window.visible = false
- @materials_window.visible = true
- end
- end
- def update_materials
- text = 'Press the Action Button to proceed. Press Cancel to go back'
- @help_window.set_text(text)
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- if @command_window.index == 0
- @materials_window.visible = false
- @forge_window.active = @forge_window.visible = true
- else
- @materials_window.visible = false
- @extract_window.active = @extract_window.visible = true
- end
- end
- if Input.trigger?(Input::C)
- case @item
- when RPG::Weapon
- number = $game_party.weapon_number(@item.id)
- @materials = Zer0_CFG.blacksmith_weapon_materials(@item.id)
- @price = Zer0_CFG.blacksmith_weapon_prices(@item.id)
- when RPG::Armor
- number = $game_party.armor_number(@item.id)
- @materials = Zer0_CFG.blacksmith_armor_materials(@item.id)
- @price = Zer0_CFG.blacksmith_armor_prices(@item.id)
- end
- # Forging Procedure
- if @command_window.index == 0
- if required_materials? && ($game_party.gold >= @price) && (number < 99)
- Audio.se_play('Audio/SE/' + Zer0_CFG::FORGE_SE, 80, 100)
- @materials.each_index {|i|
- $game_party.lose_item(@materials[i][0], @materials[i][1])}
- $game_party.lose_gold(@price)
- case @item
- when RPG::Weapon
- $game_party.gain_weapon(@item.id, 1)
- when RPG::Armor
- $game_party.gain_armor(@item.id, 1)
- end
- @materials_window.visible = false
- @forge_window.active = @forge_window.visible = true
- $game_variables[35] += 1 # Increases Custom Variable to hold Skill
- else
- $game_system.se_play($data_system.buzzer_se)
- end
- else
- if @materials.size > 0
- Audio.se_play('Audio/SE/' + Zer0_CFG::EXTRACT_SE, 80, 100)
- @materials.each_index {|i|
- $game_party.gain_item(@materials[i][0], @materials[i][1])}
- $game_party.lose_gold(@price)
- case @item
- when RPG::Weapon
- $game_party.lose_weapon(@item.id, 1)
- when RPG::Armor
- $game_party.lose_armor(@item.id, 1)
- end
- @materials_window.visible = false
- @extract_window.active = @extract_window.visible = true
- else
- $game_system.se_play($data_system.buzzer_se)
- end
- end
- [@status_window, @gold_window, @extract_window, @forge_window].each {|w|
- w.refresh}
- end
- end
- def required_materials?
- @materials.each_index {|i|
- if $game_party.item_number(@materials[i][0]) < @materials[i][1]
- return false
- end
- }
- return false if $game_party.gold < @price
- return true
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement