Heyya.
I have put together some Useful Hack Functions.
Credits to Misc people, but mostly to UC.
I did make the crosshair function.
Mabye this could get stickied?
If anybody wants to add a function, leave me a PM and ill add it in.
Before we start, Make sure you have this in your globals:
[php]
LPD3DXFONT pFont;
LPDIRECT3DDEVICE9 pDevice;
[/php]
Draw Text:
After Globals:
[php]
void PrintText(LPD3DXFONT Font, long x, long y, D3DCOLOR fontColor, char *text, ...)//Draw Text Function
{
RECT rct;
rct.left = x - 1;
rct.right = x + 1;
rct.top = y - 1 ;
rct.bottom = y + 1;
if(!text) { return; }
va_list va_alist;
char logbuf[256] = {0};
va_start (va_alist, text);
_vsnprintf (logbuf+strlen(logbuf), sizeof(logbuf) - strlen(logbuf), text, va_alist);
va_end (va_alist);
RECT FontRect = { x, y, x, y };
pFont->DrawText(NULL, logbuf, -1, &rct, DT_NOCLIP, fontColor);
}
[/php]
And to use the function (In Endscene):
[php]
PrintText(pFont, X, Y, D3DCOLOR_XRGB(0,0,0), "Your Text Here");
[/php]
NOP
After Globals:
[php]
bool Memoria( void * pDest, char * szPatch, size_t sSize )//NOP Function
{
DWORD dwOrgProtect = NULL;
if ( !VirtualProtect ( pDest, sSize, PAGE_EXECUTE_READWRITE, &dwOrgProtect ))
return FALSE;
memcpy( pDest, szPatch, sSize );
VirtualProtect( pDest, sSize, dwOrgProtect, NULL );
return TRUE;
}
[/php]
And to use it:
[php]
Memoria(0x000000, "\x90\x90\x90", 3);
[/php]
Draw Crosshair:
Globals:
[php]
float ScreenCenterX = 0.0f;//Horizontal Position
float ScreenCenterY = 0.0f;//Vertical Position
[/php]
After Globals:
[php]
void DrawXHair(LPDIRECT3DDEVICE9 pDevice, D3DCOLOR color)
{
D3DVIEWPORT9 viewP;
pDevice->GetViewport( &viewP );
DWORD ScreenCenterX = viewP.Width / 2;
DWORD ScreenCenterY = viewP.Height / 2;
D3DRECT rec1 = {ScreenCenterX-25, ScreenCenterY, ScreenCenterX+ 25, ScreenCenterY+1};
D3DRECT rec2 = {ScreenCenterX, ScreenCenterY-25, ScreenCenterX+ 1,ScreenCenterY+25};
pDevice->Clear( 1, &rec1, D3DCLEAR_TARGET, color, 0, 0 );
pDevice->Clear( 1, &rec2, D3DCLEAR_TARGET, color, 0, 0 );
}
[/php]
SetViewport:
[php]
ScreenCenterX = ( float )pViewport->Width / 2;
ScreenCenterY = ( float )pViewport->Height / 2;
[/php]
Make Crosshair (Endscene):
[php]
DrawXHair(pDevice,D3DCOLOR_XRGB(0,0,0));
[/php]
Draw Box WITH Border
After Globals:
[php]
void FillRGB( int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice )
{
if( w < 0 )w = 1;
if( h < 0 )h = 1;
if( x < 0 )x = 1;
if( y < 0 )y = 1;
D3DRECT rec = { x, y, x + w, y + h };
pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, color, 0, 0 );
}
void DrawBorder( int x, int y, int w, int h, int px, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
{
FillRGB( x, (y + h - px), w, px, BorderColor, pDevice );
FillRGB( x, y, px, h, BorderColor, pDevice );
FillRGB( x, y, w, px, BorderColor, pDevice );
FillRGB( (x + w - px), y, px, h, BorderColor, pDevice );
}
void DrawBox( int x, int y, int w, int h, D3DCOLOR BoxColor, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
{
FillRGB( x, y, w, h, BoxColor, pDevice );
DrawBorder( x, y, w, h, 1, BorderColor, pDevice );
}
[/php]
And to create the box (Endscene):
[php]
DrawBox (X,Y,W,H,Back Color,Border Color,pDevice);
[/php]
Draw Circle
Globals:
[php]
ID3DXLine *pLine;
#define PI 3.14159265
[/php]
After Globals:
[php]
void DrawCircle(int X, int Y, int radius, int numSides, DWORD Color)
{
D3DXVECTOR2 Line[128];
float Step = PI * 2.0 / numSides;
int Count = 0;
for (float a=0; a < PI*2.0; a += Step)
{
float X1 = radius * cos(a) + X;
float Y1 = radius * sin(a) + Y;
float X2 = radius * cos(a+Step) + X;
float Y2 = radius * sin(a+Step) + Y;
Line[Count].x = X1;
Line[Count].y = Y1;
Line[Count+1].x = X2;
Line[Count+1].y = Y2;
Count += 2;
}
pLine->Begin();
pLine->Draw(Line,Count,Color);
pLine->End();
}
[/php]
Create the line(with your font):
[php]
D3DXCreateLine(pDevice,&pLine);
[/php]
And to draw the circle(Endscene):
[php]
DrawCircle(X,Y,R,S,COLOR);
[/php]
I havent perfected the circle, but when i do i will update.
Universal Draw FPS: - Thanks Longevity
Globals:
[php]
float fFps = NULL;
float fLastTickCount = NULL;
float fCurrentTickCount;
char cFrameRate[50] = {NULL};
[/php]
After Globals:
[php]
char *GetFrameRate()
{
fCurrentTickCount = clock() * 0.001f;
++fFps;
if((fCurrentTickCount - fLastTickCount) > 1.0f)
{
fLastTickCount = fCurrentTickCount;
sprintf( cFrameRate, "[ Current FPS: %d ]", int( fFps ) );
fFps = 0;
}
return cFrameRate;
}
[/php]
And to show the FPS (Endscene):
[php]
pFont->DrawTextA( 5, 0, D3DCOLOR_XRGB( 255, 250, 0 ), GetFrameRate());
[/php]
Hopefully this will go to good use and help people.
Dont leech please.
& a Thanks would be good /
And heres are screenshot off what the functions are capable of: