Lucibear

Untitled

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