Advertisement
Whiteaxe

fletchdart

Dec 15th, 2015
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 66.35 KB | None | 0 0
  1. =begin
  2. *** Please note while functional this is still the first draft and could still be bugs i have not picked up on. ***
  3.  
  4. Will make, paint and crest arrows. If you are in a mapped room it can run to the shop and buy more items.
  5. This is mostly aimed at master fletchers as it will always try and complete the arrow, but should cope with botching arrows. Future updates will let you choose to stop part way.
  6. Will keep on going untill you tell it to stop or you hit the limit you set.
  7. ';fletching help' for help
  8. ';fletching setup' to change your settings
  9. ';fletching bundle' will attempt to bundle all your arrows, this will likely fail if you are not at, or near mastered, as you make arrows of all different qualities
  10. ';fletching' while the script is running will bring up a mini report(same as you get after finishing an arrow
  11. ';fletching stop' while the script is running will tell the script to stop after finsihing the current arrow
  12.  
  13.  
  14. **** Change log ****
  15. 14/12/2015 -Added exp checkrest, flip option
  16. 27/08/2015 - When using option for paintstick 1 the stow was failing, now works
  17. 26/08/2015 - Fixed a few bugs. Should now properly check for wood and stow items in the correct container.
  18. 13/05/2012 - released
  19.  
  20. #planed updated
  21. *Batch mode - do each step in batches so glue/pain can dry sitting in your bag while you work on another arrow
  22. *Fix so bow can be kept in a container, currently needs to be worn
  23. *check containers/axe/knife/bow exist before starting
  24. *on first run scan inv and guess most likely settings
  25.  
  26. If you need to contact me best way is probably a PM to stormtov on the player forums or post in my thread there http://forum.gsplayers.com/showthread.php?t=70042.
  27. Feel free to send me bug reports/suggestions/abuse there.
  28. #todo
  29. --checkrest --added exp check, checkrest
  30. --cut all shafts in batches
  31. --make own fletchings
  32. --save arrow profiles
  33. --flip arrows --added option line before cut arrow with fletch_knife
  34. --toggle for waggle
  35. --scan inventory for knife/axe/bow
  36. --scan inventory for containers
  37. =end
  38.  
  39.  
  40. #fixme1 - Bow currently must be worn, change so checks GameObj.inv and if not there gets it from container instead
  41. @XP_TO_STOP = 80;
  42. settings = CharSettings.to_hash
  43. settings['fletch_sack'] ||= ""
  44. settings['fletch_quiver'] ||= ""
  45. settings['fletch_knife'] ||= ""
  46. settings['fletch_bow'] ||= ""
  47. settings['fletch_enable_buying'] ||= false
  48. settings['fletch_paint'] ||= 0
  49. settings['fletch_paintstick1'] ||= ""
  50. settings['fletch_paintstick2'] ||= ""
  51. settings['fletch_wood'] ||= "limb of wood"
  52. settings['fletch_axe'] ||= ""
  53. settings['fletch_fletchings'] ||= "bundle of fletchings"
  54. settings['fletch_limit'] ||= ""
  55. settings['waggle'] ||= false
  56. settings['fletch_flip'] ||= false
  57. settings['fletch_drill'] ||= ""
  58. settings['fletch_arrowhead'] ||= ""
  59. settings['fletch_drilling'] ||= false
  60.  
  61. #doesnt really need to be a hash but had to make sure they were in the right order to add the drop down menu on the gui
  62. paints = {
  63. 0 => 'none',
  64. 1 => 'bright golden paint',
  65. 2 => 'fiery orange paint',
  66. 3 => 'bright yellow paint',
  67. 4 => 'dark russet paint',
  68. 5 => 'dark brown paint',
  69. 6 => 'silvery grey paint',
  70. 7 => 'twilight grey paint',
  71. 8 => 'storm grey paint',
  72. 9 => 'charcoal grey paint',
  73. 10 => 'icy blue paint',
  74. 11 => 'midnight blue paint',
  75. 12 => 'dusky blue paint',
  76. 13 => 'silvery white paint',
  77. 14 => 'bone white paint',
  78. 15 => 'pure white paint',
  79. 16 => 'glossy black paint',
  80. 17 => 'dull black paint',
  81. 18 => 'inky black paint',
  82. 19 => 'forest green paint',
  83. 20 => 'hunter green paint',
  84. 21 => 'dark green paint',
  85. 22 => 'blood red paint',
  86. 23 => 'glossy red paint',
  87. 24 => 'dull red paint',
  88. }
  89.  
  90. #Ripped setup from sloot, no clue waht is going on here but it works!
  91. setup = proc {
  92.  
  93.  
  94.  
  95. gtk_global = Hash.new
  96. window = window_action = nil
  97. Gtk.queue {
  98. ttips = Gtk::Tooltips.new.enable
  99. ttips_text = {
  100. 'fletch_sack' => 'This is the container all your supplies, axe and dagger will be in',
  101. 'fletch_quiver' => 'This is the container you want your finshed arrows to be stored in, it can be the same as the container above if you wish',
  102. 'fletch_axe' => 'This is the axe you will use for creating the shafts, needs to be what ever you would type following the get comand to remove it from your container.' ,
  103. 'fletch_knife' => 'This is the knife or dagger you will be using to cut the shafts, needs to be what ever you would type following the get comand to remove it from your container.' ,
  104. 'fletch_bow' => 'This is the bow you will be using to measure the shaft, MUST BE WORN!',
  105. 'fletch_enable_painting' => 'Check this if you would like to paint your arrows',
  106. 'fletch_enable_buying' => 'Check this if you would like the script to go buy wood, glue and fletchings from the shop',
  107. 'fletch_wood' => 'The name of the wood you would like to buy, leaving off a/an/some at the start. Eg. "limb of faewood" or "branch of kakore"',
  108. 'fletch_paint' => 'The name of the paint you would like to buy, leaving off a/an/some at the start',
  109. 'fletch_paintstick1' => 'Leave blank if you do not want to use a paintstick to crest your arrows. If you want to crest you arrows please enter the colour of the paintstick.',
  110. 'fletch_paintstick2' => 'Leave blank if you do not want to use a paintstick to crest your arrows a second time. If you want to crest you arrows a second time please enter the colour of the paintstick.',
  111. 'fletch_fletchings' => 'The name of the fletchings you would like to buy, leaving off a/an/some at the start.',
  112. 'fletch_limit' => 'This is the number of arrows you would like the script to make, leave blank for no limit. It will just keep making more till you tell it to stop, run out of space or run out of money.',
  113. 'fletch_flip' => 'This is used to flip the shaft once.',
  114. 'fletch_drill' => 'This can be any drill, but we start with an option like, blackened glaes-bitted drill.',
  115. 'fletch_arrowhead' => 'This can be any arrowhead, imflass, vultite, ora, mithril, steel, but must be {objectname} arrowhead.',
  116. 'fletch_drilling' => 'Check this box if you want to add arrowheads to your shafts.',
  117.  
  118. }
  119.  
  120. gtk_global['fletch_sack'] = Gtk::Entry.new.set_text(settings['fletch_sack'])
  121. gtk_global['fletch_quiver'] = Gtk::Entry.new.set_text(settings['fletch_quiver'])
  122. gtk_global['fletch_axe'] = Gtk::Entry.new.set_text(settings['fletch_axe'])
  123. gtk_global['fletch_knife'] = Gtk::Entry.new.set_text(settings['fletch_knife'])
  124. gtk_global['fletch_bow'] = Gtk::Entry.new.set_text(settings['fletch_bow'])
  125. gtk_global['fletch_enable_buying'] = Gtk::CheckButton.new.set_active(settings['fletch_enable_buying'])#Gtk::Entry.new.set_text(settings['fletch_enable_buying'])
  126. gtk_global['fletch_wood'] = Gtk::Entry.new.set_text(settings['fletch_wood'])
  127. gtk_global['fletch_paint'] = Gtk::ComboBox.new(is_text_only = true)
  128. gtk_global['fletch_paintstick1'] = Gtk::Entry.new.set_text(settings['fletch_paintstick1'])
  129. gtk_global['fletch_paintstick2'] = Gtk::Entry.new.set_text(settings['fletch_paintstick2'])
  130. gtk_global['fletch_fletchings'] = Gtk::Entry.new.set_text(settings['fletch_fletchings'])
  131. gtk_global['fletch_limit'] = Gtk::Entry.new.set_text(settings['fletch_limit'].to_s)
  132. gtk_global['waggle'] = Gtk::CheckButton.new.set_active(settings['waggle'])
  133. gtk_global['fletch_drill'] = Gtk::Entry.new.set_text(settings['fletch_drill'])
  134. gtk_global['fletch_flip'] = Gtk::CheckButton.new.set_active(settings['fletch_flip'])
  135. gtk_global['fletch_drilling'] = Gtk::CheckButton.new.set_active(settings['fletch_drilling'])
  136. gtk_global['fletch_arrowhead'] = Gtk::Entry.new.set_text(settings['fletch_arrowhead'])
  137. #use paints array to form combox
  138. x = 0
  139. while x < paints.length
  140. gtk_global['fletch_paint'].append_text(paints[x])
  141. x += 1
  142. end
  143. gtk_global['fletch_paint'].set_active(settings['fletch_paint']) #have to set active after apending
  144.  
  145.  
  146.  
  147.  
  148. ttips_text.each_pair { |widget,tip|
  149. if widget = gtk_global[widget]# || gtk_locals[widget]
  150. ttips.set_tip(widget,tip,'')
  151. end
  152. }
  153.  
  154. window = Gtk::Window.new
  155. window.title = "Fletching"
  156. window.border_width = 3
  157. window.resizable = true
  158. #window.resize(10, 10)
  159.  
  160. settings_page = Gtk::VBox.new(false,1).set_border_width(3)
  161. vb_pg1_1 = Gtk::VBox.new(false,1).set_border_width(3)
  162. fr_pg1_1 = Gtk::Frame.new.set_border_width(5).set_label_widget(Gtk::Label.new.set_markup('<big><b>Settings</b></big>'))
  163. fr_pg1_1.add(vb_pg1_1)
  164. settings_page.pack_start(fr_pg1_1,false)
  165.  
  166. #random note to self width will be ignored if text is longer
  167. hb = Gtk::HBox.new(false,1)
  168. hb.pack_start(Gtk::Alignment.new(1,0,0,1).add(Gtk::Label.new('Supplies Container: ')).set_width_request(120))
  169. hb.pack_start(gtk_global['fletch_sack'],false)
  170. vb_pg1_1.pack_start(hb,false)
  171.  
  172. hb = Gtk::HBox.new(false,1)
  173. hb.pack_start(Gtk::Alignment.new(1,0,0,1).add(Gtk::Label.new('Finished Container: ')).set_width_request(120))
  174. hb.pack_start(gtk_global['fletch_quiver'],false)
  175. vb_pg1_1.pack_start(hb,false)
  176.  
  177. hb = Gtk::HBox.new(false,1)
  178. hb.pack_start(Gtk::Alignment.new(1,0,0,1).add(Gtk::Label.new('Axe: ')).set_width_request(120))
  179. hb.pack_start(gtk_global['fletch_axe'],false)
  180. vb_pg1_1.pack_start(hb,false)
  181.  
  182. hb = Gtk::HBox.new(false,1)
  183. hb.pack_start(Gtk::Alignment.new(1,0,0,1).add(Gtk::Label.new('Knife: ')).set_width_request(120))
  184. hb.pack_start(gtk_global['fletch_knife'],false)
  185. vb_pg1_1.pack_start(hb,false)
  186.  
  187. hb = Gtk::HBox.new(false,1)
  188. hb.pack_start(Gtk::Alignment.new(1,0,0,1).add(Gtk::Label.new('Drill: ')).set_width_request(120))
  189. hb.pack_start(gtk_global['fletch_drill'],false)
  190. vb_pg1_1.pack_start(hb,false)
  191.  
  192. hb = Gtk::HBox.new(false,1)
  193. hb.pack_start(Gtk::Alignment.new(1,0,0,1).add(Gtk::Label.new('Bow: ')).set_width_request(120))
  194. hb.pack_start(gtk_global['fletch_bow'],false)
  195. vb_pg1_1.pack_start(hb,false)
  196.  
  197. hb = Gtk::HBox.new(false,1)
  198. hb.pack_start(Gtk::Alignment.new(1,0,0,1).add(Gtk::Label.new('Buy Items: ')).set_width_request(120))
  199. hb.pack_start(gtk_global['fletch_enable_buying'],false)
  200. vb_pg1_1.pack_start(hb,false)
  201.  
  202. hb = Gtk::HBox.new(false,1)
  203. hb.pack_start(Gtk::Alignment.new(1,0,0,1).add(Gtk::Label.new('Wood: ')).set_width_request(120))
  204. hb.pack_start(gtk_global['fletch_wood'],false)
  205. vb_pg1_1.pack_start(hb,false)
  206.  
  207. hb = Gtk::HBox.new(false,1)
  208. hb.pack_start(Gtk::Alignment.new(1,0,0,1).add(Gtk::Label.new('Paint: ')).set_width_request(120))
  209. hb.pack_start(gtk_global['fletch_paint'].set_width_request(158),false)
  210. vb_pg1_1.pack_start(hb,false)
  211.  
  212. hb = Gtk::HBox.new(false,1)
  213. hb.pack_start(Gtk::Alignment.new(1,0,0,1).add(Gtk::Label.new('Paintstick 1: ')).set_width_request(120))
  214. hb.pack_start(gtk_global['fletch_paintstick1'],false)
  215. vb_pg1_1.pack_start(hb,false)
  216.  
  217. hb = Gtk::HBox.new(false,1)
  218. hb.pack_start(Gtk::Alignment.new(1,0,0,1).add(Gtk::Label.new('Paintstick 2: ')).set_width_request(120))
  219. hb.pack_start(gtk_global['fletch_paintstick2'],false)
  220. vb_pg1_1.pack_start(hb,false)
  221.  
  222. hb = Gtk::HBox.new(false,1)
  223. hb.pack_start(Gtk::Alignment.new(1,0,0,1).add(Gtk::Label.new('Fletchings: ')).set_width_request(120))
  224. hb.pack_start(gtk_global['fletch_fletchings'],false)
  225. vb_pg1_1.pack_start(hb,false)
  226.  
  227. hb = Gtk::HBox.new(false,1)
  228. hb.pack_start(Gtk::Alignment.new(1,0,0,1).add(Gtk::Label.new('Make limit: ')).set_width_request(120))
  229. hb.pack_start(gtk_global['fletch_limit'],false)
  230. vb_pg1_1.pack_start(hb,false)
  231.  
  232. hb = Gtk::HBox.new(false,1)
  233. hb.pack_start(Gtk::Alignment.new(1,0,0,1).add(Gtk::Label.new('Use waggle: ')).set_width_request(120))
  234. hb.pack_start(gtk_global['waggle'],false)
  235. vb_pg1_1.pack_start(hb,false)
  236.  
  237. hb = Gtk::HBox.new(false,1)
  238. hb.pack_start(Gtk::Alignment.new(1,0,0,1).add(Gtk::Label.new('Use flip: ')).set_width_request(120))
  239. hb.pack_start(gtk_global['fletch_flip'],false)
  240. vb_pg1_1.pack_start(hb,false)
  241.  
  242. hb = Gtk::HBox.new(false,1)
  243. hb.pack_start(Gtk::Alignment.new(1,0,0,1).add(Gtk::Label.new('add arrowheads: ')).set_width_request(120))
  244. hb.pack_start(gtk_global['fletch_drilling'],false)
  245. vb_pg1_1.pack_start(hb,false)
  246.  
  247.  
  248. #cb = Gtk::ComboBox.new
  249. #cb.append_text 'Ubuntu'
  250. #cb.append_text 'Mandriva'
  251. #cb.append_text 'Redhat'
  252. #cb.append_text 'Gento'
  253. #cb.append_text 'Mint'
  254. #cb.pack_start(Gtk::Alignment.new(1,0,0,1).add(Gtk::Label.new('Paint: ')).set_width_request(120))
  255. #cb.pack_start(gtk_global['fletch_paint'],false)
  256. #cb.pack_start(cb.append_text 'Ubuntu')
  257. #vb_pg1_1.pack_start(cb,false)
  258.  
  259. lbl = Gtk::Label.new.set_markup("Mouse over each box for more help")
  260. lbl.set_wrap(true).set_padding(0,10)
  261. vb_pg1_1.pack_start(lbl,false)
  262.  
  263. hb_saveclose = Gtk::HBox.new(false,1)
  264. save = Gtk::Button.new('_Save & Close')
  265. close = Gtk::Button.new('E_xit')
  266. save.signal_connect('clicked') { window_action = :save }
  267. close.signal_connect('clicked') { window_action = :done }
  268. hb_saveclose.pack_start(save,false)
  269. hb_saveclose.pack_start(close,false)
  270. vb_pg1_1.pack_start(hb_saveclose,false)
  271.  
  272.  
  273.  
  274.  
  275.  
  276. # Primary VerticalBox to split up Notebook and Save/Close buttons
  277. #vb_main = Gtk::VBox.new(false,1)
  278. #vb_main.border_width = 3
  279.  
  280. #vb_main.pack_start(nb,false)
  281. #vb_main.pack_start(hb_saveclose,false)
  282.  
  283. window.signal_connect('delete_event') { window_action = :exit }
  284.  
  285. #window.add(vb_main)
  286.  
  287.  
  288. window.add(settings_page)
  289.  
  290.  
  291.  
  292. window.show_all
  293. window.keep_above = true # On windows keep_above is required AFTER show_all
  294.  
  295. }
  296. before_dying { Gtk.queue { window.destroy } }
  297. wait_while { window_action.nil? }
  298. undo_before_dying
  299. Gtk.queue { window.destroy }
  300. clean_entry = proc { |entry|
  301. entry.text = entry.text.strip
  302. if entry.text.empty?
  303. entry.text = nil
  304. end
  305.  
  306. entry.text
  307. }
  308.  
  309. if window_action == :save
  310. gtk_global.each_pair { |option,widget|
  311.  
  312. if widget.class == Gtk::CheckButton
  313. settings[option] = widget.active?
  314. elsif widget.class == Gtk::Entry
  315. settings[option] = clean_entry.call(widget)
  316. elsif widget.class == Gtk::ComboBox
  317. settings[option] = widget.active
  318. else
  319. echo "error: unknown local widget #{option} [#{widget.class}]"
  320. end
  321. }
  322.  
  323. #attempt some error checking
  324. warning = ""
  325. if settings['fletch_sack'] == ""
  326. warning += "The container for you supplies has not yet been set, the script will not run untill this is added.\r\n"
  327. end
  328. if settings['fletch_quiver'] == ""
  329. warning += "The container for you finished arrows has not yet been set, the script will not run untill this is added.\r\n"
  330. end
  331. if settings['fletch_knife'] == ""
  332. warning += "Have not set a knife/dagger to cut the shafts with, the script will not run untill this is added.\r\n"
  333. end
  334. if settings['fletch_bow'] == ""
  335. warning += "Have not set a bow to measure the shafts with, the script will not run untill this is added.\r\n"
  336. end
  337. if settings['fletch_axe'] == ""
  338. warning += "Have not set an axe to make shafts with, the script will not run untill this is added.\r\n"
  339. end
  340. if settings['fletch_wood'] == ""
  341. warning += "Have not set a what wood you want to use, the script will not run untill this is added.\r\n"
  342. end
  343. if settings['fletch_wood'] != "" and settings['fletch_wood'] !~ /wood/
  344. warning += "You have set what wood you want to use but appears you may have done so incorectly. It should read along the lines of 'limb of wood' or 'branch of faewood' for example.\r\n"
  345. end
  346. if settings['fletch_wood'] =~ /\s*a |\s*an |\s*some /
  347. settings['fletch_wood'].gsub!(/\s*a |\s*an |\s*some /, '')
  348. end
  349. if settings['fletch_paintstick1'] != "" and settings['fletch_paintstick1'] !~ /paintstick/
  350. settings['fletch_paintstick1'] = "#{settings['fletch_paintstick1'].strip} paintstick"
  351. end
  352. if settings['fletch_paintstick2'] != "" and settings['fletch_paintstick2'] !~ /paintstick/
  353. settings['fletch_paintstick2'] = "#{settings['fletch_paintstick2'].strip} paintstick"
  354. end
  355. if settings['fletch_fletchings'] != "" and settings['fletch_fletchings'] !~ /fletching/
  356. warning += "You have set what fletchings you want to use but appears you may have done so incorectly. It should read along the lines of 'bundle of fletchings' for example. Leave off any a/an/some from the start.\r\n"
  357. end
  358. if settings['fletch_fletchings'] =~ /\s*a |\s*an |\s*some /
  359. settings['fletch_fletchings'].gsub!(/\s*a |\s*an |\s*some /, '')
  360. end
  361. if settings['fletch_drill'] == ""
  362. warning += "Have not set drill to use for drilling shafts, the script will not run untill this is added.\r\n"
  363. end
  364. if settings['fletch_drill'] =~ /\s*a |\s*an |\s*some /
  365. settings['fletch_drill'].gsub!(/\s*a |\s*an |\s*some /, '')
  366. end
  367. if settings['fletch_arrowhead'] =~ /\s*a |\s*an |\s*some /
  368. settings['fletch_arrowhead'].gsub!(/\s*a |\s*an |\s*some /, '')
  369. end
  370. if warning.length > 0
  371. if !$fake_stormfront
  372. puts "<output class=\"mono\"/>#{monsterbold_start}#{warning}#{monsterbold_end}\r\n<output class=\"\"/>"
  373. else
  374. puts "#{monsterbold_start}#{warning}#{monsterbold_end}"
  375. end
  376. end
  377. echo 'settings saved'
  378. else
  379. echo 'closed without saving'
  380. end
  381. }
  382.  
  383.  
  384. def monitor_interaction()
  385. #if @MONITOR_INTERACTION
  386. start_exec_script( <<-eos
  387. def show_window(line);
  388. window_title = Char.name + ':' + line;
  389. Gtk.queue {
  390. $myWindow = Gtk::Window.new;
  391. $myWindow.title = "Autobot Alert!";
  392. $myWindow.set_size_request(450, 25);
  393. label = Gtk::Label.new window_title;
  394. $myWindow.add(label);
  395. $myWindow.show_all;
  396. };
  397. end;
  398. while(line = get);
  399. break unless running?('fletching');
  400. if(line =~ /SEND|POLICY|[Rr](\s)*[Ee](\s)*[Pp](\s)*[Oo](\s)*[Rr](\s)*[Tt]|peaking to you|unresponsive|taps you|nods to you|lease respond|not in control|character|violation|lease speak|peak out loud|Y U SHOU D|whispers,|speaking to you|smiles at you|waves to you|grins at you|hugs you|takes hold your hand|grabs your hand|clasps your hand|trying to drag you/);
  401. unless(line =~ /LNet/);
  402. show_window(line);
  403. echo "AUTOBOT ALERT: " + line;
  404. end;
  405. end;
  406. end;
  407. eos
  408. )
  409. end
  410. # end
  411.  
  412. def checksilver
  413. silvers = nil
  414. action = proc { |server_string|
  415. if server_string =~ /^\s*Name\:|^\s*Gender\:|^\s*Normal \(Bonus\)|^\s*Strength \(STR\)\:|^\s*Constitution \(CON\)\:|^\s*Dexterity \(DEX\)\:|^\s*Agility \(AGI\)\:|^\s*Discipline \(DIS\)\:|^\s*Aura \(AUR\)\:|^\s*Logic \(LOG\)\:|^\s*Intuition \(INT\)\:|^\s*Wisdom \(WIS\)\:|^\s*Influence \(INF\)\:/
  416. nil
  417. elsif server_string =~ /^\s*Mana\:\s+\-?[0-9]+\s+Silver\:\s+([0-9]+)/
  418. silvers = $1.to_i
  419. DownstreamHook.remove("slib_check_silvers")
  420. nil
  421. else
  422. server_string
  423. end
  424. }
  425. DownstreamHook.add("slib_check_silvers", action)
  426. $_SERVER_.puts "#{$cmd_prefix}info\n"
  427. wait_until { silvers }
  428. silvers
  429. end
  430.  
  431. def get_container_contents(container_name)
  432.  
  433. if container_name.nil?
  434. echo 'Blank name passed to get_container_contents'
  435. sleep 1
  436. exit
  437. else
  438. container_contents = GameObj.inv.find { |obj| obj.name =~ /#{Regexp.escape(container_name.strip)}/i } || GameObj.inv.find { |obj| obj.name =~ /#{Regexp.escape(container_name).sub(' ', ' .*')}/i }
  439. if container_contents.nil?
  440. echo "warning: failed to find your fletchsack (#{container_name})"
  441. sleep 1
  442. else
  443. if container_contents.contents.nil?
  444. open_result = dothistimeout "open ##{container_contents.id}", 10, /You open|already open/
  445. close_container_contents = true if open_result =~ /You open/
  446. if container_contents.contents.nil?
  447. dothistimeout "look in ##{container_contents.id}", 10, /In the .* you see/
  448. if container_contents.contents.nil?
  449. echo "warning: failed to find the contents of your fletchsack (#{container_name})"
  450. sleep 1
  451. end
  452. end
  453. end
  454. end
  455. end
  456. return container_contents.contents
  457. end
  458.  
  459. def check_needed_items(settings,fletch_sack_contents,paints)
  460. items = Array.new
  461. needed_items = Array.new
  462. need_wood = true
  463. need_paint = true
  464. need_glue = true
  465. need_fletchings = true
  466. need_paintstick1 = true
  467. need_paintstick2 = true
  468. #check container and if we have it mark as not needed
  469. fletch_sack_contents.each{|item|
  470. #fixme: see if can get more specfic then shaft
  471. if (settings['fletch_bow'] =~ /^crossbow/) item.name =~ /crossbow shaft/ or item.name =~ /#{settings['fletch_wood']}/
  472. need_wood = false
  473. elsif (settings['fletch_bow'] =~ /^bow/) item.name =~ /arrow shaft/ or item.name =~ /#{settings['fletch_wood']}/
  474. need_wood = false
  475. elsif (settings['fletch_bow'] =~ /^dart/) item.name =~ /dart shaft/ or item.name =~ /#{settings['fletch_wood']}/
  476. need_wood = false
  477. elsif item.name =~ /#{paints[settings['fletch_paint']]}/
  478. need_paint = false
  479. elsif item.name =~ /#{settings['fletch_fletchings']}/
  480. need_fletchings = false
  481. elsif item.name =~ /bottle of fletching glue/
  482. need_glue = false
  483. elsif item.name =~ /#{settings['fletch_paintstick1']}/ and settings['fletch_paintstick1'].length > 0
  484. need_paintstick1 = false
  485. elsif item.name =~ /#{settings['fletch_paintstick2']}/ and settings['fletch_paintstick2'].length > 0
  486. need_paintstick2 = false
  487. end
  488. }
  489.  
  490. needed_items = Array.new
  491.  
  492. if need_wood
  493. needed_items << settings['fletch_wood']
  494. end
  495. if need_glue
  496. needed_items << "bottle of fletching glue"
  497. end
  498. if need_fletchings
  499. needed_items << settings['fletch_fletchings']
  500. end
  501. if need_paint and settings['fletch_paint'] != 0
  502. needed_items << "vial of paint"
  503. end
  504. if need_paintstick1 and settings['fletch_paintstick1'].length > 0
  505. needed_items << settings['fletch_paintstick1']
  506. end
  507. if need_paintstick2 and settings['fletch_paintstick2'].length > 0
  508. needed_items << settings['fletch_paintstick2']
  509. end
  510.  
  511.  
  512.  
  513. return needed_items
  514. end
  515.  
  516. def find_order_num(supply)
  517.  
  518. status_tags
  519. clear
  520. fput 'unhide' if hidden? or invisible?
  521. fput 'order'
  522. menu = Hash.new
  523. while (line = get) and (line !~ /ORDER|BUY/)
  524. for item in line.scan(/<d.*?cmd=["']order ([0-9]+).*?>(.*?)<\/d>/)
  525. menu[item[1].sub(/^a /, '')] = item[0]
  526. end
  527. end
  528. clear
  529. status_tags
  530.  
  531. #menu = read_menu.call
  532. #echo menu.inspect
  533.  
  534. item_name = menu.keys.find { |name| name =~ /#{supply}/i }
  535. unless order_number = menu[item_name]
  536. echo ""
  537. echo "Error: failed to find the item! Remember to leave off the a/an/some at the start. eg. 'limb of faewood"
  538. echo ""
  539. end
  540. return order_number
  541.  
  542. end
  543.  
  544.  
  545.  
  546. def buy_items(settings, needed_items)
  547. if invisible?
  548. invis = true
  549. else
  550. invis = false
  551. end
  552. start_room = Room.current.id
  553. silver = checksilver
  554. if silver < 5000
  555. silver = 5000 - silver
  556. start_script "go2",['bank']
  557. wait_while {running?("go2")}
  558. fput "unhide" if hidden? or invisible?
  559. fput "withdraw #{silver}"
  560. if checksilver < 5000
  561. echo "Failed to get money from the bank"
  562. exit
  563. end
  564. end
  565. start_script "go2",['fletcher']
  566. wait_while {running?("go2")}
  567. move "south" if Room.current.location == "Ta'Vaalor"
  568.  
  569. if checkleft != nil
  570. empty_left_hand
  571. end
  572. if checkright != nil
  573. empty_right_hand
  574. end
  575. needed_items.each {|item|
  576.  
  577. if item =~ /vial of paint/
  578. order_number = find_order_num(item)
  579. multifput "order #{order_number} color #{settings['fletch_paint']}", "buy"
  580. else
  581. order_number = find_order_num(item)
  582. multifput "order #{order_number}", "buy"
  583. end
  584.  
  585. #wait up to three seconds to see if purchase was succesful
  586. endtime = Time.now + 3
  587. loop {
  588. if checkright.nil?
  589. sleep 1
  590. elsif Time.now > endtime
  591. echo "For some reason buying an item failed"
  592. exit
  593. elsif checkright
  594. echo "got item"
  595. break
  596. end
  597. }
  598. stow_check = dothistimeout "put my #{checkright} in my #{settings['fletch_sack']}", 3, /won't fit|You put a/
  599. if stow_check =~ /won't fit/
  600. echo "fletchsack full, stopping"
  601. exit
  602. elsif stow_check.nil?
  603. echo "stowcheck failed, stopping"
  604. exit
  605. end
  606.  
  607. }
  608. spent_silver += (5000 - checksilver)
  609.  
  610. start_script "go2",['bank']
  611. wait_while {running?("go2")}
  612. fput "unhide" if hidden? or invisible?
  613. fput "depo all"
  614. if invis and Spell[916].affordable?
  615. fput "incant 916"
  616. end
  617. start_script "go2",[start_room]
  618. wait_while {running?("go2")}
  619. return spent_silver
  620. end
  621.  
  622. def stow(hand,container)
  623. if (hand == "left")
  624. return if checkleft.nil?
  625. elsif (hand == "right")
  626. return if checkright.nil?
  627. else
  628. respond "This should not of happened"
  629. respond "Invalid hand of: #{hand}"
  630. exit
  631. end
  632. fput "put #{hand} in my #{container}"
  633. again = false
  634. endtime = Time.now + 6
  635. loop{
  636. if (checkleft.nil? && hand == "left")
  637. break
  638. elsif (checkright.nil? && hand == "right")
  639. break
  640. elsif Time.now > endtime -3 and !again
  641. again = true
  642. fput "put #{hand} in my #{container}"
  643. elsif Time.now > endtime
  644. "Stowing item failed"
  645. else
  646. sleep 0.1
  647. end
  648. }
  649. end
  650.  
  651. def get_knife(settings)
  652. check = dothistimeout "get my #{settings['fletch_knife']}", 3, /You remove|get what?/
  653. if check =~ /get what?/
  654. echo "Failed to get your knife."
  655. exit
  656. elsif check.nil?
  657. endtime = Time.now + 5
  658. loop {
  659. if checkleft =~ /#{settings['fletch_knife']}/
  660. break
  661. elsif Time.now > endtime
  662. echo "Failed to get your knife."
  663. exit
  664. else
  665. sleep 1
  666. end
  667. }
  668. end
  669. end
  670.  
  671. def haste!()
  672. waitcastrt?
  673. fput "incant 506" if Spell[506].known? and !Spell[506].active? and Spell[506].affordable?
  674. end
  675.  
  676. def bundle(settings)
  677. #gameobj does not get full descriptions so have to go about it ma self
  678. quiver_contents_string = nil
  679. quiver_contents = proc{|server_string|
  680. if server_string =~ /<inv id='\w+'>In the <a exist="\d+" noun="\w+">\w+<\/a>:<\/inv><inv id='\w+'>/
  681. quiver_contents_string = server_string
  682. nil
  683. else
  684.  
  685. server_string
  686. end
  687. }
  688. DownstreamHook.add('fletch_check_quiver', quiver_contents)
  689. silence_me
  690. fput "look in my #{settings['fletch_quiver']}"
  691. silence_me
  692. endtime = Time.now + 3
  693. loop {
  694. if quiver_contents_string != nil
  695. DownstreamHook.remove('fletch_check_quiver')
  696. break
  697. elsif Time.now > endtime
  698. echo "failed to get the contents of #{settings['fletch_quiver']}"
  699. DownstreamHook.remove('fletch_check_quiver')
  700. exit
  701. else
  702. sleep 0.1
  703. end
  704. }
  705.  
  706. if quiver_contents_string =~ /<inv id='(?:\w+)'>In the <a exist="(\d+)" noun="(\w+)">(?:\w+)<\/a>:<\/inv><inv id='(?:\w+)'> (.*)<\/inv>In the <a exist="\d+" noun="\w+">([\w\s\-']+)<\/a>/
  707. quiver_contents = $3.to_s.gsub( /["]/ , '\'' )
  708. quiver_contents = quiver_contents.split(/<\/inv><inv id='\w+'>\s?/)
  709.  
  710. else
  711. echo "contents malformed"
  712. end
  713. contents = Hash.new
  714. quiver_contents.each{|item|
  715. if item =~ /(.+)<a exist='(\d+)' noun='([\w\-]+)'>([\w\s\-']+)<\/a>([\s\w'\-]+)?/
  716. item_id = $2
  717. item_noun = $3
  718. item_full_name = ""
  719. item_full_name = item_full_name.strip + "#{$1.strip}"
  720. item_full_name = item_full_name.strip + " #{$4.strip} "
  721. item_full_name = item_full_name.strip + " #{$5.strip}"
  722. item_full_name.strip!
  723. end
  724. contents[item_id] = item_full_name
  725. }
  726. #finds the description of each different type of arrow
  727. arrow_types = Array.new
  728. contents.each_pair{|id,name|
  729. if name =~ /arrow$/ and !arrow_types.include? name
  730. arrow_types << name
  731. end
  732. }
  733. arrow_types.each{|desc|
  734. contents.each_pair{|id,name|
  735. if desc =~ /#{name}/
  736. if checkright.nil?
  737. fput "get ##{id} in my #{settings['fletch_quiver']}"
  738. endtime = Time.now + 6
  739. wait_until{!checkright.nil? || Time.now > endtime}
  740. else
  741. fput "get ##{id} in my #{settings['fletch_quiver']}"
  742. end
  743. if !checkleft.nil? and !checkright.nil?
  744. check = dothistimeout "bundle", 3, /You bundle your arrows together.|You add a .+ arrow to your bundle.|You may not combine more than 100 shafts./
  745. if check.nil?
  746. echo "bundling failed for some reason, stopping"
  747. exit
  748. elsif check =~ /You may not combine more than 100 shafts./
  749. #fput "stow r"
  750. stow("right",settings['fletch_quiver'])
  751. end
  752. endtime = Time.now + 6
  753. wait_until{checkleft.nil? || Time.now > endtime}
  754. end
  755. end
  756. }
  757. #fput "stow right"
  758. stow("right",settings['fletch_quiver'])
  759. }
  760. #now arrows are bundled see about condensing the bundles down
  761. bundle_ids = Array.new
  762. quiver_contents = get_container_contents(settings['fletch_quiver'])
  763. quiver_contents.each{|item|
  764. if item.name =~ /bundle of arrows/
  765. bundle_ids << item.id
  766. end
  767. }
  768.  
  769. bundle_amount = Array.new
  770. bundle_desc = Array.new
  771. bundle_check = proc{|server_string|
  772. #
  773. #Individual projectiles from this bundle will have a long of "a wooden arrow"
  774. #
  775. if server_string.nil?
  776. #nil
  777. elsif server_string =~ /You carefully count the <a exist="\d+" noun="\w+">\w+<\/a> and find (\d+) in the bundle, each one being .+, with a strength of \d+ and a durability of \d+./
  778. bundle_amount << $1
  779. nil
  780. elsif server_string =~ /Individual projectiles from this bundle will have a long of "([\w\s]+)"/
  781. bundle_desc << $1
  782. nil
  783. elsif server_string =~ /Each individual projectile will be "[\w\s]+"./
  784. nil
  785. elsif server_string =~ /<prompt time="\d+">&gt;<\/prompt>/
  786. nil
  787. else
  788. if server_string.length > 2
  789. server_string
  790. else
  791. nil
  792. end
  793. end
  794. }
  795. DownstreamHook.add('fletch_budle_check', bundle_check)
  796. silence_me
  797. bundle_ids.each{|id|
  798. fput "look ##{id}"
  799. }
  800. silence_me
  801. endtime = Time.now + 6
  802. wait_until{bundle_ids.length == bundle_desc.length || Time.now > endtime}
  803. DownstreamHook.remove('fletch_budle_check')
  804. if bundle_ids.length != bundle_desc.length
  805. echo "failed to get bundles info, stopping"
  806. exit
  807. end
  808. x = 0
  809. bundles = Array.new
  810. until x == bundle_ids.length
  811. bundles << bundle = {
  812. "id" => bundle_ids[x],
  813. "count" => bundle_amount[x],
  814. "desc" => bundle_desc[x]
  815. }
  816. x +=1
  817. end
  818. uniq_bundle_desc = bundle_desc & bundle_desc
  819. last_bundle = ""
  820. uniq_bundle_desc.each{|desc|
  821. total = 0
  822. bundles.each{|bundle|
  823. if bundle['desc'] == desc and total == 0 and bundle['count'].to_i!=100
  824. #there is a match but if there might only be one of that bundle so take note but do nothing
  825. total += bundle['count'].to_i
  826. last_bundle = bundle['id'].dup
  827. elsif bundle['desc'] == desc and total > 0 and bundle['count'].to_i!=100
  828. #match and the total is already above 0, must of already found a bundle of the same arrows
  829. total += bundle['count'].to_i
  830. if total < 100
  831. fput "get ##{bundle['id']}"
  832. matchtimeout 1, "You remove"
  833. fput "get ##{last_bundle}" if checkleft.nil?
  834. fput "bundle"
  835. last_bundle = bundle['id']
  836. else
  837.  
  838. if total == 100
  839. fput "get ##{bundle['id']}"
  840. matchtimeout 1, "You remove"
  841. fput "get ##{last_bundle}" if checkleft.nil?
  842. fput "bundle"
  843. #fput "stow r"
  844. stow("right",settings['fletch_quiver'])
  845. total = 0
  846. else
  847. amount_over = total - 100
  848. amount_to_get = bundle['count'].to_i - amount_over
  849. fput "get #{amount_to_get} ##{bundle['id']}"
  850. matchtimeout 1, "You remove"
  851. fput "get ##{last_bundle}" if checkleft.nil?
  852. fput "bundle"
  853. #fput "stow r"
  854. stow("right",settings['fletch_quiver'])
  855. bundle['amount'] = bundle['amount'].to_i - amount_to_get #resize the bundle
  856. bundles << bundle #and add back on the end
  857. total = 0
  858. end
  859.  
  860.  
  861.  
  862. end
  863. end
  864. }
  865. #fput "stow r" if !checkright.nil?
  866. stow("right",settings['fletch_quiver']) if !checkright.nil?
  867. }
  868. end
  869.  
  870. def make_heavyshafts(settings)
  871. check = dothistimeout "get my wood in my #{settings['fletch_sack']}", 1, /You remove|Get what?/
  872. if check =~ /Get what?/
  873. echo "Run out of shafts some how, this shouldn't be happening."
  874. exit
  875. elsif check.nil?
  876. #backup for scripted containers
  877. endtime = Time.now + 5
  878. loop {
  879. if checkright =~ /wood/
  880. break
  881. elsif Time.now > endtime
  882. echo "Could not get wood, stopping"
  883. exit
  884. else
  885. sleep 1
  886. end
  887. }
  888. end
  889. #get axe
  890. check = dothistimeout "get my #{settings['fletch_axe']}", 3, /You remove|get what?/
  891. if check =~ /get what?/
  892. echo "Could not get your axe to cut the shafts"
  893. exit
  894. elsif check.nil?
  895. #backup for scripted containers
  896. endtime = Time.now + 5
  897. loop {
  898. if checkright =~ /#{settings['fletch_axe']}/
  899. break
  900. elsif Time.now > endtime
  901. echo "Could not get your axe to cut the shafts"
  902. exit
  903. else
  904. sleep 1
  905. end
  906. }
  907. end
  908. #cut shafts
  909. haste!
  910. fput "cut heavy bolt my wood"
  911. endtime = Time.now + 6
  912. loop {
  913. if checkright =~ /shaft/
  914. break
  915. elsif Time.now > endtime
  916. echo "Failed to cut shafts"
  917. exit
  918. else
  919. sleep 1
  920. echo "sleeping"
  921. end
  922. }
  923. sleep 1
  924. waitrt?
  925. stow("right",settings['fletch_sack'])
  926. #fput "put right in my #{settings['fletch_sack']}"
  927. endtime = Time.now + 6
  928. loop{
  929. if checkright.nil?
  930. break
  931. elsif Time.now > endtime
  932. "Stowing item failed"
  933. exit
  934. else
  935. sleep 0.5
  936. end
  937. }
  938. stow("left",settings['fletch_sack'])
  939. end
  940. def make_shafts(settings)
  941. #get wood
  942. check = dothistimeout "get my wood in my #{settings['fletch_sack']}", 1, /You remove|Get what?/
  943. if check =~ /Get what?/
  944. echo "Run out of shafts some how, this shouldn't be happening."
  945. exit
  946. elsif check.nil?
  947. #backup for scripted containers
  948. endtime = Time.now + 5
  949. loop {
  950. if checkright =~ /wood/
  951. break
  952. elsif Time.now > endtime
  953. echo "Could not get wood, stopping"
  954. exit
  955. else
  956. sleep 1
  957. end
  958. }
  959. end
  960. #get axe
  961. check = dothistimeout "get my #{settings['fletch_axe']}", 3, /You remove|get what?/
  962. if check =~ /get what?/
  963. echo "Could not get your axe to cut the shafts"
  964. exit
  965. elsif check.nil?
  966. #backup for scripted containers
  967. endtime = Time.now + 5
  968. loop {
  969. if checkright =~ /#{settings['fletch_axe']}/
  970. break
  971. elsif Time.now > endtime
  972. echo "Could not get your axe to cut the shafts"
  973. exit
  974. else
  975. sleep 1
  976. end
  977. }
  978. end
  979. #cut shafts
  980. haste!
  981. fput "cut arrow shaft my wood"
  982. endtime = Time.now + 6
  983. loop {
  984. if checkright =~ /shaft/
  985. break
  986. elsif Time.now > endtime
  987. echo "Failed to cut shafts"
  988. exit
  989. else
  990. sleep 1
  991. echo "sleeping"
  992. end
  993. }
  994. sleep 1
  995. waitrt?
  996. stow("right",settings['fletch_sack'])
  997. #fput "put right in my #{settings['fletch_sack']}"
  998. endtime = Time.now + 6
  999. loop{
  1000. if checkright.nil?
  1001. break
  1002. elsif Time.now > endtime
  1003. "Stowing item failed"
  1004. exit
  1005. else
  1006. sleep 0.5
  1007. end
  1008. }
  1009. stow("left",settings['fletch_sack'])
  1010. end
  1011. def make_dartshafts(settings)
  1012. #get wood
  1013. check = dothistimeout "get my wood in my #{settings['fletch_sack']}", 1, /You remove|Get what?/
  1014. if check =~ /Get what?/
  1015. echo "Run out of shafts some how, this shouldn't be happening."
  1016. exit
  1017. elsif check.nil?
  1018. #backup for scripted containers
  1019. endtime = Time.now + 5
  1020. loop {
  1021. if checkright =~ /wood/
  1022. break
  1023. elsif Time.now > endtime
  1024. echo "Could not get wood, stopping"
  1025. exit
  1026. else
  1027. sleep 1
  1028. end
  1029. }
  1030. end
  1031. #get axe
  1032. check = dothistimeout "get my #{settings['fletch_axe']}", 3, /You remove|get what?/
  1033. if check =~ /get what?/
  1034. echo "Could not get your axe to cut the shafts"
  1035. exit
  1036. elsif check.nil?
  1037. #backup for scripted containers
  1038. endtime = Time.now + 5
  1039. loop {
  1040. if checkright =~ /#{settings['fletch_axe']}/
  1041. break
  1042. elsif Time.now > endtime
  1043. echo "Could not get your axe to cut the shafts"
  1044. exit
  1045. else
  1046. sleep 1
  1047. end
  1048. }
  1049. end
  1050. #cut shafts
  1051. haste!
  1052. fput "cut dart shaft my wood"
  1053. endtime = Time.now + 6
  1054. loop {
  1055. if checkright =~ /shaft/
  1056. break
  1057. elsif Time.now > endtime
  1058. echo "Failed to cut shafts"
  1059. exit
  1060. else
  1061. sleep 1
  1062. echo "sleeping"
  1063. end
  1064. }
  1065. sleep 1
  1066. waitrt?
  1067. stow("right",settings['fletch_sack'])
  1068. #fput "put right in my #{settings['fletch_sack']}"
  1069. endtime = Time.now + 6
  1070. loop{
  1071. if checkright.nil?
  1072. break
  1073. elsif Time.now > endtime
  1074. "Stowing item failed"
  1075. exit
  1076. else
  1077. sleep 0.5
  1078. end
  1079. }
  1080. stow("left",settings['fletch_sack'])
  1081. end
  1082.  
  1083. def make_bolt(settings,paints)
  1084. check = dothistimeout "get 1 my shaft", 3, /You remove|get what?/
  1085. loop {
  1086. if checkright =~ /shaft/
  1087. break
  1088. elsif Time.now > endtime
  1089. echo "Could not get shaft, stopping"
  1090. exit
  1091. else
  1092. sleep 1
  1093. end
  1094. }
  1095. get_knife(settings)
  1096. fput "cut my shaft with my #{settings['fletch_knife']}"
  1097. sleep 1
  1098. waitrt?
  1099. stow("left",settings['fletch_sack'])
  1100. #painting goes here
  1101. if settings['fletch_paint'] != 0
  1102. stow("left",settings['fletch_sack'])
  1103. paint = paints[settings['fletch_paint']].split(" ")
  1104. fput "get my #{paint[0]} paint"
  1105. endtime = Time.now + 6
  1106. loop{
  1107. if checkleft =~ /paint/
  1108. break
  1109. elsif Time.now > (endtime - 3)
  1110. fput "get my #{paint[0]} paint"
  1111. elsif Time.now > endtime
  1112. echo "Run out of paint, probably means you have another colour paint on you messing with my check. Get it out your fletchsack"
  1113. exit
  1114. else
  1115. sleep 0.5
  1116. end
  1117. }
  1118. haste!
  1119. check = dothistimeout "paint my shaft", 3, /You carefully smear a bit of paint/
  1120. if check.nil?
  1121. #if the first check failed for some reason double check by looking at the arrow
  1122. check = dothistimeout "look my shaft", 3, /The arrow shaft has been pared down and smoothed.$|The arrow shaft has been pared down and smoothed. A coat of .+ paint covers the shaft./
  1123. if check !~ /The arrow shaft has been pared down and smoothed. A coat of .+ paint covers the shaft./
  1124. echo "Could not determine if painting was successful, stopping"
  1125. exit
  1126. end
  1127. end
  1128. check = matchtimeout 40, "The paint on your arrow shaft has dried."
  1129. if !check
  1130. echo "Did not see paint dry for some reason, carrying on in case it did but might cause problems if it didn't"
  1131. end
  1132. stow("left",settings['fletch_sack'])
  1133.  
  1134. end
  1135. #paintstick1
  1136. if settings['fletch_paintstick1'].length > 0
  1137. stow("left",settings['fletch_sack'])
  1138. fput "get my #{settings['fletch_paintstick1']}"
  1139. endtime = Time.now + 6
  1140. loop{
  1141. if checkleft =~ /paintstick/
  1142. break
  1143. elsif Time.now > (endtime - 3)
  1144. fput "get my #{settings['fletch_paintstick1']}"
  1145. elsif Time.now > endtime
  1146. echo "Could not get your paintstick"
  1147. exit
  1148. else
  1149. sleep 0.5
  1150. end
  1151. }
  1152. haste!
  1153. check = dothistimeout "paint my shaft", 3, /You carefully apply a band of/
  1154. if check.nil?
  1155. #if the first check failed for some reason double check by looking at the arrow
  1156. check = dothistimeout "look my shaft", 3, /It looks like someone has painted a single .+ band on the end/
  1157. if check !~ /It looks like someone has painted a single .+ band on the end/
  1158. echo "Could not determine if painting was succesful, stopping"
  1159. exit
  1160. end
  1161. end
  1162. check = matchtimeout 40, "The paint on your arrow shaft has dried."
  1163. if !check
  1164. echo "Did not see paint dry for some reason, carrying on in case it did but might cause problems if it didn't"
  1165. end
  1166. waitrt?
  1167. stow("left",settings['fletch_sack'])
  1168. end
  1169.  
  1170. #paintstick2
  1171. if settings['fletch_paintstick2'].length > 0
  1172. stow("left",settings['fletch_sack'])
  1173. fput "get my #{settings['fletch_paintstick2']}"
  1174. endtime = Time.now + 6
  1175. loop{
  1176. if checkleft =~ /paintstick/
  1177. break
  1178. elsif Time.now > (endtime - 3)
  1179. fput "get my #{settings['fletch_paintstick2']}"
  1180. elsif Time.now > endtime
  1181. echo "Could not get your paintstick"
  1182. exit
  1183. else
  1184. sleep 0.5
  1185. end
  1186. }
  1187. haste!
  1188. check = dothistimeout "paint my shaft", 3, /You carefully apply a band of/
  1189. if check.nil?
  1190. #if the first check failed for some reason double check by looking at the arrow
  1191. check = dothistimeout "look my shaft", 3, /It looks like someone has painted a pair of .+ and .+ bands on the end.|It looks like someone has painted a single .+ band on the end/
  1192. if check !~ /It looks like someone has painted a pair of .+ and .+ bands on the end.|It looks like someone has painted a single .+ band on the end/
  1193. echo "Could not determine if painting was succesful, stopping"
  1194. exit
  1195. end
  1196. end
  1197. check = matchtimeout 40, "The paint on your heavy bolt shaft has dried."
  1198. if !check
  1199. echo "Did not see paint dry for some reason, carrying on in case it did but might cause problems if it didn't"
  1200. end
  1201. waitrt?
  1202. stow("left",settings['fletch_sack'])
  1203. end
  1204.  
  1205. #measure shaft
  1206. waitrt?
  1207. check = dothistimeout "remove my #{settings['fletch_bow']}", 1, /You sling|remove what?/
  1208. if check =~ /remove what?/
  1209. echo "Failed to get your crossbow."
  1210. exit
  1211. elsif check.nil?
  1212. endtime = Time.now + 5
  1213. loop {
  1214. if checkleft =~ /crossbow/
  1215. break
  1216. elsif Time.now > endtime
  1217. echo "Failed to get your bow."
  1218. exit
  1219. else
  1220. sleep 1
  1221. end
  1222. }
  1223. end
  1224. haste!
  1225. check = dothistimeout "measure my shaft with my #{settings['fletch_bow']}", 3, /You place the shaft in your/
  1226. if check.nil?
  1227. echo "failed, do something about this later"
  1228. exit
  1229. end
  1230. sleep 1
  1231. waitrt?
  1232. check = dothistimeout "wear my #{settings['fletch_bow']}", 3, /You sling .+ over your shoulder./
  1233. if check.nil?
  1234. echo "failed, do something about this later"
  1235. exit
  1236. end
  1237.  
  1238. get_knife(settings)
  1239. haste!
  1240. fput "cut my shaft with my #{settings['fletch_knife']}"
  1241. sleep 1
  1242. waitrt?
  1243. if checkright !~ /shaft/
  1244. stow("left",settings['fletch_sack'])
  1245. return
  1246. end
  1247. stow("left",settings['fletch_sack'])
  1248.  
  1249. fput "get my glue"
  1250. endtime = Time.now + 6
  1251. loop{
  1252.  
  1253. if checkleft =~ /glue/
  1254. break
  1255. elsif Time.now > endtime
  1256. "Failed to get glue"
  1257. exit
  1258. else
  1259. sleep 0.1
  1260. end
  1261. }
  1262.  
  1263. haste!
  1264. check = dothistimeout "put my glue on my shaft", 3, /You carefully smear a bit of glue/
  1265. if check.nil?
  1266. echo "failed, do something about this later"
  1267. exit
  1268. end
  1269. sleep 1
  1270. waitrt?
  1271. stow("left",settings['fletch_sack'])
  1272.  
  1273. fput "get 3 my fletching in my #{settings['fletch_sack']}"
  1274. endtime = Time.now + 6
  1275. loop{
  1276. if checkleft =~ /fletching/
  1277. break
  1278. elsif Time.now > endtime
  1279. "Failed to get fletchings"
  1280. exit
  1281. else
  1282. sleep 0.1
  1283. end
  1284. }
  1285.  
  1286. haste!
  1287. check = dothistimeout "put my fletching on my shaft", 3, /You attach your|You attempt to attach some|Unfortunately, the glue is now too dry to remove them and try again, so you discard /
  1288. if check =~/You attatch your/
  1289. return
  1290. end
  1291. check = matchtimeout 60, "The glue on your heavy crossbow shaft has dried."
  1292. waitrt?
  1293. if checkright !~ /shaft/
  1294. stow("left",settings['fletch_sack'])
  1295. return
  1296. end
  1297. haste!
  1298. if settings['fletch_flip'] =~ true
  1299. fput "flip my shaft"
  1300. return
  1301. end
  1302. if settings['fletch_drilling'] =~ true
  1303. fput "get my #{settings['fletch_drill']} from my #{settings['fletch_sack']}"
  1304. fput "turn my #{settings['fletch_drill']}"
  1305. waitrt?
  1306. fput "put my #{settings['fletch_drill']} in my #{settings['fletch_sack']}"
  1307. fput "get my #{settings['fletch_arrowhead']} from my #{settings['fletch_sack']}"
  1308. fput "turn my #{settings['fletch_arrowhead']}"
  1309. return
  1310. else
  1311. get_knife(settings)
  1312. put "cut my shaft with my #{settings['fletch_knife']}"
  1313. put "cut my shaft with my #{settings['fletch_knife']}"
  1314. check = matchtimeout 6, "With a few quick cuts,", "Working a bit too hastily, you slice the end right off!"
  1315. if check == false
  1316. echo "didnt see you cut the shaft for some reason, stopping"
  1317. exit
  1318. end
  1319. end
  1320. waitrt?
  1321. stow("left",settings['fletch_sack'])
  1322. end
  1323. def make_dart(settings,paints)
  1324. check = dothistimeout "get 1 my shaft", 3, /You remove|get what?/
  1325. loop {
  1326. if checkright =~ /shaft/
  1327. break
  1328. elsif Time.now > endtime
  1329. echo "Could not get shaft, stopping"
  1330. exit
  1331. else
  1332. sleep 1
  1333. end
  1334. }
  1335. get_knife(settings)
  1336. check = dothistimeout "cut my shaft with my #{settings['fletch_knife']}",1,/You pare away the excess wood/
  1337. if checkright !~ /shaft/
  1338. stow("left",settings['fletch_sack'])
  1339. return
  1340. end
  1341. sleep 1
  1342. waitrt?
  1343. stow("left",settings['fletch_sack'])
  1344. #painting goes here
  1345. if settings['fletch_paint'] != 0
  1346. stow("left",settings['fletch_sack'])
  1347. paint = paints[settings['fletch_paint']].split(" ")
  1348. fput "get my #{paint[0]} paint"
  1349. endtime = Time.now + 6
  1350. loop{
  1351. if checkleft =~ /paint/
  1352. break
  1353. elsif Time.now > (endtime - 3)
  1354. fput "get my #{paint[0]} paint"
  1355. elsif Time.now > endtime
  1356. echo "Run out of paint, probably means you have another colour paint on you messing with my check. Get it out your fletchsack"
  1357. exit
  1358. else
  1359. sleep 0.5
  1360. end
  1361. }
  1362. haste!
  1363. check = dothistimeout "paint my shaft", 3, /You carefully smear a bit of paint/
  1364. if check.nil?
  1365. #if the first check failed for some reason double check by looking at the arrow
  1366. check = dothistimeout "look my shaft", 3, /The arrow shaft has been pared down and smoothed.$|The arrow shaft has been pared down and smoothed. A coat of .+ paint covers the shaft./
  1367. if check !~ /The arrow shaft has been pared down and smoothed. A coat of .+ paint covers the shaft./
  1368. echo "Could not determine if painting was successful, stopping"
  1369. exit
  1370. end
  1371. end
  1372. check = matchtimeout 40, "The paint on your arrow shaft has dried."
  1373. if !check
  1374. echo "Did not see paint dry for some reason, carrying on in case it did but might cause problems if it didn't"
  1375. end
  1376. stow("left",settings['fletch_sack'])
  1377.  
  1378. end
  1379. #paintstick1
  1380. if settings['fletch_paintstick1'].length > 0
  1381. stow("left",settings['fletch_sack'])
  1382. fput "get my #{settings['fletch_paintstick1']}"
  1383. endtime = Time.now + 6
  1384. loop{
  1385. if checkleft =~ /paintstick/
  1386. break
  1387. elsif Time.now > (endtime - 3)
  1388. fput "get my #{settings['fletch_paintstick1']}"
  1389. elsif Time.now > endtime
  1390. echo "Could not get your paintstick"
  1391. exit
  1392. else
  1393. sleep 0.5
  1394. end
  1395. }
  1396. haste!
  1397. check = dothistimeout "paint my shaft", 3, /You carefully apply a band of/
  1398. if check.nil?
  1399. #if the first check failed for some reason double check by looking at the arrow
  1400. check = dothistimeout "look my shaft", 3, /It looks like someone has painted a single .+ band on the end/
  1401. if check !~ /It looks like someone has painted a single .+ band on the end/
  1402. echo "Could not determine if painting was succesful, stopping"
  1403. exit
  1404. end
  1405. end
  1406. check = matchtimeout 40, "The paint on your dart shaft has dried."
  1407. if !check
  1408. echo "Did not see paint dry for some reason, carrying on in case it did but might cause problems if it didn't"
  1409. end
  1410. waitrt?
  1411. stow("left",settings['fletch_sack'])
  1412. end
  1413.  
  1414. #paintstick2
  1415. if settings['fletch_paintstick2'].length > 0
  1416. stow("left",settings['fletch_sack'])
  1417. fput "get my #{settings['fletch_paintstick2']}"
  1418. endtime = Time.now + 6
  1419. loop{
  1420. if checkleft =~ /paintstick/
  1421. break
  1422. elsif Time.now > (endtime - 3)
  1423. fput "get my #{settings['fletch_paintstick2']}"
  1424. elsif Time.now > endtime
  1425. echo "Could not get your paintstick"
  1426. exit
  1427. else
  1428. sleep 0.5
  1429. end
  1430. }
  1431. haste!
  1432. check = dothistimeout "paint my shaft", 3, /You carefully apply a band of/
  1433. if check.nil?
  1434. #if the first check failed for some reason double check by looking at the arrow
  1435. check = dothistimeout "look my shaft", 3, /It looks like someone has painted a pair of .+ and .+ bands on the end.|It looks like someone has painted a single .+ band on the end/
  1436. if check !~ /It looks like someone has painted a pair of .+ and .+ bands on the end.|It looks like someone has painted a single .+ band on the end/
  1437. echo "Could not determine if painting was succesful, stopping"
  1438. exit
  1439. end
  1440. end
  1441. check = matchtimeout 40, "The paint on your arrow shaft has dried."
  1442. if !check
  1443. echo "Did not see paint dry for some reason, carrying on in case it did but might cause problems if it didn't"
  1444. end
  1445. waitrt?
  1446. stow("left",settings['fletch_sack'])
  1447. end
  1448. #measure shaft
  1449. waitrt?
  1450. check = dothistimeout "get my #{settings['fletch_bow']}", 1, /You remove|get what?/
  1451. if check =~ /remove what?/
  1452. echo "Failed to get your dart."
  1453. exit
  1454. elsif check.nil?
  1455. endtime = Time.now + 5
  1456. loop {
  1457. if checkleft =~ /crossbow/
  1458. break
  1459. elsif Time.now > endtime
  1460. echo "Failed to get your bow."
  1461. exit
  1462. else
  1463. sleep 1
  1464. end
  1465. }
  1466. end
  1467. haste!
  1468. check = dothistimeout "measure my shaft with my #{settings['fletch_bow']}", 3, /You place the shaft next to the already complete/
  1469. if check.nil?
  1470. echo "failed, do something about this later"
  1471. exit
  1472. end
  1473. sleep 1
  1474. waitrt?
  1475. check = dothistimeout "put my #{settings['fletch_bow']} in my #{settings[fletch_sack]}", 3, /You put a/
  1476. if check.nil?
  1477. echo "failed, do something about this later"
  1478. exit
  1479. end
  1480.  
  1481. get_knife(settings)
  1482. haste!
  1483. fput "cut my shaft with my #{settings['fletch_knife']}"
  1484. sleep 1
  1485. waitrt?
  1486. if checkright !~ /shaft/
  1487. stow("left",settings['fletch_sack'])
  1488. return
  1489. end
  1490. stow("left",settings['fletch_sack'])
  1491.  
  1492. fput "get my glue"
  1493. endtime = Time.now + 6
  1494. loop{
  1495.  
  1496. if checkleft =~ /glue/
  1497. break
  1498. elsif Time.now > endtime
  1499. "Failed to get glue"
  1500. exit
  1501. else
  1502. sleep 0.1
  1503. end
  1504. }
  1505.  
  1506. haste!
  1507. check = dothistimeout "put my glue on my shaft", 3, /You carefully smear a bit of glue/
  1508. if check.nil?
  1509. echo "failed, do something about this later"
  1510. exit
  1511. end
  1512. sleep 1
  1513. waitrt?
  1514. stow("left",settings['fletch_sack'])
  1515.  
  1516. fput "get 3 my fletching in my #{settings['fletch_sack']}"
  1517. endtime = Time.now + 6
  1518. loop{
  1519. if checkleft =~ /fletching/
  1520. break
  1521. elsif Time.now > endtime
  1522. "Failed to get fletchings"
  1523. exit
  1524. else
  1525. sleep 0.1
  1526. end
  1527. }
  1528.  
  1529. haste!
  1530. check = dothistimeout "put my fletching on my shaft", 3, /You attach your|You attempt |Unfortunately, the glue is now too dry to remove them and try again, so you discard /
  1531. if check =~ /You attempt/
  1532. stow("left",settings['fletch_sack'])
  1533. return
  1534. end
  1535. check = matchtimeout 60, "The glue on your dart shaft has dried."
  1536. waitrt?
  1537. if checkright !~ /shaft/
  1538. stow("left",settings['fletch_sack'])
  1539. return
  1540. end
  1541. haste!
  1542. if settings['fletch_flip'] =~ true
  1543. fput "flip my shaft"
  1544. return
  1545. end
  1546. if settings['fletch_drilling'] =~ true
  1547. fput "get my #{settings['fletch_drill']} from my #{settings['fletch_sack']}"
  1548. fput "turn my #{settings['fletch_drill']}"
  1549. waitrt?
  1550. fput "put my #{settings['fletch_drill']} in my #{settings['fletch_sack']}"
  1551. fput "get my #{settings['fletch_arrowhead']} from my #{settings['fletch_sack']}"
  1552. fput "turn my #{settings['fletch_arrowhead']}"
  1553. return
  1554. else
  1555. get_knife(settings)
  1556. put "cut my shaft with my #{settings['fletch_knife']}"
  1557. put "cut my shaft with my #{settings['fletch_knife']}"
  1558. check = matchtimeout 6, "With a few quick cuts,", "Working a bit too hastily, you slice the end right off!"
  1559. if check == false
  1560. echo "didnt see you cut the shaft for some reason, stopping"
  1561. exit
  1562. end
  1563. end
  1564. waitrt?
  1565. stow("left",settings['fletch_sack'])
  1566. end
  1567.  
  1568. def make_arrow(settings,paints)
  1569. #get shaft
  1570. check = dothistimeout "get 1 my shaft", 3, /You remove|get what?/
  1571. if check =~ /get what?/
  1572. echo "Run out of shafts some how, this shouldn't be happening."
  1573. exit
  1574. elsif check.nil?
  1575. #backup for scripted containers
  1576. endtime = Time.now + 5
  1577. loop {
  1578. if checkright =~ /shaft/
  1579. break
  1580. elsif Time.now > endtime
  1581. echo "Could not get shaft, stopping"
  1582. exit
  1583. else
  1584. sleep 1
  1585. end
  1586. }
  1587. end
  1588. get_knife(settings)
  1589. #cut shaft
  1590. haste!
  1591. fput "cut my shaft with my #{settings['fletch_knife']}"
  1592. sleep 1
  1593. waitrt?
  1594.  
  1595. if checkright !~ /shaft/
  1596. stow("left",settings['fletch_sack'])
  1597. return
  1598. end
  1599.  
  1600. #painting goes here
  1601. if settings['fletch_paint'] != 0
  1602. stow("left",settings['fletch_sack'])
  1603. paint = paints[settings['fletch_paint']].split(" ")
  1604. fput "get my #{paint[0]} paint"
  1605. endtime = Time.now + 6
  1606. loop{
  1607. if checkleft =~ /paint/
  1608. break
  1609. elsif Time.now > (endtime - 3)
  1610. fput "get my #{paint[0]} paint"
  1611. elsif Time.now > endtime
  1612. echo "Run out of paint, probably means you have another colour paint on you messing with my check. Get it out your fletchsack"
  1613. exit
  1614. else
  1615. sleep 0.5
  1616. end
  1617. }
  1618. haste!
  1619. check = dothistimeout "paint my shaft", 3, /You carefully smear a bit of paint/
  1620. if check.nil?
  1621. #if the first check failed for some reason double check by looking at the arrow
  1622. check = dothistimeout "look my shaft", 3, /The arrow shaft has been pared down and smoothed.$|The arrow shaft has been pared down and smoothed. A coat of .+ paint covers the shaft./
  1623. if check !~ /The arrow shaft has been pared down and smoothed. A coat of .+ paint covers the shaft./
  1624. echo "Could not determine if painting was successful, stopping"
  1625. exit
  1626. end
  1627. end
  1628. check = matchtimeout 40, "The paint on your arrow shaft has dried."
  1629. if !check
  1630. echo "Did not see paint dry for some reason, carrying on in case it did but might cause problems if it didn't"
  1631. end
  1632. stow("left",settings['fletch_sack'])
  1633.  
  1634. end
  1635. #paintstick1
  1636. if settings['fletch_paintstick1'].length > 0
  1637. stow("left",settings['fletch_sack'])
  1638. fput "get my #{settings['fletch_paintstick1']}"
  1639. endtime = Time.now + 6
  1640. loop{
  1641. if checkleft =~ /paintstick/
  1642. break
  1643. elsif Time.now > (endtime - 3)
  1644. fput "get my #{settings['fletch_paintstick1']}"
  1645. elsif Time.now > endtime
  1646. echo "Could not get your paintstick"
  1647. exit
  1648. else
  1649. sleep 0.5
  1650. end
  1651. }
  1652. haste!
  1653. check = dothistimeout "paint my shaft", 3, /You carefully apply a band of/
  1654. if check.nil?
  1655. #if the first check failed for some reason double check by looking at the arrow
  1656. check = dothistimeout "look my shaft", 3, /It looks like someone has painted a single .+ band on the end/
  1657. if check !~ /It looks like someone has painted a single .+ band on the end/
  1658. echo "Could not determine if painting was succesful, stopping"
  1659. exit
  1660. end
  1661. end
  1662. check = matchtimeout 40, "The paint on your arrow shaft has dried."
  1663. if !check
  1664. echo "Did not see paint dry for some reason, carrying on in case it did but might cause problems if it didn't"
  1665. end
  1666. waitrt?
  1667. stow("left",settings['fletch_sack'])
  1668. end
  1669.  
  1670. #paintstick2
  1671. if settings['fletch_paintstick2'].length > 0
  1672. stow("left",settings['fletch_sack'])
  1673. fput "get my #{settings['fletch_paintstick2']}"
  1674. endtime = Time.now + 6
  1675. loop{
  1676. if checkleft =~ /paintstick/
  1677. break
  1678. elsif Time.now > (endtime - 3)
  1679. fput "get my #{settings['fletch_paintstick2']}"
  1680. elsif Time.now > endtime
  1681. echo "Could not get your paintstick"
  1682. exit
  1683. else
  1684. sleep 0.5
  1685. end
  1686. }
  1687. haste!
  1688. check = dothistimeout "paint my shaft", 3, /You carefully apply a band of/
  1689. if check.nil?
  1690. #if the first check failed for some reason double check by looking at the arrow
  1691. check = dothistimeout "look my shaft", 3, /It looks like someone has painted a pair of .+ and .+ bands on the end.|It looks like someone has painted a single .+ band on the end/
  1692. if check !~ /It looks like someone has painted a pair of .+ and .+ bands on the end.|It looks like someone has painted a single .+ band on the end/
  1693. echo "Could not determine if painting was succesful, stopping"
  1694. exit
  1695. end
  1696. end
  1697. check = matchtimeout 40, "The paint on your arrow shaft has dried."
  1698. if !check
  1699. echo "Did not see paint dry for some reason, carrying on in case it did but might cause problems if it didn't"
  1700. end
  1701. waitrt?
  1702. stow("left",settings['fletch_sack'])
  1703. end
  1704.  
  1705.  
  1706. #cut nocks in shaft
  1707. get_knife(settings) if settings['fletch_paint'] != 0 or settings['fletch_paintstick1'].length != 0 or settings['fletch_paintstick2'].length != 0
  1708. haste!
  1709. fput "cut nock in my shaft with my #{settings['fletch_knife']}"
  1710. fput "cut nock in my shaft with my #{settings['fletch_knife']}" if settings['fletch_paint'] == 0 and settings['fletch_paintstick1'].length == 0 and settings['fletch_paintstick2'].length == 0#only need to cut twice if you didnt paint
  1711. sleep 2
  1712. waitrt?
  1713. if checkright !~ /shaft/
  1714. stow("left",settings['fletch_sack'])
  1715. return
  1716. end
  1717. #stow knife
  1718. stow("left",settings['fletch_sack'])
  1719.  
  1720. #measure shaft
  1721. waitrt?
  1722. check = dothistimeout "remove my #{settings['fletch_bow']}", 1, /You sling|remove what?/
  1723. if check =~ /remove what?/
  1724. echo "Failed to get your knife."
  1725. exit
  1726. elsif check.nil?
  1727. endtime = Time.now + 5
  1728. loop {
  1729. if checkleft =~ /bow/
  1730. break
  1731. elsif Time.now > endtime
  1732. echo "Failed to get your bow."
  1733. exit
  1734. else
  1735. sleep 1
  1736. end
  1737. }
  1738. end
  1739. haste!
  1740. check = dothistimeout "measure my shaft with my #{settings['fletch_bow']}", 3, /When the bow string reaches optimal tension, you carefully un-nock the shaft and ease the string forward while grasping the shaft with your left hand to mark the length until you can make a tiny cut on the shaft./
  1741. if check.nil?
  1742. echo "failed, do something about this later"
  1743. exit
  1744. end
  1745. sleep 1
  1746. waitrt?
  1747. check = dothistimeout "wear my #{settings['fletch_bow']}", 3, /You sling .+ over your shoulder./
  1748. if check.nil?
  1749. echo "failed, do something about this later"
  1750. exit
  1751. end
  1752. get_knife(settings)
  1753. haste!
  1754. check = dothistimeout "cut my shaft with my #{settings['fletch_knife']}", 3, /Using your previous mark as a guide, you cleanly slice the end off the arrow shaft./
  1755. if check.nil?
  1756. echo "failed, do something about this later"
  1757. exit
  1758. end
  1759. sleep 1
  1760. waitrt?
  1761. if checkright !~ /shaft/
  1762. stow("left",settings['fletch_sack'])
  1763. return
  1764. end
  1765. stow("left",settings['fletch_sack'])
  1766.  
  1767. fput "get my glue"
  1768. endtime = Time.now + 6
  1769. loop{
  1770.  
  1771. if checkleft =~ /glue/
  1772. break
  1773. elsif Time.now > endtime
  1774. "Failed to get glue"
  1775. exit
  1776. else
  1777. sleep 0.1
  1778. end
  1779. }
  1780.  
  1781. haste!
  1782. check = dothistimeout "put my glue on my shaft", 3, /You carefully smear a bit of glue/
  1783. if check.nil?
  1784. echo "failed, do something about this later"
  1785. exit
  1786. end
  1787. sleep 1
  1788. waitrt?
  1789. stow("left",settings['fletch_sack'])
  1790.  
  1791. fput "get 3 my fletching in my #{settings['fletch_sack']}"
  1792. endtime = Time.now + 6
  1793. loop{
  1794. if checkleft =~ /fletching/
  1795. break
  1796. elsif Time.now > endtime
  1797. "Failed to get fletchings"
  1798. exit
  1799. else
  1800. sleep 0.1
  1801. end
  1802. }
  1803.  
  1804. haste!
  1805. check = dothistimeout "put my fletching on my shaft", 3, /You attach your|You attempt to attach some|Unfortunately, the glue is now too dry to remove them and try again, so you discard /
  1806. if check =~/You attatch your/
  1807. return
  1808. elsif check =~/You attempt to attach some/
  1809. waitrt?
  1810. refletch_shaft(settings)
  1811. end
  1812. check = matchtimeout 60, "The glue on your arrow shaft has dried."
  1813. if check == false
  1814. refletch_shaft(settings)
  1815. end
  1816. waitrt?
  1817. if checkright !~ /shaft/
  1818. stow("left",settings['fletch_sack'])
  1819. return
  1820. end
  1821. haste!
  1822. if settings['fletch_flip'] =~ true
  1823. fput "flip my shaft"
  1824. return
  1825. end
  1826. if settings['fletch_drilling'] =~ true
  1827. fput "get my #{settings['fletch_drill']} from my #{settings['fletch_sack']}"
  1828. fput "turn my #{settings['fletch_drill']}"
  1829. waitrt?
  1830. fput "put my #{settings['fletch_drill']} in my #{settings['fletch_sack']}"
  1831. fput "get my #{settings['fletch_arrowhead']} from my #{settings['fletch_sack']}"
  1832. fput "turn my #{settings['fletch_arrowhead']}"
  1833. return
  1834. else
  1835. get_knife(settings)
  1836. put "cut my shaft with my #{settings['fletch_knife']}"
  1837. put "cut my shaft with my #{settings['fletch_knife']}"
  1838. check = matchtimeout 6, "With a few quick cuts,", "Working a bit too hastily, you slice the end right off!"
  1839. if check == false
  1840. echo "didnt see you cut the shaft for some reason, stopping"
  1841. exit
  1842. end
  1843. end
  1844.  
  1845. waitrt?
  1846. stow("left",settings['fletch_sack'])
  1847.  
  1848.  
  1849. end
  1850.  
  1851. def refletch_shaft(settings)
  1852. fput "get my glue"
  1853. endtime = Time.now + 6
  1854. loop{
  1855.  
  1856. if checkleft =~ /glue/
  1857. break
  1858. elsif Time.now > endtime
  1859. "Failed to get glue"
  1860. exit
  1861. else
  1862. sleep 0.1
  1863. end
  1864. }
  1865.  
  1866. haste!
  1867. check = dothistimeout "put my glue on my shaft", 3, /You carefully smear a bit of glue/
  1868. if check.nil?
  1869. echo "failed, do something about this later"
  1870. exit
  1871. end
  1872. sleep 1
  1873. waitrt?
  1874. stow("left",settings['fletch_sack'])
  1875. fput "get 3 my fletching in my #{settings['fletch_sack']}"
  1876. endtime = Time.now + 6
  1877. loop{
  1878. if checkleft =~ /fletching/
  1879. break
  1880. elsif Time.now > endtime
  1881. "Failed to get fletchings"
  1882. exit
  1883. else
  1884. sleep 0.1
  1885. end
  1886. }
  1887.  
  1888. haste!
  1889. check = dothistimeout "put my fletching on my shaft", 3, /You attach your|You attempt to attach some|Unfortunately, the glue is now too dry to remove them and try again, so you discard /
  1890. if check =~/You attatch your/
  1891. return
  1892. elsif check =~/You attempt to attatch some/
  1893. waitrt?
  1894. refletch_shaft(settings)
  1895. end
  1896. check = matchtimeout 60, "The glue on your arrow shaft has dried."
  1897. if check == false
  1898. refletch_shaft(settings)
  1899. return
  1900. end
  1901. waitrt?
  1902. if checkright !~ /shaft/
  1903. stow("left",settings['fletch_sack'])
  1904. return
  1905. end
  1906. haste!
  1907. if settings['fletch_flip'] =~ true
  1908. fput "flip my shaft"
  1909. return
  1910. end
  1911. if settings['fletch_drilling'] =~ true
  1912. fput "get my #{settings['fletch_drill']} from my #{settings['fletch_sack']}"
  1913. fput "turn my #{settings['fletch_drill']}"
  1914. waitrt?
  1915. fput "put my #{settings['fletch_drill']} in my #{settings['fletch_sack']}"
  1916. fput "get my #{settings['fletch_arrowhead']} from my #{settings['fletch_sack']}"
  1917. fput "turn my #{settings['fletch_arrowhead']}"
  1918. return
  1919. else
  1920. get_knife(settings)
  1921. put "cut my shaft with my #{settings['fletch_knife']}"
  1922. put "cut my shaft with my #{settings['fletch_knife']}"
  1923. check = matchtimeout 6, "With a few quick cuts,", "Working a bit too hastily, you slice the end right off!"
  1924. if check == false
  1925. echo "didnt see you cut the shaft for some reason, stopping"
  1926. exit
  1927. end
  1928. end
  1929.  
  1930. waitrt?
  1931. stow("left",settings['fletch_sack'])
  1932. end
  1933.  
  1934. def checkrest
  1935. until(percentmind < @XP_TO_STOP)
  1936. pause 30
  1937. fput "exp"
  1938. end
  1939. end
  1940.  
  1941. container_contents = nil
  1942. needed_items = nil
  1943. start_time = Time.now
  1944. arrows_made = 0
  1945. arrows_failed = 0
  1946. spent_silver = 0
  1947. finished = false
  1948.  
  1949. if variable[0] =~ /setup|config|configure/i
  1950. setup.call
  1951. exit
  1952. elsif variable[0] =~ /bundle/i
  1953. bundle(settings)
  1954. exit
  1955. elsif !variable[0].nil?
  1956. message = ""
  1957. message += "This script needs a map room if you want it to buy items for you. If this is the case when ever you run out of an item the script will run and buy more\r\n"
  1958. message += "Run ;fletching setup at any times to change you settings\r\n"
  1959. message += "Anytime the script is running ;fletching will give you a progress report. ;fletching stop will tell the script to end after finishing the arrow it is curently on. This is the prefered method of stopping, partially cut shafts left in a container migt cause the script to fail\r\n"
  1960.  
  1961. if !$fake_stormfront
  1962. puts "<output class=\"mono\"/>#{monsterbold_start}#{message}#{monsterbold_end}\r\n<output class=\"\"/>"
  1963. else
  1964. puts "#{monsterbold_start}#{message}#{monsterbold_end}"
  1965. end
  1966. exit
  1967. end
  1968.  
  1969.  
  1970. fletching_report = proc { |client_string|
  1971. if client_string =~ /^(?:<c>)?#{$clean_lich_char}(?:fletching)$/i
  1972.  
  1973. respond ""
  1974. respond "Script has been running for #{Time.at(Time.now - start_time).strftime("%H hours, %M minutes %S seconds")}, made #{arrows_made} arrows, ruined #{arrows_failed} arrows and spent #{spent_silver} silver"
  1975. respond ""
  1976. elsif client_string =~ /^(?:<c>)?#{$clean_lich_char}fletching (?:stop|done|end|finish|finished)$/i
  1977. finished = true
  1978. respond ""
  1979. respond "Once current arrow is complete script will end"
  1980. respond ""
  1981. else
  1982. client_string
  1983. end
  1984. }
  1985.  
  1986. UpstreamHook.add('fletching_hook', fletching_report)
  1987. before_dying{;UpstreamHook.remove('fletching_hook');}
  1988.  
  1989. warning = ""
  1990. if settings['fletch_sack'] == "" or settings['fletch_sack'].nil?
  1991. warning += "The container for you supplies has not yet been set, the script will not run until this is added.\r\n"
  1992. end
  1993. if settings['fletch_quiver'] == "" or settings['fletch_quiver'].nil?
  1994. warning += "The container for you finished arrows has not yet been set, the script will not run until this is added.\r\n"
  1995. end
  1996. if settings['fletch_knife'] == ""
  1997. warning += "Have not set a knife/dagger to cut the shafts with, the script will not run until this is added.\r\n"
  1998. end
  1999. if settings['fletch_bow'] == ""
  2000. warning += "Have not set a bow to measure the shafts with, the script will not run until this is added.\r\n"
  2001. end
  2002. if settings['fletch_axe'] == ""
  2003. warning += "Have not set an axe to make shafts with, the script will not run until this is added.\r\n"
  2004. end
  2005. if settings['fletch_wood'] == ""
  2006. warning += "Have not set a what wood you want to use, the script will not run until this is added.\r\n"
  2007. end
  2008. if settings['fletch_wood'] != "" and settings['fletch_wood'] !~ /wood/
  2009. warning += "You have set what wood you want to use but appears you may have done so incorrectly. It should read along the lines of 'limb of wood' or 'branch of faewood' for example. Leave off any a/an/some from the start\r\n"
  2010. end
  2011. if settings['fletch_fletchings'] != "" and settings['fletch_fletchings'] !~ /fletching/
  2012. warning += "You have set what fletchings you want to use but appears you may have done so incorrectly. It should read along the lines of 'bundle of fletchings' for example. Leave off any a/an/some from the start.\r\n"
  2013. end
  2014.  
  2015. if warning.length > 0
  2016. if !$fake_stormfront
  2017. puts "<output class=\"mono\"/>#{monsterbold_start}#{warning}#{monsterbold_end}\r\n<output class=\"\"/>"
  2018. else
  2019. puts "#{monsterbold_start}#{warning}#{monsterbold_end}"
  2020. end
  2021. setup.call
  2022. exit
  2023. end
  2024. monitor_interaction()
  2025. empty_left_hand
  2026. empty_right_hand
  2027. loop{
  2028. if settings['waggle']
  2029. start_script "waggle"
  2030. wait_while {running?("waggle")}
  2031. end
  2032. fletch_sack_contents = get_container_contents(settings['fletch_sack'])
  2033. needed_items = check_needed_items(settings,fletch_sack_contents,paints)
  2034. if !needed_items.empty?
  2035. if !settings['fletch_enable_buying']
  2036. echo "Run out of #{needed_items[0]} and the script is not set to buy more, ';fletching setup' to change this."
  2037. exit
  2038. end
  2039. respond ""
  2040. needed_items.each{|item|
  2041. respond "Out of #{item}"
  2042. }
  2043. respond "Off to buy"
  2044. respond ""
  2045. sleep 1
  2046. spent_silver += buy_items(settings, needed_items)
  2047. needed_items = Array.new
  2048. end
  2049. fletch_sack_contents = get_container_contents(settings['fletch_sack'])
  2050. #echo fletch_sack_contents
  2051. #exit
  2052. if settings['fletch_bow'] =~ /^crossbow/
  2053. make_heavyshafts(settings) if fletch_sack_contents.to_s.include? '@noun="wood"'
  2054. elsif settings['fletch_bow'] =~ /^dart/
  2055. make_dartshafts(settings) if fletch_sack_contents.to_s.include? '@noun="wood"'
  2056. else
  2057. make_shafts(settings) if fletch_sack_contents.to_s.include? '@noun="wood"'
  2058. end
  2059. checkrest
  2060. if settings['fletch_bow'] =~ /^crossbow/
  2061. make_bolt(settings,paints)
  2062. elsif settings['fletch_bow'] =~ /^dart/
  2063. make_dart(settings,paints)
  2064. elsif
  2065. make_arrow(settings,paints)
  2066. end
  2067. if checkright =~ /^bolt/
  2068. echo "stowing"
  2069. stow("right",settings['fletch_quiver'])
  2070. arrows_made += 1
  2071. elsif checkright =~ /^dart/
  2072. echo "stowing"
  2073. stow("right",settings['fletch_quiver'])
  2074. arrows_made += 1
  2075. elsif checkright =~ /^arrow/
  2076. echo "stowing"
  2077. stow("right",settings['fletch_quiver'])
  2078. arrows_made += 1
  2079. else
  2080. arrows_failed += 1
  2081. end
  2082.  
  2083. respond ""
  2084. respond "Script has been running for #{Time.at(Time.now - start_time).strftime("%H hours, %M minutes %S seconds")}, made #{arrows_made} arrows, ruined #{arrows_failed} arrows and spent #{spent_silver} silver"
  2085. respond ""
  2086. exit if finished
  2087. exit if settings['fletch_limit'].to_i > 0 and arrows_made == settings['fletch_limit'].to_i
  2088. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement