-
Автор темы
- #1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Код:
if (previous_record)
{
auto velocity = e->m_vecVelocity();
auto was_in_air = e->m_fFlags() & FL_ONGROUND && previous_record->flags & FL_ONGROUND;
auto time_difference = max(m_globals()->m_intervalpertick, e->m_flSimulationTime() - previous_record->simulation_time);
auto origin_delta = e->m_vecOrigin() - previous_record->origin;
auto animation_speed = 0.0f;
if (!origin_delta.IsZero() && TIME_TO_TICKS(time_difference) > 0)
{
e->m_vecVelocity() = origin_delta * (1.0f / time_difference);
if (e->m_fFlags() & FL_ONGROUND && animlayers[11].m_flWeight > 0.0f && animlayers[11].m_flWeight < 1.0f && animlayers[11].m_flCycle > previous_record->layers[11].m_flCycle)
{
auto weapon = e->m_hActiveWeapon().Get();
if (weapon)
{
auto max_speed = 260.0f;
auto weapon_info = e->m_hActiveWeapon().Get()->get_csweapon_info();
if (weapon_info)
max_speed = e->m_bIsScoped() ? weapon_info->flMaxPlayerSpeedAlt : weapon_info->flMaxPlayerSpeed;
auto modifier = 0.35f * (1.0f - animlayers[11].m_flWeight);
if (modifier > 0.0f && modifier < 1.0f)
animation_speed = max_speed * (modifier + 0.55f);
}
}
if (animation_speed > 0.0f)
{
animation_speed /= e->m_vecVelocity().Length2D();
e->m_vecVelocity().x *= animation_speed;
e->m_vecVelocity().y *= animation_speed;
}
if (records->size() >= 3 && time_difference > m_globals()->m_intervalpertick)
{
auto previous_velocity = (previous_record->origin - records->at(2).origin) * (1.0f / time_difference);
if (!previous_velocity.IsZero() && !was_in_air)
{
auto current_direction = math::normalize_yaw(RAD2DEG(atan2(e->m_vecVelocity().y, e->m_vecVelocity().x)));
auto previous_direction = math::normalize_yaw(RAD2DEG(atan2(previous_velocity.y, previous_velocity.x)));
auto average_direction = current_direction - previous_direction;
average_direction = DEG2RAD(math::normalize_yaw(current_direction + average_direction * 0.5f));
auto direction_cos = cos(average_direction);
auto dirrection_sin = sin(average_direction);
auto velocity_speed = e->m_vecVelocity().Length2D();
e->m_vecVelocity().x = direction_cos * velocity_speed;
e->m_vecVelocity().y = dirrection_sin * velocity_speed;
}
}
if (!(record->flags & FL_ONGROUND))
{
velocity = (record->origin - previous_record->origin) / record->simulation_time;
float_t flWeight = 1.0f - record->layers[ANIMATION_LAYER_ALIVELOOP] .m_flWeight;
if (flWeight > 0.0f)
{
float_t flPreviousRate = previous_record->layers[ANIMATION_LAYER_ALIVELOOP].m_flPlaybackRate;
float_t flCurrentRate = record->layers[ANIMATION_LAYER_ALIVELOOP].m_flPlaybackRate;
if (flPreviousRate == flCurrentRate)
{
int32_t iPreviousSequence = previous_record->layers[ANIMATION_LAYER_ALIVELOOP].m_nSequence;
int32_t iCurrentSequence = record->layers[ANIMATION_LAYER_ALIVELOOP].m_nSequence;
if (iPreviousSequence == iCurrentSequence)
{
float_t flSpeedNormalized = (flWeight / 2.8571432f) + 0.55f;
if (flSpeedNormalized > 0.0f)
{
float_t flSpeed = flSpeedNormalized * e->GetMaxPlayerSpeed();
if (flSpeed > 0.0f)
{
if (velocity.Length2D() > 0.0f)
{
velocity.x /= velocity.Length2D() / flSpeed;
velocity.y /= velocity.Length2D() / flSpeed;
}
}
}
}
}
}
static auto sv_gravity = m_cvar()->FindVar(crypt_str("sv_gravity"));
velocity.z -= sv_gravity->GetFloat() * 0.5f * TICKS_TO_TIME(record->simulation_time);
}
else
velocity.z = 0.0f;
}
}
Код:
float player_t::GetMaxPlayerSpeed()
{
weapon_t* pWeapon = this->m_hActiveWeapon().Get();
if (pWeapon)
{
weapon_info_t* pWeaponData = pWeapon->GetWeaponData();
if (pWeaponData)
return this->m_bIsScoped() ? pWeaponData->flMaxPlayerSpeedAlt : pWeaponData->flMaxPlayerSpeed;
}
return 260.0f;
}