Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- begin
- custom_require.call %w[common common-crafting common-items common-money common-travel]
- rescue
- echo 'You seem to be missing dependency. The dependency suite of scripts is required to run this.'
- exit
- end
- # TODO: make unbundle room a setting
- class Fletcher
- include DRC
- include DRCC
- include DRCI
- include DRCM
- include DRCT
- def initialize
- @shopping_data = {
- 'arrow flights' => {
- 'room' => 19306,
- 'order number' => 12,
- 'cost' => 62
- },
- 'bolt flights' => {
- 'room' => 19306,
- 'order number' => 13,
- 'cost' => 62
- },
- 'wood glue' => {
- 'room' => 9574,
- 'order number' => 13,
- 'cost' => 437
- }
- }
- @raw_mat_map = {
- 'angiswaerd' => '',
- 'boar-tusk' => '',
- 'cougar-claw' => 'curved claw',
- 'drake-fang' => '',
- 'sabretooth' => 'sabre teeth',
- 'soot-stained' => 'soot-stained claw',
- 'basilisk' => 'basilisk fang'
- }
- # Setup args
- arg_definitions = [
- [
- { name: 'shaft', regex: /shaft/i, description: 'Make some shafts?' },
- { name: 'shaft_type', options: %w[arrow bolt], description: 'What kind?' },
- { name: 'num_bundles', regex: /\d+/, description: 'How many bundles? (You make 5 shafts per bundle)' }
- ],
- [
- { name: 'head', regex: /head/i, description: 'Make arrow/bolt heads?' },
- { name: 'head_type', options: %w[arrow bolt], description: 'What kind?' },
- { name: 'head_material', options: @raw_mat_map.keys, description: 'What are you making the head out of?' },
- { name: 'num_heads', regex: /\d+/, description: 'How many heads?' }
- ],
- [
- { name: 'arrow', regex: /arrow/i, description: 'Make some arrows? Will make arrowheads and shafts as needed' },
- { name: 'head_material', options: @raw_mat_map.keys, description: 'What are you making the head out of?' },
- { name: 'quantity', regex: /\d+/, description: 'How many arrow bundles? (You make 5 arrows per bundle)' }
- ],
- [
- { name: 'bolt', regex: /bolt/i, description: 'Make some bolts? Will make boltheads and shafts as needed' },
- { name: 'head_material', options: @raw_mat_map.keys, description: 'What are you making the head out of?' }
- ],
- [
- { name: 'unbundle', regex: /unbun/i, description: 'Remove your bundle, unbundle it, transfer fletching materials to your fletching bag, bundle the rest back up' },
- { name: 'unbundle_room', regex: /\d+/, description: 'Room #', optional: true }
- ]
- ]
- args = parse_args(arg_definitions)
- # Setup settings
- @settings = get_settings
- @hometown = @settings.hometown
- @belt = @settings.engineering_belt
- @bag = @settings.crafting_container
- @bag_items = @settings.crafting_items_in_container
- @fletching_bag = @settings.fletching_bag || 'backpack'
- @shaft_material = 'maple'
- # This flag is taken from shape.lic
- Flags.add('fletching-assembly', 'You need another (.+ arrowheads)', 'You need another (\w+ flights)')
- Flags.add('fletching-carve', 'A handful of rough edges require carving with a knife to remove', 'Now the flights are ready to be trimmed with a carving knife.')
- Flags.add('fletching-done', 'Applying the final touches')
- stow_hands
- if args.shaft
- quantity = args.num_bundles.to_i
- restock_shafts(quantity, args.shaft_type)
- elsif args.head
- quantity = args.num_heads.to_i
- quantity.times { make_heads(args.head_material, args.head_type) }
- elsif args.arrow
- quantity = args.quantity.to_i
- restock_heads(quantity, 'arrow', args.head_material)
- # heads_on_hand = count_item_parts("#{args.head_material} arrowhead")
- # heads_needed = quantity - heads_on_hand
- # heads_needed.times { make_heads(args.head_material, 'arrow') } if heads_needed > 0
- restock_glue
- restock_flights(quantity, 'arrow')
- restock_shafts(quantity, 'arrow')
- make_arrows(args.head_material)
- elsif args.bolt
- echo 'Make bolts'
- elsif args.unbundle
- unbundle_bundle
- end
- end
- def bundle_shaft(shaft_type)
- return unless left_hand =~ /shaft/ || right_hand =~ /shaft/
- return unless bput("get #{shaft_type} shaft from my #{@fletching_bag}", 'You get', 'What were you', 'You are already') == 'You get'
- bput('combine shaft with shaft', 'You combine', "That's not going to work")
- end
- def bundle_head(head_material, head_type)
- return unless left_hand =~ /head/ || right_hand =~ /head/
- return unless bput("get #{head_material} #{head_type}head from my #{@fletching_bag}", 'You get', 'What were you', 'You are already') == 'You get'
- bput("combine #{head_type}head with #{head_type}head", 'You combine', "That's not going to work")
- end
- def bundle_flight(flight_type)
- return unless left_hand =~ /flight/ || right_hand =~ /flight/
- return unless bput("get #{flight_type} flight from my #{@fletching_bag}", 'You get', 'What were you', 'You are already') == 'You get'
- bput('combine flight with flight', 'You combine', "That's not going to work")
- end
- def unbundle_bundle
- bput('remove my bundle', 'You remove', 'You sling')
- bput('unbundle', 'You untie')
- bput('stow rope', 'You put')
- end
- def make_arrows(head_material)
- recipes = get_data('recipes').crafting_recipes.select { |recipe| recipe['type'] =~ /shaping/i }
- recipe = recipe_lookup(recipes, head_material)
- return unless recipe
- get_crafting_item('shaping book', @bag, @bag_items, @belt)
- turn_to("page #{find_recipe(recipe['chapter'], recipe['name'])}")
- bput('study my book', 'Roundtime')
- stow_crafting_item('shaping book', @bag, @belt)
- get_crafting_item('shaper', @bag, @bag_items, @belt)
- get_crafting_item('arrow shaft', @bag, @bag_items, @belt)
- @noun = 'arrows'
- shape('shape my shaft with shaper')
- end
- def make_shafts(shaft_type)
- get_item('shaper')
- bput("get my #{@shaft_material} lumber", 'You get')
- bput("shape my lumber into #{shaft_type} shaft", 'You break the lumber into arrow-length sections')
- stow_crafting_item('shaper', @bag, @belt)
- bundle_shaft(shaft_type)
- fput('stow shaft')
- end
- def make_heads(item, head_type)
- get_item('shaper')
- if bput("get my #{@raw_mat_map[item]} from my #{@fletching_bag}", 'You get', 'What were you', 'You are already') == 'What were you'
- stow_item('shaper')
- echo 'OUT OF ARROWHEAD MATERIAL'
- return
- end
- bput("shape #{@raw_mat_map[item]} into #{head_type}head", 'You repeatedly impact')
- stow_item('shaper')
- bundle_head(item, head_type)
- fput("put my #{item} #{head_type}head in my #{@fletching_bag}")
- end
- def buy_lumber(quantity)
- return
- ensure_copper_on_hand(564 * quantity, @settings)
- quantity.times do
- order_item(19306, 10)
- stow_hands
- end
- end
- def restock_shafts(quantity, shaft_type)
- echo 'Skipping the shaft restock -- debug'
- return
- shafts_on_hand = count_item_parts("#{shaft_type} shaft")
- bundles_needed = (((quantity * 5) - shafts_on_hand) / 5).ceil
- return if bundles_needed < 1
- buy_lumber(bundles_needed)
- bundles_needed.times { make_shafts(shaft_type) }
- end
- def restock_heads(quantity, head_type, _head_material)
- heads_on_hand = count_item_parts("#{head_type}head")
- heads_needed = (((quantity * 5) - heads_on_hand) / 5).ceil
- return true if heads_needed < 1
- head_material_on_hand = count_items('')
- true
- end
- def restock_flights(quantity, flight_type)
- flights_on_hand = count_item_parts("#{flight_type} flight")
- echo "flights_on_hand=#{flights_on_hand}"
- flights_needed = quantity - flights_on_hand
- flights = @shopping_data["#{flight_type} flights"]
- ensure_copper_on_hand(flights['cost'] * flights_needed, @settings)
- flights_needed.times do
- order_item(flights['room'], flights['order number'])
- bundle_flight(flight_type)
- fput("put my flights in my #{@fletching_bag}")
- end
- end
- def turn_to(section)
- # Taken wholesale from forge.lic (commonize?)
- unless section
- echo('Failed to find recipe in book, buy a better book?')
- stow_item('book')
- exit
- end
- bput("turn my book to #{section}", 'You turn your', 'The book is already')
- end
- def restock_glue
- return if exists?('wood glue')
- glue = @shopping_data['wood glue']
- ensure_copper_on_hand(glue['cost'], @settings)
- order_item(glue['room'], glue['order number'])
- fput("put my glue in my #{@fletching_bag}")
- end
- ###########################################################################
- ### Sniped & Modified logic from shape.lic
- ###########################################################################
- def get_item(name)
- get_crafting_item(name, @bag, @belt, @belt)
- end
- def stow_item(name)
- stow_crafting_item(name, @bag, @belt)
- end
- def carve
- return unless Flags['fletching-carve']
- Flags.reset('fletching-carve')
- stow_item('shaper')
- get_item('carving knife')
- bput("carve my #{@noun} with my knife", 'Using slow strokes you scrape away', 'You whittle away the rough edges')
- stow_item('carving knife')
- get_item('shaper')
- command = "shape my #{@noun} with my shaper"
- echo 'noun = #{@noun}'
- end
- def glue
- waitrt?
- case bput("apply glue to my #{@noun}", 'You apply some glue to your arrows and affix each arrowhead in place.', 'That tool does not seem suitable for that task.')
- when 'That tool does not seem suitable for that task.'
- echo 'There may be an error.'
- return
- when 'You apply some glue to your arrows and affix each arrowhead in place.'
- return
- end
- end
- def assemble_part
- return unless Flags['fletching-assembly']
- tool = right_hand
- stow_item(tool)
- part = Flags['fletching-assembly'][1..-1].join('.')
- part = 'backer' if part == 'backing'
- Flags.reset('fletching-assembly')
- get_item(part)
- bput("assemble my #{@noun} with my #{part}", 'affix it securely in place', 'loop both ends', 'loop the string', 'carefully mark where it will attach when you continue crafting', 'add several marks indicating optimal locations')
- stow_item(part)
- get_item('wood glue')
- glue
- stow_item('wood glue')
- # get_item(tool)
- end
- def clean_up
- Flags.delete('fletching-assembly')
- Flags.delete('fletching-carve')
- Flags.delete('fletching-done')
- end
- def shape(command)
- waitrt?
- return if Flags['fletching-done']
- assemble_part
- carve
- case bput(command,
- # 'a wood shaper is needed', 'ready for shaping with a wood shaper', 'You lap the \w+ shafts with your shaper', 'You dab the surface of your',
- 'Applying the final touches',
- 'That tool does not seem suitable for that task.',
- # 'while it is inside of something',
- # 'You fumble around but',
- # 'You must be holding the shaper to do that',
- # 'You cannot figure out how to do that',
- # 'ASSEMBLE Ingredient1',
- 'You must be holding the shaper to do that.',
- 'begin to shape it with your shaper', # Output from shaping
- 'Using abrupt motions you shape a series of grooves into your arrow shafts', # Continue with shaper?
- 'require carving with a knife to remove') # Output from analyze and shaping, need a carving knife
- when 'a wood shaper is needed', 'ready for shaping with a wood shaper', 'You must be holding the shaper to do that', 'You whittle away the rough edges'
- waitrt?
- stow_item(right_hand)
- get_item('shaper')
- command = "shape my #{@noun} with my shaper"
- when 'Applying the final touches'
- stow_item(right_hand)
- return
- when 'while it is inside of something', 'You fumble around but', 'You cannot figure out how to do that'
- echo '*** ERROR TRYING TO CRAFT, EXITING ***'
- stow_item(right_hand)
- exit
- when 'That tool does not seem suitable for that task.'
- shape("analyze my #{@noun}")
- end
- shape(command)
- end
- end
- Fletcher.new
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement