KustomPriceShop XP
#1
KustomPriceShop XP

by Kyonides

Introduction

This script allows you to open a special shop on a given map that offers:
  • Setting custom (buy or sale) prices for specific items.
  • Setting certain goods as highly undesirable, making the party lose friendship points at that shop.
  • Rewarding loyal customers with free gifts if they buy a given amount of items or weapons or armors.
  • Creating buy-only or sell-only shops.

To keep it separate from normal shops, set the shop's ID via a game variable.

You can change the maximum number of units per item allowed in your game.

Leaving the shop without doing anything will decrease the shop's friendship points by 1 (default value).
Purchases and sales will increase those points in no time! Shocked

It also lets you to set a backdrop as well instead of the current map.

SCREENSHOTS

Optional Script Calls For The Active Shop

NOTE: ItemID stands for an actual positive number, starting from 1 onwards.

Add Items with Custom Prices:
Code:
buy_price_items(ItemID1 => Price1, etc.)
sell_price_items(ItemID1 => Price1, etc.)

Add Weapons with Custom Prices:
Code:
buy_price_weapons(WeaponID1 => Price1, etc.)
sell_price_weapons(WeaponID1 => Price1, etc.)

Add Armors with Custom Prices:
Code:
buy_price_armors(ArmorID1 => Price1, etc.)
sell_price_armors(ArmorID1 => Price1, etc.)

Change Custom Price Shop's Friendship Points - Number stands for any number, either positive or negative.
Code:
price_shop_friend_points(Number)

Set Minimum Friendship Level for Certain Items, Weapons or Armors - Types: 0 - Item, 1 - Weapon, 2 - Armor
Code:
price_shop_friendship_min(Mininum, Type, ItemID1, etc.)

Set the Lowest Level The Friendship Points can reach: Number should be equal to 0 or less.
Code:
price_shop_friend_floor(Number)

Change Custom Price Shop's No Transaction Penalty - Number stands for 0 or any positive number. Default Value: 1.
Code:
price_shop_set_no_action_penalty(Number)

Reward Your Loyal Customers with Items:
Code:
buy_gifts_items(ItemID, ItemsMin, GiftItemID, Number)

Reward Your Loyal Customers with Weapons:
Code:
buy_gifts_weapons(ItemID, ItemsMin, GiftItemID, Number)

Reward Your Loyal Customers with Armors:
Code:
buy_gifts_armors(ItemID, ItemsMin, GiftItemID, Number)

Punish the Player for Selling the "Wrong" Items: LostPoints stands for 1 or above.
Code:
sell_price_wrong_items(ItemID1 => LostPoints, etc.)

Punish the Player for Selling the "Wrong" Weapons:
Code:
sell_price_wrong_weapons(WeaponID1 => LostPoints, etc.)

Punish the Player for Selling the "Wrong" Armors:
Code:
sell_price_wrong_armors(ArmorID1 => LostPoints, etc.)

The Script

Code:
# * KustomPriceShop XP * #
#   Scripter : Kyonides
#   v1.0.0 - 2026-05-23

# Create a special shop that offers:
# - Setting custom prices for specific items.
# - Setting certain goods as highly undesirable, making the party lose
#   friendship points at that shop.
# - Rewarding loyal customers with free gifts if they buy a given amount of
#   items or weapons or armors.
# - Creating purchase-only or sell-only shops.

# To keep it separate from normal shops, set the shop's ID via a game variable.
# You can change the maximum number of units per item allowed in your game.
# It also allows you to set a backdrop as well instead of the current map.
# Leaving the shop without doing anything will decrease the shop's friendship
# points by 1 (default value).

# * Optional Script Calls For The Active Shop * #

# - Add Items with Custom Prices:
# buy_price_items(ItemID1 => Price1, etc.)
# sell_price_items(ItemID1 => Price1, etc.)

# - Add Weapons with Custom Prices:
# buy_price_weapons(WeaponID1 => Price1, etc.)
# sell_price_weapons(WeaponID1 => Price1, etc.)

# - Add Armors with Custom Prices:
# buy_price_armors(ArmorID1 => Price1, etc.)
# sell_price_armors(ArmorID1 => Price1, etc.)

# - Change Custom Price Shop's Friendship Points:
#   Number stands for any number, either positive or negative.
# price_shop_friend_points(Number)

# - Set Minimum Friendship Level for Certain Items, Weapons or Armors:
#   Types: 0 - Item, 1 - Weapon, 2 - Armor
# price_shop_friendship_min(Mininum, Type, ItemID1, etc.)

# - Set the Lowest Level The Friendship Points can reach: 0 or less.
# price_shop_friend_floor(Number)

# - Change Custom Price Shop's No Transaction Penalty:
#   Number stands for 0 or any positive number. Default Value: 1.
# price_shop_set_no_action_penalty(Number)

# - Reward Your Loyal Customers with Items:
# buy_gifts_items(ItemID, ItemsMin, GiftItemID, Number)

# - Reward Your Loyal Customers with Weapons:
# buy_gifts_weapons(ItemID, ItemsMin, GiftItemID, Number)

# - Reward Your Loyal Customers with Armors:
# buy_gifts_armors(ItemID, ItemsMin, GiftItemID, Number)

# - Punish the Player for Selling the Wrong Items:
# sell_price_wrong_items(ItemID1 => LostPoints, etc.)

# - Punish the Player for Selling the Wrong Weapons:
# sell_price_wrong_weapons(WeaponID1 => LostPoints, etc.)

# - Punish the Player for Selling the Wrong Armors:
# sell_price_wrong_armors(ArmorID1 => LostPoints, etc.)

module KustomPrice
  ITEM_MAX = 99
  BUY_ONLY_SWITCH  = 8
  SELL_ONLY_SWITCH = 9
  SHOP_ID_VAR = 10
  DEFAULT_BACKDROP = "012-PortTown02"
  FRIENDSHIP_LEVEL = "Friendship Level: %s"
  SPECIAL_REWARDS  = "Special Rewards"

  class Shop
    class Gifts
      def initialize(item_min, item_id, n)
        @item_min = item_min
        @item_id = item_id
        @amount = n
      end
      attr_reader :item_min, :item_id, :amount
    end

    def initialize
      @friendship = 0
      @friendship_floor = 0
      @no_action_penalty = 1
      @friendship_min = {}
      @buy_prices = {}
      @sell_prices = {}
      @buy_item_max = {}
      @sell_item_max = {}
      @buy_gifts = {}
      @sell_wrong_goods = {}
      @friendship_min.default = {}
      @buy_prices.default = {}
      @sell_prices.default = {}
      @buy_gifts.default = {}
      @sell_wrong_goods.default = {}
      @buy_item_max.default = ITEM_MAX
      @sell_item_max.default = ITEM_MAX
    end

    def friendship=(n)
      @friendship = [@friendship + n, @friendship_floor].max
    end

    def no_action_penalty!
      self.friendship -= @no_action_penalty
    end

    def frienship_min(mininum, type, *items)
      fmin = @friendship_min[type]
      items.flatten.each {|n| fmin[n] = mininum }
      mininum
    end

    def set_buy_prices(type, data={})
      @buy_prices[type].merge!(data)
    end

    def set_sell_prices(type, data={})
      @sell_prices[type].merge!(data)
    end

    def set_buy_gifts(type, parent_id, item_min, item_id, n)
      @buy_gifts[type][parent_id] = Gifts.new(item_min, item_id, n)
    end

    def sell_wrong_goods(type, data={})
      @sell_wrong_goods[type].merge!(data)
    end
    attr_reader :friendship, :friendship_floor, :friendship_min
    attr_reader :buy_prices, :sell_prices, :buy_gifts
    attr_reader :buy_item_max, :sell_item_max, :sell_wrong_goods
    attr_accessor :goods, :no_action_penalty
  end
end

class Game_System
  alias :kyon_kp_shop_gm_sys_init :initialize
  def initialize
    kyon_kp_shop_gm_sys_init
    reset_price_shop_id!
    @custom_price_shops = {}
  end

  def reset_price_shop_id!
    @price_shop_id = 0
  end

  def init_price_shop(shop_id)
    @price_shop_id = shop_id
    @custom_price_shops[shop_id] ||= KustomPrice::Shop.new
  end

  def setup_price_shop(shop_id, new_goods)
    shop = @custom_price_shops[shop_id]
    shop.goods = new_goods
  end

  def this_price_shop
    @custom_price_shops[@price_shop_id]
  end
  attr_reader :custom_price_shops
end

class Game_Party
  def bag_items
    @items
  end

  def bag_weapons
    @weapons
  end

  def bag_armors
    @armors
  end

  def compact_bag_items!
    @items.delete_if {|k,v| v == 0 }
    @weapons.delete_if {|k,v| v == 0 }
    @armors.delete_if {|k,v| v == 0 }
  end
end

class Window_ShopCommand
  def reset_disabled_items
    @disabled = []
  end

  def disable_current_item?
    @disabled[@index]
  end
end

module KustomPrice
  module AddMethods
    def item
      @data[@index] || @no_item
    end

    def price
      @prices[@index] || 0
    end

    def type
      @types[@index] || 0
    end

    def get_price(n, item_id, price)
      case @types[n]
      when 0
        @item_prices[item_id] || price
      when 1
        @weapon_prices[item_id] || price
      when 2
        @armor_prices[item_id] || price
      end
    end
  end

class ShopBuyWindow < Window_Selectable
  include AddMethods
  attr_accessor :shop_goods
  def initialize(shop, shop_goods)
    w = 368
    @tw = w - 64
    super(0, 288, w, 192)
    sp = shop.buy_prices
    @item_prices   = sp[0]
    @weapon_prices = sp[1]
    @armor_prices  = sp[2]
    @shop_goods = shop_goods.dup
    @no_item = RPG::Item.new
    @transparent = Color.new(0, 0, 0, 0)
    @symbol_color = Color.new(255, 255, 80)
    @symbol = $data_system.words.gold
    refresh
    self.index = 0
  end

  def item_name
    self.item.name
  end

  def set_goods(goods_item)
    type, goods_id = goods_item
    case type
    when 0
      [type, $data_items[goods_id]]
    when 1
      [type, $data_weapons[goods_id]]
    when 2
      [type, $data_armors[goods_id]]
    end
  end

  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @types = []
    @data = []
    @prices = []
    for goods_item in @shop_goods
      type, item = set_goods(goods_item)
      next unless item
      n = @types.size
      @types << type
      @data << item
      @prices << get_price(n, item.id, item.price)
    end
    draw_items
  end

  def draw_items
    @item_max = @data.size
    self.contents = Bitmap.new(width - 32, row_max * 32) if @item_max > 0
    @item_max.times {|i| draw_item(i) }
  end

  def clear_line(rx, ry)
    rect = Rect.new(rx, ry, self.width - 32, 32)
    self.contents.fill_rect(rect, @transparent)
  end

  def draw_item(n)
    item = @data[n]
    font = self.contents.font
    price = @prices[n]
    if $game_party.gold >= price
      font.color = normal_color
      alpha = 255
    else
      font.color = disabled_color
      alpha = 128
    end
    ry = n * 32
    clear_line(4, ry)
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.blt(28, ry + 4, bitmap, Rect.new(0, 0, 24, 24), alpha)
    self.contents.draw_text(56, ry, @tw - 100, 32, item.name)
    self.contents.draw_text(@tw - 92, ry, 100, 32, price.to_s, 2)
    @symbol_color.alpha = alpha
    font.color = @symbol_color
    self.contents.draw_text(@tw, ry, 24, 32, @symbol, 2)
  end

  def update_help
    @help_window.set_text(self.item.description)
  end

  def delete_item
    @shop_goods.delete(@index)
    item = @data.delete(@index)
    self.contents.dispose if self.contents != nil
    self.contents = nil
    draw_items
  end

  def disable_item(n)
    draw_item(n, disabled_color)
    @disabled[n] = true
  end
end

class ShopSellWindow < Window_Selectable
  include AddMethods
  def initialize(shop)
    super(0, 128, 640, 352)
    @column_max = 2
    @no_item = RPG::Item.new
    sp = shop.sell_prices
    @item_prices   = sp[0]
    @weapon_prices = sp[1]
    @armor_prices  = sp[2]
    refresh
    self.index = 0
  end

  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @types = []
    @data = []
    @prices = []
    n = 0
    $game_party.bag_items.sort.each do |k,v|
      next if $game_party.item_number(k) == 0
      @types << 0
      @data << obj = $data_items[k]
      @prices << get_price(n, k, obj.price / 2)
      n += 1
    end
    $game_party.bag_weapons.sort.each do |k,v|
      next if $game_party.weapon_number(i) == 0
      @types << 1
      @data << obj = $data_weapons[k]
      @prices << get_price(n, k, obj.price / 2)
      n += 1
    end
    $game_party.bag_armors.sort.each do |k,v|
      next if $game_party.armor_number(i) == 0
      @types << 2
      @data << obj = $data_armors[k]
      @prices << get_price(n, k, obj.price / 2)
      n += 1
    end
    @item_max = @data.size
    return if @item_max == 0
    self.contents = Bitmap.new(width - 32, row_max * 32)
    @item_max.times {|n| draw_item(n) }
  end

  def draw_item(n)
    item = @data[n]
    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
    price = @prices[n]
    if price > 0
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + n % 2 * (288 + 32)
    y = n / 2 * 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 + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end

  def update_help
    @help_window.set_text(self.item.description)
  end
end

class ShopGiftWindow < Window_Selectable
  def initialize
    super(160, 144, 320, 128)
    @w = width - 32
    @h = height - 32
    @types = []
    @gifts = []
    @amounts = []
    @pages = 0
    @index = 0
  end

  def set_gifts(list)
    list.each do |type, gift, n|
      @types << type
      @gifts << gift
      @amounts << n
    end
    @pages = list.size
    refresh
  end

  def change_page(n)
    return if @pages == 1
    @index = (@index + n) % @pages
    refresh
  end

  def refresh
    page = @index + 1
    label = "Page " + page.to_s + "/" + @pages.to_s
    n = @amounts[@index]
    b = Bitmap.new(@w, @h)
    font = b.font
    font.color = system_color
    b.draw_text(0, 0, @w, 32, SPECIAL_REWARDS, 1)
    good = get_good
    font.color = normal_color
    b.draw_text(0, 32, @w, 32, good.name)
    b.draw_text(0, 32, @w, 32, n.to_s, 2)
    b.draw_text(0, 64, @w, 32, label, 2)
    self.contents = b
  end

  def get_good
    item_id = @gifts[@index]
    case @types[@index]
    when 0
      return $data_items[item_id]
    when 1
      return $data_weapons[item_id]
    when 2
      return $data_armors[item_id]
    end
  end
end

end

class Interpreter
  alias :kyon_kp_shop_int_chng_vars :command_122
  def command_122
    kyon_kp_shop_int_chng_vars
    var_id = @parameters[0]
    return unless KustomPrice::SHOP_ID_VAR == var_id
    var_id = @parameters[4]
    @price_shop = $game_system.init_price_shop(var_id)
  end

  def price_shop_friend_points(n)
    @price_shop.friendship += n
  end

  def price_shop_friend_floor(n)
    @price_shop.friendship_floor = n
  end

  def price_shop_friendship_min(min, type, *items)
    @price_shop.frienship_min(min, type, *items)
  end

  def price_shop_set_no_action_penalty(n)
    @price_shop.no_action_penalty = n
  end

  def buy_price_items(data={})
    @price_shop.set_buy_prices(0, data)
  end

  def buy_price_weapons(data={})
    @price_shop.set_buy_prices(1, data)
  end

  def buy_price_armors(data={})
    @price_shop.set_buy_prices(2, data)
  end

  def sell_price_items(data={})
    @price_shop.set_sell_prices(0, data)
  end

  def sell_price_weapons(data={})
    @price_shop.set_sell_prices(1, data)
  end

  def sell_price_armors(data={})
    @price_shop.set_sell_prices(2, data)
  end

  def buy_gifts_items(item_id, item_min, gift_item_id, n)
    @price_shop.set_buy_gifts(0, item_id, item_min, gift_item_id, n)
  end

  def buy_gifts_weapons(item_id, item_min, gift_item_id, n)
    @price_shop.set_buy_gifts(1, item_id, item_min, gift_item_id, n)
  end

  def buy_gifts_armors(item_id, item_min, gift_item_id, n)
    @price_shop.set_buy_gifts(2, item_id, item_min, gift_item_id, n)
  end
 
  def sell_price_wrong_items(data={})
    @price_shop.sell_wrong_goods(0, data)
  end

  def sell_price_wrong_weapons(data={})
    @price_shop.sell_wrong_goods(1, data)
  end

  def sell_price_wrong_armors(data={})
    @price_shop.sell_wrong_goods(2, data)
  end
end

class Scene_Map
  def call_shop
    $game_temp.shop_calling = false
    $game_player.straighten
    shop_var = KustomPrice::SHOP_ID_VAR
    if $game_variables[shop_var] != 0
      $scene = PriceShopScene.new
    else
      $scene = Scene_Shop.new
    end
  end
end

class PriceShopScene < Scene_Shop
  include KustomPrice
  def find_shop_id
    $game_variables[SHOP_ID_VAR]
  end

  def main
    prepare_goods
    make_backdrop
    make_windows
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    dispose_windows
    reset_price_shop
  end

  def prepare_goods
    $game_party.compact_bag_items!
    @transactions = 0
    @shop_id = find_shop_id
    @shop = $game_system.this_price_shop
    @fp = @shop.friendship
    @fp_min = @shop.friendship_min
    @goods = @shop.goods || $game_temp.shop_goods
    setup_friendly_goods
  end

  def setup_friendly_goods
    @gifts = []
    @shop_goods = []
    @goods.each do |type, obj_id|
      group = @fp_min[type]
      level = group[obj_id] || 0
      @shop_goods << [type, obj_id] if level == 0 or level <= @fp
    end
    @exclude_goods = @shop_goods.size != @goods.size
  end

  def make_backdrop
    @backdrop = Sprite.new
    @backdrop.bitmap = RPG::Cache.battleback(DEFAULT_BACKDROP)
  end

  def make_windows
    @help_window = Window_Help.new
    show_friendship_level
    @command_window = Window_ShopCommand.new
    @command_window.reset_disabled_items
    @command_window.disable_item(0) if $game_switches[SELL_ONLY_SWITCH]
    @command_window.disable_item(1) if $game_switches[BUY_ONLY_SWITCH]
    @gold_window = Window_Gold.new
    @gold_window.x = 480
    @gold_window.y = 64
    @dummy_window = Window_Base.new(0, 288, 640, 192)
    @buy_window = ShopBuyWindow.new(@shop, @shop_goods)
    @buy_window.active = false
    @buy_window.visible = false
    @buy_window.help_window = @help_window
    @sell_window = ShopSellWindow.new(@shop)
    @sell_window.active = false
    @sell_window.visible = false
    @sell_window.help_window = @help_window
    @number_window = Window_ShopNumber.new
    @number_window.active = false
    @number_window.visible = false
    @status_window = Window_ShopStatus.new
    @status_window.visible = false
    @gift_window = ShopGiftWindow.new
    @gift_window.visible = false
  end

  def show_friendship_level
    points = @shop.friendship.to_s
    points = sprintf(FRIENDSHIP_LEVEL, points)
    @help_window.set_text(points)
  end

  def update
    if @show_gifts
      update_show_gifts
      return
    end
    super
  end

  def update_show_gifts
    if Input.trigger?(Input::B) or Input.trigger?(Input::C)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return @show_gifts = nil
    elsif Input.trigger?(Input::LEFT)
      $game_system.se_play($data_system.cursor_se)
      @gift_window.change_page(-1)
      return
    elsif Input.trigger?(Input::RIGHT)
      $game_system.se_play($data_system.cursor_se)
      @gift_window.change_page(1)
    end
  end

  def update_command
    if Input.trigger?(Input::B)
      if @get_gifts
        $game_system.se_play($data_system.shop_se)
        @command_window.index = -1
        @gift_window.set_gifts(@gifts)
        @gift_window.visible = true
        Graphics.screenshot
        @get_gifts = nil
        return @show_gifts = true
      else
        $game_system.se_play($data_system.cancel_se)
        $scene = Scene_Map.new
      end
      return
    elsif Input.trigger?(Input::C)
      if @command_window.disable_current_item?
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      case @command_window.index
      when 0
        open_purchase
      when 1
        open_sale
      when 2
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Map.new
      end
    end
  end

  def open_purchase
    $game_system.se_play($data_system.decision_se)
    @command_window.active = false
    @dummy_window.visible = false
    @buy_window.active = true
    @buy_window.visible = true
    @buy_window.refresh
    @status_window.visible = true
  end

  def open_sale
    $game_system.se_play($data_system.decision_se)
    @command_window.active = false
    @dummy_window.visible = false
    @sell_window.active = true
    @sell_window.visible = true
    @sell_window.refresh
  end

  def update_buy
    @status_window.item = @buy_window.item
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @dummy_window.visible = true
      @buy_window.active = false
      @buy_window.visible = false
      @status_window.visible = false
      @status_window.item = nil
      show_friendship_level
      return
    elsif Input.trigger?(Input::C)
      @item = @buy_window.item
      price = @buy_window.price
      if @item == nil or $game_party.gold < price
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      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 ITEM_MAX == number
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      max = price == 0 ? ITEM_MAX : $game_party.gold / price
      max = [max, ITEM_MAX - number].min
      @buy_window.active = false
      @buy_window.visible = false
      @number_window.set(@item, max, price)
      @number_window.active = true
      @number_window.visible = true
    end
  end

  def update_sell
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @dummy_window.visible = true
      @sell_window.active = false
      @sell_window.visible = false
      @status_window.item = nil
      show_friendship_level
      return
    elsif Input.trigger?(Input::C)
      @item = @sell_window.item
      @status_window.item = @item
      price = @sell_window.price
      if @item == nil or price == 0
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      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
      total = number
      @sell_window.active = false
      @sell_window.visible = false
      @number_window.set(@item, total, price)
      @number_window.active = true
      @number_window.visible = true
      @status_window.visible = true
    end
  end

  def update_number
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @number_window.active = false
      @number_window.visible = false
      case @command_window.index
      when 0  # buy
        @buy_window.active = true
        @buy_window.visible = true
      when 1  # sell
        @sell_window.active = true
        @sell_window.visible = true
        @status_window.visible = false
      end
      return
    elsif Input.trigger?(Input::C)
      $game_system.se_play($data_system.shop_se)
      @number_window.active = false
      @number_window.visible = false
      item_id = @item.id
      n = @number_window.number
      @transactions += n
      case @command_window.index
      when 0  # buy
        update_number_buy(item_id, n)
        return
      when 1  # sell
        type = @sell_window.type
        lost_points = @shop.sell_wrong_goods[type][item_id] || 0
        if lost_points > 0
          @shop.friendship -= lost_points * n
        else
          @shop.friendship += n
        end
        price = @sell_window.price
        $game_party.gain_gold(n * price)
        case @item
        when RPG::Item
          $game_party.lose_item(item_id, n)
        when RPG::Weapon
          $game_party.lose_weapon(item_id, n)
        when RPG::Armor
          $game_party.lose_armor(item_id, n)
        end
        @gold_window.refresh
        @sell_window.refresh
        @status_window.refresh
        @sell_window.active = true
        @sell_window.visible = true
        @status_window.visible = false
      end
    end
  end

  def update_number_buy(item_id, n)
    @shop.friendship += n
    price = @buy_window.price
    $game_party.lose_gold(n * price)
    case @item
    when RPG::Item
      type = 0
      $game_party.gain_item(item_id, n)
    when RPG::Weapon
      type = 1
      $game_party.gain_weapon(item_id, n)
    when RPG::Armor
      type = 2
      $game_party.gain_armor(item_id, n)
    end
    @gold_window.refresh
    if @shop.friendship != @fp
      @fp = @shop.friendship
      setup_friendly_goods
      @buy_window.shop_goods = @shop_goods
    end
    @buy_window.refresh
    @status_window.refresh
    @buy_window.active = true
    @buy_window.visible = true
    gifts_list = @shop.buy_gifts[type]
    gift = gifts_list[item_id]
    if gift and gift.item_min <= n
      item_id = gift.item_id
      total = n / gift.item_min * gift.amount
      case type
      when 0
        $game_party.gain_item(item_id, total)
      when 1
        $game_party.gain_weapon(item_id, total)
      when 2
        $game_party.gain_armor(item_id, total)
      end
      @gifts << [type, item_id, total]
      @get_gifts = true
    end
  end

  def dispose_windows
    @backdrop.bitmap.dispose
    @backdrop.dispose
    @help_window.dispose
    @command_window.dispose
    @gold_window.dispose
    @dummy_window.dispose
    @buy_window.dispose
    @sell_window.dispose
    @number_window.dispose
    @status_window.dispose
    @gift_window.dispose
  end

  def reset_price_shop
    $game_variables[SHOP_ID_VAR] = 0
    $game_switches[BUY_ONLY_SWITCH] = false
    $game_switches[SELL_ONLY_SWITCH] = false
    $game_party.compact_bag_items!
    @shop.no_action_penalty! if @transactions == 0
    list = @buy_window.shop_goods
    if !@exclude_goods and list.size != @shop_goods.size
      $game_system.setup_price_shop(@shop_id, list)
    end
    $game_system.reset_price_shop_id!
  end
end

Terms & Conditions

Free as in Beer beer.
Mention me in your game credits.
You may also add the forum's name and URL there.
That's it! Tongue sticking out
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply
#2
Script Update!

Version 0.11.0 has been released today! Two Thumbs Up! 

The script now implements a very simple shop friendship aka affinity system.

Leaving the shop without doing anything will decrease the shop's friendship points by 1 (default value). Confused
Cash Purchases and sales will certainly increase those points in no time! [Image: shocked.gif] 
The no transaction penalty is customizable. Winking 
They will force the shop to update its list of available goods in real time! Grinning
The only caveat is that it will only alter the shop's list of goods you can buy only. Tongue sticking out

I also had to rewrite code to make all of this very shop-specific by default. Happy with a sweat
Everything will be stored in the Game_System class.

NOTE: You must always set the Shop's ID before setting up the shop's list of goods via the corresponding event command.
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply
#3
Script Update!

Version 0.12.0 has been published today! Shocked

The latest feature is very simple: you as the game developer can set a list of "wrong" items or weapons or armors the player can sell at a shop.

What are the consequences of such sales?

Oh, they are sort of problematic indeed! Happy with a sweat If you ever sell the shopkeeper a Witch cursed armor or 10 useless herbs, the party will lose lots of friendship points in no time. Laughing

What happens if you lose friendship points?

The same thing that would be trigger if you get used to leaving the shop without making any transaction at all. Tongue sticking out
Once you reach 0 friendship points, you lose access to any custom good the storekeeper was opening offering before. Confused How unlucky!
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply
#4
Script Update!

Version 1.0.0 is now available here! Shocked

This time it surely comes with a nice feature: rewards for a shopkeeper's loyal customers! Grinning

Just imagine this situation. A party buys 12 apples and the storekeeper decides that he is giving away 1 pear for every 4 apples they purchase there. So the party ends up getting 3 pears for free. Grinning

The menu will let you know all about those gifts before leaving the shop menu. Two Thumbs Up! 

By the way, on the main post you can see how the Special Rewards window looks like.
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply




Users browsing this thread: 1 Guest(s)