Character Select / Creator


#1

This plugin can be used to select the first character that appears in the listing. This plugin will not function until 21.2.1 or 16.1.6.

from phBot import *

def character_listing(args):
    for name in args:
        if not name.startswith('*'):
            log('Selecting %s' % name)
            select_character(name)
            break
    return 0

log('[%s] Loaded' % __name__)

#2

This plugin creates a character with a random name if no other characters exist on the account - otherwise it will auto select the first one in the listing.

Change ‘CH’ to ‘EU’ to create a European character. This will not function until 21.2.2 / 16.1.6.

from phBot import *
from struct import pack
import string
import random

CHARACTER_TYPE = 'CH'

create = False
request_listing = False

def create_character(name):
    global CHARACTER_TYPE

    if CHARACTER_TYPE == 'CH':
        c_model = get_monster_string('CHAR_CH_MAN_ADVENTURER')['model']
        chest = get_item_string('ITEM_CH_M_HEAVY_01_BA_A_DEF')['model']
        legs = get_item_string('ITEM_CH_M_HEAVY_01_LA_A_DEF')['model']
        shoes = get_item_string('ITEM_CH_M_HEAVY_01_FA_A_DEF')['model']
        weapon = get_item_string('ITEM_CH_SWORD_01_A_DEF')['model']
    elif CHARACTER_TYPE == 'EU':
        c_model = get_monster_string('CHAR_EU_MAN_NOBLE')['model']
        chest = get_item_string('ITEM_EU_M_HEAVY_01_BA_A_DEF')['model']
        legs = get_item_string('ITEM_EU_M_HEAVY_01_LA_A_DEF')['model']
        shoes = get_item_string('ITEM_EU_M_HEAVY_01_FA_A_DEF')['model']
        weapon = get_item_string('ITEM_EU_DAGGER_01_A_DEF')['model']
    else:
        log('Invalid character type (CH or EU)')
        return

    if c_model == 0 or chest == 0 or legs == 0 or shoes == 0 or weapon == 0:
        log('Could not retrieve item models')
        return

    log('Creating character with name %s and type %s' % (name, CHARACTER_TYPE))

    p = b'\x01'
    p += pack('H', len(name))
    p += name.encode('ascii')
    p += pack('I', c_model)
    p += pack('B', 0)
    p += pack('I', chest)
    p += pack('I', legs)
    p += pack('I', shoes)
    p += pack('I', weapon)
    inject_joymax(0x7007, p, False)

    request_listing = True

def character_listing(args):
    global create

    if len(args) == 0:
        create = True
    else:
        for name in args:
            if not name.startswith('*'):
                log('Selecting %s' % name)
                select_character(name)
                break
    return 0

def event_loop():
    global create, request_listing

    if create:
        create = False
        name = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(10))
        create_character(name)
    elif request_listing:
        request_listing = False
        inject_joymax(0x7007, b'\x02', False)

log('[%s] Loaded' % __name__)

#3