Level: Extra Extrapolation

Should be fixed now–the goals weren’t set to end the world properly when the munchkin was destroyed.

2 Likes

Actually that problem is still there.
“Kill Capturer” is checked as done, but the level is still running.

1 Like

Hmm, I’m not seeing it now:

Should end three seconds after it dies. Perhaps try things refreshing without cache and changing your code and casting the spell again? If it’s still not working, there’s probably some bug with updating the goals.

2 Likes

Yeah, ok… but what i wanted to say is that this level just stops, while others show up the “Done” button, and the screen to vote the level and leave feedback.

This is an example from a well-working level:

1 Like

Oh, I see what you mean now! I’ve gone ahead and added simple victory scripts to this level that should do the trick here. Thanks for bearing with me so long on this one.

2 Likes

Maybe its a bug that just happened recently, but when I just ran the level, there is no unit for me to control. I’ve uploaded a screen shot so I know i’m not going insane.

all these comments make the level sound great so I’m excited to play it!

1 Like

Hey,

Did you try restarting the level? Did it have the same bug again?

1 Like

Yup! Just tried it again, same issue… Weird right?

1 Like

Actually I was able to reproduce it. If you press the play button, your artillery appears in your minion’s spells and you can edit it then. Not sure why this happening, but I’ll look into it.

1 Like

Looks like the level creator delayed the Artillery’s existence by 0.5s to get the shot timing to work out just so. Will have to think of a better way to adjust the timing than by making the Artillery not exist at first.

2 Likes

So, as a non-coder my solution looks like this:

var ogre = this.getNearestEnemy();

if(ogre) {
if (ogre.pos.x > 15 && ogre.pos.y > 30 ){
this.attackXY(33,31);
} else if (ogre.pos.x > 33 && ogre.pos.y > 11 ){
this.attackXY(35,11);
} else if (ogre.pos.x < 36 && ogre.pos.y > 10 ){
this.attackXY(15,12);
}
}

Edit: I checked the Guide and noticed a nice primer on velocity. This was very helpful.

Without a background in physics coding this level was difficult. It was confusing to see velocity documented as “still undocumented. Sorry.”

I think that if you wanted to encourage a dynamic solution, (vs my staic solution) it’s be helpful to use a random position for the ogre like others have suggested. (Then my solution of static target points would be ineffective and cause the search for another solution.)

Another note - it is confusing that shellAirTime is set in the code instead of being a property such as this.shellAirTime in the available spells section. Since it is part of the chooseAction() spell, it give the impression that you can change this number. (e.g. set shellAirTime = 0.01 so the bullet fires faster. But this doesn’t work.)

1 Like

I’ve documented velocity now; thanks for catching that.

We do now have a way to set custom variables per-level, so we could set this.shellAirTime to 3.4 and have it available in the spell palette for your code to read. But we still don’t have a good way of documenting those custom properties, so it would also show up as “still undocumented”. Hmm. Will think about a better way to add custom property documentation.

2 Likes

I can’t complete it, It’s impossible.

1 Like

@gar I just checked, and the solution still works. Have you checked the guide for a hint?

2 Likes

Yeah I checked the guide and I understood that I need to understand where Brack is going to be and get the bomb there, I tried to fire in one spot and then in different spots but was unable to.

I notice that several people have posted code but I want to write the Code myself although I don’t think I will be able to.

1 Like

You should end up with only one this.attackXY() call in your code, but it will get called multiple times. The parameters you pass to it have to depend on the ogre’s position and velocity; you can’t decide the x and y to shoot at it in advance.

1 Like

How does it get called multiple times and what are parameters?

1 Like

The chooseAction() spell you’re writing will automatically get called after each shot lands. If it has one this.attackXY() in it, that one will be called after each shot.

Parameters are roughly the same thing as arguments. You pass them to methods to get them to do more specific things. Here, the arguments to this.attackXY(x, y) are the x and the y. So this.attackXY(23, 64) would pass x=23 and y=64 as the arguments.

For this level, then, the x and y arguments need to use a formula to take into account ogre.pos, ogre.velocity, and shellAirTime to figure out which x and y the ogre will be at when your shot lands.

2 Likes

How many shots does it take to kill Brack and can’t he be shot at on every corner of the Square that he walks in?

The code that is already there is:

var shellAirTime = 3.4; // in seconds

var ogre = this.getNearestEnemy();
if(ogre) {
this.attackXY(ogre.pos.x, ogre.pos.y
);

I understand that as:

It takes 3.4 seconds for the bomb to hit it’s target

The ogre moves and must be killed, attack ogre.

Are these the only bits of code that are needed for this spell to work correctly?

attackXY(x, y)
getNearestEnemy()
pos
say(message, data)
velocity

I didn’t know you were a cofounder of codecombat, I just bought your book on my nook.

1 Like

Tried everyone’s code before yours, yours is the only one that worked for me, how did you figure it out? I couldn’t.

1 Like