-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauto_QuestingV2.py
348 lines (251 loc) · 8.42 KB
/
auto_QuestingV2.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
# QUESTING
# REQUIRED:
# * DO NOT HAVE BACKPACKS
# * PACK PET
# * TRUSH POUCH
import sys
import re
# SETTINGS
# ========================
QuestMobileSerial = 0x0000237A
QuestName = "Hâute Couture"
QuestAlreadyStartedDescription = "I will be in your debt if you bring me flower garlands"
QuestAlreadyDoneDescription = " I appreciate your service. Now, see what elven hands can create."
PackPetSerial = 0x0000A125
PackPetFoodType = "fruit" # "meat" or "fruit"
TargetItemIds = {
0x2831: "Recipe Scroll",
0x2F58: "Talisman",
0x2F59: "Talisman",
0x2F5A: "Talisman",
0x2F5B: "Talisman"
}
TargetPropertiesRegex = {
"Recipe Scroll",
"Slayer",
"^(?=.*Bonus)(?=.*(2[5-9]|[3-9][0-9])).*$", # Talisman Bonus and 25-99
"Speed"
}
ToolKitId = 0x0F9D # Tailoring Tool
ToolGumpId = 2066278152 # Tailoring Gump
CraftItemId = 0x2306
CraftAmount = 10
MaterialId = 0x1766 # Cloth
MaterialThreshold = 500
MaterialTakeAmount = 1000
# ========================
QuestGumpId = 269917563
QuestItemColorId = 0x04ea # Orange
hasQuest = False
Fruits = [
0x09D0, # apple
0x09D1, # grape
0x09D2 # peach
]
Meats = [
0x09B7, # chicken
0x09C0, # sausage
0x09C9, # ham
0x09F2 # ribs
]
OtherFoods = [
0x097B, # fish
0x097D, # cheese
0x09EB # muffins
]
def Warning():
Misc.SendMessage("WARNING:", 33)
Misc.SendMessage("Backpacks will be DESTROYED!!", 33)
Misc.SendMessage("Select your trash poach.", 53)
global TrushPouch
TrushPouch = Target.PromptTarget()
if TrushPouch == -1:
Misc.SendMessage("Cancelled!", 5)
sys.exit()
def MoveItemToBackpack(item):
Items.Move(item, Player.Backpack.Serial, 0)
Misc.Pause(1000)
def MoveItemToTrush(item):
Items.Move(item, TrushPouch, 0)
Misc.Pause(1000)
def HasAllQuestItem():
return CraftAmount <= Items.BackpackCount(CraftItemId, QuestItemColorId)
def GetItemFromPet(item, threshold_amount, take_amount):
if Items.BackpackCount(item, -1) < threshold_amount:
pet = Mobiles.FindBySerial(PackPetSerial)
get_item = Items.FindByID(item, -1, pet.Backpack.Serial)
Items.Move(get_item, Player.Backpack.Serial, take_amount)
Misc.Pause(1000)
def OrganizeSubBackpackItems():
Misc.SendMessage("ORGANIZE ITEMS", 1150)
Misc.SendMessage("==============", 1150)
BackpackId = 0x0E75
while Items.FindByID(BackpackId, -1, Player.Backpack.Serial):
sub_backpack = Items.FindByID(BackpackId, -1, Player.Backpack.Serial)
if sub_backpack:
for item_id in TargetItemIds:
while Items.FindByID(item_id, -1, sub_backpack.Serial):
target_item = Items.FindByID(
item_id, -1, sub_backpack.Serial)
if target_item:
item_props = Items.GetPropStringList(target_item)
is_target = False
# PROPERTIES CHECK
for item_prop in item_props:
Misc.SendMessage(item_prop)
# EVAL TARGET PROPERTIES
for target_prop in TargetPropertiesRegex:
# REGEX
if re.search(target_prop, item_prop, flags=re.IGNORECASE):
Misc.Beep()
Misc.SendMessage("MATCH!", 50)
Misc.SendMessage("REGEX:", 60)
Misc.SendMessage(" => " + target_prop, 60)
Misc.SendMessage("PROPS:", 80)
Misc.SendMessage(" => " + item_prop, 80)
is_target = True
# TARGET TO KEEP OR TRUSH
if is_target:
Misc.SendMessage(" => KEEP", 90)
MoveItemToBackpack(target_item)
is_target = False
else:
Misc.SendMessage(" => TRUSH")
MoveItemToTrush(target_item)
Misc.Pause(1000)
Misc.Pause(100)
MoveItemToTrush(sub_backpack)
Misc.Pause(1000)
def SubBackpackCleanup():
bag = 0x0E75
colors = {
0x0003: "Blue",
0x000d: "Purple",
0x0021: "Red",
0x001c: "Dark Pink",
0x0037: "Frog Green",
0x003a: "Uguisu Green",
0x0044: "Green",
0x0059: "Light Blue",
0x0062: "Dark Blue",
0x0071: "Dark Purple"
}
for color in colors:
while Items.FindByID(bag, color, Player.Backpack.Serial):
item = Items.FindByID(bag, color, Player.Backpack.Serial)
MoveItemToTrush(item)
def Questing():
global hasQuest
if hasQuest:
return
if HasAllQuestItem():
return
Misc.SendMessage("QUESTING", 1150)
while not hasQuest:
# Talk
Mobiles.UseMobile(QuestMobileSerial)
Misc.Pause(100)
isQuestStarted = Gumps.LastGumpTextExist(
QuestAlreadyStartedDescription)
if isQuestStarted:
Misc.SendMessage("Already have a quest.", 55)
Gumps.WaitForGump(QuestGumpId, 10000)
Gumps.SendAction(QuestGumpId, 0) # Close
hasQuest = True
Misc.Pause(500)
return
isExactQuest = Gumps.LastGumpTextExist(QuestName)
Misc.SendMessage("Exact Quest?: %s" % isExactQuest, 55)
if isExactQuest:
Gumps.WaitForGump(QuestGumpId, 10000)
Gumps.SendAction(QuestGumpId, 4) # Accept
hasQuest = True
else:
Gumps.WaitForGump(QuestGumpId, 10000)
Gumps.SendAction(QuestGumpId, 2) # Refuse
Gumps.WaitForGump(QuestGumpId, 10000)
Gumps.SendAction(QuestGumpId, 0) # Close
hasQuest = False
Misc.Pause(500)
def Craft():
global hasQuest
if not hasQuest:
return
if HasAllQuestItem():
return
Misc.SendMessage("CRAFTING", 1150)
count = 0
while not HasAllQuestItem() and (count < 15):
tool = Items.FindByID(ToolKitId, 0, Player.Backpack.Serial)
if not tool:
Misc.SendMessage("There is no tool!", 33)
sys.exit()
Items.UseItem(tool)
Misc.Pause(1000)
Gumps.WaitForGump(ToolGumpId, 10000)
Gumps.SendAction(ToolGumpId, 21) # Remake
Misc.Pause(1500)
count += 1
Gumps.WaitForGump(ToolGumpId, 10000)
Gumps.SendAction(ToolGumpId, 0) # Close
Misc.Pause(500)
def ReportQuest():
global hasQuest
Misc.SendMessage("REPORT QUEST", 1150)
if HasAllQuestItem():
Mobiles.UseMobile(QuestMobileSerial) # Talk
Misc.Pause(250)
Gumps.WaitForGump(QuestGumpId, 10000)
Gumps.SendAction(QuestGumpId, 8) # Continue
Gumps.WaitForGump(QuestGumpId, 10000)
Gumps.SendAction(QuestGumpId, 5) # Accept
hasQuest = False
Misc.Pause(250)
def GetFood(type):
foods = None
global Meats
if type == "meat":
foods = Meats
elif type == "fruit":
foods = Fruits
else:
Misc.SendMessage("Unknown food type!", 33)
sys.exit()
for food in foods:
item = Items.FindByID(food, -1, Player.Backpack.Serial)
if item:
return item
def FeedPet(pet, type):
Misc.SendMessage("FEED PET", 1150)
while True:
Spells.CastMagery("Create Food")
Misc.Pause(1000)
food = GetFood(type)
if food:
Items.Move(food, pet, 0)
Player.HeadMessage(80, "Here you are!")
Mobiles.Message(pet, 90, "yum-yum..")
Misc.Pause(500)
break
Misc.Pause(500)
def CleanFoods(trush_poach_serial):
for food in [*Fruits, *Meats, *OtherFoods]:
item = Items.FindByID(food, -1, Player.Backpack.Serial)
if item:
Items.Move(item, trush_poach_serial, 0)
Misc.Pause(500)
# RUN
# ========================
Warning()
pet = Mobiles.FindBySerial(PackPetSerial)
while True:
FeedPet(pet, PackPetFoodType)
CleanFoods(TrushPouch)
for _ in range(10):
OrganizeSubBackpackItems()
SubBackpackCleanup()
Questing()
GetItemFromPet(MaterialId, MaterialThreshold, MaterialTakeAmount)
Craft()
ReportQuest()
Misc.Pause(50)