Gatherable resources
Posted: 07 Jun 2011, 00:05
I'm writing a game based quite heavily on Starcraft. I'm beginning with resource gathering scripts and while they're nowhere near finished I thought I'd upload them along with a few questions.
So far workers can be set to gather resources (gaia units). They will walk back and forth between the resource and the nearest hq ("mining" at the resource for a short while) giving the player resources.
The whole host of stuff that still needs doing includes only one worker mining a resource at a time, causing damage to the resources as they're mined (and making them immune to other damage), having workers mine nearby resources if their assigned resource is being mined and a whole host of other things. Also the code needs cleaning up, I haven't done any of the defining locals for performance and this is my first time with lua (I really hate the if then end syntax).
Notice that it needs some config in the form of resource, worker and hq lists, there are some sample values in there. If you can't get the workers to mine/return try increasing the radius it's taken from the center of the object (something which needs fixing) and if the model is too big they can't reach it.
As for my questions:
Is there an explicit way to make a unit invulnerable, or should I just look into armour?
Originally I used features instead of gaia units for resources. I wrote a little script that converts some features to gaia units to make things easier for me. I can't help thinking it doesn't really make too much difference but...
How often is FallbackCommand called? Should I use something called more often like Update?
Of course any other comments are appreciated.
So far workers can be set to gather resources (gaia units). They will walk back and forth between the resource and the nearest hq ("mining" at the resource for a short while) giving the player resources.
The whole host of stuff that still needs doing includes only one worker mining a resource at a time, causing damage to the resources as they're mined (and making them immune to other damage), having workers mine nearby resources if their assigned resource is being mined and a whole host of other things. Also the code needs cleaning up, I haven't done any of the defining locals for performance and this is my first time with lua (I really hate the if then end syntax).
Notice that it needs some config in the form of resource, worker and hq lists, there are some sample values in there. If you can't get the workers to mine/return try increasing the radius it's taken from the center of the object (something which needs fixing) and if the model is too big they can't reach it.
As for my questions:
Is there an explicit way to make a unit invulnerable, or should I just look into armour?
Originally I used features instead of gaia units for resources. I wrote a little script that converts some features to gaia units to make things easier for me. I can't help thinking it doesn't really make too much difference but...
How often is FallbackCommand called? Should I use something called more often like Update?
Of course any other comments are appreciated.