leeched this from over at **********, posted by Tate, looked like it could be something useful for those of us that can actually still make working hacks (unlike me XD stupid crashing >.>) yes this is a literal C+P cuz i'm too lazy to edit anything out...at least i gave credits
This is just a basic stride logging method with a basic menu. I also released this with the name regist on GD.
This isn't anything special, just something to learn off of.
Code:
int stridenum;
stridenum = 0;
LPDIRECT3DTEXTURE9 texRed;
D3DXCreateTextureFromFileInMemory(m_pD3Ddev,(LPCVOID)&bRed,60,&texRed);
const BYTE bRed[60] =
{
0x42, 0x4D, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xCC, 0x00, 0x00, 0x00
};
In EndScene()
if( GetAsyncKeyState( VK_INSERT ) & 1 )
{
Menu = !Menu; // Turns menu on and off. Simple switch.
}
if( Menu )
{
//--Menu Operations--
if( GetAsyncKeyState( VK_RIGHT ) & 1 )
{
stridenum = stridenum + 1; //Adds 1 to the current integer 'stridenum'. Stridenum is used below in the menu.
}
if( GetAsyncKeyState( VK_LEFT) & 1 )
{
if(stridenum > 0) //We can't go into negative model rec, so we're making sure our number is above 0.
{
stridenum = stridenum - 1; //Subtracts 1 to the current integer 'stridenum'. Stridenum is used below in the menu.
}
}
//--Menu Operations--*/
/*Drawing of the Menu*/
D3DRECT rec2 = {149,212,351,301};
m_pD3Ddev->Clear(1, &rec2, D3DCLEAR_TARGET, D3DCOLOR_ARGB(20,45,216,35),0 ,0);
//Draws a nice border around the simple rectangle menu.
D3DRECT rec1 = {150,213,350,300};//X, Y, WIDTH, HEIGHT //380 450
m_pD3Ddev->Clear(1, &rec1, D3DCLEAR_TARGET, D3DCOLOR_ARGB(20,0,0,0),0 ,0);
//Draws the actual menu. It's just slightly smaller than the bigger rectangle above, simulating a border.
PrintText(m_font1, 156, 220, 255, 255,255, 255, "Tate at *********. Shout to HF.");
PrintText(m_font1, 156, 265, 255, 255,255, 255, "Stride: %i", stridenum);
//Obviously prints the menu text.
//Drawing of the Menu*/
}
In DrawIndexedPrimitive()
PHP Code:
/*Debugging*/
if (m_Stride == stridenum)
{
m_pD3Ddev->SetTexture(0, texRed); //Here we are filling our model rec red.
m_pD3Ddev->SetRenderState(D3DRS_ZENABLE,D3DZB_FALSE); //Here we are doing a simple wallhack, so everything that was filled gets seen.
}
/*Debugging*/
I realize this source is for the 'noobies', so I'll go a bit indept into why we put what where. I won't go into technical aspects, but rather physical aspects.
We draw the menu in EndScene(), because when drawing in DrawIndexedPrimitive, your drawn item doesn't necessarily appear above everything else. EndScene is what it sounds like. EndScene. Basically, Z order works like so.
I want to render a cat behind a bear behind a truck.
I would render the cat first, then the bear, then the truck, that way the truck is in the front. Same concept here. EndScene will render after everything else, therefore putting your drawn items in front of everything else.
We do the debugging in DrawIndexedPrimitive, because that's where models are drawn in game.
(Originally written by me for *********. Trying to increase the level of C++ knowledge here.)