Advertisement
Whiteaxe

fletch4

Dec 15th, 2015
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 53.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 item.name =~ /#{paints[settings['fletch_paint']]}/
  476. need_paint = false
  477. elsif item.name =~ /#{settings['fletch_fletchings']}/
  478. need_fletchings = false
  479. elsif item.name =~ /bottle of fletching glue/
  480. need_glue = false
  481. elsif item.name =~ /#{settings['fletch_paintstick1']}/ and settings['fletch_paintstick1'].length > 0
  482. need_paintstick1 = false
  483. elsif item.name =~ /#{settings['fletch_paintstick2']}/ and settings['fletch_paintstick2'].length > 0
  484. need_paintstick2 = false
  485. end
  486. }
  487.  
  488. needed_items = Array.new
  489.  
  490. if need_wood
  491. needed_items << settings['fletch_wood']
  492. end
  493. if need_glue
  494. needed_items << "bottle of fletching glue"
  495. end
  496. if need_fletchings
  497. needed_items << settings['fletch_fletchings']
  498. end
  499. if need_paint and settings['fletch_paint'] != 0
  500. needed_items << "vial of paint"
  501. end
  502. if need_paintstick1 and settings['fletch_paintstick1'].length > 0
  503. needed_items << settings['fletch_paintstick1']
  504. end
  505. if need_paintstick2 and settings['fletch_paintstick2'].length > 0
  506. needed_items << settings['fletch_paintstick2']
  507. end
  508.  
  509.  
  510.  
  511. return needed_items
  512. end
  513.  
  514. def find_order_num(supply)
  515.  
  516. status_tags
  517. clear
  518. fput 'unhide' if hidden? or invisible?
  519. fput 'order'
  520. menu = Hash.new
  521. while (line = get) and (line !~ /ORDER|BUY/)
  522. for item in line.scan(/<d.*?cmd=["']order ([0-9]+).*?>(.*?)<\/d>/)
  523. menu[item[1].sub(/^a /, '')] = item[0]
  524. end
  525. end
  526. clear
  527. status_tags
  528.  
  529. #menu = read_menu.call
  530. #echo menu.inspect
  531.  
  532. item_name = menu.keys.find { |name| name =~ /#{supply}/i }
  533. unless order_number = menu[item_name]
  534. echo ""
  535. echo "Error: failed to find the item! Remember to leave off the a/an/some at the start. eg. 'limb of faewood"
  536. echo ""
  537. end
  538. return order_number
  539.  
  540. end
  541.  
  542.  
  543.  
  544. def buy_items(settings, needed_items)
  545. if invisible?
  546. invis = true
  547. else
  548. invis = false
  549. end
  550. start_room = Room.current.id
  551. silver = checksilver
  552. if silver < 5000
  553. silver = 5000 - silver
  554. start_script "go2",['bank']
  555. wait_while {running?("go2")}
  556. fput "unhide" if hidden? or invisible?
  557. fput "withdraw #{silver}"
  558. if checksilver < 5000
  559. echo "Failed to get money from the bank"
  560. exit
  561. end
  562. end
  563. start_script "go2",['fletcher']
  564. wait_while {running?("go2")}
  565. move "south" if Room.current.location == "Ta'Vaalor"
  566.  
  567. if checkleft != nil
  568. empty_left_hand
  569. end
  570. if checkright != nil
  571. empty_right_hand
  572. end
  573. needed_items.each {|item|
  574.  
  575. if item =~ /vial of paint/
  576. order_number = find_order_num(item)
  577. multifput "order #{order_number} color #{settings['fletch_paint']}", "buy"
  578. else
  579. order_number = find_order_num(item)
  580. multifput "order #{order_number}", "buy"
  581. end
  582.  
  583. #wait up to three seconds to see if purchase was succesful
  584. endtime = Time.now + 3
  585. loop {
  586. if checkright.nil?
  587. sleep 1
  588. elsif Time.now > endtime
  589. echo "For some reason buying an item failed"
  590. exit
  591. elsif checkright
  592. echo "got item"
  593. break
  594. end
  595. }
  596. stow_check = dothistimeout "put my #{checkright} in my #{settings['fletch_sack']}", 3, /won't fit|You put a/
  597. if stow_check =~ /won't fit/
  598. echo "fletchsack full, stopping"
  599. exit
  600. elsif stow_check.nil?
  601. echo "stowcheck failed, stopping"
  602. exit
  603. end
  604.  
  605. }
  606. spent_silver += (5000 - checksilver)
  607.  
  608. start_script "go2",['bank']
  609. wait_while {running?("go2")}
  610. fput "unhide" if hidden? or invisible?
  611. fput "depo all"
  612. if invis and Spell[916].affordable?
  613. fput "incant 916"
  614. end
  615. start_script "go2",[start_room]
  616. wait_while {running?("go2")}
  617. return spent_silver
  618. end
  619.  
  620. def stow(hand,container)
  621. if (hand == "left")
  622. return if checkleft.nil?
  623. elsif (hand == "right")
  624. return if checkright.nil?
  625. else
  626. respond "This should not of happened"
  627. respond "Invalid hand of: #{hand}"
  628. exit
  629. end
  630. fput "put #{hand} in my #{container}"
  631. again = false
  632. endtime = Time.now + 6
  633. loop{
  634. if (checkleft.nil? && hand == "left")
  635. break
  636. elsif (checkright.nil? && hand == "right")
  637. break
  638. elsif Time.now > endtime -3 and !again
  639. again = true
  640. fput "put #{hand} in my #{container}"
  641. elsif Time.now > endtime
  642. "Stowing item failed"
  643. else
  644. sleep 0.1
  645. end
  646. }
  647. end
  648.  
  649. def get_knife(settings)
  650. check = dothistimeout "get my #{settings['fletch_knife']}", 3, /You remove|get what?/
  651. if check =~ /get what?/
  652. echo "Failed to get your knife."
  653. exit
  654. elsif check.nil?
  655. endtime = Time.now + 5
  656. loop {
  657. if checkleft =~ /#{settings['fletch_knife']}/
  658. break
  659. elsif Time.now > endtime
  660. echo "Failed to get your knife."
  661. exit
  662. else
  663. sleep 1
  664. end
  665. }
  666. end
  667. end
  668.  
  669. def haste!()
  670. waitcastrt?
  671. fput "incant 506" if Spell[506].known? and !Spell[506].active? and Spell[506].affordable?
  672. end
  673.  
  674. def bundle(settings)
  675. #gameobj does not get full descriptions so have to go about it ma self
  676. quiver_contents_string = nil
  677. quiver_contents = proc{|server_string|
  678. if server_string =~ /<inv id='\w+'>In the <a exist="\d+" noun="\w+">\w+<\/a>:<\/inv><inv id='\w+'>/
  679. quiver_contents_string = server_string
  680. nil
  681. else
  682.  
  683. server_string
  684. end
  685. }
  686. DownstreamHook.add('fletch_check_quiver', quiver_contents)
  687. silence_me
  688. fput "look in my #{settings['fletch_quiver']}"
  689. silence_me
  690. endtime = Time.now + 3
  691. loop {
  692. if quiver_contents_string != nil
  693. DownstreamHook.remove('fletch_check_quiver')
  694. break
  695. elsif Time.now > endtime
  696. echo "failed to get the contents of #{settings['fletch_quiver']}"
  697. DownstreamHook.remove('fletch_check_quiver')
  698. exit
  699. else
  700. sleep 0.1
  701. end
  702. }
  703.  
  704. 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>/
  705. quiver_contents = $3.to_s.gsub( /["]/ , '\'' )
  706. quiver_contents = quiver_contents.split(/<\/inv><inv id='\w+'>\s?/)
  707.  
  708. else
  709. echo "contents malformed"
  710. end
  711. contents = Hash.new
  712. quiver_contents.each{|item|
  713. if item =~ /(.+)<a exist='(\d+)' noun='([\w\-]+)'>([\w\s\-']+)<\/a>([\s\w'\-]+)?/
  714. item_id = $2
  715. item_noun = $3
  716. item_full_name = ""
  717. item_full_name = item_full_name.strip + "#{$1.strip}"
  718. item_full_name = item_full_name.strip + " #{$4.strip} "
  719. item_full_name = item_full_name.strip + " #{$5.strip}"
  720. item_full_name.strip!
  721. end
  722. contents[item_id] = item_full_name
  723. }
  724. #finds the description of each different type of arrow
  725. arrow_types = Array.new
  726. contents.each_pair{|id,name|
  727. if name =~ /arrow$/ and !arrow_types.include? name
  728. arrow_types << name
  729. end
  730. }
  731. arrow_types.each{|desc|
  732. contents.each_pair{|id,name|
  733. if desc =~ /#{name}/
  734. if checkright.nil?
  735. fput "get ##{id} in my #{settings['fletch_quiver']}"
  736. endtime = Time.now + 6
  737. wait_until{!checkright.nil? || Time.now > endtime}
  738. else
  739. fput "get ##{id} in my #{settings['fletch_quiver']}"
  740. end
  741. if !checkleft.nil? and !checkright.nil?
  742. check = dothistimeout "bundle", 3, /You bundle your arrows together.|You add a .+ arrow to your bundle.|You may not combine more than 100 shafts./
  743. if check.nil?
  744. echo "bundling failed for some reason, stopping"
  745. exit
  746. elsif check =~ /You may not combine more than 100 shafts./
  747. #fput "stow r"
  748. stow("right",settings['fletch_quiver'])
  749. end
  750. endtime = Time.now + 6
  751. wait_until{checkleft.nil? || Time.now > endtime}
  752. end
  753. end
  754. }
  755. #fput "stow right"
  756. stow("right",settings['fletch_quiver'])
  757. }
  758. #now arrows are bundled see about condensing the bundles down
  759. bundle_ids = Array.new
  760. quiver_contents = get_container_contents(settings['fletch_quiver'])
  761. quiver_contents.each{|item|
  762. if item.name =~ /bundle of arrows/
  763. bundle_ids << item.id
  764. end
  765. }
  766.  
  767. bundle_amount = Array.new
  768. bundle_desc = Array.new
  769. bundle_check = proc{|server_string|
  770. #
  771. #Individual projectiles from this bundle will have a long of "a wooden arrow"
  772. #
  773. if server_string.nil?
  774. #nil
  775. 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+./
  776. bundle_amount << $1
  777. nil
  778. elsif server_string =~ /Individual projectiles from this bundle will have a long of "([\w\s]+)"/
  779. bundle_desc << $1
  780. nil
  781. elsif server_string =~ /Each individual projectile will be "[\w\s]+"./
  782. nil
  783. elsif server_string =~ /<prompt time="\d+">&gt;<\/prompt>/
  784. nil
  785. else
  786. if server_string.length > 2
  787. server_string
  788. else
  789. nil
  790. end
  791. end
  792. }
  793. DownstreamHook.add('fletch_budle_check', bundle_check)
  794. silence_me
  795. bundle_ids.each{|id|
  796. fput "look ##{id}"
  797. }
  798. silence_me
  799. endtime = Time.now + 6
  800. wait_until{bundle_ids.length == bundle_desc.length || Time.now > endtime}
  801. DownstreamHook.remove('fletch_budle_check')
  802. if bundle_ids.length != bundle_desc.length
  803. echo "failed to get bundles info, stopping"
  804. exit
  805. end
  806. x = 0
  807. bundles = Array.new
  808. until x == bundle_ids.length
  809. bundles << bundle = {
  810. "id" => bundle_ids[x],
  811. "count" => bundle_amount[x],
  812. "desc" => bundle_desc[x]
  813. }
  814. x +=1
  815. end
  816. uniq_bundle_desc = bundle_desc & bundle_desc
  817. last_bundle = ""
  818. uniq_bundle_desc.each{|desc|
  819. total = 0
  820. bundles.each{|bundle|
  821. if bundle['desc'] == desc and total == 0 and bundle['count'].to_i!=100
  822. #there is a match but if there might only be one of that bundle so take note but do nothing
  823. total += bundle['count'].to_i
  824. last_bundle = bundle['id'].dup
  825. elsif bundle['desc'] == desc and total > 0 and bundle['count'].to_i!=100
  826. #match and the total is already above 0, must of already found a bundle of the same arrows
  827. total += bundle['count'].to_i
  828. if total < 100
  829. fput "get ##{bundle['id']}"
  830. matchtimeout 1, "You remove"
  831. fput "get ##{last_bundle}" if checkleft.nil?
  832. fput "bundle"
  833. last_bundle = bundle['id']
  834. else
  835.  
  836. if total == 100
  837. fput "get ##{bundle['id']}"
  838. matchtimeout 1, "You remove"
  839. fput "get ##{last_bundle}" if checkleft.nil?
  840. fput "bundle"
  841. #fput "stow r"
  842. stow("right",settings['fletch_quiver'])
  843. total = 0
  844. else
  845. amount_over = total - 100
  846. amount_to_get = bundle['count'].to_i - amount_over
  847. fput "get #{amount_to_get} ##{bundle['id']}"
  848. matchtimeout 1, "You remove"
  849. fput "get ##{last_bundle}" if checkleft.nil?
  850. fput "bundle"
  851. #fput "stow r"
  852. stow("right",settings['fletch_quiver'])
  853. bundle['amount'] = bundle['amount'].to_i - amount_to_get #resize the bundle
  854. bundles << bundle #and add back on the end
  855. total = 0
  856. end
  857.  
  858.  
  859.  
  860. end
  861. end
  862. }
  863. #fput "stow r" if !checkright.nil?
  864. stow("right",settings['fletch_quiver']) if !checkright.nil?
  865. }
  866. end
  867. def make_heavyshafts(settings)
  868. check = dothistimeout "get my wood in my #{settings['fletch_sack']}", 1, /You remove|Get what?/
  869. if check =~ /Get what?/
  870. echo "Run out of shafts some how, this shouldn't be happening."
  871. exit
  872. elsif check.nil?
  873. #backup for scripted containers
  874. endtime = Time.now + 5
  875. loop {
  876. if checkright =~ /wood/
  877. break
  878. elsif Time.now > endtime
  879. echo "Could not get wood, stopping"
  880. exit
  881. else
  882. sleep 1
  883. end
  884. }
  885. end
  886. #get axe
  887. check = dothistimeout "get my #{settings['fletch_axe']}", 3, /You remove|get what?/
  888. if check =~ /get what?/
  889. echo "Could not get your axe to cut the shafts"
  890. exit
  891. elsif check.nil?
  892. #backup for scripted containers
  893. endtime = Time.now + 5
  894. loop {
  895. if checkright =~ /#{settings['fletch_axe']}/
  896. break
  897. elsif Time.now > endtime
  898. echo "Could not get your axe to cut the shafts"
  899. exit
  900. else
  901. sleep 1
  902. end
  903. }
  904. end
  905. #cut shafts
  906. haste!
  907. fput "cut heavy bolt my wood"
  908. endtime = Time.now + 6
  909. loop {
  910. if checkright =~ /shaft/
  911. break
  912. elsif Time.now > endtime
  913. echo "Failed to cut shafts"
  914. exit
  915. else
  916. sleep 1
  917. echo "sleeping"
  918. end
  919. }
  920. sleep 1
  921. waitrt?
  922. stow("right",settings['fletch_sack'])
  923. #fput "put right in my #{settings['fletch_sack']}"
  924. endtime = Time.now + 6
  925. loop{
  926. if checkright.nil?
  927. break
  928. elsif Time.now > endtime
  929. "Stowing item failed"
  930. exit
  931. else
  932. sleep 0.5
  933. end
  934. }
  935. stow("left",settings['fletch_sack'])
  936. end
  937. def make_shafts(settings)
  938. #get wood
  939. check = dothistimeout "get my wood in my #{settings['fletch_sack']}", 1, /You remove|Get what?/
  940. if check =~ /Get what?/
  941. echo "Run out of shafts some how, this shouldn't be happening."
  942. exit
  943. elsif check.nil?
  944. #backup for scripted containers
  945. endtime = Time.now + 5
  946. loop {
  947. if checkright =~ /wood/
  948. break
  949. elsif Time.now > endtime
  950. echo "Could not get wood, stopping"
  951. exit
  952. else
  953. sleep 1
  954. end
  955. }
  956. end
  957. #get axe
  958. check = dothistimeout "get my #{settings['fletch_axe']}", 3, /You remove|get what?/
  959. if check =~ /get what?/
  960. echo "Could not get your axe to cut the shafts"
  961. exit
  962. elsif check.nil?
  963. #backup for scripted containers
  964. endtime = Time.now + 5
  965. loop {
  966. if checkright =~ /#{settings['fletch_axe']}/
  967. break
  968. elsif Time.now > endtime
  969. echo "Could not get your axe to cut the shafts"
  970. exit
  971. else
  972. sleep 1
  973. end
  974. }
  975. end
  976. #cut shafts
  977. haste!
  978. fput "cut arrow shaft my wood"
  979. endtime = Time.now + 6
  980. loop {
  981. if checkright =~ /shaft/
  982. break
  983. elsif Time.now > endtime
  984. echo "Failed to cut shafts"
  985. exit
  986. else
  987. sleep 1
  988. echo "sleeping"
  989. end
  990. }
  991. sleep 1
  992. waitrt?
  993. stow("right",settings['fletch_sack'])
  994. #fput "put right in my #{settings['fletch_sack']}"
  995. endtime = Time.now + 6
  996. loop{
  997. if checkright.nil?
  998. break
  999. elsif Time.now > endtime
  1000. "Stowing item failed"
  1001. exit
  1002. else
  1003. sleep 0.5
  1004. end
  1005. }
  1006. stow("left",settings['fletch_sack'])
  1007. end
  1008.  
  1009. def make_bolt(settings)
  1010. check = dothistimeout "get 1 my shaft", 3, /You remove|get what?/
  1011. loop {
  1012. if checkright =~ /shaft/
  1013. break
  1014. elsif Time.now > endtime
  1015. echo "Could not get shaft, stopping"
  1016. exit
  1017. else
  1018. sleep 1
  1019. end
  1020. }
  1021. get_knife(settings)
  1022. fput "cut my shaft with my #{settings['fletch_knife']}"
  1023. sleep 1
  1024. waitrt?
  1025. stow("left",settings['fletch_sack'])
  1026.  
  1027.  
  1028. #measure shaft
  1029. waitrt?
  1030. check = dothistimeout "remove my #{settings['fletch_bow']}", 1, /You sling|remove what?/
  1031. if check =~ /remove what?/
  1032. echo "Failed to get your crossbow."
  1033. exit
  1034. elsif check.nil?
  1035. endtime = Time.now + 5
  1036. loop {
  1037. if checkleft =~ /crossbow/
  1038. break
  1039. elsif Time.now > endtime
  1040. echo "Failed to get your bow."
  1041. exit
  1042. else
  1043. sleep 1
  1044. end
  1045. }
  1046. end
  1047. haste!
  1048. check = dothistimeout "measure my shaft with my #{settings['fletch_bow']}", 3, /You place the shaft in your/
  1049. if check.nil?
  1050. echo "failed, do something about this later"
  1051. exit
  1052. end
  1053. sleep 1
  1054. waitrt?
  1055. check = dothistimeout "wear my #{settings['fletch_bow']}", 3, /You sling .+ over your shoulder./
  1056. if check.nil?
  1057. echo "failed, do something about this later"
  1058. exit
  1059. end
  1060. get_knife(settings)
  1061. haste!
  1062. fput "cut my shaft with my #{settings['fletch_knife']}"
  1063. fput "cut my shaft with my #{settings['fletch_knife']}"
  1064. sleep 1
  1065. waitrt?
  1066. if checkright !~ /shaft/
  1067. stow("left",settings['fletch_sack'])
  1068. return
  1069. end
  1070. stow("left",settings['fletch_sack'])
  1071.  
  1072. fput "get my glue"
  1073. endtime = Time.now + 6
  1074. loop{
  1075.  
  1076. if checkleft =~ /glue/
  1077. break
  1078. elsif Time.now > endtime
  1079. "Failed to get glue"
  1080. exit
  1081. else
  1082. sleep 0.1
  1083. end
  1084. }
  1085.  
  1086. haste!
  1087. check = dothistimeout "put my glue on my shaft", 3, /You carefully smear a bit of glue/
  1088. if check.nil?
  1089. echo "failed, do something about this later"
  1090. exit
  1091. end
  1092. sleep 1
  1093. waitrt?
  1094. stow("left",settings['fletch_sack'])
  1095.  
  1096. fput "get 3 my fletching in my #{settings['fletch_sack']}"
  1097. endtime = Time.now + 6
  1098. loop{
  1099. if checkleft =~ /fletching/
  1100. break
  1101. elsif Time.now > endtime
  1102. "Failed to get fletchings"
  1103. exit
  1104. else
  1105. sleep 0.1
  1106. end
  1107. }
  1108.  
  1109. haste!
  1110. 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 /
  1111. if check =~/You attatch your/
  1112. return
  1113. end
  1114. check = matchtimeout 60, "The glue on your heavy crossbow shaft has dried."
  1115. waitrt?
  1116. if checkright !~ /shaft/
  1117. stow("left",settings['fletch_sack'])
  1118. return
  1119. end
  1120. haste!
  1121. if settings['fletch_flip'] =~ true
  1122. fput "flip my shaft"
  1123. return
  1124. end
  1125. if settings['fletch_drilling'] =~ true
  1126. fput "get my #{settings['fletch_drill']} from my #{settings['fletch_sack']}"
  1127. fput "turn my #{settings['fletch_drill']}"
  1128. waitrt?
  1129. fput "put my #{settings['fletch_drill']} in my #{settings['fletch_sack']}"
  1130. fput "get my #{settings['fletch_arrowhead']} from my #{settings['fletch_sack']}"
  1131. fput "turn my #{settings['fletch_arrowhead']}"
  1132. return
  1133. else
  1134. get_knife(settings)
  1135. put "cut my shaft with my #{settings['fletch_knife']}"
  1136. put "cut my shaft with my #{settings['fletch_knife']}"
  1137. check = matchtimeout 6, "With a few quick cuts,", "Working a bit too hastily, you slice the end right off!"
  1138. if check == false
  1139. echo "didnt see you cut the shaft for some reason, stopping"
  1140. exit
  1141. end
  1142. end
  1143. waitrt?
  1144. stow("left",settings['fletch_sack'])
  1145. end
  1146.  
  1147. def make_arrow(settings,paints)
  1148. #get shaft
  1149. check = dothistimeout "get 1 my shaft", 3, /You remove|get what?/
  1150. if check =~ /get what?/
  1151. echo "Run out of shafts some how, this shouldn't be happening."
  1152. exit
  1153. elsif check.nil?
  1154. #backup for scripted containers
  1155. endtime = Time.now + 5
  1156. loop {
  1157. if checkright =~ /shaft/
  1158. break
  1159. elsif Time.now > endtime
  1160. echo "Could not get shaft, stopping"
  1161. exit
  1162. else
  1163. sleep 1
  1164. end
  1165. }
  1166. end
  1167. get_knife(settings)
  1168. #cut shaft
  1169. haste!
  1170. fput "cut my shaft with my #{settings['fletch_knife']}"
  1171. sleep 1
  1172. waitrt?
  1173.  
  1174. if checkright !~ /shaft/
  1175. stow("left",settings['fletch_sack'])
  1176. return
  1177. end
  1178.  
  1179. #painting goes here
  1180. if settings['fletch_paint'] != 0
  1181. stow("left",settings['fletch_sack'])
  1182. paint = paints[settings['fletch_paint']].split(" ")
  1183. fput "get my #{paint[0]} paint"
  1184. endtime = Time.now + 6
  1185. loop{
  1186. if checkleft =~ /paint/
  1187. break
  1188. elsif Time.now > (endtime - 3)
  1189. fput "get my #{paint[0]} paint"
  1190. elsif Time.now > endtime
  1191. echo "Run out of paint, probably means you have another colour paint on you messing with my check. Get it out your fletchsack"
  1192. exit
  1193. else
  1194. sleep 0.5
  1195. end
  1196. }
  1197. haste!
  1198. check = dothistimeout "paint my shaft", 3, /You carefully smear a bit of paint/
  1199. if check.nil?
  1200. #if the first check failed for some reason double check by looking at the arrow
  1201. 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./
  1202. if check !~ /The arrow shaft has been pared down and smoothed. A coat of .+ paint covers the shaft./
  1203. echo "Could not determine if painting was successful, stopping"
  1204. exit
  1205. end
  1206. end
  1207. check = matchtimeout 40, "The paint on your arrow shaft has dried."
  1208. if !check
  1209. echo "Did not see paint dry for some reason, carrying on in case it did but might cause problems if it didn't"
  1210. end
  1211. stow("left",settings['fletch_sack'])
  1212.  
  1213. end
  1214. #paintstick1
  1215. if settings['fletch_paintstick1'].length > 0
  1216. stow("left",settings['fletch_sack'])
  1217. fput "get my #{settings['fletch_paintstick1']}"
  1218. endtime = Time.now + 6
  1219. loop{
  1220. if checkleft =~ /paintstick/
  1221. break
  1222. elsif Time.now > (endtime - 3)
  1223. fput "get my #{settings['fletch_paintstick1']}"
  1224. elsif Time.now > endtime
  1225. echo "Could not get your paintstick"
  1226. exit
  1227. else
  1228. sleep 0.5
  1229. end
  1230. }
  1231. haste!
  1232. check = dothistimeout "paint my shaft", 3, /You carefully apply a band of/
  1233. if check.nil?
  1234. #if the first check failed for some reason double check by looking at the arrow
  1235. check = dothistimeout "look my shaft", 3, /It looks like someone has painted a single .+ band on the end/
  1236. if check !~ /It looks like someone has painted a single .+ band on the end/
  1237. echo "Could not determine if painting was succesful, stopping"
  1238. exit
  1239. end
  1240. end
  1241. check = matchtimeout 40, "The paint on your arrow shaft has dried."
  1242. if !check
  1243. echo "Did not see paint dry for some reason, carrying on in case it did but might cause problems if it didn't"
  1244. end
  1245. waitrt?
  1246. stow("left",settings['fletch_sack'])
  1247. end
  1248.  
  1249. #paintstick2
  1250. if settings['fletch_paintstick2'].length > 0
  1251. stow("left",settings['fletch_sack'])
  1252. fput "get my #{settings['fletch_paintstick2']}"
  1253. endtime = Time.now + 6
  1254. loop{
  1255. if checkleft =~ /paintstick/
  1256. break
  1257. elsif Time.now > (endtime - 3)
  1258. fput "get my #{settings['fletch_paintstick2']}"
  1259. elsif Time.now > endtime
  1260. echo "Could not get your paintstick"
  1261. exit
  1262. else
  1263. sleep 0.5
  1264. end
  1265. }
  1266. haste!
  1267. check = dothistimeout "paint my shaft", 3, /You carefully apply a band of/
  1268. if check.nil?
  1269. #if the first check failed for some reason double check by looking at the arrow
  1270. 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/
  1271. 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/
  1272. echo "Could not determine if painting was succesful, stopping"
  1273. exit
  1274. end
  1275. end
  1276. check = matchtimeout 40, "The paint on your arrow shaft has dried."
  1277. if !check
  1278. echo "Did not see paint dry for some reason, carrying on in case it did but might cause problems if it didn't"
  1279. end
  1280. waitrt?
  1281. stow("left",settings['fletch_sack'])
  1282. end
  1283.  
  1284.  
  1285. #cut nocks in shaft
  1286. get_knife(settings) if settings['fletch_paint'] != 0 or settings['fletch_paintstick1'].length != 0 or settings['fletch_paintstick2'].length != 0
  1287. haste!
  1288. fput "cut nock in my shaft with my #{settings['fletch_knife']}"
  1289. 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
  1290. sleep 2
  1291. waitrt?
  1292. if checkright !~ /shaft/
  1293. stow("left",settings['fletch_sack'])
  1294. return
  1295. end
  1296. #stow knife
  1297. stow("left",settings['fletch_sack'])
  1298.  
  1299. #measure shaft
  1300. waitrt?
  1301. check = dothistimeout "remove my #{settings['fletch_bow']}", 1, /You sling|remove what?/
  1302. if check =~ /remove what?/
  1303. echo "Failed to get your knife."
  1304. exit
  1305. elsif check.nil?
  1306. endtime = Time.now + 5
  1307. loop {
  1308. if checkleft =~ /bow/
  1309. break
  1310. elsif Time.now > endtime
  1311. echo "Failed to get your bow."
  1312. exit
  1313. else
  1314. sleep 1
  1315. end
  1316. }
  1317. end
  1318. haste!
  1319. 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./
  1320. if check.nil?
  1321. echo "failed, do something about this later"
  1322. exit
  1323. end
  1324. sleep 1
  1325. waitrt?
  1326. check = dothistimeout "wear my #{settings['fletch_bow']}", 3, /You sling .+ over your shoulder./
  1327. if check.nil?
  1328. echo "failed, do something about this later"
  1329. exit
  1330. end
  1331. get_knife(settings)
  1332. haste!
  1333. 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./
  1334. if check.nil?
  1335. echo "failed, do something about this later"
  1336. exit
  1337. end
  1338. sleep 1
  1339. waitrt?
  1340. if checkright !~ /shaft/
  1341. stow("left",settings['fletch_sack'])
  1342. return
  1343. end
  1344. stow("left",settings['fletch_sack'])
  1345.  
  1346. fput "get my glue"
  1347. endtime = Time.now + 6
  1348. loop{
  1349.  
  1350. if checkleft =~ /glue/
  1351. break
  1352. elsif Time.now > endtime
  1353. "Failed to get glue"
  1354. exit
  1355. else
  1356. sleep 0.1
  1357. end
  1358. }
  1359.  
  1360. haste!
  1361. check = dothistimeout "put my glue on my shaft", 3, /You carefully smear a bit of glue/
  1362. if check.nil?
  1363. echo "failed, do something about this later"
  1364. exit
  1365. end
  1366. sleep 1
  1367. waitrt?
  1368. stow("left",settings['fletch_sack'])
  1369.  
  1370. fput "get 3 my fletching in my #{settings['fletch_sack']}"
  1371. endtime = Time.now + 6
  1372. loop{
  1373. if checkleft =~ /fletching/
  1374. break
  1375. elsif Time.now > endtime
  1376. "Failed to get fletchings"
  1377. exit
  1378. else
  1379. sleep 0.1
  1380. end
  1381. }
  1382.  
  1383. haste!
  1384. 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 /
  1385. if check =~/You attatch your/
  1386. return
  1387. elsif check =~/You attempt to attach some/
  1388. waitrt?
  1389. refletch_shaft(settings)
  1390. end
  1391. check = matchtimeout 60, "The glue on your arrow shaft has dried."
  1392. if check == false
  1393. refletch_shaft(settings)
  1394. end
  1395. waitrt?
  1396. if checkright !~ /shaft/
  1397. stow("left",settings['fletch_sack'])
  1398. return
  1399. end
  1400. haste!
  1401. if settings['fletch_flip'] =~ true
  1402. fput "flip my shaft"
  1403. return
  1404. end
  1405. if settings['fletch_drilling'] =~ true
  1406. fput "get my #{settings['fletch_drill']} from my #{settings['fletch_sack']}"
  1407. fput "turn my #{settings['fletch_drill']}"
  1408. waitrt?
  1409. fput "put my #{settings['fletch_drill']} in my #{settings['fletch_sack']}"
  1410. fput "get my #{settings['fletch_arrowhead']} from my #{settings['fletch_sack']}"
  1411. fput "turn my #{settings['fletch_arrowhead']}"
  1412. return
  1413. else
  1414. get_knife(settings)
  1415. put "cut my shaft with my #{settings['fletch_knife']}"
  1416. put "cut my shaft with my #{settings['fletch_knife']}"
  1417. check = matchtimeout 6, "With a few quick cuts,", "Working a bit too hastily, you slice the end right off!"
  1418. if check == false
  1419. echo "didnt see you cut the shaft for some reason, stopping"
  1420. exit
  1421. end
  1422. end
  1423.  
  1424. waitrt?
  1425. stow("left",settings['fletch_sack'])
  1426.  
  1427.  
  1428. end
  1429.  
  1430. def refletch_shaft(settings)
  1431. fput "get my glue"
  1432. endtime = Time.now + 6
  1433. loop{
  1434.  
  1435. if checkleft =~ /glue/
  1436. break
  1437. elsif Time.now > endtime
  1438. "Failed to get glue"
  1439. exit
  1440. else
  1441. sleep 0.1
  1442. end
  1443. }
  1444.  
  1445. haste!
  1446. check = dothistimeout "put my glue on my shaft", 3, /You carefully smear a bit of glue/
  1447. if check.nil?
  1448. echo "failed, do something about this later"
  1449. exit
  1450. end
  1451. sleep 1
  1452. waitrt?
  1453. stow("left",settings['fletch_sack'])
  1454. fput "get 3 my fletching in my #{settings['fletch_sack']}"
  1455. endtime = Time.now + 6
  1456. loop{
  1457. if checkleft =~ /fletching/
  1458. break
  1459. elsif Time.now > endtime
  1460. "Failed to get fletchings"
  1461. exit
  1462. else
  1463. sleep 0.1
  1464. end
  1465. }
  1466.  
  1467. haste!
  1468. 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 /
  1469. if check =~/You attatch your/
  1470. return
  1471. elsif check =~/You attempt to attatch some/
  1472. waitrt?
  1473. refletch_shaft(settings)
  1474. end
  1475. check = matchtimeout 60, "The glue on your arrow shaft has dried."
  1476. if check == false
  1477. refletch_shaft(settings)
  1478. return
  1479. end
  1480. waitrt?
  1481. if checkright !~ /shaft/
  1482. stow("left",settings['fletch_sack'])
  1483. return
  1484. end
  1485. haste!
  1486. if settings['fletch_flip'] =~ true
  1487. fput "flip my shaft"
  1488. return
  1489. end
  1490. if settings['fletch_drilling'] =~ true
  1491. fput "get my #{settings['fletch_drill']} from my #{settings['fletch_sack']}"
  1492. fput "turn my #{settings['fletch_drill']}"
  1493. waitrt?
  1494. fput "put my #{settings['fletch_drill']} in my #{settings['fletch_sack']}"
  1495. fput "get my #{settings['fletch_arrowhead']} from my #{settings['fletch_sack']}"
  1496. fput "turn my #{settings['fletch_arrowhead']}"
  1497. return
  1498. else
  1499. get_knife(settings)
  1500. put "cut my shaft with my #{settings['fletch_knife']}"
  1501. put "cut my shaft with my #{settings['fletch_knife']}"
  1502. check = matchtimeout 6, "With a few quick cuts,", "Working a bit too hastily, you slice the end right off!"
  1503. if check == false
  1504. echo "didnt see you cut the shaft for some reason, stopping"
  1505. exit
  1506. end
  1507. end
  1508.  
  1509. waitrt?
  1510. stow("left",settings['fletch_sack'])
  1511. end
  1512.  
  1513. def checkrest
  1514. until(percentmind < @XP_TO_STOP)
  1515. pause 30
  1516. fput "exp"
  1517. end
  1518. end
  1519.  
  1520. container_contents = nil
  1521. needed_items = nil
  1522. start_time = Time.now
  1523. arrows_made = 0
  1524. arrows_failed = 0
  1525. spent_silver = 0
  1526. finished = false
  1527.  
  1528. if variable[0] =~ /setup|config|configure/i
  1529. setup.call
  1530. exit
  1531. elsif variable[0] =~ /bundle/i
  1532. bundle(settings)
  1533. exit
  1534. elsif !variable[0].nil?
  1535. message = ""
  1536. 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"
  1537. message += "Run ;fletching setup at any times to change you settings\r\n"
  1538. 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"
  1539.  
  1540. if !$fake_stormfront
  1541. puts "<output class=\"mono\"/>#{monsterbold_start}#{message}#{monsterbold_end}\r\n<output class=\"\"/>"
  1542. else
  1543. puts "#{monsterbold_start}#{message}#{monsterbold_end}"
  1544. end
  1545. exit
  1546. end
  1547.  
  1548.  
  1549. fletching_report = proc { |client_string|
  1550. if client_string =~ /^(?:<c>)?#{$clean_lich_char}(?:fletching)$/i
  1551.  
  1552. respond ""
  1553. 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"
  1554. respond ""
  1555. elsif client_string =~ /^(?:<c>)?#{$clean_lich_char}fletching (?:stop|done|end|finish|finished)$/i
  1556. finished = true
  1557. respond ""
  1558. respond "Once current arrow is complete script will end"
  1559. respond ""
  1560. else
  1561. client_string
  1562. end
  1563. }
  1564.  
  1565. UpstreamHook.add('fletching_hook', fletching_report)
  1566. before_dying{;UpstreamHook.remove('fletching_hook');}
  1567.  
  1568. warning = ""
  1569. if settings['fletch_sack'] == "" or settings['fletch_sack'].nil?
  1570. warning += "The container for you supplies has not yet been set, the script will not run until this is added.\r\n"
  1571. end
  1572. if settings['fletch_quiver'] == "" or settings['fletch_quiver'].nil?
  1573. warning += "The container for you finished arrows has not yet been set, the script will not run until this is added.\r\n"
  1574. end
  1575. if settings['fletch_knife'] == ""
  1576. warning += "Have not set a knife/dagger to cut the shafts with, the script will not run until this is added.\r\n"
  1577. end
  1578. if settings['fletch_bow'] == ""
  1579. warning += "Have not set a bow to measure the shafts with, the script will not run until this is added.\r\n"
  1580. end
  1581. if settings['fletch_axe'] == ""
  1582. warning += "Have not set an axe to make shafts with, the script will not run until this is added.\r\n"
  1583. end
  1584. if settings['fletch_wood'] == ""
  1585. warning += "Have not set a what wood you want to use, the script will not run until this is added.\r\n"
  1586. end
  1587. if settings['fletch_wood'] != "" and settings['fletch_wood'] !~ /wood/
  1588. 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"
  1589. end
  1590. if settings['fletch_fletchings'] != "" and settings['fletch_fletchings'] !~ /fletching/
  1591. 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"
  1592. end
  1593.  
  1594. if warning.length > 0
  1595. if !$fake_stormfront
  1596. puts "<output class=\"mono\"/>#{monsterbold_start}#{warning}#{monsterbold_end}\r\n<output class=\"\"/>"
  1597. else
  1598. puts "#{monsterbold_start}#{warning}#{monsterbold_end}"
  1599. end
  1600. setup.call
  1601. exit
  1602. end
  1603. monitor_interaction()
  1604. empty_left_hand
  1605. empty_right_hand
  1606. loop{
  1607. if settings['waggle']
  1608. start_script "waggle"
  1609. wait_while {running?("waggle")}
  1610. end
  1611. fletch_sack_contents = get_container_contents(settings['fletch_sack'])
  1612. needed_items = check_needed_items(settings,fletch_sack_contents,paints)
  1613. if !needed_items.empty?
  1614. if !settings['fletch_enable_buying']
  1615. echo "Run out of #{needed_items[0]} and the script is not set to buy more, ';fletching setup' to change this."
  1616. exit
  1617. end
  1618. respond ""
  1619. needed_items.each{|item|
  1620. respond "Out of #{item}"
  1621. }
  1622. respond "Off to buy"
  1623. respond ""
  1624. sleep 1
  1625. spent_silver += buy_items(settings, needed_items)
  1626. needed_items = Array.new
  1627. end
  1628. fletch_sack_contents = get_container_contents(settings['fletch_sack'])
  1629. #echo fletch_sack_contents
  1630. #exit
  1631. if settings['fletch_bow'] =~ /^crossbow/
  1632. make_heavyshafts(settings) if fletch_sack_contents.to_s.include? '@noun="wood"'
  1633. else
  1634. make_shafts(settings) if fletch_sack_contents.to_s.include? '@noun="wood"'
  1635. end
  1636. checkrest
  1637. if settings['fletch_bow'] =~ /^crossbow/
  1638. make_bolt(settings)
  1639. else
  1640. make_arrow(settings,paints)
  1641. end
  1642. if checkright =~ /^bolt/
  1643. echo "stowing"
  1644. stow("right",settings['fletch_quiver'])
  1645. arrows_made += 1
  1646. elsif checkright =~ /^arrow/
  1647. echo "stowing"
  1648. stow("right",settings['fletch_quiver'])
  1649. arrows_made += 1
  1650. else
  1651. arrows_failed += 1
  1652. end
  1653.  
  1654. respond ""
  1655. 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"
  1656. respond ""
  1657. exit if finished
  1658. exit if settings['fletch_limit'].to_i > 0 and arrows_made == settings['fletch_limit'].to_i
  1659. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement