Level Idea: One Last Shot

I don’t know if it’s possible or a valid idea for that matter, but I tried to mess with the Editor Creator and couldn’t even make an ogre walk by, so I decided to publish my ideas as they come to me.

One Last Shot: An ogre hunter squad has found and ambushed a human team that was having a time-off at a campfire. Two men has been severely damaged and the third one is hidden behind an bush. Problem is, he has one last arrow.
At the beginning of the play, the three Ogre will say something as a mention that they found the last standing man and will start walking towards him. The man is somewhere in the left down corner and the three ogres are up right. At one single moment, they’ll be lined up and that exact moment has to be the moment where the shot happens and kill them all.

The solution would be a mathematical calculus to determinate whether the three coordinates belongs to the same linear function. Good to exercise mathematical knowledge on matrices.

1 Like

I don’t think there are piercing projectiles as of yet, but it’s an interesting idea that I might give a shot. I’ve learned a few tricks on the level editor that I could maybe walk you through sometime. It’s not intuitive to make simple changes, but luckily the way to do simple changes is also the way to do complex ones, so there’s really only a few parts to get familiar with to make passable levels. There’s a CodeCombat chat, someone in there can help you out with the editor.

Having the extra soldiers would make it harder to make the ogres do what you want, I think. By default, they’ll aggro and move toward the nearest enemy they see. If there were extra soldiers, you’d have to run some code on them to make sure they target the ID of the soldier with the arrow.

I wonder if lasers are piercing… You could set it up like cowardly taunt, where you have a soldier to lure those ogres in front of the laser tower correctly for its shot. You could have an enormous cooldown on the tower so that it only gets one shot, as well.

The solution for your idea would depend on what limitations you’d set, I suppose. Would you just calculate the arctangent on all three enemies and wait until they’re within some tolerance? I’ve forgotten most of the math I learned, so just post whatever stuff you’d want math-content wise and I’ll see what I can do over the next week.

Edit: So the beam towers don’t work like I thought, not sure how to currently go about doing this level, but go ahead and post the maths you’d want and I’ll see if I can think of anything to fit around it.

1 Like

If the 3 guards make it harder than just 1 guard, no problem with that. The way I described was like that just because I was plugging in some sort of background story which is not that much of important.

the easiest mathematical solution (I think) would be through matrices and determinants. Let’s say Ogre 1, 2 and 3 are at (x, y), (a, b) and (p, q) respectively. Now since the code runs for each frame, MY solution would be something like the following:

Math:
x y 1 |
a b 1 | = (xb + yp + aq - pb - qx - ay)
p q 1 |

JS:

// Getting enemies
var enemies = getEnemies();

// Collecting critical information
var positionList = [];
for(var it in enemies)
     positionList.push([it.position.x, it.position.y, 1]); 

// Get the determinant of the matrice *
var det = this.determinant(positionList);
if(det == 0)
   this.shoot();

Now, here is where it gets tricky. We can: A) offer this.determinant as a solved function which would mean that the player would only have to know how to set the matrix with the 3 coordinates OR the player would have to solve that function in another tab (like it happens in some level I don’t recall).

Determinant.JS

return (list[0][0]*list[1][1] + list[0][1]*list[1][0] + list[1][0]*list[2][1] - list[2][0]*list[1][1] - list[2][1]*list[0][0] - list[1][0]*list[0][1]);
1 Like

Interesting! We do have a Beam Tower that would be perfect here. It hasn’t been used since the big upgrade, so it might not be working quite right, but that’d be the way to go. Let me know if it’s busted after you add the Beam to it and I’ll try to fix it up.

The one other tricky part will be making it such that the player has to get the determinant right rather than just firing when one of the enemies is at the position that they see on the screen as being the right position when scrubbing the time around. (If I just wait until enemies[0].pos.x === 34 and shoot, that’ll get the job done as posed. If I just have to implement the determinant function, then I could just return 0 at the same moment.)

One way to do it would be to have several waves of differently staggered ogres (using the DelaysExistence Component). Then solving the problem repeatably with the determinant would actually be easier than trying to hack it with hardcoded values. The tower’s cooldown would be such that it only gets one shot per wave.

1 Like

Guiding the TODO (for example creating areEnemiesAligned()) would IMO guide the player to that solution.

1 Like