L. Spiro wrote:To perform an external memory copy:
- Code: Select all
BYTE bBuffer[sizeof( SPRITE )];
ReadProcessMemory( GetCurProcessHandle(), (LPCVOID)¤tenemy, bBuffer, sizeof( SPRITE ), NULL );
WriteProcessMemory( GetCurProcessHandle(), (LPVOID)¤tenemy2, bBuffer, sizeof( SPRITE ), NULL );
Thanks for the snippet spiro. Of course your code was correct.... but what I was trying to do doesn't work. If something shows up in what would correspond for currentenemy2, when it is move to currentenemy1 the sprite vanishes. It's like it was never there and I don't understand why.
- Code: Select all
extern SPRITE enemy[1] = { "", 0x0062dcd8 +0x003951e0};
extern SPRITE enemy2[1] = { "", 0x0062d118 +0x003951e0};
int whichvar;
int count;
{whichvar = 1;}
for (count = 0; count < 16; count++)
{
if (enemy[count].sprite2 == -2145557916) {bat(); } //72
if (enemy2[count].sprite2 == -2145557916) {whichvar = 2; bat();} //72
}
void bat ()
{
extern SPRITE currentenemy = { "", &enemy[count]};
extern SPRITE currentenemy2 = { "", &enemy2[count]};
if (whichvar == 2)
{
{whichvar = 0;}
ReadProcessMemory( GetCurProcessHandle(), (LPCVOID)¤tenemy, bBuffer, sizeof( SPRITE ), NULL );
WriteProcessMemory( GetCurProcessHandle(), (LPVOID)¤tenemy2, bBuffer, sizeof( SPRITE ), NULL );
}
BLAH BLAH
}
What I was trying to do was increase the framerate of the game because with a loop running 32X it drops to 54-57. With a loop of 16x it stay at 57-60 FPS.
One way to do this was to write all my scripts in each stage twice so that the loop is only running 16x, then double up on vars so basically:
- Code: Select all
extern SPRITE enemy[1] = { "", 0x0062dcd8 +0x003951e0};
extern SPRITE enemy2[1] = { "", 0x0062d118 +0x003951e0};
int count;
for (count = 0; count < 16; count++)
{
if (enemy[count].sprite2 == -2145559892) {bat();}
if (enemy2[count].sprite2 == -2145559892) {bat2();}
}
void bat()
{
extern SPRITE currentenemy = { "", &enemy[count]};
BLAH BLAH
}
void bat2()
{
extern SPRITE currentenemy2 = { "", &enemy2[count]};
BLAH BLAH
}
Code space wise this is of course retarded, BUT it does make the game run way smoother. Where as with this:
- Code: Select all
extern SPRITE enemy[1] = { "", 0x0062dcd8 +0x003951e0};
int count;
for (count = 0; count < 32; count++)
{
if (enemy[count].sprite2 == -2145559892) {bat();}
}
void bat()
{
extern SPRITE currentenemy = { "", &enemy[count]};
BLAH BLAH
}
It looks better code wise, but makes the game run slower due to the looping. Any suggestions?
P.S. In reference to script builder I may feel REALLY stupid when I hear the answer but I just couldn't figure out how to put a union into it. Do I just set the offsets the same when I add the names for the various ones in??
EDIT:
This is odd..... the offsets were initially 0,2,4, 6, 8, c,10, 12. But the minute I saved the structure and went back in, it changes them. Would this effect my scripts in game or can I just disregard it?