Help - Search - Members - Calendar
Full Version: Mix Items
RPG RPG Revolution Forums > Scripting > Script Development and Support > RGSS2
breadlord
Look further down on this page, everything is on post 11
Ember
what is this i dont even
breadlord
breadlord
Help, those posts come out blank whatever i do
Octople Threat
Are you trying to post a script or something? If so I guess I could help, just PM me the stuff, and we'll see if I can't post it.
breadlord
ok, I'll pm you the script and demo

Yanfly
Why not just quote one of the other thread starter posts and use that as your template instead?
breadlord
Sorry, i don't understand, you mean something like I quote your post and put in the script?

Yanfly
QUOTE (breadlord @ Jun 7 2009, 07:04 AM) *
Sorry, i don't understand, you mean something like I quote your post and put in the script?

Something like that. Use a template that's been working for others. I recall trying to use the template provided in the sticky and it left me with blank posts.
breadlord
Octople Threat
The script still didn't send through, although don't worry, I used the link you managed to post, and I fixed everything. (Hopefully)

Here is the script:

[Show/Hide] TEH CODE
CODE
################################################################################
############################# BREADLORD'S ITEM MIX #############################
#### This script allows the player to mix  items to create new ones based   ####
#### on recipies that you make, to have a recipie in your game you have to  ####
#### put it below, were it says recipies, in the following format :         ####
####                                                                        ####
####    ingredients = [??, ??, ect] This is were you put the ingredients    ####
####                                for this recipie, you can have up yo 16 ####
####                                                                        ####
####    results = [ ??, ??, ect] This is were you put the results from this ####
####                             recipie, you can have up to 6              ####
####                                                                        ####
####    recipie = Recipie.new(results, ingredients) A vital part, put it in ####
####                                                exactly like this       ####
####                                                                        ####
####    @recipies.push(recipie) Another vital part, put it in exactly like  ####
####                            this                                        ####
####                                                                        ####
#### You call the mix scene with $scene = Scene_Mix.new                     ####
####                                                                        ####
################################################################################
#### There is one other way you can customize this script, you can make     ####
#### @pre_unlocked either true or false, @pre_unlocked controls if all the  ####
#### recipies start off unlocked, if you change it to true then all the     ####
#### recipies will be unlocked at the start of the game, if you set it to   ####
#### false then the player will either have to dicover the recipies for     ####
#### theirself or discover the recipie through an event, using the command  ####
#### $learnt.push(num), with num being the recipie number you want to       ####
#### unlock (Starting at 0). Note that even if a recipie is not unlocked    ####
#### the player can still make it, they will just not know what the result  ####
#### will be                                                                ####
################################################################################
################################################################################

#################################### Editable ##################################

class Scene_Mix < Scene_Base
  
def recipies
  
  @pre_unlocked = false
  
  @recipies = [] # Do not touch
  
  # These recipies are used in the demo, you can delete them #
  
  ingredients = [1, 2]
  results = [19]
  recipie = Recipie.new(results, ingredients)
  @recipies.push(recipie)
  
  ingredients = [3, 4]
  results = [20]
  recipie = Recipie.new(results, ingredients)
  @recipies.push(recipie)
  
  ingredients = [5, 1, 7]
  results = [18]
  recipie = Recipie.new(results, ingredients)
  @recipies.push(recipie)
  
  ingredients = [19, 20]
  results = [17]
  recipie = Recipie.new(results, ingredients)
  @recipies.push(recipie)
  
end

## Do not edit past this line ##################################################
  
  def start
    super
    if $learnt == nil
     @learnt = []
   end
    @gump = false
    create_menu_background
    recipies
    @viewport = Viewport.new(0, 0, 544, 416)
    @viewport2 = Viewport.new(272, 192, 272, 300)
    @viewport3 = Viewport.new(272, 88, 272, 104)
    @viewport4 = Viewport.new(272, 35, 272, 53)
    @item_window = Window_Item2.new(0, 35, 272, 381)
    @item_window.viewport = @viewport
    @item_window.active = true
    @selected = []
    a = 'Nothing'
    @result_window = Window_Command.new(272, [a], 2)
    @result_window.viewport = @viewport3
    @result_window.active = false
    @command_window = Window_Command.new(272, @selected, 2)
    @command_window.viewport = @viewport2
    @command_window.active = false
    @make_window = Window_Command.new(272, [''], 1)
    @make_window.viewport = @viewport4
    @make_window.active = false
  end
  
  def update
    if @item_window.active == true
     item_update
   elsif @make_window.active == true
     make_update
   end
    @item_window.update
    @make_window.update
    update_menu_background
  end
  
  def make_update
    if Input.trigger?(Input::LEFT)
      Sound.play_cursor
      @item_window.active = true
      @make_window.active = false
    elsif Input.trigger?(Input::C)
      Sound.play_use_skill
      recipie_act(@recipie_able)
    end
  end
  
  
  def item_update
    if @can_make == true
      if @gump == false
       @gump = true
       @make_window.dispose
       @make_window = Window_Command.new(272, ['Mix'], 1)
       @make_window.viewport = @viewport4
       @make_window.active = false
      end
    else
      if @gump == true
        @gump = false
       @make_window.dispose
       @make_window = Window_Command.new(272, [''], 1)
       @make_window.viewport = @viewport4
       @make_window.active = false
     end
   end
  
    if Input.trigger?(Input::B)
      a = @selected.size - 1
      if @selected[a] == nil
       Sound.play_cancel
       $scene = Scene_Map.new
     else
       Sound.play_cancel
       $game_party.gain_item($data_items[@selected[@selected.size - 1]], 1)
       @selected[@selected.size - 1] = 'a'
       @selected = @selected - ['a']
       a = []
       for i in 0..@selected.size - 1
        a.push($data_items[@selected[i]].name)
       end
       index = @item_window.index
       @item_window = Window_Item2.new(0, 35, 272, 381, index)
       @item_window.viewport = @viewport
       @item_window.active = true
       @command_window.dispose
       @command_window = Window_Command.new(272, a, 2)
       @command_window.viewport = @viewport2
       @command_window.active = false
       check
        a = []
          if @can_make == true
           for i in 0..@recipies[@recipie_able].results.size - 1
            if $learnt.include?(@recipie_able)
             if !(@recipies[@recipie_able].results[i] == nil)
              a.push($data_items[@recipies[@recipie_able].results[i]].name)
             end
            elsif @pre_unlocked == true
             if !(@recipies[@recipie_able].results[i] == nil)
              a.push($data_items[@recipies[@recipie_able].results[i]].name)
             end
            else
              a = ['??????']
            end
          end
          @result_window.dispose
          @result_window = Window_Command.new(272, a, 2)
          @result_window.viewport = @viewport3
          @result_window.active = false
        else
          a = 'Nothing'
          @result_window.dispose
          @result_window = Window_Command.new(272, [a])
          @result_window.viewport = @viewport3
          @result_window.active = false
        end
      end
    
    elsif Input.trigger?(Input::C)
      if @selected.size - 1 < 14 or @selected.size - 1 == 14 and !($game_party.items.size == 0)
          Sound.play_decision
          a = @item_window.item
        @last_selected = a.id
        $game_party.lose_item($data_items[a.id], 1)
        @selected.push(a.id)
        check
        a = []
        for i in 0..@selected.size - 1
          if !(@selected[i] == nil)
           a.push($data_items[@selected[i]].name)
         end
       end
        if @item_window.index == 0
         index = @item_window.index
        else
         index = @item_window.index - 1
        end
        @item_window = Window_Item2.new(0, 35, 272, 381, index)
        @item_window.viewport = @viewport
        @item_window.active = true
        @command_window.dispose
        @command_window = Window_Command.new(272, a, 2)
        @command_window.viewport = @viewport2
        @command_window.active = false
        check
        a = []
         if @can_make == true
           for i in 0..@recipies[@recipie_able].results.size - 1
            if $learnt.include?(@recipie_able)
             if !(@recipies[@recipie_able].results[i] == nil)
              a.push($data_items[@recipies[@recipie_able].results[i]].name)
             end
            elsif @pre_unlocked == true
             if !(@recipies[@recipie_able].results[i] == nil)
              a.push($data_items[@recipies[@recipie_able].results[i]].name)
             end
            else
              a = ['??????']
            end
          end
          @result_window.dispose
          @result_window = Window_Command.new(272, a, 2)
          @result_window.viewport = @viewport3
          @result_window.active = false
        else
          a = 'Nothing'
          @result_window.dispose
          @result_window = Window_Command.new(272, [a])
          @result_window.viewport = @viewport3
          @result_window.active = false
        end
      else
        Sound.play_buzzer
      end
    elsif @can_make == true and Input.trigger?(Input::RIGHT)
      Sound.play_cursor
      @item_window.active = false
      @make_window.active = true
    end
   end
  
def check
   @can_make = false
   @recipie_able = 0
   for i in 0..@recipies.size - 1
     a = @recipies[i].ingredients
     b = @selected
     if a.size == b.size
     for j in 0..1000
       if a.include?(j) and b.include?(j)
         a = a - [j]
         b = b - [j]
       end
       if a == [] and b == []
         @can_make = true
         @recipie_able = i
       end
     end
   end
   end
end


def recipie_act(recipie_num)
  $learnt.push(recipie_num)
  @selected.clear
  for i in 0..@recipies[recipie_num].results.size
    if !(@recipies[recipie_num].results[i] == nil)
      a = @recipies[recipie_num].results[i]
      $game_party.gain_item($data_items[a], 1)
    end
  end
        @item_window = Window_Item2.new(0, 35, 272, 381, 0)
       @item_window.viewport = @viewport
       @item_window.active = true
       @command_window.dispose
       @command_window = Window_Command.new(272, [], 2)
       @command_window.viewport = @viewport2
       @command_window.active = false
       a = 'Nothing'
      
    @result_window.dispose
    @result_window = Window_Command.new(272, [a])
    @result_window.viewport = @viewport3
    @result_window.active = false
    @make_window.dispose
    @make_window = Window_Command.new(272, [''], 1)
    @make_window.viewport = @viewport4
    @make_window.active = false
end
  
end





class Recipie
  
  attr_reader :results, :ingredients
  
  def initialize(results, ingredients)
    @results = results
    @ingredients = ingredients
  end
  
  def ingredients
    return @ingredients
  end
  
end







#==============================================================================
# ** Window_Item
#------------------------------------------------------------------------------
#  This window displays a list of inventory items for the item screen, etc.
#==============================================================================

class Window_Item2 < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x      : window x-coordinate
  #     y      : window y-coordinate
  #     width  : window width
  #     height : window height
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height, index = 0)
    super(x, y, width, height)
    @column_max = 1
    self.index = index
    refresh
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Whether or not to include in item list
  #     item : item
  #--------------------------------------------------------------------------
  def include?(item)
    return false if item == nil
    if $game_temp.in_battle
      return false unless item.is_a?(RPG::Item)
    end
    return true
  end
  #--------------------------------------------------------------------------
  # * Whether or not to display in enabled state
  #     item : item
  #--------------------------------------------------------------------------
  def enable?(item)
    return true
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    @data = []
    for item in $game_party.items
      next unless include?(item)
      @data.push(item)
      if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
        self.index = @data.size - 1
      end
    end
    @data.push(nil) if include?(nil)
    @item_max = @data.size
    create_contents
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    item = @data[index]
    if item != nil
      number = $game_party.item_number(item)
      enabled = enable?(item)
      rect.width -= 4
      draw_item_name(item, rect.x, rect.y, enabled)
      self.contents.draw_text(rect, sprintf(":%2d", number), 2)
    end
  end
  #--------------------------------------------------------------------------
  # * Update Help Text
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(item == nil ? "" : item.description)
  end
end



module Vocab
  def self.new_game
    $learnt = []
    return $data_system.terms.new_game
  end
end


class Scene_File
  alias save write_save_data
  alias load read_save_data
  
  def write_save_data(file)
    save(file)
    Marshal.dump($learnt,              file)

  end
  
  def read_save_data(file)
    load(file)
    $learnt              = Marshal.load(file)
  end
  
end



[Show/Hide] SCREENSHOTS








The demos files in your thing were all fragmented, Breadlord, so I took the liberty to make a complete demo with all the files in one...

DEMO LINK

DEMO

Let's hope this works... thumbsup.gif
breadlord
Thanks, I'll edit my first post to say to look down here.

Octople Threat
Yayz, I helped. happy.gif

Maybe for a future update you could include the option to mix from the menu?
breadlord
Someone found a glicht in the script, this should fix it. The demo is not yet fixed.

QUOTE (Octople Threat @ Jun 7 2009, 06:17 PM) *
Here is the script:

[Show/Hide] TEH CODE
CODE
################################################################################
############################# BREADLORD'S ITEM MIX #############################
#### This script allows the player to mix  items to create new ones based   ####
#### on recipies that you make, to have a recipie in your game you have to  ####
#### put it below, were it says recipies, in the following format :         ####
####                                                                        ####
####    ingredients = [??, ??, ect] This is were you put the ingredients    ####
####                                for this recipie, you can have up yo 16 ####
####                                                                        ####
####    results = [ ??, ??, ect] This is were you put the results from this ####
####                             recipie, you can have up to 6              ####
####                                                                        ####
####    recipie = Recipie.new(results, ingredients) A vital part, put it in ####
####                                                exactly like this       ####
####                                                                        ####
####    @recipies.push(recipie) Another vital part, put it in exactly like  ####
####                            this                                        ####
####                                                                        ####
#### You call the mix scene with $scene = Scene_Mix.new                     ####
####                                                                        ####
################################################################################
#### There is one other way you can customize this script, you can make     ####
#### @pre_unlocked either true or false, @pre_unlocked controls if all the  ####
#### recipies start off unlocked, if you change it to true then all the     ####
#### recipies will be unlocked at the start of the game, if you set it to   ####
#### false then the player will either have to dicover the recipies for     ####
#### theirself or discover the recipie through an event, using the command  ####
#### $learnt.push(num), with num being the recipie number you want to       ####
#### unlock (Starting at 0). Note that even if a recipie is not unlocked    ####
#### the player can still make it, they will just not know what the result  ####
#### will be                                                                ####
################################################################################
################################################################################

#################################### Editable ##################################

class Scene_Mix < Scene_Base
  
def recipies
  
  @pre_unlocked = false
  
  @recipies = [] # Do not touch
  
  # These recipies are used in the demo, you can delete them #
  
  ingredients = [1, 2]
  results = [19]
  recipie = Recipie.new(results, ingredients)
  @recipies.push(recipie)
  
  ingredients = [3, 4]
  results = [20]
  recipie = Recipie.new(results, ingredients)
  @recipies.push(recipie)
  
  ingredients = [5, 1, 7]
  results = [18]
  recipie = Recipie.new(results, ingredients)
  @recipies.push(recipie)
  
  ingredients = [19, 20]
  results = [17]
  recipie = Recipie.new(results, ingredients)
  @recipies.push(recipie)
  
end

## Do not edit past this line ##################################################
  
  def start
    super
    if $learnt == nil
     @learnt = []
   end
    @gump = false
    create_menu_background
    recipies
    @viewport = Viewport.new(0, 0, 544, 416)
    @viewport2 = Viewport.new(272, 192, 272, 300)
    @viewport3 = Viewport.new(272, 88, 272, 104)
    @viewport4 = Viewport.new(272, 35, 272, 53)
    @item_window = Window_Item2.new(0, 35, 272, 381)
    @item_window.viewport = @viewport
    @item_window.active = true
    @selected = []
    a = 'Nothing'
    @result_window = Window_Command.new(272, [a], 2)
    @result_window.viewport = @viewport3
    @result_window.active = false
    @command_window = Window_Command.new(272, @selected, 2)
    @command_window.viewport = @viewport2
    @command_window.active = false
    @make_window = Window_Command.new(272, [''], 1)
    @make_window.viewport = @viewport4
    @make_window.active = false
  end
  
  def update
    if @item_window.active == true
     item_update
   elsif @make_window.active == true
     make_update
   end
    @item_window.update
    @make_window.update
    update_menu_background
  end
  
  def make_update
    if Input.trigger?(Input::LEFT)
      Sound.play_cursor
      @item_window.active = true
      @make_window.active = false
    elsif Input.trigger?(Input::C)
      Sound.play_use_skill
      recipie_act(@recipie_able)
    end
  end
  
  
  def item_update
    if @can_make == true
      if @gump == false
       @gump = true
       @make_window.dispose
       @make_window = Window_Command.new(272, ['Mix'], 1)
       @make_window.viewport = @viewport4
       @make_window.active = false
      end
    else
      if @gump == true
        @gump = false
       @make_window.dispose
       @make_window = Window_Command.new(272, [''], 1)
       @make_window.viewport = @viewport4
       @make_window.active = false
     end
   end
  
    if Input.trigger?(Input::B)
      a = @selected.size - 1
      if @selected[a] == nil
       Sound.play_cancel
       $scene = Scene_Map.new
     else
       Sound.play_cancel
       $game_party.gain_item($data_items[@selected[@selected.size - 1]], 1)
       @selected[@selected.size - 1] = 'a'
       @selected = @selected - ['a']
       a = []
       for i in 0..@selected.size - 1
        a.push($data_items[@selected[i]].name)
       end
       index = @item_window.index
       @item_window = Window_Item2.new(0, 35, 272, 381, index)
       @item_window.viewport = @viewport
       @item_window.active = true
       @command_window.dispose
       @command_window = Window_Command.new(272, a, 2)
       @command_window.viewport = @viewport2
       @command_window.active = false
       check
        a = []
          if @can_make == true
           for i in 0..@recipies[@recipie_able].results.size - 1
            if $learnt.include?(@recipie_able)
             if !(@recipies[@recipie_able].results[i] == nil)
              a.push($data_items[@recipies[@recipie_able].results[i]].name)
             end
            elsif @pre_unlocked == true
             if !(@recipies[@recipie_able].results[i] == nil)
              a.push($data_items[@recipies[@recipie_able].results[i]].name)
             end
            else
              a = ['??????']
            end
          end
          @result_window.dispose
          @result_window = Window_Command.new(272, a, 2)
          @result_window.viewport = @viewport3
          @result_window.active = false
        else
          a = 'Nothing'
          @result_window.dispose
          @result_window = Window_Command.new(272, [a])
          @result_window.viewport = @viewport3
          @result_window.active = false
        end
      end
    
    elsif Input.trigger?(Input::C)
      if @selected.size - 1 < 14 or @selected.size - 1 == 14 and !($game_party.items.size == 0)
          Sound.play_decision
          a = @item_window.item
        @last_selected = a.id
        $game_party.lose_item($data_items[a.id], 1)
        @selected.push(a.id)
        check
        a = []
        for i in 0..@selected.size - 1
          if !(@selected[i] == nil)
           a.push($data_items[@selected[i]].name)
         end
       end
        if @item_window.index == 0
         index = @item_window.index
        else
         index = @item_window.index - 1
        end
        @item_window = Window_Item2.new(0, 35, 272, 381, index)
        @item_window.viewport = @viewport
        @item_window.active = true
        @command_window.dispose
        @command_window = Window_Command.new(272, a, 2)
        @command_window.viewport = @viewport2
        @command_window.active = false
        check
        a = []
         if @can_make == true
           for i in 0..@recipies[@recipie_able].results.size - 1
            if $learnt.include?(@recipie_able)
             if !(@recipies[@recipie_able].results[i] == nil)
              a.push($data_items[@recipies[@recipie_able].results[i]].name)
             end
            elsif @pre_unlocked == true
             if !(@recipies[@recipie_able].results[i] == nil)
              a.push($data_items[@recipies[@recipie_able].results[i]].name)
             end
            else
              a = ['??????']
            end
          end
          @result_window.dispose
          @result_window = Window_Command.new(272, a, 2)
          @result_window.viewport = @viewport3
          @result_window.active = false
        else
          a = 'Nothing'
          @result_window.dispose
          @result_window = Window_Command.new(272, [a])
          @result_window.viewport = @viewport3
          @result_window.active = false
        end
      else
        Sound.play_buzzer
      end
    elsif @can_make == true and Input.trigger?(Input::RIGHT)
      Sound.play_cursor
      @item_window.active = false
      @make_window.active = true
    end
   end
  
def check
     @can_make = false
     @recipie_able = 0
     for i in 0..@recipies.size - 1
       a = @recipies[i].ingredients
       b = @selected
       a = a.sort!
       b = b.sort!
       if a.size == b.size and a == b
         @can_make = true
         @recipie_able = i
       end
     end
   end

def recipie_act(recipie_num)
  $learnt.push(recipie_num)
  @selected.clear
  for i in 0..@recipies[recipie_num].results.size
    if !(@recipies[recipie_num].results[i] == nil)
      a = @recipies[recipie_num].results[i]
      $game_party.gain_item($data_items[a], 1)
    end
  end
        @item_window = Window_Item2.new(0, 35, 272, 381, 0)
       @item_window.viewport = @viewport
       @item_window.active = true
       @command_window.dispose
       @command_window = Window_Command.new(272, [], 2)
       @command_window.viewport = @viewport2
       @command_window.active = false
       a = 'Nothing'
      
    @result_window.dispose
    @result_window = Window_Command.new(272, [a])
    @result_window.viewport = @viewport3
    @result_window.active = false
    @make_window.dispose
    @make_window = Window_Command.new(272, [''], 1)
    @make_window.viewport = @viewport4
    @make_window.active = false
end
  
end





class Recipie
  
  attr_reader :results, :ingredients
  
  def initialize(results, ingredients)
    @results = results
    @ingredients = ingredients
  end
  
  def ingredients
    return @ingredients
  end
  
end







#==============================================================================
# ** Window_Item
#------------------------------------------------------------------------------
#  This window displays a list of inventory items for the item screen, etc.
#==============================================================================

class Window_Item2 < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x      : window x-coordinate
  #     y      : window y-coordinate
  #     width  : window width
  #     height : window height
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height, index = 0)
    super(x, y, width, height)
    @column_max = 1
    self.index = index
    refresh
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Whether or not to include in item list
  #     item : item
  #--------------------------------------------------------------------------
  def include?(item)
    return false if item == nil
    if $game_temp.in_battle
      return false unless item.is_a?(RPG::Item)
    end
    return true
  end
  #--------------------------------------------------------------------------
  # * Whether or not to display in enabled state
  #     item : item
  #--------------------------------------------------------------------------
  def enable?(item)
    return true
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    @data = []
    for item in $game_party.items
      next unless include?(item)
      @data.push(item)
      if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
        self.index = @data.size - 1
      end
    end
    @data.push(nil) if include?(nil)
    @item_max = @data.size
    create_contents
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    item = @data[index]
    if item != nil
      number = $game_party.item_number(item)
      enabled = enable?(item)
      rect.width -= 4
      draw_item_name(item, rect.x, rect.y, enabled)
      self.contents.draw_text(rect, sprintf(":%2d", number), 2)
    end
  end
  #--------------------------------------------------------------------------
  # * Update Help Text
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(item == nil ? "" : item.description)
  end
end



module Vocab
  def self.new_game
    $learnt = []
    return $data_system.terms.new_game
  end
end


class Scene_File
  alias save write_save_data
  alias load read_save_data
  
  def write_save_data(file)
    save(file)
    Marshal.dump($learnt,              file)

  end
  
  def read_save_data(file)
    load(file)
    $learnt              = Marshal.load(file)
  end
  
end



[Show/Hide] SCREENSHOTS








The demos files in your thing were all fragmented, Breadlord, so I took the liberty to make a complete demo with all the files in one...

DEMO LINK

DEMO

Let's hope this works... thumbsup.gif
Octople Threat
I was going to go in and fix it, but when I pasted the fixed script everything after line 258 was in purple, and when I tried to load up the game it gave me a syntax error right there. I don't have the faintest idea of how to fix it, just thought I shoudl let you know.
breadlord
Fixed, it was just the forum adding in email tags into the script.

Octople Threat
I tried to update it but because of the clutter in my files I think I might have screwed it up, tell me if I did.
breadlord
Why no replies?
Octople Threat
QUOTE (breadlord @ Jun 11 2009, 08:48 AM) *
Why no replies?



It's not that it's a bad script or anything. It does exactly what it's supposed to without any trouble. The reason people aren't replying is because it's one of about a half-dozen scripts that do the same thing and most of the have lots of options that they give to the player. Item synthesis scripts are pretty common, which is why I would suggest for your next script that you do something uncommon. Don't worry, just keep learning and making scripts and you'll do fine. Eventually you'll get as good as Yanfly or cmpsr2000, but you can't reach that level if you let every setback discourage you. Keep up the good work.
fizzly
Hey, I don't think it's really common script. And I kinda like it. Thanks, Breadlord! =) I think it's good, cause it's really easy to use and configure. =) By the way, I found that it's not compatible with Particle Engine ^^;
breadlord
Wich particle engine? Please post it so I can see if I can fix the compatibility issues.

fizzly
QUOTE (breadlord @ Aug 14 2009, 01:02 AM) *
Wich particle engine? Please post it so I can see if I can fix the compatibility issues.

Oh, it's not really neccessary, but thank you. =) And the problem is with Particle Engine in fact, not in yours. They just can't work together, cause I get error every time when I'm leaving mixing window(s), when the particle effect should be created. Anyway, it's not really important. =)
But if you want to check this, here's the script:

CODE
#===============================================================================
# † [VX] † Rei Particle Engine † †
# † This script lets you create particle effects in your game †
#-------------------------------------------------------------------------------
# † XP version by arevulopapo on RMXP.org
# † VX version by reijubv [aruyasoft@comic.com]
# † RPGRevolution.com
# † Released on: 16/06/2009
# † Version: 1.0 (June 16th 2009)
#-------------------------------------------------------------------------------
# > Changelog:
#   V.1.0 (16-06-09) = Initial release
#-------------------------------------------------------------------------------
# Particles are integrated into "Spriteset_Map, so they can be displayed
# over/under an event.
# To automatically give particle effect to an event, just write :
# [rpee#]
# to the event's comment.
# Change # with a preset Id specified in Rei Module
# Effects are also can be called from "Script" command like this:
# $scene.effect(EVENT_ID, EFFECT, LOCK, X, Y, Z)
#
# Explanation :
#
# EVENT_ID  - ID of the source the particles will flow from.
#             -1, player. Otherwise, that event ID.
# EFFECT    - Id of the effect to call. This can be set up in Rei module below.
# LOCK      - alignment of the particles. 'stay' to align particles
#             with event's map position, 'move' to align with event's screen
#             position.
#             For static events, like fireplaces, teleports, etc. 'stay' align
#             ment is recommended.
#             For moving events use 'move' mode.
# X, Y      - number of pixels that will be added to the event's position
#             to determine the starting point of particles.
# Z         - base Z coordinate of the particles, it'll be automatically added
#             or reduced based on particle's Y coordinate.
#-------------------------------------------------------------------------------
# To add your own particle effects, edit Rei module below...
#-------------------------------------------------------------------------------
# VX version is far more easier to configure!! ^.^
# See the demo for examples.
#-------------------------------------------------------------------------------
# Credits:
# arevulopapo for making this script in XP
# reijubv for porting this script to VX
#-------------------------------------------------------------------------------
# ? Installation:
# Put this script above main, setup in Rei module below
#==============================================================================
$imported = {} if $imported == nil
$imported["Rei_"+"ParticleEffect"] = true
#---------------------------------------------------------------------------
# ** Rei Module
#---------------------------------------------------------------------------
module Rei
  module Particle_Effect
    #-------------------------
    # don't remove or modify below lines!
    EFFECT = {}
    PRESET = {}
    # don't remove or modify above lines!
    #--------------------------
    PATH = "Pictures/" # Where you put the particle pictures inside
                                 # Graphics folder
    #-------------------------
    # don't remove or modify below lines!
    def self.update
    # don't remove or modify above lines!
    #--------------------------
    
    #-----------------------------------------------------------------------
    # To setup particle effects :
    #-----------------------------------------------------------------------
    # First setup the variables, then just place them like this
    # EFFECT[id] = [pic,acc,grv,opa,bld]
    # pic = Picture name of the particle
    # acc = Acceleration of the particle in x and y coordinate
    #       acc determine how far the particles will go it's source
    # grv = Gravity/weight of the particle in x and y coordinate
    #       acc will be reduced by grv at the end
    # opa = Opacity of the particle, starting opacity and it's reduction
    # bld = Blend type, 0 = normal, 1 = add, 2 = reduce
    # hue = hue of the picture, from 0 to 360
    #----------------------------------------------------------------------
    
    # Effect 1 ( blue stars )
    pic = 'star_blue'
    acc = [1.00*(-15+rand(30))/10, 1.00*(-15+rand(30))/10]
    grv = [0,0]
    opa = [160,5+rand(15)]
    bld = 1
    hue = 0
    EFFECT[1] = [pic,acc,grv,opa,bld,hue]
    # Effect 2 ( red stars )
    pic = 'star_red'
    acc = [1.00*(-15+rand(30))/10, 1.00*(-15+rand(30))/10]
    grv = [0,0]
    opa = [160,5+rand(15)]
    bld = 1
    hue = 0
    EFFECT[2] = [pic,acc,grv,opa,bld,hue]
    # Effect 3 ( green stars )
    pic = 'star_green'
    acc = [1.00*(-15+rand(30))/10, 1.00*(-15+rand(30))/10]
    grv = [0,0]
    opa = [160,5+rand(15)]
    bld = 1
    hue = 0
    EFFECT[3] = [pic,acc,grv,opa,bld,hue]
    # Effect 4 ( yellow stars )
    pic = 'star_yellow'
    acc = [1.00*(-15+rand(30))/10, 1.00*(-15+rand(30))/10]
    grv = [0,0]
    opa = [160,5+rand(15)]
    bld = 1
    hue = 0
    EFFECT[4] = [pic,acc,grv,opa,bld,hue]
    # Effect 5 ( "smash" particle )
    pic = 'smash'
    acc = [1.00*(-15+rand(30))/10, 1.00*(-15+rand(30))/10]
    grv = [0,0]
    opa = [160,5+rand(15)]
    bld = 1
    hue = 0
    EFFECT[5] = [pic,acc,grv,opa,bld,hue]
    # Effect 6 ( fire 1 )
    pic = 'particle_yellow'
    acc = [(rand(7)-3)*0.2, 0]
    grv = [0,0.15]
    opa = [255,8+rand(5)]
    bld = 1
    hue = 0
    EFFECT[6] = [pic,acc,grv,opa,bld,hue]
    # Effect 7 ( fire 2 )
    pic = 'particle_orange'
    acc = [(rand(7)-3)*0.2, 0]
    grv = [0,0.15]
    opa = [255,8+rand(5)]
    bld = 1
    hue = 0
    EFFECT[7] = [pic,acc,grv,opa,bld,hue]
    # Effect 8 ( red sparks )
    pic = 'particle_red'
    acc = [0.5*(-25+rand(50))/10, -4]
    grv = [0,-0.5]
    opa = [255,20]
    bld = 1
    hue = 0
    EFFECT[8] = [pic,acc,grv,opa,bld,hue]
    # Effect 9 ( smoke )
    pic = 'smoke'
    acc = [0.1*(-25+rand(50))/10, 0]
    grv = [0,0.13]
    opa = [128,3]
    bld = 1
    hue = 0
    EFFECT[9] = [pic,acc,grv,opa,bld,hue]
    # Effect 10 ( "cells" particle )
    pic = 'particle_red'
    dx = 1.00*(-100 + rand(200))/100 # Just to make calculation easier
    dy = 1.00*(-100 + rand(200))/100 # Just to make calculation easier
    acc = [5*dx, 5*dy]
    grv = [0.3*dx,0.3*dy]
    opa = [255,10]
    bld = 1
    hue = 0
    EFFECT[10] = [pic,acc,grv,opa,bld,hue]
    # Effect 11 ( skull )
    pic = 'skull'
    acc = [(rand(7)-3)*0.2, 0]
    grv = [0,0.25]
    opa = [255,10]
    bld = 2
    hue = 0
    EFFECT[11] = [pic,acc,grv,opa,bld,hue]
    # Add more with similiar format as those above
    
    end
    #-----------------------------------------------------------------------
    # To setup preset settings that can be used to automatically add effects
    # to event
    #-----------------------------------------------------------------------
    
                # Effect id, Lock type, X, Y , Z coordinate)
                # Effect id is those EFFECT[id] above,
                # Lock Type is either "stay" or "move"
                # X , Y , Z is coordinate
                
    PRESET[1] = [ 6, "stay", 0, 0, 0 ] # > Fireplace effect
    PRESET[2] = [ 9, "stay", 0, 0, 0 ] # > Smoke for a fireplace effect
    PRESET[3] = [ 11, "stay", 0, -24, 1 ]
    # Add more with similiar format as those above
  end
end
#==============================================================================
# ** Cache
#------------------------------------------------------------------------------
#  This module loads each of graphics, creates a Bitmap object, and retains it.
# To speed up load times and conserve memory, this module holds the created
# Bitmap object in the internal hash, allowing the program to return
# preexisting objects when the same bitmap is requested again.
#==============================================================================
module Cache
  #--------------------------------------------------------------------------
  # * Get Animation Graphic
  #     filename : Filename
  #     hue      : Hue change value
  #--------------------------------------------------------------------------
  def self.particle_engine(filename, hue)
    load_bitmap("Graphics/"+Rei::Particle_Effect::PATH, filename, hue)
  end
end
#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
#  This class deals with events. It handles functions including event page
# switching via condition determinants, and running parallel process events.
# It's used within the Game_Map class.
#==============================================================================
class Game_Event < Game_Character
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     map_id : map ID
  #     event  : event (RPG::Event)
  #--------------------------------------------------------------------------
  alias reipegemint initialize unless method_defined?('reipegemint')
  def initialize(map_id, event)
    reipegemint(map_id, event)
    @delay = 0
  end
    #---------------------------------------------------------------------------
    # * get particle effect preset
    #---------------------------------------------------------------------------
   def getparticleeffect
    if !@list.nil?
    for i in 0...@list.size - 1
      next if @list[i].code != 108
        if @list[i].parameters[0].include?("[rpee")
          list = @list[i].parameters[0].scan(/\[rpee([0-9]+)\]/)
          pe = $1.to_i
        end
      end
      return pe
    end
  end
    #---------------------------------------------------------------------------
    # * check if event has a specified comment
    #---------------------------------------------------------------------------
  def has_comment?(comment, return_comment = false )
    if !@list.nil?
      for i in 0...@list.size - 1
        next if @list[i].code != 108
          if @list[i].parameters[0].include?(comment)
            return @list[i].parameters[0] if return_comment
            return true
          end
      end
      return '' if return_comment
      return false
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias reipegemupd update unless method_defined?('reipegemupd')
  def update
    reipegemupd
    if self.has_comment?("[rpee")
      if @delay >1
        ef = Rei::Particle_Effect::PRESET[getparticleeffect][0]
        lc = Rei::Particle_Effect::PRESET[getparticleeffect][1]
        x  = Rei::Particle_Effect::PRESET[getparticleeffect][2]
        y  = Rei::Particle_Effect::PRESET[getparticleeffect][3]
        z  = Rei::Particle_Effect::PRESET[getparticleeffect][4]
        id = @event.id
        $scene.eveffect(id, ef, lc, x, y, z)
        @delay = 0
      end
      @delay +=1
    end
  end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs the map screen processing.
#==============================================================================
class Scene_Map
  def effect(event=1, effect=1, lock='stay', x=0, y=0 ,z=0)
    @spriteset.add_effect(event, effect, lock, x, y, z)
  end
  def eveffect(event=1,effect=1, lock='stay', x=0, y=0 ,z=0)
    @spriteset.add_eveffect(event, effect, lock, x, y, z)
  end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================
class Spriteset_Map
  attr_reader :particles
  alias particle_ssm_init initialize
  alias particle_ssm_update update
  alias particle_ssm_dispose dispose
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @particles = []
    particle_ssm_init
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    @particles.each{ |d| d.dispose }
    particle_ssm_dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    Rei::Particle_Effect.update
    @particles.each_with_index{ |p,i|
      @particles[i].update
      if p.opacity == 0
        p.dispose
        @particles.delete_at(i)
      end
      }
    particle_ssm_update
  end
  #--------------------------------------------------------------------------
  # * Get Character
  #     param : if -1, player. Otherwise, that event ID.
  #--------------------------------------------------------------------------
  def get_character(param)
    case param
    when -1
      object = $game_player
    else
      object = $game_map.events[param]
    end
    return object
  end
  #--------------------------------------------------------------------------
  # * Add particle effect
  #--------------------------------------------------------------------------
  def add_effect(event=1, effect=1, lock='stay', x=0, y=0 ,z=0)
    object = get_character(event)
    add_particles(object, x, y, Rei::Particle_Effect::EFFECT[effect][0],
    Rei::Particle_Effect::EFFECT[effect][1],Rei::Particle_Effect::EFFECT[effect][2],
    Rei::Particle_Effect::EFFECT[effect][3],
    lock,Rei::Particle_Effect::EFFECT[effect][4],z,
    Rei::Particle_Effect::EFFECT[effect][5])
  end
  def add_eveffect(event=1, effect=1, lock='stay', x=0, y=0 ,z=0)
    object = $game_map.events[event]
    add_particles(object, x, y, Rei::Particle_Effect::EFFECT[effect][0],
    Rei::Particle_Effect::EFFECT[effect][1],Rei::Particle_Effect::EFFECT[effect][2],
    Rei::Particle_Effect::EFFECT[effect][3],
    lock,Rei::Particle_Effect::EFFECT[effect][4],z,
    Rei::Particle_Effect::EFFECT[effect][5])
  end
  #--------------------------------------------------------------------------
  # * Add the particles
  #--------------------------------------------------------------------------
  def add_particles(object=$game_player, x=0, y=0, sprite='', acc=[0,0],
    grav=[0,0], opacity=[255,0], lock='stay', blend=0 ,z=0,hue=0)
    if lock=='stay'
      @particles << Particle_Event.new(@viewport1, object, x, y, sprite, acc,
      grav, opacity, blend,z,hue)
    elsif lock=='move'
      @particles << Particle_Screen.new(@viewport1, object, x, y, sprite, acc,
      grav, opacity, blend,z,hue)
    end
  end
end
#==============================================================================
# ** Particle_Screen
#------------------------------------------------------------------------------
#  This class is to handle particle effect that will stay on a non movable object.
#==============================================================================
class Particle_Screen < Sprite
  
  def initialize(viewport=Viewport.new(0,0,800,600), object=$game_player, x=0,
    y=0, sprite='', acc=[0,0], grav=[0,0], opacity=[255,3], blend=0,z=0,hue=0)
    super(viewport)
    self.bitmap = Cache.particle_engine(sprite,hue)
    self.x = object.screen_x + x
    self.y = object.screen_y - 16 + y
    self.ox = self.bitmap.width/2
    self.oy = self.bitmap.height/2
    self.blend_type = blend
    self.opacity = opacity[0]
    @baseZ = z
    @object = object
    @origin = [self.x, self.y]
    @acceleration = acc
    @gravity = grav
    @coords = [0.00, 0.00]
    @opacity = opacity[1]
    update
  end
  
  def update
    @acceleration[0] -= @gravity[0] if @gravity[0] != 0
    @acceleration[1] -= @gravity[1] if @gravity[1] != 0
    @coords[0] += @acceleration[0]
    @coords[1] += @acceleration[1]
    self.opacity -= @opacity
    self.x = @origin[0] + @coords[0]
    self.y = @origin[1] + @coords[1]
    if self.y > (@object.screen_y - 16)
      self.z = @baseZ + @object.screen_z + 32
    else
      self.z = @baseZ + @object.screen_z - 32
    end
  end
  
end
#==============================================================================
# ** Particle_Event
#------------------------------------------------------------------------------
#  This class is to handle particle effect that is placed on a movable object.
#==============================================================================
class Particle_Event < Sprite
  
  def initialize(viewport=Viewport.new(0,0,800,600), object=$game_player, x=0,
    y=0, sprite='', acc=[0,0], grav=[0,0], opacity=[255,3], blend=0,z=0,hue=0)
    super(viewport)
    self.bitmap = Cache.particle_engine(sprite,hue)
    self.x = object.x*32 + 16 - $game_map.display_x / 2 + x
    self.y = object.y*32 + 32 - $game_map.display_y / 2 + y
    self.ox = self.bitmap.width/2
    self.oy = self.bitmap.height/2
    self.blend_type = blend
    self.opacity = opacity[0]
    @baseZ = z
    @object = object
    @origin = [object.x*32 + x + 16, object.y*32 + y + 32]
    @acceleration = acc
    @gravity = grav
    @coords = [0.00, 0.00]
    @opacity = opacity[1]
    update
  end
  
  def update
    @acceleration[0] -= @gravity[0] if @gravity[0] != 0
    @acceleration[1] -= @gravity[1] if @gravity[1] != 0
    @coords[0] += @acceleration[0]
    @coords[1] += @acceleration[1]
    self.opacity -= @opacity
    self.x = @origin[0] + @coords[0] - $game_map.display_x / 8
    self.y = @origin[1] + @coords[1] - $game_map.display_y / 8 - 16
    if self.y > (@object.screen_y - 16)
      self.z = @baseZ + @object.screen_z + 32
    else
      self.z = @baseZ + @object.screen_z - 32
    end
  end
end
#--------------------------------------------------------------------------
# * END OF SCRIPT
#--------------------------------------------------------------------------


To launch particle effect, for example: [rpee1] as a comment in event.

Oh, and by the way... Are you taking requests? =P I really love yours scripts, and I wanted to change a little this "mix items" script, but I've done a mess....I'm suck at scripting ^^; I just need to add some windows with texts to this script. If you could help, I'll be honored. ^_~
breadlord
To fix the error put this
CODE
  def eveffect(id, ef, lc, x, y, z)
  end

in the mix items script below were it says class Scene_Mix < Scene_Base.

And ask away, I will do it to the best of my ability, but just to say I wont be taking any requests for anything to complex beacause I'm working on something thats BIG.

fizzly
QUOTE (breadlord @ Aug 15 2009, 08:15 AM) *
To fix the error put this
CODE
  def eveffect(id, ef, lc, x, y, z)
  end

in the mix items script below were it says class Scene_Mix < Scene_Base.

And ask away, I will do it to the best of my ability, but just to say I wont be taking any requests for anything to complex beacause I'm working on something thats BIG.

Okay, sure. smile.gif Thanks for help!
KPaxian
Just what I needed for my adventure game! Thanks breadlord smile.gif
I just need a little fix. If the combination is impossible the character loses the items, but I don't want that to happen. How do I fix it?

Edit: Never mind, my mistake. Great script, you'll definitely be in the credits
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.