Ejemplo n.º 1
0
/*
===================
InterpolateAngles

Interpolate Euler angles.
FIXME:  Use Quaternions to avoid discontinuities
Frac is 0.0 to 1.0 ( i.e., should probably be clamped, but doesn't have to be )
===================
*/
void InterpolateAngles( float *start, float *end, float *output, float frac )
{
	int i;
	float ang1, ang2;
	float d;
	
	NormalizeAngles( start );
	NormalizeAngles( end );

	for ( i = 0 ; i < 3 ; i++ )
	{
		ang1 = start[i];
		ang2 = end[i];

		d = ang2 - ang1;
		if ( d > 180 )
		{
			d -= 360;
		}
		else if ( d < -180 )
		{	
			d += 360;
		}

		output[i] = ang1 + d * frac;
	}

	NormalizeAngles( output );
}
Ejemplo n.º 2
0
void CInterpolation::SetViewAngles(vec3_t start, vec3_t end)
{
	m_StartAngle = start;
	m_EndAngle   = end;
	NormalizeAngles(m_StartAngle);
	NormalizeAngles(m_EndAngle);
}
Ejemplo n.º 3
0
float MaxAngleBetweenAngles(  float * a1, float * a2 )
{
	float d, maxd = 0.0f;

	NormalizeAngles( a1 );
	NormalizeAngles( a2 );

	for ( int i = 0 ; i < 3 ; i++ )
	{
		d = a2[i] - a1[i];
		if ( d > 180 )
		{
			d -= 360;
		}
		else if ( d < -180 )
		{	
			d += 360;
		}

		d = fabs(d);

		if ( d > maxd )
			maxd=d;
	}

	return maxd;
}
Ejemplo n.º 4
0
bool KDLRobotModel::computeFastIK(
    const Eigen::Affine3d& pose,
    const RobotState& start,
    RobotState& solution)
{
    // transform into kinematics frame and convert to kdl
    auto* T_map_kinematics = GetLinkTransform(&this->robot_state, m_kinematics_link);
    KDL::Frame frame_des;
    tf::transformEigenToKDL(T_map_kinematics->inverse() * pose, frame_des);

    // seed configuration
    for (size_t i = 0; i < start.size(); i++) {
        m_jnt_pos_in(i) = start[i];
    }

    // must be normalized for CartToJntSearch
    NormalizeAngles(this, &m_jnt_pos_in);

    if (m_ik_solver->CartToJnt(m_jnt_pos_in, frame_des, m_jnt_pos_out) < 0) {
        return false;
    }

    NormalizeAngles(this, &m_jnt_pos_out);

    solution.resize(start.size());
    for (size_t i = 0; i < solution.size(); ++i) {
        solution[i] = m_jnt_pos_out(i);
    }

    return true;
}
Ejemplo n.º 5
0
bool KDLRobotModel::computeIKSearch(
    const Eigen::Affine3d& pose,
    const RobotState& start,
    RobotState& solution)
{
    // transform into kinematics and convert to kdl
    auto* T_map_kinematics = GetLinkTransform(&this->robot_state, m_kinematics_link);
    KDL::Frame frame_des;
    tf::transformEigenToKDL(T_map_kinematics->inverse() * pose, frame_des);

    // seed configuration
    for (size_t i = 0; i < start.size(); i++) {
        m_jnt_pos_in(i) = start[i];
    }

    // must be normalized for CartToJntSearch
    NormalizeAngles(this, &m_jnt_pos_in);

    auto initial_guess = m_jnt_pos_in(m_free_angle);

    auto start_time = smpl::clock::now();
    auto loop_time = 0.0;
    auto count = 0;

    auto num_positive_increments =
            (int)((GetSolverMinPosition(this, m_free_angle) - initial_guess) /
                    this->m_search_discretization);
    auto num_negative_increments =
            (int)((initial_guess - GetSolverMinPosition(this, m_free_angle)) /
                    this->m_search_discretization);

    while (loop_time < this->m_timeout) {
        if (m_ik_solver->CartToJnt(m_jnt_pos_in, frame_des, m_jnt_pos_out) >= 0) {
            NormalizeAngles(this, &m_jnt_pos_out);
            solution.resize(start.size());
            for (size_t i = 0; i < solution.size(); ++i) {
                solution[i] = m_jnt_pos_out(i);
            }
            return true;
        }
        if (!getCount(count, num_positive_increments, -num_negative_increments)) {
            return false;
        }
        m_jnt_pos_in(m_free_angle) = initial_guess + this->m_search_discretization * count;
        ROS_DEBUG("%d, %f", count, m_jnt_pos_in(m_free_angle));
        loop_time = to_seconds(smpl::clock::now() - start_time);
    }

    if (loop_time >= this->m_timeout) {
        ROS_DEBUG("IK Timed out in %f seconds", this->m_timeout);
        return false;
    } else {
        ROS_DEBUG("No IK solution was found");
        return false;
    }
    return false;
}
Ejemplo n.º 6
0
void V_SmoothInterpolateAngles( float * startAngle, float * endAngle, float * finalAngle, float degreesPerSec )
{
	float absd,frac,d,threshhold;
	
	NormalizeAngles( startAngle );
	NormalizeAngles( endAngle );

	for ( int i = 0 ; i < 3 ; i++ )
	{
		d = endAngle[i] - startAngle[i];

		if ( d > 180.0f )
		{
			d -= 360.0f;
		}
		else if ( d < -180.0f )
		{	
			d += 360.0f;
		}

		absd = fabs(d);

		if ( absd > 0.01f )
		{
			frac = degreesPerSec * v_frametime;

			threshhold= degreesPerSec / 4;

			if ( absd < threshhold )
			{
				float h = absd / threshhold;
				h *= h;
				frac*= h;  // slow down last degrees
			}

			if ( frac >  absd )
			{
				finalAngle[i] = endAngle[i];
			}
			else
			{
				if ( d>0)
					finalAngle[i] = startAngle[i] + frac;
				else
					finalAngle[i] = startAngle[i] - frac;
			}
		}
		else
		{
			finalAngle[i] = endAngle[i];
		}

	}

	NormalizeAngles( finalAngle );
}
Ejemplo n.º 7
0
void CInterpolation::InterpolateAngle(float t, vec3_t &angle)
{
	int   i;
	float ang1, ang2;
	float d;

	for(i = 0; i < 3; i++)
	{
		ang1 = m_StartAngle[i];
		ang2 = m_EndAngle[i];

		d = ang2 - ang1;
		if(d > 180)
		{
			d -= 360;
		}
		else if(d < -180)
		{
			d += 360;
		}

		angle[i] = ang1 + d * t;
	}

	NormalizeAngles(angle);
}
Ejemplo n.º 8
0
void V_SmoothInterpolateAngles( float * startAngle, float * endAngle, float * finalAngle, float degreesPerSec )
{
	float frac,d;
	
	NormalizeAngles( startAngle );
	NormalizeAngles( endAngle );

	for ( int i = 0 ; i < 3 ; i++ )
	{
		d = endAngle[i] - startAngle[i];

		if ( d > 180.0f )
		{
			d -= 360.0f;
		}
		else if ( d < -180.0f )
		{	
			d += 360.0f;
		}

		float absd = fabs(d);

		if ( absd > 0.1f )
		{
			frac = (degreesPerSec * v_frametime ) / absd;
				
			if ( absd < 45.0f )
				frac*= absd / 45.0f; // slow down last 45 degrees

			if ( frac > 1.0f )
			{
				finalAngle[i] = endAngle[i];
			}
			else
			{
				finalAngle[i] = startAngle[i] + d * frac;
			}
		}
		else
		{
			finalAngle[i] = endAngle[i];
		}

	}

	NormalizeAngles( finalAngle );
}
Ejemplo n.º 9
0
void CameraNode::LookAt(vec3 _Position)
{
	assert(Position != _Position);
	glm::vec3 Direction = glm::normalize(Position - _Position);
	VerticalAngle = glm::radians(asinf(-Direction.y));
	HorizontalAngle = -glm::radians(atan2f(-Direction.x, -Direction.z));
	NormalizeAngles();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_PlayerClassCommando::InterpolateBullRushViewAngles( void )
{
	// Determine the fraction.
	if ( m_ClassData.m_flBullRushTime < COMMANDO_BULLRUSH_VIEWDELTA_TEST )
	{
		m_ClassData.m_vecBullRushViewDir = m_ClassData.m_vecBullRushViewGoalDir;
		return;
	}

	float flFraction = 1.0f - ( ( m_ClassData.m_flBullRushTime - COMMANDO_BULLRUSH_VIEWDELTA_TEST ) / COMMANDO_BULLRUSH_VIEWDELTA_TIME );

	QAngle angCurrent;
	InterpolateAngles( m_ClassData.m_vecBullRushViewDir, m_ClassData.m_vecBullRushViewGoalDir, angCurrent, flFraction ); 

	NormalizeAngles( angCurrent );
	m_ClassData.m_vecBullRushViewDir = angCurrent;
}
Ejemplo n.º 11
0
BOOL CPage_Node_Lane::OnInitDialog()
{
	CPropertyPage::OnInitDialog();
	m_CurrentNodeID =  m_pDoc->m_SelectedNodeID ;
	m_CurrentNodeName = m_pDoc->m_NodeIDtoNameMap [m_CurrentNodeID];

	// Give better margin to editors
	m_ListCtrl.SetCellMargin(1.2);
	CGridRowTraitXP* pRowTrait = new CGridRowTraitXP;  // Hao: this ponter should be delete. 
	m_ListCtrl.SetDefaultRowTrait(pRowTrait);

	std::vector<std::string> m_Column_names;
	int nWidth[7] = {60,60,70,90,60,80,90};

	m_Column_names.push_back ("Index");
	m_Column_names.push_back ("Link ID");
	m_Column_names.push_back ("In/Out Link");
	m_Column_names.push_back ("From/To Node");
	m_Column_names.push_back ("Lane No.");
	m_Column_names.push_back ("Lane Type");
	m_Column_names.push_back ("Pocket Length");

	//Add Columns and set headers
	for (size_t i=0;i<m_Column_names.size();i++)
	{
		CGridColumnTrait* pTrait = NULL;
		if(i==m_Column_names.size()-1) // pocket length
		{
			pTrait = new CGridColumnTraitEdit();
		}
		m_ListCtrl.InsertColumnTrait((int)i,m_Column_names.at(i).c_str(),LVCFMT_LEFT,nWidth[i],i,pTrait);
	}

	//Add Rows, all link indexed lanes
	InitLinkData();
	NormalizeAngles();
	FillLinkData();

	UpdateData(0);
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 12
0
void Bench_SetViewAngles( int recalc_wander, Vector& viewangles, float frametime, usercmd_t *cmd )
{
	if ( !Bench_Active() )
		return;

	// Clear stochastic offset between runs
	if ( Bench_InStage( FIRST_STAGE ) )
	{
		v_stochastic = vec3_origin;
	}

	if ( Bench_InStage( SECOND_STAGE ) || Bench_InStage( THIRD_STAGE ) )
	{
		Vector lookdir = g_aimorg - v_origin;
		lookdir = lookdir.Normalize();
		VectorAngles( lookdir, viewangles );
		
		viewangles[0] = -viewangles[0];

		/*
		if ( recalc_wander )
		{
			float fmag = 2.0;
			if ( Bench_GetPowerPlay() )
			{
				fmag = 10.0;
			}

			for ( i = 0; i < 2; i++ )
			{
				v_stochastic[ i ] += frametime * gEngfuncs.pfnRandomFloat( -fmag, fmag );
				v_stochastic[ i ] = max( -15.0, v_stochastic[ i ] );
				v_stochastic[ i ] = min( 15.0, v_stochastic[ i ] );
			}

			v_stochastic[ 2 ] = 0.0;
		}
		*/

		viewangles = viewangles + v_stochastic;

		NormalizeAngles( viewangles );
	}
	else
	{
		viewangles = vec3_origin;

		if ( Bench_InStage( FIRST_STAGE ) )
		{
			viewangles[ 1 ] = -90;
		}
	}

	if ( cmd )
	{
		if ( Bench_InStage( THIRD_STAGE ) )
		{
			cmd->buttons = IN_ATTACK;
		}
		else
		{
			cmd->buttons = 0;
		}
	}
}
Ejemplo n.º 13
0
bool aimbot::Think(CUserCmd* cmd)
{
	float best = std::numeric_limits<float>::quiet_NaN();

	if (css())
	{
		if (!GetMaterialParameters)
			GetMaterialParameters = (void (__cdecl*)(int, float&, float&))util::FindPattern("client", "\x55\x8B\xEC\x8B\x45\x08\x83\xC0\xBD");

		if (!GetBulletTypeParameters)
			GetBulletTypeParameters = (void (__stdcall*)(int, float&, float&))util::FindPattern("client",
				"\x55\x8B\xEC\x56\x8B\x75\x08\x68????\x56\xE8????\x83\xC4\x08\x84\xC0"
			);
	}

	if (!bf)
		bf = new BulletFilter();

	target_id = 0;
	bf->hSelf = lp;

	Vector sp = lp->GetShootPos();
	Vector tp = Vector();

	CBaseEntity* w = lp->GetActiveWeapon();

	if (gmod() && MENU_SPAWPROT == 3 && ALPHA(lp->GetMDLColor()) == 200)
		return 0;

	int lteam = lp->GetTeam();
	int maxcl = (MENU_NPCAIMBT ? ents->GetHighestEntityIndex() : globals->max_clients);

	for (int i = 1; i <= maxcl; ++i)
		if (CBaseEntity* pl = ents->GetClientEntity(i))
		{
			if (pl == lp)
				continue;

			//if (pl->IsDormant())
			//	continue;

			if (!pl->GetModel())
				continue;

			bool npc = i > globals->max_clients;
			bool lowp = 1;

			if (npc)
			{
				const char* cclass = pl->GetClientClass()->m_pNetworkName;

				if (gmod())
				{
					RecvTable* p = pl->GetClientClass()->m_pRecvTable->m_pProps[0].m_pDataTable;

					if ((strcmp(cclass, "CAI_BaseNPC") && (!p || strcmp(p->m_pNetTableName, "DT_AI_BaseNPC"))) || !pl->IsAlive())
						continue;
				}

				if (tf2())
				{
					if (
						lowp = (
							strcmp(cclass, "CObjectSentrygun") ||
							ReadPtr<bool>(pl, m_bHasSapper)
						) &&
						(
							strcmp(cclass, "CTFGrenadePipebombProjectile") ||
							!ReadPtr<int>(pl, m_iType) ||
							!ReadPtr<bool>(pl, m_bTouched) ||
							!pl->IsDummyProjectile() ||
							sp.DistTo(lp->GetAbsOrigin()) > 768.f
						)
					)
						continue;

					if (pl->GetTeam() == lteam)
						continue;
				}
			}
			else if (!DoStateCheck(pl))
				continue;

			if (!pl->UpdateBones())
				continue;
			
			float rate = Rate(lp, pl, npc);
			if (!lowp)
				rate *= 0.1f;

			if (rate > best)
				continue;

			if (css() && pl->GetOrigin().DistTo(sp) > 8192.f)
				continue;

			int aim = GetAimBone(pl);
			bool doscan = 1;

			if (pl->GetHitbox(aim))
			{
				Vector box = pl->GetBoxPos(aim);

				if (BulletTrace(sp, box, pl))
				{
					target_id	= i;
					best		= rate;
					tp			= box;

					continue;
				}
			}

			if (doscan && MENU_BONESCAN)
			{
				int m = pl->Hitboxes();
				for (int j = 0; j < m; ++j)
				{
					if (j == aim)
						continue;

					if (pl->GetHitbox(j))
					{
						Vector box = pl->GetBoxPos(j);

						if (BulletTrace(sp, box, pl))
						{
							target_id	= i;
							best		= rate;
							tp			= box;

							continue;
						}
					}
				}
			}
		}

	if (target_id > 0)
	{
		CBaseEntity* pl = ents->GetClientEntity(target_id);

		if (!pl)
			return 0;

		if (target_id > globals->max_clients) // TODO: predict non-lag comepnsated stuff
		{
			tp -= pl->GetAbsOrigin();
			tp += pl->GetOrigin() + pl->GetVelocity() * engine->GetNetChannel()->GetPing();
		}

		cmd->viewangles = (tp - sp).Angle();
		NormalizeAngles(cmd->viewangles);

		if (MENU_AUTOSHOT)
			add(cmd->buttons, IN_ATTACK);

		return 1;
	}

	return 0;
}
Ejemplo n.º 14
0
float aimbot::Rate(CBaseEntity* me, CBaseEntity* pl, bool npc)
{
	if (!npc && MENU_RAGEBOTE && pl->EntIndex() == ragebot)
		return 0.f;

	float rate = 0.f;

	switch (MENU_PRIORSYS)
	{
	case 0:
		rate = me->GetAbsOrigin().DistTo(pl->GetAbsOrigin());
		break;

	case 1:
		{
			Vector path = (pl->GetAbsOrigin() - me->GetAbsOrigin()).Angle();
			Vector eyes = me->GetEyeAngles();

			NormalizeAngles(eyes);

			rate = path.DistTo(eyes);

			break;
		}

	case 2:
		{
			Vector path = (me->GetAbsOrigin() - pl->GetAbsOrigin()).Angle();
			Vector eyes = pl->GetEyeAngles();

			NormalizeAngles(eyes);

			rate = path.DistTo(eyes);

			break;
		}

	case 3:
		{
			return pl->EntIndex() < next_shot ? 0.f : 1.f;
		}
	}

	if (npc)
	{
		rate *= 3.f;
	}
	else
	{
		if (tf2())
		{
			if (pl->TF2_HasCond(PlayerCond_Cloaked))
				rate *= 50.f;

			if (pl->TF2_HasCond(PlayerCond_DeadRingered))
				rate *= 100.f;

			if (pl->TF2_GetClassNum() == Class_Medic)
			if (ReadPtr<bool>(pl->GetActiveWeapon(), m_bHealing))
				rate *= 0.05f;
		}
	}

	return rate;
}
Ejemplo n.º 15
0
void CameraNode::OffsetOrientation(float _UpAngle, float _RightAngle)
{
	HorizontalAngle += _RightAngle;
	VerticalAngle += _UpAngle;
	NormalizeAngles();
}
Ejemplo n.º 16
0
void C_HLTVCamera::CalcChaseCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov )
{
	bool bManual = !spec_autodirector.GetBool();	// chase camera controlled manually
	
 	Vector targetOrigin1, targetOrigin2, cameraOrigin, forward;

 	if ( m_iTraget1 == 0 )
		return;

	// get primary target, also translates to ragdoll
	C_BaseEntity *target1 = GetPrimaryTarget();

 	if ( !target1 ) 
		return;
	
	if ( target1->IsAlive() && target1->IsDormant() )
		return;

	targetOrigin1 = target1->GetRenderOrigin();

	if ( !target1->IsAlive() )
	{
		targetOrigin1 += VEC_DEAD_VIEWHEIGHT;
	}
	else if ( target1->GetFlags() & FL_DUCKING )
	{
		targetOrigin1 += VEC_DUCK_VIEW;
	}
	else
	{
		targetOrigin1 += VEC_VIEW;
	}

	// get secondary target if set
	C_BaseEntity *target2 = NULL;

	if ( m_iTraget2 > 0 && (m_iTraget2 != m_iTraget1) && !bManual )
	{
		target2 = ClientEntityList().GetBaseEntity( m_iTraget2 );

		// if target is out PVS and not dead, it's not valid
		if ( target2 && target2->IsDormant() && target2->IsAlive() )
			target2 = NULL;

		if ( target2 )
		{
			targetOrigin2 = target2->GetRenderOrigin();

			if ( !target2->IsAlive() )
			{
				targetOrigin2 += VEC_DEAD_VIEWHEIGHT;
			}
			else if ( target2->GetFlags() & FL_DUCKING )
			{
				targetOrigin2 += VEC_DUCK_VIEW;
			}
			else
			{
				targetOrigin2 += VEC_VIEW;
			}
		}
	}

		// apply angle offset & smoothing
	QAngle angleOffset(  m_flPhi, m_flTheta, 0 );
	QAngle cameraAngles = m_aCamAngle;

	if ( bManual )
	{
		// let spectator choose the view angles
 		engine->GetViewAngles( cameraAngles );
	}
	else if ( target2 )
	{
		// look into direction of second target
 		forward = targetOrigin2 - targetOrigin1;
        VectorAngles( forward, cameraAngles );
        cameraAngles.z = 0; // no ROLL
	}
	else if ( m_iTraget2 == 0 || m_iTraget2 == m_iTraget1)
	{
		// look into direction where primary target is looking
		cameraAngles = target1->EyeAngles();
		cameraAngles.x = 0; // no PITCH
		cameraAngles.z = 0; // no ROLL
	}
	else
	{
		// target2 is missing, just keep angelsm, reset offset
		angleOffset.Init();
	}

	if ( !bManual )
	{
		if ( !target1->IsAlive() )
		{
			angleOffset.x = 15;
		}

		cameraAngles += angleOffset;
	}

	AngleVectors( cameraAngles, &forward );

	VectorNormalize( forward );

	// calc optimal camera position
	VectorMA(targetOrigin1, -m_flDistance, forward, cameraOrigin );

 	targetOrigin1.z += m_flOffset; // add offset

	// clip against walls
  	trace_t trace;
	C_BaseEntity::PushEnableAbsRecomputations( false ); // HACK don't recompute positions while doing RayTrace
	UTIL_TraceHull( targetOrigin1, cameraOrigin, WALL_MIN, WALL_MAX, MASK_SOLID, target1, COLLISION_GROUP_NONE, &trace );
	C_BaseEntity::PopEnableAbsRecomputations();

  	float dist = VectorLength( trace.endpos -  targetOrigin1 );

	// grow distance by 32 unit a second
  	m_flLastDistance += gpGlobals->frametime * 32.0f; 

  	if ( dist > m_flLastDistance )
	{
		VectorMA(targetOrigin1, -m_flLastDistance, forward, cameraOrigin );
	}
 	else
	{
		cameraOrigin = trace.endpos;
		m_flLastDistance = dist;
	}
	
  	if ( target2 )
	{
		// if we have 2 targets look at point between them
		forward = (targetOrigin1+targetOrigin2)/2 - cameraOrigin;
 		QAngle angle;
		VectorAngles( forward, angle );
		cameraAngles.y = angle.y;
		
		NormalizeAngles( cameraAngles );
		cameraAngles.x = clamp( cameraAngles.x, -60, 60 );

		SmoothCameraAngle( cameraAngles );
	}
	else
	{
		SetCameraAngle( cameraAngles );
	}
 	
	VectorCopy( cameraOrigin, m_vCamOrigin );
	VectorCopy( m_aCamAngle, eyeAngles );
	VectorCopy( m_vCamOrigin, eyeOrigin );
}
Ejemplo n.º 17
0
void C_HLTVCamera::SetCameraAngle( QAngle& targetAngle )
{
	m_aCamAngle	= targetAngle;
 	NormalizeAngles( m_aCamAngle );
	m_flLastAngleUpdateTime = gpGlobals->realtime;
}
Ejemplo n.º 18
0
void CreateMove(CUserCmd* cmd)
{
	sendPacket = 1;

	CBaseEntity* me	= LocalPlayer();
	CBaseEntity* w	= me->GetActiveWeapon();

	Vector qrv = cmd->viewangles;
	
	globals->cur_time = (float)me->GetTickBase() * ReadPtr<float>(me, m_flLaggedMovementValue) * globals->interval_per_tick;
	
	aimbot::Update();
	aimbot::PerformPrediction(cmd);
	
	bool aim = 0;
	if (MENU_AIMBOTEN && (!MENU_AIMBOTKB || util::IsKeyDown(MENU_AIMBOTKB)) && !aimbot::dummy)
		aim = aimbot::Think(cmd);

	if (!MENU_FAKEVIEW && aim)
		engine->SetViewAngles(cmd->viewangles);
	
	nospread::HandleCmd(cmd, w);


	if (MENU_NORECOIL && !aimbot::dummy)
	{
		nospread::FixRecoil(cmd);
		NormalizeAngles(cmd->viewangles);
	}

	if (MENU_SEMIFULL && !aimbot::dummy && !aimbot::bullet)
		del(cmd->buttons, IN_ATTACK);

	if (tf2() && MENU_AUTOSTAB && w && !strcmp(w->GetClientClass()->m_pNetworkName, "CTFKnife") &&
			!me->TF2_IsCloaked() && ReadPtr<bool>(w, m_bReadyToBackstab))

		add(cmd->buttons, IN_ATTACK);


	if (MENU_AUTORELD && w && !w->IsMelee() && !w->GetClip1() && !w->IsReloading())
	{
		add(cmd->buttons, IN_RELOAD);
		del(cmd->buttons, IN_ATTACK);
	}


	if (aim)
	{
		if (chk(cmd->buttons, IN_ATTACK) && aimbot::bullet)
			aimbot::next_shot = aimbot::target_id;
	}
	else
		aimbot::next_shot = 0;



	if (gmod() && MENU_PROPKILL && w && !strcmp(w->GetClientClass()->m_pNetworkName, "CWeaponPhysGun"))
	{
		static int hold = 0, punt = 0;

		if (chk(cmd->buttons, IN_ATTACK))
		{
			float latency = engine->GetNetChannel()->GetPing();

			hold = (int)((1.0f / globals->interval_per_tick) * (latency + 0.05f));
			punt = (int)((1.0f / globals->interval_per_tick) * (latency + 0.2f));
		}
		else
		{
			if (hold > 0)
			{
				add(cmd->buttons, IN_ATTACK);
				hold--;
			}

			if (punt > 0)
			{
				*cmd->mousewheel() = 0x7F;
				punt--;
			}
		}
	}

	if (MENU_FAKEDUCK && css() && me->IsAlive() && me->IsOnGround() && chk(cmd->buttons, IN_DUCK) && (cmd->tick_count % 2))
	{
		del(cmd->buttons, IN_DUCK);
		del(cmd->buttons, IN_ATTACK);

		sendPacket = 0;
	}

	if (MENU_SMACAIMB)
	{
		static Vector old = cmd->viewangles;
		Vector snap = (cmd->viewangles - old);

		NormalizeAngles(snap);

		const float smac = 42.f;
		if (snap.Normalize() > smac)
		{
			cmd->viewangles = old + snap * smac;
			NormalizeAngles(cmd->viewangles);

			if (aimbot::bullet)
				del(cmd->buttons, IN_ATTACK);
		}

		old = cmd->viewangles;
	}

	if (me->IsAlive())
	{
		//if (MENU_ANTIAIMB)
		//	antiaim::Think(cmd, &sendPacket);



		static float move = 400.f; // move = max(move, (abs(cmd->move.x) + abs(cmd->move.y)) * 0.5f);
		float s_move = move * 0.5065f;

		if (MENU_AUTOSTRF)
		{
			if ((chk(cmd->buttons, IN_JUMP) || !me->IsOnGround()) && me->GetWaterLevel() < 2)
			{
				cmd->move.x = move * 0.015f;
				cmd->move.y += (float)(((cmd->tick_count % 2) * 2) - 1) * s_move;
				
				if (cmd->mousex)
					cmd->move.y = (float)clamp(cmd->mousex, -1, 1) * s_move;

				static float strafe	= cmd->viewangles.y;

				float rt = cmd->viewangles.y, rotation;
				rotation = strafe - rt;

				if (rotation < FloatNegate(globals->interval_per_tick))
					cmd->move.y = -s_move;

				if (rotation > globals->interval_per_tick)
					cmd->move.y = s_move;

				strafe = rt;
			}
		}



		/*
		if (MENU_WALKBOST && !chk(cmd->buttons, IN_JUMP) && me->IsOnGround())
		{
			if ((chk(cmd->buttons, IN_FORWARD) && chk(cmd->buttons, IN_MOVELEFT)) || (chk(cmd->buttons, IN_BACK) && chk(cmd->buttons, IN_MOVERIGHT)))
			if (even)
			{
				cmd->move.y += s_move;
				cmd->move.x += s_move;
			}
			else
			{
				cmd->move.y -= s_move;
				cmd->move.x -= s_move;
			}
			else if ((chk(cmd->buttons, IN_FORWARD) && chk(cmd->buttons, IN_MOVERIGHT)) || (chk(cmd->buttons, IN_BACK) && chk(cmd->buttons, IN_MOVELEFT)))
			if (even)
			{
				cmd->move.y += s_move;
				cmd->move.x -= s_move;
			}
			else
			{
				cmd->move.y -= s_move;
				cmd->move.x += s_move;
			}
			else if (chk(cmd->buttons, IN_FORWARD) || chk(cmd->buttons, IN_BACK))
				if (even)	cmd->move.y += s_move;
				else		cmd->move.y -= s_move;
			else if (chk(cmd->buttons, IN_MOVELEFT) || chk(cmd->buttons, IN_MOVERIGHT))
				if (even)	cmd->move.x += s_move;
				else		cmd->move.x -= s_move;
		}
		*/

		Vector qmove, fixed_va = cmd->viewangles;
		float speed = cmd->move.Length2D();
		
		VectorAngles(cmd->move, qmove);
		NormalizeAngles(fixed_va);

		

		float yaw = Deg2Rad(fixed_va.y - qrv.y + qmove.y);
		float nyaw = FloatNegate(yaw);

		if (cmd->viewangles.x < -90.f || cmd->viewangles.x > 90.f)
		{
			cmd->move.x = FloatNegate(sin(nyaw) * speed);
			cmd->move.y = FloatNegate(cos(nyaw) * speed);
		}
		else
		{
			cmd->move.x = cos(yaw) * speed;
			cmd->move.y = sin(yaw) * speed;
		}

		if (MENU_BUNNYHOP)
		{
			static bool firstjump = 0, fakejmp;

			if (chk(cmd->buttons, IN_JUMP) && me->GetWaterLevel() < 2)
				if (!firstjump)
					firstjump = fakejmp = 1;
				else if (!me->IsOnGround())
					if (MENU_BHOPSAFE && fakejmp && me->GetVelocity().z < 0.0f)
						fakejmp = 0;
					else
						del(cmd->buttons, IN_JUMP);
				else
					fakejmp = 1;
			else
				firstjump = 0;
		}
	}




	if (MENU_FAKELAGB)
	{
		static int q = 0;

		if (q > 0 && !((MENU_FAKELAGA && LocalPlayer()->GetVelocity().Length() < 100.f) ||
			MENU_FAKELAGS && !aimbot::dummy && aimbot::bullet && chk(cmd->buttons, IN_ATTACK)))
		{
			q--;
			sendPacket = 0;
		}
		else
			q = MENU_FAKELAGN;
	}

	if (MENU_CHATSPAM && !(cmd->tick_count % (int)(0.2f / globals->interval_per_tick)))
	{
		char disrupt[] =
		{
			0x7F,
			10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
			10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
			10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
			10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
			10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
			10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
			10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
			10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
			10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
			10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
			0
		};

		util::SendStringCmd("say %s", disrupt);
	}
	
	if (MENU_NAMESTLR)
		namestealer::Think();
}