def run(paths=[], rsc=[], check_archi=True, rotation=1): global app Thread(target=sniff, kwargs={ 'filter': 'tcp port 5555', 'lfilter': lambda p: p.haslayer(Raw), 'prn': lambda p: on_receive(p, on_msg) }).start() app = Application().connect(path='D:/Ankama/dofus').top_window() app.move_window(x=-10, y=0, width=1365, height=768, repaint=True) # app.minimize() # wait(5,10,('lifepoints',1,20,alarm)) rsc, farmer_exception = set({ s for r in rsc for x in collection.skills.find( {'_id': { '$regex': '^%s.*' % (r), '$options': 'i' }}) for s in x['skill_id'] }), set({45, 296, 58, 308, 57, 341, 159, 52, 54, 191, 50, 46, 53, 307}) if check_archi: Thread(target=check_arch, args=[{ x['raceid']: x['_id'] for x in collection.archmonsters.find({}) }]).start() while rotation: for p in paths: teleport( collection.zaaps.find_one({'_id': p['zaap']}, { 'name': 1, '_id': 0 })['name']) p = [get_current_node(useful['mapid'], useful['mypos']) ] + p['nodes'] for s in range(len(p) - 1): for e in pathfinder(p[s], p[s + 1]): prev = useful['mapid'] shift, count = False, 2 for c in order([ x[0] if x[1]['enabledSkill'] not in farmer_exception else x[0] - 28 for x in useful['resources'].items() if x[1]['enabledSkill'] in rsc ]): if c not in forbiden_cells(): s = str(c) print('recolt', c) click(c, offx=e[2][s]['xoffset'] - 1, offy=e[2][s]['yoffset'] - 1, alt=e[2][s]['altitude'], press=shift) wait(.25, .5) shift, count = True, count + 1 cell = get_closest(e[0], int(s) if shift else useful['mypos'], e[1]) print(cell, e[1]) click(cell, direction=e[1], press=shift) wait(3, 4.5, ('mapid', prev, count, wrapper(click, cell, direction=e[1]))) print("mapchanged", prev, useful['mapid']) rotation -= 1