forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
arrows.lic
168 lines (143 loc) · 4.9 KB
/
arrows.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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#arrows
=end
custom_require.call(%w[common common-items common-crafting common-money common-travel])
class Arrows
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: 'resume', regex: /resume/i, variable: true }
]
]
args = parse_args(arg_definitions)
if args.resume
DRC.wait_for_script_to_complete('shape', ['resume', 'arrows'])
exit_tasks
exit
end
@type = args.type
@lumber = args.lumber
@tools = args.tools
DRCM.ensure_copper_on_hand(2000, @settings)
get_tools if @tools
order_lumber
check_flights
check_glue
DRCT.walk_to(@engineering_room)
make_shafts
make_arrowheads
DRC.wait_for_script_to_complete('shape', ['stow', '5', "#{@type} arrows", 'shafts', 'arrows'])
exit_tasks
end
def exit_tasks
clean_up
store_tools if @tools
exit
end
def get_tools
DRC.wait_for_script_to_complete('clerk-tools', ['engineering', 'get']) unless DRCI.exists?('shaper')
end
def store_tools
DRC.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?('arrow 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?('arrow flights')
flight = find_piece('arrow flights')
DRCT.order_item(@hometown_data['stock-room'], flight)
stow_craft('arrow 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?('arrow shafts')
get_craft('shaper')
if DRCI.get_item("#{@lumber} lumber", @bag)
DRC.bput("shape lumber into arrow shaft", 'Roundtime')
stow_craft('shaper')
stow_craft('shafts')
else
DRC.message(" *** Out of #{@lumber} lumber and shafts *** ")
DRC.beep
exit
end
end
def make_arrowheads
return if DRCI.exists?("#{@type} arrowheads")
arrow_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 = arrow_head[@type]
if DRCI.get_item(new_type, @bag)
get_craft('shaper')
DRC.bput("shape #{new_type} into arrowhead", 'Roundtime', 'You fumble')
stow_craft('shaper')
if new_type == "soot-streaked fang"
stow_craft("soot-streaked arrowheads")
else
stow_craft("#{@type} arrowheads")
end
else
DRC.beep
DRC.message("***Out of #{@type}!***")
exit_tasks
end
end
def clean_up
DRC.bput("get my arrow shafts", "You get", "You pick up", "What were")
stow_craft('arrow shafts')
stow_craft('lumber') if DRCI.exists?('lumber')
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
def get_craft(name)
DRCC.get_crafting_item(name, @bag, @bag_items, @belt)
end
def stow_craft(name)
DRCC.stow_crafting_item(name, @bag, @belt)
end
end
Arrows.new