-
Автор темы
- #1
Ну да, резольвер под гидеон, ну а хуле ты мне сделаешь?
Resolver.cpp
Resolver.h
Resolver.cpp
C++:
#include "Resolver.h"
#include "../../Utility/Utilities.h"
#include "CAutoWall.h"
#define M_RADPI 57.295779513082f
#define TIME_TO_TICKS( dt ) ( (int)( 0.5 + (float)(dt) / Interfaces::Globals->interval_per_tick ) )
#define TICKS_TO_TIME( t ) ( Interfaces::Globals->interval_per_tick *( t ) )
c_autowall* autow;
static float GRD_TO_BOG(float GRD) {
return (M_PI / 180) * GRD;
}
inline float clamp_yaw(float yaw)
{
while (yaw > 180.f)
yaw -= 360.f;
while (yaw < -180.f)
yaw += 360.f;
return yaw;
}
float MaxDelta(CBaseEntity* pEnt) {
auto animstate = uintptr_t(pEnt->GetAnimState());
float duckammount = *(float*)(animstate + 0xA4);
float speedfraction = max(0, min(*reinterpret_cast<float*>(animstate + 0xF8), 1));
float speedfactor = max(0, min(1, *reinterpret_cast<float*> (animstate + 0xFC)));
float unk1 = ((*reinterpret_cast<float*> (animstate + 0x11C) * -0.30000001f) - 0.19999999f)* speedfraction;
float unk2 = unk1 + 1.f;
float unk3;
if (duckammount > 0) {
unk2 += ((duckammount * speedfactor) * (0.5f - unk2));
}
unk3 = *(float*)(animstate + 0x334) * unk2;
return unk3;
}
float normalize_yaw(float f)
{
if (std::isnan(f) || std::isinf(f))
f = 0.0f;
if (f > 9999999.0f)
f = 0.0f;
if (f < -9999999.0f)
f = 0.0f;
while (f < -180.0f)
f += 360.0f;
while (f > 180.0f)
f -= 360.0f;
return f;
}
bool IsKnife31()
{
auto wep = G::LocalPlayer->GetActiveWeapon();
if (wep == nullptr) return false;
int id = wep->GetItemDefenitionIndex();
static const std::vector<int> v = { WEAPON_BAYONET, WEAPON_KNIFE_SURVIVAL_BOWIE, WEAPON_KNIFE_BUTTERFLY, WEAPON_KNIFE_FALCHION, WEAPON_KNIFE_FLIP, WEAPON_KNIFE_GUT, WEAPON_KNIFE_KARAMBIT, WEAPON_KNIFE_M9_BAYONET, WEAPON_KNIFE_PUSH, WEAPON_KNIFE_TACTICAL , WEAPON_KNIFE, WEAPON_KNIFE_T, WEAPON_KNIFEGG };
return (std::find(v.begin(), v.end(), id) != v.end());
}
bool IsWeaponGrenade2()
{
auto wep = G::LocalPlayer->GetActiveWeapon();
if (wep == nullptr) return false;
int id = wep->GetItemDefenitionIndex();
static const std::vector<int> v = { WEAPON_FLASHBANG,WEAPON_HEGRENADE,WEAPON_SMOKEGRENADE,WEAPON_MOLOTOV,WEAPON_DECOY,WEAPON_INCGRENADE };
return (std::find(v.begin(), v.end(), id) != v.end());
}
void c_resolver::Resolver(CBaseEntity* player)
{
if (!c_config::get()->b["rage_resolver"])
return;
static float oldSimtime[65];
static float storedSimtime[65];
static float ShotTime[65];
static float SideTime[65][3];
static int LastDesyncSide[65];
static bool Delaying[65];
static CAnimationLayer StoredLayers[64][15];
static CBaseAnimState* StoredAnimState[65];
static float StoredPosParams[65][24];
static Vector oldEyeAngles[65];
static float oldGoalfeetYaw[65];
float* PosParams = (float*)((uintptr_t)player + 0x2774);
bool update = false;
bool shot = false;
static bool jittering[65];
auto* AnimState = player->GetAnimState();
if (!AnimState || !player->GetAnimOverlays() || !PosParams)
return;
auto RemapVal = [](float val, float A, float B, float C, float D) -> float
{
if (A == B)
return val >= B ? D : C;
return C + (D - C) * (val - A) / (B - A);
};
if (storedSimtime[player->GetIndex()] != player->GetSimTime())
{
jittering[player->GetIndex()] = false;
player->clientsideanim();
player->UpdateClientSideAnimation();
memcpy(StoredPosParams[player->GetIndex()], PosParams, sizeof(float) * 24);
memcpy(StoredLayers[player->GetIndex()], player->GetAnimOverlays(), (sizeof(CAnimationLayer) * player->GetNumAnimOverlays()));
oldGoalfeetYaw[player->GetIndex()] = AnimState->m_flGoalFeetYaw;
auto pWeapon = G::LocalPlayer->GetActiveWeapon();
if (!pWeapon)
return;
if (player->GetActiveWeapon() && IsKnife31() || IsWeaponGrenade2())
{
if (ShotTime[player->GetIndex()] != player->GetActiveWeapon()->GetLastShotTime())
{
shot = true;
ShotTime[player->GetIndex()] = player->GetActiveWeapon()->GetLastShotTime();
}
else
shot = false;
}
else
{
shot = false;
ShotTime[player->GetIndex()] = 0.f;
}
float angToLocal = normalize_yaw(calculate_angle(G::LocalPlayer->GetOrigin(), player->GetOrigin()).y);
float Back = normalize_yaw(angToLocal);
float DesyncFix = 0;
float Resim = normalize_yaw((0.24f / (player->GetSimTime() - oldSimtime[player->GetIndex()])) * (oldEyeAngles[player->GetIndex()].y - player->GetEyeAngles().y));
if (Resim > MaxDelta(player))
Resim = MaxDelta(player);
if (Resim < -MaxDelta(player))
Resim = -MaxDelta(player);
if (player->GetVelocity().Length2D() > 0.5f && !shot)
{
float Delta = normalize_yaw(normalize_yaw(calculate_angle(Vector(0, 0, 0), player->GetVelocity()).y) - normalize_yaw(normalize_yaw(AnimState->m_flGoalFeetYaw + RemapVal(PosParams[11], 0, 1, -60, 60)) + Resim));
int CurrentSide = 0;
if (Delta < 0)
{
CurrentSide = 1;
SideTime[player->GetIndex()][1] = Interfaces::Globals->curtime;
}
else if (Delta > 0)
{
CurrentSide = 2;
SideTime[player->GetIndex()][2] = Interfaces::Globals->curtime;
}
if (LastDesyncSide[player->GetIndex()] == 1)
{
Resim += (MaxDelta(player) - Resim);
DesyncFix += (MaxDelta(player) - Resim);
}
if (LastDesyncSide[player->GetIndex()] == 2)
{
Resim += (-MaxDelta(player) - Resim);
DesyncFix += (-MaxDelta(player) - Resim);
}
if (LastDesyncSide[player->GetIndex()] != CurrentSide)
{
Delaying[player->GetIndex()] = true;
if (.5f < (Interfaces::Globals->curtime - SideTime[player->GetIndex()][LastDesyncSide[player->GetIndex()]]))
{
LastDesyncSide[player->GetIndex()] = CurrentSide;
Delaying[player->GetIndex()] = false;
}
}
if (!Delaying[player->GetIndex()])
LastDesyncSide[player->GetIndex()] = CurrentSide;
}
else if (!shot)
{
float Brute = UseFreestandAngle[player->GetIndex()] ? normalize_yaw(Back + FreestandAngle[player->GetIndex()]) : player->GetLowerBodyYaw();
float Delta = normalize_yaw(normalize_yaw(Brute - normalize_yaw(normalize_yaw(AnimState->m_flGoalFeetYaw + RemapVal(PosParams[11], 0, 1, -60, 60))) + Resim));
if (Delta > MaxDelta(player))
Delta = MaxDelta(player);
if (Delta < -MaxDelta(player))
Delta = -MaxDelta(player);
Resim += Delta;
DesyncFix += Delta;
if (Resim > MaxDelta(player))
Resim = MaxDelta(player);
if (Resim < -MaxDelta(player))
Resim = -MaxDelta(player);
}
float Equalized = normalize_yaw(normalize_yaw(AnimState->m_flGoalFeetYaw + RemapVal(PosParams[11], 0, 1, -60, 60)) + Resim);
float JitterDelta = fabs(normalize_yaw(oldEyeAngles[player->GetIndex()].y - player->GetEyeAngles().y));
if (JitterDelta >= 70.f && !shot)
jittering[player->GetIndex()] = true;
if (player != G::LocalPlayer && player->GetTeam() != G::LocalPlayer->GetTeam() && (player->GetFlags() & FL_ONGROUND) && c_config::get()->b["rage_resolver"])
{
if (jittering[player->GetIndex()])
AnimState->m_flGoalFeetYaw = normalize_yaw(player->GetEyeAngles().y + DesyncFix);
else
AnimState->m_flGoalFeetYaw = Equalized;
player->SetLowerBodyYaw(AnimState->m_flGoalFeetYaw);
}
StoredAnimState[player->GetIndex()] = AnimState;
oldEyeAngles[player->GetIndex()] = player->GetEyeAngles();
oldSimtime[player->GetIndex()] = storedSimtime[player->GetIndex()];
storedSimtime[player->GetIndex()] = player->GetSimTime();
update = true;
}
player->clientsideanim();
/*if (player != G::LocalPlayer && player->GetTeam() != G::LocalPlayer->GetTeam() && (player->GetFlags() & FL_ONGROUND) && g_Menu.Config.Resolver)
player->SetLowerBodyYaw(AnimState->m_flGoalFeetYaw);*/
AnimState = StoredAnimState[player->GetIndex()];
memcpy((void*)PosParams, &StoredPosParams[player->GetIndex()], (sizeof(float) * 24));
memcpy(player->GetAnimOverlays(), StoredLayers[player->GetIndex()], (sizeof(CAnimationLayer) * player->GetNumAnimOverlays()));
if (player != G::LocalPlayer && player->GetTeam() != G::LocalPlayer->GetTeam() && (player->GetFlags() & FL_ONGROUND) && c_config::get()->b["rage_resolver"] && jittering[player->GetIndex()])
player->SetAbsAngles(Vector(0, player->GetEyeAngles().y, 0));
else
player->SetAbsAngles(Vector(0, oldGoalfeetYaw[player->GetIndex()], 0));
/*if (player == G::LocalPlayer && player->GetVelocity().Length2D() < 45.f && !(g::IsSlowwalking || g::IsFakewalking))
{
AnimState->m_flUnknownFraction = 0.f;
AnimState->m_flLeanAmount = 0.f;
G::LocalPlayer->SetSequence(0);
if (g_Menu.Config.ShowAccurateLby)
player->SetLowerBodyYaw(player->GetEyeAngles().y);
player->ClientAnimations(false);
}*/
* reinterpret_cast<int*>(uintptr_t(player) + 0xA30) = Interfaces::Globals->framecount;
*reinterpret_cast<int*>(uintptr_t(player) + 0xA28) = 0;
}
void c_resolver::OnCreateMove() // cancer v2
{
if (!c_config::get()->b["rage_resolver"])
return;
if (!G::LocalPlayer->IsAlive())
return;
auto pWeapon = G::LocalPlayer->GetActiveWeapon();
if (!pWeapon)
return;
if (!G::LocalPlayer->GetActiveWeapon() || IsKnife31 || IsWeaponGrenade2)
return;
for (int i = 1; i < Interfaces::Engine->GetMaxClients(); ++i)
{
CBaseEntity* pPlayerEntity = Interfaces::EntityList->GetClientEntity(i);
if (!pPlayerEntity
|| !pPlayerEntity->IsAlive()
|| pPlayerEntity->IsDormant()
|| pPlayerEntity == G::LocalPlayer
|| pPlayerEntity->GetTeam() == G::LocalPlayer->GetTeam())
{
UseFreestandAngle[i] = false;
continue;
}
if (abs(pPlayerEntity->GetVelocity().Length2D()) > 29.f)
UseFreestandAngle[pPlayerEntity->GetIndex()] = false;
if (abs(pPlayerEntity->GetVelocity().Length2D()) <= 29.f && !UseFreestandAngle[pPlayerEntity->GetIndex()])
{
bool Autowalled = false, HitSide1 = false, HitSide2 = false;
float angToLocal = calculate_angle(G::LocalPlayer->GetOrigin(), pPlayerEntity->GetOrigin()).y;
Vector ViewPoint = G::LocalPlayer->GetOrigin() + Vector(0, 0, 90);
Vector2D Side1 = { (45 * sin(GRD_TO_BOG(angToLocal))),(45 * cos(GRD_TO_BOG(angToLocal))) };
Vector2D Side2 = { (45 * sin(GRD_TO_BOG(angToLocal + 180))) ,(45 * cos(GRD_TO_BOG(angToLocal + 180))) };
Vector2D Side3 = { (50 * sin(GRD_TO_BOG(angToLocal))),(50 * cos(GRD_TO_BOG(angToLocal))) };
Vector2D Side4 = { (50 * sin(GRD_TO_BOG(angToLocal + 180))) ,(50 * cos(GRD_TO_BOG(angToLocal + 180))) };
Vector Origin = pPlayerEntity->GetOrigin();
Vector2D OriginLeftRight[] = { Vector2D(Side1.x, Side1.y), Vector2D(Side2.x, Side2.y) };
Vector2D OriginLeftRightLocal[] = { Vector2D(Side3.x, Side3.y), Vector2D(Side4.x, Side4.y) };
for (int side = 0; side < 2; side++)
{
Vector OriginAutowall = { Origin.x + OriginLeftRight[side].x, Origin.y - OriginLeftRight[side].y , Origin.z + 90 };
Vector OriginAutowall2 = { ViewPoint.x + OriginLeftRightLocal[side].x, ViewPoint.y - OriginLeftRightLocal[side].y , ViewPoint.z };
if (autow->CanHitFloatingPoint(OriginAutowall, ViewPoint, pPlayerEntity))
{
if (side == 0)
{
HitSide1 = true;
FreestandAngle[pPlayerEntity->GetIndex()] = 90;
}
else if (side == 1)
{
HitSide2 = true;
FreestandAngle[pPlayerEntity->GetIndex()] = -90;
}
Autowalled = true;
}
else
{
for (int side222 = 0; side222 < 2; side222++)
{
Vector OriginAutowall222 = { Origin.x + OriginLeftRight[side222].x, Origin.y - OriginLeftRight[side222].y , Origin.z + 90 };
if (autow->CanHitFloatingPoint(OriginAutowall222, OriginAutowall2, pPlayerEntity))
{
if (side222 == 0)
{
HitSide1 = true;
FreestandAngle[pPlayerEntity->GetIndex()] = 90;
}
else if (side222 == 1)
{
HitSide2 = true;
FreestandAngle[pPlayerEntity->GetIndex()] = -90;
}
Autowalled = true;
}
}
}
}
if (Autowalled)
{
if (HitSide1 && HitSide2)
UseFreestandAngle[pPlayerEntity->GetIndex()] = false;
else
UseFreestandAngle[pPlayerEntity->GetIndex()] = true;
}
}
}
}
C++:
#pragma once
#include "../../singleton.h"
#include "../../Configuration/Config.h"
#include "../../SDK/CBaseEntity.h"
class c_resolver : public singleton<c_resolver>
{
public:
void run();
int32_t m_iLayerCount = 0;
void Resolver(CBaseEntity* player);
void AnimationFix(CBaseEntity* pEnt);
void OnCreateMove();
CAnimationLayer animationLayer[15];
private:
float anti_freestand(CBaseEntity* e);
bool ajusting_balance(CBaseEntity* e);
bool did_store_yaw[65];
float stored_yaws[65];
bool UseFreestandAngle[65];
float FreestandAngle[65];
};