Le Deal du moment :
Google Pixel 7 5G – Smartphone 6,3″ OLED ...
Voir le deal
316 €

Aller en bas
Nérylis
Nérylis
Membre

Nombre de messages : 615
Age : 35
Localisation : Seine Maritime
Distinction : aucune
Date d'inscription : 23/11/2014

Résolu Améliorations Script de craft

Mer 24 Juin 2015 - 21:01
Bonjour,

J'aurais besoin de plusieurs améliorations sur un script de craft que j'utilise.

Tout d'abord, une démo : http://www.mediafire.com/download/qv5fvuaat41ezgo/Test+-+Craft.exe

Voici les points que j'aimerais modifier :

- Au niveau de l'affichage des onglets, ceux-ci s'affichent lorsque j'appelle plusieurs catégories de craft. Quand j'appelle une seule catégorie, aucun onglet n'apparaît. Je ne suis pas encore sûr de ce que je vais utiliser, donc pourquoi pas mettre une ligne sur laquelle mettre true ou false. Si true, alors afficher quand même un onglet même s'il n'y a qu'une seule catégorie. Si false, ne pas mettre d'onglet.
- Toujours au niveau de l'affichage, j'ai pu remarquer que lorsqu'on atteint un certain nombre d'ingrédients, les lignes débordent de l'écran (voir la capture d'écran). Il y a 6 lignes dispos quand il y a les onglets, 8 lignes dispos quand il n'y a pas d'onglets. Serait-il possible de créer un menu déroulant pour éviter de déborder de l'écran ? Un appui sur la touche Droite pour ensuite défiler le menu des ingrédients avec les touches Haut et Bas, et un appui sur la touche Gauche pour revenir aux crafts dispos. Egalement, est-il possible de remonter un peu les icônes des niveaux requis pour les mettre au niveau des écritures (voir les flèches rouges sur ma capture d'écran) ?

Capture d'écran : https://i.servimg.com/u/f18/11/18/80/66/captur22.jpg

- Dernière chose : lorsque j'appelle une catégorie de craft, cela affiche tous les crafts configurés dans le script. Concrètement, cela veut dire que le petit forgeron de base pourra proposer, dès le début du jeu, de crafter la meilleure arme du jeu ! Serait-il possible d'ajouter dans la configuration des crafts un élément, un indice numérique par exemple, permettant de contrôler la disponibilité des crafts avec un appel de script ? Admettons qu'on mette un indice numérique de 1 pour certains crafts et lorsque j'ouvrirai le menu des crafts avec le PNJ, on pourra faire un appel de script pour dire craft dispo : (1) et cela permettra d'afficher tous les crafts possédant l'indice 1 dans la config. Pour l'appel de script avec plusieurs indices numériques, mettre (1,2,3,etc...). Tout cela permettra de contrôler à notre guise les crafts qu'on veut afficher en fonction de l'avancée dans le jeu.


Dernière édition par Nérylis le Jeu 23 Juil 2015 - 18:53, édité 1 fois
Nérylis
Nérylis
Membre

Nombre de messages : 615
Age : 35
Localisation : Seine Maritime
Distinction : aucune
Date d'inscription : 23/11/2014

Résolu Re: Améliorations Script de craft

Sam 27 Juin 2015 - 18:25
Petit up Wink
vincent26
vincent26
Membre

Nombre de messages : 766
Age : 28
Localisation : baume de transit le village paumé
Distinction : aucune
Date d'inscription : 17/08/2010

Résolu Re: Améliorations Script de craft

Dim 28 Juin 2015 - 23:33
Tient j'ai modifier directement dans le script de crafting :
Code:

#Advanced Recipe Crafting v1.0b
#----------#
#Features: Advanced Recipe crafting! Hold on tight!
#
#Usage:    Set up your recipes, learn recipes, make items! Yay!
#       $crafting_category = :craft         - call before Scene, craft is category
#       SceneManager.call(Scene_Crafting)   - opens the Crafting menu
#       SceneManager.call(Scene_CraftingAll)- opens the category Crafting menu
#       learn_recipe(id)                    - teaches that recipe
#       forget_recipe(id)                   - forgets that recipe
#
#----------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
#    given by email: sumptuaryspade@live.ca
#    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
#   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
#
#- Free to use in any project with credit given, donations always welcome!
 
module ADV_RECIPE
#Whether or not crafted items use Weapon/Armor Randomization
  USE_WA_RANDOMIZATION = false
#The names of the categories for All Crafting Menu, use :All for all recipes
  CATEGORIES = [:Alchimie,:Forgeron,:Tisserand,:Armurier]
#The icons for categories, same order as above
  CATEGORY_ICONS = [10,199,284,332,0,0,0]
#The icon for player level
  LEVEL_ICON = 117
#Xp needed for crafting level, lvl is used for current level
  XP_NEEDED_EQUATION = "100 * lvl"
#Allow the crafting of multiple items
  CRAFT_MULTIPLE = false
#Allow or disallow menu access to the crafting scene
  ENABLE_MENU_ACCESS = false
#Font Size of Detail window, smaller font size creates more room for materials
  DETAIL_FONT_SIZE = 18
 
 
#The following options disable the display of certain features. They still work
# however if declared in recipes, so edit recipes accordingly.
#Removes Gold Cost
  DISABLE_GOLD_COST = false
#Removes success rate
  DISABLE_SUCCESS = false
#Removes player level requirement
  DISABLE_PLAYER_LEVEL = false
#Removes crafting level requirement and gauge
  DISABLE_CRAFT_LEVEL = false
#Auto-learn all skills (can use forget_recipe to forget certain ones for later)
  AUTO_LEARN_RECIPES = true
 
 
#The fun (read: complicated) part!
#Recipe symbols:
#
#The crafted item, type is 0 for item, 1 for weapon, 2 for armor
# :result => [type,id,amount]
#
#The materials required, same style as result.
# :materials => [ [type,id,amount],[type,id,amount] ... ],
#
#  All the following are optional:
# :gold_cost => amount          - amount of gold to craft, can be 0
# :success => percent           - base percent chance of successful craft
# :success_gain => percent      - percent gain on success per crafting level
# :level => value               - Hero level required to craft
# :craft_level => value         - Crafting level required to craft
# :category => :category        - Crafting category (:Alchemy, :Tailor, etc)
# :multiple => false            - disallows multiple crafts
# :xp => amount                 - base Crafting xp gained per craft
# :xp_deprac => amount          - Xp lost per crafting level
# :pxp => amount                - Player xp gainer per craft
 
# Formula for xp gained is as follows and is never negative:
#  xp gain = xp - (current_level - recipe_level) * xp_deprac
 
  RECIPES = {
  0 => { :result => [0,1,1],
         :materials => [[0,4,2]],
         :gold_cost => [5,"Cuivre"],
         :success => 95,
         :success_gain => 1,
         :level => 1,
         :craft_level => 1,
         :category => :Alchimie,
         :xp => 50,
         :xp_deprac => 15,},
        
  1 => { :result => [0,2,1],
         :materials => [[0,4,1],[0,5,2]],
         :gold_cost => [50,"Argent"],
         :success => 90,
         :success_gain => 2,
         :level => 15,
         :craft_level => 1,
         :category => :Alchimie,
         :xp => 150,
         :xp_deprac => 20,},
        
  2 => { :result => [0,3,1],
         :materials => [[0,1,1],[0,2,1],[0,3,1],[0,4,1],[0,5,1],[0,6,2],[0,7,1],[0,8,1]],
         :gold_cost => [20,"Or"],
         :success => 85,
         :success_gain => 3,
         :level => 25,
         :craft_level => 1,
         :category => :Alchimie,
         :xp => 250,
         :xp_deprac => 25,},
  }
 
end
 
$crafting_category = :All
class Recipe
  attr_accessor :result
  attr_accessor :materials
  attr_accessor :known
  attr_accessor :id
  attr_accessor :gold_cost
  attr_accessor :level
  attr_accessor :category
  attr_accessor :xp
  def initialize(id,recipe_hash)
    @id = id
    @result = Material.new(recipe_hash[:result])
    @materials = []
    for item in recipe_hash[:materials]
      @materials.push(Material.new(item))
    end
    @known = false
    recipe_hash[:gold_cost] ? @gold_cost = recipe_hash[:gold_cost] : @gold_cost = 0
    recipe_hash[:success] ? @rate = recipe_hash[:success] : @rate = 100
    recipe_hash[:success_gain] ? @rated = recipe_hash[:success_gain] : @rated = 0
    recipe_hash[:level] ? @level = recipe_hash[:level] : @level = 1
    recipe_hash[:category] ? @category = recipe_hash[:category] : @category = CATEGORIES[0]
    recipe_hash[:xp] ? @xp = recipe_hash[:xp] : @xp = 0
    recipe_hash[:xp_deprac] ? @xpd = recipe_hash[:xp_deprac] : @xpd = 0
    recipe_hash[:craft_level] ? @clevel = recipe_hash[:craft_level] : @clevel = 0
    recipe_hash[:pxp] ? @pxp = recipe_hash[:pxp] : @pxp = 0
    !recipe_hash[:multiple].nil? ? @mult = recipe_hash[:multiple] : @mult = true
    @known = ADV_RECIPE::AUTO_LEARN_RECIPES
  end
  def name
    return @result.item.name
  end
  def multiple?
    @mult
  end
  def has_materials?
    for item in @materials
      return false unless $game_party.item_number(item.item) >= item.amount
    end
    return true
  end
  def has_gold?
    $game_party.gold >= @gold_cost
  end
  def has_craft_level?
    craft_level <= $game_party.craft_level_sym(@category)
  end
  def has_level?
    @level <= $game_party.highest_level && has_craft_level?
  end
  def craftable?
    has_gold? && has_materials? && has_level?
  end
  def craft_level
    @clevel
  end
  def amount_craftable?
    mat_amount = []
    for item in @materials
      mat_amount.push($game_party.item_number(item.item) / item.amount)
    end
    if @gold_cost > 0
      return [$game_party.gold / @gold_cost,mat_amount.min].min
    else
      return mat_amount.min
    end
  end
  def craft(fail = 0)
    remove_materials
    if fail < success_rate
      return add_result
    else
      return nil
    end
  end
  def remove_materials
    for item in @materials
      $game_party.gain_item(item.item,-item.amount)
    end
    $game_party.gain_gold(-@gold_cost)
  end
  def add_result
    if ADV_RECIPE::USE_WA_RANDOMIZATION
      item = $game_party.add_weapon(@result.item.id,@result.amount) if @result.item.is_a?(RPG::Weapon)
      item = $game_party.add_armor(@result.item.id,@result.amount) if @result.item.is_a?(RPG::Armor)
      item = $game_party.add_item(@result.item.id,@result.amount) if @result.item.is_a?(RPG::Item)
    else
      $game_party.gain_item(@result.item,@result.amount)
      item = @result.item
    end
    $game_party.gain_craft_exp(category_id, xp_gain)
    $game_party.members.each do |actor|
      actor.gain_exp(@pxp)
    end
    item
  end
  def category_id
    ADV_RECIPE::CATEGORIES.index(@category)
  end
  def xp_gain
    level_diff = $game_party.craft_level(category_id) - @clevel
    [@xp - @xpd * level_diff,0].max
  end
  def success_rate
    level_diff = $game_party.craft_level(category_id) - @clevel
    [@rate + @rated * level_diff,100].min
  end
end
 
class Material
  attr_accessor :item
  attr_accessor :amount
  def initialize(mat)
    @item = $data_items[mat[1]] if mat[0] == 0
    @item = $data_weapons[mat[1]] if mat[0] == 1
    @item = $data_armors[mat[1]] if mat[0] == 2
    @amount = mat[2]
  end
end
 
class Game_Party
  alias recipe_init initialize
  def initialize
    recipe_init
    @crafting_level = [1]*ADV_RECIPE::CATEGORIES.size
    @craft_exp = [0]*ADV_RECIPE::CATEGORIES.size
  end
  def craft_level(id)
    @crafting_level[id]
  end
  def craft_level_sym(sym)
    @crafting_level[ADV_RECIPE::CATEGORIES.index(sym)]
  end
  def craft_exp(id)
    @craft_exp[id]
  end
  def craft_exp_next(id)
    lvl = craft_level(id)
    return eval(ADV_RECIPE::XP_NEEDED_EQUATION)
  end
  def gain_craft_exp(id, val)
    @craft_exp[id] += val
    while craft_exp(id) >= craft_exp_next(id)
      @craft_exp[id] -= craft_exp_next(id)
      @crafting_level[id] += 1
    end
  end
end
 
module DataManager
  class << self
    alias rec_cgo create_game_objects
    alias rec_msc make_save_contents
    alias rec_esc extract_save_contents
  end
  def self.create_game_objects
    rec_cgo
    $game_recipes = create_recipes
  end
  def self.make_save_contents
    contents = rec_msc
    contents[:recipe] = $game_recipes
    contents
  end
  def self.extract_save_contents(contents)
    rec_esc(contents)
    $game_recipes = contents[:recipe]
  end
  def self.create_recipes
    recipes = {}
    ADV_RECIPE::RECIPES.each_pair do |key, val|
      recipes[key] = Recipe.new(key,val)
    end
    recipes
  end
end
 
class Game_Interpreter
  def learn_recipe(id)
    return if $game_recipes[id].nil?
    $game_recipes[id].known = true
  end
  def forget_recipe(id)
    return if $game_recipes[id].nil?
    $game_recipes[id].known = false
  end
end
 
class Window_RecipeList < Window_Selectable
  def initialize(x,y,w,h)
    super
    @data = $game_recipes.values.select {|recipe| include?(recipe)}
    refresh
  end
  def item_max
    @data ? @data.size : 1
  end
  def item
    @data && index >= 0 ? @data[index] : nil
  end
  def current_item_enabled?
    enable?(@data[index])
  end
  def include?(item)
    return false unless item.has_craft_level?
    return false unless item.known
    return true if @category == :All
    return @category == item.category
  end
  def set_category(cat)
    return if cat == @category
    @category = cat
    @data = $game_recipes.values.select {|recipe| include?(recipe)}
    refresh
  end
  def enable?(item)
    return false if item.nil?
    item.craftable?
  end
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect(index)
      rect.width -= 4
      draw_item_name(item.result.item, rect.x, rect.y, enable?(item))
      if item.amount_craftable? > 0
        draw_text(rect.x,rect.y,contents.width,24,"x"+item.amount_craftable?.to_s,2)
      end
    end
  end
  def current_item
    index >= 0 ? @data[index] : nil
  end
  def process_ok
    if current_item_enabled?
      Sound.play_ok
      Input.update
      call_ok_handler
    else
      Sound.play_buzzer
    end
  end
  def refresh
    create_contents
    super
  end
  def content_heights
    item_max * 24
  end
end
 
class Window_RecipeDetail < Window_Base
  attr_accessor :activation
  attr_accessor :need_refresh
  def initialize(x,y,w,h)
    super
    @recipe = nil
    @activation = false
    @need_refresh = true
  end
  def set_recipe(recipe)
    @recipe = recipe
    refresh
  end
  def refresh
    return unless @need_refresh
    contents.clear
    contents.font.size = ADV_RECIPE::DETAIL_FONT_SIZE
    return if @recipe.nil?
    draw_craft_level unless ADV_RECIPE::DISABLE_PLAYER_LEVEL && ADV_RECIPE::DISABLE_CRAFT_LEVEL
    draw_materials
    draw_success_rate unless ADV_RECIPE::DISABLE_SUCCESS
    draw_gold_cost unless ADV_RECIPE::DISABLE_GOLD_COST
  end
  def draw_craft_level
    change_color(system_color, @recipe.has_level?)
    draw_text(0,0,contents.width,contents.font.size,"Niveaux requis :")
    change_color(normal_color, @recipe.has_level?)
    xx = 0
    if !ADV_RECIPE::DISABLE_PLAYER_LEVEL
      draw_text(0,0,contents.width,contents.font.size,@recipe.level,2)
      draw_icon(ADV_RECIPE::LEVEL_ICON,contents.width - 48,-2)
      xx += 48
      text = @recipe.craft_level.to_s + "/"
    else
      text = @recipe.craft_level.to_s
    end
    if !ADV_RECIPE::DISABLE_CRAFT_LEVEL
      draw_text(0,0,contents.width - xx,contents.font.size,text,2)
      draw_icon(ADV_RECIPE::CATEGORY_ICONS[ADV_RECIPE::CATEGORIES.index(@recipe.category)],contents.width - 56 - xx,-4)
    end
  end
  def draw_materials
    if ADV_RECIPE::DISABLE_CRAFT_LEVEL && ADV_RECIPE::DISABLE_PLAYER_LEVEL
      y2 = 0
    else
      y2 = contents.font.size
    end
    change_color(system_color, @recipe.craftable?)
    draw_text(0,y2,self.width,contents.font.size,"Ingrédients requis :")
    y2 += contents.font.size
    yy = 0
    h = contents.font.size*@recipe.materials.length+4
    zone = Bitmap.new(contents.width,h)
    zone.font.size = ADV_RECIPE::DETAIL_FONT_SIZE
    for item in @recipe.materials
      zone.font.color.set(normal_color)
      zone.font.color.alpha = translucent_alpha unless $game_party.item_number(item.item) >= item.amount
      bitmap = Cache.system("Iconset")
      rect = Rect.new(item.item.icon_index % 16 * 24, item.item.icon_index / 16 * 24, 24, 24)
      zone.blt(0,yy, bitmap, rect, 255)
      zone.draw_text(24,yy,self.width,contents.font.size,item.item.name)
      string = $game_party.item_number(item.item).to_s + "/" + item.amount.to_s
      zone.draw_text(0,yy,self.contents.width,contents.font.size,string,2)
      yy += zone.font.size
    end
    view = Viewport.new(self.x+12,self.y+11+y2,contents.width,contents.height-y2-contents.font.size*2)
    view.z = 200
    @zone.dispose if @zone
    @zone = Sprite.new(view)
    @zone.bitmap = zone
    @need_refresh = false
  end
  def move_up
    @zone.oy = [0,@zone.oy-5].max
  end
  def move_down
    @zone.oy = [@zone.bitmap.height-@zone.viewport.rect.height,@zone.oy+5].min
  end
  def draw_success_rate
    change_color(system_color, @recipe.craftable?)
    draw_text(0,contents.height-contents.font.size,contents.width,contents.font.size,"Taux de réussite :")
    change_color(normal_color, @recipe.craftable?)
    draw_text(0,contents.height-contents.font.size,contents.width,contents.font.size,@recipe.success_rate.to_s + "%",2)
  end
  def draw_gold_cost
    if @recipe.gold_cost > 0
      change_color(system_color, @recipe.has_gold?)
      draw_text(0,contents.height-contents.font.size*2,contents.width,contents.font.size,"Coût de production :")
      change_color(normal_color, @recipe.has_gold?)
      draw_currency_value(@recipe.gold_cost,Vocab::currency_unit,0,contents.height-contents.font.size*2,contents.width)
    end  
  end
  def draw_currency_value(value, unit, x, y, width)
    cx = text_size(unit).width
    change_color(normal_color,$game_party.gold >= value)
    draw_text(x, y, width - cx - 2, contents.font.size, value, 2)
    change_color(system_color)
    draw_text(x, y, width, contents.font.size, unit, 2)
  end
end
 
class Window_RecipeConfirm < Window_Selectable
  attr_accessor :amount
  def initialize(x,y,w,h)
    super
    @amount = 1
    refresh
  end
  def item_max; 1; end;
  def enable?(item); true; end;
  def refresh
    super
    draw_text(0,0,self.contents.width,line_height,"Produire",1)
    return unless @recipe && @recipe.craftable?
    draw_text(0,0,contents.width,line_height,"x"+@amount.to_s,2)
  end
  def activate
    super
    select(0)
  end
  def deactivate
    super
    select(-1)
  end
  def set_recipe(rec)
    return if rec == @recipe
    @recipe = rec
    @amount = 1
    refresh
  end
  def cursor_movable?
    active && open? && ADV_RECIPE::CRAFT_MULTIPLE && @recipe.multiple?
  end
  def cursor_down(wrap = false)
    change_amount(-10)
  end
  def cursor_up(wrap = false)
    change_amount(10)
  end
  def cursor_right(wrap = false)
    change_amount(1)
  end
  def cursor_left(wrap = false)
    change_amount(-1)
  end
  def change_amount(val)
    Sound.play_cursor
    @amount += val
    @amount = [[@amount,1].max,@recipe.amount_craftable?].min
    refresh
  end
end
 
class Scene_CraftingAll < Scene_MenuBase
  def start
    super
    @help_window = Window_Help.new
    width = Graphics.width / 2
    height = Graphics.height - @help_window.height - 48
    @list_window = Window_RecipeList.new(0,@help_window.height+48,width,height-48)
    @list_window.set_handler(:ok, method(:list_success))
    @list_window.set_handler(:cancel, method(:cancel))
    @list_window.height += 48 if ADV_RECIPE::DISABLE_CRAFT_LEVEL
    @list_window.create_contents
    @detail_window = Window_RecipeDetail.new(width,@list_window.y,width,height-48*2)
    @detail_window.height += 48 if ADV_RECIPE::DISABLE_GOLD_COST
    @detail_window.create_contents
    height = @detail_window.y + @detail_window.height
    @confirm_window = Window_RecipeConfirm.new(width,height,width,48)
    @confirm_window.set_handler(:ok, method(:craft_success))
    @confirm_window.set_handler(:cancel, method(:confirm_cancel))
#~     if !ADV_RECIPE::DISABLE_GOLD_COST
#~       @gold_window = Window_Gold.new
#~       @gold_window.width = width
#~       @gold_window.y = Graphics.height - 48
#~       @gold_window.x = width
#~     end
    @popup_window = Window_RecPopup.new
    @popup_window.set_handler(:ok, method(:popup_ok))
    @popup_window.set_handler(:cancel, method(:popup_ok))
    @command_window = Window_RecCategory.new
    @command_window.set_handler(:ok, method(:command_ok))
    @command_window.set_handler(:cancel, method(:command_cancel))
    @gauge_window = Window_RecGauge.new unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
  end
  def popup_ok
    @popup_window.deactivate
    @popup_window.close
    @list_window.activate
  end
  def update
    super
    @help_window.set_text(@list_window.current_item.result.item.description) if !@list_window.current_item.nil?
    @detail_window.set_recipe(@list_window.current_item)
    @confirm_window.set_recipe(@list_window.current_item)
    @list_window.set_category(ADV_RECIPE::CATEGORIES[@command_window.index])
    @gauge_window.set_category(ADV_RECIPE::CATEGORIES[@command_window.index]) unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
    return unless @list_window.current_item
    if @list_window.current_item.craftable?
      @confirm_window.opacity = 255
      @confirm_window.contents_opacity = 255
    else
      @confirm_window.opacity = 75
      @confirm_window.contents_opacity = 75
    end
    if Input.trigger?(:RIGHT)
      @list_window.deactivate
      @detail_window.activation = true
    elsif Input.trigger?(:LEFT)
      @list_window.activate
      @detail_window.activation = false
    elsif Input.trigger?(:UP) && @detail_window.activation == true
      @detail_window.move_up
    elsif Input.trigger?(:DOWN) && @detail_window.activation == true
      @detail_window.move_down
    end
  end
  def list_success
    @list_window.deactivate
    @confirm_window.activate
  end
  def craft_success
    amount = 0
    item = nil
    @confirm_window.amount.times do
      item2 = @list_window.current_item.craft(rand(100))
      if item2
        amount += 1
        item = item2
      end
    end
    if item
      @popup_window.set_text(item, amount)
    else
      @popup_window.set_text_fail
    end
    @confirm_window.change_amount(-1000)
    @gold_window.refresh unless ADV_RECIPE::DISABLE_GOLD_COST
    @list_window.refresh
    @gauge_window.refresh unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
    @popup_window.activate
  end
  def confirm_cancel
    @confirm_window.deactivate
    @list_window.activate
  end
  def command_cancel
    SceneManager.return
  end
  def cancel
    @list_window.select(-1)
    @command_window.activate
  end
  def command_ok
    @list_window.select(0)
    @list_window.activate
  end
end
 
class Scene_Crafting < Scene_CraftingAll
  def start
    super
    @command_window.index = ADV_RECIPE::CATEGORIES.index($crafting_category)
    @command_window.deactivate
    @command_window.visible = false
    @list_window.height += 48
    @list_window.y -= 48
    @detail_window.height += 48
    @detail_window.y -= 48
    @list_window.create_contents
    @detail_window.create_contents
    @list_window.select(0)
    @list_window.activate
  end
  def cancel
    SceneManager.return
  end
end
 
class Window_RecCategory < Window_HorzCommand
  def initialize
    super(0,72)
  end
  def window_width; Graphics.width; end
  def window_height; 48; end
  def make_command_list
    ADV_RECIPE::CATEGORIES.each do |command|
      add_command(command.to_s,command)
    end
  end
  def item_width
    120
  end
  def draw_item(index)
    change_color(normal_color, command_enabled?(index))
    rect = item_rect_for_text(index)
    draw_text(rect, command_name(index))
    draw_icon(ADV_RECIPE::CATEGORY_ICONS[index],rect.x-24,rect.y)
  end
  def item_rect_for_text(index)
    rect = item_rect(index)
    rect.x += 28
    rect.width -= 28
    rect
  end
end
 
class Window_RecPopup < Window_Selectable
  def initialize
    super(Graphics.width/2-window_width/2,Graphics.height/2-window_height/2,120,48)
    self.openness = 0
    deactivate
  end
  def window_width; 120; end
  def window_height; 48; end
  def set_text(item, amount)
    contents.clear
    text = amount.to_s + "x " + item.name + " - Production réussie !"
    width = contents.text_size(text).width
    self.width = width + padding*2
    self.x = Graphics.width/2-width/2
    create_contents
    draw_text(24,0,contents.width,line_height,text)
    draw_icon(item.icon_index,0,0)
    open
  end
  def set_text_fail
    contents.clear
    text = "Production échouée !"
    width = contents.text_size(text).width
    self.width = width + padding*2
    self.x = Graphics.width/2-width/2
    create_contents
    draw_text(12,0,contents.width,line_height,text)
    open
  end
  def process_ok
    if current_item_enabled?
      Input.update
      deactivate
      call_ok_handler
    else
      Sound.play_buzzer
    end
  end
end
 
class Window_RecGauge < Window_Base
  def initialize
    super(0,Graphics.height-48,Graphics.width/2,48)
    @category = :All
  end
  def refresh
    contents.clear
    return if @category == :All
    draw_icon(ADV_RECIPE::CATEGORY_ICONS[cat_index],0,0)
    draw_text(24,0,contents.width,24,$game_party.craft_level(cat_index))
    rate = $game_party.craft_exp(cat_index).to_f / $game_party.craft_exp_next(cat_index)
    draw_gauge(48, -3, contents.width-48, rate, tp_gauge_color1, tp_gauge_color2)
    if Module.const_defined?(:SPECIAL_GAUGES)
      @gauges[[48,-3]].set_extra("XP",$game_party.craft_exp(cat_index),$game_party.craft_exp_next(cat_index))
    else
      text = $game_party.craft_exp(cat_index).to_s+"/"+$game_party.craft_exp_next(cat_index).to_s
      draw_text(0,0,contents.width,24,text,2)
    end
  end
  def set_category(cat)
    return if cat == @category
    @category = cat
    refresh
  end
  def cat_index
    ADV_RECIPE::CATEGORIES.index(@category)
  end
end
 
class Window_MenuCommand < Window_Command
  alias recipe_aoc add_original_commands
  def add_original_commands
    recipe_aoc
    add_command("Crafting", :recipe) if ADV_RECIPE::ENABLE_MENU_ACCESS
  end
end
 
class Scene_Menu < Scene_MenuBase
  alias recipe_create_command_window create_command_window
  def create_command_window
    recipe_create_command_window
    @command_window.set_handler(:recipe,   method(:command_recipe))
  end
  def command_recipe
    SceneManager.call(Scene_CraftingAll)
  end
end
Et voici pour la modif de zouzaka (remodifier du coup ^^)
Code:

$crafting_category = [:All]
module ADV_RECIPE
  @actual_cat = $crafting_category[0]
  def self.actual_cat=(i) ; @actual_cat = i ; end
  def self.actual_cat ; @actual_cat ; end
end
class Scene_CraftingAll
  alias :old_cancel :cancel
  def cancel
    @help_window.clear
    old_cancel
  end
  def update
    super
    @help_window.set_text(@list_window.current_item.result.item.description) if !@list_window.current_item.nil?
    @detail_window.set_recipe(@list_window.current_item)
    @confirm_window.set_recipe(@list_window.current_item)
    @list_window.set_category(ADV_RECIPE::CATEGORIES[@command_window.index])
    @gauge_window.set_category(ADV_RECIPE::CATEGORIES[@command_window.index]) unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
    return unless @list_window.current_item
    if Input.trigger?(:RIGHT)
      @list_window.deactivate
      @detail_window.activation = true
    elsif Input.trigger?(:LEFT)
      @list_window.activate
      @detail_window.activation = false
    elsif Input.repeat?(:UP)
      if @detail_window.activation == true
        @detail_window.move_up
      else
        @detail_window.need_refresh = true
      end
    elsif Input.repeat?(:DOWN)
      if @detail_window.activation == true
        @detail_window.move_down
      else
        @detail_window.need_refresh = true
      end
    end
  end
end
class Scene_Crafting
  def start
    super
    if $crafting_category.length == 1 ; alternative_start ; end
  end
  def alternative_start
    @command_window.index = ADV_RECIPE::CATEGORIES.index($crafting_category[0])
    @command_window.deactivate
    @command_window.visible = false
    @list_window.height += 48
    @list_window.y -= 48
    @detail_window.height += 48
    @detail_window.y -= 48
    @list_window.create_contents
    @detail_window.create_contents
    @list_window.select(0)
    @list_window.activate
  end
  def cancel
    if $crafting_category.length == 1 ; SceneManager.return
    else
      @list_window.select(-1)
      @command_window.activate
      @help_window.clear
    end
  end
  def update
    super
    if $crafting_category.size > 1
      @list_window.set_category($crafting_category[@command_window.index])
    else
      @list_window.set_category($crafting_category[0])
    end
  end
end
class Window_RecCategory
  def make_command_list
    if SceneManager.scene_is?(Scene_CraftingAll)
      ADV_RECIPE::CATEGORIES.each{|command| add_command(command.to_s,command)}
    else
      $crafting_category.each{|command| add_command(command.to_s,command)}
    end
  end
  def draw_item(index)
    change_color(normal_color, command_enabled?(index))
    rect = item_rect_for_text(index)
    draw_text(rect, command_name(index))
    if SceneManager.scene_is?(Scene_CraftingAll)
      draw_icon(ADV_RECIPE::CATEGORY_ICONS[index],rect.x-24,rect.y)
    else
      draw_icon(ADV_RECIPE::CATEGORY_ICONS[ADV_RECIPE::CATEGORIES.index($crafting_category[index])],rect.x-24,rect.y)
    end
  end
  alias :old_update :update
  def update
    old_update
    ADV_RECIPE.actual_cat = $crafting_category[index]
  end
end
class Game_Party
  def craft_level(id)
    if id.class == Symbol
      @crafting_level[ADV_RECIPE::CATEGORIES.index(id)]
    else
      @crafting_level[id]
    end
  end
end
class Window_RecipeConfirm
  def refresh
    super
    if @recipe && @recipe.craftable?
      change_color(normal_color, true)
      draw_text(0,0,self.contents.width,line_height,"Produire",1)
      draw_text(0,0,contents.width,line_height,"x"+@amount.to_s,2)
    else
      change_color(normal_color, false)
      draw_text(0,0,self.contents.width,line_height,"Produire",1)
    end
  end
end
class Window_RecGauge
  def cat_index
    if SceneManager.scene_is?(Scene_CraftingAll) or ADV_RECIPE.actual_cat == nil
      ADV_RECIPE::CATEGORIES.index(@category)
    else
      p(ADV_RECIPE.actual_cat)
      ADV_RECIPE::CATEGORIES.index(ADV_RECIPE.actual_cat)
    end
  end
end

Pour changer la vitesse de scrolling :
Ligne 441 et 444 remplace le 5 par la valeur voulu (c'est le nbr de pixel par frame)
Nérylis
Nérylis
Membre

Nombre de messages : 615
Age : 35
Localisation : Seine Maritime
Distinction : aucune
Date d'inscription : 23/11/2014

Résolu Re: Améliorations Script de craft

Mar 30 Juin 2015 - 20:16
Pour l'affichage des icônes, c'est bon. Pour le menu défilant, y a deux choses qui me chagrinent. Quand il y a moins de 6 ingrédients, serait-il possible d'empêcher la possibilité d'aller dans le menu défilant ? Parce qu'après, ça se place mal. Et aussi, quand on quitte le menu craft, les écritures restent affichées une fraction de seconde avant de disparaître.

Tu n'as pas fait les autres points, l'histoire des onglets et la disponibilité des crafts ?
vincent26
vincent26
Membre

Nombre de messages : 766
Age : 28
Localisation : baume de transit le village paumé
Distinction : aucune
Date d'inscription : 17/08/2010

Résolu Re: Améliorations Script de craft

Sam 4 Juil 2015 - 0:16
Salut Smile

Pour l'histoire d'onglet pour afficher l'onglet dans tout les cas tu met les ligne suivante du script de Zouzaka en commentaire :
45,61,62,66

Je regarde pour la disponibilité des craft Wink

EDIT :
Dans le début du script :
AUTO_LEARN_RECIPES = true
met false

ensuite en jeu utilise ces appel de script :
learn_recipe(id)
et
forget_recipe(id)

pour ajouter ou enlever des recettes connue

sinon comme expliquer tu laisse
AUTO_LEARN_RECIPES sur true
comme ça toute les recettes sont connue
et tu enlève celle que tu ne veut pas que le héros connaisse dès le début

après si tu veut un truc plus complexe comme tu l'expliquer hésite pas a demander
Nérylis
Nérylis
Membre

Nombre de messages : 615
Age : 35
Localisation : Seine Maritime
Distinction : aucune
Date d'inscription : 23/11/2014

Résolu Re: Améliorations Script de craft

Sam 4 Juil 2015 - 10:17
Pour les onglets, ça marche. je me déciderai plus tard si je fais comme ça ou pas.

Pour la disponibilité des crafts, effectivement, j'avais zappé cette méthode. Par contre, je n'arrive pas à savoir si on peut écrire par exemple learn_recipe(0;1;3;7) par exemple pour ajouter ces recettes. J'ai des erreurs de syntaxe à chaque fois et je ne sais pas si c'est possible. Là j'ai fais une ligne par recette en appel de script et c'est pas le top. Si tu peux m'éclairer à ce sujet. Si c'est possible à faire, je testerai en simulant un cas concret et je regarderai si ça me convient.

Pour en revenir à ce point-là :

Pour l'affichage des icônes, c'est bon. Pour le menu défilant, y a deux choses qui me chagrinent. Quand il y a moins de 6 ingrédients, serait-il possible d'empêcher la possibilité d'aller dans le menu défilant ? Parce qu'après, ça se place mal. Et aussi, quand on quitte le menu craft, les écritures restent affichées une fraction de seconde avant de disparaître.

Je parlais de moins de 6 ingrédients, c'est quand il y a les onglets. Dans le cas où je ne les fais pas apparaître, c'est 8 ingrédients. Je ne sais pas si tu peux prendre en compte ces deux cas différents.
vincent26
vincent26
Membre

Nombre de messages : 766
Age : 28
Localisation : baume de transit le village paumé
Distinction : aucune
Date d'inscription : 17/08/2010

Résolu Re: Améliorations Script de craft

Sam 4 Juil 2015 - 11:06
oui en faites je l'ai fait mais j'ai pas eu le temps de te le fournir hier soir ^^
j'ai aussi fait le system que tu avait dit avec les list de recette a afficher
tu peut assigner les recettes a un index comme tu m'a dit et appeler uniquement les recettes qui ont cette index :
Code:

#Advanced Recipe Crafting v1.0b
#----------#
#Features: Advanced Recipe crafting! Hold on tight!
#
#Usage:    Set up your recipes, learn recipes, make items! Yay!
#      $crafting_category = :craft        - call before Scene, craft is category
#      $crafting_list = list              - A appeler avant la scene. list est tableaux d'id des list de recette a afficher
#      SceneManager.call(Scene_Crafting)  - opens the Crafting menu
#      SceneManager.call(Scene_CraftingAll)- opens the category Crafting menu
#      learn_recipe(id)                    - teaches that recipe
#      forget_recipe(id)                  - forgets that recipe
#
#----------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
#    given by email: sumptuaryspade@live.ca
#    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
#  All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
#
#- Free to use in any project with credit given, donations always welcome!
 
module ADV_RECIPE
#Whether or not crafted items use Weapon/Armor Randomization
  USE_WA_RANDOMIZATION = false
#The names of the categories for All Crafting Menu, use :All for all recipes
  CATEGORIES = [:Alchimie,:Forgeron,:Tisserand,:Armurier]
#The icons for categories, same order as above
  CATEGORY_ICONS = [10,199,284,332,0,0,0]
#The icon for player level
  LEVEL_ICON = 117
#Xp needed for crafting level, lvl is used for current level
  XP_NEEDED_EQUATION = "100 * lvl"
#Allow the crafting of multiple items
  CRAFT_MULTIPLE = false
#Allow or disallow menu access to the crafting scene
  ENABLE_MENU_ACCESS = false
#Font Size of Detail window, smaller font size creates more room for materials
  DETAIL_FONT_SIZE = 18
 
 
#The following options disable the display of certain features. They still work
# however if declared in recipes, so edit recipes accordingly.
#Removes Gold Cost
  DISABLE_GOLD_COST = false
#Removes success rate
  DISABLE_SUCCESS = false
#Removes player level requirement
  DISABLE_PLAYER_LEVEL = false
#Removes crafting level requirement and gauge
  DISABLE_CRAFT_LEVEL = false
#Auto-learn all skills (can use forget_recipe to forget certain ones for later)
  AUTO_LEARN_RECIPES = true
 
 
#The fun (read: complicated) part!
#Recipe symbols:
#
#The crafted item, type is 0 for item, 1 for weapon, 2 for armor
# :result => [type,id,amount]
#
#The materials required, same style as result.
# :materials => [ [type,id,amount],[type,id,amount] ... ],
#
#  All the following are optional:
# :gold_cost => amount          - amount of gold to craft, can be 0
# :success => percent          - base percent chance of successful craft
# :success_gain => percent      - percent gain on success per crafting level
# :level => value              - Hero level required to craft
# :craft_level => value        - Crafting level required to craft
# :category => :category        - Crafting category (:Alchemy, :Tailor, etc)
# :multiple => false            - disallows multiple crafts
# :xp => amount                - base Crafting xp gained per craft
# :xp_deprac => amount          - Xp lost per crafting level
# :pxp => amount                - Player xp gainer per craft
# :list => array                - Tableaux des liste de recette auquel appartient celle-ci
 
# Formula for xp gained is as follows and is never negative:
#  xp gain = xp - (current_level - recipe_level) * xp_deprac
 
  RECIPES = {
  0 => { :result => [0,1,1],
        :materials => [[0,4,2]],
        :gold_cost => [5,"Cuivre"],
        :success => 95,
        :success_gain => 1,
        :level => 1,
        :craft_level => 1,
        :category => :Alchimie,
        :xp => 50,
        :xp_deprac => 15,
        :list => [1]},
       
  1 => { :result => [0,2,1],
        :materials => [[0,4,1],[0,5,2]],
        :gold_cost => [50,"Argent"],
        :success => 90,
        :success_gain => 2,
        :level => 15,
        :craft_level => 1,
        :category => :Alchimie,
        :xp => 150,
        :xp_deprac => 20,
        :list => [2]},
       
  2 => { :result => [0,3,1],
        :materials => [[0,1,1],[0,2,1],[0,3,1],[0,4,1],[0,5,1],[0,6,2],[0,7,1],[0,8,1]],
        :gold_cost => [20,"Or"],
        :success => 85,
        :success_gain => 3,
        :level => 25,
        :craft_level => 1,
        :category => :Alchimie,
        :xp => 250,
        :xp_deprac => 25,
        :list => [2,3]},
  }
 
end
 
$crafting_category = :All
$crafting_list = :All
class Recipe
  attr_accessor :result
  attr_accessor :materials
  attr_accessor :known
  attr_accessor :id
  attr_accessor :gold_cost
  attr_accessor :level
  attr_accessor :category
  attr_accessor :xp
  attr_accessor :list
  def initialize(id,recipe_hash)
    @id = id
    @result = Material.new(recipe_hash[:result])
    @materials = []
    for item in recipe_hash[:materials]
      @materials.push(Material.new(item))
    end
    @known = false
    recipe_hash[:gold_cost] ? @gold_cost = recipe_hash[:gold_cost] : @gold_cost = 0
    recipe_hash[:success] ? @rate = recipe_hash[:success] : @rate = 100
    recipe_hash[:success_gain] ? @rated = recipe_hash[:success_gain] : @rated = 0
    recipe_hash[:level] ? @level = recipe_hash[:level] : @level = 1
    recipe_hash[:category] ? @category = recipe_hash[:category] : @category = CATEGORIES[0]
    recipe_hash[:xp] ? @xp = recipe_hash[:xp] : @xp = 0
    recipe_hash[:xp_deprac] ? @xpd = recipe_hash[:xp_deprac] : @xpd = 0
    recipe_hash[:craft_level] ? @clevel = recipe_hash[:craft_level] : @clevel = 0
    recipe_hash[:pxp] ? @pxp = recipe_hash[:pxp] : @pxp = 0
    recipe_hash[:list] ? @list = recipe_hash[:list] : @list = []
    !recipe_hash[:multiple].nil? ? @mult = recipe_hash[:multiple] : @mult = true
    @known = ADV_RECIPE::AUTO_LEARN_RECIPES
  end
  def name
    return @result.item.name
  end
  def multiple?
    @mult
  end
  def has_materials?
    for item in @materials
      return false unless $game_party.item_number(item.item) >= item.amount
    end
    return true
  end
  def has_gold?
    $game_party.gold >= @gold_cost
  end
  def has_craft_level?
    craft_level <= $game_party.craft_level_sym(@category)
  end
  def has_level?
    @level <= $game_party.highest_level && has_craft_level?
  end
  def craftable?
    has_gold? && has_materials? && has_level?
  end
  def craft_level
    @clevel
  end
  def amount_craftable?
    mat_amount = []
    for item in @materials
      mat_amount.push($game_party.item_number(item.item) / item.amount)
    end
    if @gold_cost > 0
      return [$game_party.gold / @gold_cost,mat_amount.min].min
    else
      return mat_amount.min
    end
  end
  def craft(fail = 0)
    remove_materials
    if fail < success_rate
      return add_result
    else
      return nil
    end
  end
  def remove_materials
    for item in @materials
      $game_party.gain_item(item.item,-item.amount)
    end
    $game_party.gain_gold(-@gold_cost)
  end
  def add_result
    if ADV_RECIPE::USE_WA_RANDOMIZATION
      item = $game_party.add_weapon(@result.item.id,@result.amount) if @result.item.is_a?(RPG::Weapon)
      item = $game_party.add_armor(@result.item.id,@result.amount) if @result.item.is_a?(RPG::Armor)
      item = $game_party.add_item(@result.item.id,@result.amount) if @result.item.is_a?(RPG::Item)
    else
      $game_party.gain_item(@result.item,@result.amount)
      item = @result.item
    end
    $game_party.gain_craft_exp(category_id, xp_gain)
    $game_party.members.each do |actor|
      actor.gain_exp(@pxp)
    end
    item
  end
  def category_id
    ADV_RECIPE::CATEGORIES.index(@category)
  end
  def xp_gain
    level_diff = $game_party.craft_level(category_id) - @clevel
    [@xp - @xpd * level_diff,0].max
  end
  def success_rate
    level_diff = $game_party.craft_level(category_id) - @clevel
    [@rate + @rated * level_diff,100].min
  end
end
 
class Material
  attr_accessor :item
  attr_accessor :amount
  def initialize(mat)
    @item = $data_items[mat[1]] if mat[0] == 0
    @item = $data_weapons[mat[1]] if mat[0] == 1
    @item = $data_armors[mat[1]] if mat[0] == 2
    @amount = mat[2]
  end
end
 
class Game_Party
  alias recipe_init initialize
  def initialize
    recipe_init
    @crafting_level = [1]*ADV_RECIPE::CATEGORIES.size
    @craft_exp = [0]*ADV_RECIPE::CATEGORIES.size
  end
  def craft_level(id)
    @crafting_level[id]
  end
  def craft_level_sym(sym)
    @crafting_level[ADV_RECIPE::CATEGORIES.index(sym)]
  end
  def craft_exp(id)
    @craft_exp[id]
  end
  def craft_exp_next(id)
    lvl = craft_level(id)
    return eval(ADV_RECIPE::XP_NEEDED_EQUATION)
  end
  def gain_craft_exp(id, val)
    @craft_exp[id] += val
    while craft_exp(id) >= craft_exp_next(id)
      @craft_exp[id] -= craft_exp_next(id)
      @crafting_level[id] += 1
    end
  end
end
 
module DataManager
  class << self
    alias rec_cgo create_game_objects
    alias rec_msc make_save_contents
    alias rec_esc extract_save_contents
  end
  def self.create_game_objects
    rec_cgo
    $game_recipes = create_recipes
  end
  def self.make_save_contents
    contents = rec_msc
    contents[:recipe] = $game_recipes
    contents
  end
  def self.extract_save_contents(contents)
    rec_esc(contents)
    $game_recipes = contents[:recipe]
  end
  def self.create_recipes
    recipes = {}
    ADV_RECIPE::RECIPES.each_pair do |key, val|
      recipes[key] = Recipe.new(key,val)
    end
    recipes
  end
end
 
class Game_Interpreter
  def learn_recipe(id)
    return if $game_recipes[id].nil?
    $game_recipes[id].known = true
  end
  def forget_recipe(id)
    return if $game_recipes[id].nil?
    $game_recipes[id].known = false
  end
end
 
class Window_RecipeList < Window_Selectable
  def initialize(x,y,w,h)
    super
    @data = $game_recipes.values.select {|recipe| include?(recipe)}
    refresh
  end
  def item_max
    @data ? @data.size : 1
  end
  def item
    @data && index >= 0 ? @data[index] : nil
  end
  def current_item_enabled?
    enable?(@data[index])
  end
  def include?(item)
    return false unless item.has_craft_level?
    return false unless item.known
    return true if @category == :All
    return @category == item.category if $crafting_list == :All
    ok = false
    for i in $crafting_list
      for j in item.list
        ok = true if i == j 
      end
    end
    return false unless ok
    return @category == item.category
  end
  def set_category(cat)
    return if cat == @category
    @category = cat
    @data = $game_recipes.values.select {|recipe| include?(recipe)}
    refresh
  end
  def enable?(item)
    return false if item.nil?
    item.craftable?
  end
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect(index)
      rect.width -= 4
      draw_item_name(item.result.item, rect.x, rect.y, enable?(item))
      if item.amount_craftable? > 0
        draw_text(rect.x,rect.y,contents.width,24,"x"+item.amount_craftable?.to_s,2)
      end
    end
  end
  def current_item
    index >= 0 ? @data[index] : nil
  end
  def process_ok
    if current_item_enabled?
      Sound.play_ok
      Input.update
      call_ok_handler
    else
      Sound.play_buzzer
    end
  end
  def refresh
    create_contents
    super
  end
  def content_heights
    item_max * 24
  end
end
 
class Window_RecipeDetail < Window_Base
  attr_accessor :activation
  attr_accessor :need_refresh
  attr_accessor :can_change
  def initialize(x,y,w,h)
    super
    @recipe = nil
    @activation = false
    @need_refresh = true
    @can_change = false
  end
  def set_recipe(recipe)
    @recipe = recipe
    refresh
  end
  def dispose
    super
    @zone.dispose if @zone
  end
  def refresh
    return unless @need_refresh
    contents.clear
    contents.font.size = ADV_RECIPE::DETAIL_FONT_SIZE
    return if @recipe.nil?
    draw_craft_level unless ADV_RECIPE::DISABLE_PLAYER_LEVEL && ADV_RECIPE::DISABLE_CRAFT_LEVEL
    draw_materials
    draw_success_rate unless ADV_RECIPE::DISABLE_SUCCESS
    draw_gold_cost unless ADV_RECIPE::DISABLE_GOLD_COST
  end
  def draw_craft_level
    change_color(system_color, @recipe.has_level?)
    draw_text(0,0,contents.width,contents.font.size,"Niveaux requis :")
    change_color(normal_color, @recipe.has_level?)
    xx = 0
    if !ADV_RECIPE::DISABLE_PLAYER_LEVEL
      draw_text(0,0,contents.width,contents.font.size,@recipe.level,2)
      draw_icon(ADV_RECIPE::LEVEL_ICON,contents.width - 48,-2)
      xx += 48
      text = @recipe.craft_level.to_s + "/"
    else
      text = @recipe.craft_level.to_s
    end
    if !ADV_RECIPE::DISABLE_CRAFT_LEVEL
      draw_text(0,0,contents.width - xx,contents.font.size,text,2)
      draw_icon(ADV_RECIPE::CATEGORY_ICONS[ADV_RECIPE::CATEGORIES.index(@recipe.category)],contents.width - 56 - xx,-4)
    end
  end
  def draw_materials
    if ADV_RECIPE::DISABLE_CRAFT_LEVEL && ADV_RECIPE::DISABLE_PLAYER_LEVEL
      y2 = 0
    else
      y2 = contents.font.size
    end
    change_color(system_color, @recipe.craftable?)
    draw_text(0,y2,self.width,contents.font.size,"Ingrédients requis :")
    y2 += contents.font.size
    yy = 0
    h = contents.font.size*@recipe.materials.length+4
    zone = Bitmap.new(contents.width,h)
    zone.font.size = ADV_RECIPE::DETAIL_FONT_SIZE
    for item in @recipe.materials
      zone.font.color.set(normal_color)
      zone.font.color.alpha = translucent_alpha unless $game_party.item_number(item.item) >= item.amount
      bitmap = Cache.system("Iconset")
      rect = Rect.new(item.item.icon_index % 16 * 24, item.item.icon_index / 16 * 24, 24, 24)
      zone.blt(0,yy, bitmap, rect, 255)
      zone.draw_text(24,yy,self.width,contents.font.size,item.item.name)
      string = $game_party.item_number(item.item).to_s + "/" + item.amount.to_s
      zone.draw_text(0,yy,self.contents.width,contents.font.size,string,2)
      yy += zone.font.size
    end
    @can_change = false
    @can_change = true if yy > contents.height-y2-contents.font.size*2
    view = Viewport.new(self.x+12,self.y+11+y2,contents.width,contents.height-y2-contents.font.size*2)
    view.z = 200
    @zone.dispose if @zone
    @zone = Sprite.new(view)
    @zone.bitmap = zone
    @need_refresh = false
  end
  def move_up
    @zone.oy = [0,@zone.oy-5].max
  end
  def move_down
    @zone.oy = [@zone.bitmap.height-@zone.viewport.rect.height,@zone.oy+5].min
  end
  def draw_success_rate
    change_color(system_color, @recipe.craftable?)
    draw_text(0,contents.height-contents.font.size,contents.width,contents.font.size,"Taux de réussite :")
    change_color(normal_color, @recipe.craftable?)
    draw_text(0,contents.height-contents.font.size,contents.width,contents.font.size,@recipe.success_rate.to_s + "%",2)
  end
  def draw_gold_cost
    if @recipe.gold_cost > 0
      change_color(system_color, @recipe.has_gold?)
      draw_text(0,contents.height-contents.font.size*2,contents.width,contents.font.size,"Coût de production :")
      change_color(normal_color, @recipe.has_gold?)
      draw_currency_value(@recipe.gold_cost,Vocab::currency_unit,0,contents.height-contents.font.size*2,contents.width)
    end 
  end
  def draw_currency_value(value, unit, x, y, width)
    cx = text_size(unit).width
    change_color(normal_color,$game_party.gold >= value)
    draw_text(x, y, width - cx - 2, contents.font.size, value, 2)
    change_color(system_color)
    draw_text(x, y, width, contents.font.size, unit, 2)
  end
end
 
class Window_RecipeConfirm < Window_Selectable
  attr_accessor :amount
  def initialize(x,y,w,h)
    super
    @amount = 1
    refresh
  end
  def item_max; 1; end;
  def enable?(item); true; end;
  def refresh
    super
    draw_text(0,0,self.contents.width,line_height,"Produire",1)
    return unless @recipe && @recipe.craftable?
    draw_text(0,0,contents.width,line_height,"x"+@amount.to_s,2)
  end
  def activate
    super
    select(0)
  end
  def deactivate
    super
    select(-1)
  end
  def set_recipe(rec)
    return if rec == @recipe
    @recipe = rec
    @amount = 1
    refresh
  end
  def cursor_movable?
    active && open? && ADV_RECIPE::CRAFT_MULTIPLE && @recipe.multiple?
  end
  def cursor_down(wrap = false)
    change_amount(-10)
  end
  def cursor_up(wrap = false)
    change_amount(10)
  end
  def cursor_right(wrap = false)
    change_amount(1)
  end
  def cursor_left(wrap = false)
    change_amount(-1)
  end
  def change_amount(val)
    Sound.play_cursor
    @amount += val
    @amount = [[@amount,1].max,@recipe.amount_craftable?].min
    refresh
  end
end
 
class Scene_CraftingAll < Scene_MenuBase
  def start
    super
    @help_window = Window_Help.new
    width = Graphics.width / 2
    height = Graphics.height - @help_window.height - 48
    @list_window = Window_RecipeList.new(0,@help_window.height+48,width,height-48)
    @list_window.set_handler(:ok, method(:list_success))
    @list_window.set_handler(:cancel, method(:cancel))
    @list_window.height += 48 if ADV_RECIPE::DISABLE_CRAFT_LEVEL
    @list_window.create_contents
    @detail_window = Window_RecipeDetail.new(width,@list_window.y,width,height-48*2)
    @detail_window.height += 48 if ADV_RECIPE::DISABLE_GOLD_COST
    @detail_window.create_contents
    height = @detail_window.y + @detail_window.height
    @confirm_window = Window_RecipeConfirm.new(width,height,width,48)
    @confirm_window.set_handler(:ok, method(:craft_success))
    @confirm_window.set_handler(:cancel, method(:confirm_cancel))
#~    if !ADV_RECIPE::DISABLE_GOLD_COST
#~      @gold_window = Window_Gold.new
#~      @gold_window.width = width
#~      @gold_window.y = Graphics.height - 48
#~      @gold_window.x = width
#~    end
    @popup_window = Window_RecPopup.new
    @popup_window.set_handler(:ok, method(:popup_ok))
    @popup_window.set_handler(:cancel, method(:popup_ok))
    @command_window = Window_RecCategory.new
    @command_window.set_handler(:ok, method(:command_ok))
    @command_window.set_handler(:cancel, method(:command_cancel))
    @gauge_window = Window_RecGauge.new unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
  end
  def popup_ok
    @popup_window.deactivate
    @popup_window.close
    @list_window.activate
  end
  def update
    super
    @help_window.set_text(@list_window.current_item.result.item.description) if !@list_window.current_item.nil?
    @detail_window.set_recipe(@list_window.current_item)
    @confirm_window.set_recipe(@list_window.current_item)
    @list_window.set_category(ADV_RECIPE::CATEGORIES[@command_window.index])
    @gauge_window.set_category(ADV_RECIPE::CATEGORIES[@command_window.index]) unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
    return unless @list_window.current_item
    if @list_window.current_item.craftable?
      @confirm_window.opacity = 255
      @confirm_window.contents_opacity = 255
    else
      @confirm_window.opacity = 75
      @confirm_window.contents_opacity = 75
    end
    if Input.trigger?(:RIGHT) && @detail_window.can_change
      @list_window.deactivate
      @detail_window.activation = true
    elsif Input.trigger?(:LEFT) && @detail_window.can_change
      @list_window.activate
      @detail_window.activation = false
    elsif Input.trigger?(:UP) && @detail_window.activation == true
      @detail_window.move_up
    elsif Input.trigger?(:DOWN) && @detail_window.activation == true
      @detail_window.move_down
    end
  end
  def list_success
    @list_window.deactivate
    @confirm_window.activate
  end
  def craft_success
    amount = 0
    item = nil
    @confirm_window.amount.times do
      item2 = @list_window.current_item.craft(rand(100))
      if item2
        amount += 1
        item = item2
      end
    end
    if item
      @popup_window.set_text(item, amount)
    else
      @popup_window.set_text_fail
    end
    @confirm_window.change_amount(-1000)
    @gold_window.refresh unless ADV_RECIPE::DISABLE_GOLD_COST
    @list_window.refresh
    @gauge_window.refresh unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
    @popup_window.activate
  end
  def confirm_cancel
    @confirm_window.deactivate
    @list_window.activate
  end
  def command_cancel
    SceneManager.return
  end
  def cancel
    @list_window.select(-1)
    @command_window.activate
  end
  def command_ok
    @list_window.select(0)
    @list_window.activate
  end
end
 
class Scene_Crafting < Scene_CraftingAll
  def start
    super
    @command_window.index = ADV_RECIPE::CATEGORIES.index($crafting_category)
    @command_window.deactivate
    @command_window.visible = false
    @list_window.height += 48
    @list_window.y -= 48
    @detail_window.height += 48
    @detail_window.y -= 48
    @list_window.create_contents
    @detail_window.create_contents
    @list_window.select(0)
    @list_window.activate
  end
  def cancel
    SceneManager.return
  end
end
 
class Window_RecCategory < Window_HorzCommand
  def initialize
    super(0,72)
  end
  def window_width; Graphics.width; end
  def window_height; 48; end
  def make_command_list
    ADV_RECIPE::CATEGORIES.each do |command|
      add_command(command.to_s,command)
    end
  end
  def item_width
    120
  end
  def draw_item(index)
    change_color(normal_color, command_enabled?(index))
    rect = item_rect_for_text(index)
    draw_text(rect, command_name(index))
    draw_icon(ADV_RECIPE::CATEGORY_ICONS[index],rect.x-24,rect.y)
  end
  def item_rect_for_text(index)
    rect = item_rect(index)
    rect.x += 28
    rect.width -= 28
    rect
  end
end
 
class Window_RecPopup < Window_Selectable
  def initialize
    super(Graphics.width/2-window_width/2,Graphics.height/2-window_height/2,120,48)
    self.openness = 0
    deactivate
  end
  def window_width; 120; end
  def window_height; 48; end
  def set_text(item, amount)
    contents.clear
    text = amount.to_s + "x " + item.name + " - Production réussie !"
    width = contents.text_size(text).width
    self.width = width + padding*2
    self.x = Graphics.width/2-width/2
    create_contents
    draw_text(24,0,contents.width,line_height,text)
    draw_icon(item.icon_index,0,0)
    open
  end
  def set_text_fail
    contents.clear
    text = "Production échouée !"
    width = contents.text_size(text).width
    self.width = width + padding*2
    self.x = Graphics.width/2-width/2
    create_contents
    draw_text(12,0,contents.width,line_height,text)
    open
  end
  def process_ok
    if current_item_enabled?
      Input.update
      deactivate
      call_ok_handler
    else
      Sound.play_buzzer
    end
  end
end
 
class Window_RecGauge < Window_Base
  def initialize
    super(0,Graphics.height-48,Graphics.width/2,48)
    @category = :All
  end
  def refresh
    contents.clear
    return if @category == :All
    draw_icon(ADV_RECIPE::CATEGORY_ICONS[cat_index],0,0)
    draw_text(24,0,contents.width,24,$game_party.craft_level(cat_index))
    rate = $game_party.craft_exp(cat_index).to_f / $game_party.craft_exp_next(cat_index)
    draw_gauge(48, -3, contents.width-48, rate, tp_gauge_color1, tp_gauge_color2)
    if Module.const_defined?(:SPECIAL_GAUGES)
      @gauges[[48,-3]].set_extra("XP",$game_party.craft_exp(cat_index),$game_party.craft_exp_next(cat_index))
    else
      text = $game_party.craft_exp(cat_index).to_s+"/"+$game_party.craft_exp_next(cat_index).to_s
      draw_text(0,0,contents.width,24,text,2)
    end
  end
  def set_category(cat)
    return if cat == @category
    @category = cat
    refresh
  end
  def cat_index
    ADV_RECIPE::CATEGORIES.index(@category)
  end
end
 
class Window_MenuCommand < Window_Command
  alias recipe_aoc add_original_commands
  def add_original_commands
    recipe_aoc
    add_command("Crafting", :recipe) if ADV_RECIPE::ENABLE_MENU_ACCESS
  end
end
 
class Scene_Menu < Scene_MenuBase
  alias recipe_create_command_window create_command_window
  def create_command_window
    recipe_create_command_window
    @command_window.set_handler(:recipe,  method(:command_recipe))
  end
  def command_recipe
    SceneManager.call(Scene_CraftingAll)
  end
end

Du coup tu peut ajouter cette ligne dans l'appel de script avant de lancer le menu craft :
$crafting_list = [1,3] #<= pour les recette d'index 1 et 3
ou encore :
$crafting_list = :All

tu verra tu peut configurer plusieurs index de recette a une même recette
j'ai ajouter la config
:list => [1]
dans les définition de recette
Nérylis
Nérylis
Membre

Nombre de messages : 615
Age : 35
Localisation : Seine Maritime
Distinction : aucune
Date d'inscription : 23/11/2014

Résolu Re: Améliorations Script de craft

Sam 4 Juil 2015 - 13:54
Je viens de tester, ça marche comme je l'avais souhaité. Par contre, j'entrevois un éventuel problème : si je décide de lancer l'écran craft avec plusieurs catégories, l'appel de script marche pour toutes ces catégories. Par exemple, si je lance l'écran craft avec Alchimie et Forgeron, si je mets en appel de script la liste 1, je vais avoir toutes les recettes de la liste 1 à la fois pour l'Alchimie et le Forgeron. L'idéal serait de séparer pour chaque catégorie.
vincent26
vincent26
Membre

Nombre de messages : 766
Age : 28
Localisation : baume de transit le village paumé
Distinction : aucune
Date d'inscription : 17/08/2010

Résolu Re: Améliorations Script de craft

Sam 4 Juil 2015 - 16:28
tu ne peut pas dans ce cas toi faire attention au liste dans lesquels tu définit tes recettes ? car sinon ça risque de devenir complexe pour rien
Nérylis
Nérylis
Membre

Nombre de messages : 615
Age : 35
Localisation : Seine Maritime
Distinction : aucune
Date d'inscription : 23/11/2014

Résolu Re: Améliorations Script de craft

Sam 4 Juil 2015 - 18:26
Oui, tu as raison. A la limite, je peux faire de 0 à 9 pour l'Alchimie, 10 à 19 pour la Forge...

Dans ce cas, il ne reste plus qu'à finaliser l'affichage des ingrédients.

Pour en revenir à ce point-là :

Citation :Sélectionner le contenu
Pour l'affichage des icônes, c'est bon. Pour le menu défilant, y a deux choses qui me chagrinent. Quand il y a moins de 6 ingrédients, serait-il possible d'empêcher la possibilité d'aller dans le menu défilant ? Parce qu'après, ça se place mal. Et aussi, quand on quitte le menu craft, les écritures restent affichées une fraction de seconde avant de disparaître.

Je parlais de moins de 6 ingrédients, c'est quand il y a les onglets. Dans le cas où je ne les fais pas apparaître, c'est 8 ingrédients. Je ne sais pas si tu peux prendre en compte ces deux cas différents.
Nérylis
Nérylis
Membre

Nombre de messages : 615
Age : 35
Localisation : Seine Maritime
Distinction : aucune
Date d'inscription : 23/11/2014

Résolu Re: Améliorations Script de craft

Lun 13 Juil 2015 - 9:35
Petit up Wink
vincent26
vincent26
Membre

Nombre de messages : 766
Age : 28
Localisation : baume de transit le village paumé
Distinction : aucune
Date d'inscription : 17/08/2010

Résolu Re: Améliorations Script de craft

Lun 13 Juil 2015 - 17:44
Oups excuse je me suis oublier ^^' je l'avais fait mais pas eu le temps de te l'envoyer donc voici :
Code:

#Advanced Recipe Crafting v1.0b
#----------#
#Features: Advanced Recipe crafting! Hold on tight!
#
#Usage:    Set up your recipes, learn recipes, make items! Yay!
#      $crafting_category = :craft        - call before Scene, craft is category
#      $crafting_list = list              - A appeler avant la scene. list est tableaux d'id des list de recette a afficher
#      SceneManager.call(Scene_Crafting)  - opens the Crafting menu
#      SceneManager.call(Scene_CraftingAll)- opens the category Crafting menu
#      learn_recipe(id)                    - teaches that recipe
#      forget_recipe(id)                  - forgets that recipe
#
#----------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
#    given by email: sumptuaryspade@live.ca
#    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
#  All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
#
#- Free to use in any project with credit given, donations always welcome!
 
module ADV_RECIPE
#Whether or not crafted items use Weapon/Armor Randomization
  USE_WA_RANDOMIZATION = false
#The names of the categories for All Crafting Menu, use :All for all recipes
  CATEGORIES = [:Alchimie,:Forgeron,:Tisserand,:Armurier]
#The icons for categories, same order as above
  CATEGORY_ICONS = [10,199,284,332,0,0,0]
#The icon for player level
  LEVEL_ICON = 117
#Xp needed for crafting level, lvl is used for current level
  XP_NEEDED_EQUATION = "100 * lvl"
#Allow the crafting of multiple items
  CRAFT_MULTIPLE = false
#Allow or disallow menu access to the crafting scene
  ENABLE_MENU_ACCESS = false
#Font Size of Detail window, smaller font size creates more room for materials
  DETAIL_FONT_SIZE = 18
 
 
#The following options disable the display of certain features. They still work
# however if declared in recipes, so edit recipes accordingly.
#Removes Gold Cost
  DISABLE_GOLD_COST = false
#Removes success rate
  DISABLE_SUCCESS = false
#Removes player level requirement
  DISABLE_PLAYER_LEVEL = false
#Removes crafting level requirement and gauge
  DISABLE_CRAFT_LEVEL = false
#Auto-learn all skills (can use forget_recipe to forget certain ones for later)
  AUTO_LEARN_RECIPES = true
 
 
#The fun (read: complicated) part!
#Recipe symbols:
#
#The crafted item, type is 0 for item, 1 for weapon, 2 for armor
# :result => [type,id,amount]
#
#The materials required, same style as result.
# :materials => [ [type,id,amount],[type,id,amount] ... ],
#
#  All the following are optional:
# :gold_cost => amount          - amount of gold to craft, can be 0
# :success => percent          - base percent chance of successful craft
# :success_gain => percent      - percent gain on success per crafting level
# :level => value              - Hero level required to craft
# :craft_level => value        - Crafting level required to craft
# :category => :category        - Crafting category (:Alchemy, :Tailor, etc)
# :multiple => false            - disallows multiple crafts
# :xp => amount                - base Crafting xp gained per craft
# :xp_deprac => amount          - Xp lost per crafting level
# :pxp => amount                - Player xp gainer per craft
# :list => array                - Tableaux des liste de recette auquel appartient celle-ci
 
# Formula for xp gained is as follows and is never negative:
#  xp gain = xp - (current_level - recipe_level) * xp_deprac
 
  RECIPES = {
  0 => { :result => [0,1,1],
        :materials => [[0,4,2]],
        :gold_cost => [5,"Cuivre"],
        :success => 95,
        :success_gain => 1,
        :level => 1,
        :craft_level => 1,
        :category => :Alchimie,
        :xp => 50,
        :xp_deprac => 15,
        :list => [1]},
       
  1 => { :result => [0,2,1],
        :materials => [[0,4,1],[0,5,2]],
        :gold_cost => [50,"Argent"],
        :success => 90,
        :success_gain => 2,
        :level => 15,
        :craft_level => 1,
        :category => :Alchimie,
        :xp => 150,
        :xp_deprac => 20,
        :list => [2]},
       
  2 => { :result => [0,3,1],
        :materials => [[0,1,1],[0,2,1],[0,3,1],[0,4,1],[0,5,1],[0,6,2],[0,7,1],[0,8,1]],
        :gold_cost => [20,"Or"],
        :success => 85,
        :success_gain => 3,
        :level => 25,
        :craft_level => 1,
        :category => :Alchimie,
        :xp => 250,
        :xp_deprac => 25,
        :list => [2,3]},
  }
 
end
 
$crafting_category = :All
$crafting_list = :All
class Recipe
  attr_accessor :result
  attr_accessor :materials
  attr_accessor :known
  attr_accessor :id
  attr_accessor :gold_cost
  attr_accessor :level
  attr_accessor :category
  attr_accessor :xp
  attr_accessor :list
  def initialize(id,recipe_hash)
    @id = id
    @result = Material.new(recipe_hash[:result])
    @materials = []
    for item in recipe_hash[:materials]
      @materials.push(Material.new(item))
    end
    @known = false
    recipe_hash[:gold_cost] ? @gold_cost = recipe_hash[:gold_cost] : @gold_cost = 0
    recipe_hash[:success] ? @rate = recipe_hash[:success] : @rate = 100
    recipe_hash[:success_gain] ? @rated = recipe_hash[:success_gain] : @rated = 0
    recipe_hash[:level] ? @level = recipe_hash[:level] : @level = 1
    recipe_hash[:category] ? @category = recipe_hash[:category] : @category = CATEGORIES[0]
    recipe_hash[:xp] ? @xp = recipe_hash[:xp] : @xp = 0
    recipe_hash[:xp_deprac] ? @xpd = recipe_hash[:xp_deprac] : @xpd = 0
    recipe_hash[:craft_level] ? @clevel = recipe_hash[:craft_level] : @clevel = 0
    recipe_hash[:pxp] ? @pxp = recipe_hash[:pxp] : @pxp = 0
    recipe_hash[:list] ? @list = recipe_hash[:list] : @list = []
    !recipe_hash[:multiple].nil? ? @mult = recipe_hash[:multiple] : @mult = true
    @known = ADV_RECIPE::AUTO_LEARN_RECIPES
  end
  def name
    return @result.item.name
  end
  def multiple?
    @mult
  end
  def has_materials?
    for item in @materials
      return false unless $game_party.item_number(item.item) >= item.amount
    end
    return true
  end
  def has_gold?
    $game_party.gold >= @gold_cost
  end
  def has_craft_level?
    craft_level <= $game_party.craft_level_sym(@category)
  end
  def has_level?
    @level <= $game_party.highest_level && has_craft_level?
  end
  def craftable?
    has_gold? && has_materials? && has_level?
  end
  def craft_level
    @clevel
  end
  def amount_craftable?
    mat_amount = []
    for item in @materials
      mat_amount.push($game_party.item_number(item.item) / item.amount)
    end
    if @gold_cost > 0
      return [$game_party.gold / @gold_cost,mat_amount.min].min
    else
      return mat_amount.min
    end
  end
  def craft(fail = 0)
    remove_materials
    if fail < success_rate
      return add_result
    else
      return nil
    end
  end
  def remove_materials
    for item in @materials
      $game_party.gain_item(item.item,-item.amount)
    end
    $game_party.gain_gold(-@gold_cost)
  end
  def add_result
    if ADV_RECIPE::USE_WA_RANDOMIZATION
      item = $game_party.add_weapon(@result.item.id,@result.amount) if @result.item.is_a?(RPG::Weapon)
      item = $game_party.add_armor(@result.item.id,@result.amount) if @result.item.is_a?(RPG::Armor)
      item = $game_party.add_item(@result.item.id,@result.amount) if @result.item.is_a?(RPG::Item)
    else
      $game_party.gain_item(@result.item,@result.amount)
      item = @result.item
    end
    $game_party.gain_craft_exp(category_id, xp_gain)
    $game_party.members.each do |actor|
      actor.gain_exp(@pxp)
    end
    item
  end
  def category_id
    ADV_RECIPE::CATEGORIES.index(@category)
  end
  def xp_gain
    level_diff = $game_party.craft_level(category_id) - @clevel
    [@xp - @xpd * level_diff,0].max
  end
  def success_rate
    level_diff = $game_party.craft_level(category_id) - @clevel
    [@rate + @rated * level_diff,100].min
  end
end
 
class Material
  attr_accessor :item
  attr_accessor :amount
  def initialize(mat)
    @item = $data_items[mat[1]] if mat[0] == 0
    @item = $data_weapons[mat[1]] if mat[0] == 1
    @item = $data_armors[mat[1]] if mat[0] == 2
    @amount = mat[2]
  end
end
 
class Game_Party
  alias recipe_init initialize
  def initialize
    recipe_init
    @crafting_level = [1]*ADV_RECIPE::CATEGORIES.size
    @craft_exp = [0]*ADV_RECIPE::CATEGORIES.size
  end
  def craft_level(id)
    @crafting_level[id]
  end
  def craft_level_sym(sym)
    @crafting_level[ADV_RECIPE::CATEGORIES.index(sym)]
  end
  def craft_exp(id)
    @craft_exp[id]
  end
  def craft_exp_next(id)
    lvl = craft_level(id)
    return eval(ADV_RECIPE::XP_NEEDED_EQUATION)
  end
  def gain_craft_exp(id, val)
    @craft_exp[id] += val
    while craft_exp(id) >= craft_exp_next(id)
      @craft_exp[id] -= craft_exp_next(id)
      @crafting_level[id] += 1
    end
  end
end
 
module DataManager
  class << self
    alias rec_cgo create_game_objects
    alias rec_msc make_save_contents
    alias rec_esc extract_save_contents
  end
  def self.create_game_objects
    rec_cgo
    $game_recipes = create_recipes
  end
  def self.make_save_contents
    contents = rec_msc
    contents[:recipe] = $game_recipes
    contents
  end
  def self.extract_save_contents(contents)
    rec_esc(contents)
    $game_recipes = contents[:recipe]
  end
  def self.create_recipes
    recipes = {}
    ADV_RECIPE::RECIPES.each_pair do |key, val|
      recipes[key] = Recipe.new(key,val)
    end
    recipes
  end
end
 
class Game_Interpreter
  def learn_recipe(id)
    return if $game_recipes[id].nil?
    $game_recipes[id].known = true
  end
  def forget_recipe(id)
    return if $game_recipes[id].nil?
    $game_recipes[id].known = false
  end
end
 
class Window_RecipeList < Window_Selectable
  def initialize(x,y,w,h)
    super
    @data = $game_recipes.values.select {|recipe| include?(recipe)}
    refresh
  end
  def item_max
    @data ? @data.size : 1
  end
  def item
    @data && index >= 0 ? @data[index] : nil
  end
  def current_item_enabled?
    enable?(@data[index])
  end
  def include?(item)
    return false unless item.has_craft_level?
    return false unless item.known
    return true if @category == :All
    return @category == item.category if $crafting_list == :All
    ok = false
    for i in $crafting_list
      for j in item.list
        ok = true if i == j 
      end
    end
    return false unless ok
    return @category == item.category
  end
  def set_category(cat)
    return if cat == @category
    @category = cat
    @data = $game_recipes.values.select {|recipe| include?(recipe)}
    refresh
  end
  def enable?(item)
    return false if item.nil?
    item.craftable?
  end
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect(index)
      rect.width -= 4
      draw_item_name(item.result.item, rect.x, rect.y, enable?(item))
      if item.amount_craftable? > 0
        draw_text(rect.x,rect.y,contents.width,24,"x"+item.amount_craftable?.to_s,2)
      end
    end
  end
  def current_item
    index >= 0 ? @data[index] : nil
  end
  def process_ok
    if current_item_enabled?
      Sound.play_ok
      Input.update
      call_ok_handler
    else
      Sound.play_buzzer
    end
  end
  def refresh
    create_contents
    super
  end
  def content_heights
    item_max * 24
  end
end
 
class Window_RecipeDetail < Window_Base
  attr_accessor :activation
  attr_accessor :need_refresh
  attr_accessor :can_change
  def initialize(x,y,w,h)
    super
    @recipe = nil
    @activation = false
    @need_refresh = true
    @can_change = false
  end
  def set_recipe(recipe)
    @recipe = recipe
    refresh
  end
  def dispose
    super
    @zone.dispose if @zone
  end
  def refresh
    return unless @need_refresh
    contents.clear
    contents.font.size = ADV_RECIPE::DETAIL_FONT_SIZE
    return if @recipe.nil?
    draw_craft_level unless ADV_RECIPE::DISABLE_PLAYER_LEVEL && ADV_RECIPE::DISABLE_CRAFT_LEVEL
    draw_materials
    draw_success_rate unless ADV_RECIPE::DISABLE_SUCCESS
    draw_gold_cost unless ADV_RECIPE::DISABLE_GOLD_COST
  end
  def draw_craft_level
    change_color(system_color, @recipe.has_level?)
    draw_text(0,0,contents.width,contents.font.size,"Niveaux requis :")
    change_color(normal_color, @recipe.has_level?)
    xx = 0
    if !ADV_RECIPE::DISABLE_PLAYER_LEVEL
      draw_text(0,0,contents.width,contents.font.size,@recipe.level,2)
      draw_icon(ADV_RECIPE::LEVEL_ICON,contents.width - 48,-2)
      xx += 48
      text = @recipe.craft_level.to_s + "/"
    else
      text = @recipe.craft_level.to_s
    end
    if !ADV_RECIPE::DISABLE_CRAFT_LEVEL
      draw_text(0,0,contents.width - xx,contents.font.size,text,2)
      draw_icon(ADV_RECIPE::CATEGORY_ICONS[ADV_RECIPE::CATEGORIES.index(@recipe.category)],contents.width - 56 - xx,-4)
    end
  end
  def draw_materials
    if ADV_RECIPE::DISABLE_CRAFT_LEVEL && ADV_RECIPE::DISABLE_PLAYER_LEVEL
      y2 = 0
    else
      y2 = contents.font.size
    end
    change_color(system_color, @recipe.craftable?)
    draw_text(0,y2,self.width,contents.font.size,"Ingrédients requis :")
    y2 += contents.font.size
    yy = 0
    h = contents.font.size*@recipe.materials.length+4
    zone = Bitmap.new(contents.width,h)
    zone.font.size = ADV_RECIPE::DETAIL_FONT_SIZE
    for item in @recipe.materials
      zone.font.color.set(normal_color)
      zone.font.color.alpha = translucent_alpha unless $game_party.item_number(item.item) >= item.amount
      bitmap = Cache.system("Iconset")
      rect = Rect.new(item.item.icon_index % 16 * 24, item.item.icon_index / 16 * 24, 24, 24)
      zone.blt(0,yy, bitmap, rect, 255)
      zone.draw_text(24,yy,self.width,contents.font.size,item.item.name)
      string = $game_party.item_number(item.item).to_s + "/" + item.amount.to_s
      zone.draw_text(0,yy,self.contents.width,contents.font.size,string,2)
      yy += zone.font.size
    end
    @can_change = false
    @can_change = true if yy > contents.height-y2-contents.font.size*2
    view = Viewport.new(self.x+12,self.y+11+y2,contents.width,contents.height-y2-contents.font.size*2)
    view.z = 200
    @zone.dispose if @zone
    @zone = Sprite.new(view)
    @zone.bitmap = zone
    @need_refresh = false
  end
  def move_up
    @zone.oy = [0,@zone.oy-5].max
  end
  def move_down
    @zone.oy = [@zone.bitmap.height-@zone.viewport.rect.height,@zone.oy+5].min
  end
  def draw_success_rate
    change_color(system_color, @recipe.craftable?)
    draw_text(0,contents.height-contents.font.size,contents.width,contents.font.size,"Taux de réussite :")
    change_color(normal_color, @recipe.craftable?)
    draw_text(0,contents.height-contents.font.size,contents.width,contents.font.size,@recipe.success_rate.to_s + "%",2)
  end
  def draw_gold_cost
    if @recipe.gold_cost > 0
      change_color(system_color, @recipe.has_gold?)
      draw_text(0,contents.height-contents.font.size*2,contents.width,contents.font.size,"Coût de production :")
      change_color(normal_color, @recipe.has_gold?)
      draw_currency_value(@recipe.gold_cost,Vocab::currency_unit,0,contents.height-contents.font.size*2,contents.width)
    end 
  end
  def draw_currency_value(value, unit, x, y, width)
    cx = text_size(unit).width
    change_color(normal_color,$game_party.gold >= value)
    draw_text(x, y, width - cx - 2, contents.font.size, value, 2)
    change_color(system_color)
    draw_text(x, y, width, contents.font.size, unit, 2)
  end
end
 
class Window_RecipeConfirm < Window_Selectable
  attr_accessor :amount
  def initialize(x,y,w,h)
    super
    @amount = 1
    refresh
  end
  def item_max; 1; end;
  def enable?(item); true; end;
  def refresh
    super
    draw_text(0,0,self.contents.width,line_height,"Produire",1)
    return unless @recipe && @recipe.craftable?
    draw_text(0,0,contents.width,line_height,"x"+@amount.to_s,2)
  end
  def activate
    super
    select(0)
  end
  def deactivate
    super
    select(-1)
  end
  def set_recipe(rec)
    return if rec == @recipe
    @recipe = rec
    @amount = 1
    refresh
  end
  def cursor_movable?
    active && open? && ADV_RECIPE::CRAFT_MULTIPLE && @recipe.multiple?
  end
  def cursor_down(wrap = false)
    change_amount(-10)
  end
  def cursor_up(wrap = false)
    change_amount(10)
  end
  def cursor_right(wrap = false)
    change_amount(1)
  end
  def cursor_left(wrap = false)
    change_amount(-1)
  end
  def change_amount(val)
    Sound.play_cursor
    @amount += val
    @amount = [[@amount,1].max,@recipe.amount_craftable?].min
    refresh
  end
end
 
class Scene_CraftingAll < Scene_MenuBase
  def start
    super
    @help_window = Window_Help.new
    width = Graphics.width / 2
    height = Graphics.height - @help_window.height - 48
    @list_window = Window_RecipeList.new(0,@help_window.height+48,width,height-48)
    @list_window.set_handler(:ok, method(:list_success))
    @list_window.set_handler(:cancel, method(:cancel))
    @list_window.height += 48 if ADV_RECIPE::DISABLE_CRAFT_LEVEL
    @list_window.create_contents
    @detail_window = Window_RecipeDetail.new(width,@list_window.y,width,height-48*2)
    @detail_window.height += 48 if ADV_RECIPE::DISABLE_GOLD_COST
    @detail_window.create_contents
    height = @detail_window.y + @detail_window.height
    @confirm_window = Window_RecipeConfirm.new(width,height,width,48)
    @confirm_window.set_handler(:ok, method(:craft_success))
    @confirm_window.set_handler(:cancel, method(:confirm_cancel))
#~    if !ADV_RECIPE::DISABLE_GOLD_COST
#~      @gold_window = Window_Gold.new
#~      @gold_window.width = width
#~      @gold_window.y = Graphics.height - 48
#~      @gold_window.x = width
#~    end
    @popup_window = Window_RecPopup.new
    @popup_window.set_handler(:ok, method(:popup_ok))
    @popup_window.set_handler(:cancel, method(:popup_ok))
    @command_window = Window_RecCategory.new
    @command_window.set_handler(:ok, method(:command_ok))
    @command_window.set_handler(:cancel, method(:command_cancel))
    @gauge_window = Window_RecGauge.new unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
  end
  def popup_ok
    @popup_window.deactivate
    @popup_window.close
    @list_window.activate
  end
  def update
    super
    @help_window.set_text(@list_window.current_item.result.item.description) if !@list_window.current_item.nil?
    @detail_window.set_recipe(@list_window.current_item)
    @confirm_window.set_recipe(@list_window.current_item)
    @list_window.set_category(ADV_RECIPE::CATEGORIES[@command_window.index])
    @gauge_window.set_category(ADV_RECIPE::CATEGORIES[@command_window.index]) unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
    return unless @list_window.current_item
    if @list_window.current_item.craftable?
      @confirm_window.opacity = 255
      @confirm_window.contents_opacity = 255
    else
      @confirm_window.opacity = 75
      @confirm_window.contents_opacity = 75
    end
    if Input.trigger?(:RIGHT) && @detail_window.can_change
      @list_window.deactivate
      @detail_window.activation = true
    elsif Input.trigger?(:LEFT) && @detail_window.can_change
      @list_window.activate
      @detail_window.activation = false
    elsif Input.trigger?(:UP) && @detail_window.activation == true
      @detail_window.move_up
    elsif Input.trigger?(:DOWN) && @detail_window.activation == true
      @detail_window.move_down
    end
  end
  def list_success
    @list_window.deactivate
    @confirm_window.activate
  end
  def craft_success
    amount = 0
    item = nil
    @confirm_window.amount.times do
      item2 = @list_window.current_item.craft(rand(100))
      if item2
        amount += 1
        item = item2
      end
    end
    if item
      @popup_window.set_text(item, amount)
    else
      @popup_window.set_text_fail
    end
    @confirm_window.change_amount(-1000)
    @gold_window.refresh unless ADV_RECIPE::DISABLE_GOLD_COST
    @list_window.refresh
    @gauge_window.refresh unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
    @popup_window.activate
  end
  def confirm_cancel
    @confirm_window.deactivate
    @list_window.activate
  end
  def command_cancel
    SceneManager.return
  end
  def cancel
    @list_window.select(-1)
    @command_window.activate
  end
  def command_ok
    @list_window.select(0)
    @list_window.activate
  end
end
 
class Scene_Crafting < Scene_CraftingAll
  def start
    super
    @command_window.index = ADV_RECIPE::CATEGORIES.index($crafting_category)
    @command_window.deactivate
    @command_window.visible = false
    @list_window.height += 48
    @list_window.y -= 48
    @detail_window.height += 48
    @detail_window.y -= 48
    @list_window.create_contents
    @detail_window.create_contents
    @list_window.select(0)
    @list_window.activate
  end
  def cancel
    SceneManager.return
  end
end
 
class Window_RecCategory < Window_HorzCommand
  def initialize
    super(0,72)
  end
  def window_width; Graphics.width; end
  def window_height; 48; end
  def make_command_list
    ADV_RECIPE::CATEGORIES.each do |command|
      add_command(command.to_s,command)
    end
  end
  def item_width
    120
  end
  def draw_item(index)
    change_color(normal_color, command_enabled?(index))
    rect = item_rect_for_text(index)
    draw_text(rect, command_name(index))
    draw_icon(ADV_RECIPE::CATEGORY_ICONS[index],rect.x-24,rect.y)
  end
  def item_rect_for_text(index)
    rect = item_rect(index)
    rect.x += 28
    rect.width -= 28
    rect
  end
end
 
class Window_RecPopup < Window_Selectable
  def initialize
    super(Graphics.width/2-window_width/2,Graphics.height/2-window_height/2,120,48)
    self.openness = 0
    deactivate
  end
  def window_width; 120; end
  def window_height; 48; end
  def set_text(item, amount)
    contents.clear
    text = amount.to_s + "x " + item.name + " - Production réussie !"
    width = contents.text_size(text).width
    self.width = width + padding*2
    self.x = Graphics.width/2-width/2
    create_contents
    draw_text(24,0,contents.width,line_height,text)
    draw_icon(item.icon_index,0,0)
    open
  end
  def set_text_fail
    contents.clear
    text = "Production échouée !"
    width = contents.text_size(text).width
    self.width = width + padding*2
    self.x = Graphics.width/2-width/2
    create_contents
    draw_text(12,0,contents.width,line_height,text)
    open
  end
  def process_ok
    if current_item_enabled?
      Input.update
      deactivate
      call_ok_handler
    else
      Sound.play_buzzer
    end
  end
end
 
class Window_RecGauge < Window_Base
  def initialize
    super(0,Graphics.height-48,Graphics.width/2,48)
    @category = :All
  end
  def refresh
    contents.clear
    return if @category == :All
    draw_icon(ADV_RECIPE::CATEGORY_ICONS[cat_index],0,0)
    draw_text(24,0,contents.width,24,$game_party.craft_level(cat_index))
    rate = $game_party.craft_exp(cat_index).to_f / $game_party.craft_exp_next(cat_index)
    draw_gauge(48, -3, contents.width-48, rate, tp_gauge_color1, tp_gauge_color2)
    if Module.const_defined?(:SPECIAL_GAUGES)
      @gauges[[48,-3]].set_extra("XP",$game_party.craft_exp(cat_index),$game_party.craft_exp_next(cat_index))
    else
      text = $game_party.craft_exp(cat_index).to_s+"/"+$game_party.craft_exp_next(cat_index).to_s
      draw_text(0,0,contents.width,24,text,2)
    end
  end
  def set_category(cat)
    return if cat == @category
    @category = cat
    refresh
  end
  def cat_index
    ADV_RECIPE::CATEGORIES.index(@category)
  end
end
 
class Window_MenuCommand < Window_Command
  alias recipe_aoc add_original_commands
  def add_original_commands
    recipe_aoc
    add_command("Crafting", :recipe) if ADV_RECIPE::ENABLE_MENU_ACCESS
  end
end
 
class Scene_Menu < Scene_MenuBase
  alias recipe_create_command_window create_command_window
  def create_command_window
    recipe_create_command_window
    @command_window.set_handler(:recipe,  method(:command_recipe))
  end
  def command_recipe
    SceneManager.call(Scene_CraftingAll)
  end
end

Dis moi si ça va Wink
Nérylis
Nérylis
Membre

Nombre de messages : 615
Age : 35
Localisation : Seine Maritime
Distinction : aucune
Date d'inscription : 23/11/2014

Résolu Re: Améliorations Script de craft

Lun 13 Juil 2015 - 18:36
Il y a deux choses à changer :

- Le blocage pour aller dans le défilement des ingrédients marche bien uniquement dans le cas où dans la liste, il n'y a aucune recette avec plus de 6 ingrédients. Si par exemple il y a une recette avec 3 ingrédients et une autre avec 7 ingrédients, on peut faire défiler les ingrédients de la première recette et bien sûr, l'affichage n'est pas correct.
- Dans le cas où je n'utilise pas d'onglets, on peut accéder au défilement même si le nombre d'ingrédients est inférieur ou égal à 8 alors qu'on ne devrait pas. Pour ça que je disais que c'est 8 ingrédients max dans ce cas-là parce qu'on gagne de la place quand on n'affiche pas les onglets. Je ne sais pas si tu peux gérer ça. C'est pour ça que j'avais demandé initialement de mettre un paramètre de config true ou false pour les onglets pour gérer l'affichage dans les deux cas (onglets ou pas onglets). Après, si tu sais faire sans ça, ça me va bien.^^
Nérylis
Nérylis
Membre

Nombre de messages : 615
Age : 35
Localisation : Seine Maritime
Distinction : aucune
Date d'inscription : 23/11/2014

Résolu Re: Améliorations Script de craft

Mar 21 Juil 2015 - 18:19
Up Wink
vincent26
vincent26
Membre

Nombre de messages : 766
Age : 28
Localisation : baume de transit le village paumé
Distinction : aucune
Date d'inscription : 17/08/2010

Résolu Re: Améliorations Script de craft

Mer 22 Juil 2015 - 13:36
Essaye en changeant juste a la ligne 456 le yy par h :

@can_change = true if h > contents.height-y2-contents.font.size*2

normalement c'est ok en tous cas avec les test que j'ai fait ça marche et ça prend en compte le fait d'avoir ou non la sélection de catégorie
Nérylis
Nérylis
Membre

Nombre de messages : 615
Age : 35
Localisation : Seine Maritime
Distinction : aucune
Date d'inscription : 23/11/2014

Résolu Re: Améliorations Script de craft

Mer 22 Juil 2015 - 20:41
J'ai essayé mais ça ne marche pas, ça créé même un autre problème lorsque je lance la Scene All.

Je te mets la démo à jour pour que tu puisses jeter un oeil : http://www.mediafire.com/download/4c6wff6imhxynkx/Craft+-+Test.exe
vincent26
vincent26
Membre

Nombre de messages : 766
Age : 28
Localisation : baume de transit le village paumé
Distinction : aucune
Date d'inscription : 17/08/2010

Résolu Re: Améliorations Script de craft

Mer 22 Juil 2015 - 23:28
Alors voila ^^ il manquer des truc a droite a gauche

donc voici le script de base modifier (V.M - Advanced Recipe Crafting) :

Code:
#Advanced Recipe Crafting v1.0b
#----------#
#Features: Advanced Recipe crafting! Hold on tight!
#
#Usage:    Set up your recipes, learn recipes, make items! Yay!
#      $crafting_category = :craft        - call before Scene, craft is category
#      $crafting_list = list              - A appeler avant la scene. list est tableaux d'id des list de recette a afficher
#      SceneManager.call(Scene_Crafting)  - opens the Crafting menu
#      SceneManager.call(Scene_CraftingAll)- opens the category Crafting menu
#      learn_recipe(id)                    - teaches that recipe
#      forget_recipe(id)                  - forgets that recipe
#
#----------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
#    given by email: sumptuaryspade@live.ca
#    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
#  All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
#
#- Free to use in any project with credit given, donations always welcome!
 
module ADV_RECIPE
#Whether or not crafted items use Weapon/Armor Randomization
  USE_WA_RANDOMIZATION = false
#The names of the categories for All Crafting Menu, use :All for all recipes
  CATEGORIES = [:Alchimie,:Forgeron,:Tisserand,:Armurier]
#The icons for categories, same order as above
  CATEGORY_ICONS = [10,199,284,332,0,0,0]
#The icon for player level
  LEVEL_ICON = 117
#Xp needed for crafting level, lvl is used for current level
  XP_NEEDED_EQUATION = "100 * lvl"
#Allow the crafting of multiple items
  CRAFT_MULTIPLE = false
#Allow or disallow menu access to the crafting scene
  ENABLE_MENU_ACCESS = false
#Font Size of Detail window, smaller font size creates more room for materials
  DETAIL_FONT_SIZE = 18
 
 
#The following options disable the display of certain features. They still work
# however if declared in recipes, so edit recipes accordingly.
#Removes Gold Cost
  DISABLE_GOLD_COST = false
#Removes success rate
  DISABLE_SUCCESS = false
#Removes player level requirement
  DISABLE_PLAYER_LEVEL = false
#Removes crafting level requirement and gauge
  DISABLE_CRAFT_LEVEL = false
#Auto-learn all skills (can use forget_recipe to forget certain ones for later)
  AUTO_LEARN_RECIPES = true
 
 
#The fun (read: complicated) part!
#Recipe symbols:
#
#The crafted item, type is 0 for item, 1 for weapon, 2 for armor
# :result => [type,id,amount]
#
#The materials required, same style as result.
# :materials => [ [type,id,amount],[type,id,amount] ... ],
#
#  All the following are optional:
# :gold_cost => amount          - amount of gold to craft, can be 0
# :success => percent          - base percent chance of successful craft
# :success_gain => percent      - percent gain on success per crafting level
# :level => value              - Hero level required to craft
# :craft_level => value        - Crafting level required to craft
# :category => :category        - Crafting category (:Alchemy, :Tailor, etc)
# :multiple => false            - disallows multiple crafts
# :xp => amount                - base Crafting xp gained per craft
# :xp_deprac => amount          - Xp lost per crafting level
# :pxp => amount                - Player xp gainer per craft
# :list => array                - Tableaux des liste de recette auquel appartient celle-ci
 
# Formula for xp gained is as follows and is never negative:
#  xp gain = xp - (current_level - recipe_level) * xp_deprac
 
  RECIPES = {
  0 => { :result => [0,1,1],
        :materials => [[0,4,2]],
        :gold_cost => [5,"Cuivre"],
        :success => 95,
        :success_gain => 1,
        :level => 1,
        :craft_level => 1,
        :category => :Alchimie,
        :xp => 50,
        :xp_deprac => 15,
        :list => [1]},
       
  1 => { :result => [0,2,1],
        :materials => [[0,4,1],[0,5,2]],
        :gold_cost => [50,"Argent"],
        :success => 90,
        :success_gain => 2,
        :level => 15,
        :craft_level => 1,
        :category => :Alchimie,
        :xp => 150,
        :xp_deprac => 20,
        :list => [2]},
       
  2 => { :result => [0,3,1],
        :materials => [[0,1,1],[0,2,1],[0,3,1],[0,4,1],[0,5,1],[0,6,2],[0,7,1],[0,8,1]],
        :gold_cost => [20,"Or"],
        :success => 85,
        :success_gain => 3,
        :level => 25,
        :craft_level => 1,
        :category => :Alchimie,
        :xp => 250,
        :xp_deprac => 25,
        :list => [2,3]},
  3 => { :result => [1,1,1],
        :materials => [[0,1,1]],
        :gold_cost => [20,"Cuivre"],
        :success => 95,
        :success_gain => 3,
        :level => 1,
        :craft_level => 1,
        :category => :Forgeron,
        :xp => 10,
        :xp_deprac => 5,
        :list => [11]},
  4 => { :result => [2,1,1],
        :materials => [[0,1,1]],
        :gold_cost => [20,"Cuivre"],
        :success => 95,
        :success_gain => 3,
        :level => 1,
        :craft_level => 1,
        :category => :Tisserand,
        :xp => 10,
        :xp_deprac => 5,
        :list => [21]},
  }
 
end
 
$crafting_category = :All
$crafting_list = :All
class Recipe
  attr_accessor :result
  attr_accessor :materials
  attr_accessor :known
  attr_accessor :id
  attr_accessor :gold_cost
  attr_accessor :level
  attr_accessor :category
  attr_accessor :xp
  attr_accessor :list
  def initialize(id,recipe_hash)
    @id = id
    @result = Material.new(recipe_hash[:result])
    @materials = []
    for item in recipe_hash[:materials]
      @materials.push(Material.new(item))
    end
    @known = false
    recipe_hash[:gold_cost] ? @gold_cost = recipe_hash[:gold_cost] : @gold_cost = 0
    recipe_hash[:success] ? @rate = recipe_hash[:success] : @rate = 100
    recipe_hash[:success_gain] ? @rated = recipe_hash[:success_gain] : @rated = 0
    recipe_hash[:level] ? @level = recipe_hash[:level] : @level = 1
    recipe_hash[:category] ? @category = recipe_hash[:category] : @category = CATEGORIES[0]
    recipe_hash[:xp] ? @xp = recipe_hash[:xp] : @xp = 0
    recipe_hash[:xp_deprac] ? @xpd = recipe_hash[:xp_deprac] : @xpd = 0
    recipe_hash[:craft_level] ? @clevel = recipe_hash[:craft_level] : @clevel = 0
    recipe_hash[:pxp] ? @pxp = recipe_hash[:pxp] : @pxp = 0
    recipe_hash[:list] ? @list = recipe_hash[:list] : @list = []
    !recipe_hash[:multiple].nil? ? @mult = recipe_hash[:multiple] : @mult = true
    @known = ADV_RECIPE::AUTO_LEARN_RECIPES
  end
  def name
    return @result.item.name
  end
  def multiple?
    @mult
  end
  def has_materials?
    for item in @materials
      return false unless $game_party.item_number(item.item) >= item.amount
    end
    return true
  end
  def has_gold?
    $game_party.gold >= @gold_cost
  end
  def has_craft_level?
    craft_level <= $game_party.craft_level_sym(@category)
  end
  def has_level?
    @level <= $game_party.highest_level && has_craft_level?
  end
  def craftable?
    has_gold? && has_materials? && has_level?
  end
  def craft_level
    @clevel
  end
  def amount_craftable?
    mat_amount = []
    for item in @materials
      mat_amount.push($game_party.item_number(item.item) / item.amount)
    end
    if @gold_cost > 0
      return [$game_party.gold / @gold_cost,mat_amount.min].min
    else
      return mat_amount.min
    end
  end
  def craft(fail = 0)
    remove_materials
    if fail < success_rate
      return add_result
    else
      return nil
    end
  end
  def remove_materials
    for item in @materials
      $game_party.gain_item(item.item,-item.amount)
    end
    $game_party.gain_gold(-@gold_cost)
  end
  def add_result
    if ADV_RECIPE::USE_WA_RANDOMIZATION
      item = $game_party.add_weapon(@result.item.id,@result.amount) if @result.item.is_a?(RPG::Weapon)
      item = $game_party.add_armor(@result.item.id,@result.amount) if @result.item.is_a?(RPG::Armor)
      item = $game_party.add_item(@result.item.id,@result.amount) if @result.item.is_a?(RPG::Item)
    else
      $game_party.gain_item(@result.item,@result.amount)
      item = @result.item
    end
    $game_party.gain_craft_exp(category_id, xp_gain)
    $game_party.members.each do |actor|
      actor.gain_exp(@pxp)
    end
    item
  end
  def category_id
    ADV_RECIPE::CATEGORIES.index(@category)
  end
  def xp_gain
    level_diff = $game_party.craft_level(category_id) - @clevel
    [@xp - @xpd * level_diff,0].max
  end
  def success_rate
    level_diff = $game_party.craft_level(category_id) - @clevel
    [@rate + @rated * level_diff,100].min
  end
end
 
class Material
  attr_accessor :item
  attr_accessor :amount
  def initialize(mat)
    @item = $data_items[mat[1]] if mat[0] == 0
    @item = $data_weapons[mat[1]] if mat[0] == 1
    @item = $data_armors[mat[1]] if mat[0] == 2
    @amount = mat[2]
  end
end
 
class Game_Party
  alias recipe_init initialize
  def initialize
    recipe_init
    @crafting_level = [1]*ADV_RECIPE::CATEGORIES.size
    @craft_exp = [0]*ADV_RECIPE::CATEGORIES.size
  end
  def craft_level(id)
    @crafting_level[id]
  end
  def craft_level_sym(sym)
    @crafting_level[ADV_RECIPE::CATEGORIES.index(sym)]
  end
  def craft_exp(id)
    @craft_exp[id]
  end
  def craft_exp_next(id)
    lvl = craft_level(id)
    return eval(ADV_RECIPE::XP_NEEDED_EQUATION)
  end
  def gain_craft_exp(id, val)
    @craft_exp[id] += val
    while craft_exp(id) >= craft_exp_next(id)
      @craft_exp[id] -= craft_exp_next(id)
      @crafting_level[id] += 1
    end
  end
end
 
module DataManager
  class << self
    alias rec_cgo create_game_objects
    alias rec_msc make_save_contents
    alias rec_esc extract_save_contents
  end
  def self.create_game_objects
    rec_cgo
    $game_recipes = create_recipes
  end
  def self.make_save_contents
    contents = rec_msc
    contents[:recipe] = $game_recipes
    contents
  end
  def self.extract_save_contents(contents)
    rec_esc(contents)
    $game_recipes = contents[:recipe]
  end
  def self.create_recipes
    recipes = {}
    ADV_RECIPE::RECIPES.each_pair do |key, val|
      recipes[key] = Recipe.new(key,val)
    end
    recipes
  end
end
 
class Game_Interpreter
  def learn_recipe(id)
    return if $game_recipes[id].nil?
    $game_recipes[id].known = true
  end
  def forget_recipe(id)
    return if $game_recipes[id].nil?
    $game_recipes[id].known = false
  end
end
 
class Window_RecipeList < Window_Selectable
  def initialize(x,y,w,h)
    super
    @data = $game_recipes.values.select {|recipe| include?(recipe)}
    refresh
  end
  def item_max
    @data ? @data.size : 1
  end
  def item
    @data && index >= 0 ? @data[index] : nil
  end
  def current_item_enabled?
    enable?(@data[index])
  end
  def include?(item)
    return false unless item.has_craft_level?
    return false unless item.known
    return true if @category == :All
    return @category == item.category if $crafting_list == :All
    ok = false
    for i in $crafting_list
      for j in item.list
        ok = true if i == j 
      end
    end
    return false unless ok
    return @category == item.category
  end
  def set_category(cat)
    return if cat == @category
    @category = cat
    @data = $game_recipes.values.select {|recipe| include?(recipe)}
    refresh
  end
  def enable?(item)
    return false if item.nil?
    item.craftable?
  end
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect(index)
      rect.width -= 4
      draw_item_name(item.result.item, rect.x, rect.y, enable?(item))
      if item.amount_craftable? > 0
        draw_text(rect.x,rect.y,contents.width,24,"x"+item.amount_craftable?.to_s,2)
      end
    end
  end
  def current_item
    index >= 0 ? @data[index] : nil
  end
  def process_ok
    if current_item_enabled?
      Sound.play_ok
      Input.update
      call_ok_handler
    else
      Sound.play_buzzer
    end
  end
  def refresh
    create_contents
    super
  end
  def content_heights
    item_max * 24
  end
end
 
class Window_RecipeDetail < Window_Base
  attr_accessor :activation
  attr_accessor :need_refresh
  attr_accessor :can_change
  def initialize(x,y,w,h)
    super
    @recipe = nil
    @activation = false
    @need_refresh = true
    @can_change = false
  end
  def set_recipe(recipe)
    @need_refresh = true if @recipe != recipe
    @recipe = recipe
    refresh
  end
  def dispose
    super
    @zone.dispose if @zone
  end
  def refresh
    return unless @need_refresh
    contents.clear
    contents.font.size = ADV_RECIPE::DETAIL_FONT_SIZE
    @zone.dispose if @zone
    return if @recipe.nil?
    draw_craft_level unless ADV_RECIPE::DISABLE_PLAYER_LEVEL && ADV_RECIPE::DISABLE_CRAFT_LEVEL
    draw_materials
    draw_success_rate unless ADV_RECIPE::DISABLE_SUCCESS
    draw_gold_cost unless ADV_RECIPE::DISABLE_GOLD_COST
  end
  def draw_craft_level
    change_color(system_color, @recipe.has_level?)
    draw_text(0,0,contents.width,contents.font.size,"Niveaux requis :")
    change_color(normal_color, @recipe.has_level?)
    xx = 0
    if !ADV_RECIPE::DISABLE_PLAYER_LEVEL
      draw_text(0,0,contents.width,contents.font.size,@recipe.level,2)
      draw_icon(ADV_RECIPE::LEVEL_ICON,contents.width - 48,-2)
      xx += 48
      text = @recipe.craft_level.to_s + "/"
    else
      text = @recipe.craft_level.to_s
    end
    if !ADV_RECIPE::DISABLE_CRAFT_LEVEL
      draw_text(0,0,contents.width - xx,contents.font.size,text,2)
      draw_icon(ADV_RECIPE::CATEGORY_ICONS[ADV_RECIPE::CATEGORIES.index(@recipe.category)],contents.width - 56 - xx,-4)
    end
  end
  def draw_materials
    if ADV_RECIPE::DISABLE_CRAFT_LEVEL && ADV_RECIPE::DISABLE_PLAYER_LEVEL
      y2 = 0
    else
      y2 = contents.font.size
    end
    change_color(system_color, @recipe.craftable?)
    draw_text(0,y2,self.width,contents.font.size,"Ingrédients requis :")
    y2 += contents.font.size
    yy = 0
    h = contents.font.size*@recipe.materials.length+4
    zone = Bitmap.new(contents.width,h)
    zone.font.size = ADV_RECIPE::DETAIL_FONT_SIZE
    for item in @recipe.materials
      zone.font.color.set(normal_color)
      zone.font.color.alpha = translucent_alpha unless $game_party.item_number(item.item) >= item.amount
      bitmap = Cache.system("Iconset")
      rect = Rect.new(item.item.icon_index % 16 * 24, item.item.icon_index / 16 * 24, 24, 24)
      zone.blt(0,yy, bitmap, rect, 255)
      zone.draw_text(24,yy,self.width,contents.font.size,item.item.name)
      string = $game_party.item_number(item.item).to_s + "/" + item.amount.to_s
      zone.draw_text(0,yy,self.contents.width,contents.font.size,string,2)
      yy += zone.font.size
    end
    @can_change = false
    @can_change = true if h > contents.height-y2-contents.font.size*2
    puts "ok"
    puts h
    puts contents.height-y2-contents.font.size*2
    puts @can_change
    view = Viewport.new(self.x+12,self.y+11+y2,contents.width,contents.height-y2-contents.font.size*2)
    view.z = 200
    @zone = Sprite.new(view)
    @zone.bitmap = zone
    @need_refresh = false
  end
  def move_up
    @zone.oy = [0,@zone.oy-5].max
  end
  def move_down
    @zone.oy = [@zone.bitmap.height-@zone.viewport.rect.height,@zone.oy+5].min
  end
  def draw_success_rate
    change_color(system_color, @recipe.craftable?)
    draw_text(0,contents.height-contents.font.size,contents.width,contents.font.size,"Taux de réussite :")
    change_color(normal_color, @recipe.craftable?)
    draw_text(0,contents.height-contents.font.size,contents.width,contents.font.size,@recipe.success_rate.to_s + "%",2)
  end
  def draw_gold_cost
    if @recipe.gold_cost > 0
      change_color(system_color, @recipe.has_gold?)
      draw_text(0,contents.height-contents.font.size*2,contents.width,contents.font.size,"Coût de production :")
      change_color(normal_color, @recipe.has_gold?)
      draw_currency_value(@recipe.gold_cost,Vocab::currency_unit,0,contents.height-contents.font.size*2,contents.width)
    end 
  end
  def draw_currency_value(value, unit, x, y, width)
    cx = text_size(unit).width
    change_color(normal_color,$game_party.gold >= value)
    draw_text(x, y, width - cx - 2, contents.font.size, value, 2)
    change_color(system_color)
    draw_text(x, y, width, contents.font.size, unit, 2)
  end
end
 
class Window_RecipeConfirm < Window_Selectable
  attr_accessor :amount
  def initialize(x,y,w,h)
    super
    @amount = 1
    refresh
  end
  def item_max; 1; end;
  def enable?(item); true; end;
  def refresh
    super
    draw_text(0,0,self.contents.width,line_height,"Produire",1)
    return unless @recipe && @recipe.craftable?
    draw_text(0,0,contents.width,line_height,"x"+@amount.to_s,2)
  end
  def activate
    super
    select(0)
  end
  def deactivate
    super
    select(-1)
  end
  def set_recipe(rec)
    return if rec == @recipe
    @recipe = rec
    @amount = 1
    refresh
  end
  def cursor_movable?
    active && open? && ADV_RECIPE::CRAFT_MULTIPLE && @recipe.multiple?
  end
  def cursor_down(wrap = false)
    change_amount(-10)
  end
  def cursor_up(wrap = false)
    change_amount(10)
  end
  def cursor_right(wrap = false)
    change_amount(1)
  end
  def cursor_left(wrap = false)
    change_amount(-1)
  end
  def change_amount(val)
    Sound.play_cursor
    @amount += val
    @amount = [[@amount,1].max,@recipe.amount_craftable?].min
    refresh
  end
end
 
class Scene_CraftingAll < Scene_MenuBase
  def start
    super
    @help_window = Window_Help.new
    width = Graphics.width / 2
    height = Graphics.height - @help_window.height - 48
    @list_window = Window_RecipeList.new(0,@help_window.height+48,width,height-48)
    @list_window.set_handler(:ok, method(:list_success))
    @list_window.set_handler(:cancel, method(:cancel))
    @list_window.height += 48 if ADV_RECIPE::DISABLE_CRAFT_LEVEL
    @list_window.create_contents
    @detail_window = Window_RecipeDetail.new(width,@list_window.y,width,height-48*2)
    @detail_window.height += 48 if ADV_RECIPE::DISABLE_GOLD_COST
    @detail_window.create_contents
    height = @detail_window.y + @detail_window.height
    @confirm_window = Window_RecipeConfirm.new(width,height,width,48)
    @confirm_window.set_handler(:ok, method(:craft_success))
    @confirm_window.set_handler(:cancel, method(:confirm_cancel))
#~    if !ADV_RECIPE::DISABLE_GOLD_COST
#~      @gold_window = Window_Gold.new
#~      @gold_window.width = width
#~      @gold_window.y = Graphics.height - 48
#~      @gold_window.x = width
#~    end
    @popup_window = Window_RecPopup.new
    @popup_window.set_handler(:ok, method(:popup_ok))
    @popup_window.set_handler(:cancel, method(:popup_ok))
    @command_window = Window_RecCategory.new
    @command_window.set_handler(:ok, method(:command_ok))
    @command_window.set_handler(:cancel, method(:command_cancel))
    @gauge_window = Window_RecGauge.new unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
  end
  def popup_ok
    @popup_window.deactivate
    @popup_window.close
    @list_window.activate
  end
  def update
    super
    @help_window.set_text(@list_window.current_item.result.item.description) if !@list_window.current_item.nil?
    @detail_window.set_recipe(@list_window.current_item)
    @confirm_window.set_recipe(@list_window.current_item)
    @list_window.set_category(ADV_RECIPE::CATEGORIES[@command_window.index])
    @gauge_window.set_category(ADV_RECIPE::CATEGORIES[@command_window.index]) unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
    return unless @list_window.current_item
    if @list_window.current_item.craftable?
      @confirm_window.opacity = 255
      @confirm_window.contents_opacity = 255
    else
      @confirm_window.opacity = 75
      @confirm_window.contents_opacity = 75
    end
    if Input.trigger?(:RIGHT) && @detail_window.can_change
      @list_window.deactivate
      @detail_window.activation = true
    elsif Input.trigger?(:LEFT) && @detail_window.can_change
      @list_window.activate
      @detail_window.activation = false
    elsif Input.trigger?(:UP)
      if @detail_window.activation
        @detail_window.move_up
      else
        @detail_window.need_refresh = true
      end
    elsif Input.trigger?(:DOWN)
      if @detail_window.activation
        @detail_window.move_down
      else
        @detail_window.need_refresh = true
      end
    end
  end
  def list_success
    @list_window.deactivate
    @confirm_window.activate
  end
  def craft_success
    amount = 0
    item = nil
    @confirm_window.amount.times do
      item2 = @list_window.current_item.craft(rand(100))
      if item2
        amount += 1
        item = item2
      end
    end
    if item
      @popup_window.set_text(item, amount)
    else
      @popup_window.set_text_fail
    end
    @confirm_window.change_amount(-1000)
    @gold_window.refresh unless ADV_RECIPE::DISABLE_GOLD_COST
    @list_window.refresh
    @gauge_window.refresh unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
    @popup_window.activate
  end
  def confirm_cancel
    @confirm_window.deactivate
    @list_window.activate
  end
  def command_cancel
    SceneManager.return
  end
  def cancel
    @list_window.select(-1)
    @command_window.activate
    @detail_window.need_refresh = true
    @detail_window.refresh
  end
  def command_ok
    @list_window.select(0)
    @list_window.activate
    @detail_window.need_refresh = true
    @detail_window.refresh
  end
end
 
class Scene_Crafting < Scene_CraftingAll
  def start
    super
    @command_window.index = ADV_RECIPE::CATEGORIES.index($crafting_category)
    @command_window.deactivate
    @command_window.visible = false
    @list_window.height += 48
    @list_window.y -= 48
    @detail_window.height += 48
    @detail_window.y -= 48
    @list_window.create_contents
    @detail_window.create_contents
    @list_window.select(0)
    @list_window.activate
  end
  def cancel
    SceneManager.return
  end
end
 
class Window_RecCategory < Window_HorzCommand
  def initialize
    super(0,72)
  end
  def window_width; Graphics.width; end
  def window_height; 48; end
  def make_command_list
    ADV_RECIPE::CATEGORIES.each do |command|
      add_command(command.to_s,command)
    end
  end
  def item_width
    120
  end
  def draw_item(index)
    change_color(normal_color, command_enabled?(index))
    rect = item_rect_for_text(index)
    draw_text(rect, command_name(index))
    draw_icon(ADV_RECIPE::CATEGORY_ICONS[index],rect.x-24,rect.y)
  end
  def item_rect_for_text(index)
    rect = item_rect(index)
    rect.x += 28
    rect.width -= 28
    rect
  end
end
 
class Window_RecPopup < Window_Selectable
  def initialize
    super(Graphics.width/2-window_width/2,Graphics.height/2-window_height/2,120,48)
    self.openness = 0
    deactivate
  end
  def window_width; 120; end
  def window_height; 48; end
  def set_text(item, amount)
    contents.clear
    text = amount.to_s + "x " + item.name + " - Production réussie !"
    width = contents.text_size(text).width
    self.width = width + padding*2
    self.x = Graphics.width/2-width/2
    create_contents
    draw_text(24,0,contents.width,line_height,text)
    draw_icon(item.icon_index,0,0)
    open
  end
  def set_text_fail
    contents.clear
    text = "Production échouée !"
    width = contents.text_size(text).width
    self.width = width + padding*2
    self.x = Graphics.width/2-width/2
    create_contents
    draw_text(12,0,contents.width,line_height,text)
    open
  end
  def process_ok
    if current_item_enabled?
      Input.update
      deactivate
      call_ok_handler
    else
      Sound.play_buzzer
    end
  end
end
 
class Window_RecGauge < Window_Base
  def initialize
    super(0,Graphics.height-48,Graphics.width/2,48)
    @category = :All
  end
  def refresh
    contents.clear
    return if @category == :All
    draw_icon(ADV_RECIPE::CATEGORY_ICONS[cat_index],0,0)
    draw_text(24,0,contents.width,24,$game_party.craft_level(cat_index))
    rate = $game_party.craft_exp(cat_index).to_f / $game_party.craft_exp_next(cat_index)
    draw_gauge(48, -3, contents.width-48, rate, tp_gauge_color1, tp_gauge_color2)
    if Module.const_defined?(:SPECIAL_GAUGES)
      @gauges[[48,-3]].set_extra("XP",$game_party.craft_exp(cat_index),$game_party.craft_exp_next(cat_index))
    else
      text = $game_party.craft_exp(cat_index).to_s+"/"+$game_party.craft_exp_next(cat_index).to_s
      draw_text(0,0,contents.width,24,text,2)
    end
  end
  def set_category(cat)
    return if cat == @category
    @category = cat
    refresh
  end
  def cat_index
    ADV_RECIPE::CATEGORIES.index(@category)
  end
end
 
class Window_MenuCommand < Window_Command
  alias recipe_aoc add_original_commands
  def add_original_commands
    recipe_aoc
    add_command("Crafting", :recipe) if ADV_RECIPE::ENABLE_MENU_ACCESS
  end
end
 
class Scene_Menu < Scene_MenuBase
  alias recipe_create_command_window create_command_window
  def create_command_window
    recipe_create_command_window
    @command_window.set_handler(:recipe,  method(:command_recipe))
  end
  def command_recipe
    SceneManager.call(Scene_CraftingAll)
  end
end

et la modif de zouzaka modifier (Zouzaka - Craft menu):

Code:

$crafting_category = [:All]
module ADV_RECIPE
  @actual_cat = $crafting_category[0]
  def self.actual_cat=(i) ; @actual_cat = i ; end
  def self.actual_cat ; @actual_cat ; end
end
class Scene_CraftingAll
  alias :old_cancel :cancel
  def cancel
    @help_window.clear
    old_cancel
  end
  def update
    super
    @help_window.set_text(@list_window.current_item.result.item.description) if !@list_window.current_item.nil?
    @detail_window.set_recipe(@list_window.current_item)
    @confirm_window.set_recipe(@list_window.current_item)
    @list_window.set_category(ADV_RECIPE::CATEGORIES[@command_window.index])
    @gauge_window.set_category(ADV_RECIPE::CATEGORIES[@command_window.index]) unless ADV_RECIPE::DISABLE_CRAFT_LEVEL
    return unless @list_window.current_item
    if Input.trigger?(:RIGHT) && @detail_window.can_change
      @list_window.deactivate
      @detail_window.activation = true
    elsif (Input.trigger?(:LEFT) || (Input.repeat?(:B) && @detail_window.activation == true)) && @detail_window.can_change
      @list_window.activate
      @detail_window.activation = false
    elsif Input.repeat?(:UP) && @detail_window.activation
      if @detail_window.activation == true
        @detail_window.move_up
      else
        @detail_window.need_refresh = true
        @detail_window.refresh
      end
    elsif Input.repeat?(:DOWN) && @detail_window.activation
      if @detail_window.activation == true
        @detail_window.move_down
      else
        @detail_window.need_refresh = true
        @detail_window.refresh
      end
    end
  end
end
class Scene_Crafting
  def start
    super
    if $crafting_category.length == 1 ; alternative_start ; end #passer cette ligne en commentaire pour afficher les onglets même pour une seule catégorie de craft affichée
  end
  def alternative_start
    @command_window.index = ADV_RECIPE::CATEGORIES.index($crafting_category[0])
    @command_window.deactivate
    @command_window.visible = false
    @list_window.height += 48
    @list_window.y -= 48
    @detail_window.height += 48
    @detail_window.y -= 48
    @list_window.create_contents
    @detail_window.create_contents
    @list_window.select(0)
    @list_window.activate
  end
  def cancel
    if $crafting_category.length == 1 ; SceneManager.return    #passer cette ligne en commentaire pour afficher les onglets même pour une seule catégorie de craft affichée
    else                                                        #passer cette ligne en commentaire pour afficher les onglets même pour une seule catégorie de craft affichée
      @list_window.select(-1)
      @command_window.activate
      @help_window.clear
    end                                                        #passer cette ligne en commentaire pour afficher les onglets même pour une seule catégorie de craft affichée
  end
  def update
    super
    if $crafting_category.size > 1
      @list_window.set_category($crafting_category[@command_window.index])
    else
      @list_window.set_category($crafting_category[0])
    end
  end
end
class Window_RecCategory
  def make_command_list
    if SceneManager.scene_is?(Scene_CraftingAll)
      ADV_RECIPE::CATEGORIES.each{|command| add_command(command.to_s,command)}
    else
      $crafting_category.each{|command| add_command(command.to_s,command)}
    end
  end
  def draw_item(index)
    change_color(normal_color, command_enabled?(index))
    rect = item_rect_for_text(index)
    draw_text(rect, command_name(index))
    if SceneManager.scene_is?(Scene_CraftingAll)
      draw_icon(ADV_RECIPE::CATEGORY_ICONS[index],rect.x-24,rect.y)
    else
      draw_icon(ADV_RECIPE::CATEGORY_ICONS[ADV_RECIPE::CATEGORIES.index($crafting_category[index])],rect.x-24,rect.y)
    end
  end
  alias :old_update :update
  def update
    old_update
    ADV_RECIPE.actual_cat = $crafting_category[index]
  end
end
class Game_Party
  def craft_level(id)
    if id.class == Symbol
      @crafting_level[ADV_RECIPE::CATEGORIES.index(id)]
    else
      @crafting_level[id]
    end
  end
end
class Window_RecipeConfirm
  def refresh
    super
    if @recipe && @recipe.craftable?
      change_color(normal_color, true)
      draw_text(0,0,self.contents.width,line_height,"Produire",1)
      draw_text(0,0,contents.width,line_height,"x"+@amount.to_s,2)
    else
      change_color(normal_color, false)
      draw_text(0,0,self.contents.width,line_height,"Produire",1)
    end
  end
end
class Window_RecGauge
  def cat_index
    if SceneManager.scene_is?(Scene_CraftingAll) or ADV_RECIPE.actual_cat == nil
      ADV_RECIPE::CATEGORIES.index(@category)
    else
      p(ADV_RECIPE.actual_cat)
      ADV_RECIPE::CATEGORIES.index(ADV_RECIPE.actual_cat)
    end
  end
end

normalement c'est bon XD
Nérylis
Nérylis
Membre

Nombre de messages : 615
Age : 35
Localisation : Seine Maritime
Distinction : aucune
Date d'inscription : 23/11/2014

Résolu Re: Améliorations Script de craft

Jeu 23 Juil 2015 - 18:53
Testé, ça marche parfaitement comme je voulais. Je n'ai pas trouvé d'autres problèmes, je te mp si jamais je trouve quelque chose mais ça a l'air nickel. Merci beaucoup pour ton aide.
Contenu sponsorisé

Résolu Re: Améliorations Script de craft

Revenir en haut
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum