Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ▼ Synthesis Shop (Магазин синтеза)
- # Автор: Kread-EX
- # Версия 1.0
- # Дата выхода: 12.12.2011
- # Требует: Kread-EX Alchemic Synthesis GO GO TOTORI!
- #
- # Перевод: mephis
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- #-------------------------------------------------------------------------------------------------
- # ▼ УСЛОВИЯ ИСПОЛЬЗОВАНИЯ
- #-------------------------------------------------------------------------------------------------
- # Вы можете изменять код этого скрипта под ваши нужды.
- # Вы можете использовать этот скрипт в коммерческих целях.
- # Обязательно указывайте автора.
- #
- # # По поддержке можно со мной связаться здесь:
- # # grimoirecastle.wordpress.com
- # # или здесь
- # # rpgmakervxace.net
- # # или здесь
- # # rpgrevolution.com
- #-------------------------------------------------------------------------------------------------
- # ▼ ВВЕДЕНИЕ
- #-------------------------------------------------------------------------------------------------
- # Это дополнение к скрипту алхимического синтеза. Оно добавляет в игру
- # Магазин Синтеза, специальный магазин, в котором продаются синтезированныев вещи.
- #-------------------------------------------------------------------------------------------------
- # ▼ ИНСТРУКЦИЯ
- #-------------------------------------------------------------------------------------------------
- # Поместите этот скрипт ниже скрипта Alchemic Synthesis.
- # Затем, в Заметках синтезируемой вещи вставьте ещё один тег:
- # <synth_shop: x>
- # Где х это количество копий этой вещи, доступное в магазине.
- #
- # Чтобы вызвать магазин используйте команду скрипта:
- # SceneManager.call(Scene_SynthesisShop)
- #-------------------------------------------------------------------------------------------------
- # ▼ СОВМЕСТИМОСТЬ
- #-------------------------------------------------------------------------------------------------
- # Пока что на Ace не так много скриптов, но этот должен нормально работать со
- # скриптами Yanfly.
- #
- # Новые классы: Scene_SynthesisShop Window_SynthShopBuy, Window_SynthShopStatus
- #
- # Список псевдонимов и перекрытий:
- #
- # DataManager
- # load_database (псевдоним)
- # load_synthshop_notetags (новый метод)
- #
- # Game_Party
- # initialize (псевдоним)
- #
- # RPG::Item, RPG::Weapon, RPG::Armor
- # load_synthshop_notetags (новый метод)
- #-------------------------------------------------------------------------------------------------
- # Quits if the synthesis system isn't found
- if $imported.nil? || $imported['KRX-AlchemicSynthesis'].nil?
- msgbox('Чтобы использовать Магазин Синтеза вам нужен скрипт Alchemic Synthesis. Загрузка прервана.')
- else
- $imported['KRX-SynthesisShop'] = true
- puts 'Load: Synthesis Shop v1.0 by Kread-EX'
- module KRX
- module REGEXP
- SYNTHESIS_SHOP = /<synth_shop:[ ]*(\d+)>/i
- end
- module VOCAB
- SYNTHESIS_SHOP_STOCK = 'Запасы магазина:'
- end
- end
- #===========================================================================
- # ■ DataManager
- #===========================================================================
- module DataManager
- #--------------------------------------------------------------------------
- # ● Loads the database
- #--------------------------------------------------------------------------
- class << self
- alias_method(:krx_synthshop_dm_load_database, :load_database)
- end
- def self.load_database
- krx_synthshop_dm_load_database
- load_synthshop_notetags
- end
- #--------------------------------------------------------------------------
- # ● Loads the note tags
- #--------------------------------------------------------------------------
- def self.load_synthshop_notetags
- groups = [$data_items, $data_weapons, $data_armors]
- classes = [RPG::Item, RPG::Weapon, RPG::Armor]
- for group in groups
- for obj in group
- next if obj.nil?
- obj.load_synthshop_notetags if classes.include?(obj.class)
- end
- end
- puts "Read: Synthesis Shop Notetags"
- end
- end
- #==========================================================================
- # ■ RPG::Item
- #==========================================================================
- class RPG::Item < RPG::UsableItem
- #--------------------------------------------------------------------------
- # ● Public instance variables
- #--------------------------------------------------------------------------
- attr_reader :synthesis_shop_nb
- #--------------------------------------------------------------------------
- # ● Loads the note tags
- #--------------------------------------------------------------------------
- def load_synthshop_notetags
- @synthesis_shop_nb = 0
- @note.split(/[\r\n]+/).each do |line|
- case line
- when KRX::REGEXP::SYNTHESIS_SHOP
- @synthesis_shop_nb = $1.to_i
- end
- end
- end
- end
- #==========================================================================
- # ■ RPG::Weapon
- #==========================================================================
- class RPG::Weapon < RPG::EquipItem
- #--------------------------------------------------------------------------
- # ● Public instance variables
- #--------------------------------------------------------------------------
- attr_reader :synthesis_shop_nb
- #--------------------------------------------------------------------------
- # ● Loads the note tags
- #--------------------------------------------------------------------------
- def load_synthshop_notetags
- @synthesis_shop_nb = 0
- @note.split(/[\r\n]+/).each do |line|
- case line
- when KRX::REGEXP::SYNTHESIS_SHOP
- @synthesis_shop_nb = $1.to_i
- end
- end
- end
- end
- #==========================================================================
- # ■ RPG::Armor
- #==========================================================================
- class RPG::Armor < RPG::EquipItem
- #--------------------------------------------------------------------------
- # ● Public instance variables
- #--------------------------------------------------------------------------
- attr_reader :synthesis_shop_nb
- #--------------------------------------------------------------------------
- # ● Loads the note tags
- #--------------------------------------------------------------------------
- def load_synthshop_notetags
- @synthesis_shop_nb = 0
- @note.split(/[\r\n]+/).each do |line|
- case line
- when KRX::REGEXP::SYNTHESIS_SHOP
- @synthesis_shop_nb = $1.to_i
- end
- end
- end
- end
- #==========================================================================
- # ■ Game_Party
- #==========================================================================
- class Game_Party < Game_Unit
- #--------------------------------------------------------------------------
- # ● Public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :synthesis_stock
- #--------------------------------------------------------------------------
- # ● Object Initialize
- #--------------------------------------------------------------------------
- alias_method(:krx_synthshop_gp_initialize, :initialize) unless $@
- def initialize
- krx_synthshop_gp_initialize
- @synthesis_stock = {}
- end
- end
- #==========================================================================
- # ■ Window_SynthShopStatus
- #==========================================================================
- class Window_SynthShopStatus < Window_ShopStatus
- #--------------------------------------------------------------------------
- # ● Refreshes the contents
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_possession(4, 0)
- draw_vendor_stock(4, line_height)
- draw_item_traits
- end
- #--------------------------------------------------------------------------
- # ● Displays the number of items in stock for the vendor
- #--------------------------------------------------------------------------
- def draw_vendor_stock(x, y)
- rect = Rect.new(x, y, contents.width - 4 - x, line_height)
- change_color(system_color)
- draw_text(rect, KRX::VOCAB::SYNTHESIS_SHOP_STOCK)
- change_color(normal_color)
- draw_text(rect, $game_party.synthesis_stock[@item].to_s, 2)
- end
- #--------------------------------------------------------------------------
- # ● Displays the item traits
- #--------------------------------------------------------------------------
- def draw_item_traits
- return if @item.nil?
- draw_horz_line(line_height * 2)
- change_color(system_color)
- contents.draw_text(4, line_height * 3, width, line_height, KRX::VOCAB::TRAITS)
- change_color(normal_color)
- (1..4).each {|i| contents.draw_text(4, line_height * (i + 3), width, line_height, "#{i}.")}
- @item.synthesis_traits.each_index do |i|
- trait = @item.synthesis_traits[i]
- contents.draw_text(28, line_height * (i + 4), width - 24, line_height, trait)
- end
- end
- #--------------------------------------------------------------------------
- # ● Displays an horizontal line
- #--------------------------------------------------------------------------
- def draw_horz_line(y)
- line_y = y + line_height / 2 - 1
- contents.fill_rect(0, line_y, contents_width, 2, line_color)
- end
- #--------------------------------------------------------------------------
- # ● Returns the color used for horizontal lines
- #--------------------------------------------------------------------------
- def line_color
- color = normal_color
- color.alpha = 48
- return color
- end
- end
- #==========================================================================
- # ■ Window_SynthShopBuy
- #==========================================================================
- class Window_SynthShopBuy < Window_ShopBuy
- #--------------------------------------------------------------------------
- # ● Creates the list of items
- #--------------------------------------------------------------------------
- def make_item_list
- @data = []
- @price = {}
- @quantity = {}
- @shop_goods.each_key do |item|
- next if item.nil?
- @quantity[item] = $game_party.synthesis_stock[item]
- next if @quantity[item].nil? || @quantity[item] == 0
- @data.push(item)
- @price[item] = item.price
- end
- end
- #--------------------------------------------------------------------------
- # ● Determines if an item can be bought
- #--------------------------------------------------------------------------
- def enable?(item)
- item && price(item) <= @money && !$game_party.item_max?(item) &&
- $game_party.synthesis_stock[item] > 0
- end
- end
- #==========================================================================
- # ■ Scene_SynthesisShop
- #==========================================================================
- class Scene_SynthesisShop < Scene_Shop
- #--------------------------------------------------------------------------
- # ● Object Initialize
- #--------------------------------------------------------------------------
- def initialize
- super
- @goods = $game_party.synthesis_stock
- @purchase_only = true
- end
- #--------------------------------------------------------------------------
- # ● Constructs the window showing the goods in sale
- #--------------------------------------------------------------------------
- def create_buy_window
- wy = @dummy_window.y
- wh = @dummy_window.height
- @buy_window = Window_SynthShopBuy.new(0, wy, wh, @goods)
- @buy_window.viewport = @viewport
- @buy_window.help_window = @help_window
- @buy_window.status_window = @status_window
- @buy_window.hide
- @buy_window.set_handler(:ok, method(:on_buy_ok))
- @buy_window.set_handler(:cancel, method(:on_buy_cancel))
- end
- #--------------------------------------------------------------------------
- # ● Constructs the window showing the actors' status
- #--------------------------------------------------------------------------
- def create_status_window
- wx = @number_window.width
- wy = @dummy_window.y
- ww = Graphics.width - wx
- wh = @dummy_window.height
- @status_window = Window_SynthShopStatus.new(wx, wy, ww, wh)
- @status_window.viewport = @viewport
- @status_window.hide
- end
- #--------------------------------------------------------------------------
- # ● Confirms the item selection
- #--------------------------------------------------------------------------
- def on_buy_ok
- @item = @buy_window.item
- @buy_window.hide
- @number_window.set(@item, $game_party.synthesis_stock[@item], buying_price, currency_unit)
- @number_window.show.activate
- end
- #--------------------------------------------------------------------------
- # ● Performs the deal
- #--------------------------------------------------------------------------
- def do_buy(number)
- super(number)
- $game_party.synthesis_stock[@item] -= number
- end
- end
- #==========================================================================
- # ■ Scene_Alchemy
- #==========================================================================
- class Scene_Alchemy < Scene_MenuBase
- #--------------------------------------------------------------------------
- # ● Synthesis outcome
- #--------------------------------------------------------------------------
- alias_method(:krx_synthshop_outcome, :process_outcome)
- def process_outcome(failure = false)
- krx_synthshop_outcome(false)
- unless failure
- itm = $game_party.last_item.object
- $game_party.synthesis_stock[itm] = itm.synthesis_shop_nb
- end
- end
- end
- end # Parent script check
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement