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

[转载发布] Shop Steal (UPDATED)

[复制链接]
累计送礼:
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 09:13:58 | 显示全部楼层 |阅读模式
    Finally finished it!
    No more known bugs!
    IT'S FUNCTIONALLY PERFECT!
    NOW UPDATED TO BE MORE USER-FRIENDLY

    This allows the player to steal items from any shop in your game. The player has a 47% success chance, but the other 53% is up to you to decide!

    How stealing works: You select the new steal tab in the shop, select the item you want, then hope to god that you got that item.

    How to make the consequence: If the player fails the dice roll, then switch 21 is set to true. I will let you figure out what to do with that switch in the events; I usually make Parallel Processes that swap 21 with the other switch.

    How to change the switch/success chance: Change the values under preferences.

    Contact me about any problems


    Warning: May not work with other shop scripts




    Terms
    Please give credit to me if you're using this, even if you modify this or merged it with another shop script, give credit to all those who were involved.
    If you got questions or small modification request regarding this, let me know. Also let me know if you want to use this in your own shop script.



    Place under materials, but above main

                    Code:       
    1. #========================PREFERENCES=============================
    2. $dice = 47 #THE PERCENTAGE CHANCE OF SUCCESS
    3. $activation_switch = 21 #THE SWITCH THAT'S SET TO TRUE ON FAIL
    4. #================================================================
    5. #============================CREDIT==============================
    6. #GIVE CREDIT TO TRIACULAR, REGARDLESS OF CIRCUMSTANCES
    7. #================================================================
    8. module Vocab
    9.     ShopSteal       = "Steal"
    10. end
    11. class Scene_Shop < Scene_MenuBase
    12.   #--------------------------------------------------------------------------
    13.   # * Prepare
    14.   #--------------------------------------------------------------------------
    15.   def prepare(goods, purchase_only)
    16.     @goods = goods
    17.     @purchase_only = purchase_only
    18.   end
    19.   #--------------------------------------------------------------------------
    20.   # * Start Processing
    21.   #--------------------------------------------------------------------------
    22.   def start
    23.     super
    24.     create_help_window
    25.     create_gold_window
    26.     create_command_window
    27.     create_dummy_window
    28.     create_number_window
    29.     create_status_window
    30.     create_buy_window
    31.     create_category_window
    32.     create_sell_window
    33.     create_steal_window
    34.   end
    35.   #--------------------------------------------------------------------------
    36.   # * Create Gold Window
    37.   #--------------------------------------------------------------------------
    38.   def create_gold_window
    39.     @gold_window = Window_Gold.new
    40.     @gold_window.viewport = @viewport
    41.     @gold_window.x = Graphics.width - @gold_window.width
    42.     @gold_window.y = @help_window.height
    43.   end
    44.   #--------------------------------------------------------------------------
    45.   # * Create Command Window
    46.   #--------------------------------------------------------------------------
    47.   def create_command_window
    48.     @command_window = Window_ShopCommand.new(@gold_window.x, @purchase_only)
    49.     @command_window.viewport = @viewport
    50.     @command_window.y = @help_window.height
    51.     @command_window.set_handler(:buy,    method(:command_buy))
    52.     @command_window.set_handler(:sell,   method(:command_sell))
    53.     @command_window.set_handler(:steal,  method(:command_steal))
    54.     @command_window.set_handler(:cancel, method(:return_scene))
    55.   end
    56.   #--------------------------------------------------------------------------
    57.   # * Create Dummy Window
    58.   #--------------------------------------------------------------------------
    59.   def create_dummy_window
    60.     wy = @command_window.y + @command_window.height
    61.     wh = Graphics.height - wy
    62.     @dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
    63.     @dummy_window.viewport = @viewport
    64.   end
    65.   #--------------------------------------------------------------------------
    66.   # * Create Quantity Input Window
    67.   #--------------------------------------------------------------------------
    68.   def create_number_window
    69.     wy = @dummy_window.y
    70.     wh = @dummy_window.height
    71.     @number_window = Window_ShopNumber.new(0, wy, wh)
    72.     @number_window.viewport = @viewport
    73.     @number_window.hide
    74.     @number_window.set_handler(:ok,     method(:on_number_ok))
    75.     @number_window.set_handler(:cancel, method(:on_number_cancel))
    76.   end
    77.   #--------------------------------------------------------------------------
    78.   # * Create Status Window
    79.   #--------------------------------------------------------------------------
    80.   def create_status_window
    81.     wx = @number_window.width
    82.     wy = @dummy_window.y
    83.     ww = Graphics.width - wx
    84.     wh = @dummy_window.height
    85.     @status_window = Window_ShopStatus.new(wx, wy, ww, wh)
    86.     @status_window.viewport = @viewport
    87.     @status_window.hide
    88.   end
    89.   #--------------------------------------------------------------------------
    90.   # * Create Purchase Window
    91.   #--------------------------------------------------------------------------
    92.   def create_buy_window
    93.     wy = @dummy_window.y
    94.     wh = @dummy_window.height
    95.     @buy_window = Window_ShopBuy.new(0, wy, wh, @goods)
    96.     @buy_window.viewport = @viewport
    97.     @buy_window.help_window = @help_window
    98.     @buy_window.status_window = @status_window
    99.     @buy_window.hide
    100.     @buy_window.set_handler(:ok,     method(:on_buy_ok))
    101.     @buy_window.set_handler(:cancel, method(:on_buy_cancel))
    102.   end
    103.   #--------------------------------------------------------------------------
    104.   # * Create Category Window
    105.   #--------------------------------------------------------------------------
    106.   def create_category_window
    107.     @category_window = Window_ItemCategory.new
    108.     @category_window.viewport = @viewport
    109.     @category_window.help_window = @help_window
    110.     @category_window.y = @dummy_window.y
    111.     @category_window.hide.deactivate
    112.     @category_window.set_handler(:ok,     method(:on_category_ok))
    113.     @category_window.set_handler(:cancel, method(:on_category_cancel))
    114.   end
    115.   #--------------------------------------------------------------------------
    116.   # * Create Sell Window
    117.   #--------------------------------------------------------------------------
    118.   def create_sell_window
    119.     wy = @category_window.y + @category_window.height
    120.     wh = Graphics.height - wy
    121.     @sell_window = Window_ShopSell.new(0, wy, Graphics.width, wh)
    122.     @sell_window.viewport = @viewport
    123.     @sell_window.help_window = @help_window
    124.     @sell_window.hide
    125.     @sell_window.set_handler(:ok,     method(:on_sell_ok))
    126.     @sell_window.set_handler(:cancel, method(:on_sell_cancel))
    127.     @category_window.item_window = @sell_window
    128.   end
    129.   #--------------------------------------------------------------------------
    130.   # * Activate Purchase Window
    131.   #--------------------------------------------------------------------------
    132.   def activate_buy_window
    133.     @buy_window.money = money
    134.     @buy_window.show.activate
    135.     @status_window.show
    136.   end
    137.   #--------------------------------------------------------------------------
    138.   # * Activate Sell Window
    139.   #--------------------------------------------------------------------------
    140.   def activate_sell_window
    141.     @category_window.show
    142.     @sell_window.refresh
    143.     @sell_window.show.activate
    144.     @status_window.hide
    145.   end
    146.   #--------------------------------------------------------------------------
    147.   # * [Buy] Command
    148.   #--------------------------------------------------------------------------
    149.   def command_buy
    150.     @dummy_window.hide
    151.     activate_buy_window
    152.   end
    153.   def command_steal
    154.     @dummy_window.hide
    155.     activate_steal_window
    156.   end
    157.   def on_steal_cancel
    158.     @command_window.activate
    159.     @dummy_window.show
    160.     @steal_window.hide
    161.     @status_window.hide
    162.     @status_window.item = nil
    163.     @help_window.clear
    164.   end
    165.   def on_steal_ok
    166.     @item = @steal_window.item
    167.     @steal_window.hide
    168.     @number_window.set(@item, max_buy, buying_price, currency_unit)
    169.     @number_window.show.activate
    170.   end
    171.   def create_steal_window
    172.     wy = @dummy_window.y
    173.     wh = @dummy_window.height
    174.     @steal_window = Window_ShopSteal.new(0, wy, wh, @goods)
    175.     @steal_window.viewport = @viewport
    176.     @steal_window.help_window = @help_window
    177.     @steal_window.status_window = @status_window
    178.     @steal_window.hide
    179.     @steal_window.set_handler(:ok,     method(:on_steal_ok))
    180.     @steal_window.set_handler(:cancel, method(:on_steal_cancel))
    181.   end
    182.   def activate_steal_window
    183.     @steal_window.show.activate
    184.     @status_window.show
    185.   end
    186.   def do_steal(number)
    187.     life_or_death = rand(100)
    188.     if life_or_death <= $dice
    189.       $game_party.gain_item(@item, 1)
    190.     else
    191.       $game_switches[$activation_switch] = true
    192.       SceneManager.goto(Scene_Map)
    193.     end
    194.   end
    195.   #--------------------------------------------------------------------------
    196.   # * [Sell] Command
    197.   #--------------------------------------------------------------------------
    198.   def command_sell
    199.     @dummy_window.hide
    200.     @category_window.show.activate
    201.     @sell_window.show
    202.     @sell_window.unselect
    203.     @sell_window.refresh
    204.   end
    205.   #--------------------------------------------------------------------------
    206.   # * Buy [OK]
    207.   #--------------------------------------------------------------------------
    208.   def on_buy_ok
    209.     money
    210.     @item = @buy_window.item
    211.     @buy_window.hide
    212.     @number_window.set(@item, max_buy, buying_price, currency_unit)
    213.     @number_window.show.activate
    214.   end
    215.   #--------------------------------------------------------------------------
    216.   # * Buy [Cancel]
    217.   #--------------------------------------------------------------------------
    218.   def on_buy_cancel
    219.     @command_window.activate
    220.     @dummy_window.show
    221.     @buy_window.hide
    222.     @status_window.hide
    223.     @status_window.item = nil
    224.     @help_window.clear
    225.   end
    226.   #--------------------------------------------------------------------------
    227.   # * Category [OK]
    228.   #--------------------------------------------------------------------------
    229.   def on_category_ok
    230.     activate_sell_window
    231.     @sell_window.select(0)
    232.   end
    233.   #--------------------------------------------------------------------------
    234.   # * Category [Cancel]
    235.   #--------------------------------------------------------------------------
    236.   def on_category_cancel
    237.     @command_window.activate
    238.     @dummy_window.show
    239.     @category_window.hide
    240.     @sell_window.hide
    241.   end
    242.   #--------------------------------------------------------------------------
    243.   # * Sell [OK]
    244.   #--------------------------------------------------------------------------
    245.   def on_sell_ok
    246.     @item = @sell_window.item
    247.     @status_window.item = @item
    248.     @category_window.hide
    249.     @sell_window.hide
    250.     @number_window.set(@item, max_sell, selling_price, currency_unit)
    251.     @number_window.show.activate
    252.     @status_window.show
    253.   end
    254.   #--------------------------------------------------------------------------
    255.   # * Sell [Cancel]
    256.   #--------------------------------------------------------------------------
    257.   def on_sell_cancel
    258.     @sell_window.unselect
    259.     @category_window.activate
    260.     @status_window.item = nil
    261.     @help_window.clear
    262.   end
    263.   #--------------------------------------------------------------------------
    264.   # * Quantity Input [OK]
    265.   #--------------------------------------------------------------------------
    266.   def on_number_ok
    267.     Sound.play_shop
    268.     case @command_window.current_symbol
    269.     when :buy
    270.       do_buy(@number_window.number)
    271.     when :sell
    272.       do_sell(@number_window.number)
    273.     when :steal
    274.       do_steal(@number_window.number)
    275.     end
    276.     end_number_input
    277.     @gold_window.refresh
    278.     @status_window.refresh
    279.   end
    280.   #--------------------------------------------------------------------------
    281.   # * Quantity Input [Cancel]
    282.   #--------------------------------------------------------------------------
    283.   def on_number_cancel
    284.     Sound.play_cancel
    285.     end_number_input
    286.   end
    287.   #--------------------------------------------------------------------------
    288.   # * Execute Purchase
    289.   #--------------------------------------------------------------------------
    290.   def do_buy(number)
    291.     $game_party.lose_gold(number * buying_price)
    292.     $game_party.gain_item(@item, number)
    293.   end
    294.   #--------------------------------------------------------------------------
    295.   # * Execute Sale
    296.   #--------------------------------------------------------------------------
    297.   def do_sell(number)
    298.     $game_party.gain_gold(number * selling_price)
    299.     $game_party.lose_item(@item, number)
    300.   end
    301.   #--------------------------------------------------------------------------
    302.   # * Made By Triacular
    303.   #--------------------------------------------------------------------------
    304.   def end_number_input
    305.     @number_window.hide
    306.     case @command_window.current_symbol
    307.     when :buy
    308.       activate_buy_window
    309.     when :sell
    310.       activate_sell_window
    311.     when :steal
    312.       activate_steal_window
    313.     end
    314.   end
    315.   #--------------------------------------------------------------------------
    316.   # * Get Maximum Quantity Buyable
    317.   #--------------------------------------------------------------------------
    318.   def max_buy
    319.     max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
    320.     buying_price == 0 ? max : [max, money / buying_price].min
    321.   end
    322.   #--------------------------------------------------------------------------
    323.   # * Get Maximum Quantity Sellable
    324.   #--------------------------------------------------------------------------
    325.   def max_sell
    326.     $game_party.item_number(@item)
    327.   end
    328.   #--------------------------------------------------------------------------
    329.   # * Get Party Gold
    330.   #--------------------------------------------------------------------------
    331.   def money
    332.     @gold_window.value
    333.   end
    334.   #--------------------------------------------------------------------------
    335.   # Get Currency Unit
    336.   #--------------------------------------------------------------------------
    337.   def currency_unit
    338.     @gold_window.currency_unit
    339.   end
    340.   #--------------------------------------------------------------------------
    341.   # * Get Purchase Price
    342.   #--------------------------------------------------------------------------
    343.   def buying_price
    344.     @buy_window.price(@item)
    345.   end
    346.   #--------------------------------------------------------------------------
    347.   # * Get Sale Price
    348.   #--------------------------------------------------------------------------
    349.   def selling_price
    350.     @item.price / 2
    351.   end
    352. end
    353. class Window_ShopCommand < Window_HorzCommand
    354.   #--------------------------------------------------------------------------
    355.   # * Object Initialization
    356.   #--------------------------------------------------------------------------
    357.   def initialize(window_width, purchase_only)
    358.     @window_width = window_width
    359.     @purchase_only = purchase_only
    360.     super(0, 0)
    361.   end
    362.   #--------------------------------------------------------------------------
    363.   # * Get Window Width
    364.   #--------------------------------------------------------------------------
    365.   def window_width
    366.     @window_width
    367.   end
    368.   #--------------------------------------------------------------------------
    369.   # * Get Digit Count
    370.   #--------------------------------------------------------------------------
    371.   def col_max
    372.     return 3
    373.   end
    374.   #--------------------------------------------------------------------------
    375.   # * Create Command List
    376.   #--------------------------------------------------------------------------
    377.   def make_command_list
    378.     add_command(Vocab::ShopBuy,    :buy)
    379.     add_command(Vocab::ShopSell,   :sell,   !@purchase_only)
    380.     add_command(Vocab::ShopSteal,  :steal)
    381.     add_command(Vocab::ShopCancel, :cancel)
    382.   end
    383. end
    384. class Window_ShopSteal < Window_Selectable
    385.   #--------------------------------------------------------------------------
    386.   # * Public Instance Variables
    387.   #--------------------------------------------------------------------------
    388.   attr_reader   :status_window            # Status window
    389.   #--------------------------------------------------------------------------
    390.   # * Object Initialization
    391.   #--------------------------------------------------------------------------
    392.   def initialize(x, y, height, shop_goods)
    393.     super(x, y, window_width, height)
    394.     @shop_goods = shop_goods
    395.     @money = 0
    396.     refresh
    397.     select(0)
    398.   end
    399.   #--------------------------------------------------------------------------
    400.   # * Get Window Width
    401.   #--------------------------------------------------------------------------
    402.   def window_width
    403.     return 304
    404.   end
    405.   #--------------------------------------------------------------------------
    406.   # * Get Number of Items
    407.   #--------------------------------------------------------------------------
    408.   def item_max
    409.     @data ? @data.size : 1
    410.   end
    411.   #--------------------------------------------------------------------------
    412.   # * Get Item
    413.   #--------------------------------------------------------------------------
    414.   def item
    415.     @data[index]
    416.   end
    417.   #--------------------------------------------------------------------------
    418.   # * Set Party Gold
    419.   #--------------------------------------------------------------------------
    420.   def money=(money)
    421.     @money = money
    422.     refresh
    423.   end
    424.   #--------------------------------------------------------------------------
    425.   # * Get Activation State of Selection Item
    426.   #--------------------------------------------------------------------------
    427.   #--------------------------------------------------------------------------
    428.   # * Get Price of Item
    429.   #--------------------------------------------------------------------------
    430.   def price(item)
    431.     @price[item]
    432.   end
    433.   #--------------------------------------------------------------------------
    434.   # * Display in Enabled State?
    435.   #--------------------------------------------------------------------------
    436.   #--------------------------------------------------------------------------
    437.   # * Refresh
    438.   #--------------------------------------------------------------------------
    439.   def refresh
    440.     make_item_list
    441.     create_contents
    442.     draw_all_items
    443.   end
    444.   #--------------------------------------------------------------------------
    445.   # * Create Item List
    446.   #--------------------------------------------------------------------------
    447.   def make_item_list
    448.     @data = []
    449.     @price = {}
    450.     @shop_goods.each do |goods|
    451.       case goods[0]
    452.       when 0;  item = $data_items[goods[1]]
    453.       when 1;  item = $data_weapons[goods[1]]
    454.       when 2;  item = $data_armors[goods[1]]
    455.       end
    456.       if item
    457.         @data.push(item)
    458.         @price[item] = goods[2] == 0 ? item.price : goods[3]
    459.       end
    460.     end
    461.   end
    462.   #--------------------------------------------------------------------------
    463.   # * Draw Item
    464.   #--------------------------------------------------------------------------
    465.   def draw_item(index)
    466.     item = @data[index]
    467.     rect = item_rect(index)
    468.     draw_item_name(item, rect.x, rect.y)
    469.     rect.width -= 4
    470.     draw_text(rect, price(item), 2)
    471.   end
    472.   #--------------------------------------------------------------------------
    473.   # * Set Status Window
    474.   #--------------------------------------------------------------------------
    475.   def status_window=(status_window)
    476.     @status_window = status_window
    477.     call_update_help
    478.   end
    479.   #--------------------------------------------------------------------------
    480.   # * Update Help Text
    481.   #--------------------------------------------------------------------------
    482.   def update_help
    483.     @help_window.set_item(item) if @help_window
    484.     @status_window.item = item if @status_window
    485.   end
    486. end
    复制代码




    本贴来自国际rpgmaker官方论坛作者:Triacular处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/shop-steal-updated.104942/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-8-17 12:38 , Processed in 0.107588 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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