namespace offs {
inline uintptr_t dwEntityList = 0;
inline uintptr_t dwLocalController = 0;
inline uintptr_t dwLocalPawn = 0;
inline uintptr_t dwViewMatrix = 0;
inline uintptr_t fnCreateMove = 0;
inline uintptr_t fnTraceShape = 0;
inline void Init() {
dwEntityList = mem::Rel(mem::Pattern("client.dll", "48 8B 0D ?? ?? ?? ?? 48 89 7C 24"), 3, 7);
dwLocalController = mem::Rel(mem::Pattern("client.dll", "48 8B 05 ?? ?? ?? ?? 41 89 BE"), 3, 7);
dwLocalPawn = mem::Rel(mem::Pattern("client.dll", "48 8B 0D ?? ?? ?? ?? 48 8B 01 48 8B 40 38"), 3, 7);
dwViewMatrix = mem::Rel(mem::Pattern("client.dll", "48 8D 0D ?? ?? ?? ?? 48 C1 E0 06"), 3, 7);
fnTraceShape = mem::Rel(mem::Pattern("client.dll", "E8 ?? ?? ?? ?? 48 8B 4D ?? 48 85 C9"), 1, 5);
fnCreateMove = mem::Pattern("client.dll", "48 8B C4 4C 89 48 18 55 56 41 55");
}
}
struct Pawn {
uintptr_t ptr = 0;
bool ok() const { return ptr != 0; }
int hp() const { return mem::Read<int>(ptr + 0x344); }
int team() const { return mem::Read<int>(ptr + 0x3C8); }
bool alive() const { return hp() > 0; }
Vec3 origin() const {
uintptr_t sn = mem::Read<uintptr_t>(ptr + 0x328);
return mem::Read<Vec3>(sn + 0xC8);
}
Vec3 eye() const {
Vec3 o = origin();
float e = mem::Read<float>(ptr + 0x14D0);
return Vec3(o.x, o.y, o.z + e);
}
uintptr_t bones() const {
uintptr_t sn = mem::Read<uintptr_t>(ptr + 0x328);
return mem::Read<uintptr_t>(sn + 0x160 + 0x80);
}
Vec3 bone(int i) const {
uintptr_t b = bones();
if (!b) return Vec3(0, 0, 0);
struct B { float x, y, z, w; };
B v = mem::Read<B>(b + i * 32);
return Vec3(v.x, v.y, v.z);
}
bool spotted() const {
return mem::Read<bool>(ptr + 0x1C38);
}
};
struct Controller {
uintptr_t ptr = 0;
bool ok() const { return ptr != 0; }
Pawn pawn() const {
uintptr_t h = mem::Read<uintptr_t>(ptr + 0x7D8);
if (!h) return Pawn{0};
uintptr_t list = mem::Read<uintptr_t>(offs::dwEntityList);
if (!list) return Pawn{0};
uintptr_t e = mem::Read<uintptr_t>(list + 0x10 + 8 * (h >> 9));
if (!e) return Pawn{0};
uintptr_t result = mem::Read<uintptr_t>(e + 8 * (h & 0x1FF));
return Pawn{ result };
}
const char* name() const {
const char* n = (const char*)(ptr + 0x618);
__try { if(n) return n; }
__except(EXCEPTION_EXECUTE_HANDLER){}
return "?";
}
int team() const { return mem::Read<int>(ptr + 0x3E4); }
};
static Controller GetPlayer(int i) {
uintptr_t list = mem::Read<uintptr_t>(offs::dwEntityList);
if (!list) return Controller{0};
uintptr_t e = mem::Read<uintptr_t>(list + 0x10 + 8 * (i >> 9));
if (!e) return Controller{0};
uintptr_t result = mem::Read<uintptr_t>(e + 8 * (i & 0x1FF));
return Controller{ result };
}