Entry 64 with superunit

So we are making a “superunit” — a big (possibly upgradable) unit that will serve as player’s offensive force and defensive when idle. This means the unit can capture keeps. However, it needs to time the attacks well, otherwise it risks being overwhelmed and destroyed. When I say “it”, I mean the player.

Superdirect the superunit to a superpath

Firstly, we need to be able to send the unit to a keep or coordinate. This is pretty easy since enemy units already do this and I’ll reuse the class with a few adjustments. Obviously, we need to be able to select it first (ignore the magenta debug border):

Now, clicking anywhere on the map tells the unit to go from “idle” to “goto location” mode with a couple sanity checks.

So here is the unit target locator. I think it should be pretty big/obvious and always visible, as this is basically player’s main unit — i.e. player. Need a better graphic though.

So A* works like a charm for me. The world is neatly broken into tiles, each tile has a specific weight (how hard it is for unit to move in it), and all objects have a per-tile pointers for quick access to see which tile houses what. In addition to all the collision detection, I can pretty much make paths exactly the way I want them. Except our superunit is special — it can walk on any passable terrain without wanting to choose roads:

And this works nicely, a pretty direct route is chosen for the unit to take. This is now also useful to units that are not attacking and following the roads, but are going for a nearby unit/tower/keep/spot.

Here’s another useful thing, zone borders:

I don’t know if I can make them look much prettier than this. Since everything is tile based, so are the border sprites. It’s pretty complex and time consuming to try make smooth lines that actually align as well. Such would need to cross tiles that aren’t even neighboring other zones and do all kinds of weird and processing intensive stuffs.

This entry was posted in Uproot DevDiary.

Leave a Reply

Your email address will not be published. Required fields are marked *