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
jvchen committed Jun 19, 2015
1 parent 2861af5 commit 404d4c2
Showing 1 changed file with 71 additions and 46 deletions.
117 changes: 71 additions & 46 deletions autoPlay.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,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 @@ -385,6 +386,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();
var cHours = cTime.getUTCHours();
Expand Down Expand Up @@ -421,9 +445,7 @@
useTacticalNukeIfRelevant();
useCrippleMonsterIfRelevant();
useCrippleSpawnerIfRelevant();
if ((level < control.speedThreshold || level % control.rainingRounds === 0) && level > control.useGoldThreshold) {
useGoldRainIfRelevant();
}
useGoldRainIfRelevant();
useCrippleMonsterIfRelevant(level);
useReviveIfRelevant(level);
useMaxElementalDmgIfRelevant();
Expand All @@ -434,7 +456,7 @@
lastLevel = level;
refreshPlayerData();
}

// This belongs here so we can update the header during boss fights
updateLevelInfoTitle(level);

Expand Down Expand Up @@ -539,9 +561,9 @@
w.$J('.name', ele).text( rgEntry.actor_name );
w.$J('.ability', ele).text( this.m_Game.m_rgTuningData.abilities[ rgEntry.ability ].name + " on level " + getGameLevel());
w.$J('img', ele).attr( 'src', w.g_rgIconMap['ability_' + rgEntry.ability].icon );

w.$J(ele).v_tooltip({tooltipClass: 'ta_tooltip', location: 'top'});

this.m_eleUpdateLogContainer[0].insertBefore(ele[0], this.m_eleUpdateLogContainer[0].firstChild);
advLog(rgEntry.actor_name + " used " + this.m_Game.m_rgTuningData.abilities[ rgEntry.ability ].name + " on level " + getGameLevel(), 1);
w.$J('.name', ele).attr( "style", "color: red; font-weight: bold;" );
Expand All @@ -551,9 +573,9 @@
w.$J('.ability', ele).text( this.m_Game.m_rgTuningData.abilities[ rgEntry.ability ].name + " on level " + getGameLevel());
w.$J('img', ele).attr( 'src', w.g_rgIconMap['ability_' + rgEntry.ability].icon );
w.$J('.name', ele).attr( "style", "color: yellow" );

w.$J(ele).v_tooltip({tooltipClass: 'ta_tooltip', location: 'top'});

this.m_eleUpdateLogContainer[0].insertBefore(ele[0], this.m_eleUpdateLogContainer[0].firstChild);
}
} else {
Expand Down Expand Up @@ -1063,7 +1085,6 @@
}
}


// go to the chosen lane
if (targetFound) {
if (s().m_nExpectedLane != lowLane) {
Expand All @@ -1079,7 +1100,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 @@ -1157,7 +1180,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 @@ -1190,7 +1213,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 @@ -1237,7 +1260,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 @@ -1289,6 +1312,10 @@
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
if (enemy && enemy.m_data.type == ENEMY_TYPE.BOSS) {
Expand Down Expand Up @@ -1332,7 +1359,6 @@
}
}


function useMaxElementalDmgIfRelevant() {
// Check if Max Elemental Damage is purchased
if (isAbilityActive(ABILITIES.MAX_ELEMENTAL_DAMAGE) || Math.random() > control.useAbilityChance) {
Expand All @@ -1347,7 +1373,7 @@
function useWormholeIfRelevant() {
// Check the time before using wormhole.
var level = getGameLevel();
if (level % control.rainingRounds !== 0) {
if (level % control.wormholeRounds !== 0) {
return;
}
// Check if Wormhole is purchased
Expand Down Expand Up @@ -1387,7 +1413,7 @@
function useLikeNew() {
// 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 (tryUsingItem(ABILITIES.LIKE_NEW)) {
advLog('We can actually use Like New semi-reliably! Cooldowns-b-gone.', 2);
//canUseLikeNew = true;
Expand Down Expand Up @@ -1820,36 +1846,36 @@
function getGameLevel() {
return s().m_rgGameData.level + 1;
}

//I'm sorry of the way I name things. This function predicts jumps on a warp boss level, returns the value.
function estimateJumps() {
var level = getGameLevel();
var wormholesNow = 0;
//Gather total wormholes active.
for (var i = 0; i <= 2; i++) {
//advLog('L' + i + ':' + g_Minigame.m_CurrentScene.m_rgLaneData[i].abilities[26], 1);
if (typeof g_Minigame.m_CurrentScene.m_rgLaneData[i].abilities[26] !== 'undefined') {
wormholesNow += g_Minigame.m_CurrentScene.m_rgLaneData[i].abilities[26];
}
}
//During baws round fc
if (level % control.rainingRounds == 0) {
if (predictLastWormholesUpdate !== wormholesNow) {
predictTicks++;
predictJumps += wormholesNow;
predictLastWormholesUpdate = wormholesNow;
}
} else {
predictTicks = 0;
predictJumps = 0;
predictLastWormholesUpdate = 0;
return 0;
}
return predictJumps / predictTicks * (s().m_rgGameData.timestamp - s().m_rgGameData.timestamp_level_start);
//advLog('PT:' + predictTicks + ' PJ:' + predictJumps + ' PLWU:' + predictLastWormholesUpdate, 1);
var level = getGameLevel();
var wormholesNow = 0;

//Gather total wormholes active.
for (var i = 0; i <= 2; i++) {
//advLog('L' + i + ':' + g_Minigame.m_CurrentScene.m_rgLaneData[i].abilities[26], 1);
if (typeof g_Minigame.m_CurrentScene.m_rgLaneData[i].abilities[26] !== 'undefined') {
wormholesNow += g_Minigame.m_CurrentScene.m_rgLaneData[i].abilities[26];
}
}

//During baws round fc
if (level % control.wormholeRounds == 0) {
if (predictLastWormholesUpdate !== wormholesNow) {
predictTicks++;
predictJumps += wormholesNow;
predictLastWormholesUpdate = wormholesNow;
}
} else {
predictTicks = 0;
predictJumps = 0;
predictLastWormholesUpdate = 0;
return 0;
}

return predictJumps / predictTicks * (s().m_rgGameData.timestamp - s().m_rgGameData.timestamp_level_start);
//advLog('PT:' + predictTicks + ' PJ:' + predictJumps + ' PLWU:' + predictLastWormholesUpdate, 1);
}

/** Check periodicaly if the welcome panel is visible
Expand Down Expand Up @@ -1914,5 +1940,4 @@
};
}, false);


}(window));

0 comments on commit 404d4c2

Please sign in to comment.