(http://i.imgur.com/nQkTWYU.png)
M+ ItemCrafting
v1.0
Compatibilidade: boa
Facilidade de uso: fácil
Lag gerado: nulo
Introdução e CaracterísticasEste script cria uma janela que é basicamente a loja padrão do RMXP modificada, possibilitando que itens sejam montados a partir da junção de vários outros + gold, e que sejam desmontados por um custo. A configuração do script permite a modificação de todos os termos utilizados, o preço de montagem e de desmontagem de cada item, determinar se é possível desmontar um item, e também determinar seus componentes.
Instruções de uso- Crie um novo script na seção "Scripts Adicionais" e cole o script abaixo lá
- Configure o script ao seu gosto (instruções de configuração presente no script)
- Para chamar o script a partir de um evento, crie um chamar script com o seguinte:
$scene = Scene_Craft.new([[<tipo>, <id>], [<tipo, <id>]])
Onde <tipo> é o tipo do item (0 para itens, 1 para armas e 2 para armaduras) e <id> é o seu ID no banco de dados. Cada item é um [] que fica mais no meio, e os [] mais externos não devem ser apagados. Separe cada item com vírgulas. É importante tomar cuidado com os [], no final os números de '[' e ']' devem ser iguais. Exemplo de um chamar script com vários itens:
$scene = Scene_Craft.new([[1, 1], [1, 2], [2, 1], [2, 2]])
Na janela, terão 2 armas e 2 armaduras.
Imagens[hs width=216 height=164]http://i.imgur.com/oE5R2B1.png[/hs] [hs width=216 height=164]http://i.imgur.com/yAYIWL4.png[/hs]
Script
#==============================================================================
# M+ Item Crafting
# Por M3T (28/03/2015)
# Versão 1.0
#------------------------------------------------------------------------------
# O script é uma espécie de "loja modificada", em que você pode
# juntar itens para formar um novo a certo custo, bem como
# desmontá-los por outro custo e conseguir os itens de volta.
#------------------------------------------------------------------------------
# Configuração:
# - <tipo> é o tipo do item, onde:
# * 0 = item
# * 1 = arma
# * 2 = armadura
# - <id> é simplesmente o ID de um item (definido no banco de dados)
# Em cada "def":
# - As primeiras linhas (i = [type, id]/case i) não devem ser mexidas.
# - As linhas a mexer são:
# * entre "case i" e "end";
# * a linha que tem "return".
# - "return" sempre indicará a configuração padrão para os itens que não
# forem citados acima dele.
#------------------------------------------------------------------------------
# Como chamar a loja:
# - Em um evento, chame um script contendo:
# $scene = Scene_Craft.new([[<tipo>, <id>], [<tipo, <id>]])
# - Modifique as informações entre () para inserir os itens que terão nela.
# - Exemplo:
# $scene = Scene_Craft.new([[1, 2], [1, 3]])
#==============================================================================
($mplus ||= {})["Item Crafting"] = 1.0
module ItemCrafting
# Termos do Script - modificar se necessário
Word_Craft = "Montar" # Montar
Word_Dismount = "Desmontar" # Desmontar
Word_Leave = "Sair" # Sair
Word_Quantity = "Quantia necessária" # Quantia necessária
Word_YouHave = "Você tem" # Você tem
Word_Cancel = "Cancelar" # Cancelar
Word_Crafted = "Item montado" # Item montado
Word_Crafting = "Montar item" # Montar item
Word_Cost = "Custo" # Custo
Word_Components = "Componentes" # Componentes
# O preço de montagem de um item.
def self.craft_price(type, id)
i = [type, id]
case i
# when [<tipo>, <id>] then return <preço de crafting>
when [1, 2] then return 10
when [1, 3] then return 50
end
# preço padrão
return 0
end
# O preço de desmontagem de um item.
def self.uncraft_price(type, id)
i = [type, id]
case i
# when [<tipo>, <id>] then return <preço de desmontagem>
when [1, 2] then return 5
when [1, 3] then return 40
end
# preço padrão
return 0
end
# Possibilidade de um item ser desmontado.
def self.can_uncraft?(type, id)
i = [type, id]
case i
# when [<tipo>, <id>] then return <true/false>
when [1, 2] then return true
when [1, 3] then return false
end
return false
end
# Componentes de um item (o que será perdido na montagem e ganho
# na desmontagem)
def self.components(type, id)
i = [type, id]
case i
# when [<tipo>, <id>]
# return [[<tipo>, <id>, <quantidade>], [<t>, <i>, <q>]]
when [1, 2]
return [[1, 1, 1], [0, 25, 1]]
when [1, 3]
return [[1, 2, 1], [0, 25, 1]]
end
# componentes padrões: [<tipo>, <id>, <quantidade>]
return []
end
end
class Window_CraftingCommand < Window_Selectable
include ItemCrafting
#--------------------------------------------------------------------------
# Inicialização dos Objetos
#--------------------------------------------------------------------------
def initialize
super(0, 64, 480, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
@item_max = 3
@column_max = 3
@commands = [Word_Craft, Word_Dismount, Word_Leave]
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# Atualização
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# Desenho do Item
#
# index : Número do objeto
#--------------------------------------------------------------------------
def draw_item(index)
x = 4 + index * 160
self.contents.draw_text(x, 0, 128, 32, @commands[index])
end
end
class Window_Crafting < Window_Selectable
include ItemCrafting
#--------------------------------------------------------------------------
# Inicialização dos Objetos
#
# shop_goods : Lista de Itens
#--------------------------------------------------------------------------
def initialize(item_list)
super(0, 128, 368, 352)
@item_list = item_list
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# Aquisição do Item
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# Atualizar
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for craft_item in @item_list
case craft_item[0]
when 0
@data.push($data_items[craft_item[1]])
when 1
@data.push($data_weapons[craft_item[1]])
when 2
@data.push($data_armors[craft_item[1]])
end
end
# Número de Objetos. Se não for 0 se cria uma desenho do objeto.
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# Desenho de um Item.
# index : Número de Itens
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
# A quantidade de Itens possuídos
case item
when RPG::Item
price = ItemCrafting.craft_price(0, item.id)
number = $game_party.item_number(item.id)
when RPG::Weapon
price = ItemCrafting.craft_price(1, item.id)
number = $game_party.weapon_number(item.id)
when RPG::Armor
price = ItemCrafting.craft_price(2, item.id)
number = $game_party.armor_number(item.id)
end
# Verifica se você tem menos que 99 itens do tipo. Caso contrário haverá uma
# coloração de invalidez.
if 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, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 88, 32, price.to_s, 2)
end
#--------------------------------------------------------------------------
# Atualizar Texto de Ajuda
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
class Window_Uncrafting < Window_Selectable
include ItemCrafting
#--------------------------------------------------------------------------
# Inicialização dos Objetos
#--------------------------------------------------------------------------
def initialize
super(0, 128, 368, 352)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# Aquisição do Item
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# Atualizar
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in 1...$data_items.size
if $game_party.item_number(i) > 0 && ItemCrafting.can_uncraft?(0, i)
@data.push($data_items[i])
end
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 && ItemCrafting.can_uncraft?(1, i)
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 && ItemCrafting.can_uncraft?(2, i)
@data.push($data_armors[i])
end
end
# Número do Item. Se não for 0 se cria uma desenho do Item.
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# Desenho do Item
#
# index : Número do Item
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
# Se a compra for possível uma cor indicará isso.
if item.price > 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, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# Atualização do Texto de Ajuda
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
class Window_CraftingStatus < Window_Base
#--------------------------------------------------------------------------
# Inicialização dos Objetos
#--------------------------------------------------------------------------
def initialize
super(368, 128, 272, 352)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
@item = nil
refresh
end
#--------------------------------------------------------------------------
# Atualizar
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if @item == nil
return
end
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
when RPG::Armor
number = $game_party.armor_number(@item.id)
end
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 200, 32, "Você tem")
self.contents.font.color = normal_color
self.contents.draw_text(204, 0, 32, 32, number.to_s, 2)
if @item.is_a?(RPG::Item)
return
end
# Informação adicional do equipamento
for i in 0...$game_party.actors.size
# Item é adquirido
actor = $game_party.actors[i]
# Aqui é demonstrado se é possível ou impossível equipar o Item pela sua
# coloração.
if actor.equippable?(@item)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
# Desenhar nome do Item
self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
# Descrição do Item é adquirida
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]
else
item1 = $data_armors[actor.armor3_id]
end
# Se for equipável
if actor.equippable?(@item)
# Armas
if @item.is_a?(RPG::Weapon)
atk1 = item1 != nil ? item1.atk : 0
atk2 = @item != nil ? @item.atk : 0
change = atk2 - atk1
end
# Armaduras
if @item.is_a?(RPG::Armor)
pdef1 = item1 != nil ? item1.pdef : 0
mdef1 = item1 != nil ? item1.mdef : 0
pdef2 = @item != nil ? @item.pdef : 0
mdef2 = @item != nil ? @item.mdef : 0
change = pdef2 - pdef1 + mdef2 - mdef1
end
# Desenhar nome
self.contents.draw_text(124, 64 + 64 * i, 112, 32,
sprintf("%+d", change), 2)
end
# O Item é desenhado
if item1 != nil
x = 4
y = 64 + 64 * i + 32
bitmap = RPG::Cache.icon(item1.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, item1.name)
end
end
end
#--------------------------------------------------------------------------
# Escolher um Item
#
# item : Novo Item
#--------------------------------------------------------------------------
def item=(item)
if @item != item
@item = item
refresh
end
end
end
class Window_CraftingInfo < Window_Base
include ItemCrafting
#--------------------------------------------------------------------------
# Inicialização dos Objetos
#--------------------------------------------------------------------------
def initialize
super(368, 128, 272, 352)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
@item = nil
refresh
end
#--------------------------------------------------------------------------
# Atualizar
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if @item == nil
return
end
case @item
when RPG::Item
t = 0
number = $game_party.item_number(@item.id)
when RPG::Weapon
t = 1
number = $game_party.weapon_number(@item.id)
when RPG::Armor
t = 2
number = $game_party.armor_number(@item.id)
end
price = ItemCrafting.uncraft_price(t, @item.id)
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 200, 32, Word_Components)
self.contents.font.color = normal_color
for i in 0...ItemCrafting.components(t, @item.id).size
item = ItemCrafting.components(t, @item.id)[i]
case item[0]
when 0 then item1 = $data_items[item[1]]
when 1 then item1 = $data_weapons[item[1]]
when 2 then item1 = $data_armors[item[1]]
end
x = 4
y = 32 + i * 32
bitmap = RPG::Cache.icon(item1.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), 255)
self.contents.draw_text(x + 204, y, 32, 32, ": " + item[2].to_s, 2)
self.contents.draw_text(x + 28, y, 174, 32, item1.name)
end
self.contents.font.color = system_color
cx = contents.text_size($data_system.words.gold).width
self.contents.draw_text(4, y + 32, 200, 32, Word_Cost)
self.contents.draw_text(240-cx, y + 32, cx, 32, $data_system.words.gold, 2)
self.contents.font.color = normal_color
self.contents.draw_text(4, y + 32, 236-cx-2, 32, price.to_s, 2)
end
#--------------------------------------------------------------------------
# Escolher um Item
#
# item : Novo Item
#--------------------------------------------------------------------------
def item=(item)
if @item != item
@item = item
refresh
end
end
end
class Window_CraftingItems < Window_Base
include ItemCrafting
attr_accessor :sl
#--------------------------------------------------------------------------
# Inicialização dos Objetos
#--------------------------------------------------------------------------
def initialize
super(0, 128, 640, 352)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
@item = []
@column_max = 1
@sl = 1
refresh
end
def set(type, id)
@item = [type, id]
refresh
end
def item
return @item
end
def craft
return unless able_to_craft?
ItemCrafting.components(@item[0], @item[1]).each {|i|
case i[0]
when 0 then $game_party.lose_item(i[1], i[2])
when 1 then $game_party.lose_weapon(i[1], i[2])
when 2 then $game_party.lose_armor(i[1], i[2])
end }
$game_party.lose_gold(ItemCrafting.craft_price(@item[0], @item[1]))
case @item[0]
when 0 then $game_party.gain_item(@item[1], 1)
when 1 then $game_party.gain_weapon(@item[1], 1)
when 2 then $game_party.gain_armor(@item[1], 1)
end
end
def able_to_craft?
@item_list.each_index {|index|
item = @item_list[index]
qt = @item_qt[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if number < qt
return false
end }
if ItemCrafting.craft_price(@item[0], @item[1]) > $game_party.gold
return false
end
return true
end
#--------------------------------------------------------------------------
# Atualizar
#--------------------------------------------------------------------------
def refresh
self.contents.clear
price = ItemCrafting.craft_price(@item[0], @item[1])
cx = contents.text_size($data_system.words.gold).width
self.contents.draw_text(4, 290, 142-cx-2, 32, price.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(4, 290, 50, 32, Word_Cost)
self.contents.draw_text(146-cx, 290, cx, 32, $data_system.words.gold, 2)
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 212, 32, $data_system.words.item, 0)
self.contents.draw_text(280, 0, 180, 32, Word_Quantity, 0)
self.contents.draw_text(504, 0, 100, 32, Word_YouHave, 2)
self.contents.font.color = normal_color
if @sl == 0
self.cursor_rect.set(227, 290, 75, 32)
else
self.cursor_rect.set(335, 290, 85, 32)
end
self.contents.draw_text(227, 290, 75, 32, Word_Craft, 1)
self.contents.draw_text(335, 290, 85, 32, Word_Cancel, 1)
@item_list = []
@item_qt = []
return if @item.empty?
ItemCrafting.components(@item[0], @item[1]).each {|i|
case i[0]
when 0 then @item_list.push($data_items[i[1]])
when 1 then @item_list.push($data_weapons[i[1]])
when 2 then @item_list.push($data_armors[i[1]])
end
@item_qt.push(i[2]) }
# Número do Item. Se não for 0 se cria uma desenho do Item.
@item_max = @item_list.size
if @item_max > 0
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# Desenho do Item
#
# index : Número do Item
#--------------------------------------------------------------------------
def draw_item(index)
return if index > 7
item = @item_list[index]
qt = @item_qt[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if number < qt
self.contents.font.color = disabled_color
end
x = 4
y = 32 + 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, 212, 32, item.name, 0)
self.contents.draw_text(x + 280, y, 24, 32, qt.to_s, 0)
self.contents.draw_text(x + 504, y, 24, 32, number.to_s, 2)
self.contents.font.color = normal_color
end
def update_commands
if Input.trigger?(Input::RIGHT) || Input.trigger?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
if @sl == 0
@sl = 1
else
@sl = 0
end
refresh
end
end
end
class Scene_Craft
include ItemCrafting
def initialize(items = [])
@items = items
end
#--------------------------------------------------------------------------
# Processamento Principal
#--------------------------------------------------------------------------
def main
# Criar janela de ajuda
@help_window = Window_Help.new
# Criar janela de comandos de Loja
@command_window = Window_CraftingCommand.new
# Criar janela de dinheiro
@gold_window = Window_Gold.new
@gold_window.x = 480
@gold_window.y = 64
# Criar janela testa-de-ferro
@dummy_window = Window_Base.new(0, 128, 640, 352)
# Criar janela de compra
@craft_window = Window_Crafting.new(@items)
@craft_window.active = false
@craft_window.visible = false
@craft_window.help_window = @help_window
# Criar janela de venda
@uncraft_window = Window_Uncrafting.new
@uncraft_window.active = false
@uncraft_window.visible = false
@uncraft_window.help_window = @help_window
# Criar janela de Status
@status_window = Window_CraftingStatus.new
@status_window.visible = false
# Criar janela dos Itens
@items_window = Window_CraftingItems.new
@items_window.active = false
@items_window.visible = false
@number_window = Window_ShopNumber.new
@number_window.active = false
@number_window.visible = false
@info_window = Window_CraftingInfo.new
@info_window.visible = false
# Executar transição
Graphics.transition
# Loop principal
loop do
# Atualizar tela de jogo
Graphics.update
# Atualizar entrada de informações
Input.update
# Atualização do frame
update
# Abortar loop se a tela se alterou
if $scene != self
break
end
end
# Preparar para transição
Graphics.freeze
# Exibição das janelas
@help_window.dispose
@command_window.dispose
@gold_window.dispose
@dummy_window.dispose
@craft_window.dispose
@uncraft_window.dispose
@status_window.dispose
@items_window.dispose
@info_window.dispose
@number_window.dispose
end
#--------------------------------------------------------------------------
# Atualização do Frame
#--------------------------------------------------------------------------
def update
# Atualização das janelas
@help_window.update
@command_window.update
@gold_window.update
@dummy_window.update
@craft_window.update
@uncraft_window.update
@status_window.update
@items_window.update
@info_window.update
@number_window.update
# Se a janela de comandos estiver ativa: chamar update_command
if @command_window.active
update_command
return
end
# Se a janela de compra estiver ativa: chamar update_buy
if @craft_window.active
update_craft
return
end
# Se a janela de venda estiver ativa: chamar update_sell
if @uncraft_window.active
update_uncraft
return
end
if @items_window.active
update_items
return
end
if @number_window.active
update_number
return
end
end
#--------------------------------------------------------------------------
# Atualização do Frame (Quando a janela de comandos estiver ativa)
#--------------------------------------------------------------------------
def update_command
# Se o botão B for pressionado
if Input.trigger?(Input::B)
# Reproduzir SE de cancelamento
$game_system.se_play($data_system.cancel_se)
# Alternar para a tela do Mapa
$scene = Scene_Map.new
return
end
# Se o botão C for pressionado
if Input.trigger?(Input::C)
# Ramificação por posição na janela de comandos
case @command_window.index
when 0 # Comprar
# Reproduzir SE de OK
$game_system.se_play($data_system.decision_se)
# Mudar janelas para o modo de Compra
@command_window.active = false
@dummy_window.visible = false
@craft_window.active = true
@craft_window.visible = true
@craft_window.refresh
@status_window.visible = true
when 1 # Vender
# Reproduzir SE de OK
$game_system.se_play($data_system.decision_se)
# Mudar janelas para o modo de Venda
@command_window.active = false
@dummy_window.visible = false
@uncraft_window.active = true
@uncraft_window.visible = true
@uncraft_window.refresh
@info_window.visible = true
when 2 # Sair
# Reproduzir SE de OK
$game_system.se_play($data_system.decision_se)
# Alternar para a tela do Mapa
$scene = Scene_Map.new
end
return
end
end
#--------------------------------------------------------------------------
# Atualização do Frame (Quando a janela de Compra estiver ativa)
#--------------------------------------------------------------------------
def update_craft
# Definir janela de Status do Item
@status_window.item = @craft_window.item
# Se o botão B for pressionado
if Input.trigger?(Input::B)
# Reproduzir SE de cancelamento
$game_system.se_play($data_system.cancel_se)
# Mudar janela para o modo inicial
@command_window.active = true
@dummy_window.visible = true
@craft_window.active = false
@craft_window.visible = false
@status_window.visible = false
@status_window.item = nil
# Apagar texto de ajuda
@help_window.set_text("")
return
end
# Se o botão C for pressionado
if Input.trigger?(Input::C)
# Selecionar Item
@item = @craft_window.item
# Se o Item for inválido, ou o preço for maior do que o dinheiro possuído
if @item == nil
# Reproduzir SE de erro
$game_system.se_play($data_system.buzzer_se)
return
end
# Selecionar contador de Itens possuídos
case @item
when RPG::Item
type = 0
number = $game_party.item_number(@item.id)
when RPG::Weapon
type = 1
number = $game_party.weapon_number(@item.id)
when RPG::Armor
type = 2
number = $game_party.armor_number(@item.id)
end
# Se já houverem 99 Itens possuídos
if number == 99
# Reproduzir SE de erro
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
# Mudar janelas
@craft_window.active = false
@craft_window.visible = false
@status_window.visible = false
@items_window.active = true
@items_window.visible = true
@items_window.set(type, @item.id)
@help_window.set_text(Word_Crafting + ": " + @item.name)
end
end
#--------------------------------------------------------------------------
# Atualização do Frame (Quando a janela de Venda estiver ativa)
#--------------------------------------------------------------------------
def update_uncraft
# Se o botão B for pressionado
@info_window.item = @uncraft_window.item
if Input.trigger?(Input::B)
# reporduzir SE de cancelamento
$game_system.se_play($data_system.cancel_se)
# Mudar janelas para o modo inicial
@command_window.active = true
@dummy_window.visible = true
@uncraft_window.active = false
@uncraft_window.visible = false
@info_window.visible = false
@info_window.item = nil
@status_window.item = nil
# Apagar texto de ajuda
@help_window.set_text("")
return
end
# Se o botão C for pressionado
if Input.trigger?(Input::C)
# Selecionar Item
@item = @uncraft_window.item
# Definir a janela de Status do Item
@status_window.item = @item
# Se o Item for inválido, ou o preço do Item for 0 (impossível vender)
if @item == nil or @item.price == 0
# Reproduzir SE de erro
$game_system.se_play($data_system.buzzer_se)
return
end
# Reproduzir SE de OK
$game_system.se_play($data_system.decision_se)
# Selecionar contador de Itens possuídos
case @item
when RPG::Item
price = ItemCrafting.uncraft_price(0, @item.id)
number = $game_party.item_number(@item.id)
when RPG::Weapon
price = ItemCrafting.uncraft_price(1, @item.id)
number = $game_party.weapon_number(@item.id)
when RPG::Armor
price = ItemCrafting.uncraft_price(2, @item.id)
number = $game_party.armor_number(@item.id)
end
# Quantidade máxima para vender = número de Itens possuídos
max = number
# Mudar janelas para o modo de entrada de quantidade
@uncraft_window.active = false
@uncraft_window.visible = false
@info_window.visible = false
@number_window.set(@item, max, price)
@number_window.active = true
@number_window.visible = true
@status_window.visible = true
end
end
def update_items
if @countdown != nil && @countdown > 0
@countdown -= 1
if @countdown <= 0
@help_window.set_text(Word_Crafting + ": " + @item.name)
end
end
# Se o botão B for pressionado
if Input.trigger?(Input::B) || (Input.trigger?(Input::C) && @items_window.sl == 1)
# Reproduzir SE de cancelamento
$game_system.se_play($data_system.cancel_se)
@help_window.set_text("")
@items_window.active = false
@items_window.visible = false
@items_window.sl = 1
@craft_window.active = true
@craft_window.visible = true
@status_window.visible = true
return
end
if Input.trigger?(Input::C) && @items_window.sl == 0
if @items_window.able_to_craft?
$game_system.se_play($data_system.shop_se)
@items_window.craft
@help_window.set_text(Word_Crafted + ": " + @item.name)
@countdown = 200
@items_window.refresh
@gold_window.refresh
else
$game_system.se_play($data_system.buzzer_se)
end
end
@items_window.update_commands
end
def update_number
# Se o botão B for pressionado
if Input.trigger?(Input::B)
# Reproduzir SE de cancelamento
$game_system.se_play($data_system.cancel_se)
# Definir a janela de entrada de quantidade como inativa / invisível
@number_window.active = false
@number_window.visible = false
@uncraft_window.active = true
@uncraft_window.visible = true
@info_window.visible = true
@status_window.visible = false
return
end
# Se o botão B for pressionado
if Input.trigger?(Input::C)
# Reproduzir SE de Loja
$game_system.se_play($data_system.shop_se)
# Definir a janela de entrada de quantidade como inativa / invisível
@number_window.active = false
@number_window.visible = false
case @item
when RPG::Item
price = ItemCrafting.uncraft_price(0, @item.id)
c = ItemCrafting.components(0, @item.id)
$game_party.lose_item(@item.id, @number_window.number)
when RPG::Weapon
price = ItemCrafting.uncraft_price(1, @item.id)
c = ItemCrafting.components(1, @item.id)
$game_party.lose_weapon(@item.id, @number_window.number)
when RPG::Armor
price = ItemCrafting.uncraft_price(2, @item.id)
c = ItemCrafting.components(2, @item.id)
$game_party.lose_armor(@item.id, @number_window.number)
end
$game_party.lose_gold(@number_window.number * price)
c.each do |i|
case i[0]
when 0
$game_party.gain_item(i[1], i[2])
when 1
$game_party.gain_weapon(i[1], i[2])
when 2
$game_party.gain_armor(i[1], i[2])
end
end
# Atualizar cada janela
@gold_window.refresh
@uncraft_window.refresh
@status_window.refresh
# Mudar janelas para o modo de Venda
@uncraft_window.active = true
@uncraft_window.visible = true
@info_window.visible = true
@status_window.visible = false
return
end
end
end
Notas- A versão para Ace deve ser feita em breve, e se for pedida por alguém aqui neste tópico eu agilizo o processo.
- Não tive paciência o suficiente para comentar o script como tento fazer com meus outros, se for realmente necessário eu faço isso em uma futura versão.
- Tenho noção que a configuração ficou um pouco confusa, mas não encontrei maneira melhor de fazê-la. Caso tenham alguma sugestão ou dúvidas a respeito dela, por favor não hesite em comentar.