Advertisement
Guest User

TUTORIAL 2 - Cryoscalpel

a guest
Jan 13th, 2020
657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. document.addEventListener('keydown', function(e){
  2.     if(e.code == "ShiftLeft"){
  3.         window.aimbot = true;
  4.     }
  5. });
  6.  
  7. document.addEventListener('keyup', function(e){
  8.     if(e.code == "ShiftLeft"){
  9.         window.aimbot = false;
  10.     }
  11. });
  12.  
  13. window.aimbot = false;
  14.  
  15. window.calcAngle =function(us, them){
  16.     if(!us.x){
  17.         return [0,0]
  18.     }
  19.     var dx = us.x-them.x;
  20.     var dy = us.y-them.y;
  21.     var dz = us.z-them.z;
  22.     var pitch_radi = (Math.atan2(dy, Math.sqrt(dx*dx+dz*dz)));
  23.     var yaw_radi = -1*(Math.atan2(dz,dx)-1.57)
  24.     if(dy >= 0){
  25.         yaw_radi += Math.PI;
  26.     }else{
  27.         yaw_radi -= Math.PI;
  28.     }
  29.     return [pitch_radi, yaw_radi]
  30. }
  31.  
  32. window.getDist = function(us,them){
  33.     return Math.sqrt(   (us.x-them.x)**2 + (us.y-them.y)**2 + (us.z-them.z)**2  )
  34. }
  35.  
  36. function simpleStringify (object){
  37.     var simpleObject = {};
  38.     for (var prop in object ){
  39.         if (!object.hasOwnProperty(prop)){
  40.             continue;
  41.         }
  42.         if (typeof(object[prop]) == 'object'){
  43.             continue;
  44.         }
  45.         if (typeof(object[prop]) == 'function'){
  46.             continue;
  47.         }
  48.         simpleObject[prop] = object[prop];
  49.     }
  50.     return JSON.stringify(simpleObject);
  51. };
  52.  
  53. window.getNearest = function(us, them){
  54.     let near = {player:null,dist:null};
  55.     for(var c in them){
  56.         let player = them[c];
  57.         if(player){
  58.             console.log(simpleStringify(player))
  59.             if(player.id != us.id && player.hp > 0){
  60.                 let dist_ = getDist(us,player);
  61.                 if(!near.player || dist_ < near.dist){
  62.                     near.player = player;
  63.                     near.dist = dist_;
  64.                 }
  65.             }
  66.         }
  67.     }
  68.     return near.player;
  69. }
  70.  
  71. window.aimBot = function(us,them){
  72.     let playerNear = getNearest(us,them)
  73.     let angle = calcAngle(us,playerNear)
  74.     return angle;
  75. }
  76.  
  77. /* heres the hook
  78. //184935 e.runRenderLoop((function()
  79.             if(aimbot){
  80.                 let a_ = aimBot(dr, xr);
  81.                 if(a_[0] && a_[1]){
  82.                     dr.pitch = a_[0];
  83.                     dr.yaw = a_[1];
  84.                 }
  85.             }
  86. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement