Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Realistic Shop

Japa

Member

Can you impliment a way to put a tax on particular items?
that way, you can have trade routs in the game.
 
Hi. I'm pretty new to RPG Maker XP, but I was thinking that maybe you could modify it so that people had to use the 'Call Script' event to actually activate the script. That way, they could make several slight modifications to the script, put them as completely seperate scripts, and activate those modifications when certain conditions are met.

One way this could work is that if someone using this script has a seasons system or something like that, they could make it even more realistic by having different prices and taxes for certain items in each season. Some fish, for example, may only be in certain bodies of water at certain times, so depending on how easy they are to catch, the prices could be different. It's just a thought, but it could work...I think.
 
great script! this is perfect for my game. one thing I had to fix was the A- japanese symbol thing that appears next to the number of the amount of the items you are going to buy. just had to edit 2 messages, nothing major. So if you want to remove that at all, I'm just letting you know it's there ;)
 
Is there a way you could make it so you can see how the items selected compare to the items equipped? I'm using Guilamme777's multi-slot script, but it looks like even with the default battle system there is no way to see the difference between what is equipped and what is selected?

I know it may be hard, as a suggestion, and I have no idea how to code this, you might add another option aside from buy/sell and make it like 'try-on', and then you can't buy anything in that window but you can see how it affects you. In fact, I'm going to post this in the script request forum, maybe someone can make a patch for this.
 
Hmm... The change of database encoding when we switched servers must have messed up some of my coding. I'll change it when I get home. Thanks for pointing it out.
 
i have modified the Script to make it compatible with the my modified Version of the Advanced Shop Status Window from RPG Advocate.
the scripts can work without the other.

you can use the Animated Chars from tibuda.
if i can i will also add the Animated Icons.
enjoy it.
http://img219.imageshack.us/img219/781/shopqg8.jpg[/IMG]

Script:

Code:
#==============================================================================
#  ** MeisMe's Realistic Shop
#------------------------------------------------------------------------------
#  Created by MeisMe
#  Buxfix by Daniel
#  August 8, 2006
#  Version 2
#==============================================================================

#--------------------------------------------------------------------------
# * SDK Log
#--------------------------------------------------------------------------
SDK.log('Realistic Shop', 'MeisMe', 2.0, '')

#--------------------------------------------------------------------------
# Begin SDK Enabled Check
#--------------------------------------------------------------------------
if SDK.enabled?('Realistic Shop')
class Game_Temp
  attr_accessor :buy_rate
  attr_accessor :sell_rate
  attr_accessor :discount
  attr_accessor :tax
  attr_accessor :cart_item
  attr_accessor :cart_weapon
  attr_accessor :cart_armor
  attr_accessor :shop_type
  alias mim_shop_old_initialize initialize
  def initialize
    mim_shop_old_initialize
    @buy_rate = 100
    @sell_rate = 50
    @discount = 0
    @tax = 7
    clear_cart
    @shop_type = 0
  end
  def clear_cart
    @cart_item = {}
    @cart_weapon = {}
    @cart_armor = {}
  end
  def cart_cleared?
    if (@cart_item == {} && @cart_weapon == {} && @cart_armor == {})
      return true
    end
    return false
  end
  def item_number(item_id)
    return @cart_item.include?(item_id) ? @cart_item[item_id] : 0
  end
  def weapon_number(weapon_id)
    return @cart_weapon.include?(weapon_id) ? @cart_weapon[weapon_id] : 0
  end
  def armor_number(armor_id)
    return @cart_armor.include?(armor_id) ? @cart_armor[armor_id] : 0
  end
  def gain_item(item_id, n)
    if item_id > 0
      @cart_item[item_id] = [[item_number(item_id) + n, 0].max, 99].min
    end
  end
  def gain_weapon(weapon_id, n)
    if weapon_id > 0
      @cart_weapon[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
    end
  end
  def gain_armor(armor_id, n)
    if armor_id > 0
      @cart_armor[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
    end
  end
  def gain_items
    for i in 1..$data_items.size
      if item_number(i) > 0
        $game_party.gain_item(i, item_number(i))
      end
    end
    for i in 1..$data_weapons.size
      if weapon_number(i) > 0
        $game_party.gain_weapon(i, weapon_number(i))
      end
    end
    for i in 1..$data_armors.size
      if armor_number(i) > 0
        $game_party.gain_armor(i, armor_number(i))
      end
    end
  end
end
#==============================================================================
class Window_ShopCommand < Window_Selectable
  def initialize
    super(0, 64, 480, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    @item_max = 3
    @column_max = 3
    @commands = ["Buy", "Sell", "Exit"]
    refresh
    self.index = 0
  end
  def refresh
    self.contents.clear
    if $game_temp.shop_type == 0
      for i in 0...@item_max
      draw_item(i)
      end
    end
    if $game_temp.shop_type == 1
      self.contents.draw_text(4, 0, 324, 32, "You can only buy at this shop.")
      self.index = -1
      update_cursor_rect
    end
    if $game_temp.shop_type == 2
      self.contents.draw_text(4, 0, 324, 32, "You can only sell at this shop.")
      self.index = -1
      update_cursor_rect
    end
  end
  def draw_item(index)
    x = 4 + index * 160
    self.contents.draw_text(x, 0, 128, 32, @commands[index])
  end
  def update_cursor_rect
    if $game_temp.shop_type == 0
      super
    end
    if $game_temp.shop_type == 1 || $game_temp.shop_type == 2
      self.cursor_rect.empty
    end
  end
end
#==============================================================================
class Window_ShopBuyBG < Window_Base
  def initialize
    super(0, 128, 320, 352)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 128, 32, 'Item Name')
    self.contents.draw_text(4, 0, 284, 32, 'Marked Price', 2)
  end
end
#==============================================================================
class Window_ShopBuy < Window_Selectable
  def initialize(shop_goods)
    super(0, 160, 320, 320)
    @shop_goods = shop_goods
    refresh
    self.index = 0
    self.opacity = 0
  end
  def item
    return @data[self.index]
  end
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for goods_item in @shop_goods
      case goods_item[0]
      when 0
        item = $data_items[goods_item[1]]
      when 1
        item = $data_weapons[goods_item[1]]
      when 2
        item = $data_armors[goods_item[1]]
      end
      if item != nil
        @data.push(item)
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @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(i)
      end
    end
  end
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id) +
        $game_temp.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id) +
        $game_temp.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id) +
        $game_temp.armor_number(item.id)
    end
    price = [[item.price * $game_temp.buy_rate / 100, 9999999].min, 0].max
    if number >= 99
      self.contents.font.color = disabled_color
    else
      self.contents.font.color = normal_color
    end
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 192, y, 88, 32, price.to_s, 2)
  end
end
#==============================================================================
class Window_ShopNumber < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 128, 320, 352)
    self.contents = Bitmap.new(width - 32, height - 32)
    @item = nil
    @max = 1
    @price = 0
    @number = 1
  end
  #--------------------------------------------------------------------------
  # * Set Items, Max Quantity, and Price
  #--------------------------------------------------------------------------
  def set(item, max, price)
    @item = item
    @max = max
    @price = price
    @number = 1
    refresh
  end
  #--------------------------------------------------------------------------
  # * Set Inputted Quantity
  #--------------------------------------------------------------------------
  def number
    return @number
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_item_name(@item, 4, 96)
    self.contents.font.color = normal_color
    self.contents.draw_text(236, 96, 32, 32, "x")
    self.contents.draw_text(248, 96, 24, 32, @number.to_s, 2)
    self.cursor_rect.set(304, 96, 32, 32)
    # Draw total price and currency units
    domination = $data_system.words.gold
    cx = contents.text_size(domination).width
    total_price = @price * @number
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 160, 288-cx-4, 32, total_price.to_s, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(288-cx, 160, cx, 32, domination, 2)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    if self.active
      # Cursor right (+1)
      if Input.repeat?(Input::RIGHT) and @number < @max
        $game_system.se_play($data_system.cursor_se)
        @number += 1
        refresh
      end
      # Cursor left (-1)
      if Input.repeat?(Input::LEFT) and @number > 1
        $game_system.se_play($data_system.cursor_se)
        @number -= 1
        refresh
      end
      # Cursor up (+10)
      if Input.repeat?(Input::UP) and @number < @max
        $game_system.se_play($data_system.cursor_se)
        @number = [@number + 10, @max].min
        refresh
      end
      # Cursor down (-10)
      if Input.repeat?(Input::DOWN) and @number > 1
        $game_system.se_play($data_system.cursor_se)
        @number = [@number - 10, 1].max
        refresh
      end
    end
  end
end
#==============================================================================

class Window_ShopNumber2 < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 128, 320, 352)
    self.contents = Bitmap.new(width - 32, height - 32)
    @item = nil
    @max = 1
    @number = 1
  end
  #--------------------------------------------------------------------------
  # * Set Items, Max Quantity, and Price
  #--------------------------------------------------------------------------
  def set(item)
    @item = item
    @number = 1
    refresh
  end
  #--------------------------------------------------------------------------
  # * Set Inputted Quantity
  #--------------------------------------------------------------------------
  def number
    return @number
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_item_name(@item, 4, 96)
    case @item
    when RPG::Item
      @max = $game_temp.item_number(@item.id)
    when RPG::Weapon
      @max = $game_temp.weapon_number(@item.id)
    when RPG::Armor
      @max = $game_temp.armor_number(@item.id)
    end
    self.contents.font.color = normal_color
    self.contents.draw_text(236, 96, 32, 32, "x")
    self.contents.draw_text(248, 96, 24, 32, @number.to_s, 2)
    self.cursor_rect.set(304, 96, 32, 32)
    self.contents.draw_text(248, 128, 24, 32, "#{@max - @number}", 2)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    if self.active
      # Cursor right (+1)
      if Input.repeat?(Input::RIGHT) and @number < @max
        $game_system.se_play($data_system.cursor_se)
        @number += 1
        refresh
      end
      # Cursor left (-1)
      if Input.repeat?(Input::LEFT) and @number > 1
        $game_system.se_play($data_system.cursor_se)
        @number -= 1
        refresh
      end
      # Cursor up (+10)
      if Input.repeat?(Input::UP) and @number < @max
        $game_system.se_play($data_system.cursor_se)
        @number = [@number + 10, @max].min
        refresh
      end
      # Cursor down (-10)
      if Input.repeat?(Input::DOWN) and @number > 1
        $game_system.se_play($data_system.cursor_se)
        @number = [@number - 10, 1].max
        refresh
      end
    end
  end
end

#==============================================================================
class Window_ShopFinalize < Window_Selectable
  attr_reader :final_price
  def initialize
    super(0, 128, 320, 352)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.index = 0
    self.active = false
    @item_max = 2
    @final_price = 0
    refresh
  end
  def refresh
    @final_price = 0
    base_price = 0
    for i in 1..$data_items.size
      if $game_temp.item_number(i) > 0
        price = $game_temp.item_number(i) * $data_items[i].price
        base_price += [[price * $game_temp.buy_rate / 100, 9999999].min, 0].max
      end
    end
    for i in 1..$data_weapons.size
      if $game_temp.weapon_number(i) > 0
        price = $game_temp.weapon_number(i) * $data_weapons[i].price
        base_price += [[price * $game_temp.buy_rate / 100, 9999999].min, 0].max
      end
    end
    for i in 1..$data_armors.size
      if $game_temp.armor_number(i) > 0 
        price = $game_temp.armor_number(i) * $data_armors[i].price
        base_price += [[price * $game_temp.buy_rate / 100, 9999999].min, 0].max
      end
    end
    total_price = base_price
    discount = 0
    if $game_temp.discount != 0
      discount = [[total_price * $game_temp.discount / 100, 9999999].min, 0].max
      total_price = total_price - discount
    end
    tax = 0
    if $game_temp.tax != 0
      tax = [[total_price * $game_temp.tax / 100, 9999999].min, 0].max
    end
    total_price = total_price + tax
    self.contents.clear
    word = $data_system.words.gold
    cx = contents.text_size(word).width
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 288, 32, 'Finalize this purchase?', 1)
    self.contents.draw_text(4, 64, 128, 32, 'Price of Items:')
    self.contents.draw_text(4, 96, 128, 32, 'Sales Discount:')
    self.contents.draw_text(4, 128, 128, 32, 'Tax Added:')
    self.contents.fill_rect(4, 160, 280, 1, normal_color)
    self.contents.draw_text(4, 160, 128, 32, 'Grand Total:')
    self.contents.draw_text(0, 64, 288, 32, word, 2)
    self.contents.draw_text(0, 96, 288, 32, word, 2)
    self.contents.draw_text(0, 128, 288, 32, word, 2)
    self.contents.draw_text(0, 160, 288, 32, word, 2)
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 64, 288-cx-2, 32, base_price.to_s, 2)
    self.contents.font.color = up_color
    self.contents.draw_text(0, 96, 288-cx-2, 32, discount.to_s, 2)
    self.contents.font.color = down_color
    self.contents.draw_text(0, 128, 288-cx-2, 32, tax.to_s, 2)
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 160, 288-cx-2, 32, total_price.to_s, 2)
    self.contents.draw_text(0, 256, 288, 32, 'No', 1)
    if total_price > $game_party.gold
      self.contents.font.color = disabled_color
    end
    self.contents.draw_text(0, 224, 288, 32, 'Yes', 1)
    @final_price = total_price
  end
  def update_cursor_rect
    if self.index == 0
      cursor_rect.set(0, 224, 288, 32)
    else
      cursor_rect.set(0, 256, 288, 32)
    end
  end
end
#==============================================================================
#==============================================================================
# ** Window_ShopStatus
#------------------------------------------------------------------------------
#  This window displays number of items in possession and the actor's equipment
#  on the shop screen.
#==============================================================================

class Window_ShopStatus2 < Window_Selectable
  attr_reader :data
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(320, 128, 320, 352)
    refresh
    self.index = 0
    self.active = false
    @data = []
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add item
    for i in 1...$data_items.size
      if $game_temp.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    # Also add weapons and items if outside of battle
    for i in 1...$data_weapons.size
      if $game_temp.weapon_number(i) > 0
        @data.push($data_weapons[i])
      end
    end
    for i in 1...$data_armors.size
      if $game_temp.armor_number(i) > 0
        @data.push($data_armors[i])
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size + 1
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    if item != nil
      case item
      when RPG::Item
        number = $game_temp.item_number(item.id)
      when RPG::Weapon
        number = $game_temp.weapon_number(item.id)
      when RPG::Armor
        number = $game_temp.armor_number(item.id)
      end
      x = 4
      y = index * 32
      rect = Rect.new(x, y, self.width / @column_max - 32, 32)
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      bitmap = RPG::Cache.icon(item.icon_name)
      self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
      self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
      self.contents.draw_text(x + 240, y, 16, 32, "x", 1)
      self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
    else
      x = 4
      y = index * 32
      self.contents.font.color = @data == [] ? disabled_color :
        normal_color
      self.contents.draw_text(x, y, 288, 32, 'Finalize Purchase', 1)
    end
  end
  def item
    return @data[self.index]
  end
  def update_help
    if item != nil
      @help_window.set_text(item.description)
    else
      @help_window.set_text('Purchase all the goods in your cart.')
    end
  end
end
#==============================================================================
# ** Scene_Shop
#------------------------------------------------------------------------------
#  This class performs shop screen processing.
#==============================================================================

class Scene_Shop
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make help window
    @help_window = Window_Help.new
    # Make command window
    @command_window = Window_ShopCommand.new
    # Make gold window
    @gold_window = Window_Gold.new
    @gold_window.x = 480
    @gold_window.y = 64
    # Make dummy window
    @dummy_window = Window_Base.new(0, 128, 640, 352)
    # Make buy window
    @buy_window = Window_ShopBuy.new($game_temp.shop_goods)
    @buy_window.active = false
    @buy_window.visible = false
    @buy_window.help_window = @help_window
    @buyBG = Window_ShopBuyBG.new
    @buyBG.visible = false
    # Make sell window
    @sell_window = Window_ShopSell.new
    @sell_window.active = false
    @sell_window.visible = false
    @sell_window.help_window = @help_window
    # Make quantity input window
    @number_window = Window_ShopNumber.new
    @number_window.active = false
    @number_window.visible = false
    @number_window2 = Window_ShopNumber2.new
    @number_window2.active = false
    @number_window2.visible = false
    # Make status window
    if SDK.enabled?('Advanced Shop Status Window')
      @status_window = Window_ShopStatus.new
      @status_window.visible = false
    end
    @status_window2 = Window_ShopStatus2.new
    @status_window2.visible = false
    @status_window2.help_window = @help_window
    @finalize_window = Window_ShopFinalize.new
    @finalize_window.visible = false
    if $game_temp.shop_type == 1
      @command_window.index = 0
      @command_window.active = false
      @dummy_window.visible = false
      @buy_window.active = true
      @buy_window.visible = true
      @buyBG.visible = true
      @buy_window.refresh
      @status_window2.visible = true
    end
    if $game_temp.shop_type == 2
      @command_window.index = 1
      @command_window.active = false
      @dummy_window.visible = false
      @sell_window.active = true
      @sell_window.visible = true
      @sell_window.refresh
    end
    # 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
    @help_window.dispose
    @command_window.dispose
    @gold_window.dispose
    @dummy_window.dispose
    @buy_window.dispose
    @buyBG.dispose
    @sell_window.dispose
    @number_window.dispose
    @number_window2.dispose
    @status_window2.dispose
    @finalize_window.dispose
    $game_temp.clear_cart
    $game_temp.buy_rate = 100
    $game_temp.sell_rate = 50
    $game_temp.discount = 0
    $game_temp.shop_type = 0
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @help_window.update
    @command_window.update
    @gold_window.update
    @dummy_window.update
    @buy_window.update
    @buyBG.update
    @sell_window.update
    @number_window.update
    @number_window2.update
    @status_window2.update
    @finalize_window.update
    # If command window is active: call update_command
    if @command_window.active
      update_command
      return
    # If buy window is active: call update_buy
    elsif @buy_window.active
      update_buy
      return
    # If sell window is active: call update_sell
    elsif @sell_window.active
      update_sell
      return
    # If quantity input window is active: call update_number
    elsif @number_window.active
      update_number
      return
    elsif @status_window2.active
      update_status
    elsif @finalize_window.active
      update_finalize
    elsif @number_window2.active
      update_number2
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when command window is active)
  #--------------------------------------------------------------------------
  def update_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @command_window.index
      when 0  # buy
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Change windows to buy mode
        @command_window.active = false
        @dummy_window.visible = false
        @buy_window.active = true
        @buy_window.visible = true
        @buy_window.refresh
        @buyBG.visible = true
        @status_window2.visible = true
      when 1  # sell
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Change windows to sell mode
        @command_window.active = false
        @dummy_window.visible = false
        @sell_window.active = true
        @sell_window.visible = true
        @sell_window.refresh
      when 2  # quit
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to map screen
        $scene = Scene_Map.new
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when buy window is active)
  #--------------------------------------------------------------------------
  def update_buy
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      if $game_temp.shop_type == 1
         $scene = Scene_Map.new
         return
      end
      # Change windows to initial mode
      @command_window.active = true
      @dummy_window.visible = true
      @buy_window.active = false
      @buy_window.visible = false
      @buyBG.visible = false
      @status_window2.visible = false
      # Erase help text
      @help_window.set_text("")
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Get item
      @item = @buy_window.item
      # Get items in possession count
      case @item
      when RPG::Item
        number = $game_party.item_number(@item.id)
        number2 = $game_temp.item_number(@item.id)
      when RPG::Weapon
        number = $game_party.weapon_number(@item.id)
        number2 = $game_temp.weapon_number(@item.id)
      when RPG::Armor
        number = $game_party.armor_number(@item.id)
        number2 = $game_temp.armor_number(@item.id)
      end
      # If 99 items are already in possession
      if number + number2 >= 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 = [99, 99 - number - number2].min
      # Change windows to quantity input mode
      @buy_window.active = false
      @buy_window.visible = false
      @buyBG.visible = false
      price = [[@item.price * $game_temp.buy_rate / 100, 9999999].min, 0].max
      @number_window.set(@item, max, price)
      @number_window.active = true
      @number_window.visible = true
      if SDK.enabled?('Advanced Shop Status Window')
        @status_window2.visible = false
        @status_window.visible = true
        @status_window.active = true
        @status_window.item=nil
        @status_window.item=@item
      end      
    end
    # If RIGHT was pressed
    if Input.trigger?(Input::RIGHT) || Input.trigger?(Input::LEFT)
      $game_system.se_play($data_system.decision_se)
      @buy_window.active = false
      @status_window2.active = true
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when sell window is active)
  #--------------------------------------------------------------------------
  def update_sell
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      if $game_temp.shop_type == 2
         $game_system.se_play($data_system.cancel_se)
         $scene = Scene_Map.new
         return
      end
      # Change windows to initial mode
      @command_window.active = true
      @dummy_window.visible = true
      @sell_window.active = false
      @sell_window.visible = false
      # Erase help text
      @help_window.set_text("")
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Get item
      @item = @sell_window.item
      # If item is invalid, or item price is 0 (unable to sell)
      if @item == nil or @item.price == 0
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # 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
      # Maximum quanitity to sell = number of items in possession
      max = number
      price = [[@item.price * $game_temp.sell_rate / 100, 9999999].min, 1].max
      # Change windows to quantity input mode
      @sell_window.active = false
      @sell_window.visible = false
      @number_window.set(@item, max, price)
      @number_window.active = true
      @number_window.visible = true
      @status_window2.visible = true
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when quantity input window is active)
  #--------------------------------------------------------------------------
  def update_number
    # 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
      # Branch by command window cursor position
      case @command_window.index
      when 0  # buy
        # Change windows to buy mode
        @buy_window.active = true
        @buy_window.visible = true
        if SDK.enabled?('Advanced Shop Status Window')
          @status_window2.visible = true
          @status_window.visible = false
        end
        @buyBG.visible = true
      when 1  # sell
        # Change windows to sell mode
        @sell_window.active = true
        @sell_window.visible = true
        @status_window2.visible = false
      end
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Set quantity input window to inactive / invisible
      @number_window.active = false
      @number_window.visible = false
      if SDK.enabled?('Advanced Shop Status Window')
        @status_window2.visible = true
        @status_window.visible = false
      end        
      # Branch by command window cursor position
      case @command_window.index
      when 0  # buy
        $game_system.se_play($data_system.equip_se)
        case @item
        when RPG::Item
          $game_temp.gain_item(@item.id, @number_window.number)
        when RPG::Weapon
          $game_temp.gain_weapon(@item.id, @number_window.number)
        when RPG::Armor
          $game_temp.gain_armor(@item.id, @number_window.number)
        end
        # Refresh each window
        @gold_window.refresh
        @buy_window.refresh
        @status_window2.refresh
        # Change windows to buy mode
        @buy_window.active = true
        @buy_window.visible = true
        if SDK.enabled?('Advanced Shop Status Window')
          @status_window2.visible = true
          @status_window.visible = false
        end   
        @buyBG.visible = true
      when 1  # sell
        $game_system.se_play($data_system.shop_se)
        # Sell process
        price = [[@item.price * $game_temp.sell_rate / 100, 9999999].min, 1].max
        $game_party.gain_gold(@number_window.number * (price))
        case @item
        when RPG::Item
          $game_party.lose_item(@item.id, @number_window.number)
        when RPG::Weapon
          $game_party.lose_weapon(@item.id, @number_window.number)
        when RPG::Armor
          $game_party.lose_armor(@item.id, @number_window.number)
        end
        # Refresh each window
        @gold_window.refresh
        @sell_window.refresh
        @status_window2.refresh
        # Change windows to sell mode
        @sell_window.active = true
        @sell_window.visible = true
        @status_window2.visible = false
      end
      return
    end
  end
    def update_status
    if Input.trigger?(Input::RIGHT) || Input.trigger?(Input::LEFT)
      $game_system.se_play($data_system.decision_se)
      @buy_window.active = true
      @status_window2.active = false
    end
    if Input.trigger?(Input::C)
      if @status_window2.item == nil
        if @status_window2.data != []
          $game_system.se_play($data_system.decision_se)
          @buy_window.visible = false
          @buyBG.visible = false
          @finalize_window.visible = true
          @finalize_window.index = 0
          @finalize_window.refresh
          @finalize_window.active = true
          @status_window2.active = false
          return
        else
          $game_system.se_play($data_system.buzzer_se)
          return
        end
      else
        $game_system.se_play($data_system.decision_se)
        @status_window2.active = false
        @buy_window.visible = false
        @buyBG.visible = false
        @number_window2.set(@status_window2.item)
        @number_window2.visible = true
        @number_window2.active = true
        end
    end
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      if $game_temp.shop_type == 1
         $scene = Scene_Map.new
         return
      end
      # Change windows to initial mode
      @command_window.active = true
      @dummy_window.visible = true
      @buy_window.visible = false
      @buyBG.visible = false
      @status_window2.visible = false
      @status_window2.active = false
      # Erase help text
      @help_window.set_text("")
      return
    end
  end
  def update_finalize
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      @buy_window.visible = true
      @buy_window.active = false
      @buyBG.visible = true
      @finalize_window.visible = false
      @finalize_window.active = false
      @status_window2.active = true
      @buy_window.refresh
    end
    if Input.trigger?(Input::C)
      if @finalize_window.index == 0
        if @finalize_window.final_price > $game_party.gold
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.shop_se)
        $game_party.lose_gold(@finalize_window.final_price)
        $game_temp.gain_items
        @gold_window.refresh
        @buy_window.visible = true
        @buy_window.active = true
        @buyBG.visible = true
        @finalize_window.visible = false
        @finalize_window.active = false
        @status_window2.active = false
        $game_temp.clear_cart
        @status_window2.index = 0
        @status_window2.refresh
        @buy_window.refresh
        return
      else
        $game_system.se_play($data_system.decision_se)
        @buy_window.visible = true
        @buyBG.visible = true
        @finalize_window.visible = false
        @finalize_window.active = false
        @status_window2.active = true
        @buy_window.refresh
        return
      end
    end
  end
  def update_number2
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @buy_window.visible = true
      @buy_window.active = false
      @buyBG.visible = true
      @finalize_window.visible = false
      @finalize_window.active = false
      @status_window2.active = true
      @number_window2.visible = false
      @number_window.active = false
      @status_window2.refresh
      @buy_window.refresh
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.equip_se)
      case @status_window2.item
      when RPG::Item
        $game_temp.gain_item(@status_window2.item.id, -@number_window2.number)
      when RPG::Weapon
        $game_temp.gain_weapon(@status_window2.item.id, -@number_window2.number)
      when RPG::Armor
        $game_temp.gain_armor(@status_window2.item.id, -@number_window2.number)
      end
      @buy_window.visible = true
      @buy_window.active = false
      @buyBG.visible = true
      @finalize_window.visible = false
      @finalize_window.active = false
      @status_window2.active = true
      @number_window2.visible = false
      @number_window.active = false
      @status_window2.refresh
      @buy_window.refresh
    end
  end
end
#==============================================================================
end
#--------------------------------------------------------------------------
# End SDK Enabled Test 
#--------------------------------------------------------------------------
Code:
#==============================================================================
#  ** RPG Advocate's Advanced Shop Status Window
#------------------------------------------------------------------------------
#==============================================================================

#--------------------------------------------------------------------------
# * SDK Log
#--------------------------------------------------------------------------
SDK.log('Advanced Shop Status Window', 'RPG Advocate', 2.0, '')

#--------------------------------------------------------------------------
# Begin SDK Enabled Check
#--------------------------------------------------------------------------
if SDK.enabled?('Advanced Shop Status Window')
class Window_ShopStatus < Window_Base
    def rel(var1,var2,typ)
      if var1 > var2
        case typ
        when 0 
          return 1          
        when 1 
          return "+"         
        when 2
          return up_color
        end
      end
      if var1 < var2
        case typ
        when 0 
          return -1          
        when 1 
          return "-"         
        when 2
          return down_color
        end
      end
      if var1 = var2
        case typ
        when 0 
          return 0          
        when 1 
          return ""         
        when 2
          return normal_color
        end        
      end
    end 
  # ---------------------------------------
  def min(array)
    min=0
    for i in 0...array.size - 1
      if array[i]<array[i + 1]
        if array[i]<=array[min]
          min=i
        end
      end
    end
    return min
  end
 #--------------------------------------
  def find(array, index)#gibt position des ersten index zur?ck
    find =-1
    for i in 0...array.size
      if index == array[i]    
        return i
      end
    end
    return find 
  end
  
 #--------------------------------------
  def initialize
    if SDK.enabled?('Realistic Shop')
      super(320, 128, 320, 352)
    else
      super(368, 128, 272, 352)
    end
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    @item = nil
    refresh
  end
  # ---------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    if @item == nil
      return
    end
    case @item
    when RPG::Item
      number = $game_party.item_number(@item.id)
      kind_word = $data_system.words.item
    when RPG::Weapon
      number = $game_party.weapon_number(@item.id)
      kind_word = $data_system.words.weapon
    when RPG::Armor
      number = $game_party.armor_number(@item.id)
      @default_names = [$data_system.words.armor1,$data_system.words.armor2,$data_system.words.armor3,$data_system.words.armor4]
      if @item.kind<4
        kind_word = @default_names[@item.kind]
      elsif SDK.enabled?('Multi-slot equipment script') #Add zu Multi-slot equipment script
       @extra_slot_names = G7_MS_MOD::EXTRA_SLOT_NAMES       
        if @item.kind - 4< @extra_slot_names.size
          kind_word  = @extra_slot_names[@item.kind - 4]
        else
          kind_word = '???'
        end
      else
        kind_word = '???'
      end
    end
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 200, 32, "Possessed:")
    self.contents.draw_text(4, 15, 200, 32, "Kind:")
    self.contents.font.color = normal_color
    self.contents.draw_text(self.width - 68, 0, 32, 32, number.to_s, 2)
    self.contents.draw_text(self.width - 72, 15, 32, 32, kind_word, 2)
    $game_party.actors.each_with_index do |actor, i|
      # If equippable, then set to normal text color. If not, set to
      # invalid text color.
      new = []
      old = []
      change = []
      self.contents.font.size = $fontsize
      if SDK.enabled?('Animated Chars')
        draw_actor_graphic(actor, 15, 100 + i * 64)
        @actor_sprites[actor].visible = !@item.is_a?(RPG::Item)
        if @item.is_a?(RPG::Item)
          next
        end
        @actor_sprites[actor].animate = actor.equippable?(@item)
        if actor.equippable?(@item)
          @actor_sprites[actor].tone = Tone.new(0, 0, 0, 0)
          self.contents.font.color = normal_color
        else
          @actor_sprites[actor].frame = 0
          @actor_sprites[actor].tone = Tone.new(0, 0, 0, 255)
        end
      else
        if @item.is_a?(RPG::Item)
          next
        end
        draw_actor_name(actor, 0, 80 + i * 64)
      end
      if @item.is_a?(RPG::Weapon)
        item1 = $data_weapons[actor.weapon_id]
      elsif SDK.enabled?('Multi-slot equipment script')#Add zu Multi-slot equipment script
        item1 = $data_armors[actor.armor_ids[find(actor.armor_slots,@item.kind+1)]]
      elsif @item.kind == 0
        item1 = $data_armors[actor.armor1_id]
      elsif @item.kind == 1
        item1 = $data_armors[actor.armor2_id]
      elsif @item.kind == 2
        item1 = $data_armors[actor.armor3_id]
      else
        item1 = $data_armors[actor.armor4_id]
      end
      if actor.equippable?(@item)
        old[3] = item1 != nil ? item1.str_plus : 0
        new[3] = @item != nil ? @item.str_plus : 0
        old[4] = item1 != nil ? item1.dex_plus : 0
        new[4] = @item != nil ? @item.dex_plus : 0
        old[5] = item1 != nil ? item1.agi_plus : 0
        new[5] = @item != nil ? @item.agi_plus : 0
        old[6] = item1 != nil ? item1.int_plus : 0
        new[6] = @item != nil ? @item.int_plus : 0
        old[1] = item1 != nil ? item1.pdef : 0
        new[1] = @item != nil ? @item.pdef : 0
        old[2] = item1 != nil ? item1.mdef : 0
        new[2] = @item != nil ? @item.mdef : 0
        if @item.is_a?(RPG::Weapon)
          old[0] = item1 != nil ? item1.atk : 0
          new[0] = @item != nil ? @item.atk : 0
          old[7] = 0
          new[7] = 0
        end
        if @item.is_a?(RPG::Armor)
          old[7] = item1 != nil ? item1.eva : 0
          new[7] = @item != nil ? @item.eva : 0
          old[0] = 0
          new[0] = 0
        end
        for j in 0...7
         change[j] = new[j] - old[j] 
        end  
        if item1 == nil
          name1 = ""
        else
          name1 = item1.name
        end
        if @item == nil
          name2 = ""
        else
          name2 = @item.name
        end
        self.contents.font.size =  $fontsize
        self.contents.font.color = normal_color
        if change - [0] == [] && name1 != name2
          self.contents.draw_text(32, 54 + 64 * i, 150, 32, "No Change")
        end
        if name1 == name2
          self.contents.draw_text(32, 54 + 64 * i, 200, 32, "Currently Equipped")
        end
        self.contents.font.name = $fontface
        self.contents.font.size =  $fontsize - 2
        names = ["ATK", "PDF","MDF", "STR", "DEX", "AGI", "AGI", "EVA"]
        if @item.is_a?(RPG::Weapon) && change[0] != 0
          self.contents.font.color = normal_color      
          self.contents.draw_text(32, 42 + 64 * i, 32, 32, names[0])
          self.contents.font.color = rel(new[0],old[0],2)
          self.contents.draw_text(60, 42 + 64 * i, 4, 32, rel(new[0],old[0],1))
          self.contents.draw_text(62, 42 + 64 * i, 24, 32, change[0].abs.to_s, 2)
        end
        if @item.is_a?(RPG::Armor) && change[7] != 0
          self.contents.font.color = normal_color      
          self.contents.draw_text(32, 42 + 64 * i, 32, 32, names[j])
          self.contents.font.color = rel(new[7],old[7],2)
          self.contents.draw_text(60, 42 + 64 * i, 4, 32, rel(new[7],old[7],1))
          self.contents.draw_text(62, 42 + 64 * i, 24, 32, change[7].abs.to_s, 2)
        end      
        for j in 0...6
          if change[j] != 0
            self.contents.font.color = normal_color
            self.contents.draw_text(32+j/3*80, 42+ j%3*16 + 64 * i, 32, 32, names[j])
            self.contents.font.color = rel(new[j],old[j],2)
            self.contents.draw_text(60+j/3*80, 42+ j%3*16 + 64 * i, 4, 32,  rel(new[j],old[j],1))
            self.contents.draw_text(62+j/3*80,42+ j%3*16 + 64 * i, 24, 32, change[j].abs.to_s, 2)
          end
        end
      else
        self.contents.font.color = disabled_color
        self.contents.draw_text(32, 54 + 64 * i, 150, 32, "Cannot Equip")
      end
    end
  end
  # ---------------------------------------
  def item=(item)
    if @item != item
      @item = item
      refresh
    end
  end
  # ---------------------------------------
end
#==============================================================================
end
#--------------------------------------------------------------------------
# End SDK Enabled Test 
#--------------------------------------------------------------------------
 
Any chance to make these non-SDK? Im not too fond of the SDK and have been using many scripts that I find to be better than most of the SDK scripts I have found. As a Vulcan would say... "The needs of the many outweigh the needs of the one"
 
Gosh, I edited Scene_Shop for SDK2(yeah, hanmac's modified one), and testing it with also modified 'Advanced Shop Window', then I have this error whenever I selected any equipment(armors) at shop:
Script 'Advanced Shop Window' line 217: NoMethodError occurred.
undefined method 'abs' for nil:NilClass

Seems something's wrong with that edited 'Advanced Shop Window'.
 
nice i love the idea, but i hav one problem with it, it does not say buy sell or exit at the top. :(

P.s iam giving u cedit in my game:D:yes:
 
freds fishs;254219 said:
nice i love the idea, but i hav one problem with it, it does not say buy sell or exit at the top. :(

P.s iam giving u cedit in my game:D:yes:


That may be, because you have an illegal version of RMXP, like the Postality Knights edition (the one with a blue icon). If that's the case, downlaod the legal version at http://www.download.com and everything should work fine.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top