User Tools

Site Tools


4rpl:commands:getunits

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
4rpl:commands:getunits [2021/09/13 19:03] – additional clarification from KC Grabz4rpl:commands:getunits [2021/09/14 11:30] – added link to new wiki page Grabz
Line 10: Line 10:
  
 :!: **Note:** The difference between this API and [[GetUnitsInRange]] is this API takes a 'unitType' parameter.  By specifying a unitType, less units are searched over resulting in potentially higher performance. Furthermore, GetUnits can search for any units regardless of whether they occupy space, so units that are in flight can be found this way as well. \\  :!: **Note:** The difference between this API and [[GetUnitsInRange]] is this API takes a 'unitType' parameter.  By specifying a unitType, less units are searched over resulting in potentially higher performance. Furthermore, GetUnits can search for any units regardless of whether they occupy space, so units that are in flight can be found this way as well. \\ 
-GetUnits takes a unit type and from that it will internally find all units of that type.  It then enumerates those units and checks if they are in range and if they match the state filters. So GetUnits can be used to find any unit (air, map, or neither). This method can be more performant than [[GetUnitsInRange]] if the unit being searched is not found in large quantities on the map.+GetUnits takes a unit type and from that it will internally find all units of that type.  It then enumerates those units and checks if they are in range and if they match the state filters. So GetUnits can be used to find any unit (air, map, or neither). This method can be more performant than GetUnitsInRange if the unit being searched is not found in large quantities on the map
 + 
 +:!: __**Note: 2D square search is currently broken and will find all units as long as they are close enough on X-axis, disregarding the Z-axis. Do not use this combination of parameters.**__ 
 + 
 +For short range searches refer to the [[cw4:4rpl_unit_search_analysis|unit search analysis]] to see how the different parameters interact with finding units in a short range.
  
   * **unitType:** a string indicating the [[unit types|unit type]]((Unit Type can also be the UID of a CMOD)) to return. If empty string (""), then all units are searched.\\   * **unitType:** a string indicating the [[unit types|unit type]]((Unit Type can also be the UID of a CMOD)) to return. If empty string (""), then all units are searched.\\
Line 38: Line 42:
 GetUnits(<-unitType V3(<-cellX <-terrain <-cellZ) <-range <-isSquare <-is3D <-requireLOS <-enemyState <-builtState <-imperviousState) ->units GetUnits(<-unitType V3(<-cellX <-terrain <-cellZ) <-range <-isSquare <-is3D <-requireLOS <-enemyState <-builtState <-imperviousState) ->units
 </code> </code>
- 
-=== Usage Notes === 
-[[GetUnits]] takes a unit type and from that it will internally find all units of that type.  It then enumerates those units and checks if they are in range and if they match the state filters.  So [[GetUnits]] can be used to find any unit (air, map, or neither). [[GetUnitsInRange]] doesn't take a unit type.  It just searches in a range around the specified coordinates.  It only finds units that leave a footprint on the map.  So it won't work for flying units (or land based units that are moving). 
- 
  
 === See Also === === See Also ===
-  * [[4rpl:commands:getunitsinrange]]+  * [[GetUnitsInRange]]
  
 <=[[4rpl:start| Index]] <=[[4rpl:start| Index]]
4rpl/commands/getunits.txt · Last modified: 2024/03/21 18:05 by qople