コード例 #1
0
ファイル: h3.py プロジェクト: wusuopu/heroes3-cheat
def get_town_info(process, num):
    """ 获取城镇信息"""
    size = 0x168
    base_addr = memory.read_process(process, GAME_ADDR['town_1_base'], 4)
    addr = base_addr + (size * num)
    buf = memory.read_process(process, addr, size)

    town = Town.from_buffer_copy(buf, 0)
    data = town.to_json()
    if town.name_pointer == 0 or town.name_pointer == 0xFFFFFFFF:
        data['name'] = ''
    else:
        data['name'] = bytes2str(
            memory.read_process(process, town.name_pointer, 20), 'gbk')
    # file_name = 'town-%d' % (num)
    # print('town_name:', file_name)
    # with open(file_name, 'w') as fp:
    #     i = 0
    #     while i < size:
    #         if (i % 16) == 0:
    #             fp.write('%X: ' % (addr + i))
    #         fp.write("%02x " % (buf[i]))
    #         i += 1
    #         if (i % 16) == 0:
    #             fp.write('\n')
    return data
コード例 #2
0
ファイル: h3.py プロジェクト: wusuopu/heroes3-cheat
def list_all_player(process):
    """获取所有玩家信息"""
    buf = memory.read_process(process, GAME_ADDR['player1'], 0x168 * 8)
    i = 0
    data = []
    while i < 8:
        player = Player.from_buffer_copy(buf, 0x168 * i)
        i += 1
        data.append(player.to_json())
    return data
コード例 #3
0
ファイル: h3.py プロジェクト: wusuopu/heroes3-cheat
def get_current_play(process):
    """获取当前玩家号"""
    pointer = memory.read_process(process, POINTER, 4)
    addr = pointer + 0xB4
    num = 0
    data = {}
    while num < 8:
        if addr == GAME_ADDR['play%d_gold' % (num + 1)]:
            data['color'] = PLAYER_COLORS[num]
            data['num'] = num
            return data
        num += 1
コード例 #4
0
ファイル: h3.py プロジェクト: wusuopu/heroes3-cheat
def init_game_base_addr(process, is_hd):
    """初始化游戏基址"""
    global GAME_ADDR
    global POINTER
    global GAME_INITED

    if is_hd:
        GAME_ADDR = HD_GAME_ADDR
        POINTER = HD_POINTER
    else:
        GAME_ADDR = NO_HD_GAME_ADDR
        POINTER = NO_HD_POINTER

    print('current_player_addr0 :%x' % (POINTER))
    current_player_addr = memory.read_process(process, POINTER, 4)
    print('current_player_addr :%x' % (current_player_addr))
    if not current_player_addr:
        # 游戏还未开始
        GAME_INITED = False
    else:
        playeridx = memory.read_process(process, current_player_addr, 1)
        print('playeridx:', playeridx)
        if 0 <= playeridx <= 7:
            GAME_INITED = True
            GAME_ADDR['player1'] = current_player_addr - (0x0168 * playeridx)
            play1_gold = GAME_ADDR['player1'] + 0xb4
            GAME_ADDR['hero_1'] = GAME_ADDR['player1'] + 0x0b50
            GAME_ADDR['town_1_base'] = GAME_ADDR['hero_1'] - 0x0c
            i = 0
            while i < 8:
                GAME_ADDR['play%d_gold' % (i + 1)] = play1_gold + (i * 0x0168)
                i += 1
        for k in GAME_ADDR:
            print(k, hex(GAME_ADDR[k]))

    return GAME_INITED
コード例 #5
0
ファイル: h3.py プロジェクト: wusuopu/heroes3-cheat
def get_all_resources(process):
    # 获取所有玩家资源数据
    i = 0
    number = 8
    data = []
    while i < number:
        data.append({
            'color': PLAYER_COLORS[i],
            'data': [],
        })
        addr = GAME_ADDR['play1_gold'] + (0x0168 * i) - (0x04 * 6)
        value = memory.read_process(process, addr, 28)
        resource_num = 0
        resource_count = len(RESOURCE_NAMES)
        while resource_num < resource_count:
            offset = resource_num * 0x04
            data[i]['data'].append(
                memory.bytes_to_int(value[0 + offset:4 + offset], 4))
            resource_num += 1
        i += 1
    return data
コード例 #6
0
ファイル: h3.py プロジェクト: wusuopu/heroes3-cheat
def list_all_hero(process):
    # 全部英雄 156
    start_addr = GAME_ADDR['hero_1']
    number = 200
    i = 0
    data = []
    while i < number:
        addr = start_addr + (0x492 * i) + 0x22
        value = memory.read_process(process, addr, 32)
        name = value[1:]
        if not name or name.startswith(b'\xff\xff'):
            break
        name = bytes2str(name)
        if name:
            data.append({
                'num': i,
                'addr': addr - 0x22,
                'player': value[0],
                'name': name,
                'avator': value[1 + 13 + 4],
            })
        i += 1

    return data
コード例 #7
0
ファイル: h3.py プロジェクト: wusuopu/heroes3-cheat
def set_town_info(process, num, offset, value, size):
    """修改城镇属性"""
    town_size = 0x168
    base_addr = memory.read_process(process, GAME_ADDR['town_1_base'], 4)
    addr = base_addr + (town_size * num) + offset
    memory.write_process(process, addr, value, size)
コード例 #8
0
ファイル: h3.py プロジェクト: wusuopu/heroes3-cheat
def get_hero_info(process, num):
    base_addr = GAME_ADDR['hero_1'] + (0x0492 * num)
    buf = memory.read_process(process, base_addr, 0x492)
    data = collections.OrderedDict()
    data['num'] = num
    data['xAxis'] = bytes2number(buf, 0x00, 2),  # 坐标从左上角算起
    data['yAxis'] = bytes2number(buf, 0x02, 2),
    data['zAxis'] = bytes2number(buf, 0x04, 2),  # 0:up world, 1: under world
    data['visible'] = bytes2number(buf, 0x05, 1),
    data['color'] = PLAYER_COLORS[buf[0x22]],
    data['name'] = bytes2str(buf[0x23:(0x23 + 30)]),
    data['type'] = bytes2number(buf, 0x30, 1),  # 英雄类型 name + 13
    data['头像'] = bytes2number(buf, 0x34, 1),  # 英雄头像 type + 4
    data['魔法值'] = bytes2number(buf, 0x18, 2),
    data['特长'] = bytes2number(buf, 0x1A,
                              4),  # 英雄特长  前4个字节记录特长种类,后4个字节记录特长的具体信息
    data['移动力'] = bytes2number(buf, 0x4d, 2),
    data['经验'] = bytes2number(buf, 0x51, 4),
    data['等级'] = bytes2number(buf, 0x55, 2),
    data['攻击'] = bytes2number(buf, 0x476, 1),
    data['防御'] = bytes2number(buf, 0x477, 1),
    data['力量'] = bytes2number(buf, 0x478, 1),
    data['知识'] = bytes2number(buf, 0x479, 1),

    data['第1格兵数量'] = bytes2number(buf, 0xad, 4),
    data['第2格兵数量'] = bytes2number(buf, 0xb1, 4),
    data['第3格兵数量'] = bytes2number(buf, 0xb5, 4),
    data['第4格兵数量'] = bytes2number(buf, 0xb9, 4),
    data['第5格兵数量'] = bytes2number(buf, 0xbd, 4),
    data['第6格兵数量'] = bytes2number(buf, 0xc1, 4),
    data['第7格兵数量'] = bytes2number(buf, 0xc5, 4),
    data['第1格兵兵种'] = bytes2number(buf, 0x91, 4),
    data['第2格兵兵种'] = bytes2number(buf, 0x95, 4),
    data['第3格兵兵种'] = bytes2number(buf, 0x99, 4),
    data['第4格兵兵种'] = bytes2number(buf, 0x9d, 4),
    data['第5格兵兵种'] = bytes2number(buf, 0xa1, 4),
    data['第6格兵兵种'] = bytes2number(buf, 0xa5, 4),
    data['第7格兵兵种'] = bytes2number(buf, 0xa9, 4),

    # 1: 初级; 2: 中级; 3: 高级
    data['寻路术等级'] = bytes2number(buf, 0xC9, 1),
    data['箭术等级'] = bytes2number(buf, 0xCA, 1),
    data['后勤学等级'] = bytes2number(buf, 0xCB, 1),
    data['侦察术等级'] = bytes2number(buf, 0xCC, 1),
    data['外交术等级'] = bytes2number(buf, 0xCD, 1),
    data['航海术等级'] = bytes2number(buf, 0xCE, 1),
    data['领导术等级'] = bytes2number(buf, 0xCF, 1),
    data['智慧术等级'] = bytes2number(buf, 0xD0, 1),
    data['神秘术等级'] = bytes2number(buf, 0xD1, 1),
    data['幸运术等级'] = bytes2number(buf, 0xD2, 1),
    data['弹道术等级'] = bytes2number(buf, 0xD3, 1),
    data['鹰眼术等级'] = bytes2number(buf, 0xD4, 1),
    data['招魂术等级'] = bytes2number(buf, 0xD5, 1),
    data['理财术等级'] = bytes2number(buf, 0xD6, 1),
    data['火系魔法等级'] = bytes2number(buf, 0xD7, 1),
    data['气系魔法等级'] = bytes2number(buf, 0xD8, 1),
    data['水系魔法等级'] = bytes2number(buf, 0xD9, 1),
    data['土系魔法等级'] = bytes2number(buf, 0xDA, 1),
    data['学术等级'] = bytes2number(buf, 0xDB, 1),
    data['战术等级'] = bytes2number(buf, 0xDC, 1),
    data['炮术等级'] = bytes2number(buf, 0xDD, 1),
    data['学习能力等级'] = bytes2number(buf, 0xDE, 1),
    data['进攻术等级'] = bytes2number(buf, 0xDF, 1),
    data['防御术等级'] = bytes2number(buf, 0xE0, 1),
    data['智力等级'] = bytes2number(buf, 0xE1, 1),
    data['魔力等级'] = bytes2number(buf, 0xE2, 1),
    data['抵抗力等级'] = bytes2number(buf, 0xE3, 1),
    data['急救术等级'] = bytes2number(buf, 0xE4, 1),

    # 28项可学技能的显示位置: 1~28
    data['寻路术位置'] = bytes2number(buf, 0xE5, 1),
    data['箭术位置'] = bytes2number(buf, 0xE6, 1),
    data['后勤学位置'] = bytes2number(buf, 0xE7, 1),
    data['侦察术位置'] = bytes2number(buf, 0xE8, 1),
    data['外交术位置'] = bytes2number(buf, 0xE9, 1),
    data['航海术位置'] = bytes2number(buf, 0xEA, 1),
    data['领导术位置'] = bytes2number(buf, 0xEB, 1),
    data['智慧术位置'] = bytes2number(buf, 0xEC, 1),
    data['神秘术位置'] = bytes2number(buf, 0xED, 1),
    data['幸运术位置'] = bytes2number(buf, 0xEE, 1),
    data['弹道术位置'] = bytes2number(buf, 0xEF, 1),
    data['鹰眼术位置'] = bytes2number(buf, 0xF0, 1),
    data['招魂术位置'] = bytes2number(buf, 0xF1, 1),
    data['理财术位置'] = bytes2number(buf, 0xF2, 1),
    data['火系魔法位置'] = bytes2number(buf, 0xF3, 1),
    data['气系魔法位置'] = bytes2number(buf, 0xF4, 1),
    data['水系魔法位置'] = bytes2number(buf, 0xF5, 1),
    data['土系魔法位置'] = bytes2number(buf, 0xF6, 1),
    data['学术位置'] = bytes2number(buf, 0xF7, 1),
    data['战术位置'] = bytes2number(buf, 0xF8, 1),
    data['炮术位置'] = bytes2number(buf, 0xF9, 1),
    data['学习能力位置'] = bytes2number(buf, 0xFA, 1),
    data['进攻术位置'] = bytes2number(buf, 0xFB, 1),
    data['防御术位置'] = bytes2number(buf, 0xFC, 1),
    data['智力位置'] = bytes2number(buf, 0xFD, 1),
    data['魔力位置'] = bytes2number(buf, 0xFE, 1),
    data['抵抗力位置'] = bytes2number(buf, 0xFF, 1),
    data['急救术位置'] = bytes2number(buf, 0x100, 1),
    data['技能个数'] = bytes2number(buf, 0x101, 1),

    data['有魔法书'] = bytes2number(buf, 0x1B5,
                                4) == 0,  # 0x00000000: YES; 0xFFFFFFFF: NO
    data['士气幸运'] = bytes2number(buf, 0x107, 1),  # 0b11000000 0xC0 高士气,高幸运

    # 物品栏
    obj_index = 0
    obj_num = 64
    while obj_index < obj_num:
        data['行囊%02d' % (obj_index + 1)] = bytes2number(
            buf, 0x1d4 + (8 * obj_index), 4),
        data['行囊%02d属性' % (obj_index + 1)] = bytes2number(
            buf, 0x1d4 + (8 * obj_index) + 4, 4),
        obj_index += 1
    # 物品栏之后一个字节记录当前物品的数量
    data['行囊数量'] = bytes2number(buf, 0x1d4 + (8 * obj_index), 1)

    # file_name = 'hero_%d.txt' % (time.time())
    # print('file_name:', file_name)
    # with open(file_name, 'w') as fp:
    #     i = 0
    #     while i < 0x492:
    #         fp.write("%02x " % (buf[i]))
    #         i += 1
    #         if (i % 16) == 0:
    #             fp.write('\n')
    return data