设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3594|回复: 1
打印 上一主题 下一主题

[转载] 【ACE】公共事件專用的任務購買

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
106 小时
注册时间
2010-10-12
帖子
28
跳转到指定楼层
1
发表于 2012-1-22 22:53:22 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 asdrty123 于 2012-1-23 22:49 编辑

這是ACE專用的腳本...不過我本人也沒看懂 正在研究

來自
http://rpgmaker.net/scripts/162/
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Common Event Shop v1.00
  4. # -- Last Updated: 2012.01.13
  5. # -- Level: Normal, Hard
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================

  9. $imported = {} if $imported.nil?
  10. $imported["YEA-CommonEventShop"] = true

  11. #==============================================================================
  12. # ▼ Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2012.01.13 - Started Script and Finished.
  15. #
  16. #==============================================================================
  17. # ▼ Introduction
  18. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  19. # Sometimes, being able to buy items just isn't enough. With the common event
  20. # shop, you can set anything to be sold as long as you can event it. Expanded
  21. # upon the original Yanfly Engine ReDux version, the Ace version gives more
  22. # options such as using custom switches to enable/disable common events from
  23. # being bought or even appearing. And if that wasn't enough, advanced users can
  24. # use eval strings for more conditional common events.
  25. #
  26. #==============================================================================
  27. # ▼ Instructions
  28. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  29. # To install this script, open up your script editor and copy/paste this script
  30. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  31. #
  32. # -----------------------------------------------------------------------------
  33. # Common Event Notetags - These notetags go in a common event's comments.
  34. # -----------------------------------------------------------------------------
  35. # <cost: x>
  36. # Sets the gold cost of the common event to x gold. If this notetag is not used
  37. # the default gold cost will be whatever DEFAULT_COST is in the script module.
  38. #
  39. # <exit shop>
  40. # When this event is bought, the player will automatically exit the shop before
  41. # the common event will take place. If this tag is not used, the common event's
  42. # contents will take place inside of the common event shop.
  43. #
  44. # <icon: x>
  45. # Changes the icon used for the common event to x icon index. If this notetag
  46. # is not used, the icon used for the common event will be whatever DEFAULT_ICON
  47. # is in the script module.
  48. #
  49. # <image: string>
  50. # Changes the image used for the common event to filename "string" found in
  51. # the Graphics\Pictures\ folder. Requires Ace Shop Options to use. If this tag
  52. # is not used, the image displayed will be the common event's expanded icon.
  53. #
  54. # <help description>
  55. #  string
  56. # </help description>
  57. # Sets the text used for the help window in the shop scene. Multiple lines in
  58. # the notebox will be strung together. Use | for a line break. Text codes may
  59. # be used inside of the help description.
  60. #
  61. # <shop data>
  62. #  string
  63. # </shop data>
  64. # Can be used if you have Yanfly Engine Ace - Ace Shop Options installed. Sets
  65. # the string as the text shown inside the data window the shop. Use | for a
  66. # line break. Text codes may be used inside of the shop data text.
  67. #
  68. # <shop variables: x>
  69. # <shop variables: x, x>
  70. # This sets the variable x displayed in the status window in the lower right
  71. # corner of the screen. Insert multiples of this notetag to display more
  72. # variables inside of the status window.
  73. #
  74. # <shop enable switch: x>
  75. # <shop enable switch: x, x>
  76. # This notetag will cause the common event item to require switch x to be ON
  77. # before the common event can be bought. Insert multiples of these notetags to
  78. # require more switches to be ON before the common event item can be gouth.
  79. #
  80. # <shop enable eval>
  81. #  string
  82. #  string
  83. # </shop enable eval>
  84. # Advanced users can enable and disable common events from being bought through
  85. # this notetag. Replace string with lines of code to check for whether or not
  86. # the common event can be sold. If multiple lines are used, they are considered
  87. # to be a part of the same line.
  88. #
  89. # <shop show switch: x>
  90. # <shop show switch: x, x>
  91. # This notetag will cause the common event item to be hidden unless switch x is
  92. # ON. Insert multiple of these notetags to require more switches to be ON
  93. # before the common event item will be shown in the shop.
  94. #
  95. # <shop show eval>
  96. #  string
  97. #  string
  98. # </shop show eval>
  99. # Advanced users can show and hide common events from being listed in the buy
  100. # list through this notetag. Replace string with lines of code to check for
  101. # whether or not the common event will be shown. If multiple lines are used,
  102. # they are considered to be a part of the same line.
  103. #
  104. # -----------------------------------------------------------------------------
  105. # Script Calls - These commands are used with script calls.
  106. # -----------------------------------------------------------------------------
  107. # common_event_shop(x)
  108. # This will call common event shop x. x will the shop ID used from the SHOPS
  109. # hash in the script's module. Any items placed within the array assigned to
  110. # the shop ID will be sold as common events.
  111. #
  112. #==============================================================================
  113. # ▼ Compatibility
  114. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  115. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  116. # it will run with RPG Maker VX without adjusting.
  117. #
  118. # This script is compatible with Yanfly Engine Ace - Ace Shop Options v1.00+.
  119. # The position of this script does not matter relative to the other script.
  120. #
  121. #==============================================================================

  122. module YEA
  123.   module COMMON_EVENT_SHOP
  124.    
  125.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  126.     # - General Settings -
  127.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  128.     # These settings below adjust the default costs for common events (if no
  129.     # custom costs are used), the default icons used, and what kinds of common
  130.     # events are sold for each of the shop ID's.
  131.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  132.     DEFAULT_COST = 1000        # Default gold cost for common events.
  133.     DEFAULT_ICON = 236         # Default icon used for common events.
  134.    
  135.     # This hash adjusts the common events sold in each of the shop ID's. Insert
  136.     # the common events you want sold inside of the arrays with the shop ID as
  137.     # the hash key. You can use number ranges to add common events quicker.
  138.     SHOPS ={
  139.     # ID  => [Common Event ID's],
  140.        1  => [1, 2..8, 9, 10],
  141.        2  => [11..20],
  142.        3  => [21..30],
  143.     } # Do not remove this.
  144.    
  145.   end # COMMON_EVENT_SHOP
  146. end # YEA

  147. #==============================================================================
  148. # ▼ Editting anything past this point may potentially result in causing
  149. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  150. # halitosis so edit at your own risk.
  151. #==============================================================================

  152. module YEA
  153.   module COMMON_EVENT_SHOP
  154.     module_function
  155.     #--------------------------------------------------------------------------
  156.     # convert_integer_array
  157.     #--------------------------------------------------------------------------
  158.     def convert_integer_array(array)
  159.       result = []
  160.       array.each { |i|
  161.         case i
  162.         when Range; result |= i.to_a
  163.         when Integer; result |= [i]
  164.         end }
  165.       return result
  166.     end
  167.     #--------------------------------------------------------------------------
  168.     # convert_full_hash
  169.     #--------------------------------------------------------------------------
  170.     def convert_full_hash(hash)
  171.       result = {}
  172.       hash.each { |key| result[key[0]] = convert_integer_array(key[1]) }
  173.       return result
  174.     end
  175.     #--------------------------------------------------------------------------
  176.     # converted_contants
  177.     #--------------------------------------------------------------------------
  178.     SHOPS = convert_full_hash(SHOPS)
  179.   end # COMMON_EVENT_SHOP
  180.   module REGEXP
  181.   module COMMONEVENT
  182.    
  183.     COST                 = /<(?:COST|shop cost):[ ](\d+)>/i
  184.     IMAGE                = /<(?:IMAGE|image):[ ](.*)>/i
  185.     ICON_INDEX           = /<(?:ICON|icon index):[ ](\d+)>/i
  186.     EVENT_TYPE_EXIT      = /<(?:EXIT_SHOP|exit shop)>/i
  187.     SHOP_VARIABLES       =
  188.       /<(?:SHOP_VARIABLES|shop variables):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  189.     HELP_DESCRIPTION_ON  = /<(?:HELP_DESCRIPTION|help description)>/i
  190.     HELP_DESCRIPTION_OFF = /<\/(?:HELP_DESCRIPTION|help description)>/i
  191.     SHOP_DATA_ON         = /<(?:SHOP_DATA|shop data)>/i
  192.     SHOP_DATA_OFF        = /<\/(?:SHOP_DATA|shop data)>/i
  193.     SHOP_ENABLE_SWITCH   =
  194.       /<(?:SHOP_ENABLE_SWITCH|shop enable switch):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  195.     SHOP_SHOW_SWITCH     =
  196.       /<(?:SHOP_SHOW_SWITCH|shop show switch):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  197.     SHOP_ENABLE_EVAL_ON  = /<(?:SHOP_ENABLE_EVAL|shop enable eval)>/i
  198.     SHOP_ENABLE_EVAL_OFF = /<\/(?:SHOP_ENABLE_EVAL|shop enable eval)>/i
  199.     SHOP_SHOW_EVAL_ON    = /<(?:SHOP_SHOW_EVAL|shop show eval)>/i
  200.     SHOP_SHOW_EVAL_OFF   = /<\/(?:SHOP_SHOW_EVAL|shop show eval)>/i
  201.    
  202.   end # COMMONEVENT
  203.   end # REGEXP
  204. end # YEA

  205. #==============================================================================
  206. # ■ Numeric
  207. #==============================================================================

  208. class Numeric
  209.   
  210.   #--------------------------------------------------------------------------
  211.   # new method: group_digits
  212.   #--------------------------------------------------------------------------
  213.   unless $imported["YEA-CoreEngine"]
  214.   def group; return self.to_s; end
  215.   end # $imported["YEA-CoreEngine"]
  216.    
  217. end # Numeric

  218. #==============================================================================
  219. # ■ DataManager
  220. #==============================================================================

  221. module DataManager
  222.   
  223.   #--------------------------------------------------------------------------
  224.   # alias method: load_database
  225.   #--------------------------------------------------------------------------
  226.   class <<self; alias load_database_ces load_database; end
  227.   def self.load_database
  228.     load_database_ces
  229.     load_notetags_ces
  230.   end
  231.   
  232.   #--------------------------------------------------------------------------
  233.   # new method: load_notetags_ces
  234.   #--------------------------------------------------------------------------
  235.   def self.load_notetags_ces
  236.     groups = [$data_common_events]
  237.     for group in groups
  238.       for obj in group
  239.         next if obj.nil?
  240.         obj.load_notetags_ces
  241.       end
  242.     end
  243.   end
  244.   
  245. end # DataManager

  246. #==============================================================================
  247. # ■ RPG::Actor
  248. #==============================================================================

  249. class RPG::CommonEvent
  250.   
  251.   #--------------------------------------------------------------------------
  252.   # public instance variables
  253.   #--------------------------------------------------------------------------
  254.   attr_accessor :cost
  255.   attr_accessor :description
  256.   attr_accessor :event_type
  257.   attr_accessor :icon_index
  258.   attr_accessor :image
  259.   attr_accessor :shop_variables
  260.   attr_accessor :shop_data
  261.   attr_accessor :shop_enable_switch
  262.   attr_accessor :shop_enable_eval
  263.   attr_accessor :shop_show_switch
  264.   attr_accessor :shop_show_eval
  265.   
  266.   #--------------------------------------------------------------------------
  267.   # common cache: load_notetags_ces
  268.   #--------------------------------------------------------------------------
  269.   def load_notetags_ces
  270.     @cost = YEA::COMMON_EVENT_SHOP::DEFAULT_COST
  271.     @description = ""
  272.     @event_type = :instore
  273.     @icon_index = YEA::COMMON_EVENT_SHOP::DEFAULT_ICON
  274.     @image = nil
  275.     @shop_variables = []
  276.     @shop_data = ""
  277.     @shop_enable_switch = []
  278.     @shop_enable_eval = nil
  279.     @shop_show_switch = []
  280.     @shop_show_eval = nil
  281.     @help_description_on = false
  282.     @shop_data_on = false
  283.     @shop_enable_eval_on = false
  284.     @shop_show_eval_on = false
  285.     #---
  286.     self.note.split(/[\r\n]+/).each { |line|
  287.       case line
  288.       #---
  289.       when YEA::REGEXP::COMMONEVENT::COST
  290.         @cost = $1.to_i
  291.       when YEA::REGEXP::COMMONEVENT::ICON_INDEX
  292.         @icon_index = $1.to_i
  293.       when YEA::REGEXP::COMMONEVENT::IMAGE
  294.         @image = $1.to_s
  295.       #---
  296.       when YEA::REGEXP::COMMONEVENT::EVENT_TYPE_EXIT
  297.         @event_type = :exit
  298.       #---
  299.       when YEA::REGEXP::COMMONEVENT::SHOP_VARIABLES
  300.         $1.scan(/\d+/).each { |num|
  301.         @shop_variables.push(num.to_i) if num.to_i > 0 }
  302.       when YEA::REGEXP::COMMONEVENT::SHOP_ENABLE_SWITCH
  303.         $1.scan(/\d+/).each { |num|
  304.         @shop_enable_switch.push(num.to_i) if num.to_i > 0 }
  305.       when YEA::REGEXP::COMMONEVENT::SHOP_SHOW_SWITCH
  306.         $1.scan(/\d+/).each { |num|
  307.         @shop_show_switch.push(num.to_i) if num.to_i > 0 }
  308.       #---
  309.       when YEA::REGEXP::COMMONEVENT::HELP_DESCRIPTION_ON
  310.         @help_description_on = true
  311.       when YEA::REGEXP::COMMONEVENT::HELP_DESCRIPTION_OFF
  312.         @help_description_on = false
  313.       when YEA::REGEXP::COMMONEVENT::SHOP_DATA_ON
  314.         @shop_data_on = true
  315.       when YEA::REGEXP::COMMONEVENT::SHOP_DATA_OFF
  316.         @shop_data_on = false
  317.       when YEA::REGEXP::COMMONEVENT::SHOP_ENABLE_EVAL_ON
  318.         @shop_enable_eval = ""
  319.         @shop_enable_eval_on = true
  320.       when YEA::REGEXP::COMMONEVENT::SHOP_ENABLE_EVAL_OFF
  321.         @shop_enable_eval_on = false
  322.       when YEA::REGEXP::COMMONEVENT::SHOP_SHOW_EVAL_ON
  323.         @shop_show_eval = ""
  324.         @shop_show_eval_on = true
  325.       when YEA::REGEXP::COMMONEVENT::SHOP_SHOW_EVAL_OFF
  326.         @shop_show_eval_on = false
  327.       else
  328.         @description += line.to_s if @help_description_on
  329.         @shop_data += line.to_s if @shop_data_on
  330.         @shop_enable_eval += line.to_s if @shop_enable_eval_on
  331.         @shop_show_eval += line.to_s if @shop_show_eval_on
  332.       #---
  333.       end
  334.     } # self.note.split
  335.     #---
  336.     @description.gsub!(/[|]/i) { "\n" }
  337.     @shop_data.gsub!(/[|]/i) { "\n" }
  338.   end
  339.   
  340.   #--------------------------------------------------------------------------
  341.   # new method: note
  342.   #--------------------------------------------------------------------------
  343.   def note
  344.     @note = ""
  345.     @list.each { |event|
  346.       next if event.nil?
  347.       next unless [108, 408].include?(event.code)
  348.       @note += event.parameters[0] + "\r\n"
  349.     } # Do not remove
  350.     return @note
  351.   end
  352.   
  353. end # RPG::Actor

  354. #==============================================================================
  355. # ■ Game_Interpreter
  356. #==============================================================================

  357. class Game_Interpreter
  358.   
  359.   #--------------------------------------------------------------------------
  360.   # common_event_shop
  361.   #--------------------------------------------------------------------------
  362.   def common_event_shop(shop_id)
  363.     return unless SceneManager.scene_is?(Scene_Map)
  364.     return unless YEA::COMMON_EVENT_SHOP::SHOPS.include?(shop_id)
  365.     SceneManager.call(Scene_CommonEventShop)
  366.     goods = YEA::COMMON_EVENT_SHOP::SHOPS[shop_id]
  367.     SceneManager.scene.prepare(goods)
  368.   end
  369.   
  370. end # Game_Interpreter

  371. #==============================================================================
  372. # ■ Spriteset_CommonEventShop
  373. #==============================================================================

  374. class Spriteset_CommonEventShop < Spriteset_Map
  375.   
  376.   #--------------------------------------------------------------------------
  377.   # initialize
  378.   #--------------------------------------------------------------------------
  379.   def initialize
  380.     create_viewports
  381.     create_pictures
  382.     update
  383.   end
  384.   
  385.   #--------------------------------------------------------------------------
  386.   # create_viewports
  387.   #--------------------------------------------------------------------------
  388.   def create_viewports
  389.     @viewport = Viewport.new
  390.     @viewport.z = 2000
  391.   end
  392.   
  393.   #--------------------------------------------------------------------------
  394.   # dispose
  395.   #--------------------------------------------------------------------------
  396.   def dispose
  397.     dispose_pictures
  398.     dispose_viewports
  399.   end
  400.   
  401.   #--------------------------------------------------------------------------
  402.   # dispose_viewports
  403.   #--------------------------------------------------------------------------
  404.   def dispose_viewports
  405.     @viewport.dispose
  406.   end
  407.   
  408.   #--------------------------------------------------------------------------
  409.   # update
  410.   #--------------------------------------------------------------------------
  411.   def update
  412.     update_pictures
  413.     update_viewports
  414.   end
  415.   
  416.   #--------------------------------------------------------------------------
  417.   # update_viewports
  418.   #--------------------------------------------------------------------------
  419.   def update_viewports
  420.     @viewport.update
  421.   end
  422.   
  423.   #--------------------------------------------------------------------------
  424.   # update_pictures
  425.   #--------------------------------------------------------------------------
  426.   def update_pictures
  427.     $game_map.screen.pictures.each do |pic|
  428.       @picture_sprites[pic.number] ||= Sprite_Picture.new(@viewport, pic)
  429.       @picture_sprites[pic.number].update
  430.     end
  431.   end
  432.   
  433. end # Spriteset_CommonEventShop

  434. #==============================================================================
  435. # ■ Window_Message
  436. #==============================================================================

  437. class Window_Message < Window_Base
  438.   
  439.   #--------------------------------------------------------------------------
  440.   # public instance variables
  441.   #--------------------------------------------------------------------------
  442.   attr_accessor :back_sprite
  443.   
  444. end # Window_Message

  445. #==============================================================================
  446. # ■ Window_CommonEventShopCommand
  447. #==============================================================================

  448. class Window_CommonEventShopCommand < Window_ShopCommand
  449.   
  450.   #--------------------------------------------------------------------------
  451.   # col_max
  452.   #--------------------------------------------------------------------------
  453.   def col_max
  454.     return super if $imported["YEA-ShopOptions"]
  455.     return 2
  456.   end
  457.   
  458.   #--------------------------------------------------------------------------
  459.   # make_command_list
  460.   #--------------------------------------------------------------------------
  461.   def make_command_list
  462.     add_command(Vocab::ShopBuy,    :buy)
  463.     add_command(Vocab::ShopCancel, :cancel)
  464.   end
  465.   
  466. end # Window_CommonEventShopCommand

  467. #==============================================================================
  468. # ■ Window_CommonEventShopStatus
  469. #==============================================================================

  470. class Window_CommonEventShopStatus < Window_ShopStatus
  471.   
  472.   #--------------------------------------------------------------------------
  473.   # update_page
  474.   #--------------------------------------------------------------------------
  475.   def update_page
  476.   end
  477.   
  478.   #--------------------------------------------------------------------------
  479.   # refresh
  480.   #--------------------------------------------------------------------------
  481.   def refresh
  482.     contents.clear
  483.     reset_font_settings
  484.     draw_shop_variables
  485.   end
  486.   
  487.   #--------------------------------------------------------------------------
  488.   # draw_shop_variables
  489.   #--------------------------------------------------------------------------
  490.   def draw_shop_variables
  491.     return if @item.nil?
  492.     dy = 0
  493.     for variable_id in @item.shop_variables
  494.       next if $game_variables[variable_id].nil?
  495.       draw_variable_info(variable_id, dy)
  496.       dy += line_height
  497.       return if dy + line_height > contents.height
  498.     end
  499.   end
  500.   
  501.   #--------------------------------------------------------------------------
  502.   # draw_variable_info
  503.   #--------------------------------------------------------------------------
  504.   def draw_variable_info(variable_id, dy)
  505.     change_color(system_color)
  506.     name = $data_system.variables[variable_id]
  507.     draw_text(4, dy, contents.width - 8, line_height, name)
  508.     change_color(normal_color)
  509.     value = $game_variables[variable_id]
  510.     value = value.group if value.is_a?(Integer)
  511.     draw_text(4, dy, contents.width - 8, line_height, value, 2)
  512.   end
  513.   
  514. end # Window_CommonEventShopStatus

  515. #==============================================================================
  516. # ■ Window_CommonEventShopBuy
  517. #==============================================================================

  518. class Window_CommonEventShopBuy < Window_ShopBuy
  519.   
  520.   #--------------------------------------------------------------------------
  521.   # make_item_list
  522.   #--------------------------------------------------------------------------
  523.   def make_item_list
  524.     @data = []
  525.     @price = {}
  526.     @shop_goods.each do |event_id|
  527.       next if $data_common_events[event_id].nil?
  528.       item = $data_common_events[event_id]
  529.       next unless include?(item)
  530.       @data.push(item)
  531.       @price[item] = item.cost
  532.     end
  533.   end
  534.   
  535.   #--------------------------------------------------------------------------
  536.   # include?
  537.   #--------------------------------------------------------------------------
  538.   def include?(item)
  539.     return false unless show_show_switch?(item)
  540.     return false unless shop_show_eval?(item)
  541.     return true
  542.   end
  543.   
  544.   #--------------------------------------------------------------------------
  545.   # show_show_switch?
  546.   #--------------------------------------------------------------------------
  547.   def show_show_switch?(item)
  548.     return false if item.nil?
  549.     for switch_id in item.shop_show_switch
  550.       return false unless $game_switches[switch_id]
  551.     end
  552.     return true
  553.   end
  554.   
  555.   #--------------------------------------------------------------------------
  556.   # shop_show_eval?
  557.   #--------------------------------------------------------------------------
  558.   def shop_show_eval?(item)
  559.     return false if item.nil?
  560.     return true if item.shop_show_eval.nil?
  561.     return eval(item.shop_show_eval)
  562.   end
  563.   
  564.   #--------------------------------------------------------------------------
  565.   # draw_item_name
  566.   #--------------------------------------------------------------------------
  567.   def draw_item_name(item, dx, dy, enabled = true, dw = 172)
  568.     return if item.nil?
  569.     draw_icon(item.icon_index, dx, dy, enabled)
  570.     change_color(normal_color, enabled)
  571.     draw_text(dx+24, dy, dw, line_height, item.name)
  572.   end
  573.   
  574.   #--------------------------------------------------------------------------
  575.   # enable?
  576.   #--------------------------------------------------------------------------
  577.   def enable?(item)
  578.     return false unless shop_enable_switch?(item)
  579.     return false unless shop_enable_eval?(item)
  580.     return !item.nil? && (price(item) <= @money)
  581.   end
  582.   
  583.   #--------------------------------------------------------------------------
  584.   # shop_enable_switch?
  585.   #--------------------------------------------------------------------------
  586.   def shop_enable_switch?(item)
  587.     return false if item.nil?
  588.     for switch_id in item.shop_enable_switch
  589.       return false unless $game_switches[switch_id]
  590.     end
  591.     return true
  592.   end
  593.   
  594.   #--------------------------------------------------------------------------
  595.   # shop_req_eval?
  596.   #--------------------------------------------------------------------------
  597.   def shop_enable_eval?(item)
  598.     return false if item.nil?
  599.     return true if item.shop_enable_eval.nil?
  600.     return eval(item.shop_enable_eval)
  601.   end
  602.   
  603. end # Window_CommonEventShopBuy

  604. #==============================================================================
  605. # ■ Window_CommonEventShopData
  606. #==============================================================================

  607. class Window_CommonEventShopData < Window_Base
  608.   
  609.   #--------------------------------------------------------------------------
  610.   # initialize
  611.   #--------------------------------------------------------------------------
  612.   def initialize(dx, dy, item_window)
  613.     super(dx, dy, Graphics.width - dx, fitting_height(4))
  614.     @item_window = item_window
  615.     @item = nil
  616.     refresh
  617.   end
  618.   
  619.   #--------------------------------------------------------------------------
  620.   # item_window=
  621.   #--------------------------------------------------------------------------
  622.   def item_window= (window)
  623.     @item_window = window
  624.     update_item(@item_window.item)
  625.   end
  626.   
  627.   #--------------------------------------------------------------------------
  628.   # update
  629.   #--------------------------------------------------------------------------
  630.   def update
  631.     super
  632.     update_item(@item_window.item)
  633.   end
  634.   
  635.   #--------------------------------------------------------------------------
  636.   # update_item
  637.   #--------------------------------------------------------------------------
  638.   def update_item(item)
  639.     return if @item == item
  640.     @item = item
  641.     refresh
  642.   end
  643.   
  644.   #--------------------------------------------------------------------------
  645.   # refresh
  646.   #--------------------------------------------------------------------------
  647.   def refresh
  648.     contents.clear
  649.     reset_font_settings
  650.     draw_empty
  651.     return if @item.nil?
  652.     draw_item_image
  653.     draw_item_data
  654.   end
  655.   
  656.   #--------------------------------------------------------------------------
  657.   # draw_empty
  658.   #--------------------------------------------------------------------------
  659.   def draw_empty
  660.     colour = Color.new(0, 0, 0, translucent_alpha/2)
  661.     rect = Rect.new(1, 1, 94, 94)
  662.     contents.fill_rect(rect, colour)
  663.     dx = 96; dy = 0
  664.     dw = contents.width - 96
  665.     for i in 0...4
  666.       draw_background_box(dx, dy, dw)
  667.       dy += line_height
  668.     end
  669.   end
  670.   
  671.   #--------------------------------------------------------------------------
  672.   # draw_background_box
  673.   #--------------------------------------------------------------------------
  674.   def draw_background_box(dx, dy, dw)
  675.     colour = Color.new(0, 0, 0, translucent_alpha/2)
  676.     rect = Rect.new(dx+1, dy+1, dw-2, line_height-2)
  677.     contents.fill_rect(rect, colour)
  678.   end
  679.   
  680.   #--------------------------------------------------------------------------
  681.   # draw_item_image
  682.   #--------------------------------------------------------------------------
  683.   def draw_item_image
  684.     if @item.image.nil?
  685.       icon_index = @item.icon_index
  686.       bitmap = Cache.system("Iconset")
  687.       rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  688.       target = Rect.new(0, 0, 96, 96)
  689.       contents.stretch_blt(target, bitmap, rect)
  690.     else
  691.       bitmap = Cache.picture(@item.image)
  692.       contents.blt(0, 0, bitmap, bitmap.rect, 255)
  693.     end
  694.   end
  695.   
  696.   #--------------------------------------------------------------------------
  697.   # draw_item_data
  698.   #--------------------------------------------------------------------------
  699.   def draw_item_data
  700.     draw_text_ex(98, 0, @item.shop_data)
  701.   end
  702.   
  703. end # Window_CommonEventShopData

  704. #==============================================================================
  705. # ■ Scene_CommonEventShop
  706. #==============================================================================

  707. class Scene_CommonEventShop < Scene_Shop
  708.   
  709.   #--------------------------------------------------------------------------
  710.   # prepare
  711.   #--------------------------------------------------------------------------
  712.   def prepare(goods)
  713.     @goods = goods
  714.     @purchase_only = true
  715.   end
  716.   
  717.   #--------------------------------------------------------------------------
  718.   # start
  719.   #--------------------------------------------------------------------------
  720.   def start
  721.     super
  722.     setup_interpreter
  723.   end
  724.   
  725.   #--------------------------------------------------------------------------
  726.   # terminate
  727.   #--------------------------------------------------------------------------
  728.   def terminate
  729.     @spriteset.dispose
  730.     super
  731.   end
  732.   
  733.   #--------------------------------------------------------------------------
  734.   # create_command_window
  735.   #--------------------------------------------------------------------------
  736.   def create_command_window
  737.     wx = @gold_window.x
  738.     @command_window = Window_CommonEventShopCommand.new(wx, false)
  739.     @command_window.viewport = @viewport
  740.     @command_window.y = @help_window.height
  741.     @command_window.set_handler(:buy,    method(:command_buy))
  742.     @command_window.set_handler(:sell,   method(:command_sell))
  743.     @command_window.set_handler(:cancel, method(:return_scene))
  744.   end
  745.   
  746.   #--------------------------------------------------------------------------
  747.   # create_status_window
  748.   #--------------------------------------------------------------------------
  749.   def create_status_window
  750.     wx = @number_window.width
  751.     wy = @dummy_window.y
  752.     ww = Graphics.width - wx
  753.     wh = @dummy_window.height
  754.     @status_window = Window_CommonEventShopStatus.new(wx, wy, ww, wh)
  755.     @status_window.viewport = @viewport
  756.     @status_window.hide
  757.   end
  758.   
  759.   #--------------------------------------------------------------------------
  760.   # create_buy_window
  761.   #--------------------------------------------------------------------------
  762.   def create_buy_window
  763.     wy = @dummy_window.y
  764.     wh = @dummy_window.height
  765.     @buy_window = Window_CommonEventShopBuy.new(0, wy, wh, @goods)
  766.     @buy_window.viewport = @viewport
  767.     @buy_window.help_window = @help_window
  768.     @buy_window.status_window = @status_window
  769.     @buy_window.hide
  770.     @buy_window.set_handler(:ok,     method(:on_buy_ok))
  771.     @buy_window.set_handler(:cancel, method(:on_buy_cancel))
  772.   end
  773.   
  774.   #--------------------------------------------------------------------------
  775.   # create_data_window
  776.   #--------------------------------------------------------------------------
  777.   def create_data_window
  778.     return unless $imported["YEA-ShopOptions"]
  779.     wx = @command_window.width
  780.     wy = @command_window.y
  781.     @data_window = Window_CommonEventShopData.new(wx, wy, @buy_window)
  782.     @data_window.viewport = @viewport
  783.   end
  784.   
  785.   #--------------------------------------------------------------------------
  786.   # setup_interpreter
  787.   #--------------------------------------------------------------------------
  788.   def setup_interpreter
  789.     @interpreter = Game_Interpreter.new
  790.     @message_window = Window_Message.new
  791.     @message_window.back_opacity = 255
  792.     @message_window.back_sprite.viewport = @viewport
  793.     @spriteset = Spriteset_CommonEventShop.new
  794.   end
  795.   
  796.   #--------------------------------------------------------------------------
  797.   # update_interpreter
  798.   #--------------------------------------------------------------------------
  799.   def update_interpreter
  800.     update_basic
  801.     @interpreter.update
  802.   end
  803.   
  804.   #--------------------------------------------------------------------------
  805.   # update_basic
  806.   #--------------------------------------------------------------------------
  807.   def update_basic
  808.     $game_map.screen.update_pictures
  809.     @spriteset.update
  810.     super
  811.   end
  812.   
  813.   #--------------------------------------------------------------------------
  814.   # on_buy_ok
  815.   #--------------------------------------------------------------------------
  816.   def on_buy_ok
  817.     perform_buy
  818.     instore_event
  819.     exit_event
  820.   end
  821.   
  822.   #--------------------------------------------------------------------------
  823.   # perform_buy
  824.   #--------------------------------------------------------------------------
  825.   def perform_buy
  826.     Sound.play_shop
  827.     $game_party.lose_gold(@buy_window.price(@buy_window.item))
  828.     @buy_window.money = money
  829.     @gold_window.refresh
  830.   end
  831.   
  832.   #--------------------------------------------------------------------------
  833.   # instore_event
  834.   #--------------------------------------------------------------------------
  835.   def instore_event
  836.     event = @buy_window.item
  837.     return unless event.event_type == :instore
  838.     $game_temp.reserve_common_event(event.id)
  839.     @interpreter.setup_reserved_common_event
  840.     update_interpreter while @interpreter.running?
  841.     common_event_refresh_windows
  842.   end
  843.   
  844.   #--------------------------------------------------------------------------
  845.   # exit_event
  846.   #--------------------------------------------------------------------------
  847.   def exit_event
  848.     event = @buy_window.item
  849.     return unless event.event_type == :exit
  850.     $game_temp.reserve_common_event(event.id)
  851.     return_scene
  852.   end
  853.   
  854.   #--------------------------------------------------------------------------
  855.   # common_event_refresh_windows
  856.   #--------------------------------------------------------------------------
  857.   def common_event_refresh_windows
  858.     @buy_window.activate
  859.     @buy_window.money = money
  860.     @buy_window.refresh
  861.     @buy_window.select([@buy_window.index, @buy_window.item_max - 1].min)
  862.     @status_window.refresh
  863.     @gold_window.refresh
  864.     @data_window.refresh unless @data_window.nil?
  865.   end
  866.   
  867. end # Scene_CommonEventShop

  868. #==============================================================================
  869. #
  870. # ▼ End of File
  871. #
  872. #==============================================================================
复制代码
似乎是一個利用公共事件創立的一個任務腳本
不過我英文能力有限

您可以修改的幫助說明,圖標,成本,右側所示的變量,並通過註釋標記的數據窗口中的文本。

<cost: x>
設置常見的事件以x金錢成本。

<icon: x>
更改X圖標指數為常見的事件中所使用的圖標。

<image:說明>
更改使用常見的事件名“字符串”圖形 \圖片 \文件夾中發現圖像。

<help description>
說明
</help description>
設置在店內現場幫助窗口中使用的文本。 在notebox多線將串成。 使用|換行符。 文本代碼可以使用裡面的幫助說明。

<shop data>
說明
</shop data>
可以使用,如果你有Yanfly引擎ACE - ACE鋪選項安裝。 設置店裡面的數據窗口中顯示的文本字符串。 使用|換行符。 文本代碼可以使用裡面的店鋪數據文本。

<shop variables: X>
<shop variables: x, x>
這台在屏幕右下角的狀態窗口中顯示的變量 x。 這個 notetag插入的倍數狀態窗口內顯示更多的變數。

点评

应表明是ace的脚本。  发表于 2012-1-23 20:57

评分

参与人数 1星屑 +40 收起 理由
无双sxa + 40 我很赞同

查看全部评分

Lv4.逐梦者

梦石
0
星屑
5463
在线时间
2562 小时
注册时间
2011-9-27
帖子
1120

极短23参与开拓者

2
发表于 2012-1-25 15:05:08 | 只看该作者
什么时候,论坛的code 能出现语法高亮呢? 一片灰蒙蒙的,没有心情看。

点评

全是英文就更没心情看了……  发表于 2012-1-27 19:42
从平淡走向更平淡。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-25 10:13

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表