Wychodzi na to, że trzeba by było dodać nową zmienną do zapamiętania liczby zużytych przedmiotów, czyli dodać ją do zmiennych zapisywanych w sejwie. Z tego względu wcześniejsze zapisy nie będą kompatybilne... chyba że potrzebujesz je dostosować to pisz.
Powinno działać
#===================================================================
# Limit przedmiotów do kupienia / Shop Item Limit [VX]
# by Ayene
# 13.09.2012
# dodane wykorzystanie przedmiotów 17.06.2018
# www.ultimateam.pl
#===================================================================
# Opis:
# Skrypt umożliwia ustawienie maksymalnej liczby przedmiotów do
# kupienia w sklepie.
#
# Instrukcja:
# By skorzystać ze skryptu w oknie 'Note' przy danym przedmiocie / broni /
# pancerzu w Bazie Danych umieść tekst <max_buy LICZBA>.
#
# Przykładowo:
# Jeśli chcesz, by drużyna mogła kupić Potion maksymalnie 5 razy,
# to w oknie 'Note' tego przedmiotu należy wpisać:
# <max_buy 5>
#===================================================================
module AYE
module Custom_Shop
BUY = /<(?:MAX_BUY|max_buy)\s*(\d+)>/i
MAX_BUY = 99 # domyślna maksymalna liczba przedmiotów
end
end
class Game_System
alias aye_custshop_gsys_ini initialize
def initialize
aye_custshop_gsys_ini
@item_used = {}
end
end
#===================================================================
# RPG::BaseItem
#===================================================================
class RPG::BaseItem
attr_accessor :max_buy
def item_maxbuy_ini
@max_buy = AYE::Custom_Shop::MAX_BUY
self.note.split(/[\r\n]+/).each { |line|
case line
when AYE::Custom_Shop::BUY
@max_buy = $1.to_i
end
}
end
end
class Game_Party < Game_Unit
attr_accessor :item_used
alias aye_custshop_gparty_ini initialize
def initialize
aye_custshop_gparty_ini
@item_used = {}
for i in @item_used.keys.sort
result.push($data_items[i]) if @item_used[i] > 0
end
end
def consume_item(item)
if item.is_a?(RPG::Item) and item.consumable
lose_item(item, 1)
number = @item_used[item.id] == nil ? 0 : @item_used[item.id]
@item_used[item.id] = [[number + 1, 0].max, 99].min
end
end
end
class Window_ShopBuy < Window_Selectable
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
number = $game_party.item_used[item.id] == nil ? 0 : $game_party.item_used[item.id]
number += $game_party.item_number(item)
enabled = (item.price <= $game_party.gold and number < item.max_buy)
rect = item_rect(index)
self.contents.clear_rect(rect)
draw_item_name(item, rect.x, rect.y, enabled)
rect.width -= 4
self.contents.draw_text(rect, item.price, 2)
end
end
class Window_ShopStatus < Window_Base
alias aye_custshop_winshopstat_refresh refresh
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
aye_custshop_winshopstat_refresh
if @item.is_a?(RPG::Item)
number2 = $game_party.item_used[@item.id] == nil ? 0 : $game_party.item_used[@item.id]
self.contents.font.color = system_color
self.contents.draw_text(4, 0 + WLH, 200, WLH, "Wykorzystane:")
self.contents.font.color = normal_color
self.contents.draw_text(4, 0 + WLH, 200, WLH, number2, 2)
end
end
end
#===================================================================
# Scene_Title
#===================================================================
class Scene_Title < Scene_Base
alias aye_custshop_loaddata load_database
def load_database
aye_custshop_loaddata
for group in [$data_items, $data_weapons, $data_armors]
for obj in group
next if obj.nil?
obj.item_maxbuy_ini
end
end
end
end
#===================================================================
# Scene_Equip
#===================================================================
class Scene_Shop < Scene_Base
#--------------------------------------------------------------------------
# * Update Buy Item Selection
#--------------------------------------------------------------------------
def update_buy_selection
@status_window.item = @buy_window.item
if Input.trigger?(Input::B)
Sound.play_cancel
@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
number = $game_party.item_used[@item.id] == nil ? 0 : $game_party.item_used[@item.id]
number += $game_party.item_number(@item)
if @item == nil or @item.price > $game_party.gold or number == @item.max_buy
Sound.play_buzzer
else
Sound.play_decision
max = @item.price == 0 ? @item.max_buy : $game_party.gold / @item.price
max = [max, @item.max_buy - number].min
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
end
end
end
end