Пользователь
-
Автор темы
- #1
Onetap v4 set player angles.
Возможно вронг.
Возможно вронг.
C++:
void C_AnimationSystem::StoreInformation(C_BasePlayer* m_pEntity, C_AnimationData* m_pData)
{
m_pData->m_fFlags = m_pEntity->m_fFlags();
m_pData->m_angEyeAngles = m_pEntity->m_angEyeAngles();
m_pData->m_flDuckAmount = m_pEntity->m_flDuckAmount();
m_pData->m_flLowerBodyYaw = m_pEntity->m_flLowerBodyYawTarget();
m_pData->m_flFeetCycle = m_pEntity->GetAnimationState()->m_flFeetCycle;
m_pData->m_flFeetYawRate = m_pEntity->GetAnimationState()->m_flFeetYawRate;
}
void C_AnimationSystem::RestoreInformation(C_BasePlayer* m_pEntity, C_AnimationData* m_pData)
{
m_pEntity->m_fFlags() = m_pData->m_fFlags;
m_pEntity->m_angEyeAngles() = m_pData->m_angEyeAngles;
m_pEntity->m_flDuckAmount() = m_pData->m_flDuckAmount;
m_pEntity->m_flLowerBodyYawTarget() = m_pData->m_flLowerBodyYaw;
m_pEntity->GetAnimationState()->m_flFeetCycle = m_pData->m_flFeetCycle;
m_pEntity->GetAnimationState()->m_flFeetYawRate = m_pData->m_flFeetYawRate;
}
void C_AnimationSystem::StoreGlobalVars(int m_iEntityIndex)
{
m_flRealtime[m_iEntityIndex] = g_pGlobalVars->m_flRealtime;
m_flCurtime[m_iEntityIndex] = g_pGlobalVars->m_flCurtime;
m_flFrametime[m_iEntityIndex] = g_pGlobalVars->m_flFrametime;
m_flAbsFrametime[m_iEntityIndex] = g_pGlobalVars->m_flAbsFrametime;
m_iFramecount[m_iEntityIndex] = g_pGlobalVars->m_iFramecount;
m_iTickcount[m_iEntityIndex] = g_pGlobalVars->m_iTickcount;
m_flInterpolation[m_iEntityIndex] = g_pGlobalVars->m_flInterpolation;
}
void C_AnimationSystem::RestoreGlobalVars(int m_iEntityIndex)
{
g_pGlobalVars->m_flRealtime = m_flRealtime[m_iEntityIndex];
g_pGlobalVars->m_flCurtime = m_flCurtime[m_iEntityIndex];
g_pGlobalVars->m_flFrametime = m_flFrametime[m_iEntityIndex];
g_pGlobalVars->m_flAbsFrametime = m_flAbsFrametime[m_iEntityIndex];
g_pGlobalVars->m_iFramecount = m_iFramecount[m_iEntityIndex];
g_pGlobalVars->m_iTickcount = m_iTickcount[m_iEntityIndex];
g_pGlobalVars->m_flInterpolation = m_flInterpolation[m_iEntityIndex];
}
bool C_AnimationSystem::GenerateMatrix(C_BasePlayer* m_pEntity, matrix3x4_t* m_pMatrix, float m_flTime)
{
float m_flRealtime = g_pGlobalVars->m_flRealtime;
float m_flCurtime = g_pGlobalVars->m_flCurtime;
float m_flFrametime = g_pGlobalVars->m_flFrametime;
float m_flAbsFrametime = g_pGlobalVars->m_flAbsFrametime;
int m_iFramecount = g_pGlobalVars->m_iFramecount;
int m_iTickcount = g_pGlobalVars->m_iTickcount;
g_pGlobalVars->m_flRealtime = m_flTime;
g_pGlobalVars->m_flCurtime = m_flTime;
g_pGlobalVars->m_flFrametime = g_pGlobalVars->m_flIntervalPerTick;
g_pGlobalVars->m_flAbsFrametime = g_pGlobalVars->m_flIntervalPerTick;
g_pGlobalVars->m_iFramecount = TIME_TO_TICKS(m_flTime);
g_pGlobalVars->m_iTickcount = TIME_TO_TICKS(m_flTime);
int m_iBackupEffects = m_pEntity->m_iEffects();
m_pEntity->m_iEffects() |= EF_NOINTERP;
bool m_bSetup = m_pEntity->SetupBones(m_pMatrix, MAXSTUDIOBONES, 0x7FF00, m_flTime);
m_pEntity->m_iEffects() = m_iBackupEffects;
g_pGlobalVars->m_flRealtime = m_flRealtime;
g_pGlobalVars->m_flCurtime = m_flCurtime;
g_pGlobalVars->m_flFrametime = m_flFrametime;
g_pGlobalVars->m_flAbsFrametime = m_flAbsFrametime;
g_pGlobalVars->m_iFramecount = m_iFramecount;
g_pGlobalVars->m_iTickcount = m_iTickcount;
return m_bSetup;
}
void C_AnimationSystem::UpdateAnimations(C_BasePlayer* m_pEntity, float m_flSimulationTime)
{
if (!m_pEntity || m_flSimulationTime == 0.0)
return;
StoreGlobalVars(m_pEntity->m_iEntityIndex());
g_pGlobalVars->m_flRealtime = m_flSimulationTime;
g_pGlobalVars->m_flCurtime = m_flSimulationTime;
g_pGlobalVars->m_flFrametime = g_pGlobalVars->m_flIntervalPerTick;
g_pGlobalVars->m_flAbsFrametime = g_pGlobalVars->m_flIntervalPerTick;
g_pGlobalVars->m_iFramecount = TIME_TO_TICKS(m_flSimulationTime);
g_pGlobalVars->m_iTickcount = TIME_TO_TICKS(m_flSimulationTime);
g_pGlobalVars->m_flInterpolation = 0.0;
m_pEntity->m_bClientSideAnimation() = true;
m_pEntity->UpdateClientSideAnimation();
m_pEntity->m_bClientSideAnimation() = false;
RestoreGlobalVars(m_pEntity->m_iEntityIndex());
}
void C_AnimationSystem::SetAngles(C_BasePlayer* m_pEntity, C_LagRecord* pRecord, C_LagRecord* pPreviousRecord, int iRotationSide, float flAngle)
{
C_AnimationData data;
StoreInformation(m_pEntity, &data);
m_pEntity->SetAbsOrigin(m_pEntity->m_vecOrigin());
if (!pPreviousRecord || pPreviousRecord->m_bDormant)
std::mempcy(m_pEntity->GetAnimationLayers(), pRecord->m_aServerLayers, sizeof(CAnimationLayer) * 13);
else if (!pRecord)
std::mempcy(m_pEntity->GetAnimationLayers(), pPreviousRecord->m_aServerLayers, sizeof(CAnimationLayer) * 13);
if (pPreviousRecord->m_bDormant && pRecord->m_fFlags & FL_ONGROUND)
{
m_pEntity->GetAnimationState()->m_bOnGround = true;
m_pEntity->GetAnimationState()->m_bInHitGroundAnimation = false;
}
if (pRecord->m_iChokedTicks == 1)
{
float m_flPlayerAngle = 0.0;
if (iRotationSide)
{
if (!pPreviousRecord || pPreviousRecord->m_bDormant)
{
if (iRotationSide <= 0)
m_flPlayerAngle = pRecord->m_angEyeAngles.yaw - 60.0;
else
m_flPlayerAngle = pRecord->m_angEyeAngles.yaw + 60.0;
}
else
{
if (iRotationSide <= 0)
m_flPlayerAngle = pPreviousRecord->m_flRightAngle;
else
m_flPlayerAngle = pPreviousRecord->m_flLeftAngle;
}
}
else
{
if (flAngle)
m_flPlayerAngle = flAngle;
}
Math::NormalizeAngle(m_flPlayerAngle);
m_pEntity->GetAnimationState()->m_flGoalFeetYaw = m_flPlayerAngle;
}
else
{
float m_flLowerBodyYaw = pRecord->m_flLowerBodyYaw;
Math::NormalizeAngle(m_flLowerBodyYaw);
bool m_bDeltaInRange = abs(m_flLowerBodyYaw) < 1.0;
if (pRecord->m_iChokedTicks > 0)
{
int m_nIterator = 1;
int m_nSukaSuka = 1;
while (true)
{
float m_flPreviousLBY = pRecord->m_flLowerBodyYawBackup;
float m_flCurrentLBY = pRecord->m_flLowerBodyYaw;
if (m_flPreviousLBY != m_flCurrentLBY)
{
bool m_bShouldUseOldLBY = false;
int m_nTicksDelta = pRecord->m_iChokedTicks - m_nIterator;
if (m_bDeltaInRange)
m_bShouldUseOldLBY = m_nTicksDelta == 0;
else
m_bShouldUseOldLBY = m_nTicksDelta < 2;
if (!m_bShouldUseOldLBY)
m_flCurrentLBY = m_flPreviousLBY;
m_pEntity->m_flLowerBodyYawTarget() = m_flCurrentLBY;
}
if (pRecord->m_bSimulatedOnGround)
m_pEntity->m_fFlags() |= FL_ONGROUND;
else
m_pEntity->m_fFlags() &= ~FL_ONGROUND;
if (m_nSukaSuka < pRecord->m_iChokedTicks)
{
float m_flPlayerAngle = 0.0;
if (iRotationSide)
{
if (iRotationSide <= 0)
m_flPlayerAngle = pRecord->m_angEyeAngles.yaw - 60.0;
else
m_flPlayerAngle = pRecord->m_angEyeAngles.yaw + 60.0;
Math::NormalizeAngle(m_flPlayerAngle);
}
else
{
if (flAngle)
m_flPlayerAngle = flAngle;
}
m_pEntity->GetAnimationState()->m_flGoalFeetYaw = m_flPlayerAngle;
}
pRecord->m_bForceVelocity = true;
pRecord->m_vecUpdatedVelocity = pRecord->m_vecSimulatedVelocity;
m_pEntity->m_flDuckAmount() = pRecord->m_flDuckAmount;
m_pEntity->m_angEyeAngles() = pRecord->m_angEyeAngles;
UpdateAnimations(m_pEntity, pRecord->m_flSimulationTime);
pRecord->m_bForceVelocity = false;
if (m_nIterator >= pRecord->m_iChokedTicks)
break;
}
}
}
RestoreInformation(m_pEntity, &data);
m_pEntity->InvalidatePhysicsRecursive(ANIMATION_CHANGED);
}