设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 130|回复: 0

[转载发布] Trilobytes VX Ace #1: Shop unlocks

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58883
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68848

    灌水之王

    发表于 2026-8-2 16:52:31 | 显示全部楼层 |阅读模式


    Shop Unlocks version 1.03
    Created by Trihan


    Introduction
    This is a script which allows you  to use notetags in items, weapons and armours that will require you to sell a number of other items to a shop in order to unlock that item for purchase. It was originally written as a commission for Clyve back in 2012 but as it's been 5 years and he doesn't appear to be part of the community any more I decided to release it to the public under my Trilobytes brand.

    Features
    - Make unlockable items in the same vein as Etrian Odyssey.
    - Adds categories to the buy window.
    - Compatible with Yanfly's Ace Shop Options script.

    Screenshots
    Spoiler: Screenshots













    How to Use
    Install the script somewhere above main. If using Yanfly's Ace Shop Options, place this script below it.

    To make an item unlockable, use the notetag "<require [IWA][item ID], [quantity]>" where [IWA] is either I (Item), W (Weapon) or A (Armor), item ID is the ID of the item type in the relevant database tab, and quantity is the number of that item required. For example, "<require I1, 5>" means that the item with that notetag will be unlocked after you sell 5 of item 1 to shops. This doesn't have to be all at once; the number you have sold throughout the game is tracked. Because Ace doesn't differentiate between shops, you can sell the items to any event that has a shop processing command (unless it's purchase-only). Note that any item that you want a shop to unlock must be included in its sellable goods list; it won't be there initially but will appear as soon as you meet its requirements. If you don't include an item in the shop goods list, it won't be unlocked in that shop.

    Demo
    No demo available at present.

    Script
    Spoiler: Code
                    Code:       
    1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
    2. #  ▼ Shop unlocks script
    3. #  Author: Trihan
    4. #  Version 1.03
    5. #  Release date: 07/05/2012
    6. #
    7. #  Thanks to Prexus for helping with the data structure.
    8. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
    9. #-------------------------------------------------------------------------------------------------
    10. #  ▼ UPDATES
    11. #-------------------------------------------------------------------------------------------------
    12. # # 12/06/2012. Fixed a bug where closing the shop and reopening it would result
    13. # # in weapons/armour being removed from the list if the item or weapon with the
    14. # # same ID had already been added.
    15. # # 11/06/2012 - Fixed a compatibility bug with Enelvon/Seiryuki's sell-only
    16. # # script and Ace Shop Options where Sellonly made my category confirm code
    17. # # crash.
    18. # # 08/05/2012. Compatibility added for Yanfly's Ace Shop Options
    19. # # 07/05/2012. Original release
    20. #-------------------------------------------------------------------------------------------------
    21. #  ▼ TERMS OF USAGE
    22. #-------------------------------------------------------------------------------------------------
    23. # #  You are free to adapt this work to suit your needs.
    24. # #  You can use this work for commercial purposes if you like it.
    25. # #  Credit is appreciated.
    26. # #
    27. # # For support:
    28. # # rmrk.net
    29. # # rpgmaker.net
    30. #-------------------------------------------------------------------------------------------------
    31. #  ▼ INTRODUCTION
    32. #-------------------------------------------------------------------------------------------------
    33. # # Enables shop items to be unlocked by selling a number of required items.
    34. # # The unlocked items will be added to all shops once the requirements are met,
    35. # # as the script doesn't differentiate between vendors. If you want unlocks to
    36. # # be specified to the shop, some changes will be necessary. If you need help
    37. # # doing this feel free to contact me.
    38. # #
    39. # # Because this can potentially result in shops having a lot of things you can
    40. # # buy, I've also retooled the buy window so it uses categories like selling
    41. # # does. At the moment this includes the "Key Items" category, though hopefully
    42. # # I'll eventually disable or remove that for buying. I've also made it
    43. # # compatible with Yanfly's Ace Shop Options script for those who like using
    44. # # that.
    45. #-------------------------------------------------------------------------------------------------
    46. #  ▼ INSTRUCTIONS
    47. #-------------------------------------------------------------------------------------------------
    48. # # Only one notetag is needed on the unlockable item. You can have as many tags
    49. # # as you wish.
    50. # #
    51. # # <require [IWA][item ID], [quantity]>
    52. # #
    53. # # Where the letter denotes [I]tem, [W]eapon or [A]rmour, ID is the number of
    54. # # the item from the database, and quantity is how many need be sold to unlock.
    55. # #
    56. # # Example: <require I1, 5>
    57. # # This means the item requires you to sell 5 of item ID 1 to unlock it for
    58. # # purchase.
    59. #-------------------------------------------------------------------------------------------------
    60. #  ▼ COMPATIBILITY
    61. #-------------------------------------------------------------------------------------------------
    62. # # List of aliases and overwrites:
    63. # #
    64. # # RPG::BaseItem
    65. # # sell_req (new attr method)
    66. # # load_item_notetags (new method)
    67. # #
    68. # # DataManager
    69. # # load_database (alias)
    70. # # load_item_notetags (new method)
    71. # # init_shopsales_data (new method)
    72. # # make_save_contents (overload)
    73. # # extract_save_contents (alias)
    74. # #
    75. # # Window_ShopCategory
    76. # # make_command_list (overload)
    77. # #
    78. # # Window_ShopBuy
    79. # # initialize (overload)
    80. # # category= (new method)
    81. # # make_item_list (alias)
    82. # #
    83. # # Scene_Shop
    84. # # added_items (new attr method)
    85. # # prepare (alias)
    86. # # start (alias)
    87. # # create_status_window (alias)
    88. # # create_buy_window (alias)
    89. # # create_unlocks_window (new method)
    90. # # add_available_goods (new method)
    91. # # do_sell (alias)
    92. # # command_buy (overload)
    93. # # command_sell (alias)
    94. # # on_buy_cancel (overload)
    95. # # on_category_ok (overload)
    96. # # on_category_cancel (alias)
    97. # # added_items (new method)
    98. # # activate_unlocks_window (new method)
    99. # # on_unlock_continue (new method)
    100. # # on_unlock_cancel (new method)
    101. # # item_type (new method)
    102. # # end_number_input (overload)
    103. # #
    104. # # This script has been specifically designed to be fully compatible with
    105. # # Yanfly's Ace Shop Options script. If there are any issues using this script
    106. # # alongside it, please let me know so I can fix them.
    107. #-------------------------------------------------------------------------------------------------
    108. $imported = {} if $imported.nil?
    109. $imported['cshop'] = true
    110. puts 'Load: Shop script by Trihan'
    111. Shop = Struct.new(:map, :event, :sales, :unlocked_goods)
    112. class RPG::BaseItem
    113.   attr_reader :sell_req
    114.   attr_accessor :quantity
    115.   #--------------------------------------------------------------------------
    116.     # ● Loads the notetags
    117.     #--------------------------------------------------------------------------
    118.   def load_item_notetags
    119.     @sell_req = []
    120.     @quantity = -1
    121.         @note.split(/[\r\n]+/).each do |line|
    122.             case line
    123.             when CSHOP::REGEXP::ITEM_REQ
    124.         case $1
    125.         when "I"
    126.           @sell_req.push([0, $2.to_i, $3.to_i])
    127.         when "W"
    128.           @sell_req.push([1, $2.to_i, $3.to_i])
    129.         when "A"
    130.           @sell_req.push([2, $2.to_i, $3.to_i])
    131.         end
    132.       when CSHOP::REGEXP::SALE_QUANTITY
    133.         @quantity = $1.to_i
    134.       end
    135.         end
    136.     end
    137. end
    138. module DataManager
    139.    
    140.   # Initialize Shop Sales data
    141.   class <<self; alias shopsales_load_database load_database; end
    142.   #--------------------------------------------------------------------------
    143.     # ● Loads the database
    144.     #--------------------------------------------------------------------------
    145.   def self.load_database
    146.     shopsales_load_database
    147.     $data_shopsales = RPG::ShopSales.new
    148.     $data_shops = []
    149.     load_item_notetags
    150.   end
    151.   #--------------------------------------------------------------------------
    152.     # ● Loads the notetags
    153.     #--------------------------------------------------------------------------
    154.   def self.load_item_notetags
    155.         groups = [$data_items, $data_weapons, $data_armors]
    156.         for group in groups
    157.             for obj in group
    158.                 next if obj.nil?
    159.                 obj.load_item_notetags
    160.             end
    161.         end
    162.         puts "Read: Item Requirements Notetags"
    163.     end
    164.    
    165.   #--------------------------------------------------------------------------
    166.     # ● Dumps shop sales data into save file
    167.     #--------------------------------------------------------------------------
    168.   def self.make_save_contents
    169.     contents = {}
    170.     contents[:system]        = $game_system
    171.     contents[:timer]         = $game_timer
    172.     contents[:message]       = $game_message
    173.     contents[:switches]      = $game_switches
    174.     contents[:variables]     = $game_variables
    175.     contents[:self_switches] = $game_self_switches
    176.     contents[:actors]        = $game_actors
    177.     contents[:party]         = $game_party
    178.     contents[:troop]         = $game_troop
    179.     contents[:map]           = $game_map
    180.     contents[:player]        = $game_player
    181.     contents[:shopsales]     = $data_shopsales
    182.     contents[:shops]         = $data_shops
    183.     contents
    184.   end
    185.    
    186.   class <<self; alias shopsales_extract_save_contents extract_save_contents; end
    187.   #--------------------------------------------------------------------------
    188.     # ● Retrieves shop sales data when loading a game
    189.     #--------------------------------------------------------------------------
    190.   def self.extract_save_contents(contents)
    191.     shopsales_extract_save_contents(contents)
    192.     if contents[:shopsales]
    193.       $data_shopsales = contents[:shopsales]
    194.     else
    195.       $data_shopsales = RPG::ShopSales.new
    196.     end
    197.     if contents[:shops]
    198.       $data_shops = contents[:shops]
    199.     else
    200.       $data_shops = []
    201.     end
    202.   end
    203. end
    204. class Window_ShopCategory < Window_Command
    205.   #--------------------------------------------------------------------------
    206.     # ● Removes "key items" from the category list
    207.     #--------------------------------------------------------------------------
    208.   def make_command_list
    209.     add_command(Vocab::item,     :item)
    210.     add_command(Vocab::weapon,   :weapon)
    211.     add_command(Vocab::armor,    :armor)
    212.   end
    213. end
    214. class Window_ShopBuy < Window_Selectable
    215.   #--------------------------------------------------------------------------
    216.     # ● Initialises the buy window with a category of none
    217.     #--------------------------------------------------------------------------
    218.   def initialize(x, y, height, shop_goods, shop_id)
    219.     super(x, y, window_width, height)
    220.     @shop_goods = shop_goods
    221.     @current_id = shop_id
    222.     @money = 0
    223.     @category = :none
    224.     refresh
    225.     select(0)
    226.   end
    227.   #--------------------------------------------------------------------------
    228.     # ● Adds a category setting method for the buy window
    229.     #--------------------------------------------------------------------------
    230.   def category=(category)
    231.     return if @category == category
    232.     @category = category
    233.     refresh
    234.   end
    235.   alias :shopsales_make_item_list :make_item_list
    236.   #--------------------------------------------------------------------------
    237.     # ● Populates the buy window based on sales criteria
    238.     #--------------------------------------------------------------------------
    239.   def make_item_list
    240.     @data = []
    241.     @price = {}
    242.     @shop_goods.each do |goods|
    243.       case goods[0]
    244.         when 0;  item = $data_items[goods[1]]
    245.         when 1;  item = $data_weapons[goods[1]]
    246.         when 2;  item = $data_armors[goods[1]]
    247.       end
    248.       if item
    249.         include = true
    250.         if item.quantity == 0
    251.           include = false
    252.         end
    253.         case @category
    254.         when :item
    255.           if !item.is_a?(RPG::Item) || item.key_item?
    256.             include = false
    257.           end
    258.         when :weapon
    259.           if !item.is_a?(RPG::Weapon)
    260.             include = false
    261.           end
    262.         when :armor
    263.           if !item.is_a?(RPG::Armor)
    264.             include = false
    265.           end
    266.         when :key_item
    267.           if !item.key_item?
    268.             include = false
    269.           end
    270.         end
    271.         for req in item.sell_req
    272.           if req[0] == 0
    273.             if $data_shops[@current_id].sales.item_sales[req[1]] < req[2]
    274.               include = false
    275.             end
    276.           elsif req[0] == 1
    277.             if $data_shops[@current_id].sales.weapon_sales[req[1]] < req[2]
    278.               include = false
    279.             end
    280.           elsif req[0] == 2
    281.             if $data_shops[@current_id].sales.armor_sales[req[1]] < req[2]
    282.               include = false
    283.             end
    284.           end
    285.         end
    286.         if include == true
    287.           @data.push(item)
    288.           @price[item] = goods[2] == 0 ? item.price : goods[3]
    289.         end
    290.       end
    291.     end
    292.   end
    293. end
    294. class Scene_Shop < Scene_MenuBase
    295.   attr_reader :added_items
    296.   attr_reader :shop_map
    297.   attr_reader :shop_event
    298.   attr_reader :current_id
    299.    
    300.   alias :shopsales_prepare :prepare
    301.   #--------------------------------------------------------------------------
    302.     # ● Overload to add unlocked items to the buy list
    303.     #--------------------------------------------------------------------------
    304.   def prepare(goods, purchase_only)
    305.     shopsales_prepare(goods, purchase_only)
    306.     #add_available_goods
    307.   end
    308.   alias :shopsales_start :start
    309.   #--------------------------------------------------------------------------
    310.     # ● Overload to create the window that shows unlocked items
    311.     #--------------------------------------------------------------------------
    312.   def start
    313.     create_unlocks_window
    314.     @shop_map = $game_map.map_id
    315.     @shop_event = $game_map.interpreter.event_id
    316.     if $data_shops.size == 0
    317.       $data_shops.push Shop.new(@shop_map, @shop_event, RPG::ShopSales.new, [])
    318.     else
    319.       $data_shops.each do |shop|
    320.         if shop.map == @shop_map && shop.event == @shop_event
    321.           break
    322.         else
    323.           $data_shops.push Shop.new(@shop_map, @shop_event, RPG::ShopSales.new, [])
    324.         end
    325.       end
    326.     end
    327.     @current_id = $data_shops.index{|shop| shop.map == @shop_map && shop.event == @shop_event}
    328.     shopsales_start
    329.   end   
    330.   alias :shopsales_create_status_window :create_status_window
    331.   #--------------------------------------------------------------------------
    332.     # ● Alias to reposition the status window
    333.     #--------------------------------------------------------------------------
    334.   def create_status_window
    335.     if $imported['YEA-ShopOptions']
    336.       shopsales_create_status_window
    337.     else
    338.       wx = @number_window.width
    339.       wy = @dummy_window.y + 48
    340.       ww = Graphics.width - wx
    341.       wh = Graphics.height - wy
    342.       @status_window = Window_ShopStatus.new(wx, wy, ww, wh)
    343.       @status_window.viewport = @viewport
    344.       @status_window.hide
    345.     end
    346.   end
    347.   alias :shopsales_create_buy_window :create_buy_window
    348.   #--------------------------------------------------------------------------
    349.     # ● Alias to reposition the buy window
    350.     #--------------------------------------------------------------------------
    351.   def create_buy_window
    352.     if $imported['YEA-ShopOptions']
    353.       shopsales_create_buy_window
    354.     else
    355.       wy = @dummy_window.y + 48
    356.       wh = Graphics.height - wy
    357.       @buy_window = Window_ShopBuy.new(0, wy, wh, @goods, @current_id)
    358.       @buy_window.viewport = @viewport
    359.       @buy_window.help_window = @help_window
    360.       @buy_window.status_window = @status_window
    361.       @buy_window.hide
    362.       @buy_window.set_handler(:ok,     method(:on_buy_ok))
    363.       @buy_window.set_handler(:cancel, method(:on_buy_cancel))
    364.     end
    365.   end
    366.   #--------------------------------------------------------------------------
    367.     # ● Creates the window that shows unlocked items
    368.     #--------------------------------------------------------------------------
    369.   def create_unlocks_window
    370.     @unlock_window = Window_Unlocks.new
    371.     @unlock_window.viewport = @viewport
    372.     @unlock_window.x = (Graphics.width - @unlock_window.width) / 2
    373.     @unlock_window.y = (Graphics.height - @unlock_window.height) / 2
    374.     @unlock_window.z = 255
    375.     @unlock_window.set_handler(:ok,        method(:on_unlock_continue))
    376.     @unlock_window.set_handler(:cancel,    method(:on_unlock_cancel))
    377.     @unlock_window.hide
    378.   end
    379.    
    380.   #--------------------------------------------------------------------------
    381.     # ● Adds unlocked items to the goods list
    382.     #--------------------------------------------------------------------------
    383.   def add_available_goods
    384.     for i in 1...$data_items.size
    385.       if !$data_items[i].sell_req.empty?
    386.         include = true
    387.         for req in $data_items[i].sell_req
    388.           if req[0] == 0
    389.             if $data_shopsales.item_sales[req[1]] < req[2]
    390.               include = false
    391.             end
    392.           elsif req[0] == 1
    393.             if $data_shopsales.weapon_sales[req[1]] < req[2]
    394.               include = false
    395.             end
    396.           elsif req[0] == 2
    397.             if $data_shopsales.armor_sales[req[1]] < req[2]
    398.               include = false
    399.             end
    400.           end
    401.         end
    402.         @goods.push([0, i, 0, 0, false]) if include == true && !@goods.include?([0, i, 0, 0, false])
    403.       end
    404.     end
    405.     for i in 1...$data_weapons.size
    406.       if !$data_weapons[i].sell_req.empty?
    407.         include = true
    408.         for req in $data_weapons[i].sell_req
    409.           if req[0] == 0
    410.             if $data_shopsales.item_sales[req[1]] < req[2]
    411.               include = false
    412.             end
    413.           elsif req[0] == 1
    414.             if $data_shopsales.weapon_sales[req[1]] < req[2]
    415.               include = false
    416.             end
    417.           elsif req[0] == 2
    418.             if $data_shopsales.armor_sales[req[1]] < req[2]
    419.               include = false
    420.             end
    421.           end
    422.         end
    423.         @goods.push([1, i, 0, 0, false]) if include == true && !@goods.include?([1, i, 0, 0, false])
    424.       end
    425.     end
    426.     for i in 1...$data_armors.size
    427.       if !$data_armors[i].sell_req.empty?
    428.         include = true
    429.         for req in $data_armors[i].sell_req
    430.           if req[0] == 0
    431.             if $data_shopsales.item_sales[req[1]] < req[2]
    432.               include = false
    433.             end
    434.           elsif req[0] == 1
    435.             if $data_shopsales.weapon_sales[req[1]] < req[2]
    436.               include = false
    437.             end
    438.           elsif req[0] == 2
    439.             if $data_shopsales.armor_sales[req[1]] < req[2]
    440.               include = false
    441.             end
    442.           end
    443.         end
    444.         @goods.push([2, i, 0, 0, false]) if include == true && !@goods.include?([2, i, 0, 0, false])
    445.       end
    446.     end
    447.   end
    448.    
    449.   alias :shopsales_do_sell :do_sell
    450.   #--------------------------------------------------------------------------
    451.     # ● Alias to track sold items and immediately unlock items for which the
    452.   # criteria has been met
    453.     #--------------------------------------------------------------------------
    454.   def do_sell(number)
    455.     shopsales_do_sell(number)
    456.     @added_items = []
    457.     case item_type
    458.     when 0
    459.       $data_shops[@current_id].sales.item_sales[@item.id] += number
    460.       $data_shopsales.item_sales[@item.id] += number
    461.       p $data_shops[@current_id].sales.item_sales[@item.id]
    462.     when 1
    463.       $data_shopsales.weapon_sales[@item.id] += number
    464.     when 2
    465.       $data_shopsales.armor_sales[@item.id] += number
    466.     end
    467.     for i in 1...$data_items.size
    468.       if !$data_items[i].sell_req.empty?
    469.         include = true
    470.         for req in $data_items[i].sell_req
    471.           if req[0] == 0
    472.             if $data_shopsales.item_sales[req[1]] < req[2]
    473.               include = false
    474.             end
    475.           elsif req[0] == 1
    476.             if $data_shopsales.weapon_sales[req[1]] < req[2]
    477.               include = false
    478.             end
    479.           elsif req[0] == 2
    480.             if $data_shopsales.armor_sales[req[1]] < req[2]
    481.               include = false
    482.             end
    483.           end
    484.         end
    485.         if include == true && !@goods.include?([0, i, 0, 0, false])
    486.           #@goods.push([0, i, 0, 0, false])
    487.           @added_items.push($data_items[i])
    488.           $data_shops[@current_id].unlocked_goods.push($data_items[i])
    489.           #$data_items[i].unlocked = true
    490.         end
    491.       end
    492.     end
    493.     for i in 1...$data_weapons.size
    494.       if !$data_weapons[i].sell_req.empty?
    495.         include = true
    496.         for req in $data_weapons[i].sell_req
    497.           if req[0] == 0
    498.             if $data_shopsales.item_sales[req[1]] < req[2]
    499.               include = false
    500.             end
    501.           elsif req[0] == 1
    502.             if $data_shopsales.weapon_sales[req[1]] < req[2]
    503.               include = false
    504.             end
    505.           elsif req[0] == 2
    506.             if $data_shopsales.armor_sales[req[1]] < req[2]
    507.               include = false
    508.             end
    509.           end
    510.         end
    511.         if include == true && !@goods.include?([1, i, 0, 0, false])
    512.           #@goods.push([1, i, 0, 0, false])
    513.           @added_items.push($data_weapons[i])
    514.           #$data_weapons[i].unlocked = true
    515.         end
    516.       end
    517.     end
    518.     for i in 1...$data_armors.size
    519.       if !$data_armors[i].sell_req.empty?
    520.         include = true
    521.         for req in $data_armors[i].sell_req
    522.           if req[0] == 0
    523.             if $data_shopsales.item_sales[req[1]] < req[2]
    524.               include = false
    525.             end
    526.           elsif req[0] == 1
    527.             if $data_shopsales.weapon_sales[req[1]] < req[2]
    528.               include = false
    529.             end
    530.           elsif req[0] == 2
    531.             if $data_shopsales.armor_sales[req[1]] < req[2]
    532.               include = false
    533.             end
    534.           end
    535.         end
    536.         if include == true && !@goods.include?([2, i, 0, 0, false])
    537.           #@goods.push([2, i, 0, 0, false])
    538.           @added_items.push($data_armors[i])
    539.           #$data_armors[i].unlocked = true
    540.         end
    541.       end
    542.     end
    543.     if !@added_items.empty?
    544.       activate_unlocks_window
    545.     end
    546.   end
    547.   #--------------------------------------------------------------------------
    548.     # ● Overload to add categories to the buy command
    549.     #--------------------------------------------------------------------------
    550.   def command_buy
    551.     @dummy_window.hide
    552.     @buy_window.unselect
    553.     @buy_window.refresh
    554.     @category_window.item_window = @buy_window
    555.     if $imported['YEA-ShopOptions']
    556.       @category_window.activate
    557.       @category_window.x = 0
    558.       @command_window.x = Graphics.width
    559.       @buy_window.x = 0
    560.       @sell_window.x = Graphics.width
    561.       @data_window.item_window = @buy_window
    562.     else
    563.       @category_window.show.activate
    564.       @buy_window.show
    565.       @status_window.show
    566.       @status_window.y = @dummy_window.y + 48
    567.       @status_window.height = Graphics.height - @dummy_window.y - 48
    568.     end
    569.   end
    570.   alias :shopsales_command_sell :command_sell
    571.   #--------------------------------------------------------------------------
    572.     # ● Alias to reposition windows when sell command is selected
    573.     #--------------------------------------------------------------------------
    574.   def command_sell
    575.     @category_window.item_window = @sell_window
    576.     if $imported['YEA-ShopOptions']
    577.       shopsales_command_sell
    578.     else
    579.       @dummy_window.hide
    580.       @sell_window.unselect
    581.       @sell_window.refresh
    582.       @category_window.show.activate
    583.       @sell_window.show
    584.       @status_window.y = @dummy_window.y
    585.       @status_window.height = Graphics.height - @dummy_window.y
    586.     end
    587.   end
    588.   #--------------------------------------------------------------------------
    589.     # ● Overload to smoothly transition buy cancellation back to category list
    590.     #--------------------------------------------------------------------------
    591.   def on_buy_cancel
    592.     @buy_window.unselect
    593.     @category_window.activate
    594.     @status_window.item = nil
    595.     @help_window.clear
    596.   end
    597.   #--------------------------------------------------------------------------
    598.     # ● Overload to transition smoothly to buy/sell after category confirm
    599.     #--------------------------------------------------------------------------
    600.   def on_category_ok
    601.     if @command_window.index == 0
    602.       activate_buy_window
    603.       @buy_window.select(0)
    604.     elsif @command_window.index == 1
    605.       activate_sell_window
    606.       unless $imported['YEA-ShopOptions']
    607.         @status_window.y = @dummy_window.y
    608.         @status_window.height = Graphics.height - @dummy_window.y
    609.       end
    610.       @sell_window.select(0)
    611.     end
    612.   end
    613.   alias :shopsales_on_category_cancel :on_category_cancel
    614.   #--------------------------------------------------------------------------
    615.     # ● Alias to transition smoothly to commands after category cancel
    616.     #--------------------------------------------------------------------------
    617.   def on_category_cancel
    618.     if $imported['YEA-ShopOptions']
    619.       shopsales_on_category_cancel
    620.     else
    621.       @command_window.activate
    622.       @dummy_window.show
    623.       if @command_window.index == 0
    624.         @buy_window.hide
    625.         @status_window.hide
    626.       elsif @command_window.index == 1
    627.         @sell_window.hide
    628.       end
    629.       @category_window.hide
    630.     end
    631.   end
    632.   #--------------------------------------------------------------------------
    633.     # ● Returns the number of items that have been unlocked
    634.     #--------------------------------------------------------------------------
    635.   def added_items
    636.     @added_items.size
    637.   end
    638.   #--------------------------------------------------------------------------
    639.     # ● Activates the unlock window
    640.     #--------------------------------------------------------------------------
    641.   def activate_unlocks_window
    642.     @unlock_window.display_items(@added_items)
    643.     @unlock_window.show.activate
    644.     @category_window.show
    645.     @sell_window.show
    646.     @status_window.hide unless $imported["YEA-ShopOptions"]
    647.   end
    648.   #--------------------------------------------------------------------------
    649.     # ● Handler method for pressing the "ok" key when unlock window is active
    650.     #--------------------------------------------------------------------------
    651.   def on_unlock_continue
    652.     if added_items > 10
    653.       for i in 0..9
    654.         @added_items.shift
    655.       end
    656.       activate_unlocks_window
    657.     else
    658.       @unlock_window.hide
    659.       activate_sell_window
    660.     end
    661.   end
    662.   #--------------------------------------------------------------------------
    663.     # ● Handler method for pressing the "cancel" key when unlock window is active
    664.     #--------------------------------------------------------------------------
    665.   def on_unlock_cancel
    666.     @unlock_window.hide
    667.     activate_sell_window
    668.   end
    669.   #--------------------------------------------------------------------------
    670.     # ● Checks item type of @item
    671.     #--------------------------------------------------------------------------
    672.   def item_type
    673.     if @item.is_a?(RPG::Item)
    674.       return 0
    675.     elsif @item.is_a?(RPG::Weapon)
    676.       return 1
    677.     elsif @item.is_a?(RPG::Armor)
    678.       return 2
    679.     end
    680.   end
    681.   #--------------------------------------------------------------------------
    682.     # ● Overload to return to the correct command window after number input ends
    683.     #--------------------------------------------------------------------------
    684.   def end_number_input
    685.     @number_window.hide
    686.     case @command_window.current_symbol
    687.     when :buy
    688.       activate_buy_window
    689.     when :sell
    690.       activate_sell_window unless @unlock_window.active
    691.     end
    692.   end
    693. end
    694. module CSHOP
    695.   module REGEXP
    696.     ITEM_REQ = /<require ([IWA])(\d+), (\d+)>/i
    697.     SALE_QUANTITY = /<quantity: (\d+)/i
    698.   end
    699. end
    700. #--------------------------------------------------------------------------
    701. # ● New class that tracks how many of each item has been sold in a shop
    702. #--------------------------------------------------------------------------
    703. class RPG::ShopSales
    704.   #------------------------
    705.   attr_accessor :item_sales
    706.   attr_accessor :weapon_sales
    707.   attr_accessor :armor_sales
    708.   #------------------------
    709.   def initialize
    710.     @item_sales   = []
    711.     @weapon_sales = []
    712.     @armor_sales  = []
    713.     for index in 0..$data_items.size
    714.       item_sales[index] = 0
    715.     end
    716.     for index in 0..$data_weapons.size
    717.       weapon_sales[index] = 0
    718.     end
    719.     for index in 0..$data_armors.size
    720.       armor_sales[index] = 0
    721.     end
    722.   end
    723. end
    724. #--------------------------------------------------------------------------
    725. # ● New class that creates a window showing unlocked items
    726. #--------------------------------------------------------------------------
    727. class Window_Unlocks < Window_Selectable
    728.   def initialize
    729.     super(0, 0, 240, fitting_height(11))
    730.     self.back_opacity = 255
    731.     @show_count = 0
    732.   end
    733.   def display_items(items)
    734.     contents.clear
    735.     draw_text(0, 0, contents_width, line_height, "ITEMS UNLOCKED", 1)
    736.     items.each_with_index do |item, i|
    737.       draw_icon(item.icon_index, 0, line_height * (i + 1), true)
    738.       draw_text(0, line_height * (i + 1), contents_width, line_height, item.name, 1)
    739.     end
    740.   end
    741. end
    复制代码


    FAQ
    No questions at present.

    Credit and Thanks
    - Trihan
    - Thanks to Prexus for helping with the shop data structure.
    - Thanks to Clyve for making the original commission request.


    本贴来自国际rpgmaker官方论坛作者:Trihan处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/trilobytes-vx-ace-1-shop-unlocks.77017/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-17 09:25 , Processed in 0.102692 second(s), 56 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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