Gobattle.io Noclip and Fly

Enable noclip and flying in Gobattle.io

当前为 2024-10-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Gobattle.io Noclip and Fly
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Enable noclip and flying in Gobattle.io
  6. // @author Toluwa Oyerinde
  7. // @match https://gobattle.io/*
  8. // @grant
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. let isNoclipEnabled = false; // Noclip state
  16. let isFlying = false; // Fly state
  17. let player; // Reference to the player
  18. const speed = 5; // Speed of flying
  19.  
  20. // Get the player object from the game
  21. function init() {
  22. // Ensure the game context is available
  23. player = window.gobattle.player;
  24. if (!player) {
  25. console.error("Player object not found.");
  26. return;
  27. }
  28. console.log("Noclip and Flying initialized.");
  29. }
  30.  
  31. // Toggle Noclip
  32. function toggleNoclip() {
  33. isNoclipEnabled = !isNoclipEnabled;
  34. if (isNoclipEnabled) {
  35. console.log("Noclip enabled.");
  36. } else {
  37. console.log("Noclip disabled.");
  38. }
  39. }
  40.  
  41. // Toggle Fly
  42. function toggleFly() {
  43. isFlying = !isFlying;
  44. if (isFlying) {
  45. console.log("Flying enabled.");
  46. } else {
  47. console.log("Flying disabled.");
  48. }
  49. }
  50.  
  51. // Noclip logic
  52. function noclip() {
  53. if (isNoclipEnabled) {
  54. // Manipulate the player's collision properties
  55. player.transform.position.x += 0; // Neutralize collision
  56. player.transform.position.y += 0; // Neutralize gravity
  57. player.transform.position.z += 0; // Neutralize collision
  58. requestAnimationFrame(noclip); // Continue noclip
  59. }
  60. }
  61.  
  62. // Flying logic
  63. function fly() {
  64. if (isFlying) {
  65. const movement = new THREE.Vector3(0, 0, 0); // Create a movement vector
  66.  
  67. if (isKeyPressed('W')) movement.z -= speed; // Move forward
  68. if (isKeyPressed('S')) movement.z += speed; // Move backward
  69. if (isKeyPressed('A')) movement.x -= speed; // Move left
  70. if (isKeyPressed('D')) movement.x += speed; // Move right
  71. if (isKeyPressed('Space')) movement.y += speed; // Move up
  72. if (isKeyPressed('Shift')) movement.y -= speed; // Move down
  73.  
  74. // Apply movement to player position
  75. player.transform.position.add(movement);
  76. requestAnimationFrame(fly); // Continue flying
  77. }
  78. }
  79.  
  80. // Check if a key is pressed
  81. function isKeyPressed(key) {
  82. return window.input.isKeyPressed(key);
  83. }
  84.  
  85. // Key event listener
  86. window.addEventListener('keydown', (event) => {
  87. if (event.key === 'F') { // Toggle noclip with F
  88. toggleNoclip();
  89. }
  90. if (event.key === 'G') { // Toggle flying with G
  91. toggleFly();
  92. }
  93. });
  94.  
  95. // Main loop
  96. function gameLoop() {
  97. if (isFlying) {
  98. fly();
  99. }
  100. if (isNoclipEnabled) {
  101. noclip();
  102. }
  103. requestAnimationFrame(gameLoop); // Repeat the loop
  104. }
  105.  
  106. // Initialize script
  107. init();
  108. gameLoop(); // Start the main loop
  109. })();