Giter Club home page Giter Club logo

Comments (4)

 avatar commented on August 16, 2024

not good autostrafe

from csgo_modest.

synvy avatar synvy commented on August 16, 2024

not good autostrafe

Yea, but it's simple, quick, and it works. This is supposed to be used as a base, correct? If people want a better strafer, they should add one themselves. Just thought it would be nice to have that in since bhop is already in there.

from csgo_modest.

outlassn avatar outlassn commented on August 16, 2024
void autostrafe()
{
	if ( !config::get<bool>( ctx::cfg.movement_autostrafe ) )
		return;

	/// Is player underwater / onground? Autostrafe won't work in these conditions
	if ( ctx::client.local->get_flags().has_flag( FL_ONGROUND ) )
		return;

	/// Allow movement if movement keys are pressed
	if ( ctx::client.cmd->buttons.has_flag( IN_MOVERIGHT ) || ctx::client.cmd->buttons.has_flag( IN_MOVELEFT ) 
	  || ctx::client.cmd->buttons.has_flag( IN_FORWARD )   || ctx::client.cmd->buttons.has_flag( IN_BACK ) )
		return;

	if ( ctx::client.local->get_velocity().length_2d() < 50.f )
	{
		/// This gets called if the player is standing still and holds the space bar
		set_autostrafe_movement( calculate_best_rotation( 320.f ) );
	}
	else if ( ctx::client.cmd->mousedx > 1 || ctx::client.cmd->mousedx < -1 )
	{
		/// This gets called if the player is manually strafing with their mouse
		ctx::client.cmd->sidemove = ctx::client.cmd->mousedx < 0.f ? -450.f : 450.f;
	}
	else
	{
		/// This gets called if the player is not strafing with their mouse, but already has some velocity
		set_autostrafe_movement( calculate_best_rotation( ctx::client.local->get_velocity().length_2d() ) );
	}
}

float calculate_best_rotation( float ideal_velocity )
{
	float ideal_rotation = std::min( math::rad2deg( std::asinf( 30.f / ideal_velocity ) ) * 0.5f, 45.f );
	float turn_direction_modifier = ctx::client.cmd->command_number % 2 ? 1.f : -1.f;

	ctx::client.cmd->forwardmove = 0.f;
	ctx::client.cmd->sidemove = 450.f;

	float best_rotation = ( ideal_rotation - 90.f ) * turn_direction_modifier;
	
	return best_rotation;
}

void set_autostrafe_movement( float current_rotation )
{
	float sin_rotation = sin( math::deg2rad( current_rotation ) );
	float cos_rotation = cos( math::deg2rad( current_rotation ) );

	float new_forwardmove = ( sin_rotation * ctx::client.cmd->forwardmove ) + ( cos_rotation * ctx::client.cmd->sidemove );
	float new_sidemove = ( cos_rotation * ctx::client.cmd->forwardmove ) + ( sin_rotation * ctx::client.cmd->sidemove );

	ctx::client.cmd->forwardmove = new_forwardmove;
	ctx::client.cmd->sidemove = new_sidemove;
}`

much better, enjoy pasta

from csgo_modest.

DucaRii avatar DucaRii commented on August 16, 2024

I don't feel like a base needs a lot ( if any ) features at all.

from csgo_modest.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.