Automated Party Reforming

Hey guys,

Here’s my plugin for reforming your party until you reach the wanted value. This is especially useful for those patry matching events.

from phBot import *
import phBotChat
import QtBind
import time
import threading
import struct

gui = QtBind.init(__name__, 'Party Match Event')

labelParty = QtBind.createLabel(gui, "Party number to reach: ", 10, 50)
labelDelay = QtBind.createLabel(gui, "Delay: ", 10, 69)
textBoxParty = QtBind.createLineEdit(gui, '100', 125, 50, 77, 16)
textBoxDelay = QtBind.createLineEdit(gui, '500', 125, 69, 77, 16)
button1 = QtBind.createButton(gui, 'button_clicked', 'Start Matching', 10, 90)
started = False
pName = 'Party Match Event'
pVersion = '1.0.0'
logging = True


def button_clicked():
	global started
	if started == True:
		if logging == True:
			log("Matching has been stopped!")
		started = False
		QtBind.setText(gui, button1, "Start Matching")
	else:
		if logging == True:
			log("Matching has been started!")
		started = True
		reformParty()
		QtBind.setText(gui, button1, "Stop Matching")

	
def handle_joymax(opcode, data):
	global started
	readableOpcode = '0x' + '{:02X}'.format(opcode)
	if readableOpcode == "0xB069":
		#log("Server: (Opcode) 0x" + '{:02X}'.format(opcode) + " (Data) "+ ("None" if not data else ' '.join('{:02X}'.format(x) for x in data)))
		data = ("None" if not data else ' '.join('{:02X}'.format(x) for x in data))
		data = data.split()
		data = data[1]
		partyNumber = int(data, 16)
		checkPartyNumber(partyNumber)
	elif readableOpcode == "0xB06B":
		data = ("None" if not data else ' '.join('{:02X}'.format(x) for x in data))
		data = data.split()
		if data[0] == "02" and data[1] == "1C" and data[2] == "2C":
			started = False
			QtBind.setText(gui, button1, "Start Matching")
			log("Please remove your party from the matching manually!")
	return True
	
def checkPartyNumber(number):
	global started
	if started == True:
		textParty = QtBind.text(gui, textBoxParty)
		intParty = int(textParty)
		if intParty > number:
			reformParty(number)
		else:
			started = False
			QtBind.setText(gui, button1, "Start Matching")
	
def reformParty(number=0):
	delay = QtBind.text(gui, textBoxDelay)
	delay = int(delay)
	delay /= 1000
	if number == 0:
		packetData = b'\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x01\x6E\x01\x00\x31'
		inject_joymax(0x7069, packetData, True)
		if logging == True:
			log("Party has been created!")
	else:
		packetData = struct.pack('<I', number)
		packetData += b'\x00\x00\x00'
		inject_joymax(0x706B, packetData, True)
		if logging == True:
			log("Party has been removed!")
		time.sleep(delay)
		packetData = b'\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x01\x6E\x01\x00\x31'
		inject_joymax(0x7069, packetData, True)
		if logging == True:
			log("Party has been created!")
			
log('Plugin: '+pName+' v'+pVersion+' succesfully loaded')

Reading bytes as hex strings. Yikes.

1 Like

Okay I’m enterily new to packets. What would be a good alternative?

You dont need this its totally unnecessary. Only do that if you need it as a string, like putting it through the bot log.

data = ("None" if not data else ' '.join('{:02X}'.format(x) for x in data))
data = data.split()
if opcode == 0xB069:

For instance…

Hello , was this plugin updated or something as it not work for me:(