Every now and then… and I mean rarely every now and then… something nice happens as a result of a structured design. I just accidentally discovered an originally unintended effect using Launchers to target Creeper on the other side of a Micro Rift. Here’s the technical skinny:
Launchers want to fire at the densest Creeper within a radius. Their algorithm is to look at all Creeper within a surrounding radius to find the densest Creeper to which there is a path. To do this they scan through all surrounding cells and build up a sorted list of densest to least dense Creeper occupied cells. Then, this list is evaluated to see if there is a path to the target cell. This is necessary because the projectile fired by the launcher is powered/guided and it has to travel to the target cell via a route that is completely powered. I’ve talked about all of this in a previous blog post…
If there is a wall of terrain between the launcher and some nice fat pile of Creeper, the projectile won’t fire (the wall is in the way). But what if there is a MicroRift on both sides of that wall? Well it turns out that the projectile will take the shortcut and nuke the Creeper after all.
Some might say “of course”.. and they’d be right. This does make sense. Of course I never really thought about this when I was coding everything up. It just worked out this way. Btw, for the vast majority of folks who have never done any development… the ratio of bugs to serendipitous events is about 1000 to 1 on a good day.
Here’s a little image of a Launcher fired projectile on it’s way through a MicroRift to deal some punishment. I’ve added the yellow arrows to show the path it is taking.