-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDextrome_Unchained_Mining.py
More file actions
538 lines (465 loc) · 21 KB
/
Dextrome_Unchained_Mining.py
File metadata and controls
538 lines (465 loc) · 21 KB
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
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
import sys
import math
from System.Collections.Generic import List
from System import Byte, Int32
from Scripts.utilities.items import FindItem, FindNumberOfItems, MoveItem
from Scripts.glossary.items.ores import ores
from Scripts.glossary.colors import colors
import clr
clr.AddReference('System.Speech')
from System.Speech.Synthesis import SpeechSynthesizer
if Player.Name == "Shmolas":
storageShelfSerial = 0x401B271D
vaultSerial = 0x4028C99B
petSerial = 0x00013F18
pet = Mobiles.FindBySerial( petSerial )
runeBookSerial = 0x4034E9C4
# targetRunebook = False
# canCastRecall = False
# homeRuneIndex = 10
targetRunebook = True
canCastRecall = True
toolbagSerial = 0x4046965F #can be a container in your bank(vault) or just a container within range
numberOfRunes = 6
homeforgeSerial = 0x402DDABC
resourceShelfSerial = 0x402DD22C
elif Player.Name == "Phill Myke Hunt":
storageShelfSerial = 0x401B271D
vaultSerial = 0x4028C99B
petSerial = 0x000022F6
pet = Mobiles.FindBySerial( petSerial )
runeBookSerial = 0x401444C6
targetRunebook = True
canCastRecall = True
toolbagSerial = 0x400CBA40 #can be a container in your bank(vault) or just a container within range
numberOfRunes = 8
homeforgeSerial = 0x402DDABC
resourceShelfSerial = 0x402DD22C
captchaGumpId = 1565867016
checkForAnyGump = True
oreLandIDs = [0x00F1, 0x00F2, 0x00F3, 0x00F0, 0x023A]
oreStaticIDs = [0x053B, 0x053C, 0x053D, 0x053E, 0x053F]
forgesList = [0x197A, 0x197E, 0x19A2, 0x1982, 0x1992, 0x1996, 0x199A, 0x0FB1]
oreposx = []
oreposy = []
oreposz = []
miningAttemptsSinceLastCaptcha = 0
ScanZone = 16
global miningTool
#generic
self = Player.Serial
self_pack = Player.Backpack.Serial
##types lists
forgesList = List[int]((0x197A, 0x197E, 0x19A2, 0x1982, 0x1992, 0x1996, 0x199A, 0x0FB1))
tinkerTools = [0x1EB8, 0x1EBC]
minerTools = [0x0F39, 0x0E86]
pickaxeID = 0x0F39 #0x0E86
## msg stubs
smeltSuccess = 'You smelt the ore removing the impurities and put the metal in your backpack.'
smeltFail = 'You burn away the impurities but are left with less useable metal.'
spk = SpeechSynthesizer()
def sayTTS(text):
spk.Speak(text)
def GetGM():
enemyfil = Mobiles.Filter()
enemyfil.Enabled = True
enemyfil.RangeMin = 0
enemyfil.RangeMax = 8
enemyfil.ZLevelMin = Player.Position.Z -8
enemyfil.ZLevelMax = Player.Position.Z +8
enemyfil.CheckLineOfSight = True
enemyfil.Friend = False
#enemyfil.IsHuman = True
enemyfil.Notorieties = List[Byte](bytes([7]))
enemyList = Mobiles.ApplyFilter(enemyfil)
gm = Mobiles.Select(enemyList, 'Nearest')
return gm
def ScanLandForOre( ):
global orenumber
Misc.SendMessage("--> Scanning Tiles in ScanZone", 77)
minx = Player.Position.X - ScanZone + 2
maxx = Player.Position.X + ScanZone + 4
miny = Player.Position.Y - ScanZone + 2
maxy = Player.Position.Y + ScanZone + 8
while miny <= maxy/2 - 1:
while minx <= maxy/2 - 1:
#tileinfo = Statics.GetStaticsTileInfo(minx, miny, Player.Map)
tileLandID = Statics.GetLandID(minx, miny, Player.Map)
tileZ = Statics.GetLandZ(minx,minx, Player.Map)
# if tileinfo.Count > 0:
# for tile in tileinfo:
# for staticid in oreStaticIDs:
# if staticid == tile.StaticID:
# Misc.SendMessage('-> Ore found at X: %i - Y: %i - Z: %i' % (minx, miny, tile.StaticZ), 66)
# oreposx.Add(minx)
# oreposy.Add(miny)
# oreposz.Add(tile.StaticZ)
if tileLandID != None:
for landID in oreLandIDs:
if landID == tileLandID:
tileinfo = Statics.GetStaticsTileInfo(minx, miny, Player.Map)
validTile = True
if tileinfo.Count > 0:
for tile in tileinfo:
if tile.StaticID != 0x0000 or tileLandID == None:
validTile = False
if validTile:
Misc.SendMessage('-> Ore found at X: %i - Y: %i - Z: %i' % (minx, miny, tileZ), 66)
oreposx.Add(minx)
oreposy.Add(miny)
oreposz.Add(tileZ)
else:
Misc.NoOperation()
minx = minx + 1
minx = Player.Position.X - ScanZone
miny = miny + 1
while miny <= maxy:
while minx <= maxx:
#tileinfo = Statics.GetStaticsTileInfo(minx, miny, Player.Map)
tileLandID = Statics.GetLandID(minx, miny, Player.Map)
tileZ = Statics.GetLandZ(minx,minx, Player.Map)
# if tileinfo.Count > 0:
# for tile in tileinfo:
# for staticid in oreStaticIDs:
# if staticid == tile.StaticID:
# Misc.SendMessage('-> Ore found at X: %i - Y: %i - Z: %i' % (minx, miny, tile.StaticZ), 66)
# oreposx.Add(minx)
# oreposy.Add(miny)
# oreposz.Add(tile.StaticZ)
if tileLandID != None:
for landID in oreLandIDs:
if landID == tileLandID:
tileinfo = Statics.GetStaticsTileInfo(minx, miny, Player.Map)
validTile = True
if tileinfo.Count > 0:
for tile in tileinfo:
if tile.StaticID != 0x0000 or tileLandID == None:
validTile = False
if validTile:
Misc.SendMessage('-> Ore found at X: %i - Y: %i - Z: %i' % (minx, miny, tileZ), 66)
oreposx.Add(minx)
oreposy.Add(miny)
oreposz.Add(tileZ)
else:
Misc.NoOperation()
minx = minx + 1
minx = Player.Position.X - ScanZone
miny = miny + 1
orenumber = oreposx.Count
Misc.SendMessage('--> Total Ore Tiles: %i' % (orenumber), 77)
def MoveToOre(i):
#Misc.SendMessage('distance X: %i' % abs(Player.Position.X - oreposx[i]) )
#Misc.SendMessage('distance Y: %i' % abs(Player.Position.Y - oreposy[i]) )
if abs(Player.Position.X - oreposx[i]) > 5 or abs(Player.Position.Y - oreposy[i]) > 5:
if Player.Mount == None:
Mobiles.UseMobile( pet ) #remount
Misc.Pause( 650 )
staticOnTile = False
tileLandID = Statics.GetLandID(oreposx[i], oreposy[i], Player.Map)
tileinfo = Statics.GetStaticsTileInfo(oreposx[i], oreposy[i], Player.Map)
landFlag_Impassable = Statics.GetLandFlag(tileLandID, "Impassable")
if landFlag_Impassable == True:
staticOnTile = True
elif tileinfo.Count > 0:
for tile in tileinfo:
if tile.StaticID != 0x0000 or tileLandID == None:
staticOnTile = True
if staticOnTile == True:
tileLandID = Statics.GetLandID(oreposx[i], oreposy[i]-1, Player.Map)
tileinfo = Statics.GetStaticsTileInfo(oreposx[i], oreposy[i]-1, Player.Map)
landFlag_Impassable = Statics.GetLandFlag(tileLandID, "Impassable")
if landFlag_Impassable == True:
staticOnTile = True
elif tileinfo.Count > 0:
for tile in tileinfo:
if tile.StaticID != 0x0000 or tileLandID == None:
staticOnTile = True
if staticOnTile == True:
staticOnTile = False
tileLandID = Statics.GetLandID(oreposx[i], oreposy[i]+1, Player.Map)
tileinfo = Statics.GetStaticsTileInfo(oreposx[i], oreposy[i]+1, Player.Map)
landFlag_Impassable = Statics.GetLandFlag(tileLandID, "Impassable")
if landFlag_Impassable == True:
staticOnTile = True
elif tileinfo.Count > 0:
for tile in tileinfo:
if tile.StaticID != 0x0000 or tileLandID == None or landFlag_Impassable == True:
staticOnTile = True
if staticOnTile == True:
staticOnTile = False
tileLandID = Statics.GetLandID(oreposx[i]-1, oreposy[i]-1, Player.Map)
tileinfo = Statics.GetStaticsTileInfo(oreposx[i]-1, oreposy[i]-1, Player.Map)
landFlag_Impassable = Statics.GetLandFlag(tileLandID, "Impassable")
if landFlag_Impassable == True:
staticOnTile = True
elif tileinfo.Count > 0:
for tile in tileinfo:
if tile.StaticID != 0x0000 or tileLandID == None:
staticOnTile = True
if staticOnTile == True:
staticOnTile = False
tileLandID = Statics.GetLandID(oreposx[i]+1, oreposy[i]-1, Player.Map)
tileinfo = Statics.GetStaticsTileInfo(oreposx[i]+1, oreposy[i]-1, Player.Map)
landFlag_Impassable = Statics.GetLandFlag(tileLandID, "Impassable")
if landFlag_Impassable == True:
staticOnTile = True
elif tileinfo.Count > 0:
for tile in tileinfo:
if tile.StaticID != 0x0000 or tileLandID == None:
staticOnTile = True
if staticOnTile == True:
staticOnTile = False
tileinfo = Statics.GetStaticsTileInfo(oreposx[i]-1, oreposy[i]-1, Player.Map)
landFlag_Impassable = Statics.GetLandFlag(tileLandID, "Impassable")
if landFlag_Impassable == True:
staticOnTile = True
elif tileinfo.Count > 0:
for tile in tileinfo:
if tile.StaticID != 0x0000 or tileLandID == None:
staticOnTile = True
if staticOnTile == True:
Misc.NoOperation()
Misc.SendMessage('cant move to target', 56)
else:
Misc.SendMessage('Moving to X: %i - Y: %i - Z: %i' % (oreposx[i]+1, oreposy[i]+1, oreposz[i]), 76)
PathFinding.PathFindTo(oreposx[i]+1, oreposy[i]+1, oreposz[i])
else:
Misc.SendMessage('Moving to X: %i - Y: %i - Z: %i' % (oreposx[i]+1, oreposy[i]-1, oreposz[i]), 76)
PathFinding.PathFindTo(oreposx[i]+1, oreposy[i]-1, oreposz[i])
else:
Misc.SendMessage('Moving to X: %i - Y: %i - Z: %i' % (oreposx[i]-1, oreposy[i]-1, oreposz[i]), 76)
PathFinding.PathFindTo(oreposx[i]-1, oreposy[i]-1, oreposz[i])
else:
Misc.SendMessage('Moving to X: %i - Y: %i - Z: %i' % (oreposx[i], oreposy[i]+1, oreposz[i]), 76)
PathFinding.PathFindTo(oreposx[i], oreposy[i]+1, oreposz[i])
else:
Misc.SendMessage('Moving to X: %i - Y: %i - Z: %i' % (oreposx[i], oreposy[i]-1, oreposz[i]), 76)
PathFinding.PathFindTo(oreposx[i], oreposy[i]-1, oreposz[i])
else:
Misc.SendMessage('Moving to X: %i - Y: %i - Z: %i' % (oreposx[i], oreposy[i], oreposz[i]), 76)
PathFinding.PathFindTo(oreposx[i], oreposy[i], oreposz[i])
def MoveOreToPet():
pet = Mobiles.FindBySerial( petSerial )
if pet == None:
Player.HeadMessage( colors[ 'red' ], 'Could not find storage pet!' )
# Mobiles.UseMobile( Player.Serial ) #dismount
# Misc.Pause( 650 )
Misc.WaitForContext(pet, 10000)
Misc.ContextReply(pet, "Open Backpack")
Misc.Pause( 650 )
for item in Player.Backpack.Contains:
if item.ItemID == 0x19B9: #ore
Journal.Clear()
Misc.Pause(200)
Misc.SendMessage('Moving %s to %s' % (item.Name, pet.Name))
Items.Move(item.Serial,Mobiles.FindBySerial( petSerial ).Backpack,0)
Misc.Pause( 650 )
def GoHome():
Player.ChatSay("all follow me")
Misc.Pause(1000)
#while (Gumps.CurrentGump() != 0 and checkForAnyGump) or Gumps.CurrentGump() == captchaGumpId:
while Gumps.HasGump(captchaGumpId):
sayTTS("%s Captcha Alert" % (Player.Name))
Misc.Pause(666)
if Player.Mount == None:
mount = Mobiles.FindBySerial( petSerial )
if mount != None:
Mobiles.UseMobile( mount )
if targetRunebook and canCastRecall:
Spells.Cast("Recall")
Target.WaitForTarget(5000)
Target.TargetExecute(runeBookSerial) #runebook
elif not targetRunebook:
if canCastRecall:
Misc.NoOperation() #TODO: implement going to runeindex page and click the recall button
else:
Items.UseItem(runeBookSerial) #runebook
Gumps.WaitForGump(89, 10000)
Gumps.SendAction(89, homeRuneIndex) #home location
Misc.Pause(5000)
Misc.Pause( 650 )
#Player.Walk("Right")
if Player.Name == "Shmolas":
if Player.Direction == "Left":
Player.Walk("Left")
Misc.Pause( 50 )
else:
Player.Walk("Left")
Misc.Pause( 50 )
Player.Walk("Left")
Misc.Pause( 50 )
Mobiles.UseMobile( Player.Serial ) #dismount
Misc.Pause( 650 )
Misc.WaitForContext(petSerial, 10000)
Misc.ContextReply(petSerial, "Open Backpack")
Misc.Pause( 650 )
# storageBox = Items.FindBySerial( 0x40018161 )
# Items.UseItem( storageBox )
# Misc.Pause( 650 )
#smelt ores into ingots
for item in Player.Backpack.Contains:
if item.ItemID == 0x19B9: #ore
Items.UseItem(item)
Target.WaitForTarget(5000,False)
Target.TargetExecute(homeforgeSerial) #forge
Misc.Pause( 500 )
pet = Mobiles.FindBySerial( petSerial )
if not pet:
Mobiles.UseMobile( Player.Serial ) #dismount
Misc.Pause( 650 )
for item in pet.Backpack.Contains:
if item.ItemID == 0x19B9: #ore
Items.UseItem(item)
Target.WaitForTarget(5000,False)
Target.TargetExecute(homeforgeSerial) #forge
Misc.Pause( 500 )
#move ingots manually
# pickaxecounter = 0
#
# for item in Player.Backpack.Contains:
# if item.ItemID == 0x1BF2: #ingot
# MoveItem( Items, Misc, item, storageBox )
# Misc.Pause( 650 )
# elif item.ItemID == 0x0E86:
# pickaxecounter += 1
#Use resource shelf for storing ingots and getting pickaxes/shovels
Items.UseItem(resourceShelfSerial)
Gumps.WaitForGump(111922706, 10000)
Misc.Pause(50)
Gumps.SendAction(111922706, 123) #fill from backpack
Gumps.WaitForGump(111922706, 10000)
Misc.Pause(50)
Gumps.SendAction(111922706, 125) #next page
Gumps.WaitForGump(111922706, 10000)
Misc.Pause(50)
Gumps.SendAction(111922706, 125) #next page
Gumps.WaitForGump(111922706, 10000)
Misc.Pause(50)
Gumps.SendAction(111922706, 60) #get shovel
Gumps.WaitForGump(111922706, 10000)
Misc.Pause(50)
Gumps.SendAction(111922706, 0) #close gump
Misc.Pause(250)
pet = Mobiles.FindBySerial( petSerial )
Mobiles.UseMobile( pet ) #remount
Misc.Pause( 650 )
#open bank vault
vault = Items.FindBySerial(vaultSerial)
Items.UseItem( vault )
Misc.Pause( 650 )
#get pickaxes from bag in bank
# if pickaxecounter < 2:
# toolbag = Items.FindBySerial(toolbagSerial)
# Items.UseItem( toolbag )
# Misc.Pause( 650 )
# tooltomove = Items.FindByID(0x0E86,-1,toolbag.Serial)
# if tooltomove:
# MoveItem( Items, Misc, tooltomove, Player.Backpack )
# Misc.Pause( 650 )
# tooltomove = Items.FindByID(0x0E86,-1,toolbag.Serial)
# if tooltomove:
# MoveItem( Items, Misc, tooltomove, Player.Backpack )
# Misc.Pause( 650 )
#refill recall scrolls from bank to runebook
if not canCastRecall:
recallscrolls = Items.FindByID(0x1F4C,-1,Player.Bank.Serial, 2)
if recallscrolls:
Items.Move(recallscrolls.Serial, runeBookSerial, 2)
Misc.Pause( 650 )
else:
Misc.WaitForContext(storageShelfSerial, 10000)
Misc.ContextReply(storageShelfSerial, 1)
Target.WaitForTarget(10000, False)
Misc.Pause( 950 )
Target.Self()
Misc.Pause( 950 )
Gumps.SendAction(2834126535, 3637)
Misc.Pause( 950 )
Gumps.SendAction(2834126535, 0)
Misc.Pause( 950 )
#sys.exit(99) #turns script off
#while True:
for iRune in range(1,numberOfRunes):
Player.HeadMessage(138, "recall to next spot")
Items.UseItem(runeBookSerial)
Misc.Pause(600)
Gumps.WaitForGump( 89, 10000 )
if canCastRecall:
Gumps.SendAction( 89, 50 + iRune )
else:
Gumps.SendAction(89, 10 + iRune)
Misc.Pause(2500)
oreposx = []
oreposy = []
oreposz = []
ScanLandForOre()
i = 0
wentHome = False
while i < orenumber and wentHome == False:
pet = Mobiles.FindBySerial( petSerial )
if pet == None and Player.Mount == None:
Player.HeadMessage( colors[ 'red' ], 'Could not find storage pet!' )
#Misc.SendMessage('Target = X: %i - Y: %i - Z: %i' % (oreposx[i], oreposy[i], oreposz[i]), 66)
MoveToOre(i)
if Player.Mount != None:
Mobiles.UseMobile( Player.Serial ) #dismount
Misc.Pause( 650 )
Misc.UseContextMenu(petSerial,"Command: Guard",1000)
Journal.Clear()
Misc.Pause(200)
# iteminhand = Player.GetItemOnLayer("RightHand")
# if not iteminhand:
# pickaxe = Items.FindByID(pickaxeID, -1, Player.Backpack.Serial)
# Misc.Pause(200)
# if pickaxe:
# Misc.SendMessage("equipping pickaxe")
# Player.EquipItem(pickaxe)
# Misc.Pause( 650 )
pickaxe = Items.FindByID(pickaxeID, -1, Player.Backpack.Serial)
while ( not Journal.SearchByName( 'There is no metal here to mine.', 'System' ) and
not Journal.SearchByName( 'Target cannot be seen.', 'System' ) and
not Journal.SearchByName( 'You can\'t mine there.', 'System' ) and
not Journal.SearchByName( 'That is too far away.', 'System' ) and
not Journal.SearchByName( 'You have worn out your tool!', 'System' ) ):
while Gumps.HasGump(captchaGumpId):
sayTTS("%s Captcha Alert" % (Player.Name))
Misc.Pause(666)
while GetGM():
sayTTS("%s GM Alert" % (Player.Name))
Misc.SendMessage("%s Mining Attempt Since Last Captcha" % (miningAttemptsSinceLastCaptcha))
Misc.Pause(555)
if Player.Weight <= Player.MaxWeight - 20:
#Player.HeadMessage(99,"mining")
# iteminhand = Player.GetItemOnLayer("RightHand")
# if not iteminhand:
# pickaxe = Items.FindByID(pickaxeID, -1, Player.Backpack.Serial)
# else:
# pickaxe = iteminhand
pickaxe = Items.FindByID(pickaxeID, -1, Player.Backpack.Serial)
if pickaxe:
#Misc.SendMessage("using pickaxe")
Items.UseItem(pickaxe)
Target.WaitForTarget(2500,False)
tileinfo = Statics.GetStaticsTileInfo(oreposx[i], oreposy[i], Player.Map)
Target.TargetExecute(oreposx[i], oreposy[i], oreposz[i])
Misc.Pause( 500 )
miningAttemptsSinceLastCaptcha += 1
if Journal.SearchByType( 'Target cannot be seen.', 'Regular' ):
Journal.Clear()
break
Misc.Pause( 500 ) # Wait for the mining animation to complete and then call the guards in case an elemental appears
else:
#GoHome()
wentHome = True
break
else:
Player.HeadMessage(99,"overweight")
MoveOreToPet()
if Journal.Search("You are overloaded") or Player.Weight >= Player.MaxWeight - 20:
Misc.SendMessage('Overloaded time to go home')
#GoHome()
wentHome = True
break
Misc.Pause( 50 )
i+=2
GoHome()