These are chat archives for ESova/program

8th
Sep 2016
DrillerkilleR
@Anticimex
Sep 08 2016 01:45
Imam problem sa 96 lekcijom
Ako moze neko da mi pomogne!

hero.commandSoldier = function(soldier, soldierIndex, numSoldiers) {
var angle = Math.PI 2 soldierIndex / numSoldiers;
var defendPos = {x: 41, y: 40};
defendPos.x += 10 Math.cos(angle);
defendPos.y += 10
Math.sin(angle);
hero.command(soldier, "defend", defendPos);
};

// Find the strongest target (most health)
// This function returns something! When you call the function, you will get some value back.
hero.findStrongestTarget = function() {
var mostHealth = 0;
var bestTarget = null;
var enemies = hero.findEnemies();
// Figure out which enemy has the most health, and set bestTarget to be that enemy.
for (var i=0; i < enemies.length; i++) {
var enemy = enemies[i];
if (enemy.health > mostHealth) {
bestTarget = enemy;
mostHealth = enemy.health;
}

`````` }

// Only focus archers' fire if there is a big ogre.
if (bestTarget && bestTarget.health > 15) {
return bestTarget;
} else {
return null;
}``````

};

// If the strongestTarget has more than 15 health, attack that target. Otherwise, attack the nearest target.
this.commandArcher = function(archer) {
var nearest = hero.findNearestEnemy();
if(archerTarget) {
hero.command(archer, "attack", archerTarget);
} else if(nearest) {
hero.command(archer, "attack", nearest);
}
};
var archerTarget = null;
while(true) {
// If archerTarget is dead or doesn't exist, find a new one.
if(!archerTarget || archerTarget.health <= 0) {
// Set archerTarget to be the target that is returned by findStrongestTarget()
archerTarget = hero.findStrongestTarget();
}
var friends = hero.findFriends();
var soldiers = hero.findByType("soldier");
// Create a variable containing your archers.
var archers = hero.findByType("archer");
for(var i=0; i < soldiers.length; i++) {
var soldier = soldiers[i];
hero.commandSoldier(soldier, i, soldiers.length);
}
// use commandArcher() to command your archers
var archers = this.findByType("archer");
for(var j=0; j < archers.length; j++) {
var archer = archers[j];
this.commandArcher(archer[j]);
}

}

DrillerkilleR
@Anticimex
Sep 08 2016 02:27
@skiper120 Da li mi mozes poslati kako da resim 96 lekciju, stalno mi izbacuje gresku
Hvala u napred!
Ivan JokiÄ‡
@IvanJokicIT
Sep 08 2016 12:04

@Anticimex evo ti kod // Hushbaum has been ambushed by ogres!
// She is busy healing her soldiers, you should command them to fight!
// The ogres will send more troops if they think they can get to Hushbaum or your archers, so keep them inside the circle!

// Soldiers spread out in a circle and defend.
hero.commandSoldier = function(soldier, soldierIndex, numSoldiers) {
var angle = Math.PI 2 soldierIndex / numSoldiers;
var defendPos = {x: 41, y: 40};
defendPos.x += 10 Math.cos(angle);
defendPos.y += 10
Math.sin(angle);
hero.command(soldier, "defend", defendPos);
};

// Find the strongest target (most health)
// This function returns something! When you call the function, you will get some value back.
hero.findStrongestTarget = function() {
var mostHealth = 0;
var bestTarget = null;
var enemies = hero.findEnemies();
// Figure out which enemy has the most health, and set bestTarget to be that enemy.
for(var i=0 ; i < enemies.length ; i++){
if (enemies[i].health > mostHealth){
mostHealth = enemies[i].health;
bestTarget = enemies[i];
}
}
// Only focus archers' fire if there is a big ogre.
if (bestTarget && bestTarget.health > 15) {
return bestTarget;
} else {
return null;
}
};

// If the strongestTarget has more than 15 health, attack that target. Otherwise, attack the nearest target.
hero.commandArcher = function(archer) {
var nearest = archer.findNearestEnemy();
if(archerTarget) {
hero.command(archer, "attack", archerTarget);
} else if(nearest) {
hero.command(archer, "attack", nearest);
}
};

var archerTarget = null;
while(true) {
// If archerTarget is dead or doesn't exist, find a new one.
if(!archerTarget || archerTarget.health <= 0) {
// Set archerTarget to be the target that is returned by findStrongestTarget()
archerTarget = hero.findStrongestTarget();
}
var friends = hero.findFriends();
var soldiers = hero.findByType("soldier");
// Create a variable containing your archers.
var archers = hero.findByType("archer");
for(var i=0; i < soldiers.length; i++) {
var soldier = soldiers[i];
hero.commandSoldier(soldier, i, soldiers.length);
}
// use commandArcher() to command your archers
for(var i=0; i < archers.length; i++) {
var archer = archers[i];
hero.commandArcher(archer);
}
}

Nemanja
@zgubidanac
Sep 08 2016 17:46
jos uvek nista od 111?