Thursday, July 05, 2007

Carry-alls and harvesters... An excellent combination

Today I added in all the goodness for carry-alls to pickup harvesters and deliver them into the refinery. It was quite some work to get that working, since I had to code in a few extra special cases(is this a harvester, does it have clearance for the refinery, is the landing area actually the refinery, etc.). But, now harvesters DO get picked up by a carry-all, if around, and they'll fly em into the refinery. And flying is SO much faster than driving :).

Carry-all just picked up harvester enroute to spice field.

Also, a newly built refinery now will receive a free harvester, which is dropped off in style by a carry-all, which will depart immediatly after dropping off the harvester. After the carry-all leaves the onscreen boundaries, it will delete itself.

Fully loaded harvester being returned to refinery

The carry-all which delivers the reinforcements into the field is a little special carry-all, namely a ReinforcementCarryall. I wrote a special class for it, since I didn't want to implement the code for leaving the field in the regular carry-all. That would really pollute the code. Also, this new Carry-all makes it possible to have regular reinforcement drops too, which is pretty sweet. Including stuffing 20 units into it.

But, there's a little issue with the carry-alls right now: When a tile is used, it won't be able to drop off it's payload, and just keeps hanging there, until the tile becomes free. So, that's what I'm going to solve next: find a free tile and unload there.

I already wrote a similar thing for the harvester to find spice tiles, so I'm considering to make it a general helper class and use a generic Comparable kind of thing. It's code that won't be called too often so speed isn't a really big issue here. And added goodness is that I can 'smear' out the search over multiple frames. In the case of finding a spice field which needs 200 steps to be found, it will cause severe lag. Being able to do this is say, 40 frames, it will only be 5 steps per frame, and therefor no big deal.

After this works, I'm going to fix a little bug with the selection rendering, constructing and then finally implement the credit counter control.

2 comments:

Anonymous said...

You just have to re-implement the bug from the original where a unit in need (of repair, return to refinery etc) would 'hijack' a leaving carry-all to take it where it wanted to to go, giving you a free carry-all in the process.

"In the case of finding a spice field which needs 200 steps to be found"

Is this really that hard on performance? I was working on my little game the other day where I run many more tests, which I think are similar. Are you sure it's a performance issue, or are you mainly worried it might become a bottleneck in the future?

Toolmaker said...

I did leave out the bug on purpose, since it could give you an unfair advantage in multiplayer games.

What I intend to do is give a player 'startup' credits, which he can spend on additional equipment. So instead of saying 'start with 6 units', you get 10 credits, and you could get an additional carry-all / harvester, or 8 trikes to quickly raid the enemies base.

However, if you could hijack a carry-all, it would beat the purpose ordering a carry-all in the beginning, giving unknowingly players a disadvantage.

Well, I don't think it's a big bottleneck for now, but as I've seen with my own play style in Dune 2000, I'd get around 10 to 12 harvesters. If any of those are all the sudden beginning a scout for a new spice field, I'm afraid performance would drop too much. Right now, the TileFinder doesn't do a lot of work per cycle, but I can crank this up to say 50.