Загрузка данных


# -*- coding: utf-8 -*-
import pymeow
import time
import ctypes
import math
from ctypes import wintypes

# Константы для CS 1.6 (версия 5.2.0.0 non-Steam, 32-bit)
dwLocalPlayer = 0x10F4F4
dwEntityList = 0x10F5B0
dwViewMatrix = 0x10F5D0  # Пример смещения (найти через Cheat Engine)
m_iTeamNum = 0xF0
m_iHealth = 0xF8
m_vecOrigin = 0x130

# GDI для рисования поверх окна
user32 = ctypes.windll.user32
gdi32 = ctypes.windll.gdi32

def get_process():
    # Ищем процесс hl.exe
    pid = pymeow.process_by_name("hl.exe")
    if not pid:
        print("CS 1.6 не запущен")
        return None
    pymeow.open_process(pid)
    return pid

def world_to_screen(x, y, z, view_matrix, screen_w, screen_h):
    # Проекция через матрицу вида
    w = view_matrix[12]*x + view_matrix[13]*y + view_matrix[14]*z + view_matrix[15]
    if w < 0.01:
        return None
    sx = view_matrix[0]*x + view_matrix[1]*y + view_matrix[2]*z + view_matrix[3]
    sy = view_matrix[4]*x + view_matrix[5]*y + view_matrix[6]*z + view_matrix[7]
    sx = (screen_w / 2) * (1 + sx / w)
    sy = (screen_h / 2) * (1 - sy / w)
    return (int(sx), int(sy))

def draw_rect(hdc, x, y, w, h, color):
    brush = gdi32.CreateSolidBrush(color)
    gdi32.SelectObject(hdc, brush)
    gdi32.Rectangle(hdc, x, y, x+w, y+h)
    gdi32.DeleteObject(brush)

def main():
    pid = get_process()
    if not pid:
        return
    
    hwnd = user32.FindWindowW(None, "Counter-Strike")
    if not hwnd:
        print("Окно не найдено")
        return
    
    hdc = user32.GetDC(hwnd)
    screen_w = 800
    screen_h = 600
    
    # Загрузка адреса базы клиента
    client_base = pymeow.module_by_name(pid, "hw.dll")["base"]
    print(f"Client base: {hex(client_base)}")
    
    while True:
        # Чтение локального игрока
        local_player = pymeow.r_int(client_base + dwLocalPlayer)
        if local_player == 0:
            time.sleep(0.05)
            continue
        
        local_team = pymeow.r_int(local_player + m_iTeamNum)
        
        # Чтение матрицы (упрощённо, можно пропустить и использовать статическую)
        view_matrix = [0]*16
        for i in range(16):
            view_matrix[i] = pymeow.r_float(client_base + dwViewMatrix + i*4)
        
        for i in range(1, 33):
            entity = pymeow.r_int(client_base + dwEntityList + i*4)
            if entity == 0:
                continue
            entity_team = pymeow.r_int(entity + m_iTeamNum)
            if entity_team == local_team:
                continue
            health = pymeow.r_int(entity + m_iHealth)
            if health <= 0:
                continue
            
            x = pymeow.r_float(entity + m_vecOrigin)
            y = pymeow.r_float(entity + m_vecOrigin + 4)
            z = pymeow.r_float(entity + m_vecOrigin + 8)
            
            screen = world_to_screen(x, y, z, view_matrix, screen_w, screen_h)
            if screen:
                draw_rect(hdc, screen[0]-10, screen[1]-20, 20, 30, 0x0000FF)  # красный
        time.sleep(0.03)

if __name__ == "__main__":
    main()