Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Catalogue Script v. 1.3, Allows you to keep collection logs of specified groups of items
modern algebra
post Jul 23 2007, 09:02 PM
Post #1


Level 11
Group Icon

Group: Revolutionary
Posts: 191
Type: Scripter
RM Skill: Skilled




Catalogue Script
Version: 1.3
Author: modern algebra
Date: July 20, 2007

Version History
  • v. 1.3: Added an information screen about the item. Now, you can select an item and see a breakdown of what it does. As well, added icons
  • v. 1.2: Various little design changes and aesthetic stuff. Included Ordering Tax option
  • v. 1.1: Increased it's functionality by allowing the option of ordering items from the catalogue. (not released)
  • v. 1.0: Made the basic screen. Viewable catalogue of all items collected
Description



This script allows you to set up groups of items, and then it will give you a log of all the items in that group that the party has encountered. You can have an infinite number of groups. It also allows you to order items from a catalogue at user-specified locations. As well, it gives detailed onfo on all items you have collected.

Features
  • Easily customizable groups containing any number of items, weapons, armors, or all three
  • Unlimited number of groups
  • Displays all the items in that group that have been encountered so far, as well as the price in a store
  • Has a ratio in the corner between the items encountered and total items in a group
  • Can set up an event which allows you to order items from a specified catalogue
  • Can attach an ordering tax on ordering from the catalogue of whatever you desire
  • Shows all the stats and descriptions of each and every item through a window accessible when you are not ordering.
Screenshots





It Stretches!



Script



[Show/Hide] Code Part 1
CODE
===============================================================================
# Catalogue Script
# Version: 1.4
# Author: modern algebra
# Date: July 10, 2007
#------------------------------------------------------------------------------
# Description: Allows you to have a log of all items collected and not yet
# collected.
#------------------------------------------------------------------------------
# Instructions: This script allows you to set up groups of items (items, weapons,
#               and/or armors. All types can be contained within a single group)
#               and allows you to view which of the items in that group have
#               been in your party's possession. By default, there are three
#               groups: items, weapons, armors. But you can change these and add
#               more very easily. To use, call this in a script:
#
#                    $scene = Scene_Catalogue.new (X)
#
#               where X is the group number. I'd suggest this script to be used
#               as items which call common events which have that $scene thing
#               in them. By default, it exits to the item menu. Instructions on
#               how to configure the group are at line 31
#------------------------------------------------------------------------------            
# You can also use this as a method of ordering, like from a real catalogue.
# Basically, it brings up your item log, and you can choose any of the items to
# buy. This can be useful for an Animal Crossing Game for example, but I think
# it can be useful for many types of games. In order to use this feature, use
# this call script:
#
#   $scene = Scene_Catalogue.new (X,Y)
#
# where X is the group number and Y is the ordering tax coefficient. I.e., Y is
# a number, and whatever you make that number it will multiply the price by it.
# For example, if Y = 1.15, then there will be 15% ordering tax. I.e. if an item
# costs 50 Gold in a store, then it would cost 58 Gold to order it from the
# catalogue.
#===============================================================================
#===============================================================================
# Game_Party: Aliases the gain XXX methods in order to turn the fact that you
# encountered the items on, as well as sets up the basic catalogue data
#===============================================================================
class Game_Party
  
  attr_reader   :encountered_items
  attr_reader   :catalogue
  
  alias add_encounter_items_array initialize
  def initialize
    add_encounter_items_array
    @catalogue = []
    #==========================================================================
=
    # CONFIGURABLE AREA
    #---------------------------------------------------------------------------
    # To make a group, make an array, and place each item you wish to have in
    # that group inside the array. Example:
    #
    # @catalogue.push (["Fish",[$data_items[1], $data_items[3], $data_items[32]]])
    # @catalogue.push (["Gold Items",[$data_armors[5], $data_weapons[3]]])
    #
    # That would make two groups. The first group would be called "Fish" and
    # have item 1, item 3, and item 32 in it, and the second group would be
    # called "Gold Items" and include armor 5 and weapon 3 in it.
    # By default, there are three categories, items, weapons and armors.
    #---------------------------------------------------------------------------
    # The basic set up:
    # @catalogue.push (["name", [<array of items included in the group>]])
    #
    # You can set up as many groups as you like.
    #
    # If you know how, you can also put them on the same line, like this:
    # @catalogue = [["Items",$data_items],["Weapons",$data_weapons],["Armors", $data_armors]]
    # but to keep it simple, follow the instructions. In default, items group is
    # 0, weapons group is 1, armors group is 2, and if you add another group
    # underneath, it would be 3, and so on. So, $scene = Scene_Catalogue.new (0)
    # would bring up the items log, etc...
    #==========================================================================
=
    @catalogue.push (["Item",$data_items.compact])
    @catalogue.push (["Weapon",$data_weapons.compact])
    @catalogue.push (["Armor", $data_armors.compact])
    @catalogue.push (["Key", $data_items[23,3]])
    #==========================================================================
=
    # END CONFIGURABLE AREA
    #==========================================================================
=
    @encountered_items = []
    for i in 0...3
      @encountered_items[i] = []
    end
    for i in $data_system.party_members
      actor = $data_actors[i]
      gain_weapon (actor.weapon_id,0)
      gain_armor (actor.armor1_id,0)
      gain_armor (actor.armor2_id,0)
      gain_armor (actor.armor3_id,0)
      gain_armor (actor.armor4_id,0)
    end
  end
  
  alias modify_encountered_items gain_item
  def gain_item (item_id, n)
    modify_encountered_items (item_id, n)
    if n >= 0
      for i in 0...@catalogue.size
        if @catalogue[i][1].include? ($data_items[item_id])
          @encountered_items[0][item_id] = true
        end
      end
    end
  end
  
  alias modify_encountered_weapons gain_weapon
  def gain_weapon (weapon_id, n)
    modify_encountered_weapons (weapon_id, n)
    if n >= 0
      for i in 0...@catalogue.size
        if @catalogue[i][1].include? ($data_weapons[weapon_id])
          @encountered_items[1][weapon_id] = true
        end
      end
    end
  end
  
  alias modify_encountered_armors gain_armor
  def gain_armor(armor_id, n)
    modify_encountered_armors (armor_id, n)
    if n >= 0
      for i in 0...@catalogue.size
        if @catalogue[i][1].include? ($data_armors[armor_id])
          @encountered_items[2][armor_id] = true
        end
      end
    end
  end
end  
#===============================================================================
# Draws the information screen
#===============================================================================
class Window_ItemInfo < Window_Base
  
  def initialize
    super (24, 24, 592,432)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.z = 500
    self.visible = false
  end

  def quick_write_text (x,y,text)
    tw = (self.contents.text_size(text)).width
    if tw > 95
      tw = 95
    end
    self.contents.draw_text (x-tw,y,tw+5,32,text)
  end
  
  def refresh (item)
    self.contents.clear
    case item
    when RPG::Item
      type = 0
      type_name = "Item"
    when RPG::Weapon
      type = 1
      type_name = "Weapon"
    when RPG::Armor
      type = 2
      type_name = "Armour"
    end
    self.contents.blt (93,64,RPG::Cache.icon(item.icon_name),Rect.new(0,0,24,24))
    self.contents.font.color = system_color
    self.contents.draw_text (4,96,80,32, "Type:")
    if type != 0
      self.contents.draw_text (4,128,87,32, "Equippable by:")
    end
    self.contents.draw_text (240,40,120,32,"Description:")
    quick_write_text (320,210,"Stats:")
    self.contents.draw_text (65,252,100,32,"Price:")
    if type == 1
      self.contents.draw_text (65,284,100,32,$data_system.words.atk+":")
    elsif type == 2
      self.contents.draw_text (65,284,100,32,"Evasion:")
    end
    if type != 0
      self.contents.draw_text (65,316,100,32,$data_system.words.pdef+":")
      self.contents.draw_text (65,348,100,32,$data_system.words.mdef+":")
      self.contents.draw_text (305,252,100,32,$data_system.words.str+":")
      self.contents.draw_text (305,284,100,32,$data_system.words.agi+":")
      self.contents.draw_text (305,316,100,32,$data_system.words.dex+":")
      self.contents.draw_text (305,348,100,32,$data_system.words.int+":")
    else
      self.contents.draw_text (65,284,100,32,"Occasion:")
      self.contents.draw_text (65,316,80,32,"Scope:")
      self.contents.draw_text (65,348,80,32,"Usage:")
      self.contents.draw_text (305,254,80,32,$data_system.words.hp+" Gain:")
      self.contents.draw_text (305,286,80,32,$data_system.words.sp+" Gain:")
      words = ["","Max "+$data_system.words.hp+":","Max "+$data_system.words.hp+":",
              $data_system.words.str+":", $data_system.words.agi+":",
              $data_system.words.dex+":", $data_system.words.int+":"]
      self.contents.draw_text (305,318,100,32,words[item.parameter_type])
    end
    self.contents.fill_rect (1,33,559,1,Color.new(-150,-150,-255,255))
    self.contents.fill_rect (0,34,559,1,Color.new(-255,-255,-255,255))
    self.contents.fill_rect (0,1,1,398,Color.new(-150,-150,-255,255))
    self.contents.fill_rect (1,1,1,398,Color.new(-255,-255,-255,255))
    self.contents.fill_rect (559,1,1,398,Color.new(-150,-150,-255,255))
    self.contents.fill_rect (558,1,1,398,Color.new(-255,-255,-255,255))
    self.contents.font.color = normal_color
    quick_write_text (320,0,item.name)
    quick_write_text (190,96,type_name)
    quick_write_text (285,252,item.price.to_s)
    if type == 1
      quick_write_text (285,284,item.atk.to_s)
    elsif type == 2
      quick_write_text (285,284,item.eva.to_s)
    end
    if type != 0
      quick_write_text (290,316,item.pdef.to_s)
      quick_write_text (290,348,item.mdef.to_s)
      sign = positive_num?(item.str_plus)
      quick_write_text (500,252,sign+item.str_plus.to_s)
      sign = positive_num?(item.agi_plus)
      quick_write_text (500,284,sign+item.agi_plus.to_s)
      sign = positive_num?(item.dex_plus)
      quick_write_text (500,316,sign+item.dex_plus.to_s)
      sign = positive_num?(item.int_plus)
      quick_write_text (500,348,sign+item.int_plus.to_s)
    else
      words = ["Always","In Battle","Out of Battle","Never"]
      quick_write_text (285,284,words[item.occasion])
      words = ["N/A", "One Enemy", "All Enemies", "One Ally", "All Allies",
               "One Felled Ally", "All Felled Allies", "The User"]
      quick_write_text (285,316,words[item.scope])
      if item.consumable; quick_write_text (285,348,"One Use")
      else; quick_write_text (285,348,"Unlimited Uses")
      end
      if item.recover_hp == 0 && item.recover_hp_rate == 0
        hp_recovery_string = "N/A"
      elsif item.recover_hp_rate != 0 && item.recover_hp_rate != 0
        hp_recovery_string = item.recover_hp_rate.to_s+"% + "+item.recover_hp.to_s
      elsif item.recover_hp != 0
        hp_recovery_string = item.recover_hp.to_s
      else
        hp_recovery_string = item.recover_hp_rate.to_s
      end
      quick_write_text (500,254,hp_recovery_string)
      if item.recover_sp == 0 && item.recover_sp_rate == 0
        sp_recovery_string = "N/A"
      elsif item.recover_sp_rate != 0 && item.recover_sp_rate != 0
        sp_recovery_string = item.recover_sp_rate.to_s+"% + "+item.recover_sp.to_s
      elsif item.recover_sp != 0
        sp_recovery_string = item.recover_sp.to_s
      else
        sp_recovery_string = item.recover_sp_rate.to_s
      end
      quick_write_text (500,286,sp_recovery_string)
      if item.parameter_type != 0
        quick_write_text (500,318,"+"+item.parameter_points.to_s)
      end
    end
    if type != 0
      equip_classes = []
      substring = ""
      for i in 1...$data_classes.size
        e_class = $data_classes[i]
        string = ""
        if type == 1
          test = e_class.weapon_set
        elsif type == 2
          test = e_class.armor_set
        end
        if test.include? (item.id)
          if e_class.name.size <= 4
            string = e_class.name.dup
          else
            string += e_class.name[0,1]
            for i in 1...e_class.name.size
              substring = e_class.name[i,1]
              if substring !="a"&&substring !="e"&&substring !="i"&&substring !="o"&&substring != "u"
                string +=substring
              end
            end
            if string.size > 4
              string = string[0,2]+string[string.size-2,2]
            end
          end
          equip_classes.push (string.upcase!)
        end
      end
      if equip_classes.nitems == 0
        quick_write_text (160,296,"N/A")
      else
        line_length = 0
        line_number = 0
        for i in 0...equip_classes.size
          if i != equip_classes.size - 1
            tw = (self.contents.text_size(equip_classes[i]+", ")).width
            self.contents.draw_text (90+line_length,128+line_number,tw,32,equip_classes[i]+", ")
          else
            tw = (self.contents.text_size(equip_classes[i])).width
            self.contents.draw_text (90+line_length,128+line_number,tw,32,equip_classes[i])
          end
          line_length += tw
          if line_length > 75
            line_number +=32
            line_length = -80
          end
        end
        self.contents.fill_rect (209,202,350,1,Color.new(-255,-255,-255,255))
        self.contents.fill_rect (210,201,350,1,Color.new(-150,-150,-255,255))
        if line_number > 64
          self.contents.fill_rect (209,34,1,220,Color.new(-255,-255,-255,255))
          self.contents.fill_rect (210,33,1,220,Color.new(-150,-150,-255,255))
          self.contents.fill_rect (0,254,209,1,Color.new(-255,-255,-255,255))
          self.contents.fill_rect (1,253,209,1,Color.new(-150,-150,-255,255))
        elsif line_number > 32
          self.contents.fill_rect (209,34,1,120+line_number,Color.new(-255,-255,-255,255))
          self.contents.fill_rect (210,33,1,120+line_number,Color.new(-150,-150,-255,255))
          self.contents.fill_rect (209,120+line_number,1,82-line_number,Color.new(-255,-255,-255,255))
          self.contents.fill_rect (210,120+line_number,1,82-line_number,Color.new(-150,-150,-255,255))
          self.contents.fill_rect (0,154+line_number,209,1,Color.new(-255,-255,-255,255))
          self.contents.fill_rect (1,153+line_number,209,1,Color.new(-150,-150,-255,255))
        else
          self.contents.fill_rect (209,34,1,168,Color.new(-255,-255,-255,255))
          self.contents.fill_rect (210,33,1,168,Color.new(-150,-150,-255,255))
          self.contents.fill_rect (0,202,209,1,Color.new(-255,-255,-255,255))
          self.contents.fill_rect (1,201,209,1,Color.new(-150,-150,-255,255))
        end
      end
    end
    if item.is_a? (RPG::Item)
      self.contents.fill_rect (209,34,1,170,Color.new(-255,-255,-255,255))
      self.contents.fill_rect (210,33,1,170,Color.new(-150,-150,-255,255))
      self.contents.fill_rect (0,202,559,1,Color.new(-255,-255,-255,255))
      self.contents.fill_rect (1,201,559,1,Color.new(-150,-150,-255,255))
    end
    desc = item.description
    line = []
    ts = desc.size
    line_index = 0
    limit = 0
    loop do
      line[line_index] = desc[limit, 40]
      for i in 1...40
        if line[line_index][-i,1] == " " || limit + (40-i) >= desc.size
          limit += (41-i)
          ts -= 40-i
          line_index +=1
          break
        else
          line[line_index][-i,1] = " "
        end
      end
      if ts <= 0
        break
      end
    end  
    line.compact!
    for i in 0...line.size
      self.contents.draw_text (220, 28*i + 76, 350,32, line[i])
    end
  end
  
  def positive_num? (num)
    if num > 0
      return "+"
    else
      return ""
    end
  end
end
CODE
#===============================================================================
# This window displays the ratio of collected items to total items
#===============================================================================
class Window_TotalItemsRatio < Window_Base
  
  def initialize (group_number)
    super (400,0,240,64)
    self.contents = Bitmap.new (width-32, height-32)
    @total = $game_party.catalogue[group_number][1].size
    @current = 0
    for i in 0...@total
      item = $game_party.catalogue[group_number][1][i]
      case item
      when RPG::Item; type = 0
      when RPG::Weapon; type = 1
      when RPG::Armor; type = 2
      end
      if $game_party.encountered_items[type][item.id] == true
        @current += 1
      end
    end
    if @current == @total
      self.contents.font.color = system_color
    end
    tw = (self.contents.text_size(@current.to_s + " / " + @total.to_s)).width
    self.contents.draw_text (104 - (tw/2),0,tw,32,@current.to_s + " / " + @total.to_s)
  end
end
#===============================================================================
# This window displays all collected items
#===============================================================================
class Window_Catalogue < Window_Selectable
  
  def initialize (group, price_multiplier = nil)
    super (0,128,640,352)
    @column_max = 2
    @group = $game_party.catalogue[group][1]
    @group_number = group
    @price_multiplier = price_multiplier
    refresh
  end
  
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Check inventory for new additions
    for i in 0...@group.size
      case @group[i]
      when RPG::Item; type = 0
      when RPG::Weapon; type = 1
      when RPG::Armor; type = 2
      end
      if $game_party.encountered_items[type][@group[i].id] == true
        @data.push (@group[i])
      end
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(@data[i], i)
      end
    end
  end
  
  def draw_item (item, index)
    if @price_multiplier != nil
      if $game_party.gold >= (item.price * @price_multiplier)
        self.contents.font.color = normal_color
        self.contents.draw_text ((320*(index%2))+30,(index/2)*32,200,32,item.name)
      else
        self.contents.font.color = disabled_color
        self.contents.draw_text ((320*(index%2))+30,(index/2)*32,200,32,item.name)
      end
      if item.price != 0
        tw = self.contents.text_size ((item.price * @price_multiplier).to_i.to_s)
        self.contents.draw_text (270 + (326*(index%2))-tw.width ,(index/2)*32,tw.width,32,(item.price * @price_multiplier).to_i.to_s)
      else
        tw = self.contents.text_size ("N/A")
        self.contents.draw_text (270 + (326*(index%2))-tw.width ,(index/2)*32,tw.width+10,32,"N/A")
      end
    else
      self.contents.draw_text ((320*(index%2))+30,(index/2)*32,200,32,item.name)
      if item.price != 0
        tw = self.contents.text_size (item.price.to_s)
        self.contents.draw_text (270 + (326*(index%2))-tw.width ,(index/2)*32,tw.width,32,item.price.to_s)
      else
        tw = self.contents.text_size ("N/A")
        self.contents.draw_text (270 + (326*(index%2))-tw.width ,(index/2)*32,tw.width+10,32,"N/A")
      end
    end
    self.contents.blt((320*(index%2)),(index/2)*32+4,RPG::Cache.icon(item.icon_name),Rect.new(0,0,24,24))
  end
  
  def item
    return @data[self.index]
  end
end
#===============================================================================
# This window shows how many of that type of item you possess
#===============================================================================
class Window_CurrentlyPossessed < Window_Base
  
  def initialize
    super (0,416,300,64)
    self.contents = Bitmap.new(width-32,height-32)
  end
  
  def refresh (item)
    self.contents.clear
    case item
    when RPG::Item
      quantity = $game_party.item_number (item.id)
    when RPG::Weapon
      quantity = $game_party.weapon_number (item.id)
      for actor in $game_party.actors
        if item.id == actor.weapon_id
          quantity += 1
        end
      end
    when RPG::Armor
      quantity = $game_party.armor_number (item.id)
      for actor in $game_party.actors
        if item.id == actor.armor1_id || item.id == actor.armor2_id || item.id == actor.armor3_id || item.id == actor.armor4_id
          quantity += 1
        end
      end
    end
    self.contents.font.color = system_color
    self.contents.draw_text (0, 4,300,22,"Currently Possessed:")
    self.contents.font.color = normal_color
    ts = (self.contents.text_size(quantity.to_s)).width
    self.contents.draw_text (268 - ts, 4,ts,22,quantity.to_s)
  end
end
#===============================================================================
# This window shows the price of the item with ordering tax
#===============================================================================
class Window_TotalPrice < Window_Base
  
  def initialize (price_multiplier)
    super (300,416,180,64)
    @price_multiplier = price_multiplier
    self.contents = Bitmap.new(width-32,height-32)
  end
  
  def refresh (item)
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text (0,4,100,32,"Ordering Tax:")
    if item.price > 0
      ts = (self.contents.text_size (((100*@price_multiplier)-100).to_i.to_s+"%")).width
      ts2 = (self.contents.text_size (((100*@price_multiplier)-100).to_i.to_s)).width
      self.contents.draw_text (148-ts+ts2,4,ts-ts2,32,"%")
      self.contents.font.color = normal_color
      self.contents.draw_text (146-ts,4,ts,32,((100*@price_multiplier)-100).to_i.to_s)
    else
      ts = (self.contents.text_size ("N/A")).width
      self.contents.font.color = normal_color
      self.contents.draw_text (146-ts,4,ts+10,32,"N/A")
    end
  end
end
#===============================================================================
# This window displays the name of the group being viewed
#===============================================================================
class Window_CatalogueName < Window_Base
  def initialize (group)
    super (0,0,400,64)
    self.contents = Bitmap.new(width - 32, height - 32)
    @group = $game_party.catalogue[group][0]
    self.contents.font.color = system_color
    ts = self.contents.text_size (@group + " Log")
    self.contents.draw_text (184 - 0.5*ts.width,0,ts.width,32,@group + " Log")
  end
end
#===============================================================================
# The main processing of the script
#===============================================================================
class Scene_Catalogue
  
  def initialize (group_number, price_multiplier = nil)
    @group_number = group_number
    @price_multiplier = price_multiplier
  end
  
  def main
    @name_window = Window_CatalogueName.new (@group_number)
    @help_window = Window_Help.new
    @help_window.y = 64
    if @price_multiplier!=nil
      @catalogue_window = Window_Catalogue.new (@group_number,@price_multiplier)
      @catalogue_window.height = 288
      @possession_window = Window_CurrentlyPossessed.new
      @possession_window.refresh (@catalogue_window.item)
      @gold_window = Window_Gold.new
      @gold_window.y = 416
      @gold_window.x = 480
      @totalprice_window = Window_TotalPrice.new (@price_multiplier)
      @totalprice_window.refresh (@catalogue_window.item)
      # Make quantity input window
      @number_window = Window_ShopNumber.new
      @number_window.active = false
      @number_window.visible = false
      @number_window.z = 500
      @number_window.x = 136
    else
      @catalogue_window = Window_Catalogue.new (@group_number)
      @itemdata_window = Window_ItemInfo.new
    end
    @catalogue_window.active = true
    @catalogue_window.index = 0
    @ratio_window = Window_TotalItemsRatio.new (@group_number)
    @help_window.set_text (@catalogue_window.item == nil ? "" : @catalogue_window.item.description)
    @help_window.update
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    if @price_multiplier != nil
      @number_window.dispose
      @possession_window.dispose
      @gold_window.dispose
      @totalprice_window.dispose
    else
      @itemdata_window.dispose
    end
    @ratio_window.dispose
    @catalogue_window.dispose
    @help_window.dispose
    @name_window.dispose
  end
  
  def update
    if @price_multiplier == nil && @itemdata_window.visible
      update_iteminfo
    elsif @catalogue_window.active
      catalogue_update
    elsif @number_window.active
      number_update
    end
  end
  
  def update_iteminfo
    if Input.trigger? (Input::B)
      $game_system.se_play($data_system.cancel_se)
      @itemdata_window.visible = false
      @catalogue_window.active = true
    end
  end
  
  def number_update
    @number_window.update
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Set quantity input window to inactive / invisible
      @number_window.active = false
      @number_window.visible = false
      @catalogue_window.active = true
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Play shop SE
      $game_system.se_play($data_system.shop_se)
      # Set quantity input window to inactive / invisible
      @number_window.active = false
      @number_window.visible = false
      $game_party.lose_gold((@number_window.number * @item.price * @price_multiplier).to_i)
      case @item
      when RPG::Item
        $game_party.gain_item(@item.id, @number_window.number)
      when RPG::Weapon
        $game_party.gain_weapon(@item.id, @number_window.number)
      when RPG::Armor
        $game_party.gain_armor(@item.id, @number_window.number)
      end
      # Refresh each window
      @gold_window.refresh
      @possession_window.refresh (@item)
      @catalogue_window.refresh
      @catalogue_window.active = true
    end
  end
  
  def catalogue_update
    previous_item = @catalogue_window.item
    @catalogue_window.update
    if @catalogue_window.item != previous_item
      @help_window.set_text (@catalogue_window.item == nil ? "" : @catalogue_window.item.description)
      @help_window.update
      if @price_multiplier != nil
        @possession_window.refresh (@catalogue_window.item)
        @totalprice_window.refresh (@catalogue_window.item)
      end
    end
    if Input.trigger?(Input::C)
      if @price_multiplier != nil
        @item = @catalogue_window.item
        # If item is invalid, or price is higher than money possessed, or price = 0
        if @item == nil || @item.price <= 0 || $game_party.gold < (@item.price*@price_multiplier).to_i
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Get items in possession count
        case @item
        when RPG::Item
          number = $game_party.item_number(@item.id)
        when RPG::Weapon
          number = $game_party.weapon_number(@item.id)
        when RPG::Armor
          number = $game_party.armor_number(@item.id)
        end
        # If 99 items are already in possession
        if number == 99
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Calculate maximum amount possible to buy
        max = (@item.price * @price_multiplier).to_i == 0 ? 99 : $game_party.gold / (@item.price * @price_multiplier).to_i
        max = [max, 99 - number].min
        # Change windows to quantity input mode
        @catalogue_window.active = false
        @number_window.set(@item, max, (@item.price * @price_multiplier).to_i)
        @number_window.active = true
        @number_window.visible = true
      else
        @itemdata_window.refresh (@catalogue_window.item)
        @catalogue_window.active = false
        @itemdata_window.visible = true
      end
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      if @price_multiplier == nil
        $scene = Scene_Item.new
      else
        $scene = Scene_Map.new
      end
      return
    end
  end
end


Credit
  • modern algebra
Thanks
  • zzzdude, for the request
Support


I am willing to rectify any incompatibility issues and fix any bugs. Unless it is a very interesting request, I will not add major features to this upon one user's request, though if many people want it I will do it. I will provide support for this script at rmrk.net, and also here, if I become active. Your best bet is to go to this topic for support though: http://rmrk.net/index.php/topic,18932.0.html. If this script is posted elsewhere (besides rrrevolution, rmrk, or rmrevolution.rmrk.net), I am not aware of it and as such, am not able to provide support. On that note, please don't steal my script.

Known Compatibility Issues


It will not work with any script which overwrites Window_Gold or Window_ShopNumber
It will not initialize for old savefiles.

Demo


http://www.sendspace.com/file/6tn2a2

This post has been edited by Night_Runner: Oct 12 2010, 04:10 AM
Go to the top of the page
 
+Quote Post
   
Guest_Black Shadow_*
post Jul 25 2007, 02:57 AM
Post #2





Guests





Interesting script. Is it something you aren't good at Algebra?O_o
Go to the top of the page
 
+Quote Post
   
modern algebra
post Jul 25 2007, 08:18 AM
Post #3


Level 11
Group Icon

Group: Revolutionary
Posts: 191
Type: Scripter
RM Skill: Skilled




eh? I'm not sure I understand
Go to the top of the page
 
+Quote Post
   
TheSilentOne
post Jul 25 2007, 03:27 PM
Post #4


Level 10
Group Icon

Group: Revolutionary
Posts: 156
Type: None
RM Skill: Beginner




Nice script. I could see a good use for this. You have your regular shops, but then you got little catalogues as well. Very cool. Will check for any bugs soon. Nice to see an original script thats not released on RMXP.org, kinda shocking really. tongue.gif
Go to the top of the page
 
+Quote Post
   
modern algebra
post Jul 25 2007, 03:58 PM
Post #5


Level 11
Group Icon

Group: Revolutionary
Posts: 191
Type: Scripter
RM Skill: Skilled




Thanks for the compliment. Hopefully you won't find any bugs. As for .org, I've had... bad experiences there smile.gif For future reference, don't believe Erk when he says he has candy tongue.gif

Oh, and if you want to see scripts not on .org, check out Blizzard. He's written tons of scripts, but he has a severe dislike for .org for some reason. In any case, it's a good script resource.

Also, I don't know why, but the code is corrupted and has little & nbsp; thingys in front of some of the comments. Either quote the post and take it from the quote, or remove them manually to get it working. I fixed it I think, there might be a few more lurking around. It came from spacing the #============ bars

This post has been edited by modern algebra: Jul 25 2007, 04:18 PM
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 24th May 2013 - 07:13 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker