Skip to content

Commit

Permalink
Don't use raining gold on x00 levels and refactor
Browse files Browse the repository at this point in the history
Moved checks for raining gold rounds to a function and refactored old raining gold checks to use the function.
Updated raining gold round checks to be true when all of the following are true:
* level is greater than useGoldThreshold
* level is less than speedThreshold or level is a rainingRound
* level is NOT a wormhole round

Changed rainingRound to 10
Added wormholdRound value to control and set it to 100
  • Loading branch information
bluejv7 committed Jun 19, 2015
1 parent 4a1b8ec commit 39502fd
Showing 1 changed file with 40 additions and 12 deletions.
52 changes: 40 additions & 12 deletions autoPlay.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@
speedThreshold: 2000,
// Stop using offensive abilities shortly before rain/wormhole rounds.
rainingSafeRounds: 5,
rainingRounds: 100,
rainingRounds: 10,
timePerUpdate: 60000,
useSlowMode: false,
minsLeft: 60,
allowWormholeLevel: 180000,
wormholeRounds: 100,
githubVersion: SCRIPT_VERSION,
useAbilityChance: 0.03,
useLikeNewMinChance: 0.02,
Expand Down Expand Up @@ -382,6 +383,29 @@
}
}
}

function isGoldRainRound() {
var level = getGameLevel();
// Don't use gold rain below gold threshold
if (level < control.useGoldThreshold) {
return false;
}

// Don't use gold rain past the speedThreshold
if (level > control.speedThreshold) {
// ...and if level is not a raining round
if (level % control.rainingRounds !== 0) {
return false;
}
}

// Don't use gold rain on wormhole rounds
if (level % control.wormholeRounds === 0) {
return false;
}

return true;
}

function isNearEndGame() {
var cTime = new Date();
Expand Down Expand Up @@ -420,9 +444,7 @@
useTacticalNukeIfRelevant();
useCrippleMonsterIfRelevant();
useCrippleSpawnerIfRelevant();
if ((level < control.speedThreshold || level % control.rainingRounds === 0) && level > control.useGoldThreshold) {
useGoldRainIfRelevant();
}
useGoldRainIfRelevant();
useCrippleMonsterIfRelevant(level);
useReviveIfRelevant(level);
useMaxElementalDmgIfRelevant();
Expand Down Expand Up @@ -1077,7 +1099,9 @@

// Prevent attack abilities and items if up against a boss or treasure minion
var level = getGameLevel();
if (targetIsTreasure || (targetIsBoss && (level < control.speedThreshold || level % control.rainingRounds === 0))) {
if (targetIsTreasure) {
BOSS_DISABLED_ABILITIES.forEach(disableAbility);
} else if (targetIsBoss && (isGoldRainRound() || level % control.wormholeRounds === 0)) {
BOSS_DISABLED_ABILITIES.forEach(disableAbility);
} else {
BOSS_DISABLED_ABILITIES.forEach(enableAbility);
Expand Down Expand Up @@ -1155,7 +1179,7 @@
var enemy = s().GetEnemy(currentLane, i);
if (enemy) {
enemyCount++;
if (enemy.m_data.type === 0 || (level > control.speedThreshold && level % control.rainingRounds !== 0 && level % 10 === 0)) {
if (enemy.m_data.type === 0 || (!isGoldRainRound() && level % 10 === 0)) {
enemySpawnerExists = true;
}
}
Expand Down Expand Up @@ -1188,7 +1212,7 @@
var enemy = s().GetEnemy(currentLane, i);
if (enemy) {
enemyCount++;
if (enemy.m_data.type === 0 || (level > control.speedThreshold && level % control.rainingRounds !== 0 && level % 10 === 0)) {
if (enemy.m_data.type === 0 || (!isGoldRainRound() && level % 10 === 0)) {
enemySpawnerExists = true;
}
}
Expand Down Expand Up @@ -1235,7 +1259,7 @@
for (var i = 0; i < 4; i++) {
var enemy = s().GetEnemy(currentLane, i);
if (enemy) {
if (enemy.m_data.type === 0 || (level > control.speedThreshold && level % control.rainingRounds !== 0 && level % 10 === 0)) {
if (enemy.m_data.type === 0 || (!isGoldRainRound() && level % 10 === 0)) {
enemySpawnerExists = true;
enemySpawnerHealthPercent = enemy.m_flDisplayedHP / enemy.m_data.max_hp;
}
Expand Down Expand Up @@ -1286,6 +1310,10 @@
if (!canUseItem(ABILITIES.RAINING_GOLD)) {
return;
}

if (!isGoldRainRound()) {
return;
}

var enemy = s().GetEnemy(s().m_rgPlayerData.current_lane, s().m_rgPlayerData.target);
// check if current target is a boss, otherwise its not worth using the gold rain
Expand Down Expand Up @@ -1345,7 +1373,7 @@
function useWormholeIfRelevant() {
// Check the time before using wormhole.
var level = getGameLevel();
if (level % control.rainingRounds !== 0 && !wormHoleConstantUse) {
if (level % control.wormholeRounds !== 0 && !wormHoleConstantUse) {
return;
}

Expand All @@ -1360,7 +1388,7 @@
function useLikeNew() {
// Check the time before using like new.
var level = getGameLevel();
if (level % control.rainingRounds !== 0) {
if (level % control.wormholeRounds !== 0) {
return;
}

Expand All @@ -1373,7 +1401,7 @@

// Make sure that we're still in the boss round when we actually use it.
var level = getGameLevel();
if (level % control.rainingRounds === 0) {
if (level % control.wormholeRounds === 0) {
if (triggerAbility(ABILITIES.LIKE_NEW)) {
advLog('We can actually use Like New semi-reliably! Cooldowns-b-gone.', 2);
}
Expand Down Expand Up @@ -1820,7 +1848,7 @@
}

//During baws round fc
if (level % control.rainingRounds == 0) {
if (level % control.wormholeRounds == 0) {
if (predictLastWormholesUpdate !== wormholesNow) {
predictTicks++;
predictJumps += wormholesNow;
Expand Down

0 comments on commit 39502fd

Please sign in to comment.