Newtrat

gameOverride

Mar 6th, 2019
588
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.gameFunctions = window.gameFunctions || {};
  2. window.gameFunctions.gameOverride = function(){
  3.     this.override = true;
  4.    
  5.     // ZOOM
  6.    
  7.     var baseCameraTargetZoom = this[obfuscate.camera][obfuscate.targetZoom];
  8.     this[obfuscate.camera].__defineSetter__(obfuscate.targetZoom, function(val){
  9.         baseCameraTargetZoom = val;
  10.     });
  11.     this[obfuscate.camera].__defineGetter__(obfuscate.targetZoom, function(){
  12.         if(window.gameVars && window.menu && window.menu.UserSetting.look.zoomEnabled)
  13.             return window.gameVars.ZoomLevel;
  14.        
  15.         return baseCameraTargetZoom;
  16.     });
  17.    
  18.     var baseZoomFast = this[obfuscate.activePlayer].zoomFast;
  19.     this[obfuscate.activePlayer].__defineSetter__("zoomFast", function(val){
  20.         baseZoomFast = val;
  21.     });
  22.     this[obfuscate.activePlayer].__defineGetter__("zoomFast", function(){
  23.         if(window.menu && window.menu.UserSetting.look.zoomEnabled)
  24.             return true;
  25.        
  26.         return baseZoomFast;
  27.     });
  28.     // this[obfuscate.activePlayer][obfuscate.localData].inventory.soda = 1;
  29.     // console.log(this[obfuscate.activePlayer][obfuscate.localData].inventory);
  30.     // INPUT
  31.    
  32.     var inpt = this[obfuscate.input];
  33.     window.deadPlayers = new Set();
  34.     // this[obfuscate.input].mouseButton = !1;
  35.     // this[obfuscate.input].mouseButtonOld = !1;
  36.     // this[obfuscate.input].rightMouseButton = !1;
  37.     // this[obfuscate.input].rightMouseButtonOld = !1;
  38.     // console.log(inpt);
  39.    
  40.     var processInput = function(bind, down){
  41.        
  42.         if(window.gameVars.Input.GlobalHookCallback) {
  43.             if(bind.code == 27)  {
  44.                 window.gameVars.Input.GlobalHookCallback.call(this, {code: 0, shift: false, ctrl: false, alt: false});
  45.             } else if(((bind.code == 16) || (bind.code == 17) || (bind.code == 18)) &&
  46.                 (window.gameVars.Input.Keyboard.AnythingElsePressed == 0)) {
  47.                 if(down)
  48.                     return
  49.                 if(bind.code == 16) bind.shift = false;
  50.                 if(bind.code == 17) bind.ctrl = false;
  51.                 if(bind.code == 18) bind.alt = false;
  52.                 window.gameVars.Input.GlobalHookCallback.call(this, bind);
  53.             } else if(down){
  54.                 window.gameVars.Input.GlobalHookCallback.call(this, bind);
  55.             }
  56.            
  57.             return;
  58.         }
  59.        
  60.         // always pass Esc
  61.         if(bind.code == 27) return keyboardEvent(27, down);
  62.        
  63.         var opt = window.menu.UserSetting.binds;
  64.        
  65.         if(checkBind(opt.autoAim, bind)) {
  66.             window.gameVars.Input.Cheat.AutoAimPressed = down;
  67.         }else if(checkBind(opt.switchMainWeapon, bind)) {
  68.             window.gameVars.Input.Cheat.SwitchWeaponFirst = down;
  69.         }else if(checkBind(opt.zoomIn, bind)) {
  70.             window.gameVars.Input.Cheat.ZoomDelta += 1;
  71.         }else if(checkBind(opt.zoomOut, bind)) {
  72.             window.gameVars.Input.Cheat.ZoomDelta -= 1;
  73.         }else if(checkBind(opt.displayNames, bind)) {
  74.             window.gameVars.Input.Cheat.ShowNamesPressed = down;
  75.         // }else if(checkBind(opt.streamerMode, bind)) {
  76.            
  77.         }else if(checkBind(opt.goUp, bind)) {
  78.             keyboardEvent(87, down);
  79.         }else if(checkBind(opt.goLeft, bind)) {
  80.             keyboardEvent(65, down);
  81.         }else if(checkBind(opt.goDown, bind)) {
  82.             keyboardEvent(83, down);
  83.         }else if(checkBind(opt.goRight, bind)) {
  84.             keyboardEvent(68, down);
  85.         }else if(checkBind(opt.shoot, bind)) {
  86.             mouseButtonEvent(0, down);
  87.         }else if(checkBind(opt.reload, bind)) {
  88.             keyboardEvent(82, down);
  89.         }else if(checkBind(opt.swapWeapSlots, bind)) {
  90.             keyboardEvent(84, down);
  91.         }else if(checkBind(opt.interact, bind)) {
  92.             keyboardEvent(70, down);
  93.         }else if(checkBind(opt.cancelAction, bind)) {
  94.             keyboardEvent(88, down);
  95.         }else if(checkBind(opt.teamPing, bind)) {
  96.             triggerPing(down);
  97.         }else if(checkBind(opt.emotes, bind)) {
  98.             triggerEmote(down);
  99.         }else if(checkBind(opt.toggleMap, bind)) {
  100.             keyboardEvent(77, down);
  101.         }else if(checkBind(opt.toggleMiniMap, bind)) {
  102.             keyboardEvent(86, down);
  103.         }else if(checkBind(opt.equipLast, bind)) {
  104.             keyboardEvent(81, down);
  105.         }else if(checkBind(opt.equipNext, bind)) {
  106.             mouseWheelEvent(1);
  107.         }else if(checkBind(opt.equipPrev, bind)) {
  108.             mouseWheelEvent(-1);
  109.         }else if(checkBind(opt.equipWeapon1, bind)) {
  110.             keyboardEvent(49, down);
  111.         }else if(checkBind(opt.equipWeapon2, bind)) {
  112.             keyboardEvent(50, down);
  113.         }else if(checkBind(opt.equipWeapon3, bind)) {
  114.             keyboardEvent(51, down);
  115.         }else if(checkBind(opt.equipWeapon4, bind)) {
  116.             keyboardEvent(52, down);
  117.         }else if(checkBind(opt.useMedical7, bind)) {
  118.             keyboardEvent(55, down);
  119.         }else if(checkBind(opt.useMedical8, bind)) {
  120.             keyboardEvent(56, down);
  121.         }else if(checkBind(opt.useMedical9, bind)) {
  122.             keyboardEvent(57, down);
  123.         }else if(checkBind(opt.useMedical0, bind)) {
  124.             keyboardEvent(48, down);
  125.         }
  126.     }
  127.    
  128.     var checkBind = function(ref, bind){
  129.         try {
  130.             return ref.code == bind.code &&
  131.             !(ref.shift && !bind.shift) &&
  132.             !(ref.ctrl && !bind.ctrl) &&
  133.             !(ref.alt && !bind.alt);
  134.         } catch (err) {
  135.             return false;
  136.         }
  137.     }
  138.  
  139.    
  140.     document.addEventListener('mousedown', function(e) {
  141.         // console.log(e.button);  
  142.         if((e.button == 1) || (e.button == 2) || (e.button == 3) || (e.button == 4) || (window.gameVars.Input.GlobalHookCallback && (e.button == 0))){
  143.             processInput({code: e.button * -1 - 1, shift: e.shiftKey, ctrl: e.ctrlKey, alt: e.altKey}, true);
  144.         }
  145.         if(window.gameVars && window.gameVars.Menu)
  146.             e.stopPropagation();
  147.         if(e.button == 0) {
  148.             inpt.mouseButton = true;
  149.         }
  150.         if(e.button == 1) {
  151.             e.preventDefault();
  152.             e.stopPropagation();
  153.         }
  154.     });
  155.  
  156.     document.addEventListener('mouseup', function(e) {
  157.         if (e.button == 0) {
  158.             inpt.mouseButton = false;
  159.         } else if (e.button == 1, 2, 3, 4) {
  160.             processInput({code: e.button * -1 - 1, shift: e.shiftKey, ctrl: e.ctrlKey, alt: e.altKey}, false);
  161.         }
  162.     });
  163.  
  164.    
  165.     var keyboardEvent = function(code, down){
  166.         // console.log(down);
  167.         down ? onKeyDownBase.call(inpt, {keyCode: code}) : onKeyUpBase.call(inpt, {keyCode: code});
  168.     }
  169.    
  170.     var mouseButtonEvent = function(buttonCode, down){
  171.         down ? onMouseDownBase.call(inpt, {button: buttonCode}) : onMouseUpBase.call(inpt, {button: buttonCode});
  172.         if(buttonCode == 0) {
  173.             window.gameVars.Input.Cheat.FirePressed = down;
  174.         }
  175.     }
  176.    
  177.     var mouseWheelEvent = function(delta){
  178.         onMouseWheelBase.call(inpt, {deltaY: delta});
  179.     }
  180.    
  181.     var triggerEmote = function(down) {
  182.         if(window.Pings && window.Pings.EmoteTrigger)
  183.             window.Pings.EmoteTrigger(down)
  184.     }
  185.    
  186.     var triggerPing = function(down) {
  187.         if(window.Pings && window.Pings.PingTrigger)
  188.             window.Pings.PingTrigger(down)
  189.     }
  190.    
  191.     // keyboard
  192.    
  193.     var onKeyDownBase = function (e) {
  194.         this.keys[e.keyCode] = !0,
  195.         this.shiftKey |= e.shiftKey
  196.     }
  197.     // console.log(onKeyDownBase);
  198.     this[obfuscate.input].onKeyDown = function(e){
  199.         // console.log("Key down!");
  200.         processInput({code: e.keyCode, shift: e.shiftKey, ctrl: e.ctrlKey, alt: e.altKey}, true);
  201.         if(e.keyCode == 16) return window.gameVars.Input.Keyboard.ShiftPressed = true;
  202.         if(e.keyCode == 17) return window.gameVars.Input.Keyboard.CtrlPressed = true;
  203.         if(e.keyCode == 18) return window.gameVars.Input.Keyboard.AltPressed = true;
  204.         window.gameVars.Input.Keyboard.AnythingElsePressed += 1;
  205.     };
  206.     var onKeyUpBase = function (e) {
  207.         delete this.keys[e.keyCode]
  208.     };
  209.     this[obfuscate.input].onKeyUp = function(e){
  210.         processInput({code: e.keyCode, shift: e.shiftKey, ctrl: e.ctrlKey, alt: e.altKey}, false);
  211.         if(e.keyCode == 16) return window.gameVars.Input.Keyboard.ShiftPressed = false;
  212.         if(e.keyCode == 17) return window.gameVars.Input.Keyboard.CtrlPressed = false;
  213.         if(e.keyCode == 18) return window.gameVars.Input.Keyboard.AltPressed = false;
  214.         window.gameVars.Input.Keyboard.AnythingElsePressed -= 1;
  215.         if(window.gameVars.Input.Keyboard.AnythingElsePressed < 0)
  216.             window.gameVars.Input.Keyboard.AnythingElsePressed = 0;
  217.     };
  218.    
  219.     window.addEventListener("focus", function(event)
  220.     {
  221.         window.gameVars.Input.Keyboard.ShiftPressed = false;
  222.         window.gameVars.Input.Keyboard.CtrlPressed = false;
  223.         window.gameVars.Input.Keyboard.AltPressed = false;
  224.         window.gameVars.Input.Keyboard.AnythingElsePressed = 0;
  225.     }, false);
  226.    
  227.     // mouse
  228.    
  229.     var onMouseMoveBase = this[obfuscate.input].onMouseMove;
  230.     this[obfuscate.input].onMouseMove = function(e){
  231.         if(window.gameVars){
  232.             window.gameVars.Input.Mouse.Pos.x = e.clientX;
  233.             window.gameVars.Input.Mouse.Pos.y = e.clientY;
  234.            
  235.             if(window.gameVars.Input.Mouse.AimActive) {
  236.                 // e.clientX = window.gameVars.Input.Mouse.AimPos.x;
  237.                 // e.clientY = window.gameVars.Input.Mouse.AimPos.y;
  238.                 e = {
  239.                     clientX: window.gameVars.Input.Mouse.AimPos.x,
  240.                     clientY: window.gameVars.Input.Mouse.AimPos.y
  241.                 }
  242.             }
  243.         }
  244.        
  245.         onMouseMoveBase.call(inpt, e);
  246.     };
  247.     var onMouseDownBase = function(e) {
  248.         this.mouseButton = this.mouseButton || 0 === e.button,
  249.         this.rightMouseButton = this.rightMouseButton || 2 === e.button
  250.     };
  251.     // console.log(onMouseDownBase);
  252.     onMouseDownBase = function(e){
  253.         processInput({code: e.button * -1 - 1, shift: e.shiftKey, ctrl: e.ctrlKey, alt: e.altKey}, true);
  254.     };
  255.     var onMouseUpBase = function (e) {
  256.         this.mouseButton = 0 !== e.button && this.mouseButton,
  257.         this.rightMouseButton = 2 !== e.button && this.rightMouseButton
  258.     };
  259.     onMouseUpBase = function(e){
  260.         processInput({code: e.button * -1 - 1, shift: e.shiftKey, ctrl: e.ctrlKey, alt: e.altKey}, false);
  261.     };
  262.     var onMouseWheelBase = this[obfuscate.input].onMouseWheel;
  263.     if (window.menu.UserSetting.look.zoomEnabled) {
  264.         this[obfuscate.input].onMouseWheel = function(e){
  265.             e.stopPropagation();
  266.             if(window.gameVars && window.gameVars.Menu && !(window.gameVars.Input.GlobalHookCallback))
  267.                 return;
  268.             processInput({
  269.                 code: e.deltaY < 0 ? -6 : -7,
  270.                 shift: window.gameVars.Input.Keyboard.ShiftPressed,
  271.                 ctrl: window.gameVars.Input.Keyboard.CtrlPressed,
  272.                 alt: window.gameVars.Input.Keyboard.AltPressed
  273.             }, true);
  274.         }
  275.     } else {
  276.         this[obfuscate.input].onMouseWheel = onMouseWheelBase;
  277.     }
  278.    
  279.     var inputKeyPressedBase = this[obfuscate.input][obfuscate.keyPressed];
  280.     // console.log(inputKeyPressedBase);
  281.     this[obfuscate.input][obfuscate.keyPressed] = function(e){
  282.         if(window.gameVars)
  283.         {
  284.             if(window.gameVars.Input.Cheat.RepeatInteraction && e == 70)
  285.                 return true;
  286.         }
  287.        
  288.         return inputKeyPressedBase.call(inpt, e);
  289.     };
  290.  
  291.     var mousePressedFunc = function () {
  292.         return !this.mouseButtonOld && this.mouseButton
  293.     }
  294.    
  295.     var inputMousePressedBase = this[obfuscate.input][obfuscate.mouseDown];
  296.     this[obfuscate.input][obfuscate.mouseDown] = function(){
  297.         if(window.gameVars && window.gameVars.Input.Cheat.RepeatFire)
  298.             return false;
  299.        
  300.         return inputMousePressedBase.call(inpt);
  301.     };
  302.     var zHelper = function (e) {
  303.         return void 0 !== this.keys[e]
  304.     }
  305.     var mouseDownFunc = function (e) {
  306.         return this.keysOld[e] && !this.zHelper(e)
  307.     }
  308.    
  309.     var inputMouseDownBase = this[obfuscate.input][obfuscate.mousePressed];
  310.     this[obfuscate.input][obfuscate.mousePressed] = function(){
  311.         if(window.gameVars && window.gameVars.Input.Cheat.RepeatFire)
  312.             return true;
  313.        
  314.         return inputMouseDownBase.call(inpt);
  315.     };
  316.    
  317. }
Advertisement
Add Comment
Please, Sign In to add comment