forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bolts.lic
171 lines (149 loc) · 4.91 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
=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
include DRC
include DRCC
include DRCI
include DRCM
include DRCT
def initialize
@settings = get_settings
@bag = @settings.crafting_container
@bag_items = @settings.crafting_items_in_container
@belt = @settings.engineering_belt
@hometown = @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
wait_for_script_to_complete('tinker', ['continue', 'bolts'])
exit_tasks
exit
end
@type = args.type
@lumber = args.lumber
@tools = args.tools
ensure_copper_on_hand(2000, @settings)
get_tools if @tools
order_lumber
check_flights
check_glue
DRCT.walk_to(@engineering_room)
make_shafts
make_bolts
wait_for_script_to_complete('tinker', ['stow', '7', "#{@type} bolts", 'shafts', 'bolts'])
exit_tasks
end
def exit_tasks
clean_up
store_tools if @tools
exit
end
def get_tools
wait_for_script_to_complete('clerk-tools', ['engineering', 'get']) unless DRCI.exists?('shaper')
end
def store_tools
wait_for_script_to_complete('clerk-tools', ['engineering', 'store']) if DRCI.exists?('shaper')
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)
stow_craft('lumber')
end
def check_flights
return if DRCI.exists?('bolt flights')
flight = find_piece('bolt flights')
DRCT.order_item(@hometown_data['stock-room'], flight)
stow_craft('bolt flights')
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
stow_craft('glue')
DRCT.dispose('glue')
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
stow_craft('glue')
end
def make_shafts
return if DRCI.exists?('bolt shafts')
get_craft('shaper')
if DRCI.get_item("#{@lumber} lumber", @bag)
DRC.bput("shape lumber into bolt shaft", 'Roundtime')
stow_craft('shaper')
stow_craft('shafts')
stow_craft('lumber')
else
DRC.message(" *** Out of #{@lumber} lumber and shafts *** ")
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)
get_craft('shaper')
DRC.bput("shape #{new_type} into bolthead", 'Roundtime', 'You fumble')
stow_craft('shaper')
if new_type == "soot-streaked fang"
stow_craft("soot-streaked boltheads")
else
stow_craft("#{@type} boltheads")
end
else
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")
stow_craft('bolt shafts')
stow_craft('lumber')
end
def find_piece(match_string)
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
def get_craft(name)
get_crafting_item(name, @bag, @bag_items, @belt)
end
def stow_craft(name)
stow_crafting_item(name, @bag, @belt)
end
end
Bolts.new