Best way to get nearest unit of a certain type
Posted: 12 Jun 2011, 11:17
I'm thinking of adding a feature to my map, namely that if a team is in the possession of a certain alien unit, then other aliens are more likely to join that team (maybe depending on distance to it). Would this function do it?
Do I supply the team id and unitDefID and then get just a number in return? I'm sorry but the description is a bit unclear.
The other way would be to store this information in a table when this other unit is created, would that be faster and more efficient than to lookup the value dynamically when a unit is created from a meteorite? Or should I try to minimise the amount of static variables in a gadget instead?
Sorry if this is a stupid question.
Code: Select all
Spring.GetTeamUnitsByDefs
( number teamID, number unitDefID | { number unitDefID1, ... } )
-> nil | unitTable = { [1] = number unitID, etc... }
The other way would be to store this information in a table when this other unit is created, would that be faster and more efficient than to lookup the value dynamically when a unit is created from a meteorite? Or should I try to minimise the amount of static variables in a gadget instead?
Sorry if this is a stupid question.