I have some codes:
- Code: Select all
extern DWORD NPC_BASE_ADD = {"", 0x00DC9988};
const DWORD NPC_DATA_SIZE = 0x8038;
const INT REGION_WIDTH = 512;
const INT REGION_HEIGHT = 1024;
const INT CELL_WIDTH = 32;
const INT CELL_HEIGHT = 32;
const INT MAX_NPC = 256;
const INT MAX_OBJ = 256;
const INT PLAYER_INDEX = 1;
const DWORD RUN_FUNC_ADD = 0x004C41B7;
const DWORD WLK_FUNC_ADD = 0x004C4204;
//const DWORD DOSOMETHING_FUNC_ADD = 0x00ABCDEF;
INT PosX_Real = 0;
INT PosY_Real = 0;
INT PosX_Map = 0;
INT PosY_Map = 0;
typedef struct NPC
{
BYTE Padding0[0xC];
// 0x0C
DWORD NextNPC;
BYTE Padding00[0xC];
// 0x1C
UINT Lev;
// 0x20
UINT Kind;
// 0x24
UINT Sys;
BYTE Padding01[0xB4];
// 0xDC
UINT Color;
BYTE Padding02[0xCE8];
// 0xDC8
UINT Health;
// 0xDCC;
UINT HealthMax;
// 0xDD0
UINT DontKnow1;
BYTE Padding03[8];
// 0xDDC
UINT Mana;
// 0xDE0;
UINT ManaMax;
BYTE Padding04[0x1EC];
// 0xFD0
UINT MapX;
// 0xFD4
UINT MapY;
// 0xFD8
UINT MapZ;
// 0xFDC
UINT MapOffX;
// 0xFE0
UINT MapOffY;
// 0xFE4
UINT MapOffZ;
BYTE Padding05[0x49];
// 0x1031
CHAR Name[0x20];
UINT Sex;
BYTE Padding06[0x84];
INT PeopleIdx;
BYTE Padding07[0x19B];
// 0x1278
UINT Fight;
BYTE Padding08[0x1C];
// 0x1298;
WORD RegionX;
WORD RegionY;
} NPC;
VOID On_HK_9( DWORD dw1, DWORD dw2 ) {
Clear();
Go();
}
VOID Go() {
extern struct NPC pPlayer = { "", NPC_BASE_ADD + PLAYER_INDEX * NPC_DATA_SIZE};
GetRealPos(&PosX_Real, &PosY_Real
, pPlayer.RegionX, pPlayer.RegionY
, pPlayer.MapX, pPlayer.MapY
, pPlayer.MapOffX, pPlayer.MapOffY
);
GetMapPos(&PosX_Map, &PosY_Map
, pPlayer.RegionX, pPlayer.RegionY
, pPlayer.MapX, pPlayer.MapY
//, pPlayer.MapOffX, pPlayer.MapOffY
);
PrintF("Name:%s", pPlayer.Name);
PrintF("Next:%0.8x\n", pPlayer.NextNPC);
PrintF("Lev:%u\n", pPlayer.Lev);
PrintF("Sys:%u\n", pPlayer.Sys);
PrintF("Kind:%u\n", pPlayer.Kind);
PrintF("Health/HelathMax:%u/%u\n", pPlayer.Health, pPlayer.HealthMax);
PrintF("Mana /ManaMax :%u/%u\n", pPlayer.Mana, pPlayer.ManaMax);
PrintF("PosX /PosY :%u/%u\n", PosX_Map, PosY_Map);
PrintF("PosX_Real/PosY_Real:%u/%u\n", PosX_Real, PosY_Real);
PrintF("PeopleIdx:%d\n", pPlayer.PeopleIdx);
PrintF("Fight:%u\n", pPlayer.Fight);
}
VOID GetRealPos(INT *nX, INT *nY, INT RegionX, INT RegionY, INT MapX, INT MapY, INT MapOffX, INT MapOffY)
{
*nX = RegionX * REGION_WIDTH + MapX * CELL_WIDTH + (MapOffX >> 10);
*nY = RegionY * REGION_HEIGHT + MapY * CELL_HEIGHT + (MapOffY >> 10);
}
VOID GetMapPos(INT *nX, INT *nY, INT RegionX, INT RegionY, INT MapX, INT MapY)
{
*nX = (RegionX * REGION_WIDTH + MapX * CELL_WIDTH) >> 8;
*nY = (RegionY * REGION_HEIGHT + MapY * CELL_HEIGHT) >> 9;
}
I compiled this Code successfully without opening the game.exe process.
But when i opened the process. It threw an error at the first PrintF():
ERROR: Pos: 1777 Call to undefined function or incompatible argument lists (“PrintF”)...
If i removed the first PrintF, everything is OK.I don't know why?
Can anybody help me.
BTW, can u help me write a function to open the game at C:\game.exe and automatically type the login and the password to login to the game.
And another question is how i can alway check the pPlayer.Fight and the pPlayer.Health that if (Fight == 1 && Health <= 500) then call a function at the Function Address to do something.
Sorry bcz I don't kown how to write code for executing the function at the FUNC_ADD.
Anyone help me to call the function Run(int x, int y) at the DWORD RUN_FUNC_ADD = 0x004C41B7;
Waitting for "extern to function" coming soon.
Thanks in advance.