GSC reference › Built-in
ArraySort()
Built-in (engine)
Server
Returns a sorted array of entities by closest or farthest distance from <origin>
Signature
ArraySort(<array>, <origin>, [closest], [max], [range])
Parameters
| Name | Required? | Details |
|---|---|---|
| array | Required | array to sort |
| origin | Required | the origin from which to compare |
| closest | Optional | if set to true the array will be sorted by distance closest to <origin>, if false by distance farthest from <origin> |
| max | Optional | if set then only the first <max> count of entities will be returned |
| range | Optional | if set then only the entities within <range> will be considered |
Real uses in BO3's scripts
Called 50 times in the decompiled scripts. A few, zombies first:
- scripts/zm/_zm_powerup_nuke.gsc, line 64
player.zombie_nuked = arraysort(zombies, self.origin); - scripts/zm/_zm_weap_octobomb.gsc, line 797
a_ai_targets = arraysort(a_ai_potential_targets, self.origin, 1, a_ai_potential_targets.size, 112); - scripts/zm/zm_castle_ee.gsc, line 402
var_8717daa1 = arraysort(var_8717daa1, e_target_current.origin); - scripts/zm/zm_genesis_flingers.gsc, line 268
a_ai_enemies = arraysort(a_ai_enemies, nd_start.origin, 1, 99, 768); - scripts/zm/zm_genesis_portals.gsc, line 437
a_ai_enemies = arraysort(a_ai_enemies, var_6d359b2e, 1, 99, 768);
Related built-ins
- ArraySortClosest()Returns a sorted array of entities by closest from <origin>
- 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
- 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).