// You'll need good strategy to win this one!
// Your clone will have the same equipment you have!
// But, they're not very skilled at using special powers.
function moveTo(position) {
if (hero.isReady("jump")) {
hero.jumpTo(position);
}
else {
hero.move(position);
}
}
function attack(enemy) {
if (enemy) {
if (hero.isReady("bash")) {
hero.bash(enemy);
}
else if (hero.distanceTo(enemy) > 5) {
moveTo(enemy.pos);
}
else if (hero.canCast("chain-lightning", enemy)) {
hero.cast("chain-lightning", enemy);
}
else {
hero.attack(enemy);
}
}
}
while(true) {
var enemy = hero.findNearestEnemy();
if (enemy.type == "archer") {
attack(enemy);
}
}
i need strategy pls (it not count as solution right?)
well, heres the thing about clash of clones
the idea is that you have a clone that only attacks. They cannot do any special abilites like shield or bash or cleave or cast chain lighnting. The way this is meant to be played is by making the clone low enough to where he can be killed, but having code complex enough to keep you alive.
You will lose if the code does not include special abilites, because there are also ogres spawning to back up the clone army.
Okay from what I can tell…
You should be fine.
But just to be safe I would put in a few lines about keeping yourself alive
like before everything else put
// You'll need good strategy to win this one!
// Your clone will have the same equipment you have!
// But, they're not very skilled at using special powers.
hero.moveXY(68, 78);
var back = 0;
while (true) {
var enemys = hero.findEnemies();
var index = 0;
var closest_soldier = null;
var soldier_dist = 999;
var closest_archer = null;
var archer_dist = 999;
var closest = null;
var dist = 999;
while(index<enemys.length) {
var distance = hero.distanceTo(enemys[index]);
if(enemys[index].health>0 && enemys[index].type != "sand-yak" ) {
if(enemys[index].type == 'archer' && distance<archer_dist) {
var archer_dist=distance;
var closest_archer = enemys[index];
}
if(enemys[index].type == 'soldier' && distance<soldier_dist) {
var soldier_dist=distance;
var closest_soldier = enemys[index];
}
if(distance<dist) {
var soldier_dist=dist;
var closest = enemys[index];
}
}
index ++;
}
if(closest_soldier && soldier_dist<10) {
var enemy = closest_soldier;
}
else if(closest_archer && archer_dist<20) {
var enemy = closest_archer;
}
else {
var enemy = closest;
}
if(enemy) {
if(hero.health < hero.maxHealth / 2.5 && back == 0) {
hero.moveXY(40, 85);
back = 1;
}
}
else if(hero.health<hero.maxHealth/5 && back==1) {
hero.moveXY(40, 85);
back = 2;
}
else if(hero.isReady("jump") && hero.distanceTo>15) {
hero.jumpTo(enemy.pos);
}
else if(hero.isReady("bash")) {
hero.bash(enemy);
}
else if(hero.canCast("chainlightning", enemy)) {
hero.cast("chain-lightning", enemy);
hero.attack(enemy);
}
else {
hero.attack(enemy);
}
}
// You'll need good strategy to win this one!
// Your clone will have the same equipment you have!
// But, they're not very skilled at using special powers.
function findArcher() {
var enemies = hero.findEnemies();
var index = 0;
var archer = null;
while (index < enemies.length) {
var enemy = enemies[index];
if (enemy.type == "archer") {
archer = enemy;
}
index ++;
}
}
function attack() {
var archer = findArcher();
if (archer) {
if (hero.isReady("bash")) {
hero.bash(archer);
}
else if (hero.canCast("invisibility")) {
hero.cast("invisibility", hero);
}
else if (hero.canCast("chain-lightning", archer)) {
hero.cast("chain-lightning", archer);
}
else {
hero.attack(archer);
}
}
}
function moveTo(position) {
if (hero.isReady("jump")) {
hero.jumpTo(position);
}
else {
hero.move(position);
}
}
moveTo({'x': 55, 'y': 91});
moveTo({'x': 80, 'y': 86});
while(true) {
attack();
var archer = findArcher();
if (archer < 0) {
hero.moveXY(26, 75);
}
}
@TheBredMeister help pls reply, when hero almost near archer it stop moving.