Monday, August 28, 2006

Carry-alls nearly done...

Right now, carry-alls are almost done.

I ran into a whole bunch of problems when implementing the carry-alls. First of all, my math was rusty and I had to fix that up. After that, flying circles and flying towards the target was easy to work out.

However, once above the unit, the carry-all seemed to rotate slightly, and then stall at a random direction. It took me quite some debugging efforts to find out that the carry-all was attempting to rotate towards the target and right after that attempted to rotate to face the same direction as the unit was. At some point, it ended up rotating one time Clockwise and another CounterClockwise, in the same frame. The fix was easy.

Right now, I'm coding up the parts that signal the unit that it's request for a carry-all has been granted, meaning it needs to cut down it's path to the nearest node and wait there for the carry-all to arrive. The carry-all already picks the unit up, so it's a matter a adding a state to the Unit class, do some actual path remodelling.

After that, I need a way to cancel the request in case the unit is destroyed or reached it's destination without the carry-all. The first would be a bit more difficult to handle, the latter is simple, since at that point, the request would still be in the queue. I will probably cancel the request if the unit is within 3 tiles distance from the target tile.

I should probably be able to implement that all tomorrow. For today I'm done coding.

No comments: