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

[转载发布] PickPocket script

[复制链接]
累计送礼:
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-7-31 19:55:39 | 显示全部楼层 |阅读模式
    Hi everyone, I thought about a mechanics I added some time ago to my game, a pickpocketing system, it was really ugly, lots of lines of setup for each event, so I decided to turn it into a script,


            I changed this







            into this:







            I am pretty satisfied with the result, so I thought I'd share this   



            Description:


            You simply have to put one line of script call in an event box (e.g Eaty_Steal(['g',0],32,100,@event_id,10,"How dare you!") ), and when the player will interact with that npc while pressing a default key
    SHIFT), he'll try to steal what you set within the script call, if the player gets caught you can decide what the consequences will be.


            The chances of success are determined by this formula (rand(attention_level) - $game_party.leader.agi ), which you can freely change (in that case also adjust the conditions check accordingly (value<0, value<a/2, value>=a/2)).


            Here's the script:

    Spoiler                Code:       
    1. #=============================================================================#
    2. #
    3. #  EatYourBeetS stealing script
    4. #
    5. # In any event put this in the first line:
    6. # Eaty_Steal(['g',0],32,100,@event_id,10,"How dare you!")
    7. #
    8. # ['g', = item type: 'g'=gold, 'i'=item, 'a'=armor, 'w'=weapon
    9. #   0], = item ID, not checked when you choose 'g'
    10. #  32 , = quantity of item or gold that will be stolen
    11. #  100, = attention level, used to determine the chances of stealing or
    12. #         getting caught, check the formula in Dinamic setup
    13. #  @event_id, used for the self switch, just pass it as @event_id
    14. #  10 , = ID of the switch to activate when caught, 0 if you don't need it
    15. #         (I use one switch per city)
    16. #  "How dare you!" = optional, determines what will the npc say if you
    17. #  )                 get caught, you can change the default below
    18. #
    19. #
    20. #  *Free to use anywhere
    21. #  *Credits: EatYourBeetS
    22. #  *If you find bugs or have an idea about how to improve this,
    23. #  please let me know!
    24. #
    25. #=============================================================================#  
    26. class Game_Interpreter
    27. #--------------------------------------------------------------------------
    28. # * Steal from NPCs                                        [NEW METHOD]
    29. #--------------------------------------------------------------------------
    30. def Eaty_Steal(i=['g',0],q=1,a=50,event_id,switch,line)
    31. #=============================================================================
    32. #      Custom conditions
    33. #
    34. #  Add other conditions here if you want, e.g, if you want to steal only when
    35. #  an item is equipped add:
    36. #  return unless $game_party.members_equip_include?($data_armors[ID])
    37. return unless Input.press?(:SHIFT) #Steal Button(to press with Z/space/enter)
    38. return if $game_switches[switch]==true && switch!=0
    39. #=============================================================================                                 
    40. if $game_self_switches[[$game_map.map_id,event_id,'D']]==false #SW check
    41.                            #Dinamic setup                          
    42. line.is_a?(String) ? line : (line=nil; line="Thief!") #-> default line
    43. data_id = i[1] #Don't change
    44. #-----
    45. a       = rand(a) + a/5                      #Stealing Formula
    46. value   = a - $game_party.leader.agi         #Stealing Formula
    47. #-----
    48. #============================================================================
    49. #       Stealing successful
    50. #=========================================================================     
    51. if value < 0
    52.         $game_message.background = 1
    53.         $game_message.add("\nYou stole something!")
    54.         $game_self_switches[[map_id,event_id,'D']] = true  #SW ON
    55.        #$game_variables[16] -= 3 #this is my 'karma' variable,
    56.        #     if you have something similar just change the id      
    57.         q_s=q.to_s+" " if q!=1
    58.         q_s=""         if q==1
    59.         RPG::SE.new("Chime2", 100, 120).play  #Success Sound
    60. #----------------------------------------------------------------------         
    61. if i[0] != 'g'         
    62.   if    i[0] == 'w'
    63.       icon = $data_weapons[data_id].icon_index
    64.       name = $data_weapons[data_id].name
    65.       $game_party.gain_item($data_weapons[data_id], q)
    66.   elsif i[0] == 'a'
    67.       icon = $data_armors[data_id].icon_index
    68.       name = $data_armors[data_id].name  
    69.       $game_party.gain_item($data_armors[data_id], q)
    70.   elsif i[0] == 'i'
    71.       icon = $data_items[data_id].icon_index
    72.       name = $data_items[data_id].name
    73.       $game_party.gain_item($data_items[data_id], q)
    74.   end
    75. $game_message.background = 1
    76. $game_message.add("#{q_s}#{name} \\i[#{icon}] Obtained!")         
    77. else
    78. #----------------------------------------------------------------------   
    79. $game_party.gain_gold(q)
    80. $game_message.background = 1
    81. $game_message.add("#{q}\\i[361] Obtained!")  #361 is my gold icon index      
    82. end      
    83. #==========================================================================
    84. #       Stealing failed
    85. #========================================================================      
    86. elsif  value >= 0 && value < (a/2)
    87.         $game_message.background = 1
    88.         $game_message.add("\nStealing failed!")
    89. elsif  value >= a/2
    90.         $game_message.add("#{line}")
    91.         RPG::SE.new("Reflection", 100, 120).play #Failure Sound
    92.         $game_switches[switch]=true if switch != 0
    93. end
    94. #----------------------------------------------------------------------
    95. else #If Self Switch is on
    96. $game_message.background = 1
    97. $game_message.add("\nYou already stole something")
    98. end     # Self switch check end
    99. #----------------------------------------------------------------------
    100. command_115 #Exit event processing
    101. end     # Method end
    102. #==============================================================================
    103. end     # Game_Interpreter class end
    104. #==============================================================================
    复制代码






                            This is my first script, please let me know about any improvement I can make, or any bugs or mistakes.






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

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-8-17 20:15 , Processed in 0.138271 second(s), 53 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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