Пользователь
-
Автор темы
- #1
Onetap v2 animation system.
Возможно вронг.
Возможно вронг.
C++:
void OneTap::Features::AnimationSystem::Instance()
{
if (!g_pLocalPlayer)
return;
if (g_pGlobals.Data.PlayersVectorStart == g_pGlobals.Data.PlayersVectorEnd)
return;
if (g_pGlobals.Server.AnimstateMode > ANIMSTATE_DEFAULT)
{
OneTap::Features::AnimationSystem::Legacy::Instance();
return;
}
int m_iIterationPlayer = 0;
do
{
if (m_iIterationPlayer == g_pEngine->GetLocalPlayer())
{
++m_iIterationPlayer;
continue;
}
if (m_iIterationPlayer > 64)
{
++m_iIterationPlayer;
continue;
}
std::vector<CLagRecord> m_pLagRecords = g_pGlobals.AnimationSystem.Records[m_iIterationPlayer];
CLagRecord* m_pLagRecord = m_pLagRecords.front();
if (!m_pLagRecord)
{
++m_iIterationPlayer;
continue;
}
CLagData* m_pLagData = OneTap::Features::AnimationSystem::Storage::GetLagData(m_pLagRecords);
CLagData* m_pPreviousLagData = nullptr;
OneTap::Features::AnimationSystem::Storage::GetRotationData(m_pLagRecord->m_pRotationData, 0);
OneTap::Features::AnimationSystem::Storage::GetRotationData(m_pLagRecord->m_pRotationData, 1);
if (m_pLagRecords.size() > 1)
m_pPreviousLagData = OneTap::Features::AnimationSystem::Storage::GetPreviousLagData(m_pLagRecords);
CCSPlayer* m_pPlayer = g_pEntityList->GetClientEntity(m_iIterationPlayer);
m_pLagRecord->m_bIsEnemy = g_pConfigs.RageBot.Enabled && m_pPlayer->IsEnemy();
m_pLagRecord->m_bIsScoped = false;
OneTap::Features::AnimationSystem::ResetNetworkLayers(m_pLagData->m_aServerLayers);
std::memcpy(m_pLagData->m_aServerLayers, m_pPlayer->GetAnimationLayers(), sizeof(C_AnimationLayer) * 13);
std::memcpy(m_pLagData->m_aServerPoses, m_pPlayer->m_flPoseParameter(), sizeof(float) * 24);
if (m_pLagRecord->m_bIsEnemy)
{
if (m_pLagData->m_iLag == 1)
{
OneTap::Features::AnimationSystem::SetAngles(m_pPlayer, m_pLagRecord, m_pLagData, m_pPreviousLagData, -1);
m_pLagRecord->m_flNegativeAbsYaw = m_pPlayer->GetAnimationState()->m_flGoalFeetYaw;
std::memcpy(m_pLagData->m_aResolverLayers[2], m_pPlayer->GetAnimationLayers(), sizeof(C_AnimationLayer) * 13);
OneTap::Features::AnimationSystem::UpdateNetworkLayers(m_pLagData->m_aServerLayers, m_pPlayer);
OneTap::Features::AnimationSystem::SetAngles(m_pPlayer, m_pLagRecord, m_pLagData, m_pPreviousLagData, 1);
m_pLagRecord->m_flPositiveAbsYaw = m_pPlayer->GetAnimationState()->m_flGoalFeetYaw;
std::memcpy(m_pLagData->m_aResolverLayers[1], m_pPlayer->GetAnimationLayers(), sizeof(C_AnimationLayer) * 13);
OneTap::Features::AnimationSystem::UpdateNetworkLayers(m_pLagData->m_aServerLayers, m_pPlayer);
}
OneTap::Features::AnimationSystem::SetAngles(m_pPlayer, m_pLagRecord, m_pLagData, m_pPreviousLagData, 1);
C_SDK::Math::NormalizeAngle(m_pLagData->m_angEyeAngles.yaw);
bool m_bNegativeEyeYaw = (m_pLagData->m_angEyeAngles.yaw < 0.0);
if (m_bNegativeEyeYaw)
{
m_pLagRecord->m_flNegativeAbsYaw = m_pPlayer->GetAnimationState()->m_flGoalFeetYaw;
std::memcpy(m_pLagData->m_aResolverLayers[2], m_pPlayer->GetAnimationLayers(), sizeof(C_AnimationLayer) * 13);
}
else
{
m_pLagRecord->m_flPositiveAbsYaw = m_pPlayer->GetAnimationState()->m_flGoalFeetYaw;
std::memcpy(m_pLagData->m_aResolverLayers[1], m_pPlayer->GetAnimationLayers(), sizeof(C_AnimationLayer) * 13);
}
OneTap::Features::AnimationSystem::UpdateNetworkLayers(m_pLagData->m_aServerLayers, m_pPlayer);
OneTap::Features::AnimationSystem::SetAngles(m_pPlayer, m_pLagRecord, m_pLagData, m_pPreviousLagData, -1);
if (m_bNegativeEyeYaw)
{
m_pLagRecord->m_flPositiveAbsYaw = m_pPlayer->GetAnimationState()->m_flGoalFeetYaw;
std::memcpy(m_pLagData->m_aResolverLayers[1], m_pPlayer->GetAnimationLayers(), sizeof(C_AnimationLayer) * 13);
}
else
{
m_pLagRecord->m_flNegativeAbsYaw = m_pPlayer->GetAnimationState()->m_flGoalFeetYaw;
std::memcpy(m_pLagData->m_aResolverLayers[2], m_pPlayer->GetAnimationLayers(), sizeof(C_AnimationLayer) * 13);
}
}
OneTap::Features::AnimationSystem::SetAngles(m_pPlayer, m_pLagRecord, m_pLagData, m_pPreviousLagData, 0);
m_pLagRecord->m_flZeroAbsYaw = m_pPlayer->GetAnimationState()->m_flGoalFeetYaw;
std::memcpy(m_pLagData->m_aResolverLayers[0], m_pPlayer->GetAnimationLayers(), sizeof(C_AnimationLayer) * 13);
std::memcpy(m_pPlayer->GetAnimationLayers(), m_pLagData->m_aServerLayers, sizeof(C_AnimationLayer) * 13);
std::memcpy(m_pPlayer->m_flPoseParameter(), m_pLagData->m_aServerPoses, sizeof(float) * 24);
m_pLagRecord->m_vecOrigin = m_pPlayer->m_vecOrigin();
OneTap::Features::RageBot::Resolver(m_pLagRecord, m_pLagData, m_pPreviousLagData);
if (m_pLagRecord->m_bIsEnemy)
{
C_SDK::Math::NormalizeAngle(m_pLagRecord->m_flPositiveAbsYaw);
bool m_bPositive = abs(m_pLagRecord->m_flPositiveAbsYaw) > 0.1;
bool m_bZero = abs(m_pLagRecord->m_flPositiveAbsYaw) == 0.1;
C_SDK::Math::NormalizeAngle(m_pLagRecord->m_flZeroAbsYaw);
bool m_bNegative = (!m_bPositive && !m_bZero && abs(m_pLagRecord->m_flZeroAbsYaw)) < 0.1;
m_pLagData->m_iResolveWay = m_bNegative;
}
m_pLagData->m_flNegativeAngle = m_pLagData->m_angEyeAngles.yaw - 90.0;
C_SDK::Math::NormalizeAngle(m_pLagData->m_flNegativeAngle);
m_pLagData->m_flPositiveAngle = m_pLagData->m_angEyeAngles.yaw + 90.0;
C_SDK::Math::NormalizeAngle(m_pLagData->m_flPositiveAngle);
OneTap::Features::AnimationSystem::Update(m_pPlayer);
}
while (m_iIterationPlayer != g_pGlobals.Data.PlayersVectorEnd);
}
void OneTap::Features::AnimationSystem::Update(CCSPlayer* m_pPlayer)
{
float m_iFrameCount = g_pGlobalVars->m_frameCount;
float m_flCurrentTime = g_pGlobalVars->m_currentTime;
float m_flFrameTime = g_pGlobalVars->m_frameTime;
float m_flAbsFrameTime = g_pGlobalVars->m_absoluteFrameTime;
float m_iTickCount = g_pGlobalVars->m_tickCount;
g_pGlobalVars->m_currentTime = g_pGlobals.Data.Tickcount * g_pGlobalVars->m_intervalPerTick;
g_pGlobalVars->m_frameTime = g_pGlobalVars->m_intervalPerTick;
g_pGlobalVars->m_absoluteFrameTime = g_pGlobalVars->m_intervalPerTick;
g_pGlobalVars->m_frameCount = g_pGlobals.Data.Tickcount;
g_pGlobalVars->m_tickCount = g_pGlobals.Data.Tickcount;
m_pPlayer->m_bClientSideAnimation() = true;
m_pPlayer->UpdateClientSideAnimation();
m_pPlayer->m_bClientSideAnimation() = false;
g_pGlobalVars->m_currentTime = m_flCurrentTime;
g_pGlobalVars->m_frameTime = m_flFrameTime;
g_pGlobalVars->m_absoluteFrameTime = m_flAbsFrameTime;
g_pGlobalVars->m_frameCount = m_iFrameCount;
g_pGlobalVars->m_tickCount = m_iTickCount;
}
void OneTap::Features::AnimationSystem::ResetNetworkLayers(C_AnimationLayer* m_aAnimationLayers)
{
std::memset(m_aAnimationLayers, 0, sizeof(C_AnimationLayer) * 13);
}
void OneTap::Features::AnimationSystem::UpdateNetworkLayers(C_AnimationLayer* m_aAnimationLayers, CCSPlayer* m_pPlayer)
{
std::memcpy(m_pPlayer->GetAnimationLayers(), m_aAnimationLayers, sizeof(C_AnimationLayer) * 13);
}
void OneTap::Features::AnimationSystem::Storage::Save(CAnimationData* m_pData, CCSPlayer* m_pPlayer)
{
m_pData->m_fFlags = m_pPlayer->m_fFlags();
m_pData->m_angEyeAngles = m_pPlayer->m_angEyeAngles();
m_pData->m_flDuckAmount = m_pPlayer->m_flDuckAmount();
m_pData->m_flLowerBodyYawTarget = m_pPlayer->m_flLowerBodyYawTarget();
m_pData->m_flFeetCycle = m_pPlayer->GetAnimationState()->m_flFeetCycle;
m_pData->m_flFeetYawRate = m_pPlayer->GetAnimationState()->m_flFeetYawRate;
}
void OneTap::Features::AnimationSystem::Storage::Apply(CAnimationData* m_pData, CCSPlayer* m_pPlayer)
{
m_pPlayer->m_fFlags() = m_pData->m_fFlags);
m_pPlayer->m_angEyeAngles() = m_pData->m_angEyeAngles;
m_pPlayer->m_flDuckAmount() = m_pData->m_flDuckAmount;
m_pPlayer->m_flLowerBodyYawTarget() = m_pData->m_flLowerBodyYawTarget;
m_pPlayer->GetAnimationState()->m_flFeetCycle = m_pData->m_flFeetCycle;
m_pPlayer->GetAnimationState()->m_flFeetYawRate = m_pData->m_flFeetYawRate;
}
bool OneTap::Features::AnimationSystem::SetupBones(CCSPlayer* m_pPlayer, matrix3x4_t* m_pMatrix, float m_flCurrentTime)
{
auto m_fBackupEffects = m_pPlayer->m_fEffects();
m_pPlayer->m_fEffects() |= -EF_NOINTERP;
bool m_bIsSetup = m_pPlayer->SetupBones(m_pMatrix, 128, BONE_USED_BY_HITBOX, m_flCurrentTime);
m_pPlayer->m_fEffects() = m_fBackupEffects;
return m_bIsSetup;
}
void OneTap::Features::AnimationSystem::TriggerBalanceAdjust(CCSPlayer* m_pPlayer)
{
if (m_pPlayer->GetAnimationLayers())
{
if (m_pPlayer->GetAnimationState())
{
if (m_pPlayer->GetAnimationState()->m_flVelocity <= 1.0)
{
if (m_pPlayer->GetAnimationState()->m_bOnGround)
{
if (!m_pPlayer->GetAnimationState()->m_bOnLadder && !m_pPlayer->GetAnimationState()->m_bInHitGroundAnimation)
{
float m_flUpdateTimeDelta = m_pPlayer->GetAnimationState()->m_flUpdateTimeDelta;
if (m_flUpdateTimeDelta > 0.0)
{
float m_flCurrentFeetYaw = m_pPlayer->GetAnimationState()->m_flCurrentFeetYaw;
float m_flGoalFeetYaw = m_pPlayer->GetAnimationState()->m_flGoalFeetYaw;
float m_flFeetYawDelta = m_flCurrentFeetYaw - m_flGoalFeetYaw;
if (m_flGoalFeetYaw < m_flCurrentFeetYaw)
{
if (m_flFeetYawDelta >= 180.0)
m_flFeetYawDelta = m_flFeetYawDelta - 360.0;
}
else if (m_flFeetYawDelta <= -180.0)
{
m_flFeetYawDelta = m_flFeetYawDelta + 360.0;
}
if ((m_flFeetYawDelta / m_flUpdateTimeDelta) > 120.0)
{
m_pPlayer->GetAnimationLayers()[3].m_flWeight = 0.0;
m_pPlayer->GetAnimationLayers()[3].m_flCycle = 0.0;
m_pPlayer->GetAnimationLayers()[3].m_nSequence = m_pPlayer->GetSequenceActivity(ACT_CSGO_IDLE_TURN_BALANCEADJUST);
}
}
}
}
}
}
}
}
void OneTap::Features::AnimationSystem::SetAngles(CCSPlayer* m_pPlayer, CLagRecord* m_pLagRecord, CLagData* m_pLagData, CLagData* m_pPreviousLagData, int m_iSide)
{
CAnimationData m_pData;
OneTap::Features::AnimationSystem::Storage::Save(&m_pData, m_pPlayer);
m_pPlayer->SetAbsOrigin(m_pPlayer->m_vecOrigin());
if (!m_pPreviousLagData || m_pPreviousLagData->m_bIsDormant)
{
std::memcpy(m_pPlayer->GetAnimationLayers(), m_pLagData->m_aServerLayers, sizeof(C_AnimationLayer) * 13);
}
else if (!prevLagData->m_dormant)
{
std::memcpy(m_pPlayer->GetAnimationLayers(), m_pPreviousLagData->m_aServerLayers, sizeof(C_AnimationLayer) * 13);
m_pPlayer->GetAnimationState()->m_flFeetCycle = m_pPreviousLagData->m_flFeetCycle;
m_pPlayer->GetAnimationState()->m_flFeetYawRate = m_pPreviousLagData->m_flFeetYawRate;
}
if (m_pLagData->m_fFlags & FL_ONGROUND)
{
m_pPlayer->GetAnimationState()->m_bOnGround = true;
m_pPlayer->GetAnimationState()->m_bInHitGroundAnimation = false;
}
float m_flAngle = 0.0;
if (m_pLagData->m_iLag == 1)
{
if (m_iSide)
{
if (!m_pPreviousLagData || m_pPreviousLagData->m_bIsDormant)
{
if (m_iSide <= 0)
m_flAngle = m_pLagData->m_angEyeAngles.yaw - 60.0;
else
m_flAngle = m_pLagData->m_angEyeAngles.yaw + 60.0;
}
else
{
if (m_iSide <= 0)
m_flAngle = m_pLagRecord->m_flZeroAbsYaw
else
m_flAngle = m_pLagRecord->m_flPositiveAbsYaw;
}
C_SDK::Math::NormalizeAngle(m_flAngle);
m_pPlayer->GetAnimationState()->m_flGoalFeetYaw = m_flAngle;
}
m_pPlayer->m_flDuckAmount() = m_pLagData->m_flDuckAmount;
m_pLagRecord->m_bIsUpdatingAnimation = true;
m_pPlayer->m_angEyeAngles() = m_pLagData->m_angEyeAngles;
OneTap::Features::AnimationSystem::Update(m_pPlayer);
m_pLagRecord->m_bIsUpdatingAnimation = false;
}
else
{
int m_iLagIterator = 0;
if (m_pLagData->m_iLag > 0)
{
while (1)
{
if ((++m_iLagIterator < m_pLagData->m_iLag) && m_iSide)
{
if (m_iSide <= 0)
m_flAngle = m_pLagData->m_angEyeAngles.yaw - 60.0;
else
m_flAngle = m_pLagData->m_angEyeAngles.yaw + 60.0;
C_SDK::Math::NormalizeAngle(m_flAngle);
m_pPlayer->GetAnimationState()->m_flGoalFeetYaw = m_flAngle;
}
m_pPlayer->m_flDuckAmount() = m_pLagData->m_flDuckAmount;
m_pLagRecord->m_bIsUpdatingAnimation = true;
m_pLagRecord->m_vecEyePos = m_pLagRecord->m_pLegacyData->m_vecDesiredEyePos;
m_pPlayer->m_angEyeAngles = m_pLagData->m_angEyeAngles;
OneTap::Features::AnimationSystem::Update(m_pPlayer);
m_pLagRecord->m_bIsUpdatingAnimation = false;
if (m_iLagIterator >= m_pLagData->m_iLag)
break;
}
}
}
OneTap::Features::AnimationSystem::Storage::Apply(&data, m_pPlayer);
m_pPlayer->InvalidatePhysicsRecursive(ANIMATION_CHANGED);
}