Dota 2 Workshop Tools/Scripting/API/Global.FindUnitsInRadius: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (clean up, added deadend tag)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Dead end|date=January 2024}}
{{Note | This page is automatically generated.  Any changes may be overwritten}}
{{Note | This page is automatically generated.  Any changes may be overwritten}}
[[Category:Dota2Function]]
[[Category:Global]]


== Function Description ==
== Function Description ==


''' table FindUnitsInRadius(int ''teamNumber'', Vector ''position'', handle ''cacheUnit'', float ''radius'', int ''teamFilter'', int ''typeFilter'', int ''flagFilter'', int ''order'', bool ''canGrowCache'') '''
''' table FindUnitsInRadius(int ''teamNumber'', Vector ''position'', handle ''cacheUnit'', float ''radius'', int ''teamFilter'', int ''typeFilter'', int ''flagFilter'', int ''order'', bool ''canGrowCache'') '''


''Finds the units in a given radius with the given flags. ( iTeamNumber, vPosition, hCacheUnit, flRadius, iTeamFilter, iTypeFilter, iFlagFilter, iOrder, bCanGrowCache )''
''Finds the units in a given radius with the given flags. ( iTeamNumber, vPosition, hCacheUnit, flRadius, iTeamFilter, iTypeFilter, iFlagFilter, iOrder, bCanGrowCache )''


;Example
;Example
Line 39: Line 36:
| int
| int
| teamNumber
| teamNumber
| Your Unit's Team
| Your Unit's Team. Refer [https://developer.valvesoftware.com/wiki/Dota_2_Workshop_Tools/Scripting/Constants#Teams Here]
|-
|-
| Vector
| Vector
Line 51: Line 48:
| float
| float
| radius
| radius
| No Description Set
| The search radius. (FIND_UNITS_EVERYWHERE means the radius will cover the whole map. Refer to more [https://developer.valvesoftware.com/wiki/Dota_2_Workshop_Tools/Scripting/Constants#Find_Types Here])
|-
|-
| int
| int
| teamFilter
| teamFilter
| No Description Set
| This will be with respect to team on the first parameter. Refer [https://developer.valvesoftware.com/wiki/Dota_2_Workshop_Tools/Scripting/Constants#AbilityUnitTargetTeam Here]
|-
|-
| int
| int
| typeFilter
| typeFilter
| No Description Set
| Types of units you want to include/exclude in search. Refer [https://developer.valvesoftware.com/wiki/Dota_2_Workshop_Tools/Scripting/Constants#AbilityUnitTargetType Here]
|-
|-
| int
| int
| flagFilter
| flagFilter
| No Description Set
| Include/Exclude units which if respectilely flagged. Refer [https://developer.valvesoftware.com/wiki/Dota_2_Workshop_Tools/Scripting/Constants#Unit_Target_Flags Here]
|-
|-
| int
| int
Line 76: Line 73:
== Returns ==
== Returns ==


''table'' - No Description Set
A table containing the found units. If no units are found, <code>FindUnitsInRadius</code> returns an empty table; it does not return <code>nil</code>.
 
[[Category:Dota2Function]]
[[Category:Global]]

Latest revision as of 09:56, 21 January 2024

Dead End - Icon.png
This article has no Wikipedia icon links to other VDC articles. Please help improve this article by adding links Wikipedia icon that are relevant to the context within the existing text.
January 2024
Note.pngNote: This page is automatically generated. Any changes may be overwritten

Function Description

table FindUnitsInRadius(int teamNumber, Vector position, handle cacheUnit, float radius, int teamFilter, int typeFilter, int flagFilter, int order, bool canGrowCache)

Finds the units in a given radius with the given flags. ( iTeamNumber, vPosition, hCacheUnit, flRadius, iTeamFilter, iTypeFilter, iFlagFilter, iOrder, bCanGrowCache )

Example
-- Find all Dire units
direUnits = FindUnitsInRadius(DOTA_TEAM_BADGUYS,
                              Vector(0, 0, 0),
                              nil,
                              FIND_UNITS_EVERYWHERE,
                              DOTA_UNIT_TARGET_TEAM_FRIENDLY,
                              DOTA_UNIT_TARGET_ALL,
                              DOTA_UNIT_TARGET_FLAG_NONE,
                              FIND_ANY_ORDER,
                              false)

-- Make the found units move to (0, 0, 0)
for _,unit in pairs(direUnits) do
   unit:MoveToPosition(Vector(0, 0, 0))
end

Parameters

Type Name Description
int teamNumber Your Unit's Team. Refer Here
Vector position Point in dota 2 map about which you want to center your search. Use unit:GetAbsOrigin() to center it about a unit.
handle cacheUnit No Description Set
float radius The search radius. (FIND_UNITS_EVERYWHERE means the radius will cover the whole map. Refer to more Here)
int teamFilter This will be with respect to team on the first parameter. Refer Here
int typeFilter Types of units you want to include/exclude in search. Refer Here
int flagFilter Include/Exclude units which if respectilely flagged. Refer Here
int order No Description Set
bool canGrowCache No Description Set

Returns

A table containing the found units. If no units are found, FindUnitsInRadius returns an empty table; it does not return nil.