Jump to content

Recommended Posts

Glad could help! (=

I ran into another problem. I can't use this script on key items. A user on the previous page wrote a solution, but it doesn't work for me. He wrote:

 

The same was happening to me, and I've just figured out why. The "combine" option isn't working with key items. To fix this, look for the method check_combinations (the same one keridenes altered above), find the lines that end with :item, duplicate them and edit the copies so they read :key_item instead. For example:

 

@combineitem1 = $data_items[i[0][0]] if i[0][1] == :item

 

becomes

 

@combineitem1 = $data_items[i[0][0]] if i[0][1] == :item

@combineitem1 = $data_items[i[0][0]] if i[0][1] == :key_item

 

I pasted the @combineitem1....key_item lines like mentioned above, but still cannot use key items. Any ideas?

Share this post


Link to post
Share on other sites

[[8, :key_item],[9, :item], [3, :armor]]

 

Stuff like this doesn't work?

Yeah, I've put :key_item to the combination like that too, and doesn't work. Strange. 

Share this post


Link to post
Share on other sites

Simply use something like this:

[[17, :item],[18, :item], [19, :item]]

 

key items are also counted as items, so just make key items, grab their ID's and mark them as items. They will combine, I have tested that.

Share this post


Link to post
Share on other sites

Simply use something like this:

[[17, :item],[18, :item], [19, :item]]

 

key items are also counted as items, so just make key items, grab their ID's and mark them as items. They will combine, I have tested that.

Holy cow, it worked! Thank you very very much. :) Thinking about it, it is only logical, there are no different IDs for key items, they are also ID'd as items.

Share this post


Link to post
Share on other sites

 

 

Scene Combine for RGSS3

by efeberk

 

 

 

Introduction

 

This script will allow to combine two items and generate a new item from combined items.

 

Screenshot:

 

2eplw5i.png

 

Script

 

=begin
===============================================================================
 Scene_Combine by efeberk
 Version: RGSS3
===============================================================================
 This script will allow to combine two items and generate a new item from
 combined items. The scene is similiar with item_window. Actually you can use
 Scene_Combine instead of Scene_Item because there is an option named "Use" that
 allows you to use items. Why you need Item scene?
 
 Example : You have 1 potion and 1 stimulant. Combine them and generate a new
 Ultra stimulant.
--------------------------------------------------------------------------------
 
How to open Scene_Combine:
 
SceneManager.call(Scene_Combine)
 
Note : This script works on Items, Weapons and Armors
=end
 
module EFE
  COMBINE_BUTTON = "Combine"
  USE_BUTTON = "Use"
  SUCCESS = "Items have been combined succesfully"
  
  #Item name will be colored when you select an item in the list.
  SELECTED_COLOR = 14
  
  
  COMBINATIONS = [
   
  #[[item1, :type], [item2, :type], [result, :type]],
  #[[item1, :type], [item2, :type], [result, :type]],
  [[1, :item],[2, :weapon], [3, :armor]], 
  [[8, :item],[9, :item], [3, :armor]]
  
  ]
end
 
#==============================================================================
# ** Window_ItemKategory
#------------------------------------------------------------------------------
#  This window is for selecting a category of normal items and equipment
# on the item screen or shop screen.
#==============================================================================
 
class Window_ItemKategory < Window_HorzCommand
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :item_window
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0)
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    Graphics.width
  end
  #--------------------------------------------------------------------------
  # * Get Digit Count
  #--------------------------------------------------------------------------
  def col_max
    return 4
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    @item_window.category = current_symbol if @item_window
  end
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  def make_command_list
    add_command(Vocab::item,     :item)
    add_command(Vocab::weapon,   :weapon)
    add_command(Vocab::armor,    :armor)
    add_command(Vocab::key_item, :key_item)
  end
  #--------------------------------------------------------------------------
  # * Set Item Window
  #--------------------------------------------------------------------------
  def item_window=(item_window)
    @item_window = item_window
    update
  end
end
 
 
class Window_ItemListe < Window_Selectable
 
    attr_reader    :accepted_items
    attr_reader    :combining
  
  def initialize(x, y, width, height)
    super
    @combining = false
    @accepted_items = []
    @category = :none
    @data = []
  end
  
  def combining=(combine)
    @combining = combine
  end
 
  def category=(category)
    return if @category == category
    @category = category
    refresh
    self.oy = 0
  end
 
  def col_max
    return 2
  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)
    case @category
    when :item
      item.is_a?(RPG::Item) && !item.key_item?
    when :weapon
      item.is_a?(RPG::Weapon)
    when :armor
      item.is_a?(RPG::Armor)
    when :key_item
      item.is_a?(RPG::Item) && item.key_item?
    else
      false
    end
  end
 
  def draw_item_name(item, x, y, enabled = true, width = 172)
    return unless item
    draw_icon(item.icon_index, x, y, enabled)
    draw_text(x + 24, y, width, line_height, item.name)
  end
  
  def enable?(item)
    return true if @combining
    $game_party.usable?(item)
  end
 
  def make_item_list
    @data = $game_party.all_items.select {|item| include?(item) }
    @data.push(nil) if include?(nil)
  end
 
  def select_last
    select(@data.index($game_party.last_item.object) || 0)
  end
 
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect(index)
      rect.width -= 4
      k = [item.id, :item] if item.is_a?(RPG::Item)
      k = [item.id, :weapon] if item.is_a?(RPG::Weapon)
      k = [item.id, :armor] if item.is_a?(RPG::Armor)
      change_color(normal_color, enable?(item))
      change_color(text_color(EFE::SELECTED_COLOR), enable?(item)) if @accepted_items.include?(k)
      draw_item_name(item, rect.x, rect.y, enable?(item))
      draw_item_number(rect, item)
    end
  end
 
  def draw_item_number(rect, item)
    draw_text(rect, sprintf(":%2d", $game_party.item_number(item)), 2)
  end
 
  def update_help
    @help_window.set_item(item)
  end
 
  def refresh
    make_item_list
    create_contents
    draw_all_items
  end
end
 
 
class Window_AcceptCombination < Window_HorzCommand
 
  def initialize(x, y)
    super(x, y)
    self.z = 0
  end
 
  def window_width
    return Graphics.width
  end
 
  def col_max
    return 2
  end
 
  def make_command_list
    add_command(EFE::COMBINE_BUTTON,   :combine)
    add_command(EFE::USE_BUTTON, :use)
  end
end
 
class Scene_Combine < Scene_ItemBase
  
  def start
    super
    create_help_window
    create_options_window
    create_category_window
    create_item_window
  end
  
  def create_options_window
    @options_window = Window_AcceptCombination.new(0, @help_window.y + @help_window.height)
    @options_window.set_handler(:combine,     method(:combine_ok))
    @options_window.set_handler(:use,     method(:use_ok))
    @options_window.set_handler(:cancel,     method(:return_scene))
  end
  
  def combine_ok
    @item_window.combining = true
    @combine = true
    @category_window.item_window = @item_window
    @options_window.deactivate.unselect
    @category_window.activate.select(0)
  end
  
  def use_ok
    @item_window.combining = false
    @category_window.item_window = @item_window
    @options_window.deactivate.unselect
    @category_window.activate.select(0)
  end
 
  def create_category_window
    @category_window = Window_ItemKategory.new
    @category_window.viewport = @viewport
    @category_window.help_window = @help_window
    @category_window.y = @help_window.height + @options_window.height
    @category_window.set_handler(:ok,     method(:on_category_ok))
    @category_window.set_handler(:cancel, method(:on_category_cancel))
  end
 
  def create_item_window
    wy = @category_window.y + @category_window.height
    wh = Graphics.height - wy
    @item_window = Window_ItemListe.new(0, wy, Graphics.width, wh)
    @item_window.viewport = @viewport
    @item_window.help_window = @help_window
    @item_window.set_handler(:ok,     method(:on_item_ok))
    @item_window.set_handler(:cancel, method(:on_item_cancel))
    @category_window.deactivate.unselect
  end
 
  def on_category_ok
    @item_window.activate
    @item_window.select_last
  end
  
  def on_category_cancel
    @item_window.deactivate.unselect
    @item_window.accepted_items.clear
    @category_window.deactivate.unselect
    @options_window.activate.select(0)
  end
 
  def on_item_ok
    k = [@item_window.item.id, :item] if @item_window.item.is_a?(RPG::Item)
    k = [@item_window.item.id, :weapon] if @item_window.item.is_a?(RPG::Weapon)
    k = [@item_window.item.id, :armor] if @item_window.item.is_a?(RPG::Armor)
    if !@item_window.combining
      @options_window.deactivate
      $game_party.last_item.object = item
      determine_item
    else
      if @item_window.accepted_items.include?(k)
        @item_window.accepted_items.delete(k)
      else
        @item_window.accepted_items.push(k)
      end
      if @item_window.accepted_items.size == 2
        check_combinations(@item_window.accepted_items[0], @item_window.accepted_items[1])
        @item_window.refresh
      else
        @item_window.refresh
        @item_window.activate
      end
    end 
  end
  
  def check_combinations(id1, id2)
    EFE::COMBINATIONS.each {|i| 
    if (id1 == i[0] || id1 == i[1]) && (id2 == i[0] || id2 == i[1])
      @combineitem1 = $data_items[i[0][0]] if i[0][1] == :item
      @combineitem1 = $data_weapons[i[0][0]] if i[0][1] == :weapon
      @combineitem1 = $data_armors[i[0][0]] if i[0][1] == :armor
      @combineitem2 = $data_items[i[1][0]] if i[1][1] == :item
      @combineitem2 = $data_weapons[i[1][0]] if i[1][1] == :weapon
      @combineitem2 = $data_armors[i[1][0]] if i[1][1] == :armor
      @resultitem = $data_items[i[2][0]] if i[2][1] == :item
      @resultitem = $data_weapons[i[2][0]] if i[2][1] == :weapon
      @resultitem = $data_armors[i[2][0]] if i[2][1] == :armor
      @item_window.accepted_items.clear
      @item_window.refresh
      @item_window.activate
      $game_party.lose_item(@combineitem1, 1)
      $game_party.lose_item(@combineitem2, 1)
      $game_party.gain_item(@resultitem, 1)
      messagebox(EFE::SUCCESS, 400)
      return
    end
    }
    @item_window.accepted_items.clear
    @item_window.refresh
    @item_window.activate
  end
  
  def on_item_cancel
    @item_window.unselect
    @category_window.activate
  end
 
  def play_se_for_item
    Sound.play_use_item
  end
 
  def use_item
    super
    @item_window.redraw_current_item
  end
end

=begin
===============================================================================
 MessageBox by efeberk
 Version: RGSS3
===============================================================================
 This script will allow to open a new messagebox window only with a text.
--------------------------------------------------------------------------------

Call MessageBox in Script:

messagebox(text, width)

width : width of the window

=end

class Window_MessageBox < Window_Base

  def initialize(x, y, text, width)
    super(x, y, width, fitting_height(1))
    refresh(text)
  end
  
  
  def refresh(text)
    draw_text(0, 0, contents_width, line_height, text, 1)
  end

end

class Scene_MessageBox < Scene_Base
  
  def start
    super
    create_message_window
    create_background
  end
  
  def prepare(text, width)
    @text = text
    @width = width
  end
  
  def update
    super
    if Input.repeat?(: || Input.repeat?(:C)
      SceneManager.return
    end
  end
  
  def create_message_window
    @message_window = Window_MessageBox.new(0, 0, @text, @width)
    @message_window.width = @width
    @message_window.x = (Graphics.width / 2) - (@message_window.width / 2)
    @message_window.y = (Graphics.height / 2) - (@message_window.height / 2)
  end
  
  def create_background
    @background_sprite = Sprite.new
    @background_sprite.bitmap = SceneManager.background_bitmap
    @background_sprite.color.set(100, 100, 100, 128)
  end
end

def messagebox(text, width)
    SceneManager.call(Scene_MessageBox)
    SceneManager.scene.prepare(text, width)
end

 

 

 

 

 

Hi. I'm using your combine items script, and I found out that sometimes it causes an RGSS3 stopped working crash. I noticed that by using Mithran's debugger script:

 

http://forums.rpgmakerweb.com/index.php?/topic/17400-hidden-gameexe-crash-debugger-graphical-object-global-reference-ace/&page=1

 

Others suggested that this might be because some critical objects are not disposed properly. The script created a log in my game, where I found that the crash is happenning after a memory leak caused by the combine items script. I paste that log here, find the Memory Leak line and you will see which line in your script causes the problems. Since I'm nost s scripter I can't make out much of it, but maybe you can solve it more easily:

 

 

Time: 2016-01-26 11:41:20 +0100

CRITICAL OBJECT #<HudSpriteMouse:0x9cd7694>

In Scene Scene_Map

Creation Stack::

Script 0128 -- hud, Line: 109:in `block in create_pictures'

Script 0128 -- hud, Line: 108:in `each'

Script 0128 -- hud, Line: 108:in `create_pictures'

Script 0049 -- Spriteset_Map, Line: 19:in `initialize'

Script 0124 -- Fog effect, Line: 460:in `initialize'

Script 0125 -- Light, Line: 733:in `initialize'

Script 0102 -- Scene_Map, Line: 129:in `new'

Script 0102 -- Scene_Map, Line: 129:in `create_spriteset'

Script 0102 -- Scene_Map, Line: 17:in `start'

Script 0100 -- Scene_Base, Line: 12:in `main'

Script 0133 -- Bug hunt, Line: 246:in `main'

Script 0006 -- SceneManager, Line: 23:in `run'

Script 0137 -- Main, Line: 7:in `block in <main>'

:1:in `block in rgss_main'

:1:in `loop'

:1:in `rgss_main'

Script 0137 -- Main, Line: 7:in `<main>'

ruby:in `eval'

-----

Time: 2016-01-26 11:41:26 +0100

Memory Leak #<Sprite:0x9beebec>

In Scene Scene_MessageBox

Creation Stack::

Script 0126 -- combine items, Line: 424:in `create_background'

Script 0126 -- combine items, Line: 401:in `start'

Script 0100 -- Scene_Base, Line: 12:in `main'

Script 0133 -- Bug hunt, Line: 246:in `main'

Script 0006 -- SceneManager, Line: 23:in `run'

Script 0137 -- Main, Line: 7:in `block in <main>'

:1:in `block in rgss_main'

:1:in `loop'

:1:in `rgss_main'

Script 0137 -- Main, Line: 7:in `<main>'

ruby:in `eval'

 

Share this post


Link to post
Share on other sites

The line in question is:

  def update
    super
    if Input.repeat?(: || Input.repeat?(:C)
      SceneManager.return
    end
  end

 

The reason it crashes is incomplete 'if statement' - it lacks of specified key.

 

It's weird, that the script lacks of that- perhaps the author was modifying something and broke it that way accidentally?

Now the real question is what key was there...

 

I assume it was the return key??

 

Welp, while I'm not sure which key exactly was there, I do know how to fix this.

 

Try replacing that line with this:

  def update
    super
    if Input.repeat?(:B) || Input.repeat?(:C)
      SceneManager.return
    end
  end

 

If the chosen key (:B) will act weirdly (for example close the menu when it shouldn't) , try replacing it with other ones. You'll find the list of keys in the RM settings, it was F1 key during gameplay to access these I believe. There you'll see which key has which symbol.

You can also remove that and just keep the (:C) key, which is the action button.

 

If you'll have any troubles, feel free to poke me.

Hope that helps!

Share this post


Link to post
Share on other sites

Hello @NeedHelpGuy, your error looks exactly like the one, that was mentioned before.

 

Try the solution I've posted before. It's right above your post. ;) Tell me if it works for you. :)

 

Crash your game then go to the script editor; it will point you to the line, that caused the crash. You'll see a part similar to the one I've posted above. Correct that one line and try running the game again.

Share this post


Link to post
Share on other sites

Hello! I love the straightfowardness of the script, as I have been looking for an open-ended alchemy system for ages (as compared to crafting specific items through eventing), but I ran into a minor snag:

I use Yanfly's Item Menu for its categories ability and have a whole category of items that are strictly alchemy ingredients (as apposed to Smithing, Quest Items, Potions, Food, etc). All the alchemy ingredients are flowers, herbs, and the like. Would it be possible, when opening the crafting scene, to only show the 'ingredients' item category instead of every single item in my inventory? I imagine this could be easily done by referencing the category in the Yanfly script, but I don't know much about scripting so I haven't gotten it to work.

Edited by fladdles
spelling and grammar

Share this post


Link to post
Share on other sites
2 minutes ago, PhoenixSoul said:

I dunno about custom item types, but I'm pretty sure that one can modify certain display values and comment out what they don't want to see show up in the script.

Looks like @Rikifive has been helpful with this script before, and @roninator2 as well...

How would I go about modifying display values? I was able to remove the Weapons, Armors, and Special Items display from the UI interface, but the Items section still shows everything in my inventory.

Share this post


Link to post
Share on other sites

Easier (probably) idea! At line 105 you have this:

@accepted_items = []

 

I dont know jack about scripting, but what if the script only displays a certain specified range of item id's? I only have about a dozen alchemy ingredients in the game, so I think that would be easier than trying to specifically make it compatible with a whole 'nother script. I could just tell the script to only display if I have any number of these dozen or so items and leave it at that. That would be perfect.
Basically, if I have no alchemy ingredients, it would be an empty window display - but if I have any alchemy ingredients (specified by ID number or even a notetag, doesnt matter) ONLY they will show up in the window when I go to craft something.

Edited by fladdles
i suck at spelling

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×