Ephenia / Pokeclicker-Scripts

Various scripts & enhancements for the game Pokéclicker.
https://github.com/Ephenia/Pokeclicker-Scripts
GNU General Public License v3.0
194 stars 261 forks source link

Is it possible to activate the auto gym or auto dungeon in another script? #129

Open Sorrow81 opened 2 years ago

Sorrow81 commented 2 years ago

I would like to add in the auto quest complete the ability to beat trainers, dungeons etc.

I'm currently copying the parts I'm interested in but it's not ideal.

function completeDefeatDungeonQuest(dungeonQuest) {
  if (!questLocationInProgress) {
    if (player.town().name != dungeonQuest.dungeon && player.region != dungeonQuest.region) {
      let firstRoute = Routes.getRoutesByRegion(dungeonQuest.region);
      MapHelper.moveToRoute(firstRoute.routeName, dungeonQuest.region);
      MapHelper.moveToTown(dungeonQuest.dungeon);
    }

    if (player.town().name == dungeonQuest.dungeon) {
      questLocationInProgress = true;
      questLocationLoop = setInterval(function() {
        if (!dungeonQuest.notified) {
          if (player.town().hasOwnProperty("dungeon") == true && player.town().dungeon !== undefined) {
            var getTokens = App.game.wallet.currencies[GameConstants.Currency.dungeonToken]();
            var dungeonCost = player.town().dungeon.tokenCost;
            if (MapHelper.calculateTownCssClass(player.town().name) != "currentLocation") {
              MapHelper.moveToTown(player.town().name)
            }
            //Don't think this condition is ever possible
            /*if (player.region != player.town().region) {
                player.region = player.town().region
            }*/
            if (getTokens >= dungeonCost && App.game.gameState != GameConstants.GameState.dungeon) {
              DungeonRunner.initializeDungeon(player.town().dungeon)
            }
            if (App.game.gameState === GameConstants.GameState.dungeon) {
              var dungeonBoard = DungeonRunner.map.board();
              //The boss can be found at any time
              if (foundBoss == false) {
                bossCoords = scan(dungeonBoard)
              }
              //Wander around until we can move to the boss tile
              //Pathfinding should be implemented here, A* looks like the best algorithm
              else if (foundBoss == true) {
                wander(dungeonBoard, bossCoords)
              }
            }
          }
        } else {
          questLocationInProgress = false;
          clearInterval(questLocationLoop);
        }
      }, 50);
    }
  }
}

function scan(dungeonBoard) {
//...
}

function wander(dungeonBoard) {
//...
}

Is it possible to do something like this :

function completeDefeatDungeonQuest(dungeonQuest) {
  if (!questLocationInProgress) {
    if (player.town().name != dungeonQuest.dungeon && player.region != dungeonQuest.region) {
      let firstRoute = Routes.getRoutesByRegion(dungeonQuest.region);
      MapHelper.moveToRoute(firstRoute.routeName, dungeonQuest.region);
      MapHelper.moveToTown(dungeonQuest.dungeon);
    }

    if (player.town().name == dungeonQuest.dungeon) {
      if (dungeonState == "OFF") {
        toggleAutoDungeon()
      }
      questLocationInProgress = true;
      questLocationLoop = setInterval(function() {
        if (dungeonQuest.notified) {
          if (dungeonState == "ON") {
            toggleAutoDungeon()
          }
          questLocationInProgress = false;
          clearInterval(questLocationLoop);
        }
      }, 50);
    }
  }
}

I think it's possible, but I couldn't find what I was looking for.

Sorrow81 commented 2 years ago

A javascript click on the button is enough