-
Notifications
You must be signed in to change notification settings - Fork 0
/
DXM-UC_CraftFullSpellbook-loop.py
453 lines (364 loc) · 15.6 KB
/
DXM-UC_CraftFullSpellbook-loop.py
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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
from System.Collections.Generic import List
global pen, gumpID, player, lisignorescroll, storeduplicates, stoCont, manareq, craftspellbook, minresources, minpens, amounttorestock, progress, loopcount
manareq = 90 #This is the amount of mana you will meditate to for most spell circles if your mana is lower than spell cost
storeduplicates = True #This will save extra scrolls if you already have that spell in your current spellbook
fillspellbook = True #This will attempt to fill a spellbook with the scrolls you crafted
minresources = 5 #When your reags or scrolls fall below this amount, it will grab the amount of each missing supply that you choose on next line
amounttorestock = 10 #You can keep this low if there is a risk you may be PKed while crafting
minpens = 1 #How many pens you want to have on you at all times. Keep at least 2 just in case one breaks, but up to you.
minrune = 0 #How many blank runes to carry (for Runebook crafting)
craft = 'fillFromContainer' #This sets the crafting mode. Options (case sensitive): fullSpellBook, grindScroll, fillFromContainer, runebook.
#If you want to make one circle, just comment out the fullSpellBook circles at the bottom of script that you dont need
loopmode = False #Set this to True if you want it to keep making spell books
maxloops = 9
#########################
stoCont = Target.PromptTarget('Target your Storage Container')
Items.UseItem(stoCont)
Misc.Pause(2000)
regsList = [0x0F86,0x0F7B,0x0F8C,0x0F88,0x0F7A,0x0F8D,0x0F85,0x0F84,0x0EF3]
lisTupSupplies = [
('mandrakeroot', 0x0F86),
('bloodmoss', 0x0F7B),
('sulphurousash', 0x0F8C),
('nightshade', 0x0F88),
('blackpearl', 0x0F7A),
('spidersilk', 0x0F86),
('ginseng', 0x0F85),
('garlic', 0x0F84),
('blank scrolls', 0x0EF3),
('pen and ink', 0x0FBF)
]
dSupplies = dict(lisTupSupplies)
player = Mobiles.FindBySerial(Player.Serial)
def getSupplies(reagAmount = minresources):
needsupplies = False
outofstock = True
lisNeedResupply = []
for i in regsList:
if Items.BackpackCount(i,-1) < reagAmount:
needsupplies = True
try:
reg = Items.FindByID(i,-1,stoCont)
Misc.SendMessage('Taking %s' %(reg.Name))
Misc.Pause(500)
Items.Move(reg,Player.Backpack.Serial,amounttorestock)
Misc.Pause(1100)
except:
outofstock = True
lisNeedResupply.append(i)
if Items.BackpackCount(0x0FBF,-1) < minpens:
needsupplies = True
try:
takepen = Items.FindByID(0x0FBF,-1,stoCont)
Misc.SendMessage('Taking %s' %(takepen.Name))
Misc.Pause(500)
Items.Move(takepen,Player.Backpack.Serial, 1)
Misc.Pause(1100)
except:
outofstock = True
lisNeedResupply.append(i)
if craft == 'runebook':
if Items.BackpackCount(0x1F14,-1) < minrune:
needsupplies = True
try:
takerune = Items.FindByID(0x1F14,-1,stoCont)
Misc.SendMessage('Taking %s' %(takerune.Name))
Misc.Pause(500)
Items.Move(takerune,Player.Backpack.Serial, 1)
Misc.Pause(1100)
except:
outofstock = True
lisNeedResupply.append(i)
if craft != 'fillFromContainer':
if outofstock:
for i in lisNeedResupply:
lisNeededItem = []
lisNeededItemName = [k for k, v in dSupplies.items() if v == i]
while len(lisNeedResupply) >= 1:
Mobiles.Message(player, 92, 'Out of supplies: %s' %(lisNeededItemName))
Misc.Pause(500)
iterationCount = 0
for i in lisNeedResupply:
try:
item = Items.FindByID(i, -1, stoCont)
Misc.Pause(500)
Items.Move(item,Player.Backpack.Serial,amounttorestock)
lisNeedResupply.remove(i)
Misc.Pause(1100)
except:
Mobiles.Message(player, 35, 'Unable to find: %s' %(lisNeededItemName[iterationCount]))
iterationCount += 1
Misc.Pause(3500)
if needsupplies:
#Misc.SendMessage('Confirming if more supplies needed')
getSupplies()
def checkSpellbook():
global pen
spellbook = Items.FindByID(0x0EFA,0x0000,Player.Backpack.Serial)
equippedbook = Player.GetItemOnLayer('RightHand')
if not equippedbook:
Mobiles.Message(player,92, 'You must equip a full spellbook for this script to work, and please have an incomplete spellbook in backpack.')
return
if spellbook:
return spellbook
else:
Mobiles.Message(player, 35, 'No spell books found in backpack')
def checkPen():
global pen
try:
pen = Items.FindByID(0x0FBF,-1,Player.Backpack.Serial)
if not pen:
Mobiles.Message(player, 35, 'No Pens Found', True)
except:
Misc.SendMessage('Error in checkPen()', 35)
Misc.Pause(4000)
def checkMana(desiredMana):
while Player.Mana < desiredMana:
if not Timer.Check('SkillDelay'):
Player.UseSkill('Meditation')
Timer.Create('SkillDelay',11500)
else:
Mobiles.Message(player, 92, 'Meditating to %s mana' %(desiredMana))
Misc.Pause(1000)
def makeFirstCircle(spellbook, craft = True):
circle = 1
manacost = 10
checkfail = False
gumpNo = [1,2,9,16,23,30,37,44,51]
lisscrolls = [0x1F2E,0x1F2F,0x1F30,0x1F31,0x1F32,0x1F33,0x1F2D,0x1F34]
if not craft:
return lisscrolls
else:
makeScrolls(gumpNo, lisscrolls, circle, manacost, spellbook, checkfail)
def makeSecondCircle(spellbook, craft = True):
circle = 2
manacost = 10
checkfail = False
gumpNo = [1,58,65,72,79,86,93,100,107]
lisscrolls = [0x1F35,0x1F36,0x1F37,0x1F38,0x1F39,0x1F3A,0x1F3B,0x1F3C]
if not craft:
return lisscrolls
else:
makeScrolls(gumpNo, lisscrolls, circle, manacost, spellbook, checkfail)
def makeThirdCircle(spellbook, craft = True):
circle = 3
manacost = 10
checkfail = False
gumpNo = [8,2,9,16,23,30,37,44,51]
lisscrolls = [0x1F3D,0x1F3E,0x1F3F,0x1F40,0x1F41,0x1F42,0x1F43,0x1F44]
if not craft:
return lisscrolls
else:
makeScrolls(gumpNo, lisscrolls, circle, manacost, spellbook, checkfail)
def makeFourthCircle(spellbook, craft = True):
circle = 4
manacost = 11
checkfail = False
gumpNo = [8,58,65,72,79,86,93,100,107]
lisscrolls = [0x1F45,0x1F46,0x1F47,0x1F48,0x1F49,0x1F4A,0x1F4B,0x1F4C]
if not craft:
return lisscrolls
else:
makeScrolls(gumpNo, lisscrolls, circle, manacost, spellbook, checkfail)
def makeFifthCircle(spellbook, craft = True):
circle = 5
manacost = 14
checkfail = False
gumpNo = [15,2,9,16,23,30,37,44,51]
lisscrolls = [0x1F4D,0x1F4E,0x1F4F,0x1F50,0x1F51,0x1F52,0x1F53,0x1F54,]
if not craft:
return lisscrolls
else:
makeScrolls(gumpNo, lisscrolls, circle, manacost, spellbook, checkfail)
def makeSixthCircle(spellbook, craft = True):
circle = 6
manacost = 20
checkfail = False
gumpNo = [15,58,65,72,79,86,93,100,107]
lisscrolls = [0x1F55,0x1F56,0x1F57,0x1F58,0x1F59,0x1F5A,0x1F5B,0x1F5C]
if not craft:
return lisscrolls
else:
makeScrolls(gumpNo, lisscrolls, circle, manacost, spellbook, checkfail)
def makeSeventhCircle(spellbook, craft = True):
circle = 7
manacost = 40
checkfail = True
gumpNo = [22,2,9,16,23,30,37,44,51]
lisscrolls = [0x1F5D,0x1F5E,0x1F5F,0x1F60,0x1F61,0x1F62,0x1F63,0x1F64]
if not craft:
return lisscrolls
else:
makeScrolls(gumpNo, lisscrolls, circle, manacost, spellbook, checkfail)
def makeEighthCircle(spellbook, craft = True):
circle = 8
manacost = 50
checkfail = True
gumpNo = [22,58,65,72,79,86,93,100,107]
lisscrolls = [0x1F65,0x1F66,0x1F67,0x1F68,0x1F69,0x1F6A,0x1F6B,0x1F6C]
if not craft:
return lisscrolls
else:
makeScrolls(gumpNo, lisscrolls, circle, manacost, spellbook, checkfail)
def makeScrolls(gumpNo, lisscrolls, circle, manacost, spellbook, checkfail):
global pen, progress
for i in gumpNo:
#Med to full if you are out of mana
if Player.Mana < manacost:
checkMana(Player.ManaMax)
while True:
#Check supplies and pens
getSupplies()
checkPen()
Misc.Pause(500)
#Use pen if gump is not open and select the spell circle
if not Gumps.IsValid(gumpID):
Items.UseItem(pen)
Gumps.WaitForGump(gumpID, 1500)
Misc.Pause(1100)
if i == gumpNo[0]:
Misc.SendMessage('Selected spell circle')
Gumps.SendAction(gumpID, gumpNo[0])
Gumps.WaitForGump(gumpID, 1500)
Misc.Pause(500)
break
#Craft the spell
else:
mana = Player.Mana
Gumps.SendAction(gumpID, i)
Gumps.WaitForGump(gumpID, 1500)
Misc.Pause(350)
if Player.Mana < mana and checkfail:
if not craft == 'runebook': moveScrolls(lisscrolls)
break
elif checkfail:
checkprogress = progress
moveScrolls(lisscrolls)
if checkprogress < progress:
break
else:
Misc.NoOperation()
else:
if not craft == 'runebook': moveScrolls(lisscrolls)
break
def moveScrolls(lisscrolls, container = Player.Backpack.Serial):
global progress
#moveScrolls to SpellBook and store any duplicates if storeduplicates = True in settings
for i in lisscrolls:
scroll = Items.FindByID(i,-1,container)
if scroll and fillspellbook:
Misc.SendMessage("Adding %s to spellbook" %(scroll.Name))
progress += 1
Mobiles.Message(player, 35, '%d/64 spells completed' %(progress))
Items.Move(scroll,spellbook,1)
Misc.Pause(1100)
if Journal.Search('That spell is already'):
Journal.Clear()
if storeduplicates:
Misc.SendMessage('Storing %s' %(scroll.Name))
Items.Move(scroll,stoCont,-1)
Misc.Pause(750)
elif scroll and not fillspellbook:
Misc.SendMessage('Storing %s' %(scroll.Name))
Items.Move(scroll,stoCont,-1)
Misc.Pause(750)
def fillFromContainer(spellbook, lisScrolls, stoContContents):
for i in stoContContents:
if i.ItemID in lisScrolls:
Misc.SendMessage("Adding %s to spellbook" %(i.Name))
Items.Move(i,spellbook,1)
Misc.Pause(900)
def Initiate():
global pen, gumpID, progress, loopcount
progress = 0
loopcount += 1
while True:
runebook = Items.FindByID(0x0EFA, 0x0461, Player.Backpack.Serial, -1, True)
if runebook:
Misc.IgnoreObject(runebook)
else:
break
getSupplies()
pen = Items.FindByID(0x0FBF,-1,Player.Backpack.Serial)
if pen:
Items.UseItem(pen)
maxloop = 0
while not Gumps.HasGump() and maxloop <= 3:
Misc.Pause(1000)
maxloop += 1
if Gumps.HasGump():
Mobiles.Message(player, 92, 'Inscribe gump set successfully')
gumpID = Gumps.CurrentGump()
else:
Mobiles.Message(player, 92, 'No gumpID detected set to default of 949095101')
gumpID = 949095101
else:
Mobiles.Message(player, 92, 'No Pens found in backpack')
loopcount = 0
while True:
Initiate() #Ensures you have the minimum resources and fetches your gumpID (for servers where the scribe gump ID changes)
if not craft == 'runebook': #Finds a spellbook in your pack to try filling, or skips it if you are making runebooks
spellbook = checkSpellbook()
if spellbook:
Items.Message(spellbook, 35, 'Filling this spellbook')
else:
Mobiles.Message(Player.Serial,35,"No spellbooks left",1)
Misc.Pause(500)
if craft == 'grindScroll':
gumpNo = [22,72]
while True:
makeScrolls(gumpNo, [], 8, 50, False, False)#(gumpNo, lisscrolls, circle, manacost, spellbook, checkfail)
item = Items.FindByID(0x1F67,0x0000,Player.Backpack.Serial)
if item: Items.Move(item,stoCont,-1)
if craft == 'fullSpellBook':
makeFirstCircle(spellbook) #Comment out any of these functions to skip a spell circle
makeSecondCircle(spellbook)
makeThirdCircle(spellbook)
makeFourthCircle(spellbook)
makeFifthCircle(spellbook)
makeSixthCircle(spellbook)
makeSeventhCircle(spellbook)
makeEighthCircle(spellbook)
elif craft == 'fillFromContainer': #This mode will fill spellbooks from the scrolls sitting in your storage container
stoContItem = Items.FindBySerial(stoCont)
stoContContents = stoContItem.Contains
lisScrolls = makeFirstCircle(spellbook, False)
fillFromContainer(spellbook, lisScrolls,stoContContents)
lisScrolls = makeSecondCircle(spellbook, False)
fillFromContainer(spellbook, lisScrolls,stoContContents)
lisScrolls = makeThirdCircle(spellbook, False)
fillFromContainer(spellbook, lisScrolls,stoContContents)
lisScrolls = makeFourthCircle(spellbook, False)
fillFromContainer(spellbook, lisScrolls,stoContContents)
lisScrolls = makeFifthCircle(spellbook, False)
fillFromContainer(spellbook, lisScrolls,stoContContents)
lisScrolls = makeSixthCircle(spellbook, False)
fillFromContainer(spellbook, lisScrolls,stoContContents)
lisScrolls = makeSeventhCircle(spellbook, False)
fillFromContainer(spellbook, lisScrolls,stoContContents)
lisScrolls = makeEighthCircle(spellbook, False)
fillFromContainer(spellbook, lisScrolls,stoContContents)
if craft == 'runebook':
lisTupSupplies.append(('blank rune', 0x1F14))
if minresources < 8: minresources = 8 #Number of scrolls required to make a rune book
## Make a recall scroll ##
gumpNo = [22,51]
makeScrolls(gumpNo, [], 4, 11, False, False)#Doesn't check for craft failure
## Make a gate scroll ##
gumpNo = [43,23]
makeScrolls(gumpNo, [], 7, 40, False, True) #Checks for craft failure
## Make runebook ##
gumpNo = [57,2]
makeScrolls(gumpNo, [], 1, 0, False, False)#Doesn't check for craft failure
Misc.Pause(650)
if craft == 'runebook':
spellbook = Items.FindByID(0x0EFA, 0x0461, Player.Backpack.Serial, -1, True)
try:
Items.Move(spellbook,stoCont,0)
except:
Mobiles.Message(player, 35, 'No spellbook or runebook found in backpack')
if not loopmode:
break
else:
if loopcount >= maxloops: break
Misc.Pause(900)