Source Code H1z1 sdk

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
Cuz why not. Up-to-date with 28.07 update. For improvement call game functions to get origin/positions cuz class changes often. Figure physix out on your own as homework.

C++:
#ifndef _ENGINE_H
#define _ENGINE_H

#include <Windows.h>
#include <d3dx9.h>

#include "Pattern.h"

DWORD64 CGAME = 0;
DWORD64 CGRAPHICS = 0;
#define WORLDTOSCREEN 0x14030B420 //outdated
#define DRAWDEBUGTEXT 0x140307460 //outdated

#define FIRSTOBJ 0x11D8
#define NEXTOBJ  0x420

#define NAME_OFFSET 0x4f8
#define VECORIGIN_ENTITY_OFFSET 0x1c0
#define VECORIGIN_LOCAL_OFFSET 0x1c0
#define VECORIGIN_VEHICLE_OFFSET 0x1c0
#define VECORIGIN_ITEM_OFFSET 0x1420 // spawn origin
#define CLASSID_OFFSET 0x5e0


/* 
//not using

// use d3dxvec3 and convert to vec4 just use 1.f as the 4th plane element
bool WorldToScreen(D3DXVECTOR4* in, int* x, int* y)
{
	return ((bool(__thiscall*)(void*, Vec4*, int*, int*)) dwWorldToScreen)(this, in, x, y);
}

typedef void(__thiscall* oDrawDebugText)(void* pThis, char* text, __int64 x, __int64 y, int color);
oDrawDebugText pDrawDebugText = (oDrawDebugText)(DRAWDEBUGTEXT);
*/

class CObject
{
public:
	char* getName()
	{
		return *(char**)((DWORD64)this + NAME_OFFSET);
	}
	CObject* getNext()
	{
		return (CObject*)*(DWORD64*)((DWORD64)this + NEXTOBJ);
	}
	D3DXVECTOR3* getEntityOrigin()
	{
		return (D3DXVECTOR3*)((DWORD64)this + VECORIGIN_ENTITY_OFFSET);
	}
	D3DXVECTOR3* getLocalOrigin()
	{
		return (D3DXVECTOR3*)((DWORD64)this + VECORIGIN_LOCAL_OFFSET);
	}
	D3DXVECTOR3* getVehicleOrigin()
	{
		return (D3DXVECTOR3*)((DWORD64)this + VECORIGIN_VEHICLE_OFFSET);
	}
	D3DXVECTOR3* getItemVecOrigin()
	{
		return (D3DXVECTOR3*)((DWORD64)this + VECORIGIN_ITEM_OFFSET);
	}
	D3DXVECTOR3* getDirection()
	{
		return (D3DXVECTOR3*)((DWORD64)this + VECDIRECTION_OFFSET);
	}
	int getObjectClassId()
	{
		return *(int*)((DWORD64)this + CLASSID_OFFSET);
	}
};

class CGame
{
public:
	__forceinline CObject* getFirstObject()
	{
		return (CObject*)*(DWORD64*)((DWORD64)this + FIRSTOBJ);
	}
	__forceinline int getObjectCount()
	{
		return *(int*)((DWORD64)this + OBJCOUNT);
	}
	static CGame* Singleton()
	{
		if (!CGAME)
		{
			DWORD64 qwBase = (DWORD64)(GetModuleHandleA(0));

			DWORD64 qwResult = (DWORD64)Pattern::FindPattern(qwBase,
				0x413D000,
				(BYTE*)"\xF3\x45\x0F\x10\xEF\x45\x0F\x10\xE6\xF3",
				"xxxxxxxxxx");

			DWORD dwRIP = *(DWORD*)(qwResult - 4);
			CGAME = static_cast<DWORD64>(dwRIP) + qwResult;
		}

		return (CGame*)(*(ULONGLONG*)CGAME);
	}
};

class CCameraMatrix
{
public:
	char __pad0[0x1B0];
	float m_WorldProj[4][4]; // 0x01B0
};

class CCamera
{
public:
	char pad0[0x20];
	CCameraMatrix* m_pCameraMat; // 0x0020 
};

class CGraphics
{
public:
	char pad0[40];
	int m_nScreenWidth;		// 0x0028 
	int m_nScreenHeight;		// 0x002C 
	char pad1[24];
	CCamera* m_pCamera;		// 0x0048 

	static CGraphics* Singleton()
	{
		if (!CGRAPHICS)
		{
			DWORD64 qwBase = (DWORD64)(GetModuleHandleA(0));

			DWORD64 qwResult = (DWORD64)Pattern::FindPattern(qwBase,
				0x413D000,
				(BYTE*)"\x48\x8B\x05\x00\x00\x00\x00\x48\x8B\x48\x00\x48\x8B\x89",
				"xxx????xxx?xxx");
			DWORD dwRIP = *(DWORD*)(qwResult + 3);
			CGRAPHICS = static_cast<DWORD64>(dwRIP) + 7 + qwResult;
		}

		return (CGraphics*)(*(ULONGLONG*)CGRAPHICS);
	}
};

D3DXVECTOR3& GetMatrixAxis(const D3DXMATRIX& matrix, UINT i)
{
	return *(D3DXVECTOR3*)&matrix.m[i][0];
}

bool WorldToScreen(D3DXVECTOR3* World, D3DXVECTOR3* Out)
{
	CGraphics* pGraphics = CGraphics::Singleton();
	if (!pGraphics)
		return false;

	D3DXMATRIX Matrix = *(D3DXMATRIX*)(&(pGraphics->m_pCamera->m_pCameraMat->m_WorldProj));

	int ScreenWidth = pGraphics->m_nScreenWidth;
	int ScreenHeight = pGraphics->m_nScreenHeight;

	D3DXMatrixTranspose(&Matrix, &Matrix);

	Matrix._21 *= -1;
	Matrix._22 *= -1;
	Matrix._23 *= -1;
	Matrix._24 *= -1;

	D3DXVECTOR3 wp = GetMatrixAxis(Matrix, 3);

	float w = D3DXVec3Dot(&wp, World) + Matrix.m[3][3];

	if (w < 0.098)
		return false;

	D3DXVECTOR3 xp = GetMatrixAxis(Matrix, 0);
	D3DXVECTOR3 zp = GetMatrixAxis(Matrix, 1);

	float x = D3DXVec3Dot(&xp, World) + Matrix.m[0][3];
	float y = D3DXVec3Dot(&zp, World) + Matrix.m[1][3];

	Out->x = static_cast<float>((ScreenWidth / 2) * (1.0 + x / w));
	Out->y = static_cast<float>((ScreenHeight / 2) * (1.0 - y / w));

	return true;
}

enum classIds_t
{
	Player = 4,
	PlayerRoyale = 5,
	Zombie0 = 12,
	OffRoad = 17,
	Deer = 19,
	Wolf = 20,
	Food = 21,
	Items = 44,
	Weapons = 52,
	Chest = 66, 
	Wreck0 = 68,
	Wreck1 = 69,
	Wreck2 = 70,
	Bear = 80,
	Barbeque = 83,
	Rabbit = 85,
	Zombie1 = 91,
	PickupTruck = 114,
	PoliceCar = 118,
	SleepingBag = 122,
	Round_308 = 134,
	Flare = 45,
	LootBag = 46,
	StorageContainer = 51,
	PlayerStash = 109,
	LootCache = 127,
	Landmine = 156,
	WeaponLocker = 112,
	FragSmokeNades = 174,
	StunNade = 178
};

#define IS_PLAYER (classId == classIds_t::Player || classId == classIds_t::PlayerRoyale)
#define IS_ZOMBIE (classId == classIds_t::Zombie0 || classId == classIds_t::Zombie1)
#define IS_ANIMAL (classId == classIds_t::Wolf || classId == classIds_t::Bear || classId == classIds_t::Deer || classId == classIds_t::Rabbit)

#define IS_VEHICLE (classId == classIds_t::OffRoad || classId == classIds_t::PickupTruck || classId == classIds_t::PoliceCar)

#define IS_WEAPON (classId == classIds_t::Weapons || classId == classIds_t::Flare || classId == classIds_t::Landmine || classId == classIds_t::FragSmokeNades || classId == classIds_t::StunNade)
#define IS_AMMO (classId == classIds_t::Round_308)

#define IS_ITEM (classId == classIds_t::Items || classId == classIds_t::LootBag)
#define IS_LOOT (classId == classIds_t::StorageContainer || classId == classIds_t::PlayerStash || classId == classIds_t::LootCache || classId == classIds_t::Chest || classId == classIds_t::WeaponLocker)
#define IS_FOOD (classId == classIds_t::Food)


class CPhysx 
{
public:
	// ....

};

#endif
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
Player iteration

C++:
CGame* pGame = CGame::Singleton();
if (!pGame)
	return;

if (!pGame->getFirstObject())
	return;

for (CObject* pObj = pGame->getFirstObject()->getNext(); pObj; pObj = pObj->getNext(), i++)
{
	if (!IsValidPtr(pObj))
		break;

	int classId = pObj->getObjectClassId();

	D3DXVECTOR3* pTargetOriginVec;
	if (IS_PLAYER)
	{
		pTargetOriginVec= obj->getEntityOrigin();
		// ....
	}
}
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods