#=============================================================================== # # Yanfly Engine RD - Common Event Shop # Last Date Updated: 2009.05.31 # Level: Normal, Hard # # µ·(¶Ç´Â ´Ù¸¥ È­Æó)À¸·Î Ä¿¸Õ À̺¥Æ®¸¦ ±¸ÀÔÇÒ ¼ö ÀÖ½À´Ï´Ù. # ¿¹¸¦ µé¾î Ư¼öÇÑ ´É·Â ÀÔ¼ö, µ¿·á °í¿ë, ¾îµò°¡·Î ÅÚ·¹Æ÷Æ® µîµî # À̺¥Æ®·Î ÇÒ ¼ö ÀÖ´Â ¸ðµç °ÍÀ» ±¸ÀÔÇÒ ¼ö ÀÖ½À´Ï´Ù! # #=============================================================================== # Updates: # ---------------------------------------------------------------------------- # o 2009.05.31 - Started script and finished. #=============================================================================== # Instructions #=============================================================================== # # ¸ÕÀú º¯¼ö CE_SHOP_VARIABLEÀ» ÁöÁ¤Çϼ¼¿ä. # ÀÌ °ªÀÌ 1 ÀÌ»óÀ϶§ »óÁ¡À» ¿­¸é ÇØ´ç Ä¿¸Õ À̺¥Æ® ¼¥ÀÌ ¿­¸®°Ô µË´Ï´Ù. # ÀÌ °ªÀ» 0À¸·Î µÇµ¹¸®¸é ÀÏ¹Ý »óÁ¡ È­¸éÀÌ µË´Ï´Ù. # 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 # ÀÌ º¯¼ö¸¦ Çʵå¸Ê¿¡¼­ º¯È­½ÃÅ°¸é, it will change # the scene to the common event shop and then reset itself. CE_SHOP_VARIABLE = 95 #------------------------------------------------------------------------- # Set up your common event shops the way you prefer here. Fill out each # part completely to create your own common event shops. # # CurID - È­Æó ID, 0Àº gold. 1 ÀÌ»óÀº º¯¼ö¸¦ »ç¿ë. # Buy Text - Text used to select the common event list. # Leave - Text used to leave the common event shop. # Welcome - Ä¿¸Õ À̺¥Æ®°¡ ¼±ÅõÇÁö ¾Ê¾ÒÀ»¶§ Ç¥½ÃµÇ´Â ¸Þ½ÃÁö. # 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 => [ 1, "·¹º§¾÷", "¶°³­´Ù", "Welcome to the level up shop!", [1, 2, 3, 4], ],# À§´Â °¡°Ô¿¡¼­ ÆÈ°íÀÖ´Â Ä¿¸Õ À̺¥Æ® ¸ñ·Ï. # ShopID => [CurID, Buy Text, Leave, Welcome Text -------------------] 2 => [ 0, "°í¿ë", "¶°³­´Ù", "Unlock more party members!", [5, 6, 7, 8], ],# 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 - Ä¿¸Õ À̺¥Æ® Àç°í·®(ÃÖ´ë ±¸ÀÔ È½¼ö) # Leave - Ä¿¸Õ À̺¥Æ®¸¦ ±¸ÀÔÈÄ °¡°Ô¸¦ ºüÁ®³ª°¥°ÍÀΰ¡ ¼³Á¤ # Descr - Ä¿¸Õ À̺¥Æ® ¼³¸í #------------------------------------------------------------------------- # 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] ---------------------- 1 => [ 1750, 1, 10, false, "Levels up Ralph."], 2 => [ 1500, 2, 10, false, "Levels up Ulrika."], 3 => [ 1250, 3, 10, false, "Levels up Bennett."], 4 => [ 1000, 4, 10, false, "Levels up Ylva."], 5 => [ 5000, 5, 1, true, "Recruit Lawrence into your party."], 6 => [ 5000, 6, 1, true, "Recruit Oscar into your party."], 7 => [ 5000, 7, 1, true, "Recruit Vera into your party."], 8 => [ 5000, 8, 1, true, "Recruit Elmer into your party."], } # Do not remove this. # È­ÆóÀÇ ¸íĪ Á¤ÀÇ # This determines how to call the currency for each variable value. # ID 0 ÀÌÇÏ´Â ±âº» È­Æó¸¦ ¶æÇÑ´Ù. CURRENCY_VARIABLE_MATCH ={ # VarID => Name 1 => " Sil", 2 => " Plat", 3 => " Souls", 4 => " Credits", } # Do not remove this. # µðÆúÆ® È­Æó ´ÜÀ§(À§ ¸ñ·Ï¿¡ ¸ÅÄ¡ÇÏÁö ¾Ê´Â °æ¿ì) UNDEFINED_CURRENCY = " Points" # true: °¡°ÝÀÌ 0À϶§µµ °¡°Ý Ç¥½Ã(¿¹: 0°ñµå) 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 $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 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 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 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 # #===============================================================================