YERD Dynamic Common Event Shop
Sept 1 2011
SummaryA way to change what appears in a common event shop based on certain conditions.
Features Desired
- In-game command of the shop
- Add/remove items from the shop based on conditions
What other scripts are you using?
- YERD Common Event Shop
- Sky00Valentine's Quest Script
Did you search?Yes
Where did you search?
- This site
- rpgmakervx.net
- rpgrevolution
What did you search for?
- YERD common event shop
- dynamic
- script
If it is already possible to do this with a script call, that would be great to know. I looked through the script and it didn't seem like there were any pre-made script calls to modify the script in-game.
YERD_CommentEventShop
#===============================================================================
#
# Yanfly Engine RD - Common Event Shop
# Last Date Updated: 2009.05.31
# Level: Normal, Hard
#
# Sometimes the lack of things you can do with money can become a little boring
# since it's only ever used for buying items and equipment and that's it. Well,
# now your players can expend their funds on common events (that you can decide
# what will happen). They can purchase common events that may unlock extras,
# recruit characters, teleport to unique places, anything your eventing ability
# allows you to do.
#
#===============================================================================
# Updates:
# ----------------------------------------------------------------------------
# o 2009.05.31 - Started script and finished.
#===============================================================================
# Instructions
#===============================================================================
#
# First, bind the CE_SHOP_VARIABLE to a variable you wish to dedicate towards
# the common event shops. Whenever you send the player to a shop and the common
# event variable's value is above 0, the player will be taken to the common
# event shop instead. Remember to set the variable back to 0 when you want to
# issue a normal shop.
#
#===============================================================================
#
# Compatibility
# - Alias: Scene_Map: call_shop
#
#===============================================================================
$imported = {} if $imported == nil
$imported["CommonEventShop"] = true
module YE
module EVENT
# Note that when you change this variable on the field map, it will change
# the scene to the common event shop and then reset itself.
CE_SHOP_VARIABLE = 99
#-------------------------------------------------------------------------
# Set up your common event shops the way you prefer here. Fill out each
# part completely to create your own common event shops.
#
# CurID - Currency ID, 0 for gold. If higher, uses a variable instead.
# Buy Text - Text used to select the common event list.
# Leave - Text used to leave the common event shop.
# Welcome - Text displayed at top when common event list isn't selected.
# Sold IDs - Array containing all of the common events sold in the shop.
#-------------------------------------------------------------------------
CE_SHOP_LIST={ # Follow the example.
# ShopID => [CurID, Buy Text, Leave, Welcome Text -------------------]
1 => [ 0, "Select Mission", "Leave", "Welcome to the Mission Counter.",
[10, 12, 13],
],# Above are the common events sold in the shop.
# ShopID => [CurID, Buy Text, Leave, Welcome Text -------------------]
2 => [ 0, "Buy Points", "Leave", "No pain, no gain! Money helps too.",
[3, 5, 7, 9, 4, 6, 8, 11],
],# Above are the common events sold in the shop.
} # Do not remove this.
#-------------------------------------------------------------------------
# This following hash determines how much common events will be sold. Fill
# out each part completely in order for this script to function correctly.
#
# ID - ID of the common event being sold.
# Cost - Cost of the common event being sold.
# Icon - Icon of the common event being sold.
# Limit - How many times the common event can be sold.
# Leave - Leave the shop upon buying the common event.
# Descr - Description of the common event.
#-------------------------------------------------------------------------
# Zero limit means that there is no maximum amount of times to buy event.
#-------------------------------------------------------------------------
COMMON_EVENT_ITEM_HASH ={ # Follow the example.
# ID => [ Cost, Icon, Limit, Leave, Description] ----------------------
3 => [ 5000, 131, 0, false, "+5 Status Points for the party member in slot 1"],
4 => [ 9500, 129, 0, false, "+10 Status Points for the party member in slot 1"],
5 => [ 5000, 130, 0, false, "+5 Status Points for the party member in slot 2"],
6 => [ 9500, 131, 0, false, "+10 Status Points for the party member in slot 2"],
7 => [ 5000, 129, 0, false, "+5 Status Points for the party member in slot 3"],
8 => [ 9500, 130, 0, false, "+10 Status Points for the party member in slot 3"],
9 => [ 5000, 160, 0, false, "+5 Status Points for the party member in slot 4"],
11=> [ 9500, 125, 0, false, "+10 Status Points for the party member in slot 4"],
10=> [ 0, 153, 1, false, "Mission: The Legend of Dexx"],
12=> [ 0, 200, 1, false, "Mission: Photoshopped Slime"],
13=> [ 0, 120, 1, false, "Mission: Cutscene!"],
} # Do not remove this.
# This determines how to call the currency for each variable value. Note
# that variable 0 and below will always return the default currency so
# don't adding values for those.
CURRENCY_VARIABLE_MATCH ={
# VarID => Name
1 => " Sil",
2 => " Plat",
3 => " Souls",
4 => " Credits",
} # Do not remove this.
# This will be the name given to variables not listed under the list above.
UNDEFINED_CURRENCY = " Points"
# If there is no cost for the common event, would you like for it to still
# show 0 Gold or 0 Points?
CE_SHOW_FREE_COST = false
# The following will let you decide whether or not you would like to show
# a limit indicator for the number of times a common event can be bought.
CE_LIMIT_TEXT = "%d/%d"
CE_SHOW_LIMIT = true
CE_SHOW_LIMIT_0 = false
CE_SHOW_LIMIT_1 = false
end # YE
end # YE
#===============================================================================
# Editting anything past this point may potentially result in causing computer
# damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
# Therefore, edit at your own risk.
#===============================================================================
#===============================================================================
# Game_Party
#===============================================================================
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :ces_limit
end # Game_Party
#===============================================================================
# Scene_Map
#===============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# alias call_shop
#--------------------------------------------------------------------------
alias call_shop_ces call_shop unless $@
def call_shop
if meet_ceshop_conditions
$game_temp.next_scene = nil
$scene = Scene_Common_Event_Shop.new
else
call_shop_ces
end
end
#--------------------------------------------------------------------------
# meet_ceshop_conditions
#--------------------------------------------------------------------------
def meet_ceshop_conditions
shop_id = $game_variables[YE::EVENT::CE_SHOP_VARIABLE]
return false if shop_id <= 0
return false unless $scene.is_a?(Scene_Map)
return false unless YE::EVENT::CE_SHOP_LIST.include?(shop_id)
return true
end
end # Scene_Map
#===============================================================================
# Scene_Common_Event_Shop
#===============================================================================
class Scene_Common_Event_Shop < Scene_Base
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
@shop_id = $game_variables[YE::EVENT::CE_SHOP_VARIABLE]
@currency = YE::EVENT::CE_SHOP_LIST[@shop_id][0]
@welcome = YE::EVENT::CE_SHOP_LIST[@shop_id][3]
@interpreter = Game_Interpreter.new
@message_window = Window_Message.new
@message_window.back_opacity = 255
@common_event = 0
end
#--------------------------------------------------------------------------
# start
#--------------------------------------------------------------------------
def start
super
create_menu_background
create_command_window
@help_window = Window_Help.new
@currency_window = Window_Variable_Currency.new(@currency)
@event_window = Window_Common_Event.new
@event_window.help_window = @help_window
set_welcome_text
end
#--------------------------------------------------------------------------
# terminate
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
@message_window.dispose
@command_window.dispose
@help_window.dispose
@currency_window.dispose
@event_window.dispose
end
#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
update_menu_background
update_interpreter
update_currency_window
@message_window.update
@interpreter.update
return if @interpreter.running?
return if $game_message.visible
if @command_window.active
update_command_window
elsif @event_window.active
update_event_window
end
end
#--------------------------------------------------------------------------
# update_interpreter
#--------------------------------------------------------------------------
def update_interpreter
if @common_event > 0
@interpreter.setup($data_common_events[@common_event].list)
@common_event = 0
return
end
end
#--------------------------------------------------------------------------
# update_currency_window
#--------------------------------------------------------------------------
def update_currency_window
if @currency == 0
if @currency_window.value != $game_party.gold
@currency_window.refresh
end
else
if @currency_window.value != $game_variables[@currency]
@currency_window.refresh
end
end
end
#--------------------------------------------------------------------------
# update_command_window
#--------------------------------------------------------------------------
def update_command_window
@command_window.update
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
$game_variables[YE::EVENT::CE_SHOP_VARIABLE] = 0
elsif Input.trigger?(Input::C)
Sound.play_decision
case @command_window.index
when 0
@command_window.active = false
@event_window.active = true
text = YE::EVENT::COMMON_EVENT_ITEM_HASH[@event_window.event][4]
@help_window.contents.clear
@help_window.contents.font.color = @help_window.normal_color
@help_window.contents.draw_text(4, 0, 504, 24, text)
when 1
$scene = Scene_Map.new
$game_variables[YE::EVENT::CE_SHOP_VARIABLE] = 0
end
end
end
#--------------------------------------------------------------------------
# update_event_window
#--------------------------------------------------------------------------
def update_event_window
@event_window.update
@help_window.update
if Input.trigger?(Input::B)
Sound.play_cancel
@command_window.active = true
@event_window.active = false
set_welcome_text
elsif Input.trigger?(Input::C)
event = @event_window.event
if event == nil
Sound.play_buzzer
elsif !can_purchase_event?(event)
Sound.play_buzzer
else
Sound.play_shop
adjust_currency(event)
buy_event(event)
end
end
end
#--------------------------------------------------------------------------
# create_command_window
#--------------------------------------------------------------------------
def create_command_window
s1 = YE::EVENT::CE_SHOP_LIST[@shop_id][1]
s2 = YE::EVENT::CE_SHOP_LIST[@shop_id][2]
@command_window = Window_Command.new(384, [s1, s2], 2)
@command_window.y = 56
end
#--------------------------------------------------------------------------
# set welcome text
#--------------------------------------------------------------------------
def set_welcome_text
@help_window.contents.clear
@help_window.contents.draw_text(4, 0, 540, 24, @welcome)
end
#--------------------------------------------------------------------------
# can purchase event?
#--------------------------------------------------------------------------
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] >= YE::EVENT::COMMON_EVENT_ITEM_HASH[event][2]
return false
end
return true
end
#--------------------------------------------------------------------------
# adjust currency
#--------------------------------------------------------------------------
def adjust_currency(event)
cost = YE::EVENT::COMMON_EVENT_ITEM_HASH[event][0]
if @currency == 0
$game_party.lose_gold(cost)
else
$game_variables[@currency] -= cost
end
end
#--------------------------------------------------------------------------
# buy event
#--------------------------------------------------------------------------
def buy_event(event)
$game_party.ces_limit[event] += 1
@event_window.refresh
if YE::EVENT::COMMON_EVENT_ITEM_HASH[event][3]
$game_temp.common_event_id = event
$scene = Scene_Map.new
$game_variables[YE::EVENT::CE_SHOP_VARIABLE] = 0
else
@common_event = event
end
end
end
#===============================================================================
# Window_Variable_Currency
#===============================================================================
class Window_Variable_Currency < Window_Base
#--------------------------------------------------------------------------
# intialize
#--------------------------------------------------------------------------
def initialize(currency)
super(384, 56, 160, WLH + 32)
@currency = currency
refresh
end
#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if @currency > 0
@value = $game_variables[@currency]
if YE::EVENT::CURRENCY_VARIABLE_MATCH.include?(@currency)
@vocab = YE::EVENT::CURRENCY_VARIABLE_MATCH[@currency]
else
@vocab = YE::EVENT::UNDEFINED_CURRENCY
end
else
@value = $game_party.gold
@vocab = Vocab::gold
end
draw_currency
end
#--------------------------------------------------------------------------
# draw_currency
#--------------------------------------------------------------------------
def draw_currency
cx = contents.text_size(@vocab).width
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 118 - cx, WLH, @value, 2)
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, WLH, @vocab, 2)
end
#--------------------------------------------------------------------------
# value
#--------------------------------------------------------------------------
def value
return @value
end
end # Window_Variable_Currency
#==============================================================================
# Window_Common_Event
#==============================================================================
class Window_Common_Event < Window_Selectable
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
super(0, 112, 544, 304)
shop_id = $game_variables[YE::EVENT::CE_SHOP_VARIABLE]
@shop = YE::EVENT::CE_SHOP_LIST[shop_id]
if @shop[0] <= 0
@currency = Vocab::gold
elsif YE::EVENT::CURRENCY_VARIABLE_MATCH.include?(@shop[0])
@currency = YE::EVENT::CURRENCY_VARIABLE_MATCH[@shop[0]]
else
@currency = YE::EVENT::UNDEFINED_CURRENCY
end
@shop_items = @shop[4]
self.index = 0
refresh
end
#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
@data = []
@common_event = []
@item_max = 0
for item in @shop_items
@data.push(item) if YE::EVENT::COMMON_EVENT_ITEM_HASH.include?(item)
end
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# draw item
#--------------------------------------------------------------------------
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 = ce_array[2]
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
#--------------------------------------------------------------------------
# event
#--------------------------------------------------------------------------
def event
return @data[self.index]
end
#--------------------------------------------------------------------------
# update help
#--------------------------------------------------------------------------
def update_help
if event == nil
@help_window.set_text("")
else
text = YE::EVENT::COMMON_EVENT_ITEM_HASH[event][4]
@help_window.set_text(text)
end
end
#--------------------------------------------------------------------------
# enabled
#--------------------------------------------------------------------------
def enabled
$game_party.ces_limit = {} if $game_party.ces_limit == nil
$game_party.ces_limit[@common_event_id] = 0 if
$game_party.ces_limit[@common_event_id] == nil
return false if $data_common_events[@common_event_id] == nil
if @shop[0] == 0
return false if $game_party.gold < @common_event_cost
else
return false if $game_variables[@shop[0]] < @common_event_cost
end
if @common_event_limit > 0 and
$game_party.ces_limit[@common_event_id] >= @common_event_limit
return false
end
return true
end
end # Window_Common_Event
#===============================================================================
#
# END OF FILE
#
#===============================================================================
I'm not a scripter, but could you be more specific about these "certain conditions" you are talking about? Examples, perhaps?
Of course. I'm looking for the ability to add quests to my quest shop as other quests are completed.
For example:
When: Find the Sword Part 1 is complete
Add: Find the Sword Part 2 to Quest Shop
The actual checking of the quest condition can be done with a script call (as defined in the script) but the common event shop can't be changed. I'm just looking for a way to do this. Hope this helps.
Could you put a link to the script or something? I can't find it anywhere.
Of course. It has been added to the first post
#=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# * Dynamic Common Event Shop
#=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#-------------------------------------------------------------------------------
# Script Calls:
# $game_system.add_ce_command(id, value)
# - Adds the value to the common event shop with the id id.
# - e.g $game_system.add_ce_command(1, 6) would add the common event 6 to the
# shop with the id of 1.
#
# $game_system.delete_ce_command(id, value)
# - Deletes the value to the common event shop with the id id.
# - e.g $game_system.add_ce_command(2, 4) would delete the common event 4
# from the shop with the id of 1.
#-------------------------------------------------------------------------------
class Game_System
attr_accessor :ce_shop_list
alias coz_jonf_yf_dynamic_gs_initialize initialize
def initialize
coz_jonf_yf_dynamic_gs_initialize
@ce_shop_list = YE::EVENT::CE_SHOP_LIST
end
def add_ce_command(id, value); @ce_shop_list[id][4].push(value); end
def delete_ce_command(id, value); @ce_shop_list[id][4].delete(value); end
end
#-------------------------------------------------------------------------------
class Scene_Map < Scene_Base
def meet_ceshop_conditions
shop_id = $game_variables[YE::EVENT::CE_SHOP_VARIABLE]
return false if shop_id <= 0
return false unless $scene.is_a?(Scene_Map)
return false unless @ce_shop_list.include?(shop_id)
return true
end
end
#-------------------------------------------------------------------------------
class Scene_Common_Event_Shop < Scene_Base
def initialize
@shop_id = $game_variables[YE::EVENT::CE_SHOP_VARIABLE]
@currency = $game_system.ce_shop_list[@shop_id][0]
@welcome = $game_system.ce_shop_list[@shop_id][3]
@interpreter = Game_Interpreter.new
@message_window = Window_Message.new
@message_window.back_opacity = 255
@common_event = 0
end
def create_command_window
s1 = $game_system.ce_shop_list[@shop_id][1]
s2 = $game_system.ce_shop_list[@shop_id][2]
@command_window = Window_Command.new(384, [s1, s2], 2)
@command_window.y = 56
end
def can_purchase_event?(event)
return false if $data_common_events[event] == nil
cost = YE::EVENT::COMMON_EVENT_ITEM_HASH[event][0]
if $game_system.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] >= YE::EVENT::COMMON_EVENT_ITEM_HASH[event][2]
return false
end
return true
end
end
#-------------------------------------------------------------------------------
class Window_Common_Event < Window_Selectable
def initialize
super(0, 112, 544, 304)
shop_id = $game_variables[YE::EVENT::CE_SHOP_VARIABLE]
@shop = $game_system.ce_shop_list[shop_id]
if @shop[0] <= 0
@currency = Vocab::gold
elsif YE::EVENT::CURRENCY_VARIABLE_MATCH.include?(@shop[0])
@currency = YE::EVENT::CURRENCY_VARIABLE_MATCH[@shop[0]]
else
@currency = YE::EVENT::UNDEFINED_CURRENCY
end
@shop_items = @shop[4]
self.index = 0
refresh
end
end
Done blind, so it might be buggy :(
Just did a quest test of both commands. If I run the $game_system.add_ce_command line more than once for the same item (ex 1, 2) then it will add more than 1 instance of that item to the shop. When the item is actually bought, all instances will be bought as if it was one unit. Just a minor problem, and it can easily be avoided with eventing.
Another problem that I encountered is that none of the commands work on a loaded game. I tested this in several situations:
1. Did not run the script, saved the game, loaded the game, went to the NPC that was supposed to run the script, the Common Event shop was unaffected.
2. Ran the script. It affects the shop. Save the game, loaded the game, went to the NPC to run the "delete" line, CE Shop was unaffected. The add command doesn't work either.
I tested all of the situations from both the in-editor playtester and by running the EXE in the folder. The error occurs in both cases.
On a basic level it works great it's just missing something. I appreciate all of the work cozzie, and I thank you greatly for what you've done so far, I hope you can keep it up.
My bad. I'm thinking that it was probably a simple error. Try this:
#=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# * Dynamic Common Event Shop
#=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#-------------------------------------------------------------------------------
# Script Calls:
# $game_system.add_ce_command(id, value)
# - Adds the value to the common event shop with the id id.
# - e.g $game_system.add_ce_command(1, 6) would add the common event 6 to the
# shop with the id of 1.
#
# $game_system.delete_ce_command(id, value)
# - Deletes the value to the common event shop with the id id.
# - e.g $game_system.add_ce_command(2, 4) would delete the common event 4
# from the shop with the id of 1.
#-------------------------------------------------------------------------------
class Game_System
attr_accessor :ce_shop_list
alias coz_jonf_yf_dynamic_gs_initialize initialize
def initialize
coz_jonf_yf_dynamic_gs_initialize
@ce_shop_list = YE::EVENT::CE_SHOP_LIST.clone
end
def add_ce_command(id, value); @ce_shop_list[id][4].push(value); end
def delete_ce_command(id, value); @ce_shop_list[id][4].delete(value); end
end
#-------------------------------------------------------------------------------
class Scene_Map < Scene_Base
def meet_ceshop_conditions
shop_id = $game_variables[YE::EVENT::CE_SHOP_VARIABLE]
return false if shop_id <= 0
return false unless $scene.is_a?(Scene_Map)
return false unless @ce_shop_list.include?(shop_id)
return true
end
end
#-------------------------------------------------------------------------------
class Scene_Common_Event_Shop < Scene_Base
def initialize
@shop_id = $game_variables[YE::EVENT::CE_SHOP_VARIABLE]
@currency = $game_system.ce_shop_list[@shop_id][0]
@welcome = $game_system.ce_shop_list[@shop_id][3]
@interpreter = Game_Interpreter.new
@message_window = Window_Message.new
@message_window.back_opacity = 255
@common_event = 0
end
def create_command_window
s1 = $game_system.ce_shop_list[@shop_id][1]
s2 = $game_system.ce_shop_list[@shop_id][2]
@command_window = Window_Command.new(384, [s1, s2], 2)
@command_window.y = 56
end
def can_purchase_event?(event)
return false if $data_common_events[event] == nil
cost = YE::EVENT::COMMON_EVENT_ITEM_HASH[event][0]
if $game_system.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] >= YE::EVENT::COMMON_EVENT_ITEM_HASH[event][2]
return false
end
return true
end
end
#-------------------------------------------------------------------------------
class Window_Common_Event < Window_Selectable
def initialize
super(0, 112, 544, 304)
shop_id = $game_variables[YE::EVENT::CE_SHOP_VARIABLE]
@shop = $game_system.ce_shop_list[shop_id]
if @shop[0] <= 0
@currency = Vocab::gold
elsif YE::EVENT::CURRENCY_VARIABLE_MATCH.include?(@shop[0])
@currency = YE::EVENT::CURRENCY_VARIABLE_MATCH[@shop[0]]
else
@currency = YE::EVENT::UNDEFINED_CURRENCY
end
@shop_items = @shop[4]
self.index = 0
refresh
end
end
That doesn't seem to work either.
I thought it might be an argument with another script, but it's proving to be extremely difficult to isolate the problem. I'll continually edit this post with whatever results I can find from testing.
I have moved only essential scripts to a new project to try to find an error. In a new project, the same problem occurs when I save the game and then load from that saved game.
Would a demo be useful to you?
Yeah, that would be helpful.
http://www.mediafire.com/?qfhuwbq32orhpjc
This should be a working demo with the quest script and the common event shop
Dynamic shop was supposed to go below the Common Event shop. My apologies if that wasn't clear. Anyways, here's an updated version that fixes the other problem:
#=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# * Dynamic Common Event Shop
#=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#-------------------------------------------------------------------------------
# Script Calls:
# $game_system.add_ce_command(id, value)
# - Adds the value to the common event shop with the id id.
# - e.g $game_system.add_ce_command(1, 6) would add the common event 6 to the
# shop with the id of 1.
#
# $game_system.delete_ce_command(id, value)
# - Deletes the value to the common event shop with the id id.
# - e.g $game_system.add_ce_command(2, 4) would delete the common event 4
# from the shop with the id of 1.
#-------------------------------------------------------------------------------
class Game_System
attr_accessor :ce_shop_list
alias coz_jonf_yf_dynamic_gs_initialize initialize
def initialize
coz_jonf_yf_dynamic_gs_initialize
@ce_shop_list = YE::EVENT::CE_SHOP_LIST.clone
end
def add_ce_command(id, value)
return if @ce_shop_list[id][4].include?(value)
@ce_shop_list[id][4].push(value)
end
def delete_ce_command(id, value); @ce_shop_list[id][4].delete(value); end
end
#-------------------------------------------------------------------------------
class Scene_Map < Scene_Base
def meet_ceshop_conditions
shop_id = $game_variables[YE::EVENT::CE_SHOP_VARIABLE]
return false if shop_id <= 0
return false unless $scene.is_a?(Scene_Map)
return false unless $game_system.ce_shop_list.include?(shop_id)
return true
end
end
#-------------------------------------------------------------------------------
class Scene_Common_Event_Shop < Scene_Base
def initialize
@shop_id = $game_variables[YE::EVENT::CE_SHOP_VARIABLE]
@currency = $game_system.ce_shop_list[@shop_id][0]
@welcome = $game_system.ce_shop_list[@shop_id][3]
@interpreter = Game_Interpreter.new
@message_window = Window_Message.new
@message_window.back_opacity = 255
@common_event = 0
end
def create_command_window
s1 = $game_system.ce_shop_list[@shop_id][1]
s2 = $game_system.ce_shop_list[@shop_id][2]
@command_window = Window_Command.new(384, [s1, s2], 2)
@command_window.y = 56
end
def can_purchase_event?(event)
return false if $data_common_events[event] == nil
cost = YE::EVENT::COMMON_EVENT_ITEM_HASH[event][0]
if $game_system.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] >= YE::EVENT::COMMON_EVENT_ITEM_HASH[event][2]
return false
end
return true
end
end
#-------------------------------------------------------------------------------
class Window_Common_Event < Window_Selectable
def initialize
super(0, 112, 544, 304)
shop_id = $game_variables[YE::EVENT::CE_SHOP_VARIABLE]
@shop = $game_system.ce_shop_list[shop_id]
if @shop[0] <= 0
@currency = Vocab::gold
elsif YE::EVENT::CURRENCY_VARIABLE_MATCH.include?(@shop[0])
@currency = YE::EVENT::CURRENCY_VARIABLE_MATCH[@shop[0]]
else
@currency = YE::EVENT::UNDEFINED_CURRENCY
end
@shop_items = @shop[4]
self.index = 0
refresh
end
end
Thanks so much, it works now without any immediate errors.
My first instinct was to put the script below the common event shop at first, but it only produced an error. When I put the script above, it worked mostly without error.
This new script goes below the CEShop script without error, and works perfectly. Once again, thanks so much cozziekuns