# Serpent Savings - help

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

I also tried

``````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);
return e < d * Math.PI / 180 && Math.hypot(a(d1.x), a(d1.y)) > Math.hypot(a(d2.x), a(d2.y));
};
``````

I have this problem too. You might want to get a Elemental Codex to cast haste on your peasant. Your code is fine, peasant is just too slow.

1 Like

Poor you, this level is nearly impossible without using haste, at least for me. Maybe use your pet to fetch maybe?

Fetch what though?

What if I summon an extra peasant… hmm

That would cost 60 gold though…

Fetch coins to you maybe?

But the hero can’t collect coins… maybe it could fetch to the peasant?

Blue foxes can transform into peasants I think.

But they don’t do anything except distract enemies as far as I know.

I don’t have a blue fox, and @Endsoldier (who is totally not @Eric_Tang) is right

Hmm, I think that units that don’t have attack methods wouldn’t get distracted.

Also @moonwatcher348. Buy Elemental Codex I if you are able to buy it, it’s cheap and only cost 110 gems.

I don’t have a wizard, so I can’t -_-