-
Notifications
You must be signed in to change notification settings - Fork 178
/
bolts.lic
156 lines (134 loc) · 5.2 KB
/
bolts.lic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#bolts
=end
custom_require.call(%w[common common-items common-crafting common-money common-travel])
class Bolts
def initialize
@settings = get_settings
@worn_trashcan = @settings.worn_trashcan
@worn_trashcan_verb = @settings.worn_trashcan_verb
@bag = @settings.crafting_container
@bag_items = @settings.crafting_items_in_container
@belt = @settings.engineering_belt
@hometown = @settings.force_crafting_town || @settings.hometown
@engineering_room = @settings.engineering_room
@hometown_data = get_data('crafting')['shaping'][@hometown]
arg_definitions = [
[
{ name: 'type',
options: %w[cougar-claw boar-tusk sabretooth angiswaerd hele'la basilisk elsralael soot-stained ice-adder jagged-horn drake-fang],
variable: true,
descriptions: "Which arrow type to create?" },
{ name: 'lumber',
regex: /\w+/i,
variable: true,
description: 'Type of lumber used.' },
{ name: 'tools',
regex: /tools/,
optional: true,
description: 'Get tools from clerk.' }
],
[
{ name: 'continue', regex: /continue/i, variable: true }
]
]
args = parse_args(arg_definitions)
if args.continue
DRC.wait_for_script_to_complete('tinker', ['resume', 'bolts'])
exit_tasks
exit
end
@type = args.type
@lumber = args.lumber
@tools = args.tools
DRCM.ensure_copper_on_hand(2000, @settings, @hometown)
DRC.wait_for_script_to_complete('clerk-tools', ['engineering', 'get']) unless DRCI.exists?('shaper') if @tools
order_lumber
check_flights
check_glue
DRCT.walk_to(@engineering_room)
make_shafts
make_bolts
DRC.wait_for_script_to_complete('tinker', ['7', "#{@type} bolts", 'shafts', 'bolts'])
exit_tasks
end
def exit_tasks
clean_up
DRC.wait_for_script_to_complete('clerk-tools', ['engineering', 'store']) if DRCI.exists?('shaper') if @tools
exit
end
def order_lumber
return if DRCI.exists?("#{@lumber} lumber") || DRCI.exists?('bolt shafts')
wood = find_piece("#{@lumber} lumber")
DRCT.order_item(@hometown_data['stock-room'], wood)
DRC.bput("combine my lumber", "You combine", "You must") if DRCI.get_item("#{@lumber} lumber", @bag)
DRCC.stow_crafting_item('lumber', @bag, @belt)
end
def check_flights
return if DRCI.exists?('bolt flights')
flight = find_piece('bolt flights')
DRCT.order_item(@hometown_data['stock-room'], flight)
DRCC.stow_crafting_item('bolt flights', @bag, @belt)
end
def check_glue
if DRCI.search?('glue')
DRC.bput('get my glue', 'You get')
/(\d+)/ =~ DRC.bput('count my glue', 'The wood glue has *\d+ uses remaining')
if Regexp.last_match(1).to_i < 5
DRCC.stow_crafting_item('glue', @bag, @belt)
DRCI.dispose_trash('glue', @worn_trashcan, @worn_trashcan_verb)
DRCT.order_item(@hometown_data['tool-room'], @hometown_data['glue-number'])
end
else
DRCT.order_item(@hometown_data['tool-room'], @hometown_data['glue-number'])
end
DRCC.stow_crafting_item('glue', @bag, @belt)
end
def make_shafts
return if DRCI.exists?('bolt shafts')
DRCC.get_crafting_item('shaper', @bag, @bag_items, @belt)
if DRCI.get_item("#{@lumber} lumber", @bag)
DRC.bput("shape lumber into bolt shaft", 'Roundtime')
DRCC.stow_crafting_item('shaper', @bag, @belt)
DRCC.stow_crafting_item('shafts', @bag, @belt)
DRCC.stow_crafting_item('lumber', @bag, @belt)
else
DRC.message(" *** Out of #{@lumber} lumber and shafts *** ")
DRC.beep
exit
end
end
def make_bolts
return if DRCI.exists?("#{@type} boltheads")
bolt_head = { "cougar-claw" => "curved claw", "boar-tusk" => "boar tusk", "sabretooth" => "ivory fang", "angiswaerd" => "angiswaerd tooth", "hele'la" => "needlesharp tooth", "basilisk" => "basilisk fang", "elsralael" => "elsralael tooth", "soot-stained" => "soot-streaked fang", "ice-adder" => "adder fang", "jagged-horn" => "jagged horn", "drake-fang" => "drake fang" }
new_type = bolt_head[@type]
if DRCI.get_item(new_type, @bag)
DRCC.get_crafting_item('shaper', @bag, @bag_items, @belt)
DRC.bput("shape #{new_type} into bolthead", 'Roundtime', 'You fumble')
DRCC.stow_crafting_item('shaper', @bag, @belt)
if new_type == "soot-streaked fang"
DRCC.stow_crafting_item('soot-streaked boltheads', @bag, @belt)
else
DRCC.stow_crafting_item("#{@type} boltheads", @bag, @belt)
end
else
DRC.beep
DRC.message("***Out of #{@type}!***")
exit_tasks
end
end
def clean_up
DRC.bput("get my bolt shafts", "You get", "You pick up", "What were")
DRCC.stow_crafting_item('bolt shafts', @bag, @belt)
DRCC.stow_crafting_item('lumber', @bag, @belt)
end
def find_piece(match_string)
DRC.wait_for_script_to_complete('go2', [@hometown_data['stock-room']])
echo(match_string)
piece = DRC.bput('order', "^\\d+\\)\\.\\s\\s(?:some|a|an|stack of|5 pieces of|10 pieces of|1 batch of straight)?\\s*#{match_string}")
piece =~ /^(\d+)/
echo(piece)
Regexp.last_match(1)
end
end
Bolts.new