Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define AIMLOCK 4.2f
- #define AIMSPEEDFACTOR 60
- #define AIMRANGE 180.0f
- void getyawpitch(const vec &from, const vec &to, float &yaw, float &pitch){
- float dist = from.dist(to);
- yaw = -(float)atan2(to.x-from.x, to.y-from.y)/PI*180+180;
- pitch = asin((to.z-from.z)/dist)/RAD;
- }
- float absf(float f){
- if(f<0.0f){
- return -f;
- }else{
- return f;
- }
- }
- if(keys[VK_LSHIFT] && player1->state == CS_ALIVE){
- float tDist = 99999.0f;
- int tTarg = -1;
- float ny, np;
- float angleDist = 99999.0f;
- loopv(players){ // Closest to Crosshair Aimbot
- if(players[i] != NULL && player1 != NULL){
- if(!isteam(player1->team,players[i]->team) && players[i]->state == CS_ALIVE){
- getyawpitch(player1->o,players[i]->o,ny,np);
- if((absf(player1->pitch - np) + absf(player1->yaw - ny)) < angleDist){
- angleDist = (absf(player1->pitch - np) + absf(player1->yaw - ny));
- tTarg = i;
- }
- }
- }
- }
- if(tTarg > -1){
- if(players[tTarg] != NULL){
- getyawpitch(player1->o,players[tTarg]->o,ny,np);
- if(absf(player1->pitch-np)<AIMRANGE && absf(player1->yaw-ny)<AIMRANGE){
- if(player1->pitch > np){
- player1->pitch -= ((player1->pitch-np)/AIMSPEEDFACTOR);
- if((player1->pitch - np) < AIMLOCK){
- player1->pitch = np;
- }
- }
- if(player1->pitch < np){
- player1->pitch += ((np-player1->pitch)/AIMSPEEDFACTOR);
- if((np - player1->pitch) < AIMLOCK){
- player1->pitch = np;
- }
- }
- if(player1->yaw > ny){
- player1->yaw -= ((player1->yaw-ny)/AIMSPEEDFACTOR);
- if((player1->yaw - ny) < AIMLOCK){
- player1->yaw = ny;
- }
- }
- if(player1->yaw < ny){
- player1->yaw += ((ny-player1->yaw)/AIMSPEEDFACTOR);
- if((ny - player1->yaw) < AIMLOCK){
- player1->yaw = ny;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment