Guest User

Untitled

a guest
Apr 11th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.83 KB | None | 0 0
  1. script = Script.self
  2. sword = nil
  3. sword_container = nil
  4. close_containers = []
  5. if UserVars.lootsack.nil? or UserVars.lootsack.empty?
  6. lootsack = GameObj.inv.find { |obj| obj.noun =~ /cloak|longcoat|backpack|pack/ }
  7. else
  8. lootsack = GameObj.inv.find { |obj| obj.name =~ /\#{Regexp.escape(UserVars.lootsack.strip)}/i } || GameObj.inv.find { |obj| obj.name =~ /\#{Regexp.escape(UserVars.lootsack).sub(' ', ' .*')}/i }
  9. end
  10. find_all_containers_var = nil
  11. find_all_containers = proc {
  12. if find_all_containers_var.nil?
  13. hp = proc { |ss| if ss =~ /^You are wearing/; DownstreamHook.remove('find_all_container_ids'); nil; else; ss; end }
  14. DownstreamHook.add('find_all_container_ids', hp)
  15. restore_silent = script.silent
  16. restore_want_downstream = script.want_downstream
  17. restore_want_downstream_xml = script.want_downstream_xml
  18. script.silent = true
  19. script.want_downstream = false
  20. script.want_downstream_xml = true
  21. clear
  22. put 'inventory containers'
  23. script.silent = restore_silent
  24. timeout = Time.now + 30
  25. container_ids = []
  26. while (Time.now < timeout) and (line = get)
  27. if line =~ /^You are wearing/
  28. container_ids = line.scan(/<a exist=\"([^\"]+)\"/).flatten
  29. break
  30. end
  31. end
  32. script.want_downstream = restore_want_downstream
  33. script.want_downstream_xml = restore_want_downstream_xml
  34. clear
  35. find_all_containers_var = container_ids.collect { |id| GameObj[id] }
  36. end
  37. find_all_containers_var
  38. }
  39. stow_sword = proc {
  40. if sword.nil?
  41. if GameObj.right_hand.noun == 'sword'
  42. sword = GameObj.right_hand
  43. elsif GameObj.left_hand.noun == 'sword'
  44. sword = GameObj.left_hand
  45. end
  46. end
  47. if sword
  48. if sword_container
  49. dothistimeout \"_drag #\#{sword.id} #\#{sword_container.id}\", 10, /^You put|^absent-mindedly drop|^You slip|^You tuck|^I could not find what you were referring to/
  50. else
  51. if lootsack
  52. dothistimeout \"_drag #\#{sword.id} #\#{lootsack.id}\", 10, /^You put|^absent-mindedly drop|^You slip|^You tuck|^You can't .+ It's closed!|^I could not find what you were referring to|^Your .*? won't fit in/
  53. end
  54. if (GameObj.right_hand.id == sword.id) or (GameObj.left_hand.id == sword.id)
  55. for container in find_all_containers.call
  56. next if container == lootsack
  57. dothistimeout \"_drag #\#{sword.id} #\#{container.id}\", 10, /^You put|^absent-mindedly drop|^You slip|^You tuck|^You can't .+ It's closed!|^I could not find what you were referring to|^Your .*? won't fit in/
  58. break unless (GameObj.right_hand.id == sword.id) or (GameObj.left_hand.id == sword.id)
  59. end
  60. end
  61. end
  62. end
  63. }
  64. empty_hands
  65. if lootsack
  66. if lootsack.contents.nil?
  67. result = dothistimeout \"open #\#{lootsack.id}\", 10, /^You open|^That is already open|^There doesn't seem to be any way to do that|^What were you referring to|^I could not find what you were referring to/
  68. if lootsack.contents.nil? and result =~ /^That is already open/
  69. dothistimeout \"look in #\#{lootsack.id}\", 10, /^In the|^There is nothing|^That is closed|^What were you referring to|^I could not find what you were referring to/
  70. elsif result =~ /^You open/
  71. close_containers.push(lootsack)
  72. end
  73. end
  74. if sword = lootsack.contents.find { |obj| obj.name == 'short sword' }
  75. sword_container = lootsack
  76. end
  77. end
  78. if sword.nil?
  79. for container in find_all_containers.call
  80. next if container == lootsack
  81. if container.contents.nil?
  82. result = dothistimeout \"open #\#{container.id}\", 10, /^You open|^That is already open|^There doesn't seem to be any way to do that|^What were you referring to|^I could not find what you were referring to/
  83. if container.contents.nil? and result =~ /^That is already open/
  84. dothistimeout \"look in #\#{container.id}\", 10, /^In the|^There is nothing|^That is closed|^What were you referring to|^I could not find what you were referring to/
  85. elsif result =~ /^You open/
  86. close_containers.push(container)
  87. end
  88. end
  89. if sword = container.contents.find { |obj| obj.name == 'short sword' }
  90. sword_container = container
  91. break
  92. end
  93. end
  94. end
  95. if sword
  96. dothistimeout \"_drag #\#{sword.id} right\", 10, /^You (?:carefully )?(?:remove|grab|reach|slip|tuck)|^Get what/
  97. else
  98. if $go2_get_silvers
  99. this_room = Room.current
  100. if Script.running.find_all { |s| s.name == 'go2' }.length > 1
  101. echo 'oh crap'
  102. for s in Script.running
  103. s.kill if s.name == 'go2' and s != Script.self
  104. end
  105. exit
  106. end
  107. force_start_script 'go2', [ 'bank', '--disable-confirm' ]
  108. wait_while { Script.running.find_all { |s| s.name == 'go2' }.length > 1 }
  109. fput 'unhide' if hidden? or invisible?
  110. fput 'withdraw 200'
  111. force_start_script 'go2', [ 'weaponshop', '--disable-confirm' ]
  112. wait_while { Script.running.find_all { |s| s.name == 'go2' }.length > 1 }
  113. fput 'unhide' if hidden? or invisible?
  114. fput 'order 3'
  115. fput 'buy'
  116. force_start_script 'go2', [ 'bank', '--disable-confirm' ]
  117. wait_while { Script.running.find_all { |s| s.name == 'go2' }.length > 1 }
  118. fput 'unhide' if hidden? or invisible?
  119. fput 'deposit all'
  120. force_start_script 'go2', [ this_room.id.to_s ]
  121. wait_while { Script.running.find_all { |s| s.name == 'go2' }.length > 1 }
  122. else
  123. echo 'You have no short sword! Use ;go2 getsilvers=on if you want this script to buy one for you.'
  124. close_containers.each { |c| fput \"close #\#{c.id}\" }
  125. fill_hands
  126. exit
  127. end
  128. end
  129. if resolve = Spell[9704] and resolve.known? and resolve.affordable? and not resolve.active?
  130. resolve.cast
  131. end
  132. move 'go pool'
  133. fput 'swim down'
  134. fput 'kneel'
  135. sleep 0.5
  136. fput 'pry gap'
  137. waitrt?
  138. if Room.current.id == 22229
  139. fput 'swim up'
  140. fput 'go shore'
  141. waitrt?
  142. stow_sword.call
  143. close_containers.each { |c| fput \"close #\#{c.id}\" }
  144. fill_hands
  145. $go2_restart = true
  146. else
  147. waitrt?
  148. fput 'stand' until standing?
  149. waitrt?
  150. stow_sword.call
  151. close_containers.each { |c| fput \"close #\#{c.id}\" }
  152. fill_hands
  153. $go2_restart = true
  154. end
Add Comment
Please, Sign In to add comment