-
Автор темы
- #1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Аим уводит куда то назад
Video:
Оффсеты(вроде правильные):
CFPPlayer: 0xD88
GetViewCamera: 0x17C0
Video:
Пожалуйста, авторизуйтесь для просмотра ссылки.
Оффсеты(вроде правильные):
CFPPlayer: 0xD88
GetViewCamera: 0x17C0
C++:
Vec3 Pos = GetBonePosById(pEntity, 22);
Vec3 vCameraPos, vFinalPos = { ZERO };
vCameraPos = Renderer->GetViewCamera();
Vec3 vector = Pos - vCameraPos;
float sqrtdist = cry_isqrtf(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z);
vector /= sqrtdist;
Quat qFinalRotation = Quat::CreateRotationVDir(vector.normalize());
if (GetAsyncKeyState(VK_F2))mActor->GetPlayer()->SetViewRotation(qFinalRotation);
SetViewRotation:
class CFPPlayer {
public:
void SetViewRotation(Quat& rotation) {
driver.write<Quat>((uintptr_t)this + 0x84, rotation);
driver.write<Quat>((uintptr_t)this + 0x94, rotation);
driver.write<Quat>((uintptr_t)this + 0xA4, rotation);
}
};
Vec3:
struct Vec3
{
public:
FLOAT x, y, z;
Vec3(type_zero) : x(0), y(0), z(0) {}
Vec3() { Vec3(0.f, 0.f, 0.f); }
Vec3(FLOAT x, FLOAT y, FLOAT z)
{
this->x = x;
this->y = y;
this->z = z;
}
FLOAT length() const { return sqrt(x * x + y * y + z * z); }
FLOAT Distance(Vec3& VecB)
{
Vec3 Out = *this - VecB;
return sqrt(Out.x * Out.x + Out.y * Out.y + Out.z * Out.z);
}
Vec3 PZD(Vec3& VecB)
{
Vec3 Out = *this - VecB;
return Out / sqrt(Out.x * Out.x + Out.y * Out.y + Out.z * Out.z);
}
VOID Set(FLOAT x, FLOAT y, FLOAT z)
{
this->x = x;
this->y = y;
this->z = z;
}
void Normalize()
{
assert(this->IsValid());
float fInvLen = isqrt_safe_tpl(x * x + y * y + z * z);
x *= fInvLen; y *= fInvLen; z *= fInvLen;
}
bool NumberValid(const float& x)
{
uint32 i = FloatU32(x);
uint32 expmask = FloatU32ExpMask;
uint32 iexp = i & expmask;
bool invalid = (iexp == expmask);
if (invalid)
{
union f32_u
{
uint32 uintVal;
f32 floatVal;
};
f32_u u; u.uintVal = 0x7F800001;
float fpe = u.floatVal;
(void)fpe;
}
return !invalid;
}
bool IsValid()
{
if (!NumberValid(x)) return false;
if (!NumberValid(y)) return false;
if (!NumberValid(z)) return false;
return true;
}
Vec3& normalize()
{
FLOAT len2 = x * x + y * y + z * z;
if (len2 > 1e-20f)
{
FLOAT rlen = (float)1.0 / sqrt(len2);
x *= rlen; y *= rlen; z *= rlen;
}
else { x = 0; y = 0; z = 1; }
return *this;
}
Vec3& FastNormalize()
{
FLOAT l = length();
l = 1.f / l;
this->x *= l;
this->y *= l;
this->z *= l;
return *this;
}
Vec3 GetNormalized() const
{
float fInvLen = isqrt_safe_tpl(x * x + y * y + z * z);
Vec3 out = *this;
out.x *= fInvLen;
out.y *= fInvLen;
out.z *= fInvLen;
return out;
}
Vec3 GetNormalizedSafe(const struct Vec3& safe) const
{
float fLen2 = x * x + y * y + z * z;
if (fLen2 > 0.0f)
{
float fInvLen = isqrt_tpl(fLen2);
Vec3 out;
out.x = safe.x * fInvLen;
out.y = safe.y * fInvLen;
out.z = safe.z * fInvLen;
return out;
}
else { return safe; }
}
FLOAT len2() { return x * x + y * y + z * z; }
FLOAT len() { return sqrt(x * x + y * y + z * z); }
Vec3 operator / (FLOAT fValue) { return Vec3(x / fValue, y / fValue, z / fValue); }
Vec3& operator /= (FLOAT fValue)
{
*this = *this / fValue;
return *this;
}
Vec3 operator / (FLOAT fValue) const
{
Vec3 vOut;
vOut.x = this->x / fValue;
vOut.y = this->y / fValue;
vOut.z = this->z / fValue;
return vOut;
}
BOOL operator != (Vec3& vec) { return !(vec.x == x && vec.y == y && vec.z == z); }
BOOL operator == (Vec3& vec) { return (vec.x == x && vec.y == y && vec.z == z); }
Vec3 operator / (Vec3& vec) const { return Vec3(vec.x / x, vec.y / y, vec.z / z); }
Vec3 operator + (Vec3& vec) const { return Vec3(vec.x + x, vec.y + y, vec.z + z); }
Vec3 operator * (Vec3& vec) const { return Vec3(vec.x * x, vec.y * y, vec.z * z); }
Vec3 operator * (FLOAT fValue) const { return Vec3(x * fValue, y * fValue, z * fValue); }
Vec3 operator - (Vec3& vec) const { return Vec3(vec.x - x, vec.y - y, vec.z - z); }
VOID CheckMin(Vec3& other)
{
x = min(other.x, x);
y = min(other.y, y);
z = min(other.z, z);
}
VOID CheckMax(Vec3& other)
{
x = max(other.x, x);
y = max(other.y, y);
z = max(other.z, z);
}
Vec3(f32 f) : x(f), y(f), z(f) { assert(this->IsValid()); }
};
Quat:
struct Quat
{
public:
Vec3 v;
FLOAT w;
Quat(const Matrix3x3& m)
{
float s, p, tr = m.m00 + m.m11 + m.m22;
w = 1, v.x = 0, v.y = 0, v.z = 0;
if (tr > 0)
s = (float)sqrt(tr + 1.0f), p = 0.5f / s, w = s * 0.5f, v.x = (m.m21 - m.m12) * p, v.y = (m.m02 - m.m20) * p, v.z = (m.m10 - m.m01) * p;
else if ((m.m00 >= m.m11) && (m.m00 >= m.m22))
s = (float)sqrt(m.m00 - m.m11 - m.m22 + 1.0f), p = 0.5f / s, w = (m.m21 - m.m12) * p, v.x = s * 0.5f, v.y = (m.m10 + m.m01) * p, v.z = (m.m20 + m.m02) * p;
else if ((m.m11 >= m.m00) && (m.m11 >= m.m22))
s = (float)sqrt(m.m11 - m.m22 - m.m00 + 1.0f), p = 0.5f / s, w = (m.m02 - m.m20) * p, v.x = (m.m01 + m.m10) * p, v.y = s * 0.5f, v.z = (m.m21 + m.m12) * p;
else if ((m.m22 >= m.m00) && (m.m22 >= m.m11))
s = (float)sqrt(m.m22 - m.m00 - m.m11 + 1.0f), p = 0.5f / s, w = (m.m10 - m.m01) * p, v.x = (m.m02 + m.m20) * p, v.y = (m.m12 + m.m21) * p, v.z = s * 0.5f;
}
Quat() {}
friend float operator | (const Quat& q, const Quat& p) { return (q.v.x * p.v.x + q.v.y * p.v.y + q.v.z * p.v.z + q.w * p.w); }
friend Quat operator - (const Quat& q, const Quat& p)
{
Quat ret;
ret.w = q.w - p.w;
ret.v.x = q.v.x - p.v.x;
ret.v.y = q.v.y - p.v.y;
ret.v.z = q.v.z - p.v.z;
return ret;
}
void SetRotationVDir(const Vec3& vdir)
{
w = (0.70710676908493042f);
v.x = (vdir.z * 0.70710676908493042f);
v.y = (0.0f);
v.z = (0.0f);
float l = sqrt(vdir.x * vdir.x + vdir.y * vdir.y);
if (l > (0.00001))
{
Vec3 hv;
hv.x = vdir.x / l;
hv.y = vdir.y / l + 1.0f;
hv.z = l + 1.0f;
float r = sqrt(hv.x * hv.x + hv.y * hv.y);
float s = sqrt(hv.z * hv.z + vdir.z * vdir.z);
float hacos0 = 0.0;
float hasin0 = -1.0;
if (r > (0.00001)) { hacos0 = hv.y / r; hasin0 = -hv.x / r; }
float hacos1 = hv.z / s;
float hasin1 = vdir.z / s;
w = (hacos0 * hacos1);
v.x = (hacos0 * hasin1);
v.y = (hasin0 * hasin1);
v.z = (hasin0 * hacos1);
}
}
static Quat CreateRotationVDir(const Vec3& vdir)
{
Quat q;
q.SetRotationVDir(vdir);
return q;
}
void Normalize(void)
{
float d = sqrt(w * w + v.x * v.x + v.y * v.y + v.z * v.z);
w *= d;
v.x *= d;
v.y *= d;
v.z *= d;
}
void SetNlerp(const Quat& p, const Quat& tq, float t)
{
Quat q = tq;
assert(p.IsValid());
assert(q.IsValid());
if ((p | q) < 0)
{
float qx = -q.v.x;
float qy = -q.v.y;
float qz = -q.v.z;
q.v.x = qx;
q.v.y = qy;
q.v.z = qz;
}
v.x = p.v.x * (1.0f - t) + q.v.x * t;
v.y = p.v.y * (1.0f - t) + q.v.y * t;
v.z = p.v.z * (1.0f - t) + q.v.z * t;
w = p.w * (1.0f - t) + q.w * t;
Normalize();
}
void SetSlerp(const Quat& tp, const Quat& tq, float t)
{
assert(tp.IsValid());
Quat p, q;
p = tp;
q = tq;
Quat q2;
float cosine = (p | q);
if (cosine < 0.0f)
{
float qx = -q.v.x;
float qy = -q.v.y;
float qz = -q.v.z;
cosine = -cosine;
q.v.x = qx;
q.v.y = qy;
q.v.z = qz;
}
if (cosine > 0.9999f)
{
SetNlerp(p, q, t);
return;
}
q2.w = q.w - p.w * cosine;
q2.v.x = q.v.x - p.v.x * cosine;
q2.v.y = q.v.y - p.v.y * cosine;
q2.v.z = q.v.z - p.v.z * cosine;
float sine = sqrt(q2 | q2);
float s, c;
sincos(atan2(sine, cosine) * t, &s, &c);
w = (p.w * c + q2.w * s / sine);
v.x = (p.v.x * c + q2.v.x * s / sine);
v.y = (p.v.y * c + q2.v.y * s / sine);
v.z = (p.v.z * c + q2.v.z * s / sine);
}
static Quat CreateSlerp(const Quat& p, const Quat& tq, float t)
{
Quat d;
d.SetSlerp(p, tq, t);
return d;
}
};