// 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 wizards 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;
// 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 its a positive number:
if (pointValue>0){
// Use convert to get XY coordinates.
var pos = convert(i, j);
hero.say(pos);
// Move there, say "VENI" and be prepared!
hero.move(pos);
hero.say(spell);
while(true) {
var enemy = hero.findNearestEnemy();
if (enemy){
hero.attack(enemy);
}
}
}
}
}
I do not know what I am doing wrong can you please help me. It is not picking up the items or attacking the enemies and I do not know what is going on. This is my code:
// 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;
// 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.
var item = hero.findNearest(hero.findItems());
var enemy = hero.findNearest(hero.findEnemies());
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:
var pos = convert(i, j);
if (pointValue > 0 && pointValue % 1===0) {
hero.moveXY(pos.x, pos.y);
hero.say(spell);
if (enemy) {
hero.attack(enemy);
}
if (item) {
hero.moveXY(item.pos.x, item.pos.y);
}
}
// Use convert to get XY coordinates.
// Move there, say "VENI" and be prepared!
}
Please paste ALL of your code inside the triple back tick marks.
``` <— Triple back tick marks.
Paste ALL of your code in here.
``` <— Triple back tick marks.
There are many people here willing and able to help. If you use the </> button correctly, then ALL of your code should look like this:
while True:
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
else:
hero.say("My code is formatted properly")
If ALL of your code isn’t formatted like the code above, then you’re doing it wrong and we can’t see the structure of the code to troubleshoot whether or not that is the issue. Use the </> button and help us help you. This works when sending a private message as well.
My hero and everything else keeps freezing and I do not know what to do. Please help me. My code is bellow.
// 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;
// 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.
var item = hero.findNearest(hero.findItems());
var enemy = hero.findNearest(hero.findEnemies());
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:
var pos = convert(i, j);
if (pointValue > 0 && pointValue % 1===0) {
hero.moveXY(pos.x, pos.y);
hero.say(spell);
if (enemy) {
hero.attack(enemy);
}
if (item) {
hero.moveXY(item.pos.x, item.pos.y);
}
}
// Use convert to get XY coordinates.
// Move there, say "VENI" and be prepared!
}
}