I am doing the final level of HoC and whenever I do:
game.setActionFor("shaman", "spawn", function (event) {
while (true) event.target.attack(hero);
});
game.spawnXY("shaman", 40, 50);
const hero = game.spawnPlayerXY("guardian", 40, 35);
while (true) {
let missile = hero.findNearest(hero.findEnemyMissiles());
if (missile) {
let dir = Vector.subtract(missile.pos, hero.pos);
hero.reflect(dir);
}
}
It gives me the error: “Unhandled error: ReferenceError: act is not defined”.
@staff
Rabbit
2
Which line is the one with error?
It doesn’t say any line, since it’s an unhandled error. But I’m guessing it’s from the reflect()
function.
Rabbit
4
Maybe remove the (true)
part in line 2 (I don’t know much about javascript)
I’m sure that isn’t the error.
Rabbit
6
You can just try @moonwatcher348
It would just give me another error.
1 Like
I have over 2 years of experience with JavaScript, so I am sure.
1 Like
Rabbit
9
Then that might mean you know the error
No, this is an error that only exists in codecombat, and I don’t have much experience with codecombat.
Rabbit
11
Maybe you should check if shaman exists
Aya
12
just guessing (I don’t know javascript) hero
should be defined before this line:
1 Like
Rabbit
13
Hero is already defined @Aya
Aya
14
I know, but it should be in a different order (probably), so that it can exist
Rabbit
15
I think is is defined already
1 Like
Rabbit
16
I think this is the part with error