Bug com Itens Infinitos

10 Respostas   125 Visualizações

0 Membros e 1 Visitante estão vendo este tópico.

Float

  • *
  • Posts: 6
  • Ouros: 0
Tópico criado em: 06/09/2018 às 19:10 - Última modificação por Corvo em 07/09/2018 às 11:23

Boa noite!  :coffee:

Eu adicionei um script em meu jogo que se chama "Gambler's Forge".
Ele basicamente serve para criar uma forja, onde você sacrifica 4 itens, para criar 1 aleatório configurado no próprio script.

O problema  :facepalm:, é que quando ou usar uma poção por exemplo, que é um item consumível, ela misteriosamente pode ser usada mesmo que tenha acabado. Exemplo: Eu tenho 2 poções que recuperam 1 de HP, e tenho 10 de HP máximo. Mesmo depois que elas acabam, ainda poder ser usadas. Não ficam no menu, mas continuam a ser consumidas se ficar apertando ENTER (Ou qualquer outra tecla para uso de itens).  :hm2:

Código: [Selecionar]
# )--------------------------------------------------(
# )--     Author:     Mr Trivel                    --(
# )--     Name:       Gambler's Forge              --(
# )--     Created:    2014-06-05                   --(
# )--     Version:    1.01                         --(
# )--------------------------------------------------(
# )--     Requires:   None                         --(
# )--------------------------------------------------(
# )--    Version changes:                          --(
# )-- 1.01 - Items with <No Forge> note tag, are   --(
# )--        now not listed in the forge.          --(
# )--------------------------------------------------(
# )--             Description                      --(
# )-- Use 4 items to get 1 random item from item   --(
# )-- tables.                                      --(
# )--------------------------------------------------(
# )-- For all people who want to gamble their      --(
# )-- useless items away or want to try and get    --(
# )-- something useful can now use Gambler's       --(
# )-- Forge for that!                              --(
# )--------------------------------------------------(
# )--             Instructions                     --(
# )--  Call the Gambler's Forge scene by using:    --(
# )-- SceneManager.call(MrTS_Scene_Gamblers_Forge) --(
# )--                                              --(
# )-- If you don't want an item to be forgeable,   --(
# )-- add <No Forge> in that item's note box.      --(
# )-- <No Forge> <Noforge> <noforge> <no forge>    --(
# )--------------------------------------------------(
# )--             LICENSE INFO                     --(
# )--http://mrtrivelvx.wordpress.com/terms-of-use/ --(
# )--------------------------------------------------(

module MrTS
  module MrTS_Gambler_Forge
   
    # )-----------------------------------------------(
    # )--  Feel free to customize for your needs    --(
    # )--     2 means 2nd item in the database      --(
    # )-----------------------------------------------(
    # )--  Item rewards - what Items can player get --(
    # )-----------------------------------------------(
    ITEM_REWARDS   =  [
                      133, 134, 6, 135, 136, 137, 7, 150, 7 , 7, 138, 6, 6 , 134,
                      134, 134, 150, 158
                      ]
    # )--------------------------------------------------(
    # )-- Weapon rewards - what Weapons can player get --(
    # )--------------------------------------------------(
    WEAPON_REWARDS =  [
                      53, 53, 53
                      ]
    # )------------------------------------------------(
    # )-- Armor rewards - what Armors can player get --(
    # )------------------------------------------------(
    ARMOR_REWARDS  =  [
                      71, 71, 71, 126, 127, 128
                      ]
   
    # )---------------------------------------------(
    # )--  How long reward pop up stays on screen --(
    # )---------------------------------------------(
    POP_UP_TIME = 120 # 60 = 1 second
   
    # )----------------(
    # )--  Text list --(
    # )----------------(
    TEXT_LIST = [
                "Iniciar",
                "Ingredientes",
                "Remover Todos",
                "Sair",
                "Bem vindo a alquimia"
                ]
   
    # )----------------------------------------(
    # )--  Preferably don't edit down below  --(
    # )----------------------------------------(
                     
  end
end


# )--------------------------------------(
# )--  Class: MrTS_Scene_Mystic_Forge  --(
# )--------------------------------------(
class MrTS_Scene_Gamblers_Forge < Scene_Base
 
  # )---------------------(
  # )--  Method: start  --(
  # )---------------------(
  def start
    create_background
    create_main_viewport
    create_all_windows
    @timer_started = false
    @timer = 0
  end
 
  # )---------------------------------(
  # )--  Method: create_background  --(
  # )---------------------------------(
  def create_background
    @background_sprite = Sprite.new
    @background_sprite.bitmap = SceneManager.background_bitmap
    @background_sprite.color.set(16, 16, 16, 128)
  end
 
  # )----------------------(
  # )--  Method: update  --(
  # )----------------------(
  def update
    super
    @timer += 1 if @timer_started
    if @timer > MrTS::MrTS_Gambler_Forge::POP_UP_TIME
      @reward_window.close
      @timer_started = false
      @timer = 0
    end
  end
 
  # )-------------------------(
  # )--  Method: terminate  --(
  # )-------------------------(
  def terminate
    super
    dispose_all_windows
    dispose_background
  end
 
  # )----------------------------------(
  # )--  Method: dispose_background  --(
  # )----------------------------------(
  def dispose_background
    @background_sprite.dispose
  end
 
  # )----------------------------------(
  # )--  Method: create_all_windows  --(
  # )----------------------------------(
  def create_all_windows
    create_mystic_forge_window
    create_items_taken_window
    create_command_window
    create_item_list_window
    create_reward_window
  end
 
  # )--------------------(
  # )--  Method: item  --(
  # )--------------------(
  def item
    @item_list.item
  end
 
  # )------------------------------------------(
  # )--  Method: create_mystic_forge_window  --(
  # )------------------------------------------(
  def create_mystic_forge_window
    @welcome_window = MrTS_Mystic_Forge_Window.new
  end
 
  # )-----------------------------------------(
  # )--  Method: create_items_taken_window  --(
  # )-----------------------------------------(
  def create_items_taken_window
    @taken_window = MrTS_Items_Taken_Window.new
  end
 
  # )---------------------------------------(
  # )--  Method: create_item_list_window  --(
  # )---------------------------------------(
  def create_item_list_window
    @item_list = MrTS_Mystic_Forge_Item_List_Window.new(@command_window, @taken_window.y + @taken_window.height)
    @item_list.set_handler(:ok    , method(:item_ok))
    @item_list.set_handler(:cancel, method(:item_back))
  end
 
  # )-----------------------(
  # )--  Method: item_ok  --(
  # )-----------------------(
  def item_ok
    $game_party.last_item.object = item
    @taken_window.add_item(item)
    @item_list.activate
    @item_list.select_last
    @item_list.refresh
  end
 
  # )-------------------------(
  # )--  Method: item_back  --(
  # )-------------------------(
  def item_back
    @item_list.unselect
    @command_window.activate
  end 
 
  # )-------------------------------------(
  # )--  Method: create_command_window  --(
  # )-------------------------------------(
  def create_command_window
    @command_window = MrTS_Command_Window_MF.new
    @command_window.set_handler(:forge, method(:forge))
    @command_window.set_handler(:additem, method(:additem))
    @command_window.set_handler(:restart, method(:restart))
    @command_window.set_handler(:quit, method(:return_scene))
    @command_window.set_handler(:cancel, method(:command_back))
  end
 
  # )---------------------(
  # )--  Method: forge  --(
  # )---------------------(
  def forge
    if @taken_window.can_forge?
      @taken_window.destroy_items
      @reward_window.give_reward
      @item_list.refresh
      @timer_started = true
    end
    @command_window.activate
  end
 
  # )----------------------------(
  # )--  Method: command_back  --(
  # )----------------------------(
  def command_back
    @taken_window.return_items
    @item_list.refresh
    return_scene
  end
 
  # )-----------------------(
  # )--  Method: additem  --(
  # )-----------------------(
  def additem
    @item_list.activate
    @item_list.select_last
  end
 
  # )-----------------------(
  # )--  Method: restart  --(
  # )-----------------------(
  def restart
    @taken_window.return_items
    @command_window.activate
    @item_list.refresh
  end
 
  # )------------------------------------(
  # )--  Method: create_reward_window  --(
  # )------------------------------------(
  def create_reward_window
    @reward_window = MrTS_Mystic_Forge_Reward_Window.new
  end
 
  # )-----------------------------------(
  # )--  Method: dispose_all_windows  --(
  # )-----------------------------------(
  def dispose_all_windows
    @welcome_window.dispose
    @taken_window.dispose
    @command_window.dispose
    @item_list.dispose
    @reward_window.dispose
  end
end # End of MrTS_Scene_Mystic_Forge

# )----------------------------------------------(
# )--  Class: MrTS_Mystic_Forge_Reward_Window  --(
# )----------------------------------------------(
class MrTS_Mystic_Forge_Reward_Window < Window_Base
 
  # )--------------------------(
  # )--  Method: initialize  --(
  # )--------------------------(
  def initialize
    dw = 172 + standard_padding*2
    dh = line_height + standard_padding*2
    dx = Graphics.width/2 - dw/2
    dy = Graphics.height/2 - dh/2
    super(dx, dy, dw, dh)
    self.openness = 0
  end
 
  # )---------------------------(
  # )--  Method: give_reward  --(
  # )---------------------------(
  def give_reward
    loot_table = rand(3)
    case loot_table
    when 0
      item = $data_items[MrTS::MrTS_Gambler_Forge::ITEM_REWARDS[rand(MrTS::MrTS_Gambler_Forge::ITEM_REWARDS.size)]]
    when 1
      item = $data_weapons[MrTS::MrTS_Gambler_Forge::WEAPON_REWARDS[rand(MrTS::MrTS_Gambler_Forge::WEAPON_REWARDS.size)]] 
    when 2
      item = $data_armors[MrTS::MrTS_Gambler_Forge::ARMOR_REWARDS[rand(MrTS::MrTS_Gambler_Forge::ARMOR_REWARDS.size)]]
    end
    open
    create_contents
    draw_item_name(item, 0, 0)
    $game_party.gain_item(item, 1)
  end
end # end of MrTS_Mystic_Forge_Reward_Window

# )-------------------------------------------------(
# )--  Class: MrTS_Mystic_Forge_Item_List_Window  --(
# )-------------------------------------------------(
class MrTS_Mystic_Forge_Item_List_Window < Window_Selectable
 
  # )--------------------------(
  # )--  Method: initialize  --(
  # )--------------------------(
  def initialize (command_window, y)
    super(0, y, Graphics.width, Graphics.height - y - command_window.height)
    @data = []
    refresh
  end
 
  # )-----------------------(
  # )--  Method: col_max  --(
  # )-----------------------(
  def col_max
    return 2
  end
 
  # )------------------------(
  # )--  Method: item_max  --(
  # )------------------------(
  def item_max
    return @data ? @data.size : 1
  end
 
  # )--------------------(
  # )--  Method: item  --(
  # )--------------------(
  def item
    @data && index >= 0 ? @data[index] : nil
  end
 
  # )-----------------------(
  # )--  Method: refresh  --(
  # )-----------------------(
  def refresh
    make_data
    create_contents
    draw_all_items
  end
 
  # )---------------------------(
  # )--  Method: select_last  --(
  # )---------------------------(
  def select_last
    select(@data.index($game_party.last_item.object) || 0)
  end
 
  # )-------------------------(
  # )--  Method: make_data  --(
  # )-------------------------(
  def make_data
    @data = $game_party.all_items.select {|item| include?(item) }
    @data.push(nil) if include?(nil)
  end
 
  # )-------------------------(
  # )--  Method: draw_item  --(
  # )-------------------------(
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect(index)
      rect.width -= 4
      draw_item_name(item, rect.x, rect.y, true)
      draw_item_number(rect, item)
    end
  end
 
  # )--------------------------------(
  # )--  Method: draw_item_number  --(
  # )--------------------------------(
  def draw_item_number(rect, item)
    draw_text(rect, sprintf(":%2d", $game_party.item_number(item)), 2)
  end
 
  # )------------------------------(
  # )--  Method: can_be_listed?  --(
  # )------------------------------(
  def can_be_listed?(item)
    item.note[/(<[n-nN-N]o\s*[f-fF-F]orge>)/]
    if $1
      false
    else
      true
    end
  end
 
  # )------------------------(
  # )--  Method: include?  --(
  # )------------------------(
  def include?(item)
    if (item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor) ||
      (item.is_a?(RPG::Item) && !item.key_item?)) && can_be_listed?(item)
      true
    else
      false
    end
  end
end # end of MrTS_Mystic_Forge_Item_List_Window


# )-------------------------------------(
# )--  Class: MrTS_Command_Window_MF  --(
# )-------------------------------------(
class MrTS_Command_Window_MF < Window_HorzCommand
  # )--------------------------(
  # )--  Method: initialize  --(
  # )--------------------------(
  def initialize
    super(0, Graphics.height - line_height - standard_padding*2)
  end
 
  # )---------------------------------(
  # )--  Method: make_command_list  --(
  # )---------------------------------(
  def make_command_list
    add_command(MrTS::MrTS_Gambler_Forge::TEXT_LIST[0], :forge)
    add_command(MrTS::MrTS_Gambler_Forge::TEXT_LIST[1], :additem)
    add_command(MrTS::MrTS_Gambler_Forge::TEXT_LIST[2], :restart)
    add_command(MrTS::MrTS_Gambler_Forge::TEXT_LIST[3], :quit)
  end
 
  # )----------------------------(
  # )--  Method: window_width  --(
  # )----------------------------(
  def window_width
    Graphics.width
  end
 
  # )-----------------------(
  # )--  Method: col_max  --(
  # )-----------------------(
  def col_max
    return 4
  end
 
end # end of MrTS_Command_Window_MF


# )---------------------------------------(
# )--  Class: MrTS_Mystic_Forge_Window  --(
# )---------------------------------------(
class MrTS_Mystic_Forge_Window < Window_Base
 
  # )--------------------------(
  # )--  Method: initialize  --(
  # )--------------------------(
  def initialize
    super(0, 0, Graphics.width, line_height + standard_padding*2)
    draw_welcome_message
  end
 
  # )------------------------------------(
  # )--  Method: draw_welcome_message  --(
  # )------------------------------------(
  def draw_welcome_message
    contents.clear
    text = MrTS::MrTS_Gambler_Forge::TEXT_LIST[4]
    draw_text(contents.width/2 - text_size(text).width/2, 0, contents.width, line_height, text)
  end
end # end of MrTS_Mystic_Forge_Window


# )---------------------------------------(
# )--  Class: MrTS_Items_Taken_Window  --(
# )---------------------------------------(
class MrTS_Items_Taken_Window < Window_Base
 
  # )--------------------------(
  # )--  Method: initialize  --(
  # )--------------------------(
  def initialize
    super(0, line_height + standard_padding*2, Graphics.width, line_height*2 + standard_padding * 4)
    @item = []
    refresh
  end
 
  # )-----------------------(
  # )--  Method: refresh  --(
  # )-----------------------(
  def refresh
    contents.clear
    create_contents
    draw_items   
  end
 
  # )--------------------------(
  # )--  Method: draw_items  --(
  # )--------------------------(
  def draw_items
    item_no = 0
   
    while item_no < 4
      item = @item[item_no]
      dx = contents.width/2 * (item_no%2)
      dy = (contents.height - line_height) * (item_no/2)
      draw_icon(16, dx, dy)
      if item
        draw_item_name(item, dx, dy)
      end
      item_no += 1
    end
  end
 
  # )--------------------------(
  # )--  Method: can_forge?  --(
  # )--------------------------(
  def can_forge?
    if @item.length == 4
      true
    else
      false
    end
  end
 
  # )------------------------(
  # )--  Method: add_item  --(
  # )------------------------(
  def add_item(item)
    if item && @item.length < 4
      $game_party.lose_item(item, 1)
      @item.push(item)
      refresh
    end
  end
 
  # )-----------------------------(
  # )--  Method: destroy_items  --(
  # )-----------------------------(
  def destroy_items
    @item = []
    refresh
  end
 
  # )----------------------------(
  # )--  Method: return_items  --(
  # )----------------------------(
  def return_items
    @item.each do |it|
      $game_party.gain_item(it, 1)
    end
   
    @item = []
    refresh
  end
end # end of MrTS_Items_Taken_Window

Corvo

Resposta 1: 06/09/2018 às 19:20

Boa noite, Float.
Algumas perguntas para ajudar a sanar sua dúvida: esse script é do Ace, certo? O erro só acontece se ele estiver ativo? Há outros scripts modificando as funções dos itens no seu jogo?

Float

  • *
  • Posts: 6
  • Ouros: 0
Resposta 2: 06/09/2018 às 22:30 - Última modificação por Float em 06/09/2018 às 22:47

Boa noite, Float.
Algumas perguntas para ajudar a sanar sua dúvida: esse script é do Ace, certo? O erro só acontece se ele estiver ativo? Há outros scripts modificando as funções dos itens no seu jogo?

Sim, o script é do RPG Maker Vx Ace.
O erro acontece, simplesmente do script estar no jogo. Antes mesmo de chamá-lo.
O Script é o único que muda as funções dos itens. (Fora script de mudar a cor de nome dos itens).

Tentei a retirada de Script por script do projeto, e o resultado foi o mesmo.

Corvo

Resposta 3: 07/09/2018 às 08:21

Acontece só neste item? Talvez você tenha se esquecido de marcá-lo como 'Consumível' no database, não?

Float

  • *
  • Posts: 6
  • Ouros: 0
Resposta 4: 07/09/2018 às 08:24

Acontece só neste item? Talvez você tenha se esquecido de marcá-lo como 'Consumível' no database, não?

Acontece com todos, e a poção está marcada como consumível.  :T.T:

Corvo

Resposta 5: 07/09/2018 às 08:32

Ah, tinha deixado passar esse atalho aí. A tecla de atalho para uso dos itens é configurada por script ou por evento? No primeiro caso pode haver incompatibilidade entre os códigos e apenas a HUD está sendo atualizada. Teríamos de ver as configurações desse sistema. Já que você retirou o script que postou aqui e continuou na mesma, o problema podem ser os outros dois. Recomendo que dê uma olhada especialmente no que altera a cor dos nomes dos itens. Eles costumam ser mais bugados que o normal.

Float

  • *
  • Posts: 6
  • Ouros: 0
Resposta 6: 07/09/2018 às 08:36

Ah, tinha deixado passar esse atalho aí. A tecla de atalho para uso dos itens é configurada por script ou por evento? No primeiro caso pode haver incompatibilidade entre os códigos e apenas a HUD está sendo atualizada. Teríamos de ver as configurações desse sistema. Já que você retirou o script que postou aqui e continuou na mesma, o problema podem ser os outros dois. Recomendo que dê uma olhada especialmente no que altera a cor dos nomes dos itens. Eles costumam ser mais bugados que o normal.

Fiz um teste retirando script por script do jogo, e ele continuou a bugar, mesmo após a retirada do cor de itens.
O bug para ao retirar o Gambler.

Corvo

Resposta 7: 07/09/2018 às 08:51

Então é incompatibilidade deste com algum outro código que esteja usando, provavelmente o dos atalhos. Testei aqui e ele funciona perfeitamente quando não há outras alterações nos itens do jogo. Esse tipo de sistema é fácil de se fazer por eventos e recomendo que, o que der pra ser feito com eles, faça. Sempre que adicionamos um script corremos o risco de ele ser incompatível com outros que estejamos usando.

Agora, qual seria o script de atalhos em questão? Podemos ver se é possível corrigir a incompatibilidade, coisa que não garanto.  :sera:

Float

  • *
  • Posts: 6
  • Ouros: 0
Resposta 8: 07/09/2018 às 08:56

Então é incompatibilidade deste com algum outro código que esteja usando, provavelmente o dos atalhos. Testei aqui e ele funciona perfeitamente quando não há outras alterações nos itens do jogo. Esse tipo de sistema é fácil de se fazer por eventos e recomendo que, o que der pra ser feito com eles, faça. Sempre que adicionamos um script corremos o risco de ele ser incompatível com outros que estejamos usando.

Agora, qual seria o script de atalhos em questão? Podemos ver se é possível corrigir a incompatibilidade, coisa que não garanto.  :sera:

Não estou usando script de atalho não kkk.
E eu criei um novo projeto com este script, ele funcionou normal. Fui colocando os scripts que uso em meu jogo, e não
Ocorreram bugs. Será que a incompatibilidade dele é em algo no meu projeto?

Corvo

Resposta 9: 07/09/2018 às 09:06

[...]
Não ficam no menu, mas continuam a ser consumidas se ficar apertando ENTER (Ou qualquer outra tecla para uso de itens).  :hm2:
[...]

 :derp:
Como assim? Então não estou entendendo o problema. Onde exatamente os itens continuam a ser usados? No menu, porém sem aparecer na lista? Acontece se eles forem gastos normalmente ou apenas quando usados na forja de itens?

Sim, se você incluiu muitos scripts no jogo com certeza um ou mais deles são incompatíveis com o script de forja, seria bom ver uma lista dos que você incluiu. Para identificar compatibilidades basta observar se você incluiu mais de um código para a mesma função ou função semelhante. Por exemplo, dois scripts que alterem o menu, dois scripts que modifiquem os itens, por aí vai.

Float

  • *
  • Posts: 6
  • Ouros: 0
Resposta 10: 07/09/2018 às 11:14 - Última modificação por Float em 07/09/2018 às 11:18

[...]
Não ficam no menu, mas continuam a ser consumidas se ficar apertando ENTER (Ou qualquer outra tecla para uso de itens).  :hm2:
[...]

 :derp:
Como assim? Então não estou entendendo o problema. Onde exatamente os itens continuam a ser usados? No menu, porém sem aparecer na lista? Acontece se eles forem gastos normalmente ou apenas quando usados na forja de itens?

Sim, se você incluiu muitos scripts no jogo com certeza um ou mais deles são incompatíveis com o script de forja, seria bom ver uma lista dos que você incluiu. Para identificar compatibilidades basta observar se você incluiu mais de um código para a mesma função ou função semelhante. Por exemplo, dois scripts que alterem o menu, dois scripts que modifiquem os itens, por aí vai.

Corvo, obrigado pela ajuda! Eu encontrei o problema. Parece que este script, bugou após ser misturado com o Glamber.

#==============================================================================
# ** Alchemy System
# by: Jeneeus Guruman
#------------------------------------------------------------------------------
#  This script allows to:
#     - Create items, weapons, and armors via using skills or items with a
#     success rate based on the user's parameters, $game_variables, etc.
#
#   How to use:
#
#     * Plug-n-play
#     * Place this below default and non-aliased scripts.
#     * Only usable outside the battle. Therefore, the occasion must be set to
#     "only from the menu" or the skill/item won't work.
#     * When using an item creation SKILL, the scope must be set to "none" or
#     the skill won't work.
#     * When using an item creation ITEM, the scope must be set to either
#     "one ally" or "user" or the item won't work.
#       
#       <alchemy>
#         * Using the skill or item will activate item creation scene.
#
#     * Note: Place this notetag to the skill or item that opens the
#       alchemy scene.
#
#       <alche_ireq: type, id, amount>
#       type: the type of item
#         0 = Items ($data_items)
#         1 = Weapons ($data_weapons)
#         2 = Armors ($data_armors)
#       id: the id of an item/weapon/armor in the database
#       amount: the amount of the specified item needed to create this item
#       Notetag examples:
#         <alche_ireq: 0, 1, 2>  => An item needs to have at least 2 "Potions"
#       in the inventory to create this item.
#
#     * Note: If you put more than 1 requirement, the item can be made if ALL of
#       the items is in the party's inventory.
#
#       <alche_areq: id>
#       id: the actor that will able to exclusively create the item.
#
#     * Note: This notetag is optional. If this is not specified, all actors
#       that have the ability can create this item.
#
#       <alche_lreq: n>
#       n: the required level to create this item. the item will not be shown
#       if the level is below the requirement.
#
#     * Note: This notetag is required or the item will not be shown.
#
#       <alche_greq: n>
#       n: the required gold to create this item.
#
#     * Note: This notetag is optional. If this is not specified, no gold is
#       needed.
#
#       <success_rate: 'formula'>
#       formula: The formula for calculating the creation success rate.
#       The formula is the same as the formula in skill damage except that
#       there is no target (which is supposed to be expressed as 'b').
#       Take note that the quotations (') are included to make it work.
#       Also multiple lines of one fourmula are allowed.
#       Notetag examples:
#         <alche_success>: 'a.level + a.luk / 10'> 
#       => If the user's level is 50 having 300 LUK, the success rate will have
#       80% chance to make this item, provided that the maximum success rate is 100.
#         <alche_success: '100'> 
#       => The item has 100% chance to create this, provided that the maximum success rate is 100.
#
#     * Note: This notetag is required. To display the decimal parts, put #.0
#     (if it is a whole number) or variable.to_f (if it is a variable).
#     For example, <success_rate: 'a.level.to_f + a.luk.to_f / 10.0'>
#
#==============================================================================

module Jene
  #--------------------------------------------------------------------------
  # * BASE_SUCCESS
  #     Minimum success rate chance.
  #--------------------------------------------------------------------------
  BASE_SUCCESS = 0
  #--------------------------------------------------------------------------
  # * MAX_SUCCESS
  #     The target success rate to have sure creation. Take note that it needs
  #   to be higher than BASE_SUCCESS.
  #--------------------------------------------------------------------------
  MAX_SUCCESS = 100
  #--------------------------------------------------------------------------
  # * CREATION_TIME
  #     The time in frames that the item creation will be done.
  #   60 frames = 1 second
  #--------------------------------------------------------------------------
  CREATION_TIME = 60
  #--------------------------------------------------------------------------
  # * CREATION_NAME
  #     The text to be displayed during CREATION_TIME.
  #--------------------------------------------------------------------------
  CREATION_NAME = 'a fabricar'
  #--------------------------------------------------------------------------
  # * CREATION_FAIL_NAME
  #     The text to be displayed if failed.
  #--------------------------------------------------------------------------
  CREATION_FAIL_NAME = 'Falhou!'
  #--------------------------------------------------------------------------
  # * CREATION_SUCCESS_NAME
  #     The text to be displayed if successful.
  #--------------------------------------------------------------------------
  CREATION_SUCCESS_NAME = 'Sucesso!!!'
  #--------------------------------------------------------------------------
  # * CREATION_SOUND
  #     The ME to play while creating an item. This will not be played if the
  #   CREATION_TIME is less than 30 frames.
  #--------------------------------------------------------------------------
  CREATION_SOUND = 'Bell2'
  #--------------------------------------------------------------------------
  # * CREATION_FAIL_SOUND
  #     The ME to play if item creation fails.
  #--------------------------------------------------------------------------
  CREATION_FAIL_SOUND = 'Break'
  #--------------------------------------------------------------------------
  # * CREATION_SUCCESS_SOUND
  #     The ME to play if item creation is successful.
  #--------------------------------------------------------------------------
  CREATION_SUCCESS_SOUND = 'Item3'
 
#----------------------------------------------------------------------------
# * Do not edit anything below here. Or else, evil errors will be released
# from the other dimension of evil.
#----------------------------------------------------------------------------

  JENE_ALCHEMY = /<alchemy>/i
  ALCHE_SUCCESS_RATE = /<alche_success[:]?\s+'([\s\S]*)'>/i
  ALCHE_LEVEL_REQ = /<alche_lreq[:]?\s+(\d+)>/i
  ALCHE_GOLD_REQ = /<alche_greq[:]?\s+(\d+)>/i
  ALCHE_ACTOR_REQ = /<alche_areq[:]?\s+(\d+)>/i
  ALCHE_ITEM_REQ = /<alche_ireq[:]?\s*(\d+)\s*[,]?\s*(\d+)\s*[,]?\s*(\d+)>/i

  def self.alche_creation_se
    Audio.se_play("Audio/SE/" + CREATION_SOUND)
  end
 
  def self.alche_fail_se
    Audio.se_play("Audio/SE/" + CREATION_FAIL_SOUND)
  end
 
  def self.alche_success_se
    Audio.se_play("Audio/SE/" + CREATION_SUCCESS_SOUND)
  end
 
  def self.success_rate(f, a, v)
    [[eval(f), BASE_SUCCESS].max, MAX_SUCCESS].min rescue BASE_SUCCESS
  end
end

class RPG::Item
 
  def alche_success(actor)
    self.note.each_line { |line|
      if line =~ Jene::ALCHE_SUCCESS_RATE
        return Jene.success_rate($1, actor, $game_variables)
      end
    }
    return Jene::BASE_SUCCESS
  end
 
  def alche_ireq
    bonus_arr = []
    self.note.each_line { |line|
      if line =~ Jene::ALCHE_ITEM_REQ
        bonus_arr.push([$1.to_i, $2.to_i, $3.to_i])
      end
    }
    return bonus_arr
  end
 
  def alche_lreq
    self.note.each_line { |line|
      if line =~ Jene::ALCHE_LEVEL_REQ
        return $1.to_i
      end
    }
    return 0
  end
 
  def alche_areq
    bonus_arr = []
    self.note.each_line { |line|
      if line =~ Jene::ALCHE_ACTOR_REQ
        return bonus_arr.push($1.to_i)
      end
    }
    return bonus_arr
  end
 
  def alche_greq
    self.note.each_line { |line|
      if line =~ Jene::ALCHE_GOLD_REQ
        return $1.to_i
      end
    }
    return 0
  end
end

class RPG::EquipItem
 
  def alche_success(actor)
    self.note.each_line { |line|
      if line =~ Jene::ALCHE_SUCCESS_RATE
        return Jene.success_rate($1, actor, $game_variables)
      end
    }
    return Jene::BASE_SUCCESS
  end
 
  def alche_ireq
    bonus_arr = []
    self.note.each_line { |line|
      if line =~ Jene::ALCHE_ITEM_REQ
        bonus_arr.push([$1.to_i, $2.to_i, $3.to_i])
      end
    }
    return bonus_arr
  end
 
  def alche_lreq
    self.note.each_line { |line|
      if line =~ Jene::ALCHE_LEVEL_REQ
        return $1.to_i
      end
    }
    return 0
  end
 
  def alche_areq
    bonus_arr = []
    self.note.each_line { |line|
      if line =~ Jene::ALCHE_ACTOR_REQ
        return bonus_arr.push($1.to_i)
      end
    }
    return bonus_arr
  end
 
  def alche_greq
    self.note.each_line { |line|
      if line =~ Jene::ALCHE_GOLD_REQ
        return $1.to_i
      end
    }
    return 0
  end
end

class RPG::UsableItem
  def alchemy?
    self.note.each_line { |line|
      if line =~ Jene::JENE_ALCHEMY
        return true
      end
    }
    return false
  end
end

#==============================================================================
# ** Game_BattlerBase
#------------------------------------------------------------------------------
#  This base class handles battlers. It mainly contains methods for calculating
# parameters. It is used as a super class of the Game_Battler class.
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Determine Skill/Item Usability
  #--------------------------------------------------------------------------
  alias jene_alche_usable? usable?
  def usable?(item)
    return true if item.is_a?(RPG::UsableItem) && alche_any? && actor? && item.alchemy?
    jene_alche_usable?(item)
  end
  #--------------------------------------------------------------------------
  # * Check If Any Item Creation Exists
  #--------------------------------------------------------------------------
  def alche_any?
    items = []
    $data_items.each do |i|
      next if i == nil
      if i.alche_lreq <= level && i.alche_lreq > 0
        items.push(i)
      end
    end
    !items.empty?
  end
end

#==============================================================================
# ** Window_Gold
#------------------------------------------------------------------------------
#  This window displays the party's gold.
#==============================================================================

class Window_AlcheLoad < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    x = (Graphics.width - window_width) / 2
    y = (Graphics.height - window_height) / 2
    super(x, y, window_width, window_height)
    @text = Jene::CREATION_NAME + "..."
    @loaded = 0.0
    @start = false
    @item = nil
    @success_rate = Jene::BASE_SUCCESS
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    return Graphics.width / 2
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_height
    return fitting_height(2)
  end
  #--------------------------------------------------------------------------
  # * Check Loading
  #--------------------------------------------------------------------------
  def loading?
    @start
  end
  #--------------------------------------------------------------------------
  # * Check Loading
  #--------------------------------------------------------------------------
  def done_loading?
    !@start && @loaded > 0
  end
  #--------------------------------------------------------------------------
  # * Start Loading
  #--------------------------------------------------------------------------
  def start_loading(item)
    @loaded = 0.0
    @start = true
    @item = item
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def text=(text)
    @text = text
  end
  #--------------------------------------------------------------------------
  # * Set Success Rate
  #--------------------------------------------------------------------------
  def set_success
    @success_rate = rand(Jene::MAX_SUCCESS)
  end
  #--------------------------------------------------------------------------
  # * Get Success Rate
  #--------------------------------------------------------------------------
  def success?
    return false if @item == nil
    actor = SceneManager.scene.previous_scene.is_a?(Scene_Skill) ?
      $game_party.menu_actor : $game_party.target_actor
    @item.alche_success(actor) > @success_rate
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    update_progress if @start
  end
  #--------------------------------------------------------------------------
  # * Update Item Creation Processing
  #--------------------------------------------------------------------------
  def update_progress
    contents.clear
    pw = window_width - 24
    if @loaded >= pw
      @start = false
      set_success
      if success?
        Jene.alche_success_se
        @text = Jene::CREATION_SUCCESS_NAME
      else
        Jene.alche_fail_se
        @text = Jene::CREATION_FAIL_NAME
      end
    else
      @loaded += pw.to_f / [Jene::CREATION_TIME.to_f, 1.0].max
    end
    draw_text(4, 0, pw, line_height, @text, 1)
    rate = [@loaded / pw, 1].min
    draw_gauge(4, line_height + 4, pw, rate, system_color, normal_color)
  end
end

#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  A battler class with methods for sprites and actions added. This class
# is used as a super class of the Game_Actor class and Game_Enemy class.
#==============================================================================

class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # * Use Skill/Item
  #    Called for the acting side and applies the effect to other than the user.
  #--------------------------------------------------------------------------
  alias jene_alche_use_item use_item
  def use_item(item)
    if !SceneManager.scene_is?(Scene_Battle) && item.alchemy? && actor?
      scene = SceneManager.scene
      SceneManager.call(Scene_Alche)
      SceneManager.scene.previous_scene = scene
    end
    jene_alche_use_item(item) unless item.alchemy?
  end
end

#==============================================================================
# ** Window_Alche
#------------------------------------------------------------------------------
#  This window displays a list of buyable goods on the shop screen.
#==============================================================================

class Window_Alche < Window_Selectable
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :status_window            # Status window
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y, height, actor)
    super(x, y, window_width, height)
    @actor = actor
    @money = 0
    refresh
    select(0)
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    return 200
  end
  #--------------------------------------------------------------------------
  # * Get Number of Items
  #--------------------------------------------------------------------------
  def item_max
    @data ? @data.size : 1
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    @data[index]
  end
  #--------------------------------------------------------------------------
  # * Get Activation State of Selection Item
  #--------------------------------------------------------------------------
  def current_item_enabled?
    enable?(@data[index])
  end
  #--------------------------------------------------------------------------
  # * Get Price of Item
  #--------------------------------------------------------------------------
  def ingre_ok?(item)
    return false if item.alche_greq > $game_party.gold
    item.alche_ireq.each_with_index do |ingre, i|
      item_ingre = nil
      case ingre[0]
      when 0
        item_ingre = $data_items[ingre[1]]
      when 1
        item_ingre = $data_weapons[ingre[1]]
      when 2
        item_ingre = $data_armors[ingre[1]]
      end
      return false if item_ingre == nil
      return false if ingre[2] > $game_party.item_number(item_ingre)
    end
    return true
  end
  #--------------------------------------------------------------------------
  # * Display in Enabled State?
  #--------------------------------------------------------------------------
  def enable?(item)
    item && ingre_ok?(item) && !$game_party.item_max?(item)
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    make_item_list
    create_contents
    draw_all_items
  end
  #--------------------------------------------------------------------------
  # * Create Item List
  #--------------------------------------------------------------------------
  def make_item_list
    @data = []
    ($data_items + $data_weapons + $data_armors).each do |items|
      next if items == nil
      if items.alche_lreq <= @actor.level && items.alche_lreq > 0 &&
        (items.alche_areq.include?(@actor.id) || items.alche_areq.empty?)
        @data.push(items)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    rect = item_rect(index)
    draw_item_name(item, rect.x, rect.y, enable?(item), window_width * 3 / 4)
  end
  #--------------------------------------------------------------------------
  # * Set Status Window
  #--------------------------------------------------------------------------
  def status_window=(status_window)
    @status_window = status_window
    call_update_help
  end
  #--------------------------------------------------------------------------
  # * Update Help Text
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_item(item) if @help_window
    @status_window.item = item if @status_window
  end
end

#==============================================================================
# ** Window_GameEnd
#------------------------------------------------------------------------------
#  This window is for selecting Go to Title/Shut Down on the game over screen.
#==============================================================================

class Window_AlcheCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(y)
    super(12, y)
    self.openness = 0
    select(1)
  end
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  def make_command_list
    add_command("Sim", :make)
    add_command("Não",  :cancel)
  end
end


#==============================================================================
# ** Scene_Shop
#------------------------------------------------------------------------------
#  This class performs shop screen processing.
#==============================================================================

class Scene_Alche < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    super
    create_help_window
    create_alche_window
    create_status_window
    create_confirm_window
    create_progress_window
    activate_alche_window
  end
  #--------------------------------------------------------------------------
  # * Set Previous Scene
  #--------------------------------------------------------------------------
  def previous_scene=(scene)
    @scene = scene
  end
  #--------------------------------------------------------------------------
  # * Set Previous Scene
  #--------------------------------------------------------------------------
  def previous_scene
    @scene
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    if @progress_window.active && @progress_window.done_loading?
      on_alche_done if Input.trigger?(:C)
    end
  end
  #--------------------------------------------------------------------------
  # * Create Progress Window
  #--------------------------------------------------------------------------
  def create_progress_window
    @progress_window = Window_AlcheLoad.new
    @progress_window.viewport = @viewport
    @progress_window.hide
  end
  #--------------------------------------------------------------------------
  # * Create Status Window
  #--------------------------------------------------------------------------
  def create_status_window
    wx = @result_window.width
    wy = @help_window.y + @help_window.height
    ww = Graphics.width - wx
    wh = Graphics.height - wy
    @status_window = Window_AlcheIngre.new(wx, wy, ww, wh)
    @status_window.viewport = @viewport
    @result_window.status_window = @status_window
  end
  #--------------------------------------------------------------------------
  # * Create Status Window
  #--------------------------------------------------------------------------
  def create_confirm_window
    wy = @result_window.y + 12 + @result_window.line_height * (@result_window.index + 1)
    @confirm_window = Window_AlcheCommand.new(wy)
    @confirm_window.viewport = @viewport
    @confirm_window.set_handler(:make, method(:on_alche_confirm))
    @confirm_window.set_handler(:cancel, method(:on_alche_cancel))
  end
  #--------------------------------------------------------------------------
  # * Create Purchase Window
  #--------------------------------------------------------------------------
  def create_alche_window
    wy = @help_window.y + @help_window.height
    wh = Graphics.height - wy
    actor = @scene.is_a?(Scene_Skill) ? $game_party.menu_actor : $game_party.target_actor
    @result_window = Window_Alche.new(0, wy, wh, actor)
    @result_window.viewport = @viewport
    @result_window.help_window = @help_window
    @result_window.set_handler(:ok,     method(:on_alche_ok))
    @result_window.set_handler(:cancel, method(:return_scene))
  end
  #--------------------------------------------------------------------------
  # * Activate Purchase Window
  #--------------------------------------------------------------------------
  def activate_alche_window
    @result_window.show.activate
    @status_window.show
  end
  #--------------------------------------------------------------------------
  # * Buy [OK]
  #--------------------------------------------------------------------------
  def on_alche_ok
    @confirm_window.open
    @confirm_window.activate
    @help_window.set_text("Continuar " + Jene::CREATION_NAME + "?")
  end
  #--------------------------------------------------------------------------
  # * Activate Purchase Window
  #--------------------------------------------------------------------------
  def activate_progress_window
    @item = @result_window.item
    @progress_window.text = Jene::CREATION_NAME
    @progress_window.show.activate
    @progress_window.start_loading(@item)
  end
  #--------------------------------------------------------------------------
  # * Activate Purchase Window
  #--------------------------------------------------------------------------
  def deactivate_progress_window
    @progress_window.hide.deactivate
  end
  #--------------------------------------------------------------------------
  # * Buy [OK]
  #--------------------------------------------------------------------------
  def on_alche_confirm
    Jene.alche_creation_se if Jene::CREATION_TIME >= 30
    @confirm_window.close
    activate_progress_window
  end
  #--------------------------------------------------------------------------
  # * Buy [OK]
  #--------------------------------------------------------------------------
  def on_alche_done
    Sound.play_ok
    if @progress_window.success?
      do_make
    else
      do_consume
    end
    deactivate_progress_window
    @result_window.activate
    @status_window.show
    @result_window.refresh
    @status_window.refresh
  end
  #--------------------------------------------------------------------------
  # * Buy [OK]
  #--------------------------------------------------------------------------
  def on_alche_loaded
    @confirm_window.open
    @confirm_window.activate
  end
  #--------------------------------------------------------------------------
  # * Buy [OK]
  #--------------------------------------------------------------------------
  def on_alche_cancel
    @confirm_window.close
    @result_window.activate
  end
  #--------------------------------------------------------------------------
  # * Execute Purchase
  #--------------------------------------------------------------------------
  def do_make
    do_consume
    $game_party.gain_item(@item, 1)
  end
  #--------------------------------------------------------------------------
  # * Lose All Item Requirements
  #--------------------------------------------------------------------------
  def do_consume
    $game_party.lose_gold(@item.alche_greq)
    @item.alche_ireq.each do |ingre|
      item_ingre = nil
      case ingre[0]
      when 0
        item_ingre = $data_items[ingre[1]]
      when 1
        item_ingre = $data_weapons[ingre[1]]
      when 2
        item_ingre = $data_armors[ingre[1]]
      end
      next if item_ingre == nil
      $game_party.lose_item(item_ingre, ingre[2])
    end
  end
  #--------------------------------------------------------------------------
  # * Get Party Gold
  #--------------------------------------------------------------------------
  def money
    @gold_window.value
  end
  #--------------------------------------------------------------------------
  # Get Currency Unit
  #--------------------------------------------------------------------------
  def currency_unit
    @gold_window.currency_unit
  end
  #--------------------------------------------------------------------------
  # * Get Purchase Price
  #--------------------------------------------------------------------------
  def alche_price
    @item.alche_greq
  end
end

#==============================================================================
# ** Window_AlcheIngre
#------------------------------------------------------------------------------
#  This window displays number of items in possession and the actor's
# equipment on the shop screen.
#==============================================================================

class Window_AlcheIngre < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super(x, y, width, height)
    @item = nil
    @page_index = 0
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_success_rate(4, 0)
    draw_gold_cost(4, line_height)
    draw_ingredients(4, line_height * 2) if @item != nil
  end
  #--------------------------------------------------------------------------
  # * Set Actor
  #--------------------------------------------------------------------------
  def actor
    SceneManager.scene.previous_scene.is_a?(Scene_Skill) ?
      $game_party.menu_actor : $game_party.target_actor
  end
  #--------------------------------------------------------------------------
  # * Set Item
  #--------------------------------------------------------------------------
  def item=(item)
    @item = item
    refresh
  end
  #--------------------------------------------------------------------------
  # * Draw Quantity Possessed
  #--------------------------------------------------------------------------
  def draw_success_rate(x, y)
    rect = Rect.new(x, y, contents.width - 4 - x, line_height)
    change_color(system_color)
    draw_text(rect, "Taxa de Sucesso")
    change_color(normal_color)
    success = Jene::BASE_SUCCESS
    if @item != nil
      success = @item.alche_success(actor)
    end
    draw_text(rect, (100.0 / Jene::MAX_SUCCESS * success).to_s + "%", 2)
  end
  #--------------------------------------------------------------------------
  # * Draw Quantity Possessed
  #--------------------------------------------------------------------------
  def draw_gold_cost(x, y)
    rect = Rect.new(x, y, contents.width - 4 - x, line_height)
    alche_gold = 0
    if @item != nil
      alche_gold = @item.alche_greq
    end
    change_color(system_color)
    draw_text(rect, "Custo")
    change_color(normal_color, alche_gold <= $game_party.gold)
    draw_text(rect, $game_party.gold.to_s + Vocab::currency_unit +
      "/" + alche_gold.to_s + Vocab::currency_unit, 2)
  end
  #--------------------------------------------------------------------------
  # * Draw Equipment Information
  #--------------------------------------------------------------------------
  def draw_ingredients(x, y)
    rect = Rect.new(x, y, contents.width - 4 - x, line_height)
    change_color(system_color)
    draw_text(rect, "Ingredientes")
    if @item.alche_ireq.empty?
      rect.x += 24
      rect.y += line_height
      change_color(normal_color)
      draw_text(rect, "Nenhum")
    else
      @item.alche_ireq.each_with_index do |ingre, i|
        draw_individual_ingredients(x, y + line_height * i, ingre)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Actor Equipment Information
  #--------------------------------------------------------------------------
  def draw_individual_ingredients(x, y, ingre)
    item_ingre = nil
    case ingre[0]
    when 0
      item_ingre = $data_items[ingre[1]]
    when 1
      item_ingre = $data_weapons[ingre[1]]
    when 2
      item_ingre = $data_armors[ingre[1]]
    end
    qty_left = $game_party.item_number(item_ingre)
    change_color(normal_color, qty_left >= ingre[2])
    draw_item_name(item_ingre, x, y + line_height, qty_left >= ingre[2],
      width * 3 / 4)
    rect = Rect.new(x, y + line_height, contents.width - 4 - x, line_height)
    draw_text(rect, qty_left.to_s + "/" + ingre[2].to_s, 2)
  end
end

#==============================================================================
# ** Scene_ItemBase
#------------------------------------------------------------------------------
#  This class performs common processing for the item screen and skill screen.
#==============================================================================

class Scene_ItemBase < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Determine if Item is Usable
  #--------------------------------------------------------------------------
  alias jene_alche_item_usable? item_usable?
  def item_usable?
    return true if alche_any? && [7, 11].include?(item.scope)
    jene_alche_item_usable?
  end
  #--------------------------------------------------------------------------
  # * Check If Any Item Creation Exists
  #--------------------------------------------------------------------------
  def alche_any?
    items = []
    ($data_items + $data_weapons + $data_armors).each do |i|
      next if i == nil
      if i.alche_lreq <= user.level && i.alche_lreq > 0
        items.push(i)
      end
    end
    !items.empty?
  end
end

Vou procurar outro parecido, e que seja compatível com Glamber.  :ok: :XD: