// You need to find and destroy 3 skeletons.
// Skeletons and items are summoned at points of power.
// Move to a point and say the spell: "VENI".
// To find the required points, use the wizard's map.
// 0s are bad points. Positive numbers are good.
var spell = "VENI";
// The map of points is a 2D array of numbers.
var wizard = hero.findNearest(hero.findFriends());
var powerMap = wizard.powerMap;
var enemy = hero.findNearestEnemy();
var item = hero.findNearestItem();
// This function converts grid into x-y coordinates.
function convert(row, col) {
return {x: 16 + col * 12, y: 16 + row * 12};
}
// Loop through the powerMap to find positive numbers.
// First, loop through indexes of rows.
for (var i = 0; i < powerMap.length; i++) {
// Each row is an array. Iterate through it.
for (var j = 0; j < powerMap[i].length; j++) {
// Get the value of the i row and j column.
var pointValue = powerMap[i][j];
// If it's a positive number:
if (pointValue > 0) {
var point = convert(i,j)
hero.jumpTo(point);
hero.say("VENI");
if (enemy) {
hero.attack(enemy);
}
else if (item){
hero.jumpTo(item.pos);
}
}
}
// Use convert to get XY coordinates.
// Move there, say "VENI" and be prepared!
}
}
MY hero does not do anything!
Also,
There is this bar at the bottom of the level that is not at the bottom of other levels!
Thanks
Move to (point.x, point.y). Then, attack the enemy while it’s health is greater than 0, you don’t want to attack the enemy when it is dead. In your else statement, move to the item’s position, don’t jump, you can’t always jump.
Now the hero moves but, he still does not attack or go to items
// You need to find and destroy 3 skeletons.
// Skeletons and items are summoned at points of power.
// Move to a point and say the spell: "VENI".
// To find the required points, use the wizard's map.
// 0s are bad points. Positive numbers are good.
var spell = "VENI";
// The map of points is a 2D array of numbers.
var wizard = hero.findNearest(hero.findFriends());
var powerMap = wizard.powerMap;
var enemy = hero.findNearestEnemy();
var item = hero.findNearestItem();
// This function converts grid into x-y coordinates.
function convert(row, col) {
return {
x: 16 + col * 12,
y: 16 + row * 12
};
}
// Loop through the powerMap to find positive numbers.
// First, loop through indexes of rows.
for (var i = 0; i < powerMap.length; i++) {
// Each row is an array. Iterate through it.
for (var j = 0; j < powerMap[i].length; j++) {
// Get the value of the i row and j column.
var pointValue = powerMap[i][j];
// If it's a positive number:
if (pointValue > 0) {
var point = convert(i, j);
hero.moveXY(point.x, point.y);
hero.say("VENI");
if (enemy) {
while (enemy.health > 0) {
hero.attack(enemy);
}
} else if (item) {
hero.moveXY(item.pos.x, item.pos.y);
}
}
} // Use convert to get XY coordinates.
// Move there, say "VENI" and be prepared!
}
Thanks @abc See you tomorrow @Anonym
Also there is error without a line “cannot read property ‘pos’ of undefined”