jbrocky

Untitled

Dec 4th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.93 KB | None | 0 0
  1. =begin
  2. Documentation: https://elanthipedia.play.net/Lich_script_repository#pick
  3. =end
  4.  
  5. custom_require.call(%w(common common-arcana common-items common-money common-travel drinfomon equipmanager events spellmonitor))
  6.  
  7. class LockPicker
  8. include DRC
  9. include DRCA
  10. include DRCI
  11. include DRCM
  12. include DRCT
  13.  
  14. def initialize
  15. setup
  16.  
  17. boxes = get_boxes(@settings.picking_box_source) if @settings.picking_box_source
  18. if boxes.nil? || boxes.empty?
  19. check_pet_boxes(@settings.picking_pet_box_source)
  20. return
  21. end
  22.  
  23. @equipment_manager = EquipmentManager.new
  24.  
  25. @equipment_manager.empty_hands
  26.  
  27. removed_items = @equipment_manager.remove_gear_by(&:hinders_lockpicking)
  28.  
  29. if left_hand || right_hand
  30. echo '***ITEMS ARE STILL IN HANDS, EXITING***'
  31. @equipment_manager.wear_items(removed_items)
  32. return
  33. end
  34.  
  35. lockpick_buffs = @settings.lockpick_buffs
  36.  
  37. do_buffs(lockpick_buffs)
  38.  
  39. fput 'sit'
  40.  
  41. boxes.each do |box|
  42. if !attempt_open(box)
  43. break
  44. end
  45. end
  46.  
  47. fix_standing
  48. @equipment_manager.wear_items(removed_items)
  49. end
  50.  
  51. def setup
  52. arg_definitions = [[]]
  53.  
  54. args = parse_args(arg_definitions, true)
  55.  
  56. @settings = get_settings(args.flex)
  57.  
  58. @lockpick_costs = {
  59. 'ordinary' => 125,
  60. 'stout' => 250,
  61. 'slim' => 500
  62. }
  63. @loot_nouns = @settings.lootables
  64. echo "Loot nouns: #{@loot_nouns}" if UserVars.lockpick_debug
  65.  
  66. @trash_nouns = get_data('items').trash_nouns
  67. echo "Trash nouns: #{@trash_nouns}" if UserVars.lockpick_debug
  68.  
  69. messages = get_data('picking').picking
  70. @pick_careful = messages['pick_careful']
  71. @pick_quick = messages['pick_quick']
  72. @pick_blind = messages['pick_blind']
  73. @pick_retry = messages['pick_retry']
  74. @disarm_failed = messages['disarm_failed']
  75. @disarm_retry = messages['disarm_retry']
  76. @disarm_identify_failed = messages['disarm_identify_failed']
  77. @disarm_too_hard = messages['disarm_too_hard']
  78. @disarm_careful = messages['disarm_careful']
  79. @disarm_quick = messages['disarm_quick']
  80. @disarm_normal = messages['disarm_normal']
  81.  
  82. Flags.add('disarm-more', 'not fully disarmed', 'not yet fully disarmed', 'still has more to torment you with')
  83. open_container(@settings.picking_box_source)
  84. open_container(@settings.picking_box_storage)
  85. open_container(@settings.picking_pet_box_source)
  86. end
  87.  
  88. def open_container(name)
  89. return unless name
  90.  
  91. fput("open my #{name}")
  92. end
  93.  
  94. def do_buffs(buffs)
  95. if DRRoom.pcs.include?(@settings.lockpick_buff_bot)
  96. fput("whisper #{@settings.lockpick_buff_bot} buff hol")
  97. end
  98.  
  99. buffs['spells'].each do |spell|
  100. echo "Buffing: #{spell}" if UserVars.lockpick_debug
  101. buff(spell, @settings)
  102. end
  103.  
  104. buffs['khri']
  105. .map { |name| "Khri #{name}" }
  106. .each { |name| activate_khri?(@settings.kneel_khri, name) }
  107. end
  108.  
  109. def attempt_open(box)
  110. waitrt?
  111. echo "attempt_open(#{box})" if UserVars.lockpick_debug
  112. bput("get my #{box} from my #{@settings.picking_box_source}", 'You get a .* from inside your ')
  113.  
  114. unless disarm?(box)
  115. bput("put my #{box} in my #{@settings.picking_box_storage}", 'You put your .* in your ') if right_hand
  116. return
  117. end
  118.  
  119. case bput("put my #{box} in my #{@settings.picking_pet_box_source}", /You put/, /room/)
  120. when /You put/
  121. return true
  122. when /room/
  123. bput("stow #{box}", /You put/)
  124. return false
  125. end
  126. end
  127.  
  128. def disarm?(box)
  129. waitrt?
  130. check_danger
  131. echo "disarm?(#{box})" if UserVars.lockpick_debug
  132. case bput("disarm my #{box} identify", @disarm_identify_failed, @disarm_too_hard, @disarm_careful, @disarm_quick, @disarm_normal, 'Roundtime')
  133. when 'Roundtime', *@disarm_careful
  134. disarm_speed?(box, 'careful')
  135. when *@disarm_quick
  136. disarm_speed?(box, 'quick')
  137. when *@disarm_normal
  138. disarm_speed?(box, 'normal')
  139. when *@disarm_identify_failed
  140. disarm?(box)
  141. when *@disarm_too_hard
  142. if @settings.lockpick_ignore_difficulty
  143. disarm_speed?(box, 'careful')
  144. else
  145. false
  146. end
  147. end
  148. end
  149.  
  150. def check_danger
  151. pause 0.5 while stunned?
  152. return unless bleeding? || checkpoison
  153.  
  154. snapshot = Room.current.id
  155. wait_for_script_to_complete('safe-room')
  156. walk_to(snapshot)
  157. end
  158.  
  159. def disarm_speed?(box, speed)
  160. waitrt?
  161. echo "disarm_speed?(#{box}, #{speed})" if UserVars.lockpick_debug
  162. Flags.reset('disarm-more')
  163.  
  164. case bput("disarm my #{box} #{speed}", @disarm_failed, @disarm_retry, 'Roundtime')
  165. when *@disarm_failed
  166. beep
  167. beep
  168. echo('**SPRUNG TRAP**')
  169.  
  170. check_danger
  171.  
  172. return false
  173. when *@disarm_retry
  174. new_speed = reget(10, 'something to shift') ? 'careful' : speed
  175. return disarm_speed?(box, new_speed)
  176. end
  177. pause 1
  178. waitrt?
  179.  
  180. result = true
  181.  
  182. analyze(box) if @settings.harvest_traps
  183.  
  184. result = disarm?(box) if Flags['disarm-more']
  185.  
  186. result
  187. end
  188.  
  189. def analyze(box)
  190. waitrt?
  191. case bput("disarm my #{box} analyze", /You've already analyzed/, /You are unable to determine a proper method/, 'Roundtime')
  192. when /You are unable to determine a proper method/
  193. return analyze(box)
  194. end
  195. harvest(box)
  196. end
  197.  
  198. def harvest(box)
  199. waitrt?
  200. case bput("disarm my #{box} harvest",
  201. /You fumble around with the trap apparatus/,
  202. /much for it to be successfully harvested/,
  203. /completely unsuitable for harvesting/,
  204. /previous trap have already been completely harvested/,
  205. 'Roundtime')
  206. when /You fumble around with the trap apparatus/
  207. harvest(box)
  208. when 'Roundtime'
  209. waitrt?
  210. dispose_trash(left_hand) # only dispose https://elanthipedia.play.net/Locksmithing_skill#Box_Traps items.
  211. while left_hand
  212. end
  213. end
  214. end
  215. end
  216.  
  217. LockPicker.new
Advertisement
Add Comment
Please, Sign In to add comment