summaryrefslogtreecommitdiff
path: root/internal_rewrite/movement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'internal_rewrite/movement.cpp')
-rw-r--r--internal_rewrite/movement.cpp42
1 files changed, 40 insertions, 2 deletions
diff --git a/internal_rewrite/movement.cpp b/internal_rewrite/movement.cpp
index 8760487..3793e1b 100644
--- a/internal_rewrite/movement.cpp
+++ b/internal_rewrite/movement.cpp
@@ -50,7 +50,10 @@ void c_movement::auto_strafer( ) {
vec3_t velocity = g_ctx.m_local->m_vecVelocity( );
float speed = velocity.length2d( );
- auto cmd = g_ctx.get_last_cmd( );
+
+ bool use_original = !g_settings.rage.enabled && !g_settings.rage.anti_aim;
+
+ auto cmd = use_original ? m_ucmd : g_ctx.get_last_cmd( );
auto on_ground = g_ctx.m_local->m_fFlags( ) & FL_ONGROUND;
if( cmd && ( m_ucmd->m_buttons & IN_JUMP ) && ( speed > 1.0f || g_settings.misc.air_duck( ) ) && !on_ground ) {
@@ -64,12 +67,47 @@ void c_movement::auto_strafer( ) {
cmd->m_sidemove = ( cmd->m_cmd_nr % 2 ) ? 450.f : -450.f;
cmd->m_forwardmove = 0;
- rotate_movement( cmd, std::remainderf( ideal_rotation, 360.f ) );
+ rotate_movement( cmd, ideal_rotation );
}
else {
cmd->m_sidemove = m_ucmd->m_mousedx < 0.f ? -450.f : 450.f;
}
}
+ else if( g_settings.misc.auto_strafe == 2 ) {
+ if( !cmd->m_mousedx ) {
+ float ideal_rotation = std::min( RAD2DEG( std::asinf( 30.f / std::max( speed, FLT_EPSILON ) ) ) * 0.5f, 45.f );
+
+ float move_yaw = math::vector_angles( vec3_t( ), vec3_t( cmd->m_forwardmove, cmd->m_sidemove, 0.f ) ).y;
+ float vel_yaw = math::vector_angles( vec3_t( ), velocity ).y;
+
+ float velocity_delta = std::remainderf( g_csgo.m_engine( )->GetViewAngles( ).y - vel_yaw, 360.f );
+
+ float move_delta = std::remainderf( move_yaw - velocity_delta, 360.f );
+ float ideal_yaw = math::approach_angle( move_yaw, velocity_delta, ideal_rotation );
+
+ float delta_yaw = std::remainderf( move_yaw - ideal_yaw, 360.f );
+
+ if( std::abs( delta_yaw ) > ideal_rotation )
+ ideal_rotation = 0.f;
+ else if( ( cmd->m_cmd_nr % 2 ) )
+ ideal_rotation *= -1;
+
+ cmd->m_sidemove = ( cmd->m_cmd_nr % 2 ) ? 450.f : -450.f;
+ cmd->m_forwardmove = 0;
+
+ rotate_movement( cmd, std::remainderf( ideal_yaw + ideal_rotation, 360.f ) );
+ }
+ else {
+ float move_yaw = math::vector_angles( vec3_t( ), vec3_t( cmd->m_forwardmove, cmd->m_sidemove, 0.f ) ).y;
+
+ float rotation = cmd->m_mousedx < 0.f ? -90.f : 90.f;
+
+ cmd->m_forwardmove = 450.f;
+ cmd->m_sidemove = 0.f;
+
+ rotate_movement( cmd, move_yaw + rotation );
+ }
+ }
}
}