-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDXM-UC_MineArea.py
378 lines (316 loc) · 15.5 KB
/
DXM-UC_MineArea.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
import sys
import math
from System.Collections.Generic import List
from System import Byte, Int32
###CONFIG SETTINGS###
petSerial = 0x0001E8A9
###---------------###
colors = {
'green': 65,
'cyan': 90,
'orange': 43,
'red': 1100,
'yellow': 52
}
pet = Mobiles.FindBySerial( petSerial )
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 = []
ScanZone = 24
global miningTool
self = Player.Serial
self_pack = Player.Backpack.Serial
forgesList = List[int]((0x197A, 0x197E, 0x19A2, 0x1982, 0x1992, 0x1996, 0x199A, 0x0FB1))
tinkerTools = [0x1EB8, 0x1EBC]
minerTools = [0x0F39, 0x0E86]
pickaxeID = 0x0F39 #0x0E86
journalEntryDelayMilliseconds = 200
targetClearDelayMilliseconds = 200
dragDelayMilliseconds = 700
class myItem:
name = None
itemID = None
color = None
category = None
weight = None
def __init__ ( self, name, itemID, color, category, weight ):
self.name = name
self.itemID = itemID
self.color = color
self.category = category
self.weight = weight
def FindItem( itemID, container, color = -1, ignoreContainer = [] ):
'''
Searches through the container for the item IDs specified and returns the first one found
Also searches through any subcontainers, which Misc.FindByID() does not
'''
ignoreColor = False
if color == -1:
ignoreColor = True
if isinstance( itemID, int ):
foundItem = next( ( item for item in container.Contains if ( item.ItemID == itemID and ( ignoreColor or item.Hue == color ) ) ), None )
elif isinstance( itemID, list ):
foundItem = next( ( item for item in container.Contains if ( item.ItemID in itemID and ( ignoreColor or item.Hue == color ) ) ), None )
else:
raise ValueError( 'Unknown argument type for itemID passed to FindItem().', itemID, container )
if foundItem != None:
return foundItem
subcontainers = [ item for item in container.Contains if ( item.IsContainer and not item.Serial in ignoreContainer ) ]
for subcontainer in subcontainers:
foundItem = FindItem( itemID, subcontainer, color, ignoreContainer )
if foundItem != None:
return foundItem
def FindNumberOfItems( itemID, container, color = -1 ):
'''
Recursively looks through a container for any items in the provided list
Returns the a dictionary with the number of items found from the list
'''
ignoreColor = False
if color == -1:
ignoreColor = True
# Create the dictionary
numberOfItems = {}
if isinstance( itemID, int ):
# Initialize numberOfItems
numberOfItems[ itemID ] = 0
# Populate numberOfItems
for item in container.Contains:
if item.ItemID == itemID and ( ignoreColor or item.Hue == color ):
numberOfItems[ itemID ] += item.Amount
elif isinstance( itemID, list ):
# Initialize numberOfItems
for ID in itemID:
numberOfItems[ ID ] = 0
# Populate numberOfItems
for item in container.Contains:
if item.ItemID in itemID and ( ignoreColor or item.Hue == color ):
numberOfItems[ item.ItemID ] += item.Amount
else:
raise ValueError( 'Unknown argument type for itemID passed to FindItem().', itemID, container )
subcontainers = [ item for item in container.Contains if item.IsContainer ]
# Iterate through each item in the given list
for subcontainer in subcontainers:
numberOfItemsInSubcontainer = FindNumberOfItems( itemID, subcontainer )
for ID in numberOfItems:
numberOfItems[ ID ] += numberOfItemsInSubcontainer[ ID ]
return numberOfItems
def MoveItem( Items, Misc, item, destinationBag, amount = 0 ):
Items.Move( item, destinationBag, amount )
Misc.Pause( config.dragDelayMilliseconds )
def ScanLandForOre( ):
global oreposcoords
Misc.SendMessage("--> Scanning Tiles in ScanZone", 77)
minx = Player.Position.X - ScanZone
maxx = Player.Position.X + ScanZone + 2
miny = Player.Position.Y - ScanZone
maxy = Player.Position.Y + ScanZone + 4
tmporeposcoords = []
while miny <= maxy:
while minx <= maxx:
tileLandID = Statics.GetLandID(minx, miny, Player.Map)
tileZ = Statics.GetLandZ(minx,minx, Player.Map)
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)
tmporeposcoords.Add([minx,miny,tileZ])
else:
Misc.NoOperation()
minx = minx + 1
minx = Player.Position.X - ScanZone
miny = miny + 1
oreposcoords = sorted(tmporeposcoords , key=lambda k: [k[1], k[0], k[2]])
Misc.SendMessage(oreposcoords.Count)
def MoveToOre(i):
if abs(Player.Position.X - oreposcoords [i][0]) > 5 or abs(Player.Position.Y - oreposcoords [i][1]) > 5:
if Player.Mount == None:
Mobiles.UseMobile( pet ) #remount
Misc.Pause( 650 )
staticOnTile = False
tileLandID = Statics.GetLandID(oreposcoords[i][0], oreposcoords[i][1], Player.Map)
tileinfo = Statics.GetStaticsTileInfo(oreposcoords[i][0], oreposcoords[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:
tileLandID = Statics.GetLandID(oreposcoords[i][0], oreposcoords[i][1]-1, Player.Map)
tileinfo = Statics.GetStaticsTileInfo(oreposcoords[i][0], oreposcoords[i][1]-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(oreposcoords[i][0], oreposcoords[i][1]+1, Player.Map)
tileinfo = Statics.GetStaticsTileInfo(oreposcoords[i][0], oreposcoords[i][1]+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(oreposcoords[i][0]-1, oreposcoords[i][1]-1, Player.Map)
tileinfo = Statics.GetStaticsTileInfo(oreposcoords[i][0]-1, oreposcoords[i][1]-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(oreposcoords[i][0]+1, oreposcoords[i][1]-1, Player.Map)
tileinfo = Statics.GetStaticsTileInfo(oreposcoords[i][0]+1, oreposcoords[i][1]-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(oreposcoords[i][0]-1, oreposcoords[i][1]-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' % (oreposcoords[i][0]+1, oreposcoords[i][1]+1, oreposcoords[i][2]), 76)
PathFinding.PathFindTo(oreposcoords[i][0]+1, oreposcoords[i][1]+1, oreposcoords[i][2])
else:
Misc.SendMessage('Moving to X: %i - Y: %i - Z: %i' % (oreposcoords[i][0]+1, oreposcoords[i][1]-1, oreposcoords[i][2]), 76)
PathFinding.PathFindTo(oreposcoords[i][0]+1, oreposcoords[i][1]-1, oreposcoords[i][2])
else:
Misc.SendMessage('Moving to X: %i - Y: %i - Z: %i' % (oreposcoords[i][0]-1, oreposcoords[i][1]-1, oreposcoords[i][2]), 76)
PathFinding.PathFindTo(oreposcoords[i][0]-1, oreposcoords[i][1]-1, oreposcoords[i][2])
else:
Misc.SendMessage('Moving to X: %i - Y: %i - Z: %i' % (oreposcoords[i][0], oreposcoords[i][1]+1, oreposcoords[i][2]), 76)
PathFinding.PathFindTo(oreposcoords[i][0], oreposcoords[i][1]+1, oreposcoords[i][2])
else:
Misc.SendMessage('Moving to X: %i - Y: %i - Z: %i' % (oreposcoords[i][0], oreposcoords[i][1]-1, oreposcoords[i][2]), 76)
PathFinding.PathFindTo(oreposcoords[i][0], oreposcoords[i][1]-1, oreposcoords[i][2])
else:
Misc.SendMessage('Moving to X: %i - Y: %i - Z: %i' % (oreposcoords[i][0], oreposcoords[i][1], oreposcoords[i][2]), 76)
PathFinding.PathFindTo(oreposcoords[i][0], oreposcoords[i][1], oreposcoords[i][2])
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)
if Player.Name == "Phill Myke Hunt":
Items.UseItem(item)
Target.WaitForTarget(5000,False)
Target.TargetExecute(0x00001CE2) #firebeetle
Misc.Pause( 500 )
else:
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.HeadMessage( colors[ 'green' ], "DONE MINING")
sys.exit(99) #turns script off
#while True:
if not Player.IsGhost:
oreposcoords = []
ScanLandForOre()
i = 0
wentHome = False
Misc.SendMessage("---")
Misc.SendMessage(oreposcoords.Count)
while i < oreposcoords.Count 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' % (oreposcoords[i][0], oreposcoords[i][1], oreposcoords[i][2]), 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)
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(oreposcoords[i][0], oreposcoords[i][1], Player.Map)
Target.TargetExecute(oreposcoords[i][0], oreposcoords[i][1], oreposcoords[i][2])
Misc.Pause( 2000 ) # Wait for the mining animation to complete
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()