I’ve been trying to solve this level for quite a while now… I honestly think it’s harder than Kelvintaph Defiler, the most I’ve gotten is 170.
I don’t understand how you’re supposed to pass this level
My code so far:
const circ = (cx, cy, r, a) => (new Vector(r * Math.cos(angle), r * Math.sin(angle)));
hero.getPath = function (p1, p2, a) {
a = a ? a : 1;
let s = Math.hypot(Math.abs(p1.x - p2.x), Math.abs(p1.y - p2.y));
let d = Math.atan2(p2.x - p1.x, p2.y - p1.y);
let path = [];
for (let i = 0; i < s; i += a) path.push(circ(p1.x, p1.y, i, d));
return path;
};
hero.isInPath = function (p1, p2, p3, d) {
d = d ? d : 5;
let d1 = new Vector(p2.x - p1.x, p2.y - p1.y);
let d2 = new Vector(p3.x - p1.x, p3.y - p1.y);
let a = Math.abs;
let at = Math.atan2;
let d11 = (at(d1.x, d1.y) + 360) % 360;
let d22 = (at(d2.x, d2.y) + 360) % 360;
let e = ((a(d11 - d22) + 360) % 360);
if (Math.ceil(d11 / 180) !== Math.ceil(d22 / 180)) {
e = 360 - e;
}
return e < d * Math.PI / 180 && Math.hypot(a(d1.x), a(d1.y)) > Math.hypot(a(d2.x), a(d2.y));
};
hero.findBest = function (l, u, prop) {
prop = prop ? prop : 'value';
let bt = l[0];
for (let item of l) {
if (item[prop] / u.distanceTo(item) > bt[prop] / u.distanceTo(bt)) {
bt = item;
}
}
return bt;
};
function i (unit) {
let items = [];
for (let item of hero.findItems()) if (hero.findEnemies().filter(enemy => hero.isInPath(unit.pos, item.pos, enemy.pos)).length === 0) items.push(item);
return items;
}
while (true) {
let f = hero.findFriends().filter(fr => fr.health > 0)[0];
if (!f) continue;
let enemy = f.findNearestEnemy();
let item = hero.findBest(i(f), f);
// if (item) hero.command(f, 'move', item.pos);
if (item) {
while (true) {
hero.command(f, "move", item.pos);
if (f.distanceTo(item) <= 3 || f.health <= 0) break;
}
}
}
The most I’ve gotten is 178