Lucibear

Untitled

Sep 23rd, 2020
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.74 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 = 8;
  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. break;
  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. for(let s = 0; s < App.game.breeding.eggSlots; s ++){
  177. if(!App.game.breeding.hasFreeEggSlot()){
  178. break;
  179. }
  180. else{
  181. useEggs(eggList);
  182. if(BreedingController.breedableList().length > 0 && App.game.breeding.hasFreeEggSlot()){
  183. App.game.breeding.gainPokemonEgg(BreedingController.breedableList()[0]);
  184. break;
  185. }
  186. }
  187. }
  188. }
  189. function autoFarm(){
  190. let count = App.game.farming.unlockedPlotCount();
  191. for(let p = 0;p < count; p++){
  192. if(App.game.farming.plotList[p].timeLeft <= 0 && App.game.farming.plotList[p].isUnlocked){
  193. App.game.farming.harvest(p,true);
  194. App.game.farming.plant(p,FarmController.selectedBerry);
  195. }
  196. }
  197. }
  198. function autoMine(){
  199. if(switches.Bomb && Underground.energy >= Underground.getMaxEnergy() - Underground.getEnergyGain()){
  200. Mine.bomb(10)
  201. }
  202. }
  203. function autoItems(){
  204. if(!switches.Items){return;}
  205. for(let item of battleItems){
  206. if(player.itemList[item]() > 0){
  207. ItemHandler.useItem(item);
  208. }
  209. }
  210. }
  211. window.toggleSetting = function(settingName){
  212. if (switches[settingName]) {
  213. document.getElementById("auto" + settingName).style.color = 'red';
  214. switches[settingName] = false;
  215. } else if (!switches[settingName]) {
  216. document.getElementById("auto" + settingName).style.color = 'black';
  217. switches[settingName] = true;
  218. }
  219. }
  220. window.speedBall = function(){
  221. if (toggles.speedBall) {
  222. document.getElementById("speedBall").style.color = 'red';
  223. toggles.speedBall = false;
  224. App.game.pokeballs.pokeballCatchTime = [1250, 1000, 750, 500];
  225. } else if (!toggles.speedBall) {
  226. document.getElementById("speedBall").style.color = 'black';
  227. toggles.speedBall = true;
  228. App.game.pokeballs.pokeballCatchTime = [125, 100, 75, 50]
  229. }
  230. }
  231. var delay = 0;
  232. function automate(){
  233. delay = ++delay % 100;
  234. if(delay % 50 == 0){
  235. autoMine();
  236. autoFarm();
  237. }
  238. if(delay % 20 == 0){
  239. autoBreeder();
  240. }
  241. autoGym();
  242. autoClicker();
  243. autoDungeon();
  244. autoItems();
  245. }
  246. function addInterface(){
  247. window.window.$("#battleContainer").append('<button id="autoClick" style="color:red" onclick="toggleSetting(\'Click\')">AutoClick</button>');
  248. window.window.$("#breedingDisplay").append('<button id="autoHatch" style="color:red" onclick="toggleSetting(\'Hatch\')">AutoHatch</button>');
  249. var centerbuttons = '<div id="centerbuttons" class="row" margin:"auto">' +
  250. '<button id="autoRepeat" style="color:red" onclick="toggleSetting(\'Repeat\')">Repeat Dungeon</button>' +
  251. '<button id="autoDungeon" style="color:red" onclick="toggleSetting(\'Dungeon\',\'autoDungeon\')">Auto Dungeon</button>' +
  252. '<button id="autoGym" style="color:red" onclick="toggleSetting(\'Gym\')">Auto Gym</button>' +
  253. '<button id="autoBomb" style="color:black" onclick="toggleSetting(\'Bomb\')">Auto Bomb</button>' +
  254. '<button id="autoItems" style="color:black" onclick="toggleSetting(\'Items\')">Auto Items</button>' +
  255. '<button id="speedBall" style="color:red" onclick="speedBall()">SpeedBall(cheaty)</button>' +
  256. '</div>';
  257. window.window.$("#middle-column").append(centerbuttons);
  258.  
  259. setButtons();
  260. setInterval(automate,10);
  261. }
  262. window.checkLoad = function(){
  263. if(!App.game || !App.game.farming){
  264. return;
  265. }
  266. clearInterval(cl);
  267.  
  268. window.window.$("#battleContainer").append('<button id="autoClick" style="color:red" onclick="toggleSetting(\'Click\')">AutoClick</button>');
  269.  
  270. window.window.$("#breedingDisplay").append(
  271. '<button id="autoHatch" style="color:red" onclick="toggleSetting(\'Hatch\')">AutoHatch</button>');
  272.  
  273. var centerbuttons = '<div id="centerbuttons" class="row" margin:"auto">' +
  274. '<button id="autoRepeat" style="color:red" onclick="toggleSetting(\'Repeat\')">Repeat Dungeon</button>' +
  275. '<button id="autoDungeon" style="color:red" onclick="toggleSetting(\'Dungeon\',\'autoDungeon\')">Auto Dungeon</button>' +
  276. '<button id="autoGym" style="color:red" onclick="toggleSetting(\'Gym\')">Auto Gym</button>' +
  277. '<button id="autoBomb" style="color:black" onclick="toggleSetting(\'Bomb\')">Auto Bomb</button>' +
  278. '<button id="autoItems" style="color:black" onclick="toggleSetting(\'Items\')">Auto Items</button>' +
  279. '<button id="speedBall" style="color:red" onclick="speedBall()">SpeedBall(cheaty)</button>' +
  280. '</div>';
  281. window.window.$("#middle-column").append(centerbuttons);
  282.  
  283. setButtons();
  284. setInterval(automate,10);
  285. }
  286. window.cl = setInterval(checkLoad,10);
  287. App.start= replaceStart;
  288.  
  289. // document.querySelector("#middle-column").innerHTML += ('<button id="autoDungeon" style="color:red" onclick="toggleDungeon()">AutoDungeon</button>');
  290. // document.querySelector("#middle-column").innerHTML += ('<button id="autoDungeon" style="color:red" onclick="toggleDungeon()">AutoDungeon</button>');
  291. })();
Advertisement
Add Comment
Please, Sign In to add comment