-
Notifications
You must be signed in to change notification settings - Fork 0
/
engineer.cmd
431 lines (382 loc) · 12.1 KB
/
engineer.cmd
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
include libmaster.cmd
include var_engineer.cmd
##############################
### Engineering
### USAGE: .engineer <number> <item> [design]
### EX: .engineer 3 bead weasel
###############################
###############################
### IDLE ACTION VARIABLES
###############################
action var eng.craft.nextTool shaper when ^Shaping with a wood shaper is needed to further smooth the material's surface\.
action var eng.craft.nextTool rasp when ^A bulbous knot will make continued shaping difficult unless rubbed out with a rasp\.
action var eng.craft.nextTool knife when ^The wood is ready to have more fine detail carved with a carving knife\.
action var eng.craft.nextTool engDone when ^Applying the final touches
action var eng.lumber $1 when ^You count out (\d+) pieces of lumber remaining\.$
action goto eng.cord when ^You need another finished short leather cord
action goto eng.strip when ^You need another finished leather strips
action goto eng.analyze when ^Applying the final touches
action goto eng.repairTools when ^The stamp is too badly damaged to be used for that\.$
action goto stunPause when ^You are stunned|^After a brief flare of pain, your senses go numb and you lose all muscular control
###############################
### VARIABLES
###############################
put #tvar eng.craft.item %2
put #tvar eng.craft.item.design 0
if_3 then {
put #tvar eng.craft.item.design %3
}
var eng.chapter 0
var eng.chapterLength 0
var eng.craft.nextTool 0
var eng.craft.numberCrafted 0
var eng.craft.numberNeeded %1
var eng.cut 0
var eng.page 0
if ("$charactername" = "Inauri") then put .look
gosub store default $char.inv.container.craft
goto eng.finishItem
###############################
### SETUP
###############################
eng.finishItem:
if ("$righthand" <> "Empty" && "$righthandnoun" = "$eng.craft.item") then {
matchre eng.exitError ^Roundtime
matchre eng.setNextTool (shaper|rasp|knife|cord|strap)
put analyze $eng.craft.item
matchwait 5
}
goto eng.checkLumber
eng.setNextTool:
var eng.craft.nextTool $1
if (%eng.craft.nextTool = 0) then {
put #echo >Log Yellow [eng] Unable to determine next tool for $righthand, exiting.
gosub stow
goto eng.exit
}
gosub eng.mainLoop
eng.checkLumber:
matchre eng.lumberCount ^.*\b(lumber)\b.*$
matchre eng.needLumberExit ^\[Use INVENTORY HELP for more options\.\]$
gosub inventory $char.inv.container.craft
matchwait 5
eng.lumberCount:
gosub count my lumber
if (%eng.cut = 0) then {
var eng.cut $eng.book.cut.$eng.craft.item
}
if (%eng.lumber < %eng.cut) then {
goto eng.needLumberExit
}
goto eng.prepareLumber
eng.prepareLumber:
gosub stow
gosub stow left
gosub get my lumber
if (%eng.lumber <> %eng.cut) then {
gosub mark my lumber at %eng.cut
gosub get my scissors
if ("$lefthandnoun" <> "scissors") then {
put #echo >Log Orange [eng] Scissors are missing, exiting.
gosub stow
goto eng.exit
}
gosub cut my lumber with my scissor
gosub stow
gosub stow left
gosub get my lumber
}
goto eng.prepareItem
eng.prepareItem:
gosub get my shaping book
if ("$lefthandnoun" <> "book") then {
goto eng.prepareItem
echo lefthandnoun: $lefthandnoun
put #echo >Log Orange [eng] Missing our shaping book, exiting.
gosub stow
goto eng.exit
}
gosub eng.findChapter
gosub turn my book to chapter %eng.chapter
# Action for finding book page because genie is dumb.
if ("$eng.craft.item" = "burin") then {
action var eng.page $1 when ^.*?Page (\d+)\: (a|an|some) fine wood $eng.craft.item(.*)$
}
if (matchre("$eng.craft.item", "bracelet|necklace|earrings|bead")) then {
action var eng.page $1 when ^.*?Page (\d+)\: (a|an|some) (articulated|detailed|pair of)? wood $eng.craft.item(.*)$
} else {
action var eng.page $1 when ^.*?Page (\d+)\: (a|an|some) wood $eng.craft.item(.*)$
}
gosub read my book
if (%eng.page = 0) then {
put #echo >Log Yellow [eng] Could not locate page for $eng.craft.item, exiting.
goto eng.exit
}
gosub turn my book to page %eng.page
gosub study my book
gosub stow my book
if ($eng.craft.item.design <> 0) then {
goto eng.prepareDesign
}
goto eng.main
# Use the defined craft item name to find the chapter and cut number.
eng.findChapter:
var eng.chapter 0
var eng.chapterGroup 0
if (contains("($eng.book.basics)", "$eng.craft.item")) then {
var eng.chapter 1
var eng.chapterGroup basics
}
if (contains("($eng.book.enhancements)", "$eng.craft.item")) then {
if (%eng.chapter = 0) then {
var eng.chapter 6
var eng.chapterGroup enhancements
}
}
if (contains("($eng.book.accessories)", "$eng.craft.item")) then {
if (%eng.chapter = 0) then {
var eng.chapter 7
var eng.chapterGroup accessories
}
}
if (contains("($eng.book.images)", "$eng.craft.item")) then {
if (%eng.chapter = 0) then {
var eng.chapter 8
var eng.chapterGroup images
}
}
if (contains("($eng.book.weaponry)", "$eng.craft.item")) then {
if (%eng.chapter = 0) then {
var eng.chapter 9
var eng.chapterGroup weaponry
}
}
if (%eng.chapter = 0) then {
put #echo >Log Yellow [eng] Failed to find design for $eng.craft.item, exiting.
goto eng.exit
}
if (%eng.cut = 0) then {
var eng.cut $eng.book.cut.$eng.craft.item
}
return
eng.prepareDesign:
var eng.chapter 0
var eng.page 0
gosub get my codex
if ("$lefthandnoun" <> "codex") then {
goto eng.prepareDesign
put #echo >Log Orange [eng] Design codex is missing, exiting.
gosub stow
goto eng.exit
}
if (contains("($eng.codex.races)", "$eng.craft.item.design")) then {
var eng.chapter 1
}
if (contains("($eng.codex.immortals)", "$eng.craft.item.design")) then {
if (%eng.chapter = 0) then {
var eng.chapter 2
}
}
if (contains("($eng.codex.animals)", "$eng.craft.item.design")) then {
if (%eng.chapter = 0) then {
var eng.chapter 3
}
}
if (%eng.chapter = 0) then {
put #echo >Log [eng] Failed to find design $eng.craft.item.design.
goto eng.exit
}
gosub turn my codex to chapter %eng.chapter
# Action for finding codex page because genie is dumb.
action var eng.page $1 when ^.*?Page (\d+)\: $eng.craft.item.design(.*)$
gosub read my codex
if (%eng.page = 0) then {
put #echo >Log Yellow [eng] Could not locate page for $eng.craft.item.design, exiting.
goto eng.exit
}
gosub turn my codex to page %eng.page
gosub study my codex
gosub stow my codex
goto eng.main
###############################
### MAIN
###############################
eng.main:
if ("$lefthandnoun" <> "drawknife") then {
gosub stow left
gosub get my drawknife
}
if ("$lefthandnoun" <> "drawknife") then {
goto eng.main
put #echo >Log Orange [eng] Drawknife missing!
gosub stow left
goto eng.exit
}
gosub scrape my lumber with my drawknife
gosub stow my drawknife
eng.mainLoop:
var eng.lastTool 0
if (%eng.craft.nextTool = 0) then {
put #echo >Log Yellow [eng] Unable to determine what the next tool is. Please fix script.
gosub stow
gosub stow left
goto eng.exit
}
if ("$lefthand" <> "Empty") then {
gosub stow left
}
if ("%eng.craft.nextTool" = "knife") then {
gosub get my carving knife
} else {
gosub get my %eng.craft.nextTool
}
if ("$lefthandnoun" = "Empty") then {
put #echo >Log Orange [eng] Tool missing! (%eng.craft.nextTool)
gosub stow left
goto eng.exit
}
var eng.lastTool %eng.craft.nextTool
var eng.craft.nextTool 0
gosub eng.%eng.lastTool
goto eng.mainLoop
###############################
### UTILITY
###############################
eng.analyze:
gosub stow left
if ("$righthandnoun" = "$char.craft.workorder.item") then {
gosub eng.stamp
}
gosub analyze $righthandnoun
gosub stow
evalmath eng.craft.numberCrafted (%eng.craft.numberCrafted + 1)
if (%eng.craft.numberNeeded > %eng.craft.numberCrafted) then {
put #echo >log Yellow [eng] Progress %eng.craft.numberCrafted/%eng.craft.numberNeeded
goto eng.checkLumber
}
goto eng.exit
eng.cord:
if ("$lefthand" <> "cord") then {
gosub stow left
gosub get my cord
}
if ("$lefthandnoun" <> "cord") then {
put #echo >Log Yellow [eng] Need cord to finish $eng.craft.item, exiting.
gosub stow
goto eng.exit
}
gosub assemble my $eng.craft.item with cord
return
eng.knife:
if ("$lefthand" <> "knife") then {
gosub stow left
gosub get my carving knife
}
if ("$lefthandnoun" <> "knife") then {
gosub eng.knife
put #echo >Log Orange [eng] Carving knife missing!
gosub stow
goto eng.exit
}
gosub carve my $eng.craft.item with my carving knife
gosub stow left
return
eng.rasp:
if ("$lefthandnoun" <> "rasp") then {
gosub stow left
gosub get my rasp
}
if ("$lefthandnoun" <> "rasp") then {
gosub eng.rasp
put #echo >Log Orange [eng] Rasp missing!
gosub stow
goto eng.exit
}
gosub scrape my $eng.craft.item with my rasp
gosub stow left
return
eng.repairTools:
if ("$lefthand" <> "Empty" || "$righthand" <> "Empty") then {
gosub stow
gosub stow left
}
put #var eng.repairNeeded 1
put #echo >log Pink [eng] Stamp is broken. Repair your tools.
goto eng.exit
eng.shaper:
if ("$lefthandnoun" <> "shaper") then {
gosub stow left
gosub get my wood shaper
}
if ("$lefthandnoun" <> "shaper") then {
gosub eng.shaper
put #echo >Log Orange [eng] Wood shaper missing!
gosub stow
goto eng.exit
}
gosub shape my $eng.craft.item with my shaper
gosub stow left
return
eng.stamp:
if ($eng.repairNeeded = 1) then {
return
}
if ("$lefthand" <> "stamp") then {
gosub stow left
gosub get my stamp
}
if ("$lefthand" = "Empty") then {
gosub eng.stamp
put #echo >Log Orange [eng] Stamp is missing!
return
}
gosub mark my $eng.craft.item with my stamp
gosub stow stamp
return
eng.strap:
if ("$lefthand" <> "strap") then {
gosub stow left
gosub get my strap
}
if ("$lefthandnoun" <> "strap") then {
put #echo >Log Yellow [eng] Need strap to finish $eng.craft.item, exiting.
gosub stow
goto eng.exit
}
gosub assemble my $eng.craft.item with strap
return
eng.stunPause:
if ($stunned <> 0) then {
pause 2
goto engStunPause
}
if (%eng.craft.nextTool <> 0) then {
gosub get my %eng.craft.nextTool
gosub get my $eng.craft.item
}
goto eng.finishItem
###############################
### EXIT
###############################
eng.exit:
if ("$righthand" <> "Empty" || "$lefthand" <> "Empty") then {
gosub stow
gosub stow left
}
put #echo >log yellow [eng] Engineering done.
gosub store default $char.inv.container.default
pause .2
put #parse ENGINEER DONE
exit
eng.exitError:
put #echo >Log Yellow [eng] Unable to determine next tool for $righthand.
goto eng.exit
eng.needLumberExit:
if ("$righthand" <> "Empty" || "$lefthand" <> "Empty") then {
gosub stow
gosub stow left
}
put #var eng.needLumber 1
put #echo >log yellow [eng] Need more lumber.
gosub store default $char.inv.container.default
goto eng.exit