Lucibear

Untitled

Oct 3rd, 2020
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.01 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Pokeclicker
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.8
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://www.pokeclicker.com/
  8. // @grant none
  9. // @run-at document-start
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. var switches = {
  15. "Click":true,
  16. "Hatch":true,
  17. "Dungeon":true,
  18. "Gym":false,
  19. "Repeat":false,
  20. "Bomb":true,
  21. "Items":false
  22. };
  23. var toggles = {
  24. "speedBall":false
  25. }
  26. var dungeonCoord = {
  27. "x":0,
  28. "y":5
  29. };
  30. var targetEggs = 16;
  31.  
  32. function replaceStart(){
  33. {
  34. if (!App.debug) {
  35. Object.freeze(GameConstants);
  36. }
  37. Preload.load(App.debug).then(() => {
  38. ko.options.deferUpdates = true;
  39. console.log(`[${GameConstants.formatDate(new Date())}] %cLoading Game Data..`, 'color:#8e44ad;font-weight:900;');
  40. // Needs to be loaded first so save data can be updated (specifically "player" data)
  41. const update = new Update();
  42. UndergroundItem.initialize();
  43. player = Save.load();
  44. Preload.hideSplashScreen();
  45. App.game = new Game(update, new Breeding(), new Pokeballs(), new Wallet(), new KeyItems(), new BadgeCase(), new OakItems([20, 50, 100]), new Party(), new Shards(), new Farming(), new LogBook(), new RedeemableCodes(), new Statistics(), new Quests(), new SpecialEvents(), new Discord());
  46. for(let i = 0; i < (targetEggs - 4);i++){
  47. App.game.breeding.defaults.eggList.push(ko.observable(new Egg()));
  48. }
  49. console.log(`[${GameConstants.formatDate(new Date())}] %cGame loaded`, 'color:#8e44ad;font-weight:900;');
  50. Notifier.notify({ message: 'Game loaded', type: GameConstants.NotificationOption.info });
  51. GameController.bindToolTips();
  52. GameController.addKeyListeners();
  53. PokedexHelper.populateTypeFilters();
  54. PokedexHelper.updateList();
  55. App.game.initialize();
  56. ko.applyBindings(App.game);
  57. GameController.applyRouteBindings();
  58. Preload.hideSplashScreen();
  59. App.game.start();
  60. });
  61. }
  62. }
  63.  
  64. function setButtons(){
  65. for(let key of Object.keys(switches)){
  66. if (!switches[key]) {
  67. document.getElementById("auto" + key).style.color = 'red';
  68. switches[key] = false;
  69. } else if (switches[key]) {
  70. document.getElementById("auto" + key).style.color = 'black';
  71. switches[key] = true;
  72. }
  73. }
  74. }
  75. function autoClicker(){
  76. if(!switches.Click){return;}
  77. if(App.game.gameState == 2){
  78. Battle.clickAttack();
  79. }
  80. else if(App.game.gameState == 3){
  81. GymBattle.clickAttack();
  82. }
  83. }
  84. function moveTile(){
  85. if(DungeonBattle.catching()){
  86. return;
  87. }
  88. //dungeonCoord = DungeonRunner.map.playerPosition();
  89.  
  90. //console.log("moving to " + dungeonCoord.x + "," + dungeonCoord.y);
  91. DungeonRunner.map.moveToCoordinates(dungeonCoord.x, dungeonCoord.y);
  92. if(dungeonCoord.y <= 0){
  93. dungeonCoord.x = ++dungeonCoord.x % DungeonRunner.map.size;
  94. dungeonCoord.y = DungeonRunner.map.size-1;
  95. }
  96. else{
  97. dungeonCoord.y--;
  98. }
  99. }
  100. function autoGym(){
  101. if(!switches.Gym){return;}
  102. if(App.game.gameState == 6 && player.town().gym()){
  103. GymRunner.startGym(player.town().gym());
  104. }
  105. }
  106. function autoDungeon(){
  107. if(!switches.Dungeon){return;}
  108. if(switches.Repeat && App.game.gameState == 6 && player.town().dungeon()){
  109. DungeonRunner.dungeon = player.town().dungeon();
  110. if(DungeonRunner.hasEnoughTokens()){
  111. DungeonRunner.initializeDungeon(player.town().dungeon());
  112. dungeonCoord = {x:0,y:DungeonRunner.map.size-1};
  113. // dungeonCoord.x = Math.floor(DungeonRunner.map.size/2);
  114. // dungeonCoord.y = DungeonRunner.map.size-1;
  115. }
  116. }
  117.  
  118. else if(App.game.gameState != 4){
  119. // dungeonCoord.x = Math.floor(DungeonRunner.map.size/2);
  120. // dungeonCoord.y = DungeonRunner.map.size-1;
  121. return;
  122. }
  123. else if (DungeonRunner.map.currentTile().type() == 0){ //empty
  124. moveTile();
  125. }
  126. else if (DungeonRunner.map.currentTile().type() == 1){ //Enemy
  127. DungeonBattle.clickAttack();
  128. if(DungeonRunner.pokemonDefeated){
  129. moveTile();
  130. }
  131. }
  132. else if (DungeonRunner.map.currentTile().type() == 2){ //Chest
  133. DungeonRunner.openChest();
  134. moveTile();
  135. }
  136. else if (DungeonRunner.map.currentTile().type() == 3){ //Boss
  137. if(!DungeonRunner.fightingBoss()){
  138. DungeonRunner.startBossFight();
  139. dungeonCoord = {x:0,y:DungeonRunner.map.size-1};
  140. }
  141. DungeonBattle.clickAttack();
  142. }
  143. }
  144. var eggList = [
  145. "Dragon_egg",
  146. "Electric_egg",
  147. "Fighting_egg",
  148. "Fire_egg",
  149. "Grass_egg",
  150. "Mystery_egg",
  151. "Water_egg"
  152. ]
  153. var battleItems = [
  154. "xAttack",
  155. "xClick",
  156. "Lucky_egg",
  157. "Token_collector",
  158. "Item_magnet",
  159. "Lucky_incense"
  160. ]
  161. function useEggs(itemList){
  162. for(let egg of itemList){
  163. if(player.itemList[egg]() > 0 && !ItemList[egg].getCaughtStatus()){
  164. ItemHandler.useItem(egg);
  165. return;
  166. }
  167. }
  168. }
  169. function autoBreeder() {
  170. if(!switches.Hatch){return;}
  171. for(let s = 0; s < App.game.breeding.eggSlots; s ++){
  172. if(App.game.breeding.eggList[s]().canHatch()){
  173. App.game.breeding.hatchPokemonEgg(s);
  174. }
  175. }
  176. if(App.game.breeding.hasFreeEggSlot()){
  177. useEggs(eggList);
  178. }
  179. let ind = 0;
  180. let offset = 0;
  181. let hatcheryList;
  182. if(App.game.breeding.hasFreeEggSlot()){
  183. hatcheryList = BreedingController.breedableList().filter(p => !p.breeding);
  184. }
  185. while(App.game.breeding.hasFreeEggSlot() && BreedingController.breedableList().length > ind){
  186. App.game.breeding.gainPokemonEgg(hatcheryList.shift());
  187. ind++;
  188. }
  189. }
  190. function autoFarm(){
  191. let count = App.game.farming.unlockedPlotCount();
  192. for(let p = 0;p < count; p++){
  193. if(App.game.farming.plotList[p].timeLeft <= 0 && App.game.farming.plotList[p].isUnlocked){
  194. App.game.farming.harvest(p,true);
  195. App.game.farming.plant(p,FarmController.selectedBerry);
  196. }
  197. }
  198. }
  199. function autoMine(){
  200. if(switches.Bomb && Underground.energy >= Underground.getMaxEnergy() - Underground.getEnergyGain()){
  201. Mine.bomb(10)
  202. }
  203. }
  204. function autoItems(){
  205. if(!switches.Items){return;}
  206. for(let item of battleItems){
  207. if(player.itemList[item]() > 0){
  208. ItemHandler.useItem(item);
  209. }
  210. }
  211. }
  212. window.toggleSetting = function(settingName){
  213. if (switches[settingName]) {
  214. document.getElementById("auto" + settingName).style.color = 'red';
  215. switches[settingName] = false;
  216. } else if (!switches[settingName]) {
  217. document.getElementById("auto" + settingName).style.color = 'black';
  218. switches[settingName] = true;
  219. }
  220. }
  221. window.speedBall = function(){
  222. if (toggles.speedBall) {
  223. document.getElementById("speedBall").style.color = 'red';
  224. toggles.speedBall = false;
  225. App.game.pokeballs.pokeballCatchTime = [1250, 1000, 750, 500];
  226. } else if (!toggles.speedBall) {
  227. document.getElementById("speedBall").style.color = 'black';
  228. toggles.speedBall = true;
  229. App.game.pokeballs.pokeballCatchTime = [125, 100, 75, 50]
  230. }
  231. }
  232. var delay = 0;
  233. function automate(){
  234. delay = ++delay % 100;
  235. if(delay % 50 == 0){
  236. autoMine();
  237. autoFarm();
  238. }
  239. if(delay % 50 == 0){
  240. autoBreeder();
  241. }
  242. if(delay % 2 == 0){
  243. autoClicker();
  244. autoDungeon()
  245. }
  246. autoGym();;
  247. autoItems();
  248. }
  249. function addInterface(){
  250. window.window.$("#battleContainer").append('<button id="autoClick" style="color:red" onclick="toggleSetting(\'Click\')">AutoClick</button>');
  251. window.window.$("#breedingDisplay").append('<button id="autoHatch" style="color:red" onclick="toggleSetting(\'Hatch\')">AutoHatch</button>');
  252. var centerbuttons = '<div id="centerbuttons" class="row" margin:"auto">' +
  253. '<button id="autoRepeat" style="color:red" onclick="toggleSetting(\'Repeat\')">Repeat Dungeon</button>' +
  254. '<button id="autoDungeon" style="color:red" onclick="toggleSetting(\'Dungeon\',\'autoDungeon\')">Auto Dungeon</button>' +
  255. '<button id="autoGym" style="color:red" onclick="toggleSetting(\'Gym\')">Auto Gym</button>' +
  256. '<button id="autoBomb" style="color:black" onclick="toggleSetting(\'Bomb\')">Auto Bomb</button>' +
  257. '<button id="autoItems" style="color:black" onclick="toggleSetting(\'Items\')">Auto Items</button>' +
  258. '<button id="speedBall" style="color:red" onclick="speedBall()">SpeedBall(cheaty)</button>' +
  259. '</div>';
  260. window.window.$("#middle-column").append(centerbuttons);
  261.  
  262. setButtons();
  263. setInterval(automate,10);
  264. }
  265. window.checkLoad = function(){
  266. if(App && App.start != replaceStart){
  267. App.start= replaceStart;
  268. }
  269. if(!App.game || !App.game.farming){
  270. return;
  271. }
  272. clearInterval(cl);
  273.  
  274. window.window.$("#battleContainer").append('<button id="autoClick" style="color:red" onclick="toggleSetting(\'Click\')">AutoClick</button>');
  275.  
  276. window.window.$("#breedingDisplay").append(
  277. '<button id="autoHatch" style="color:red" onclick="toggleSetting(\'Hatch\')">AutoHatch</button>');
  278.  
  279. var centerbuttons = '<div id="centerbuttons" class="row" margin:"auto">' +
  280. '<button id="autoRepeat" style="color:red" onclick="toggleSetting(\'Repeat\')">Repeat Dungeon</button>' +
  281. '<button id="autoDungeon" style="color:red" onclick="toggleSetting(\'Dungeon\',\'autoDungeon\')">Auto Dungeon</button>' +
  282. '<button id="autoGym" style="color:red" onclick="toggleSetting(\'Gym\')">Auto Gym</button>' +
  283. '<button id="autoBomb" style="color:black" onclick="toggleSetting(\'Bomb\')">Auto Bomb</button>' +
  284. '<button id="autoItems" style="color:black" onclick="toggleSetting(\'Items\')">Auto Items</button>' +
  285. '<button id="speedBall" style="color:red" onclick="speedBall()">SpeedBall(cheaty)</button>' +
  286. '</div>';
  287. window.window.$("#middle-column").append(centerbuttons);
  288. Array.from(document.getElementsByClassName('eggSlot')).forEach(e => e.className = "col-3 col-md-3 p-0 eggSlot")
  289.  
  290. setButtons();
  291. setInterval(automate,10);
  292. }
  293. window.cl = setInterval(checkLoad,10);
  294.  
  295. // document.querySelector("#middle-column").innerHTML += ('<button id="autoDungeon" style="color:red" onclick="toggleDungeon()">AutoDungeon</button>');
  296. // document.querySelector("#middle-column").innerHTML += ('<button id="autoDungeon" style="color:red" onclick="toggleDungeon()">AutoDungeon</button>');
  297. })();
Advertisement
Add Comment
Please, Sign In to add comment