Tutorial (C++) How To Add in MW2/MW3 Structs

Venox

Moderator
Messages
95
Points
583
Code:
//Some structs  for mw3 but you can use this mw2(Update the Offsets )


struct Vector3;
struct gentity_s;
struct playerState_s;
struct Vector3
{
    float v[3];
    Vector3(float v1, float v2, float v3)
    {
        v[0] = v1; v[1] = v2; v[2] = v3;
    }
    VOID Print(PCHAR Text)
    {
        DbgPrint("%s addr: %X v1: %f v2: %f v3: %f\n", Text, v, v[0], v[1], v[2]);
    }
};
struct gentity_s
{
    INT EntityNumber;
    BYTE _0x4[0x14];
    Vector3 Origin;
    BYTE _0x1B[0x18];
    Vector3 Angles;
    BYTE _0x36[0x110];
    playerState_s* playerState;
    BYTE _0x15C[0xC];
    UINT16 ModelIndex;
    BYTE _0x16A[0x32];
    INT Health;
    BYTE _0x1A0[0xE0];
};
struct playerState_s
{
    BYTE _0x0[0x1C];
    Vector3 Origin;
    Vector3 Velocity;
    BYTE _0x22[0x32E4];
    INT Score;
    BYTE _0x331C[0x70];
    CHAR PlayerName[32];
    INT MaxHealth;
    BYTE _0x33B0[0x24];
    INT Team;
    BYTE _0x33D8[0x78];
    CHAR ClanTag[4];
    BYTE _0x3454[0x1A8];
    INT MovementFlags;
    BYTE _0x3600[0x380];

    VOID SetOrigin(Vector3 NewOrigin)
    {
        memcpy((PVOID)Origin.v, (PVOID)NewOrigin.v, sizeof(float) * 3);
    }
    VOID SetVelocity(Vector3 NewVelocity)
    {
        memcpy((PVOID)Velocity.v, (PVOID)NewVelocity.v, sizeof(float) * 3);
    }
};
gentity_s *gentity(INT Index)
{
    return (gentity_s*)(0x82DCCC80 + (Index * 0x280));
}
DWORD gclient(INT Client)
{
    return *(DWORD*)(0x834C0480 + 0x205E90) + (Client * 0x68B80);
}



//Some functions


VOID (__cdecl *ClientCommand)(INT ClientNumber) = (VOID (__cdecl *)(INT))0x82239C80;
BOOL (__cdecl *Dvar_GetBool)(PCHAR Dvar) = (BOOL (__cdecl *)(PCHAR))0x8232E200;
PCHAR (__cdecl *Dvar_GetString)(PCHAR Dvar) = (PCHAR (__cdecl *)(PCHAR))0x8232E3C0;
VOID (__cdecl *SV_Cmd_EndTokenizedString)() = (VOID (__cdecl *)())0x82288988;
VOID (__cdecl *SV_Cmd_TokenizeString)(PCHAR TextIn) = (VOID (__cdecl *)(PCHAR))0x82288968;
UINT16 (__cdecl *Scr_ExecEntThreadNum)(INT EntityNumber, UINT32 ClassNumber, INT Handle, UINT32 ParameterCount) = (UINT16 (__cdecl *)(INT, UINT32, INT, UINT32))0x822C40C0;
VOID (__cdecl *CBuf_AddText)(INT LocalClientNumber, PCHAR Text) = (VOID (__cdecl *)(INT, PCHAR))0x82287EE0;
PCHAR (__cdecl *va)(PCHAR Format, ...) = va = (PCHAR (__cdecl *)(PCHAR, ...))0x82336528;
 


//Monitor connection/disconnection damage and death + more
//Code (Text):
UINT16 Scr_ExecEntThread(gentity_s *gentity, INT Handle, UINT32 ParameterCount)
{
    //DbgPrint("Scr_ExecEntThread - gentity[%X] Handle[%X] ParameterCount[%X]\n", gentity, Handle, ParameterCount);

    switch(Handle)
    {
    case 0x1037F4:
        DbgPrint("Player %i Connected!\n", gentity->EntityNumber);
        break;
    case 0x103814:
        DbgPrint("Player %i Disconnected!\n", gentity->EntityNumber);
        break;
    case 0x103822:
        //DbgPrint("Player %i Damaged!\n", gentity->EntityNumber);
        break;
    case 0x103851:
        //DbgPrint("Player %i Killed!\n", gentity->EntityNumber);
        break;
    }

    return Scr_ExecEntThreadNum(gentity->EntityNumber, NULL, Handle, ParameterCount);
}




//Then add this
//Code (Text):
DetourFunction((PDWORD)0x8226AEE8, (DWORD)Scr_ExecEntThread);

For a modded lobby
Code (Text):
    *(UINT16*)(0x8222E59C + 0x02) = 450; // G_Speed
    *(FLOAT*)0x82001D68 = 999; // Super Jump
    *(FLOAT*)0x82000C04 = 9999; // No Fall
    *(INT*)0x820F63E4 = 0x7D495378; // Unlimited Ammo - mr r9, r10
    *(INT*)0x820F46DC = 0x39600000; // Full Auto Guns - li r11, 0
    *(INT*)0x82233A7C = 0x60000000; // Disable PlayerCmd_FreezeControls

Real Godmode (no blood)
Code (Text):
gentity(Client)->playerState->MaxHealth = 9999;
gentity(Client)->Health = 9999;



//----------------------------------------------------------------------

*(int*)(getEntity(clientIndex) + 0x184) = 1; -> god mode On
*(int*)(getEntity(clientIndex) + 0x184) = 0; -> god mode Off
*(int*)(getEntity(clientIndex) + 0x184) = 3; -> no Knockback but no godMode
*(int*)(getEntity(clientIndex) + 0x184) = 2; -> demigod (i think)
 

Top