GSC reference › Built-in
ArraySortClosest()
Built-in (engine)
Server
Returns a sorted array of entities by closest from <origin>
Signature
ArraySortClosest(<array>, <origin>, [maxReturnCount], [minDist], [maxDist])
Parameters
| Name | Required? | Details |
|---|---|---|
| array | Required | array to sort |
| origin | Required | the origin from which to compare |
| maxReturnCount | Optional | if set then only the first <max> count of entities will be returned |
| minDist | Optional | if set then only the entities further than <minDist> will be considered |
| maxDist | Optional | if set then only the entities closer then <maxDist will be considered |
Real uses in BO3's scripts
Called 73 times in the decompiled scripts. A few, zombies first:
- scripts/zm/_electroball_grenade.gsc, line 469
var_82aacc64 = arraysortclosest(var_82aacc64, self.origin); - scripts/zm/_zm_ai_mechz.gsc, line 718
a_ai_kill_zombies = arraysortclosest(a_ai, v_origin, 18, 0, 200); - scripts/zm/_zm_ai_sentinel_drone.gsc, line 1527
var_82aacc64 = arraysortclosest(var_82aacc64, origin); - scripts/zm/_zm_ai_thrasher.gsc, line 911
var_e38f15ea = arraysortclosest(var_6a9eb5b0, entity.origin, 5, 50, 96); - scripts/zm/_zm_altbody_beast.gsc, line 427
a_closest = arraysortclosest(a_ai, self.beast_mode_return_origin);
Related built-ins
- GetClosestPointOnNavMesh()Get a point on NavMesh that's closest to the given position within radius.
- ArrayGetClosest()Returns the entity/vector that is closest to the <origin> from the <array>.
- ArraySort()Returns a sorted array of entities by closest or farthest distance from <origin>
- GetClosestPointOnNavVolume()Get a point on nav volume that's closest to the given position within radius.
- GetNodesInRadiusSorted()Gets all of the nodes (max of 256) within a cylinder, sorted by closest to <origin>
- SortHeldWeapons()Sort the playerState heldWeapons to remove empty spaces
- GetNodeArraySorted()Gets an array of nodes that have the given name, key pair, within given radius, sorts them
- GetClosestEnemySqDist()Get the distance to the nearest enemy
- QSortScoredSpawnPointsAscending()Sort the scored spawn points in an ascending order
New to GSC?
Start with the basics, or paste a compile error to get the fix.
Built-in descriptions, parameters and examples come from Treyarch's BO3 mod tools docs. Usage links point at shiversoftdev/t7-source (decompiled BO3 scripts).