Начинающий
- Статус
- Оффлайн
- Регистрация
- 15 Окт 2019
- Сообщения
- 45
- Реакции
- 8
SetupEyePosition, and think() call (delete previous g_cl.m_shoot_pos lol):
// total bones actually used.
#define MAXSTUDIOBONES 128
vec3_t Aimbot::SetupEyePosition(ang_t ang) {
if (!g_cl.m_local)
return { };
ang.clamp();
// get bone cache pointer and count.
matrix3x4_t* pCachedBones = g_cl.m_local->m_BoneCache().Base();
int boneCount = g_cl.m_local->m_BoneCache().Count();
if (!pCachedBones || boneCount <= 0)
return g_cl.m_local->GetEyePosition();
matrix3x4_t pBackupMatrix[MAXSTUDIOBONES];
matrix3x4_t pAimbotMatrix[MAXSTUDIOBONES];
// backup current bone matrices.
std::memcpy(pBackupMatrix, pCachedBones, boneCount * sizeof(matrix3x4_t));
std::memcpy(pAimbotMatrix, g_ServerAnimations.m_uServerAnimations.m_pMatrix, sizeof g_ServerAnimations.m_uServerAnimations.m_pMatrix);
const auto vecOrigin = g_cl.m_local->get_abs_origin();
for (int i = 0; i < boneCount; ++i)
for (int n = 0; n <= 2; ++n)
pAimbotMatrix[i].m_flMatVal[n][3] += vecOrigin[n];
// write modified matrix to bone cache.
std::memcpy(pCachedBones, pAimbotMatrix, boneCount * sizeof(matrix3x4_t));
g_cl.m_local->ForceBoneCache();
const auto ret = g_cl.m_local->GetEyePosition();
// restore original bone matrices.
std::memcpy(pCachedBones, pBackupMatrix, boneCount * sizeof(matrix3x4_t));
return ret;
}
void Aimbot::think() {
if (!g_cl.m_local)
return;
if (g_cl.m_local->IsDead())
return;
ang_t angHead = { -3.5f, 0.f, 0.f };
// apply recoil angle..
angHead -= g_cl.m_local->m_aimPunchAngle() * cvars::weapon_recoil_scale->GetFloat();
// setup eyepos
g_cl.m_shoot_pos = SetupEyePosition(angHead);
.... rest of your code
Player::GetEyePosition, and Entity::GetEyePosition:
vec3_t Entity::GetEyePosition(bool bInterpolated) {
vec3_t vecOrigin = bInterpolated ? get_abs_origin() : m_vecOrigin();
vec3_t offset = this->m_vecViewOffset();
if (offset.z >= 46.1f) {
if (offset.z > 64.0f) {
offset.z = 64.0f;
}
}
else {
offset.z = 46.0f;
}
vecOrigin += offset;
return vecOrigin;
}
vec3_t Player::GetEyePosition(bool bModifyEyePos, bool bInterpolated) {
vec3_t eyePosition;
eyePosition.Init();
const float oldz = this->m_vecViewOffset().z;
if (this->m_vecViewOffset().z > 64.0f) {
this->m_vecViewOffset().z = 64.0f;
}
else if (this->m_vecViewOffset().z <= 46.05f) {
this->m_vecViewOffset().z = 46.0f;
}
if (bModifyEyePos) {
util::get_method<void(__thiscall*)(void*, vec3_t*)>(this, 277)(this, &eyePosition);
}
else {
eyePosition = this->Entity::GetEyePosition(bInterpolated);
}
this->m_vecViewOffset().z = oldz;
return eyePosition;
}