-
Автор темы
- #1
Код:
float features::ragebot::skeet_accelerate_rebuilt ( ucmd_t* cmd, player_t* player, const vec3_t& wish_dir, const vec3_t& wish_speed, bool& ducking ) {
VMP_BEGINMUTATION ( );
auto wanted_vel = wish_dir * wish_speed;
auto wanted_speed = wanted_vel.length_2d ( );
auto weapon = player->weapon ( );
auto duck_amount = player->crouch_amount ( );
auto flags_check = player->flags ( );
ducking = false;
if ( !( cmd->m_buttons & buttons_t::duck ) ) {
auto is_ducking = *reinterpret_cast< bool* >( reinterpret_cast< uintptr_t >( &player->fall_vel ( ) ) + 0x31 );
if ( duck_amount > 0.0 )
is_ducking = true;
if ( is_ducking || duck_amount >= 1.0f ) {
auto duck_speed = 2.0f;
if ( player->crouch_speed ( ) >= 1.5f )
duck_speed = player->crouch_speed ( );
auto next_duck = std::max ( 0.0f, duck_amount - ( duck_speed * cs::ticks2time ( 1 ) ) );
auto backup_next_duck = next_duck;
if ( next_duck <= 0.0f )
next_duck = 0.0f;
auto new_flags = flags_check & ~flags_t::ducking;
if ( backup_next_duck > 0.0f )
new_flags = player->flags ( );
flags_check = new_flags & ~flags_t::ducking;
if ( next_duck > 0.75f )
flags_check = new_flags;
auto new_is_ducking = false;
if ( backup_next_duck > 0.0f )
new_is_ducking = is_ducking;
if ( new_is_ducking )
ducking = true;
}
if ( !!( flags_check & flags_t::ducking ) )
ducking = true;
}
auto is_walking = !!( cmd->m_buttons & buttons_t::speed ) && !ducking;
auto max_speed = 250.0f;
auto acceleration_scale = std::max ( max_speed, wanted_speed );
auto goal_speed = acceleration_scale;
static auto sv_accelerate_use_weapon_speed = cs::i::cvar->find ( _ ( "sv_accelerate_use_weapon_speed" ) );
auto slowed_by_scope = false;
if ( sv_accelerate_use_weapon_speed->get_bool ( ) && weapon ) {
auto max_speed = 260.0f;
auto zoom_levels = 0;
const auto weapon = g::local->weapon ( );
if ( weapon ) {
if ( auto data = weapon->data ( ) )
max_speed = g::local->scoped ( ) ? data->m_max_speed_alt : data->m_max_speed;
zoom_levels = *reinterpret_cast< int* >( reinterpret_cast< uintptr_t >( weapon ) + 0x3340 );
}
slowed_by_scope = ( zoom_levels > 0 && zoom_levels > 1 && ( max_speed * 0.52f ) < 110.0f );
goal_speed *= std::min ( 1.0f, ( max_speed / max_speed ) );
if ( ( !ducking && !is_walking ) || ( ( is_walking || ducking ) && slowed_by_scope ) )
acceleration_scale *= std::min ( 1.0f, ( max_speed / max_speed ) );
}
if ( ducking ) {
if ( !slowed_by_scope )
acceleration_scale *= 0.34f;
goal_speed *= 0.34f;
}
if ( is_walking ) {
if ( !player->has_heavy_armor ( ) && !slowed_by_scope )
acceleration_scale *= 0.52f;
goal_speed *= 0.52f;
}
auto accel = g::cvars::sv_accelerate->get_float ( );
if ( is_walking && wanted_speed > ( goal_speed - 5.0f ) )
accel *= std::clamp ( 1.0f - ( std::max ( 0.0f, wanted_speed - ( goal_speed - 5.0f ) ) / std::max ( 0.0f, goal_speed - ( goal_speed - 5.0f ) ) ), 0.0f, 1.0f );
return cs::ticks2time ( 1 ) * accel * acceleration_scale;
VMP_END ( );
};
void features::ragebot::skeet_slow ( ucmd_t* cmd, float wanted_speed, vec3_t& old_angs ) {
VMP_BEGINMUTATION ( );
if ( !g::local || !g::local->alive ( ) )
return;
const auto weapon = g::local->weapon ( );
const auto vel = g::local->vel ( );
const auto speed2d = vel.length_2d ( );
const auto move_vec = vec3_t ( cmd->m_fmove, cmd->m_smove, cmd->m_umove );
if ( !( cmd->m_buttons & buttons_t::jump ) && move_vec.length ( ) >= 38.0f ) {
if ( speed2d >= 28.0f ) {
const auto stop_speed = std::max ( g::cvars::sv_stopspeed->get_float ( ), speed2d );
const auto friction = g::cvars::sv_friction->get_float ( );
const auto max_stop_speed = std::max ( speed2d - ( ( stop_speed * friction ) * cs::ticks2time ( 1 ) ), 0.0f );
auto max_stop_speed_vec = vel * ( max_stop_speed / speed2d );
max_stop_speed_vec.z = 0.0f;
auto delta_target_speed = wanted_speed - max_stop_speed;
if ( abs( delta_target_speed ) >= 0.5f ) {
vec3_t move_dir;
vec3_t angles;
cs::i::engine->get_viewangles ( angles );
vec3_t fwd, right, up;
cs::angle_vec ( angles, &fwd, &right, nullptr );
fwd.normalize ( );
right.normalize ( );
if ( delta_target_speed >= 0.0f ) {
cmd->m_buttons &= ~buttons_t::speed;
move_dir.x = ( cmd->m_fmove * fwd.x ) + ( cmd->m_smove * right.x );
move_dir.y = ( cmd->m_smove * right.y ) + ( cmd->m_fmove * fwd.y );
move_dir.z = 0.0f;
move_dir.normalize();
}
else {
move_dir = vel.normalized ( );
move_dir.z = 0.0f;
cmd->m_fmove = 450.0f;
cmd->m_smove = 0.0f;
old_angs.y = cs::normalize( cs::vec_angle ( move_dir ).y + 180.0f );
old_angs.x = old_angs.z = 0.0f;
delta_target_speed *= -1.0f;
}
auto ducking = false;
const auto accel = skeet_accelerate_rebuilt ( cmd, g::local, move_dir, max_stop_speed_vec, ducking );
const auto currentspeed = max_stop_speed_vec.dot_product ( move_dir );
const auto addspeed = std::clamp ( std::min( g::local->max_speed() , 260.0f ) - currentspeed, 0.0f, accel );
if ( addspeed > delta_target_speed + 0.5f ) {
auto move_length = currentspeed + delta_target_speed;
if (ducking) {
if ( g::local->crouch_amount ( ) == 1.0f )
move_length /= 0.34f;
}
const auto move_scale = move_length / move_vec.length ( );
cmd->m_fmove = cmd->m_fmove * move_scale;
cmd->m_smove = cmd->m_smove * move_scale;
cmd->m_umove = cmd->m_umove * move_scale;
}
}
else {
cmd->m_smove = 0.0f;
cmd->m_fmove = 0.0f;
}
}
}
VMP_END ( );
}