Results 1 to 3 of 3
  1. #1
    InvokeStatic's Avatar
    Join Date
    Mar 2017
    Gender
    female
    Posts
    8
    Reputation
    10
    Thanks
    399

    [CS 1.6] Perfect Pitch/Yaw NoSpread

    Copy pasters go to hell, sellers that sell this go to hell. You will be cracked, your shit will be leaked and you will be publicly embarrassed. Meant for non-profit consumption only.
    Code:
    double SpreadCone = GetSpread();
    double CosineInput, CosinePitch, InputRoll, PitchBreakingPoint, PitchInput, RadiansPitch;
    double ReciprocalYaw_1, ReciprocalYaw_2, TrapGodConstant, UpVal, Yaw_1;
     
    QAngle QAdjusterAngles, QAngles,  QInputAngles, QInputRoll, QNewAngles, QOldAngles;
    Vector vecRandom;
    	
    Vector vecDir, vecForward, vecRight, vecUp;
    Vector vecReciprocalVector, vecInputRight, vecInputRight2;
     
    TrapGodConstant = 0;
     
    // Trap God Constant computation goes here
     
    QAngles.Init ( cmd->viewangles, 0, 0 );
     
    QOldAngles = QAngles;
     
    QAngles = ( QAngle )0;
     
    QAngles.AngleVectors ( &vecForward, &vecRight, &vecUp );
     
    vecDir = vecForward + ( -SpreadCone * vecRandom[0] * vecRight ) + ( -SpreadCone * vecRandom[1] * vecUp );
     
    vecDir.Normalize();
     
    PitchBreakingPoint = ( atan2 ( vecDir[1], sqrt ( ( 1 - ( vecDir[1] * vecDir[1] ) ) ) ) * 180 / M_PI );
     
    if ( PitchBreakingPoint < 0 )
    {
    	PitchBreakingPoint += 360;
    }
     
    if ( PitchBreakingPoint > 180 )
    {
    	PitchBreakingPoint -= 360;
    }
    else if ( PitchBreakingPoint < -180 )
    {
    	PitchBreakingPoint += 360;
    }
     
    if ( PitchBreakingPoint < 0 )
    {
    	PitchBreakingPoint = 90 + PitchBreakingPoint;
    }
    else
    {
    	PitchBreakingPoint = 90 - PitchBreakingPoint;
    }
     
    QAngles = vecDir.ToEulerAngles();
     
    QAngles.AngleVectors ( &vecForward, &vecRight, &vecUp );
     
    UpVal = vecUp[2];
     
    QAngles = QOldAngles;
     
    CosineInput = QAngles[0] * ( M_PI * 2 / 360 );
    		    
    CosinePitch = cos ( CosineInput );
     
    if ( CosinePitch != 0 )
    {
    	Yaw_1 = 1 / CosinePitch;
    }
    else
    {
    	Yaw_1 = 0;
    }
     
    Yaw_1 *= vecDir[1];
     
    vecInputRight[1] = Yaw_1;
     
    if ( Yaw_1 >= 1 || Yaw_1 <= -1 )
    {
    	vecInputRight[0] = 0;
    }
    else
    {
    	vecInputRight[0] = sqrt ( ( 1 - ( vecInputRight[1] * vecInputRight[1] ) ) );
    }
     
    vecInputRight[2] = 0;
    	
    QAdjusterAngles[1] = ( atan2 ( vecInputRight[1], vecInputRight[0] ) * 180 / M_PI );
    		
    if ( QAdjusterAngles[1] < 0 )
    {
    	QAdjusterAngles[1] += 360;
    }
    		 
    QAdjusterAngles.Normalize();
     
    vecInputRight2[1] = vecDir[1];
     
    if ( vecDir[1] >= 1 || vecDir[1] <= -1 )
    {
    	vecInputRight[0] = 0;
    }
    else
    {
    	vecInputRight2[0] = sqrt ( ( 1 - ( vecInputRight2[1] * vecInputRight2[1] ) ) );
    }
     
    vecInputRight2[2] = 0;
    		
    if ( vecInputRight[0] != 0 )
    {
    	ReciprocalYaw_1 = vecInputRight[1] / vecInputRight[0];
    }
    else
    {
    	ReciprocalYaw_1 = 0;
    }
     
    if ( vecInputRight2[0] != 0 )
    {
    	ReciprocalYaw_2 = vecInputRight2[1] / vecInputRight2[0];
    }
    else
    {
    	ReciprocalYaw_2 = 0;
    }
     
    vecReciprocalVector[0] = ReciprocalYaw_1;
    vecReciprocalVector[1] = ReciprocalYaw_2;
    vecReciprocalVector[2] = 0;
     
    vecReciprocalVector.Normalize();
     
    if ( vecReciprocalVector[0] != 0 )
    {
    	PitchInput = 1 / vecReciprocalVector[0];
    }
    else
    {
    	PitchInput = 0;
    }
     
    PitchInput *= vecReciprocalVector[1];
     
    if ( QAngles[0] < 0 )
    {
    	QInputAngles[0] = asin ( -PitchInput ) * 180 / M_PI;
    }
    else
    {
    	QInputAngles[0] = asin ( PitchInput ) * 180 / M_PI;
    }
    	
    if ( QInputAngles[0] < 0 )
    {
    	QInputAngles[0] += 360;
    }
    	
    QInputAngles.Normalize();
     
    double TempPitch = QAngles[0];
    	
    if ( TempPitch < 0 )
    {
    	TempPitch = -TempPitch;
    }
     
    if ( QAngles[0] < 0 )
    {
    	QInputAngles[0] += ( 45 - TempPitch ) * 2;
    }
    else
    {
    	QInputAngles[0] -= ( 45 - TempPitch ) * 2;
    }
     
    QInputAngles[1] = 0;
    QInputAngles[2] = 0;
     
    QInputAngles.Normalize();
     
    QInputAngles.AngleVectors ( &vecForward, &vecRight, &vecUp );
     
    vecDir[0] = vecForward[0] + ( SpreadCone * vecRandom[0] * vecRight[0] ) + ( SpreadCone * vecRandom[1] * vecUp[0] );
    vecDir[1] = 0;
    vecDir[2] = vecForward[2] + ( SpreadCone * vecRandom[0] * vecRight[2] ) + ( SpreadCone * vecRandom[1] * vecUp[2] );
    	
    vecDir.Normalize();
    		
    if ( QAngles[0] < 0 )
    {
    	QAdjusterAngles[0] = ( asin ( vecDir[2] ) * 180 / M_PI );
    }
    else
    {
    	QAdjusterAngles[0] = ( asin ( -vecDir[2] ) * 180 / M_PI );
    }
    	
    if ( QAdjusterAngles[0] < 0 )
    {
    	QAdjusterAngles[0] += 360;
    }
    	
    QAdjusterAngles.Normalize();
     
    QNewAngles = QOldAngles;
     
    if ( QAngles[0] < 0 )
    {
    	QNewAngles[0] += QNewAngles[0] + QAdjusterAngles[0];
    }
    else
    {
    	QNewAngles[0] += QNewAngles[0] - QAdjusterAngles[0];
    }
     
    QNewAngles[1] = QNewAngles[1] + QAdjusterAngles[1];
    QNewAngles[2] = 0;
     
    QNewAngles.Normalize();
     
    if ( QAngles[0] < -PitchBreakingPoint || QAngles[0] > PitchBreakingPoint )
    {
    	QNewAngles.AngleVectors ( &vecForward, &vecRight, &vecUp );
    	
    	InputRoll = vecUp[1] / UpVal;
     
    	QInputRoll[0] = ( asin ( InputRoll ) * 180 / M_PI );
     
    	if ( QInputRoll[0] < 0 )
    	{
    		QInputRoll[0] += 360;
    	}
     
    	QInputRoll.Normalize();
     
    	QInputRoll[0] *= -1;
     
    	QNewAngles = QOldAngles;
     
    	QNewAngles[2] = QInputRoll[0] + TrapGodConstant;
     
    	QNewAngles.AngleVectors ( &vecForward, &vecRight, &vecUp );
    	
    	vecDir = vecForward + ( -SpreadCone * vecRandom[0] * vecRight ) + ( -SpreadCone * vecRandom[1] * vecUp );
    	
    	vecDir.Normalize();
    	
    	QNewAngles = vecDir.ToEulerAngles ( &vecUp );
    	
    	QNewAngles.Normalize();
    	
    	QNewAngles[2] += TrapGodConstant;
     
    	QNewAngles.Normalize();
    }
    Credits: wav

  2. #2
    Rin's Avatar
    Join Date
    Aug 2015
    Gender
    male
    Location
    The Fifth Holy Grail War
    Posts
    224
    Reputation
    10
    Thanks
    19
    My Mood
    Psychedelic
    tl;dr.

  3. #3
    Exhaleq's Avatar
    Join Date
    Mar 2015
    Gender
    male
    Posts
    1
    Reputation
    10
    Thanks
    0
    how to use?

Similar Threads

  1. Pitch yaw
    By crossfighter in forum Crossfire Coding Help & Discussion
    Replies: 8
    Last Post: 07-26-2016, 04:25 AM
  2. [Release] pitch yaw roll to pitch yaw
    By snipwnage2 in forum Garry's Mod Hacks & Cheats
    Replies: 11
    Last Post: 07-11-2015, 09:01 PM
  3. Pitch & Yaw - Offsets
    By Chuck Norris in forum WarRock Hack Source Code
    Replies: 8
    Last Post: 02-13-2015, 05:03 AM
  4. yaw pitch/ playermgr?
    By kibbles18 in forum Combat Arms Coding Help & Discussion
    Replies: 14
    Last Post: 04-30-2011, 10:04 AM
  5. Pitch, Yaw, Roll
    By _Fk127_ in forum Combat Arms Coding Help & Discussion
    Replies: 3
    Last Post: 04-27-2011, 05:34 PM