With that easy script, you will be able to control how many items you will buy (or sell), without going to a counter window.
The new multiplier number shown on the same window as the items list, will be managed now with -> and <-
Nope for this type of script.
#==============================================================================
# Scene_Shop Item Counter (Castlevania style)
# -----------------------------------------------------
# Author: Wecoc
#==============================================================================
module RPG
class Item
alias ini initialize unless $@
def initialize
ini
@itemcount = 1
@newprice = 0
end
attr_accessor :itemcount
attr_accessor :newprice
end
class Weapon
alias ini initialize unless $@
def initialize
ini
@itemcount = 1
@newprice = 0
end
attr_accessor :itemcount
attr_accessor :newprice
end
class Armor
alias ini initialize unless $@
def initialize
ini
@itemcount = 1
@newprice = 0
end
attr_accessor :itemcount
attr_accessor :newprice
end
end
#==============================================================================
# ** Window_ShopBuy
#==============================================================================
class Window_ShopBuy < Window_Selectable
attr_accessor :itemcount
def initialize(shop_goods)
super(0, 128, 368, 352)
@shop_goods = shop_goods
ini_itemcount
refresh
self.index = 0
end
def ini_itemcount
for goods_item in @shop_goods
case goods_item[0]
when 0
$data_items[goods_item[1]].itemcount = 1
when 1
$data_weapons[goods_item[1]].itemcount = 1
when 2
$data_armors[goods_item[1]].itemcount = 1
end
end
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
@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, @data[i].itemcount)
end
end
end
def draw_item(index, itemcount)
item = @data[index]
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
item.newprice = item.price * item.itemcount
if item.newprice <= $game_party.gold and number < (100-item.itemcount)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 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 + 160, y, 88, 32, item.itemcount.to_s, 2)
self.contents.draw_text(x + 240, y, 88, 32, item.newprice.to_s, 2)
end
def update
if self.active and @item_max > 0 and @index >= 0
if Input.repeat?(Input::DOWN)
if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
@index < @item_max - @column_max
$game_system.se_play($data_system.cursor_se)
@index = (@index + @column_max) % @item_max
end
end
if Input.repeat?(Input::UP)
if (@column_max == 1 and Input.trigger?(Input::UP)) or
@index >= @column_max
$game_system.se_play($data_system.cursor_se)
@index = (@index - @column_max + @item_max) % @item_max
end
end
if Input.repeat?(Input::RIGHT)
if item.itemcount == 99
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.cursor_se)
item.itemcount += 1
refresh
end
end
if Input.repeat?(Input::LEFT)
if item.itemcount == 1
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.cursor_se)
item.itemcount -= 1
refresh
end
end
if Input.repeat?(Input::R)
$game_system.se_play($data_system.cursor_se)
if item.itemcount >= 90
item.itemcount = 99
else
item.itemcount += 10
end
refresh
end
if Input.repeat?(Input::L)
$game_system.se_play($data_system.cursor_se)
if item.itemcount <= 10
item.itemcount = 1
else
item.itemcount -= 10
end
refresh
end
end
if self.active and @help_window != nil
update_help
end
update_cursor_rect
end
end
#==============================================================================
# Window_ShopSell
#==============================================================================
class Window_ShopSell < Window_Selectable
def initialize
super(0, 128, 368, 352)
@column_max = 1
ini_itemcount
refresh
self.index = 0
end
def ini_itemcount
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
$data_items[i].itemcount = 1
end
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
$data_weapons[i].itemcount = 1
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
$data_armors[i].itemcount = 1
end
end
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors[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(i, @data[i].itemcount)
end
end
end
def draw_item(index, itemcount)
item = @data[index]
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
item.newprice = item.price * item.itemcount
if item.price > 0
if item.itemcount <= number
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
else
self.contents.font.color = disabled_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 + 160, y, 88, 32, item.itemcount.to_s, 2)
self.contents.draw_text(x + 240, y, 88, 32, item.newprice.to_s, 2)
#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
if self.active and @item_max > 0 and @index >= 0
if Input.repeat?(Input::DOWN)
if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
@index < @item_max - @column_max
$game_system.se_play($data_system.cursor_se)
@index = (@index + @column_max) % @item_max
end
end
if Input.repeat?(Input::UP)
if (@column_max == 1 and Input.trigger?(Input::UP)) or
@index >= @column_max
$game_system.se_play($data_system.cursor_se)
@index = (@index - @column_max + @item_max) % @item_max
end
end
if Input.repeat?(Input::RIGHT)
if item.itemcount == 99
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.cursor_se)
item.itemcount += 1
refresh
end
end
if Input.repeat?(Input::LEFT)
if item.itemcount == 1
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.cursor_se)
item.itemcount -= 1
refresh
end
end
if Input.repeat?(Input::R)
$game_system.se_play($data_system.cursor_se)
if item.itemcount >= 90
item.itemcount = 99
else
item.itemcount += 10
end
refresh
end
if Input.repeat?(Input::L)
$game_system.se_play($data_system.cursor_se)
if item.itemcount <= 10
item.itemcount = 1
else
item.itemcount -= 10
end
refresh
end
end
if self.active and @help_window != nil
update_help
end
update_cursor_rect
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#==============================================================================
# Scene_Shop
#==============================================================================
class Scene_Shop
def main
@help_window = Window_Help.new
@command_window = Window_ShopCommand.new
@gold_window = Window_Gold.new
@gold_window.x = 480
@gold_window.y = 64
@dummy_window = Window_Base.new(0, 128, 640, 352)
@buy_window = Window_ShopBuy.new($game_temp.shop_goods)
@buy_window.active = false
@buy_window.visible = false
@buy_window.help_window = @help_window
@sell_window = Window_ShopSell.new
@sell_window.active = false
@sell_window.visible = false
@sell_window.help_window = @help_window
@status_window = Window_ShopStatus.new
@status_window.visible = false
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@help_window.dispose
@command_window.dispose
@gold_window.dispose
@dummy_window.dispose
@buy_window.dispose
@sell_window.dispose
@status_window.dispose
end
def update
@help_window.update
@command_window.update
@gold_window.update
@dummy_window.update
@buy_window.update
@sell_window.update
@status_window.update
if @command_window.active
update_command
return
end
if @buy_window.active
update_buy
return
end
if @sell_window.active
update_sell
return
end
end
def update_command
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
case @command_window.index
when 0 # buy
$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
when 1 # sell
$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
@status_window.visible = true
when 2 # quit
$game_system.se_play($data_system.decision_se)
$scene = Scene_Map.new
end
return
end
end
def update_buy
@status_window.item = @buy_window.item
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@buy_window.ini_itemcount
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@status_window.visible = false
@status_window.item = nil
@help_window.set_text("")
return
end
if Input.trigger?(Input::C)
@item = @buy_window.item
if @item == nil or @item.newprice > $game_party.gold
$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 number >= (100-@item.itemcount)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.shop_se)
$game_party.lose_gold(@item.newprice)
case @item
when RPG::Item
$game_party.gain_item(@item.id, @item.itemcount)
when RPG::Weapon
$game_party.gain_weapon(@item.id, @item.itemcount)
when RPG::Armor
$game_party.gain_armor(@item.id, @item.itemcount)
end
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
end
end
def update_sell
@status_window.item = @sell_window.item
if Input.trigger?(Input::B)
@sell_window.ini_itemcount
$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
@help_window.set_text("")
return
end
if Input.trigger?(Input::C)
@item = @sell_window.item
@status_window.item = @item
if @item == nil or @item.price == 0
$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.itemcount > number
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.shop_se)
$game_party.gain_gold((@item.newprice)/2)
case @item
when RPG::Item
$game_party.lose_item(@item.id, @item.itemcount)
when RPG::Weapon
$game_party.lose_weapon(@item.id, @item.itemcount)
when RPG::Armor
$game_party.lose_armor(@item.id, @item.itemcount)
end
@gold_window.refresh
@sell_window.refresh
@status_window.refresh
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = true
end
end
end
Just post above main.
Probably it will not fit well with custom shop systems.
Please report any bugs/issues.