Picking up items

Hi,
is there any way to pick up items by using the python API?
I am asking, because based on the documentation of get_drops I am assuming that there is a method where I could use the dictionary key to pickup an item, but I can´t find any method for it.

Cheers

# get_drops()

Returns a dictionary of all pickable items nearby (based on pick filter settings) or `None` if you are not in game. The dictionary `key` is the pick ID used for picking up an item.

You have to inject a packet to do that.

Ok, I´m on it. Could you help me a little bit out… I am kind of new to Python and packet injection.

The pick operation has the opcode: 0x7074
An example for the data would be: 01 02 01 EF 4A 19 00
It seems to me, like 01 02 01 are static and I assume that the ID returned from get_drops somehow represents the last part (e.g. EF 4A 19 00)

Currently I have the follow code, but somehow I can´t append the ID to the bytearray.
The parameter id is the item ID return from get_drops.
Any idea what I am doing wrong?

Cheers

def inject_pick(id, tradeGood):
    strOpcode = "0x7074"
    strData = "01 02 01"
    opcode = int(strOpcode,16)
    Packet = bytearray()
    data = strData.split()
    i = 0
    while i < len(data):
        Packet.append(int(data[i],16))
        i += 1
    Packet.append(id)
    inject_joymax(opcode,Packet,True)  
    log('Plugin '+pName+': Picked up "'+tradeGood['name']+'" ')

Not tested.

packet = b'\x01\x02\x01' + struct.pack('I', tradeGood)
inject_joymax(0x7074, packet, False)
1 Like

Took me a while till I figured out, that I have to import struct. :man_facepalming: but now it works like a charm.
Thanks a lot!

1 Like

Will you share it with us when you’re done?

My plugin is kind of an extension based on xAutoDungeon and highly specified on my trading case^^
And since it is based on the xAutoDungeon, I don´t know if I am allowed to share the whole plugin.

But maybe I will contact JellyBitz once I have improved my plugin and we could add the feature to the xAutoDungeon.

if you are intrested in the code for picking items:
Here is one part of my implementation.

def inject_pick(id, tradeGood):
    packet = b'\x01\x02\x01' + struct.pack('I', id)
    inject_joymax(0x7074, packet, False)  
    log('Plugin '+pName+': Picked up "'+tradeGood['name']+'" ')


def pick_loop():
    if not 0 == len(tradeGoods):
        timer = Timer(0.5, pick_loop)
        timer.start()
        itemTuple = tradeGoods.popitem()
        id = itemTuple[0]
        tradeGood = itemTuple[1]
        x = tradeGood['x']
        y = tradeGood['y']
        move_to(x, y, 0.0)
        log('Plugin '+pName+': Moving to X: '+ str(x)+' Y: '+ str(y))
        inject_pick(id, tradeGood)
    else:
        getDrops()
        filter_drops()
        if(0 == len(tradeGoods)):
            log('Plugin '+pName+': Finished picking trade goods.')
            global isRepicking
            isRepicking = False
        else:
            log('Plugin '+pName+': Could not pick all item, start picking again.')
            pick_loop()
1 Like