# how to issue a harvest command
harvesting is attacking.
# figure out what resource is harvestable
harvestable resources have a custom parameter tag in unitdef:
is_mineable=1
# know which units are capable of harvesting
custom paremeter:
is_miner=1
atm it is only the "bminer" unit
Dropoffs are currently hard coded, but will be changed to have a custom parameter:
is_dropoff=1
or similiar
# know when resources are harvested aka some kind of 'dropped off resource' event
UnitDamaged, then do if attacker=miner and attacked unit = mineable blabla then stuff was mined
no 'dropped off resource' event atm
# where harvestable resources are
all resources are visible outside LOS by alwaysvisible=true, so GetTeamUnits (GaiaTeam) should get them all
# How much I get on each dropoff
damage done = resources harvested
how much a miner can carry is defined by a custom tag:
max_cargo=25
# How long between harvester go mine, and harvester comes back, aka how long does one bought of mining actually take before the miner comes back with shiny stuff
the actual mining takes ~2 seconds and time to return depends on distance.
maybe this is helpfull:
http://springrts.com/phpbb/viewtopic.ph ... 3&start=52
# How many times can a harvestable [be] min[ed]?
depends on maxdamage (health) of the harvestable unit.
ie if maxdamage of a "bminerals" is 500 and a "bminer" carries a cargo of 25 then this resource can be mined 20 times before its depleted.
# Can it be mined by more than one miner at a time?
yes, but too many miners (> 4) and they tend to clog up. better to spread them out a bit.
# How do I know when a harvestable appears
# How do I know when a harvestable dissapears
UnitCreated/Unitdestroyed, check if the new/dead unit has is_mineable=1
# How do I know if a unit is currently mining? aka its current state
if its "attacking" then its mining.
there also is a table of miners in the mining widget:
miners[unitID].cargo [0 to maxcargo]
and
miners[unitID].status ["gotodropoff", "gotores", "searchres" or something like this]
eventually that will be changed into a custom parameter "cargo" so that all widgets/gadgets can read this info more easily.
# How do I know if a harvestable dissapears because it has been completely mined
Atm the only thing that causes them to disappear is being completly mined out.
Miners already work on their own, they automagically search for new resources, return to the nearest drop offs etc. So basically all an AI has to do is:
-build a miner unit then leave it alone -> it will start to harvest and its stuff
-place depots near the resources so the travel paths are shorter for the miners. miners will go to the nearest depot on their own.
-> AI must be able to morph units to use depots!
(must also be able to use morph to make attack units)
The AIs I tested (dont remember) failed because they would always asign new attack commands to the miners, never letting them return.
Some workaround solutions for this were briefly talked about but I wasnt a fan of them really. ie giving the AI different (start) units and combining my KTAI ("knorkes test ai") and another AI in one team, KTAI doing the placing of depots and another AI doing the fighting stuff. Um yeah lol...
I think if an AI only ever "touches" the miners if it needs them to build something, then thats half the solution. Yes, maybe its bad practice that "miner AI" and "miner resource logic" are mixed in one gadget instead of "miner AI" being in a widget so that players can make their own optimizezed miner AIs but really wtf doesnt matter. Isnt really needed for the AI to know that much details about the miners as they kind of work on their own.
I had not really thought about AIs so much but my idea was to just ask an AI dev what kind of info they need to get their AI working with CT blablabla and I hope this post is somewhat helpful with that.