Issue with levels goalkeeper and ice-soccer


#1

Hello,
I have issues with the two soccer levels, i can’t get hold on the ball. If i do :

loop this.say(this.findByType("ball").length);

my character keeps saying ‘0’, so this.findByType(‘ball’) returns an empty array. Is it a matter of glasses ?

edit : i have the +60 glasses (‘lunettes téléobjectif classes’ in french…)


#2

Since findByType returns an array and there’s only one ball around, try accessing the first item with this.findByType(“ball”)[0] instead.

edit: Sorry I think I misunderstood the problem. I guess the range of your glasses is the culprit.

edit 2: I don’t have the same glasses to test with so I tried with range 25 glasses but couldn’t get anything to work with them. With range 60 you might be able to see the ball some of the time. Try putting your commands inside an “if peasant and ball” and see if they react some of the time.


#3

this.findByType(‘ball’)[0] is null
i read the other’s code, most of them have infinity range glasses, maybe that’s why they can see the ball and i don’t. Moreover, some have glasses that see through walls, i’m not sure there’s no wall between my hero and the ball.
If it’s confirmed it is a matter of glasses, i give up, i won’t spend gems on glasses for now…


#4

I only have lenses and they worked alright so the line of sight shouldn’t be a problem. Or at least not a big one.


#5

As i’m doing :

loop this.say(this.findByType("ball").length);

my hero should say ‘1’ when the ball gets close, however this blind rabbit keeps saying '0’
brb, i’ll check the distance from my hero to nearest corner of the field

edit :
seems it’s not a matter of distance, when i do this :

distance = function(p1,p2) {
  return Math.sqrt(Math.pow(p1.x - p2.x , 2) + Math.pow(p1.y - p2.y , 2));
};

loop {
    this.say('distance : ' + distance(this.pos,{x:45,y:35}));
    this.say(this.findByType("ball").length);
}

, my hero keeps saying ‘distance : 43.01[…]’ and ‘0’, so it cannot see the ball (‘0’) although the distance to the center of the field ({x:45,y:35}) is less than his glasses range
ima gonna flag this as bug…


#7

Yes it seems strange that you never see the ball. But then again, the say action takes quite some time to finish so maybe it’s a matter of timing aswell. The window where he can reach the ball should be pretty small if the nearest corner is at distance 43 and if the ball is elsewhere when the saying starts it will be negative even if it comes into range during the speech bubble.

Edit: Don’t know JS syntax…

Try checking if length is greater than 0 before saying length. Just to make sure you actually never see it.


#8

Nono, in fact i’m checking the distance to the center of the field (i said nearest corner earlier, but i enlarged my search to the center, just to be sure…). I even checked distance to the opposite corner, and it’s nearly my glasses range (62 for 60), so my dude should see the ball at the begining.


#9

I’ve just made a tweak to Goalkeeper and Ice Soccer so that your hero can always see the ball regardless of your glasses’ range and x-ray-vision abilities. Thanks for debugging this one for me!


#10

thanks, awesome, now i can play it to its full potential :slight_smile: