Skip to content
This repository has been archived by the owner on Jul 5, 2018. It is now read-only.

Commit

Permalink
[Implements #74] Avoid bosses near level 25 (#76) + fix heal
Browse files Browse the repository at this point in the history
* [Implements #74] Avoid bosses near level 25

Avoid bosses if you're almost level 25 so you can get your remaining level-based items.
It'll close #74.

* Fix heal ability during boss battles

With the latest change to try avoiding to use heal instantly at the start when it's useless, it entered in a never used state, rip.
  • Loading branch information
Harest authored Jul 1, 2018
1 parent 4b98615 commit 952af14
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions idle.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var boss_options = {
"last_heal": undefined
}
var current_game_is_boss = false; // State if we're entering / in a boss battle or not
var avoid_boss = false; // We'll set it to true if you're almost level 25 so you can get your remaining level-based items.

class BotGUI {
constructor(state) {
Expand Down Expand Up @@ -357,12 +358,19 @@ var INJECT_report_boss_damage = function() {
results.response.boss_status.boss_players.forEach( function(player) {
if (player.accountid == account_id) {
if (player.hp > 0) {
gui.updateTask("In boss battle. Boss HP left: " + results.response.boss_status.boss_hp + ". EXP earned: " + player.xp_earned + ". HP left: " + player.hp);
if ((parseInt(gPlayerInfo.score) + parseInt(player.xp_earned)) >= 26390000) {
avoid_boss = true;
gui.updateTask("You're very close to reach level 25. Exiting boss fight to prevent you to not get level-based items.");
end_game();
} else {
gui.updateTask("In boss battle. Boss HP left: " + results.response.boss_status.boss_hp + ". EXP earned: " + player.xp_earned + ". HP left: " + player.hp);
}
} else {
gui.updateTask("You died, ending boss fight. Boss HP left: " + results.response.boss_status.boss_hp + ". EXP earned: " + player.xp_earned);
end_game();
}
boss_options.last_heal = (player.time_last_heal !== undefined) ? player.time_last_heal : undefined;
if (player.time_last_heal !== undefined)
boss_options.last_heal = player.time_last_heal;
}
});
gui.progressbar.SetValue((results.response.boss_status.boss_max_hp - results.response.boss_status.boss_hp) / results.response.boss_status.boss_max_hp);
Expand Down Expand Up @@ -390,7 +398,7 @@ var INJECT_report_boss_damage = function() {
var damageTaken = 0;
var now = (new Date().getTime()) / 1000;
if (boss_options.last_heal === undefined)
boss_options.last_heal = now;
boss_options.last_heal = now - Math.floor(Math.random() * 40);
var healDiff = now - boss_options.last_heal;
var useHealing = (healDiff >= 120) ? 1 : 0;
gServer.ReportBossDamage(damageDone, damageTaken, useHealing, success, error);
Expand Down Expand Up @@ -476,6 +484,9 @@ var INJECT_end_round = function(attempt_no) {
gui.updateExp(data.response.new_score + " / " + data.response.next_level_score);
gui.updateEstimatedTime(calculateTimeToNextLevel());
gui.updateZone("None");

// Avoid bosses if we're near level 25
avoid_boss = (gPlayerInfo.score >= 26390000 && gPlayerInfo.score < 26400000);

// Restart the round if we have that variable set
if(loop_rounds) {
Expand Down Expand Up @@ -625,7 +636,7 @@ function GetBestZone() {
for (var idx = 0; idx < window.gGame.m_State.m_Grid.m_Tiles.length; idx++) {
var zone = window.gGame.m_State.m_Grid.m_Tiles[idx].Info;
if (!zone.captured && zone.progress > 0) {
if (zone.boss) {
if (zone.boss && !avoid_boss) {
console.log("Zone " + idx + " with boss. Switching to it.");
return [idx, zone.boss];
}
Expand Down Expand Up @@ -698,9 +709,9 @@ function GetBestPlanet() {
data.response.planets[0].zones.forEach( function ( zone ) {
if (zone.difficulty >= 1 && zone.difficulty <= 7 && zone.captured == false) {
var zoneProgress = (zone.capture_progress === undefined) ? 0 : zone.capture_progress;
var zoneScore = Math.ceil(Math.pow(10, (zone.difficulty - 1) * 2) * (1 - zoneProgress)) + ((zone.boss_active) ? 10000000000 : 0);
var zoneScore = Math.ceil(Math.pow(10, (zone.difficulty - 1) * 2) * (1 - zoneProgress)) + ((zone.boss_active && !avoid_boss) ? 10000000000 : 0);
activePlanetsScore[planet_id] += isNaN(zoneScore) ? 0 : zoneScore;
if (zone.boss_active == true)
if (zone.boss_active == true && !avoid_boss)
bossSpawned = true;
if (zone.difficulty > planetsMaxDifficulty[planet_id])
planetsMaxDifficulty[planet_id] = zone.difficulty;
Expand Down Expand Up @@ -1043,6 +1054,9 @@ var INJECT_init = function() {
// Set Account ID
account_id = gAccountID;

// Avoid bosses if we're near level 25
avoid_boss = (gPlayerInfo.score >= 26390000 && gPlayerInfo.score < 26400000);

if (gGame.m_State instanceof CBattleSelectionState)
INJECT_init_battle_selection();
else if (gGame.m_State instanceof CPlanetSelectionState)
Expand Down

0 comments on commit 952af14

Please sign in to comment.