Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoclicker patch for update changes to click attacks #379

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions enhancedautoclicker.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// @description Clicks through battles, with adjustable speed, and provides various insightful statistics. Also includes an automatic gym battler and automatic dungeon explorer with multiple pathfinding modes.
// @copyright https://github.com/Ephenia
// @license GPL-3.0 License
// @version 3.4.1
// @version 3.4.2

// @homepageURL https://github.com/Ephenia/Pokeclicker-Scripts/
// @supportURL https://github.com/Ephenia/Pokeclicker-Scripts/issues
Expand Down Expand Up @@ -443,30 +443,24 @@ class EnhancedAutoClicker {
// Set delay based on the autoclicker's tick rate
// (lower to give setInterval some wiggle room)
const delay = Math.min(Math.ceil(1000 / this.ticksPerSecond) - 10, 50);
Battle.clickAttackCached = 0;
Battle.clickAttackLastCached = 0;
Battle.clickAttack = function () {
// click attacks disabled and we already beat the starter
if (App.game.challenges.list.disableClickAttack.active() && player.regionStarters[GameConstants.Region.kanto]() != GameConstants.Starter.None) {
return;
}
const now = Date.now();
if (now - this.lastClickAttack < delay) {
if (this.lastClickAttack > now - delay) {
return;
}
if (!this.enemyPokemon()?.isAlive()) {
return;
}
this.lastClickAttack = now;
// Avoid recalculating damage 20 times per second
if (now - this.clickAttackLastCached > 1000) {
this.clickAttackCached = App.game.party.calculateClickAttack(true);
this.clickAttackLastCached = now;
}
// Don't autoclick more than needed for lethal
var clicks = Math.min(clickMultiplier, Math.ceil(this.enemyPokemon().health() / this.clickAttackCached));
const clickDamage = App.game.party.calculateClickAttack(true);
var clicks = Math.min(clickMultiplier, Math.ceil(this.enemyPokemon().health() / clickDamage));
GameHelper.incrementObservable(App.game.statistics.clickAttacks, clicks);
this.enemyPokemon().damage(this.clickAttackCached * clicks);
this.enemyPokemon().damage(clickDamage * clicks);
if (!this.enemyPokemon().isAlive()) {
this.defeatPokemon();
}
Expand Down