-
Notifications
You must be signed in to change notification settings - Fork 0
/
lumberjack.py
297 lines (257 loc) · 11.3 KB
/
lumberjack.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
import sys
from System.Collections.Generic import List
from Scripts.utilities.items import MoveItem
from Scripts import config
import clr
clr.AddReference('System.Speech')
from System.Speech.Synthesis import SpeechSynthesizer
###CONFIG
beetle = 0x0000DFE5
homeRuneSerial = 0x401444C6
vaultSerial = 0x4028C99B
####
spk = SpeechSynthesizer()
tileinfo = List[Statics.TileInfo]
treeposx = []
treeposy = []
treeposz = []
treegfx = []
treenumber = 0
toolid = 0x0F43 #set chopping tool graphic id defaulted as hatchet
maxweight = 375
TreeStaticID = [3221, 3222, 3225, 3227, 3228, 3229, 3210, 3238, 3240, 3242, 3243, 3267, 3268, 3272, 3273, 3274, 3275, 3276, 3277, 3280, 3283, 3286, 3288, 3290, 3293, 3296, 3299, 3302, 3320, 3323, 3326, 3329, 3365, 3367, 3381, 3383, 3384, 3394, 3395, 3417, 3440, 3461, 3476, 3478, 3480, 3482, 3484, 3486, 3488, 3490, 3492, 3496]
RaggioScansione = 18
boardID = 0x1BD7
compendium = 0x4007AC82
captchaGumpId = 1565867016
checkForAnyGump = True
resourceShelfSerial = 0x402DD22C
harvestAttemptsSinceLastCaptcha = 0
def sayTTS(text):
spk.Speak(text)
def ScanStatic( ):
global treenumber
Misc.SendMessage("--> Inizio Scansione Tile", 77)
minx = Player.Position.X - RaggioScansione
maxx = Player.Position.X + RaggioScansione
miny = Player.Position.Y - RaggioScansione
maxy = Player.Position.Y + RaggioScansione
while miny <= maxy:
while minx <= maxx:
tileinfo = Statics.GetStaticsTileInfo(minx, miny, Player.Map)
if tileinfo.Count > 0:
for tile in tileinfo:
for staticid in TreeStaticID:
if staticid == tile.StaticID:
Misc.SendMessage('--> Albero X: %i - Y: %i - Z: %i' % (minx, miny, tile.StaticZ), 66)
treeposx.Add(minx)
treeposy.Add(miny)
treeposz.Add(tile.StaticZ)
treegfx.Add(tile.StaticID)
else:
Misc.NoOperation()
minx = minx + 1
minx = Player.Position.X - RaggioScansione
miny = miny + 1
treenumber = treeposx.Count
Misc.SendMessage('--> Totale Alberi: %i' % (treenumber), 77)
#
#while not Player.IsGhost:
# Player.HeadMessage(90, "PathFinding")
#
# PathFinding.PathFindTo(975,1608,0)
# PathFinding.PathFindTo(965,1604,0)
# PathFinding.PathFindTo(973,1596,0)
def MoveToTree(i):
staticOnTile = False
tileinfo = Statics.GetStaticsTileInfo(treeposx[i], treeposy[i]-1, Player.Map)
if tileinfo.Count > 0:
for tile in tileinfo:
if tile.StaticID != 0x0000:
staticOnTile = True
if staticOnTile == True:
staticOnTile = False
tileinfo = Statics.GetStaticsTileInfo(treeposx[i], treeposy[i]+1, Player.Map)
if tileinfo.Count > 0:
for tile in tileinfo:
if tile.StaticID != 0x0000:
staticOnTile = True
if staticOnTile == True:
staticOnTile = False
tileinfo = Statics.GetStaticsTileInfo(treeposx[i]-1, treeposy[i]-1, Player.Map)
if tileinfo.Count > 0:
for tile in tileinfo:
if tile.StaticID != 0x0000:
staticOnTile = True
if staticOnTile == True:
staticOnTile = False
tileinfo = Statics.GetStaticsTileInfo(treeposx[i]+1, treeposy[i]-1, Player.Map)
if tileinfo.Count > 0:
for tile in tileinfo:
if tile.StaticID != 0x0000:
staticOnTile = True
if staticOnTile == True:
#staticOnTile = False
# tileinfo = Statics.GetStaticsTileInfo(treeposx[i]-1, treeposy[i]-1, Player.Map)
# if tileinfo.Count > 0:
# for tile in tileinfo:
# if tile.StaticID != 0x0000:
# staticOnTile = True
PathFinding.PathFindTo(treeposx[i]+1, treeposy[i]+1, treeposz[i])
else:
PathFinding.PathFindTo(treeposx[i]+1, treeposy[i]-1, treeposz[i])
else:
PathFinding.PathFindTo(treeposx[i]-1, treeposy[i]-1, treeposz[i])
else:
PathFinding.PathFindTo(treeposx[i], treeposy[i]+1, treeposz[i])
else:
PathFinding.PathFindTo(treeposx[i], treeposy[i]-1, treeposz[i])
def MoveBoardsToBeetle():
Mobiles.UseMobile( Player.Serial ) #dismount
Misc.Pause( 650 )
Misc.WaitForContext(beetle, 10000)
Misc.ContextReply(beetle, "Open Backpack")
Misc.Pause( 650 )
for item in Player.Backpack.Contains:
if item.ItemID == boardID:
MoveItem( Items, Misc, item, Mobiles.FindBySerial( beetle ).Backpack )
Misc.Pause( 650 )
Mobiles.UseMobile( beetle ) #remount
Misc.Pause( 650 )
if Player.Weight >= maxweight:
for item in Player.Backpack.Contains:
if item.ItemID == 0x1BDD: #log
Items.UseItem(hatchet) #use hatchet
Target.WaitForTarget(2500,False) #wait for the target to appear on screen.
Target.TargetExecute(item)
Misc.Pause(750)
GoHome()
def GoHome():
Spells.Cast("Recall")
Target.WaitForTarget(5000)
Target.TargetExecute(homeRuneSerial) #rune or runebook
Misc.Pause( 650 )
Player.Run("North")
Player.Run("North")
Player.Run("North")
Player.Run("North")
Player.Run("North")
Player.Run("North")
Player.Run("North")
Player.Run("North")
Player.Run("North")
Player.Run("North")
Player.Run("North")
Player.Run("North")
Mobiles.UseMobile( Player.Serial ) #dismount
Misc.Pause( 650 )
Misc.WaitForContext(beetle, 10000)
Misc.ContextReply(beetle, "Open Backpack")
Misc.Pause( 650 )
# storageBox = Items.FindBySerial( 0x40018161 )
# Items.UseItem( storageBox )
# Misc.Pause( 650 )
#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, 59) #get hatchet
Gumps.WaitForGump(111922706, 10000)
Misc.Pause(50)
Gumps.SendAction(111922706, 0) #close gump
Misc.Pause(250)
#open bank vault
vault = Items.FindBySerial(vaultSerial)
Items.UseItem( vault )
Misc.Pause( 650 )
woodbaginbank = Items.FindBySerial(0x400CBA40)
for item in Player.Backpack.Contains:
if item.ItemID == boardID:
MoveItem( Items, Misc, item.Serial, vault )
Misc.Pause( 650 )
while (Gumps.CurrentGump() != 0 and checkForAnyGump) or Gumps.CurrentGump() == captchaGumpId:
sayTTS("%s Captcha Alert" % (Player.Name))
Misc.Pause(666)
for item in Mobiles.FindBySerial( beetle ).Backpack.Contains:
MoveItem( Items, Misc, item, woodbaginbank)
Misc.Pause( 650 )
Mobiles.UseMobile( beetle ) #remount
Misc.Pause( 650 )
sys.exit(99) #turns script off
while not Player.IsGhost:
ScanStatic()
i = 0
while i < treenumber:
MoveToTree(i)
Misc.Pause(500)
Journal.Clear() #Make sure journal is not reading ahead of when this started.
woodFound = True
while woodFound:
Journal.Clear() #clear message as to not get confused.
Player.HeadMessage(67, "Start Chopping Wood")
#hatchet = Items.FindByID(toolid, -1, Player.Backpack.Serial) #find hatchet in pack.
hatchet = Items.FindByID(toolid, -1, -1)
if hatchet: #if hatchet exists
Items.UseItem(hatchet) #use hatchet
Target.WaitForTarget(2500,False) #wait for the target to appear on screen.
harvestAttemptsSinceLastCaptcha += 1
tiles = Statics.GetStaticsTileInfo(treeposx[i], treeposy[i], Player.Map) #read map files to find target as static
if len(tiles) != 0 and tiles[0].StaticID != 0: #if tile is not id 0
Target.TargetExecute(treeposx[i], treeposy[i], tiles[0].StaticZ, tiles[0].StaticID) #target tile
Misc.Pause(1000)#pause
if Journal.Search("That is too far away.") == True: #if string is read in journal
Player.HeadMessage(1100, "Too Far Away")
break #go to next location
if Player.Weight >= maxweight:
Player.HeadMessage(1100, "Overweight!")
MoveBoardsToBeetle()
Misc.Pause(1000) #pause
else: #if tile does not exist
Target.Cancel() #cancel target
sys.exit(99) #turns script off
else: #if hatchet does not exist
Player.HeadMessage(90, "No Hatchet")
sys.exit(99) #turns script off
captchaCheck = True
countWaitTime = 0
while captchaCheck:
Misc.Pause(666)
countWaitTime += 666
if Journal.Search("There's not enough wood here to harvest.") == True or Journal.Search("You can't use an axe on that.") == True:
Player.HeadMessage(90, ">>> TREE IS DONE <<<")
Misc.Pause(666)
for item in Player.Backpack.Contains:
if item.ItemID == 0x1BDD: #log
Items.UseItem(hatchet) #use hatchet
Target.WaitForTarget(2500,False) #wait for the target to appear on screen.
Target.TargetExecute(item)
Misc.Pause(2000)
woodFound = False
captchaCheck = False
elif Journal.Search("You chop some") == True or Journal.Search("You hack at the tree for a while") or Journal.Search("You must wait to perform another action") == True:
Misc.Pause(250)
captchaCheck = False
else:
Player.HeadMessage(90, "WAITING")
if (Gumps.CurrentGump() != 0 and checkForAnyGump) or Gumps.CurrentGump() == captchaGumpId:
Misc.SendMessage("%s Mining Attempt Since Last Captcha" % (harvestAttemptsSinceLastCaptcha))
sayTTS("%s Captcha Alert" % (Player.Name))
harvestAttemptsSinceLastCaptcha = 0
if countWaitTime > 5000:
if Gumps.CurrentGump() == 0:
captchaCheck = False
i = i + 1
treeposx = []
treeposy = []
treeposz = []
treegfx = []
treenumber = 0