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


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

# Константы для CS 1.6 (версия 5.2.0.0 non-Steam)
dwLocalPlayer = 0x10F4F4
dwEntityList = 0x10F5B0
dwViewMatrix = 0x10F5D0
m_iTeamNum = 0xF0
m_iHealth = 0xF8
m_vecOrigin = 0x130

user32 = ctypes.windll.user32
gdi32 = ctypes.windll.gdi32

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

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 main():
    pid = pymeow.process_by_name("hl.exe")
    if not pid:
        print("hl.exe не найден. Запустите CS 1.6")
        input()
        return
    
    pymeow.open_process(pid)
    hwnd = user32.FindWindowW(None, "Counter-Strike")
    if not hwnd:
        print("Окно Counter-Strike не найдено")
        input()
        return
    
    client_base = pymeow.module_by_name(pid, "hw.dll")["base"]
    print(f"hw.dll base: {hex(client_base)}")
    
    hdc = user32.GetDC(hwnd)
    screen_w = 800
    screen_h = 600
    
    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 = [pymeow.r_float(client_base + dwViewMatrix + i*4) for i in range(16)]
        
        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_pos = world_to_screen(x, y, z, view_matrix, screen_w, screen_h)
            if screen_pos:
                draw_rect(hdc, screen_pos[0]-10, screen_pos[1]-20, 20, 30, 0x0000FF)
        
        time.sleep(0.03)

if __name__ == "__main__":
    main()