All pastes #916485 Raw Edit

Untitled

public text v1 · immutable
#916485 ·published 2008-02-24 18:19 UTC
rendered paste body

#define AIM_MINR		5			//min retina radius
#define AIM_MAXR		75			//max retina radius
#define AIM_RES			1			//retinal DPI
#define AIM_RATIO		0.3f		//retinal balance
#define AIM_RETINA		15			//retinal dialation speed
#define AIM_SPEED		35

//scan screen for colored pixel blobs and check their dimensions
HRESULT sys_IDirect3DDevice9::Aim()
{
	COLORREF pix;
	RECT wndrect;
	HWND hl2hwnd;
	HDC hl2dc;
	int x, y;
	float scx, scy;
	static float a, b, c, mx, my, omx, omy, weight;

	if(b<AIM_MINR)
		b=AIM_MINR;

	if(b>AIM_MAXR)
		b=AIM_MAXR;

	omx = mx;
	omy = my;
	mx = 0;
	my = 0;
	c=0;

	hl2hwnd = GetForegroundWindow();
	hl2dc = GetDC(hl2hwnd);
	GetClientRect(hl2hwnd, &wndrect);

	scx = (wndrect.left + wndrect.right) / 2;
	scy = (wndrect.top + wndrect.bottom) / 2;

	for(a=0; a<360; a+=(360/AIM_RES)/b)
	{
		x = scx + cos(a * (3.141/180)) * (b - 1);
		y = scy + sin(a * (3.141/180)) * (b - 1);

		pix = GetPixel(hl2dc, x, y);

		if(GetRValue(pix) < 20 && GetGValue(pix) < 20 && GetBValue(pix) > 235)
		{
			mx += cos(a * (3.141/180));
			my += sin(a * (3.141/180));
			c++;
		}

		//SetPixel(hl2dc, x, y, RGB(255, 255, 255));
	}

	ReleaseDC(hl2hwnd, hl2dc);

	//mouse move event
	mx = (mx + omx) / 2;
	my = (my + omy) / 2;
	mouse_event(MOUSEEVENTF_MOVE, (int)(mx * AIM_SPEED / b), (int)(my * AIM_SPEED / b), 0, NULL);

	//reticle sensory
	weight = c/b;
	weight /= AIM_RES;		//clamp to [0,1]

	//reticle dialation
	if(weight > AIM_RATIO)
		b+=AIM_RETINA*(weight-AIM_RATIO);
	else
	{
		b-=AIM_RETINA*(AIM_RATIO-weight);
//		my-=AIM_SPEED/b;
	}

	return 0;
}


HRESULT sys_IDirect3DDevice9::Present(CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion) 
{
	if(GetAsyncKeyState(VK_RBUTTON))
		Aim();
	return pIDirect3DDevice9->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}