forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcraft.lic
executable file
·320 lines (283 loc) · 11.2 KB
/
craft.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#craft
=end
custom_require.call(%w[drinfomon equipmanager common common-crafting common-items common-money common-travel])
class Craft
include DRC
include DRCC
include DRCI
include DRCM
include DRCT
def initialize
arg_definitions = [
[
{ name: 'craft', options: %w[forging outfitting engineering alchemy enchanting], description: 'What craft to train' }
]
]
args = parse_args(arg_definitions)
@settings = get_settings
@hometown = @settings.hometown
@training_room = (@settings.training_rooms || [@settings.safe_room]).sample
@settings.storage_containers.each { |container| fput("open my #{container}") }
@equipment_manager = EquipmentManager.new(@settings)
@craft_max_mindstate = @settings.craft_max_mindstate
@yarn_quantity = @settings.yarn_quantity
if args.craft == 'engineering'
exit if DRSkill.getxp('Engineering') > @craft_max_mindstate
train_engineering
end
if args.craft == 'outfitting'
exit if DRSkill.getxp('Outfitting') > @craft_max_mindstate
train_outfitting
end
if args.craft == 'forging'
exit if DRSkill.getxp('Forging') > @craft_max_mindstate
train_forging
end
if args.craft == 'alchemy'
echo('Alchemy is only supported by workorders.')
exit
end
if args.craft == 'enchanting'
exit if DRSkill.getxp('Enchanting') > @craft_max_mindstate
train_enchanting
end
end
def train_outfitting
rank = DRSkill.getrank('Outfitting')
if rank <= 25 # Tier 1 Extremely Easy
sew(5, 'knitted socks', 'socks')
elsif rank <= 50 # Tier 2 Very Easy
sew(5, 'knitted mittens', 'mittens')
elsif rank <= 100 # Tier 3 Easy
sew(5, 'knitted hat', 'hat')
elsif rank <= 175 # Tier 4 Simple
sew(5, 'knitted gloves', 'gloves')
elsif rank <= 300 # Tier 5 Basic
sew(5, 'knitted hose', 'hose')
elsif rank <= 425 # Tier 6 Somewhat Challenging
sew(5, 'knitted cloak', 'cloak')
elsif rank <= 650 # Tier 7 Challenging
sew(5, 'knitted blanket', 'blanket')
else # Tier 12 Extremely Difficult
echo('*** NOT YET IMPLEMENTED ***')
end
end
def train_engineering
rank = DRSkill.getrank('Engineering')
if rank <= 25 # Tier 1 Extremely Easy
shape(7, 'wood band', 'band')
elsif rank <= 50 # Tier 2 Very Easy
shape(7, 'a wood bracelet', 'bracelet')
elsif rank <= 100 # Tier 3 Easy
shape(7, 'wood cloak pin', 'cloak pin')
elsif rank <= 175 # Tier 4 Simple
shape(7, 'wood amulet', 'amulet')
elsif rank <= 300 # Tier 5 Basic
shape(7, 'wood brooch', 'brooch')
elsif rank <= 425 # Tier 6 Somewhat Challenging
shape(7, 'wood armband', 'armband')
elsif rank <= 600 # Tier 7 Challenging
shape(7, 'wood choker', 'choker')
elsif rank <= 700 # Tier 8 - Complicated
shape(7, 'articulated wood necklace', 'necklace')
elsif rank <= 850 # Tier 9 - Intricate
shape(7, 'wood crown', 'crown')
elsif rank <= 1175 # Tier 10 - Difficult
shape(7, 'wood comb', 'comb')
elsif rank <= 1400 # Tier 11 - Very Difficult
shape(7, 'wood haircomb', 'haircomb')
else # Tier 12 Extremely Difficult
echo('*** NOT YET IMPLEMENTED ***')
end
end
def train_forging
rank = DRSkill.getrank('Forging')
if rank <= 25 # Tier 1 - Extremely Easy
smith('a shallow metal cup')
elsif rank <= 50 # Tier 2 - Very Easy
smith('a short metal mug')
elsif rank <= 100 # Tier 3 - Easy
smith('a back scratcher')
elsif rank <= 175 # Tier 4 - Simple
smith('a metal ankle band')
elsif rank <= 300 # Tier 5 - Basic
smith('a metal lockpick ring')
elsif rank <= 425 # Tier 6 - Somewhat Challenging
smith('a metal armband')
elsif rank <= 550 # Tier 7 - Challenging
smith('some metal clippers')
elsif rank <= 700 # Tier 8 - Complicated
smith('some squat knitting needles')
elsif rank <= 850 # Tier 9 - Intricate
smith('serrated hide scraper')
elsif rank <= 1175 # Tier 10 - Difficult
smith('serrated scissors')
elsif rank <= 1400 # Tier 11 - Very Difficult
smith('thin sewing needles')
else # Tier 12 - Extremely Difficult
smith('trapezoidal wire sieve')
end
end
def train_enchanting
crafting_data = get_data('crafting')
rank = DRSkill.getrank('Enchanting')
if rank <= 25 # Tier 1 Extremely Easy
# Buy an abolution sigil and wood totem
ensure_copper_on_hand(2000, @settings)
order_item(crafting_data['artificing'][@hometown]['stock-room'], 2)
order_item(crafting_data['artificing'][@hometown]['stock-room'], 6)
stow_hands
wait_for_script_to_complete('enchant', [2, 'radiant trinket', 'totem'])
dispose_trash('totem')
elsif rank <= 50 # Tier 2 - Very Easy
# Buy an induction sigil and wood totem
ensure_copper_on_hand(2000, @settings)
order_item(crafting_data['artificing'][@hometown]['stock-room'], 1)
order_item(crafting_data['artificing'][@hometown]['stock-room'], 6)
stow_hands
wait_for_script_to_complete('enchant', [2, 'flash trinket', 'totem'])
dispose_trash('totem')
elsif rank <= 100 # Tier 3 - Easy
# Buy an rarefaction sigil and wood totem
ensure_copper_on_hand(2000, @settings)
order_item(crafting_data['artificing'][@hometown]['stock-room'], 5)
order_item(crafting_data['artificing'][@hometown]['stock-room'], 6)
stow_hands
wait_for_script_to_complete('enchant', [2, 'wind trinket', 'totem'])
dispose_trash('totem')
elsif rank <= 175 # Tier 4 - Simple
# Buy an permutation sigil and wood totem
ensure_copper_on_hand(2000, @settings)
order_item(crafting_data['artificing'][@hometown]['stock-room'], 4)
order_item(crafting_data['artificing'][@hometown]['stock-room'], 6)
stow_hands
wait_for_script_to_complete('enchant', [2, 'earth trinket', 'totem'])
dispose_trash('totem')
elsif rank <= 300 # Tier 5 - Basic
# Buy an abolution and induction sigils and wood totem
ensure_copper_on_hand(2000, @settings)
order_item(crafting_data['artificing'][@hometown]['stock-room'], 1)
order_item(crafting_data['artificing'][@hometown]['stock-room'], 2)
stow_hands
order_item(crafting_data['artificing'][@hometown]['stock-room'], 6)
stow_hands
wait_for_script_to_complete('enchant', [3, 'basic holy ritual focus', 'totem'])
dispose_trash('totem')
elsif rank <= 425 # Tier 6 - Somewhat Challenging
# Buy a permutation and rarefaction sigils and runestone
ensure_copper_on_hand(4000, @settings)
order_item(crafting_data['artificing'][@hometown]['stock-room'], 4)
order_item(crafting_data['artificing'][@hometown]['stock-room'], 5)
stow_hands
buy_item(crafting_data['artificing'][@hometown]['stock-room'], 'runestone')
stow_hands
wait_for_script_to_complete('enchant', [6, 'strange arrow runestone', 'runestone'])
dispose_trash('runestone')
elsif rank <= 550 # Tier 7 - Challenging
echo('*** NOT YET IMPLEMENTED ***')
elsif rank <= 700 # Tier 8 - Complicated
echo('*** NOT YET IMPLEMENTED ***')
elsif rank <= 850 # Tier 9 - Intricate
echo('*** NOT YET IMPLEMENTED ***')
elsif rank <= 1175 # Tier 10 - Difficult
echo('*** NOT YET IMPLEMENTED ***')
else # Tier 11 Very Difficult
echo('*** NOT YET IMPLEMENTED ***')
end
end
def money_for_training?(amount, skill)
if ensure_copper_on_hand(amount, @settings)
true
else
echo("Low on funds, removing #{skill} from training")
@settings.crossing_training.delete(skill)
false
end
end
def sew(chapter, unique_name, item)
check_yarn
walk_to(@training_room)
check_listening
check_teaching
wait_for_script_to_complete('sew', ['trash', 'knitting', chapter, unique_name, item, 'wool'])
bput('stow my yarn', 'You put', 'Stow what')
end
def shape(chapter, unique_name, item)
check_wood
find_shaping_room(@hometown, @training_room)
check_listening
check_teaching
wait_for_script_to_complete('shape', ['trash', chapter, unique_name, 'maple', item])
bput('get my lumber', 'You get some', 'You pick up')
dispose_trash('lumber')
end
def smith(full_name)
wait_for_script_to_complete('smith', ['bronze', full_name, 'buy'])
dispose_trash(right_hand)
dispose_trash(left_hand)
end
def buy_wood
crafting_data = get_data('crafting')
return unless money_for_training?(1000, 'Engineering')
order_item(crafting_data['shaping'][@hometown]['stock-room'], 10)
bput('stow my lumber', 'You put your', 'Stow what')
end
def buy_yarn(skipcoin = false)
crafting_data = get_data('crafting')
ensure_copper_on_hand(3000, @settings) unless skipcoin
order_item(crafting_data['tailoring'][@hometown]['stock-room'], 13)
bput('combine my yarn', 'You combine', 'You must be holding both')
count = bput('count my yarn', 'You count out \d+ yards').scan(/\d+/).first.to_i
buy_yarn(true) if count < @yarn_quantity
stow_hands
end
def check_yarn
case DRC.bput('get my yarn', 'You get', 'You are already', 'What were you')
when 'What were you'
buy_yarn
when 'You get', 'You are already'
count = bput('count my yarn', 'You count out \d+ yards').scan(/\d+/).first.to_i
buy_yarn if count < @yarn_quantity
end
stow_hands
end
def check_wood
case bput('get my maple lumber', 'You get', 'You are already', 'What were you')
when 'What were you'
buy_wood
when 'You get', 'You are already'
count = bput('count my lumber', 'You count out \d+ pieces of lumber remaining').scan(/\d+/).first.to_i
buy_wood if count < 5
end
stow_hands
end
def check_teaching
return unless @settings.classes_to_teach
return if @settings.classes_to_teach.empty?
return if @last_teacher
if @class_timer.nil? || Time.now - @class_timer > 10 * 60
@settings.classes_to_teach.rotate!
bput('stop teach', 'You stop', 'you aren\'t teaching')
pause
@class_timer = Time.now
end
to_teach = @settings.classes_to_teach.first
DRRoom.pcs.each { |character| bput("teach #{to_teach} to #{character}", 'You begin to', 'is already listening to you', 'is listening to someone else', 'I could not find who you were referring to', 'You have already offered', 'That person is too busy teaching', 'You are already teaching', 'You cannot teach two different classes at the same time', 'is not paying attention to you', 'You cannot listen to a teacher and teach', 'already trying to teach you something') }
end
def check_listening
return unless @settings.listen
return if listen?(@last_teacher, @settings.listen_observe)
return if DRRoom.pcs.empty?
return unless @listen_timer.nil? || Time.now - @listen_timer > 5 * 60
return unless @class_timer.nil?
classes = assess_teach
@last_teacher = classes
.reject { |t, s| t.nil? || s.nil? }
.sort_by { |_t, s| [DRSkill.getxp(s), DRSkill.getrank(s)] }
.find { |t, _s| listen?(t, @settings.listen_observe) }
.first
@listen_timer = @last_teacher ? nil : Time.now
end
end
Craft.new