Skip to content

Commit

Permalink
update 28.05
Browse files Browse the repository at this point in the history
* fix & simplify and optimize autowall
* correct includes to newest win sdk
* correct codestyle
* other optimizations
  • Loading branch information
rollraw committed May 28, 2020
1 parent 142cfce commit f1c052f
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 183 deletions.
6 changes: 3 additions & 3 deletions base/features/antiaim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void CAntiAim::Run(CUserCmd* pCmd, CBaseEntity* pLocal, bool& bSendPacket)
}
}

// get angles
// save angles to modify later
angSentView = pCmd->angViewPoint;

/* edge antiaim, fakewalk, other hvhboi$tuff do here */
Expand All @@ -83,7 +83,7 @@ void CAntiAim::Run(CUserCmd* pCmd, CBaseEntity* pLocal, bool& bSendPacket)
angSentView.Clamp();
}

// set angles
// send angles
pCmd->angViewPoint = angSentView;
}

Expand Down Expand Up @@ -188,7 +188,7 @@ void CAntiAim::Yaw(CUserCmd* pCmd, CBaseEntity* pLocal, float flServerTime, bool
if (C::Get<int>(Vars.iAntiAimDesyncKey) > 0 && IPT::IsKeyReleased(C::Get<int>(Vars.iAntiAimDesyncKey)))
flSide = -flSide;

// check is lowerbody updated and have choked command
// check is lowerbody updated
if (flServerTime >= flNextLowerBodyUpdate)
{
// check is we not choke now
Expand Down
229 changes: 120 additions & 109 deletions base/features/autowall.cpp

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions base/features/autowall.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ struct FireBulletData_t
Trace_t enterTrace;
CTraceFilter filter;

float flTraceLength;
float flMaxRange;
float flCurrentDamage;
float flReductionDamage;
float flPenetrateDamage;
int iPenetrateCount;
};

Expand All @@ -41,7 +37,7 @@ class CAutoWall : public CSingleton<CAutoWall>
// Check
void ClipTraceToPlayers(const Vector& vecAbsStart, const Vector& vecAbsEnd, unsigned int fMask, ITraceFilter* pFilter, Trace_t* pTrace);
bool IsBreakableEntity(CBaseEntity* pEntity);
bool TraceToExit(Trace_t* pEnterTrace, Trace_t* pExitTrace, Vector vecStart, Vector vecDirection);
bool TraceToExit(Trace_t* pEnterTrace, Trace_t* pExitTrace, Vector vecPosition, Vector vecDirection);
bool HandleBulletPenetration(CBaseEntity* pLocal, surfacedata_t* pEnterSurfaceData, CCSWeaponData* pWeaponData, FireBulletData_t& data);
bool SimulateFireBullet(CBaseEntity* pLocal, CBaseCombatWeapon* pWeapon, FireBulletData_t& data);
};
3 changes: 2 additions & 1 deletion base/features/triggerbot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ void CTriggerBot::Run(CUserCmd* pCmd, CBaseEntity* pLocal)
if (C::Get<bool>(Vars.bTriggerAutoWall))
{
FireBulletData_t data;
float flDamage = CAutoWall::Get().GetDamage(pLocal, vecEnd, &data);

// check for minimal damage
if (CAutoWall::Get().GetDamage(pLocal, vecEnd, &data) < C::Get<int>(Vars.iTriggerMinimalDamage))
if (flDamage < C::Get<int>(Vars.iTriggerMinimalDamage))
return;

// copy trace from autowall
Expand Down
6 changes: 4 additions & 2 deletions base/sdk/datatypes/qangle.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
// used: isfinite, fmodf, remainderf
#include <cmath>

class QAngle
{
Expand Down Expand Up @@ -151,8 +153,8 @@ class QAngle

QAngle Normalize()
{
this->x = std::isfinite(this->x) ? std::remainder(this->x, 360.f) : 0.f;
this->y = std::isfinite(this->y) ? std::remainder(this->y, 360.f) : 0.f;
this->x = std::isfinite(this->x) ? std::remainderf(this->x, 360.f) : 0.f;
this->y = std::isfinite(this->y) ? std::remainderf(this->y, 360.f) : 0.f;
this->z = 0.f;
return *this;
}
Expand Down
3 changes: 3 additions & 0 deletions base/sdk/datatypes/vector.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#pragma once
// used: isfinite, fmodf, sqrtf
#include <cmath>

// @credits: https://github.com/ValveSoftware/source-sdk-2013/blob/master/sp/src/public/mathlib/vector.h

enum
Expand Down
21 changes: 10 additions & 11 deletions base/sdk/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,11 @@ class CBaseEntity : public IClientEntity, public CBaseViewModel
return *(std::array<float, 24U>*)((std::uintptr_t)this + CNetvarManager::Get().flPoseParameter);
}

bool* IsClientSideAnimation()
{
return (bool*)((std::uintptr_t)this + CNetvarManager::Get().bClientSideAnimation);
}

CAnimationLayer* GetAnimationLayers()
{
// @pattern = 8B 89 ? ? ? ? 8D 0C D1 + 0x2 // should work but for me offset is easy to update
Expand All @@ -777,11 +782,6 @@ class CBaseEntity : public IClientEntity, public CBaseViewModel
return (CBasePlayerAnimState*)((std::uintptr_t)this + 0x3900);
}

bool* IsClientSideAnimation()
{
return (bool*)((std::uintptr_t)this + CNetvarManager::Get().bClientSideAnimation);
}

#pragma region baseentity_exports
// DoExtraBonesProcessing
// pattern xref: "ankle_L"
Expand All @@ -800,10 +800,10 @@ class CBaseEntity : public IClientEntity, public CBaseViewModel

Vector GetEyePosition()
{
Vector vecIn = { };
Vector vecPosition = { };

// get eye position
MEM::CallVFunc<void, Vector&>(this, 168, vecIn);
MEM::CallVFunc<void, Vector&>(this, 168, vecPosition);

// correct this like it do weapon_shootpos
// @ida weapon_shootpos: 55 8B EC 56 8B 75 08 57 8B F9 56 8B 07 FF 90
Expand All @@ -812,11 +812,11 @@ class CBaseEntity : public IClientEntity, public CBaseViewModel
CBasePlayerAnimState* pAnimState = this->GetAnimationState();

if (pAnimState != nullptr)
ModifyEyePosition(pAnimState, &vecIn);
ModifyEyePosition(pAnimState, &vecPosition);
}

// return corrected position
return vecIn;
return vecPosition;
}

void SetSequence(int iSequence)
Expand Down Expand Up @@ -868,7 +868,6 @@ class CBaseEntity : public IClientEntity, public CBaseViewModel
return (this->GetLifeState() == LIFE_ALIVE) ? true : false;
}


inline void SetPoseAngles(float flYaw, float flPitch)
{
auto& arrPose = this->GetPoseParameter();
Expand All @@ -895,7 +894,7 @@ class CBaseEntity : public IClientEntity, public CBaseViewModel
bool IsEnemy(CBaseEntity* pEntity);
bool IsTargetingLocal(CBaseEntity* pLocal);
bool IsCanShoot(CBaseCombatWeapon* pWeapon);
bool IsVisible(CBaseEntity* pLocal, const Vector& vecSpot, bool bSmokeCheck = false);
bool IsVisible(CBaseEntity* pEntity, const Vector& vecSpot, bool bSmokeCheck = false);
#pragma endregion
};

Expand Down
94 changes: 49 additions & 45 deletions base/utilities/math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,40 @@ bool M::Setup()
return true;
}

void M::VectorAngles(const Vector& forward, QAngle& angles)
void M::VectorAngles(const Vector& vecForward, QAngle& angView)
{
if (forward[PITCH] == 0.f && forward[YAW] == 0.f)
float flPitch, flYaw;

if (vecForward[PITCH] == 0.f && vecForward[YAW] == 0.f)
{
angles[PITCH] = (forward[ROLL] > 0.f) ? 270.f : 90.f;
angles[YAW] = 0.f;
flPitch = (vecForward[ROLL] > 0.f) ? 270.f : 90.f;
flYaw = 0.f;
}
else
{
angles[PITCH] = std::atan2f(-forward[ROLL], forward.Length2D()) * -180.f / M_PI;
angles[YAW] = std::atan2f(forward[YAW], forward[PITCH]) * 180.f / M_PI;
flPitch = std::atan2f(-vecForward[ROLL], vecForward.Length2D()) * 180.f / M_PI;

if (flPitch < 0.f)
flPitch += 360.f;

flYaw = std::atan2f(vecForward[YAW], vecForward[PITCH]) * 180.f / M_PI;

if (angles[YAW] > 90.f) angles[YAW] -= 180.f;
else if (angles[YAW] < 90.f) angles[YAW] += 180.f;
else if (angles[YAW] == 90.f) angles[YAW] = 0.f;
if (flYaw < 0.f)
flYaw += 360.f;
}

angles[ROLL] = 0.f;
angView[PITCH] = flPitch;
angView[YAW] = flYaw;
angView[ROLL] = 0.f;
}

void M::AngleVectors(const QAngle& angles, Vector* pForward, Vector* pRight, Vector* pUp)
void M::AngleVectors(const QAngle& angView, Vector* pForward, Vector* pRight, Vector* pUp)
{
float sr, sp, sy, cr, cp, cy;
float sp, sy, sr, cp, cy, cr;

DirectX::XMScalarSinCos(&sp, &cp, M_DEG2RAD(angles[PITCH]));
DirectX::XMScalarSinCos(&sy, &cy, M_DEG2RAD(angles[YAW]));
DirectX::XMScalarSinCos(&sr, &cr, M_DEG2RAD(angles[ROLL]));
DirectX::XMScalarSinCos(&sp, &cp, M_DEG2RAD(angView[PITCH]));
DirectX::XMScalarSinCos(&sy, &cy, M_DEG2RAD(angView[YAW]));
DirectX::XMScalarSinCos(&sr, &cr, M_DEG2RAD(angView[ROLL]));

if (pForward != nullptr)
{
Expand All @@ -65,46 +72,46 @@ void M::AngleVectors(const QAngle& angles, Vector* pForward, Vector* pRight, Vec

if (pRight != nullptr)
{
pRight->x = (-1 * sr * sp * cy + -1 * cr * -sy);
pRight->y = (-1 * sr * sp * sy + -1 * cr * cy);
pRight->x = -1 * sr * sp * cy + -1 * cr * -sy;
pRight->y = -1 * sr * sp * sy + -1 * cr * cy;
pRight->z = -1 * sr * cp;
}

if (pUp != nullptr)
{
pUp->x = (cr * sp * cy + -sr * -sy);
pUp->y = (cr * sp * sy + -sr * cy);
pUp->x = cr * sp * cy + -sr * -sy;
pUp->y = cr * sp * sy + -sr * cy;
pUp->z = cr * cp;
}
}

void M::MatrixGetColumn(const matrix3x4_t& matIn, int nColumn, Vector& vecOut)
void M::MatrixGetColumn(const matrix3x4_t& matrix, int nColumn, Vector& vecOut)
{
vecOut.x = matIn[0][nColumn];
vecOut.y = matIn[1][nColumn];
vecOut.z = matIn[2][nColumn];
vecOut.x = matrix[0][nColumn];
vecOut.y = matrix[1][nColumn];
vecOut.z = matrix[2][nColumn];
}

void M::MatrixSetColumn(const Vector& vecIn, int nColumn, matrix3x4_t& matOut)
void M::MatrixSetColumn(const Vector& vecColumn, int nColumn, matrix3x4_t& matrix)
{
matOut[0][nColumn] = vecIn.x;
matOut[1][nColumn] = vecIn.y;
matOut[2][nColumn] = vecIn.z;
matrix[0][nColumn] = vecColumn.x;
matrix[1][nColumn] = vecColumn.y;
matrix[2][nColumn] = vecColumn.z;
}

void M::MatrixSetOrigin(matrix3x4_t& matrix, const Vector vecOrigin, const Vector vecNewOrigin)
void M::MatrixSetOrigin(matrix3x4_t& matrix, const Vector& vecOrigin, const Vector& vecNewOrigin)
{
Vector vecMatrixOrigin(matrix[0][3], matrix[1][3], matrix[2][3]);
M::MatrixSetColumn(vecNewOrigin + (vecMatrixOrigin - vecOrigin), 3, matrix);
}

void M::AngleMatrix(const QAngle& angles, matrix3x4_t& matrix)
void M::AngleMatrix(const QAngle& angView, matrix3x4_t& matrix)
{
float sr, sp, sy, cr, cp, cy;
float sp, sy, sr, cp, cy, cr;

DirectX::XMScalarSinCos(&sp, &cp, M_DEG2RAD(angles[PITCH]));
DirectX::XMScalarSinCos(&sy, &cy, M_DEG2RAD(angles[YAW]));
DirectX::XMScalarSinCos(&sr, &cr, M_DEG2RAD(angles[ROLL]));
DirectX::XMScalarSinCos(&sp, &cp, M_DEG2RAD(angView[PITCH]));
DirectX::XMScalarSinCos(&sy, &cy, M_DEG2RAD(angView[YAW]));
DirectX::XMScalarSinCos(&sr, &cr, M_DEG2RAD(angView[ROLL]));

matrix[0][0] = cp * cy;
matrix[1][0] = cp * sy;
Expand Down Expand Up @@ -155,23 +162,20 @@ float M::GetFov(const QAngle& angView, const QAngle& angAimPoint)
return M_RAD2DEG(std::acosf(vecView.DotProduct(vecAim) / vecView.LengthSqr()));
}

QAngle M::CalcAngle(Vector src, Vector dst)
QAngle M::CalcAngle(Vector vecStart, Vector vecEnd)
{
QAngle angles;
Vector vecDelta = src - dst;
VectorAngles(vecDelta, angles);
QAngle angView;
Vector vecDelta = vecStart - vecEnd;
VectorAngles(vecDelta, angView);
vecDelta.Normalize();
return angles;
}

float M::VectorDistance(Vector src, Vector dst)
{
return std::sqrtf(std::pow(src.x - dst.x, 2) + std::pow(src.y - dst.y, 2) + std::pow(src.z - dst.z, 2));
return angView;
}

Vector M::VectorTransform(const Vector& vecIn, const matrix3x4_t& matrix)
Vector M::VectorTransform(const Vector& vecTransform, const matrix3x4_t& matrix)
{
return Vector(vecIn.DotProduct(matrix[0]) + matrix[0][3], vecIn.DotProduct(matrix[1]) + matrix[1][3], vecIn.DotProduct(matrix[2]) + matrix[2][3]);
return Vector(vecTransform.DotProduct(matrix[0]) + matrix[0][3],
vecTransform.DotProduct(matrix[1]) + matrix[1][3],
vecTransform.DotProduct(matrix[2]) + matrix[2][3]);
}

Vector M::ExtrapolateTick(Vector p0, Vector v0)
Expand Down
12 changes: 5 additions & 7 deletions base/utilities/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ namespace M
/* convert vector to angles */
void VectorAngles(const Vector& vecForward, QAngle& angView);
/* convert angles to x, y, z vectors */
void AngleVectors(const QAngle& angles, Vector* pForward, Vector* pRight = nullptr, Vector* pUp = nullptr);
void AngleVectors(const QAngle& angView, Vector* pForward, Vector* pRight = nullptr, Vector* pUp = nullptr);
/* set vector position by matrix column */
void MatrixGetColumn(const matrix3x4_t& matIn, int nColumn, Vector& vecOut);
void MatrixGetColumn(const matrix3x4_t& matrix, int nColumn, Vector& vecOut);
/* set matrix column position by vector */
void MatrixSetColumn(const Vector& vecIn, int nColumn, matrix3x4_t& matOut);
void MatrixSetColumn(const Vector& vecColumn, int nColumn, matrix3x4_t& matrix);
/* set matrix origin with matrix columns position */
void MatrixSetOrigin(matrix3x4_t& matIn, const Vector vecOrigin, const Vector vecNewOrigin);
void MatrixSetOrigin(matrix3x4_t& matIn, const Vector& vecOrigin, const Vector& vecNewOrigin);
/* convert angles to matrix */
void AngleMatrix(const QAngle& angles, matrix3x4_t& matrix);
/* convert angle to screen pixels by sensivity, pitch and yaw */
Expand All @@ -59,9 +59,7 @@ namespace M
/* calculate fov by view and target angles */
float GetFov(const QAngle& angView, const QAngle& angAimPoint);
/* calculate angles by source and destination vectors */
QAngle CalcAngle(const Vector src, Vector dst);
/* get distance from source to destination vectors */
float VectorDistance(Vector src, Vector dst);
QAngle CalcAngle(const Vector vecStart, Vector vecEnd);
/* transform vector by matrix and return it */
Vector VectorTransform(const Vector& vecIn, const matrix3x4_t& matrix);
/* calculate next tick position */
Expand Down

0 comments on commit f1c052f

Please sign in to comment.