Skip to content
Draft
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
48 changes: 45 additions & 3 deletions d2bs/kolbot/libs/scripts/BaalAssistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
let quitFlag = false;
let [hotCheck, safeCheck, baalCheck, ngCheck, baalIsDead] = [false, false, false, false, false];
let [ShrineStatus, secondAttempt, throneStatus, killTracker] = [false, false, false, false];

let shrineActive = false; // if we have a xp shrine
let lastShrineCheck = 0; // for check throttle

// convert all messages to lowercase
Config.BaalAssistant.HotTPMessage.forEach((msg, i) => {
Config.BaalAssistant.HotTPMessage[i] = msg.toLowerCase();
Expand All @@ -38,6 +40,26 @@
Config.BaalAssistant.NextGameMessage[i] = msg.toLowerCase();
});

function CheckShrine() { // Check if XP shrine is still active, restore Helper to original config setting.
// If we never had a shrine, do nothing
if (!shrineActive)
return;

const now = getTickCount();
// throttle: only allow once per 1000 ms
if (now - lastShrineCheck < 1000) {
return; // skip
}
lastShrineCheck = now;

// If shrine buff is gone, shrine expired
if (!me.getState(sdk.states.ShrineExperience)) {
Helper = Config.BaalAssistant.Helper;
shrineActive = false;
console.debug("XP shrine expired or removed, Helper restored to original config setting.");
}
}

const chatEvent = function (nick, msg) {
if (nick === Leader) {
if ((Config.BaalAssistant.DollQuit && msg === "Dolls found! NG.")
Expand Down Expand Up @@ -242,6 +264,8 @@
break;
}
if (Misc.getShrinesInArea(i, sdk.shrines.Experience, true)) {
shrineActive = true;

Check failure on line 267 in d2bs/kolbot/libs/scripts/BaalAssistant.js

View workflow job for this annotation

GitHub Actions / lint

Mixed spaces and tabs
Helper = false;
break;
}
}
Expand All @@ -257,6 +281,8 @@
break;
}
if (Misc.getShrinesInArea(i, sdk.shrines.Experience, true)) {
shrineActive = true;

Check failure on line 284 in d2bs/kolbot/libs/scripts/BaalAssistant.js

View workflow job for this annotation

GitHub Actions / lint

Mixed spaces and tabs
Helper = false;
break;
}
}
Expand Down Expand Up @@ -382,28 +408,33 @@
}

if (!Game.getMonster(sdk.monsters.ThroneBaal)) {
CheckShrine();
break;
}

switch (Common.Baal.checkThrone(Helper)) {
case 1:
Helper && Attack.clear(40);
tick = getTickCount();
CheckShrine();

break;
case 2:
Helper && Attack.clear(40);
tick = getTickCount();
CheckShrine();

break;
case 4:
Helper && Attack.clear(40);
tick = getTickCount();
CheckShrine();

break;
case 3:
Helper && Attack.clear(40) && Common.Baal.checkHydra();
tick = getTickCount();
CheckShrine();

break;
case 5:
Expand All @@ -414,9 +445,11 @@
.map((unitId) => Game.getMonster(unitId))
.filter(Boolean).some((unit) => unit.attackable)) {
delay(1000);
CheckShrine();
}

delay(1000);
CheckShrine();
}

break MainLoop;
Expand Down Expand Up @@ -455,6 +488,7 @@
let portal = Game.getObject(sdk.objects.WorldstonePortal);

if (portal) {
CheckShrine();
delay((Helper ? 1000 : 4000));
Pather.usePortal(null, null, portal);
} else {
Expand All @@ -472,11 +506,19 @@
Pather.moveTo(15177, 5952);
let baal = Game.getMonster(sdk.monsters.Baal);

while (!!baal && baal.attackable && !baalIsDead) {
while (!!baal && baal.attackable && !baalIsDead && !Helper) {
delay(1000);
CheckShrine();

}
if (Helper || Config.BaalAssistant.HurtBaal > 0) { // shrine was removed and Helper enabled
Pather.moveTo(15134, 5923);
Config.BaalAssistant.HurtBaal > 0
? Attack.hurt(sdk.monsters.Baal, Config.BaalAssistant.HurtBaal)
: Attack.kill(sdk.monsters.Baal);

Check failure on line 518 in d2bs/kolbot/libs/scripts/BaalAssistant.js

View workflow job for this annotation

GitHub Actions / lint

Mixed spaces and tabs
Pickit.pickItems();
}
}

} else {
// how to accurately know when to end script in the instance of no ngCheck
// listen for baal death packet maybe?
Expand Down
Loading