# Precision-kicking help

my code

``````

# Push thene ball to knock over all the blue skeletons without hitting any red ones.
def commandPeasant():
flag = self.findFlag()
friends = self.findFriends()
for friend in friends:
enemy = self.findNearestEnemy()

if friend.type == "skeleton":
continue

if flag:
self.command(friend, "move", flag.pos)
pass

while True:

commandPeasant()

``````

i wnat to not use flags (also this level is next to imposible with flags)
and i need a kick start for understand how to do this with vectors

hero and equipment does not matter for this level aslong as you have boss star 2 or above this is a soccer level

1 Like

and proclimation V (20 chars)

here’s my code but you have to play fill in the blanks lol: (also sorry it’s js)

``````function findFurthest (t, r, u) {
let m = 'distance' + (u ? 'To' : '');
let e = r;
for (let v of r) {
if (t[m](v) > t[m](e)) {
e = v;
}
}
return e;
}
function dir (x1, y1, x2, y2) {
if (x2 === true) {
y2 = y1.y;
x2 = y1.x;
y1 = x1.y;
x1 = x1.x;
}
return null; // something to do with atan (math function)
}
function circle (cx, cy, radius, angle) {
return null; // something to do with the level: library tactician
}
function move (unit, place) {
hero.command(unit, 'move', place);
// wait until the unit gets to the place they're moving to, move command only takes 0.1s, while the unit takes a bit more time than that to move... hint: while true with a break condition regarding distanceTo
}
const p = null; // peasant
const ball = null;
const center = null;
const original = new Vector(p.pos.x, p.pos.y);
const dia = [null, null, null, null]; // west, north, south, east by 10 meters of the ball
while (true) {
let prev = findFurthest(p, null /* enemies that are alive (it probably does the filter already, but just in case... hint: p.findEnemies() with filter method: array.filter(variableName => condition) (or python: filter(lambda variableName: condition, array) */, true);
move(p, circle(center.x, center.y, null /* radius, it's mentioned somewhere above... */, null/* dir function with parameters: prev.pos, center, and true, I'll yet you figure out the order */ + Math.PI));
move(null, null); // move p to center
let t = findFurthest(p, null /* same as prev but check if enemy isn't prev: enemy health is bigger than 0 and enemy does not equal prev */, true);
if (!t) break;
move(p, circle(center.x, center.y, null /* radius, it's mentioned somewhere above... */, dir(center, t.pos, true) + Math.PI));
// wait until ball is in the center: ball.distanceTo(center), while loop with break condition
}
``````

This level is possible without flags, thats what I did.

can you message me the answer i have been working on this for a while and I dont get it

Hi @Liam_Reed
Welcome to the community!  We do not post answers in the forum, but we can give you tip and hints for you to solve the level.

1 Like

How do I post my code for help

Copy the code from the game, then press the </> button in the editor on here, and paste it in.

`It will look like this.`

@Liam_Reed are you coding in python or javascript?

i use java. this is my code

`````` var ball = hero.findNearest(hero.findByType("ball"));
var ballPos = ball.pos;
var enemy = hero.findNearestEnemy();
var friends = hero.findFriends();
var friend = hero.findNearest(friends);
var heroPos = hero.pos;
var nubPos = enemy.pos;
var newVector = Vector.subtract(nubPos, ballPos);
var direction = Vector.normalize(newVector);
var dm = Vector.multiply(direction,-3);
while(true) {
var point1 = {"x": 40,"y": 25};
hero.command(friend, "move", point1);
if(friend.distanceTo(finalVector)<2){
hero.command(friend, "move", finalVector);
hero.command(friend, "move", ballPos);
}
else{
var point2 = {"x": 30, "y": 35};
hero.command(friend, "move", point2);
}
if(friend.distanceTo(finalVector) < 2){
hero.command(friend, "move", finalVector);
hero.command(friend, "move", ballPos);
}
else{
var  point3 = {"x": 40, "y": 45};
hero.command(friend, "move", point3);
}
if(friend.distanceTo(finalVector)<2){
hero.command(friend, "move", finalVector);
hero.command(friend, "move", ballPos);
}
else{
var  point4 = {"x": 51, "y": 35};
hero.command(friend, "move", point4);
}
if(friend.distanceTo(finalVector)<8){
hero.command(friend, "move", finalVector);
hero.command(friend, "move", ballPos);
}
}[quote="MrCoolKoala, post:11, topic:35158, full:true"]
@Liam_Reed are you coding in python or javascript?
[/quote]

``````
1 Like