I have revised my code many times but my hero always die in battle too fast, and my enemy either.
Here’s my code:
loop {
var enemy = this.findNearest(this.findEnemies());
var flag = this.findFlag();
if (flag) {
this.pickUpFlag(flag);
}
else if (enemy.type != "sand-yak") {
if (this.isReady("bash")) {
this.bash(enemy);
}
else {
this.attack(enemy);
}
}
}
Is there any better strategy, please?``
In the level Clash of Clones, the most difficult enemy to defeat is your clone. The clone has the this.attack();
function by default so the better the sword you have, the better the weapon the enemy possesses. Equipping your character without a weapon will render the clone useless. You can always this.bash();
after that.
2 Likes
As Dragons_Project already mentioned, your clone has always the same tools as you, but it doesn’t use all of them. The code for the AI is basically findNearestEnemy() -> attack()
(With some more checks, not important here). It will for example never jump, use a spell or bash.
So while you are heavily outnumbered, you’re way smarter than your clone, being able to do all the mentioned special-moves (and more). Stripping your enemy off the possibility to attack is an easy way to win.
Other than that, please use existing topics!
2 Likes