View topic - Best way to get nearest unit of a certain type



All times are UTC + 1 hour


Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: 12 Jun 2011, 10:17 
User avatar

Joined: 23 Feb 2009, 16:29
Location: Finland
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?

Code:
Spring.GetTeamUnitsByDefs

 ( number teamID, number unitDefID | { number unitDefID1, ... } )
   -> nil | unitTable = { [1] = number unitID, etc... }


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.


Top
 Offline Profile  
 
PostPosted: 12 Jun 2011, 12:32 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
You supply the teamID and unitDefID and get a TABLE of the units of that unitdef on that team.

IMO I'd go with this method and see how it works, unless you're spawning aliens many times a second I don't see it being a problem.


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.