class Game_System
attr_accessor :ces_limits
alias amn_ces_gamesystem_init initialize
def initialize
amn_ces_gamesystem_init
load_ces_limits
end
def load_ces_limits
@ces_limits = Hash.new(1)
YE::EVENT::COMMON_EVENT_ITEM_HASH.each_key do |key|
@ces_limits[key] = YE::EVENT::COMMON_EVENT_ITEM_HASH[key][2]
end
end
end
class Game_Interpreter
def set_ces_limit(ce_id, amount)
return unless $game_system.ces_limits.has_key?(ce_id)
$game_system.ces_limits[ce_id] = amount
end
def increase_ces_limit(ce_id, amount)
return unless $game_system.ces_limits.has_key?(ce_id)
$game_system.ces_limits[ce_id] += amount
end
def decrease_ces_limit(ce_id, amount)
return unless $game_system.ces_limits.has_key?(ce_id)
$game_system.ces_limits[ce_id] = [$game_system.ces_limits[ce_id] - amount, 1].max
end
end
class Window_Common_Event < Window_Selectable
#--------------------------------------------------------------------------
# draw item #OVERWRITE
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
rx = rect.x; ry = rect.y; rw = rect.width; rh = rect.height
sw = self.width - 32
@common_event_id = @data[index]
ce_array = YE::EVENT::COMMON_EVENT_ITEM_HASH[@common_event_id]
@common_event_name = $data_common_events[@common_event_id].name
@common_event_cost = ce_array[0]
@common_event_icon = ce_array[1]
@common_event_limit = $game_system.ces_limits[@common_event_id]
draw_icon(@common_event_icon, rx+2, ry, enabled)
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(rx+26, ry, rw-278, rh, @common_event_name, 0)
if YE::EVENT::CE_SHOW_LIMIT
limit = $game_party.ces_limit[@common_event_id]
text = sprintf(YE::EVENT::CE_LIMIT_TEXT, limit, @common_event_limit)
if !YE::EVENT::CE_SHOW_LIMIT_0 and @common_event_limit == 0
text = ""
end
if !YE::EVENT::CE_SHOW_LIMIT_1 and @common_event_limit == 1
text = ""
end
self.contents.draw_text(rw-242, ry, 80, rh, text, 1)
end
unless !YE::EVENT::CE_SHOW_FREE_COST and @common_event_cost <= 0
text = sprintf("%s%s", @common_event_cost, @currency)
self.contents.draw_text(rw-152, ry, 150, rh, text, 2)
end
end
end
class Scene_Common_Event_Shop < Scene_Base
#--------------------------------------------------------------------------
# can purchase event? #OVERWRITE
#--------------------------------------------------------------------------
def can_purchase_event?(event)
return false if $data_common_events[event] == nil
cost = YE::EVENT::COMMON_EVENT_ITEM_HASH[event][0]
if YE::EVENT::CE_SHOP_LIST[@shop_id][0] == 0
return false if $game_party.gold < cost
else
return false if $game_variables[@currency] < cost
end
$game_party.ces_limit = {} if $game_party.ces_limit == nil
$game_party.ces_limit[event] = 0 if $game_party.ces_limit[event] == nil
if YE::EVENT::COMMON_EVENT_ITEM_HASH[event][2] != 0 and
$game_party.ces_limit[event] >= $game_system.ces_limits[event]
return false
end
return true
end
end