Advertisement
Josiahiscool73

11v xcloud cheat(best)

Apr 25th, 2025 (edited)
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.57 KB | None | 0 0
  1. // == Xbox Cloud Gaming aim assist ===
  2.  
  3. (function(){
  4. // --- Flags & State ---
  5. let enabled = true,
  6. pointerLocked = false,
  7. gameArea = null,
  8. stateInt, dispatchInt;
  9.  
  10. const TOGGLE_KEY = 'end', KILL_KEY = 'home';
  11. console.log(' KBM Aim Assist – [End]=Toggle, [Home]=Kill');
  12.  
  13. // --- Config ---
  14. const POLL_MS = 16,
  15. DISPATCH_MS = 100,
  16. AXIS_DEADZONE = 0.05;
  17.  
  18. const BASE_SENS_X = 0.025,
  19. BASE_SENS_Y = 0.025,
  20. ADS_MULT = 1.75,
  21. MOUSE_DECAY = 0.0;
  22.  
  23. const ENABLE_SMOOTH = true,
  24. SMOOTH_BASE = 0.5,
  25. SMOOTH_PEAK = 0.9,
  26. SMOOTH_RAMP_MS = 300;
  27.  
  28. const ENABLE_MICRO = true,
  29. MICRO_RAD = 0.02,
  30. MICRO_SPD = 0.15;
  31.  
  32. const ENABLE_RECOIL = true,
  33. FIRE_IDX = 7;
  34.  
  35. const RECOIL_PRESETS = {
  36. scar: 0.020,
  37. m16: 0.017,
  38. compact_smg: 0.030,
  39. pump_shotgun: 0.005,
  40. bolt_sniper: 0.008,
  41. tac_shotgun: 0.007,
  42. heavy_sniper: 0.010
  43. };
  44. let currentPreset = 'scar';
  45.  
  46. // --- Controller State ---
  47. const state = {
  48. axes: [0,0,0,0],
  49. buttons: Array(17).fill().map((_,i)=>({
  50. pressed:false, touched:false, value:0, index:i
  51. })),
  52. axisKey: {0:{neg:false,pos:false},1:{neg:false,pos:false}},
  53. dx: 0, dy:0,
  54. ts: performance.now(),
  55. microAngle: 0,
  56. adsStart: 0
  57. };
  58.  
  59. // --- Mappings ---
  60. const ADS_IDX = 6;
  61. const keyMap = {
  62. w:{t:'a',a:1,v:-1}, s:{t:'a',a:1,v:1},
  63. a:{t:'a',a:0,v:-1}, d:{t:'a',a:0,v:1},
  64. ' ':{t:'b',i:0}, shift:{t:'b',i:10}, control:{t:'b',i:11},
  65. r:{t:'b',i:2}, e:{t:'b',i:3}, f:{t:'b',i:5}, g:{t:'b',i:1},
  66. escape:{t:'b',i:9}, tab:{t:'b',i:8}, m:{t:'b',i:8},
  67. z:{t:'b',i:14}, x:{t:'b',i:15}, c:{t:'b',i:13}, v:{t:'b',i:12}
  68. };
  69. const mouseMap = {
  70. 0:{t:'b',i:FIRE_IDX},
  71. 2:{t:'b',i:ADS_IDX}
  72. };
  73.  
  74. // --- Build a real Gamepad object ---
  75. function makeGamepad() {
  76. const axes = state.axes.map(v=>Math.abs(v)<AXIS_DEADZONE ? 0 : v);
  77. const btns = state.buttons.map(b=>({
  78. pressed:b.pressed, touched:b.touched, value:b.value, index:b.index
  79. }));
  80. return {
  81. axes, buttons: btns, connected: true,
  82. id: "KBM Mapper v10.7", index: 0,
  83. mapping: "standard", timestamp: state.ts
  84. };
  85. }
  86.  
  87. // --- Core Update Loop ---
  88. function updateState() {
  89. if (!enabled || !pointerLocked) return;
  90. const now = performance.now();
  91. const isADS = state.buttons[ADS_IDX].pressed;
  92. const isFire = state.buttons[FIRE_IDX].pressed;
  93.  
  94. // manage ADS ramp timer
  95. if (isADS && state.adsStart===0) state.adsStart = now;
  96. if (!isADS) state.adsStart = 0;
  97.  
  98. // base mouse deltas
  99. let sx = BASE_SENS_X, sy = BASE_SENS_Y;
  100. if (isADS) { sx *= ADS_MULT; sy *= ADS_MULT; }
  101.  
  102. let rx = state.axes[2]*MOUSE_DECAY + state.dx * sx;
  103. let ry = state.axes[3]*MOUSE_DECAY + state.dy * sy;
  104.  
  105. // circular micro-movement
  106. if (ENABLE_MICRO && isADS) {
  107. rx += Math.cos(state.microAngle) * MICRO_RAD;
  108. ry += Math.sin(state.microAngle) * MICRO_RAD;
  109. state.microAngle = (state.microAngle + MICRO_SPD) % (2*Math.PI);
  110. }
  111.  
  112. // manual anti-recoil
  113. if (ENABLE_RECOIL && isFire) {
  114. ry += RECOIL_PRESETS[currentPreset] || 0;
  115. }
  116.  
  117. // smoothing ramp
  118. if (ENABLE_SMOOTH && isADS) {
  119. const held = now - state.adsStart;
  120. const t = Math.min(1, held / SMOOTH_RAMP_MS);
  121. const factor = SMOOTH_BASE * (1 - t) + SMOOTH_PEAK * t;
  122. rx = state.axes[2]*factor + rx*(1-factor);
  123. ry = state.axes[3]*factor + ry*(1-factor);
  124. }
  125.  
  126. // clamp to [-1,1]
  127. state.axes[2] = Math.max(-1, Math.min(1, rx));
  128. state.axes[3] = Math.max(-1, Math.min(1, ry));
  129.  
  130. // clear deltas & timestamp
  131. state.dx = state.dy = 0;
  132. state.ts = now;
  133. }
  134.  
  135. // --- Dispatch a real GamepadEvent ---
  136. function dispatchPad() {
  137. if (!enabled) return;
  138. const gp = makeGamepad();
  139. try {
  140. const evt = new GamepadEvent('gamepadconnected', { gamepad: gp });
  141. window.dispatchEvent(evt);
  142. } catch (e) {
  143. console.error('Failed to dispatch GamepadEvent:', e);
  144. }
  145. }
  146.  
  147. // --- Input Helpers ---
  148. function prevent(e) { e.preventDefault(); e.stopPropagation(); }
  149. function shouldCapture(key, code) {
  150. if ([TOGGLE_KEY, KILL_KEY].includes(key)) return false;
  151. if (/^[a-z0-9]$/.test(key)) return true;
  152. if ("`-=[]\\;',./~_+{}|:\"<>?".includes(key)) return true;
  153. return ['Tab','Enter','Escape','ArrowUp','ArrowDown','ArrowLeft','ArrowRight']
  154. .includes(code);
  155. }
  156.  
  157. // --- Keyboard Handlers ---
  158. function onKeyDown(e) {
  159. const k = e.key.toLowerCase();
  160. if (k === KILL_KEY) { teardown(); return prevent(e); }
  161. if (k === TOGGLE_KEY) { toggle(); return prevent(e); }
  162. if (!enabled) return;
  163.  
  164. // recoil preset switch (1–7)
  165. if (ENABLE_RECOIL && /[1-7]/.test(k)) {
  166. const arr = ['scar','m16','compact_smg','pump_shotgun','bolt_sniper','tac_shotgun','heavy_sniper'];
  167. currentPreset = arr[+k-1];
  168. console.log(` Recoil → ${currentPreset} (${RECOIL_PRESETS[currentPreset]})`);
  169. return prevent(e);
  170. }
  171.  
  172. const m = keyMap[k];
  173. if (m) {
  174. prevent(e);
  175. if (m.t === 'b') {
  176. const btn = state.buttons[m.i];
  177. btn.pressed = btn.touched = true; btn.value = 1;
  178. } else {
  179. const ax = state.axisKey[m.a];
  180. m.v < 0 ? ax.neg = true : ax.pos = true;
  181. state.axes[m.a] = ax.neg && ax.pos ? 0 : (ax.neg ? -1 : 1);
  182. }
  183. } else if (shouldCapture(k, e.code)) {
  184. prevent(e);
  185. }
  186. }
  187.  
  188. function onKeyUp(e) {
  189. const k = e.key.toLowerCase();
  190. if ([KILL_KEY, TOGGLE_KEY].includes(k)) return prevent(e);
  191. if (!enabled) return;
  192. if (ENABLE_RECOIL && /[1-7]/.test(k)) return prevent(e);
  193.  
  194. const m = keyMap[k];
  195. if (m) {
  196. prevent(e);
  197. if (m.t === 'b') {
  198. const btn = state.buttons[m.i];
  199. btn.pressed = btn.touched = false; btn.value = 0;
  200. } else {
  201. const ax = state.axisKey[m.a];
  202. m.v < 0 ? ax.neg = false : ax.pos = false;
  203. state.axes[m.a] = ax.neg ? -1 : ax.pos ? 1 : 0;
  204. }
  205. } else if (shouldCapture(k, e.code)) {
  206. prevent(e);
  207. }
  208. }
  209.  
  210. // --- Mouse Handlers ---
  211. function onMouseDown(e) {
  212. if (!enabled) return;
  213. const m = mouseMap[e.button]; if (!m) return;
  214. prevent(e);
  215. const btn = state.buttons[m.i];
  216. btn.pressed = btn.touched = true; btn.value = 1;
  217. }
  218. function onMouseUp(e) {
  219. if (!enabled) return;
  220. const m = mouseMap[e.button]; if (!m) return;
  221. prevent(e);
  222. const btn = state.buttons[m.i];
  223. btn.pressed = btn.touched = false; btn.value = 0;
  224. }
  225. function onMouseMove(e) {
  226. if (!enabled || !pointerLocked) return;
  227. prevent(e);
  228. state.dx += e.movementX || 0;
  229. state.dy += e.movementY || 0;
  230. }
  231.  
  232. // --- Pointer Lock ---
  233. function onPointerLockChange() {
  234. pointerLocked = (document.pointerLockElement === gameArea);
  235. console.log(pointerLocked ? '🔒 Pointer Locked' : '🔓 Pointer Unlocked');
  236. if (!pointerLocked) {
  237. state.axes[2] = state.axes[3] = 0;
  238. state.microAngle = 0;
  239. }
  240. }
  241. function requestLock() {
  242. gameArea?.requestPointerLock?.();
  243. }
  244.  
  245. // --- Toggle & Teardown ---
  246. function toggle() {
  247. enabled = !enabled;
  248. console.log(enabled ? '%cMapper ON' : '%cMapper OFF',
  249. 'font-weight:bold;color:' + (enabled ? 'lightgreen' : 'orange'));
  250. if (!enabled) {
  251. // reset controller state
  252. state.axes = [0,0,0,0];
  253. state.buttons.forEach(b=>{b.pressed=b.touched=false; b.value=0});
  254. state.axisKey = {0:{neg:false,pos:false},1:{neg:false,pos:false}};
  255. currentPreset = 'scar';
  256. if (pointerLocked) document.exitPointerLock();
  257. }
  258. }
  259.  
  260. function teardown() {
  261. enabled = false;
  262. clearInterval(stateInt);
  263. clearInterval(dispatchInt);
  264. window.removeEventListener('keydown', onKeyDown, true);
  265. window.removeEventListener('keyup', onKeyUp, true);
  266. gameArea.removeEventListener('mousedown', onMouseDown, true);
  267. gameArea.removeEventListener('mouseup', onMouseUp, true);
  268. gameArea.removeEventListener('mousemove', onMouseMove, true);
  269. gameArea.removeEventListener('click', requestLock);
  270. document.removeEventListener('pointerlockchange', onPointerLockChange);
  271. navigator.getGamepads = () => [];
  272. console.warn('%cKBM Mapper v10.7 TERMINATED – refresh to reload','color:red;font-weight:bold;');
  273. }
  274.  
  275. // --- Initialization ---
  276. (function init(){
  277. gameArea = document.getElementById('game-stream')
  278. || document.querySelector('video[playsinline]')
  279. || document.querySelector('video')
  280. || document.body;
  281. navigator.getGamepads = () => enabled ? [ makeGamepad() ] : [];
  282.  
  283. window.addEventListener('keydown', onKeyDown, true);
  284. window.addEventListener('keyup', onKeyUp, true);
  285. gameArea.addEventListener('mousedown', onMouseDown, true);
  286. gameArea.addEventListener('mouseup', onMouseUp, true);
  287. gameArea.addEventListener('mousemove', onMouseMove, true);
  288. gameArea.addEventListener('click', requestLock,false);
  289. document.addEventListener('pointerlockchange', onPointerLockChange,false);
  290.  
  291. stateInt = setInterval(updateState, POLL_MS);
  292. dispatchInt = setInterval(dispatchPad, DISPATCH_MS);
  293.  
  294. console.log(' KBM Aim Assist ACTIVE – click to lock pointer');
  295. console.log(' Press 1–7 to select recoil preset:', Object.keys(RECOIL_PRESETS).join(', '));
  296. })();
  297.  
  298. })();
  299.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement