nearestTerrainObjects: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (fixed syntax highlighting)
No edit summary
 
(86 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma3 |Game name=
|game1= arma3
|version1= 1.54


|1.54|Game version=
|gr1= Object Detection
____________________________________________________________________________________________


| Returns a list of nearest terrain objects of the given types to the given position or object, within the specified distance. If more than one object is found they will be ordered according to 3D distance to the object (i.e. the closest one will be first in the array).  
|descr= Returns a list of nearest terrain objects of the given types to the given position or object, within the specified distance. If more than one object is found they will be ordered according to 3D distance to the object (i.e. the closest one will be first in the array).  
In contrast to [[nearestObjects]] this command returns terrain placed objects like trees, rocks and buildings which don't necessarily need an associated config class.<br><br>
In contrast to [[nearestObjects]] this command returns terrain placed objects like trees, rocks and buildings which don't necessarily need an associated config class.<br><br>
Possible type names:<tt>"TREE", "SMALL TREE", "BUSH", "BUILDING", "HOUSE", "FOREST BORDER", "FOREST TRIANGLE", "FOREST SQUARE", "CHURCH", "CHAPEL", "CROSS", "BUNKER", "FORTRESS", "FOUNTAIN", "VIEW-TOWER", "LIGHTHOUSE", "QUAY", "FUELSTATION", "HOSPITAL", "FENCE", "WALL", "HIDE", "BUSSTOP", "ROAD", "FOREST", "TRANSMITTER", "STACK", "RUIN", "TOURISM", "WATERTOWER", "TRACK", "MAIN ROAD", "ROCK", "ROCKS", "POWER LINES", "RAILWAY", "POWERSOLAR", "POWERWAVE", "POWERWIND", "SHIPWRECK", "TRAIL"</tt>
Possible type names:
<br><br>
{{Columns|7|
Since Arma 3 v1.61.136035 it is possible to switch the sorting algorithm off by providing optional param, which significantly increases the performance of this command, especially if the search is performed with large radius.
* {{hl|"BUILDING"}}
<br><br>
* {{hl|"BUNKER"}}
Since Arma 3 v1.65.138818 it is possible to switch search and sorting mode between 2D and 3D.<br><br>
* {{hl|"BUSH"}}
<syntaxhighlight lang="cpp"></syntaxhighlight><!---THIS IS HERE TO MAKE SYNTAX HIGHLIGHTING WORK INSIDE THE SPOILER (BLACKMAGIC)--->
* {{hl|"BUSSTOP"}}
* {{hl|"CHAPEL"}}
* {{hl|"CHURCH"}}
* {{hl|"CROSS"}}
* {{hl|"FENCE"}}
* {{hl|"FOREST BORDER"}}
* {{hl|"FOREST SQUARE"}}
* {{hl|"FOREST TRIANGLE"}}
* {{hl|"FOREST"}}
* {{hl|"FORTRESS"}}
* {{hl|"FOUNTAIN"}}
* {{hl|"FUELSTATION"}}
* {{hl|"HIDE"}}
* {{hl|"HOSPITAL"}}
* {{hl|"HOUSE"}}
* {{hl|"LIGHTHOUSE"}}
* {{hl|"MAIN ROAD"}}
* {{hl|"POWER LINES"}}
* {{hl|"POWERSOLAR"}}
* {{hl|"POWERWAVE"}}
* {{hl|"POWERWIND"}}
* {{hl|"QUAY"}}
* {{hl|"RAILWAY"}}
* {{hl|"ROAD"}}
* {{hl|"ROCK"}}
* {{hl|"ROCKS"}}
* {{hl|"RUIN"}}
* {{hl|"SHIPWRECK"}}
* {{hl|"SMALL TREE"}}
* {{hl|"STACK"}}
* {{hl|"TOURISM"}}
* {{hl|"TRACK"}}
* {{hl|"TRAIL"}}
* {{hl|"TRANSMITTER"}}
* {{hl|"TREE"}}
* {{hl|"VIEW-TOWER"}}
* {{hl|"WALL"}}
* {{hl|"WATERTOWER"}}
}}
 
{{Feature|important|The names are / The filter is based on the named property [[Arma 3: Named_Properties#map|map]] - not on the named property ''class'' or any config definition!}}
 
<spoiler text="Terrain object counts">
<spoiler text="Terrain object counts">
{{Informative|Types which are missing are not present in the given world. [[Virtual Reality]] has no terrain objects.}}
{{Feature|informative|Types which are missing are not present in the given world. [[Virtual Reality]] has no terrain objects. Last updated {{GVI|arma3|2.12}}}}
<big>[[Stratis]]</big>
<big>[[Stratis]]</big>
<div style="columns: 5">
{{Columns|5|
* TREE: 40110
* BUSH: 47974
* BUSH: 47974
* HOUSE: 684
* CHAPEL: 2
* CHAPEL: 2
* CROSS: 1
* CROSS: 1
* LIGHTHOUSE: 3
* FENCE: 1728
* FUELSTATION: 3
* FUELSTATION: 3
* FENCE: 1728
* WALL: 1355
* HIDE: 70975
* HIDE: 70975
* HOUSE: 684
* LIGHTHOUSE: 3
* ROAD: 143
* ROAD: 143
* ROCK: 820
* SHIPWRECK: 11
* TRACK: 2063
* TRANSMITTER: 11
* TRANSMITTER: 11
* TREE: 40110
* WALL: 1355
* WATERTOWER: 1
* WATERTOWER: 1
* TRACK: 2063
}}
* ROCK: 820
* SHIPWRECK: 11
</div>


<big>[[Altis]]</big>
<big>[[Altis]]</big>
<div style="columns: 5">
{{Columns|5|
* TREE: 263630
* BUSH: 747193
* BUSH: 747193
* HOUSE: 17472
* CHAPEL: 165
* CHURCH: 54
* CHURCH: 54
* CHAPEL: 165
* CROSS: 48
* CROSS: 48
* LIGHTHOUSE: 7
* FENCE: 47940
* FUELSTATION: 32
* FUELSTATION: 32
* HIDE: 655958
* HOSPITAL: 1
* HOSPITAL: 1
* FENCE: 47940
* HOUSE: 17472
* WALL: 38943
* LIGHTHOUSE: 7
* HIDE: 655958
* ROAD: 4849
* TRANSMITTER: 23
* RUIN: 3
* TOURISM: 1
* WATERTOWER: 10
* TRACK: 26823
* MAIN ROAD: 2061
* MAIN ROAD: 2061
* ROCK: 5483
* POWER LINES: 2224
* POWER LINES: 2224
* POWERSOLAR: 10
* POWERSOLAR: 10
* POWERWAVE: 51
* POWERWAVE: 51
* POWERWIND: 128
* POWERWIND: 128
* ROAD: 4849
* ROCK: 5483
* RUIN: 3
* SHIPWRECK: 43
* SHIPWRECK: 43
</div>
* TOURISM: 1
* TRACK: 26823
* TRANSMITTER: 23
* TREE: 263630
* WALL: 38943
* WATERTOWER: 10
}}


<big>[[Malden 2035]]</big>
<big>[[Malden 2035]]</big>
<div style="columns: 5">
{{Columns|5|
* TREE: 101960
* BUSH: 288461
* BUSH: 288461
* HOUSE: 4062
* BUSSTOP: 45
* CHAPEL: 14
* CHURCH: 14
* CHURCH: 14
* CHAPEL: 14
* CROSS: 16
* CROSS: 16
* LIGHTHOUSE: 15
* FENCE: 11189
* FUELSTATION: 24
* FUELSTATION: 24
* FENCE: 11189
* WALL: 14189
* HIDE: 192553
* HIDE: 192553
* BUSSTOP: 45
* HOUSE: 4062
* ROAD: 1442
* LIGHTHOUSE: 15
* TRANSMITTER: 7
* WATERTOWER: 63
* TRACK: 3489
* MAIN ROAD: 1050
* MAIN ROAD: 1050
* ROCK: 3513
* POWER LINES: 3427
* POWER LINES: 3427
* POWERSOLAR: 1
* POWERSOLAR: 1
* ROAD: 1442
* ROCK: 3513
* SHIPWRECK: 23
* SHIPWRECK: 23
</div>
* TRACK: 3489
* TRANSMITTER: 7
* TREE: 101960
* WALL: 14189
* WATERTOWER: 63
}}


<big>[[Tanoa]]</big>
<big>[[Tanoa]]</big>
<div style="columns: 5">
{{Columns|5|
* TREE: 506993
* BUSH: 754347
* BUSH: 754347
* HOUSE: 13389
* CHURCH: 21
* CHURCH: 21
* FENCE: 2912
* FUELSTATION: 85
* FUELSTATION: 85
* FENCE: 2912
* WALL: 20526
* HIDE: 356904
* HIDE: 356904
* ROAD: 1485
* HOUSE: 13389
* TRANSMITTER: 16
* TOURISM: 35
* WATERTOWER: 73
* TRACK: 9419
* MAIN ROAD: 2921
* MAIN ROAD: 2921
* ROCK: 8909
* POWER LINES: 3985
* POWER LINES: 3985
* RAILWAY: 2138
* POWERSOLAR: 2
* POWERSOLAR: 2
* POWERWIND: 19
* POWERWIND: 19
* RAILWAY: 2138
* ROAD: 1485
* ROCK: 8909
* SHIPWRECK: 58
* SHIPWRECK: 58
* TOURISM: 35
* TRACK: 9419
* TRAIL: 6936
* TRAIL: 6936
</div>
* TRANSMITTER: 16
* TREE: 506993
* WALL: 20526
* WATERTOWER: 73
}}


<syntaxhighlight lang="cpp">private _types = ["TREE", "SMALL TREE", "BUSH", "BUILDING", "HOUSE", "FOREST BORDER", "FOREST TRIANGLE", "FOREST SQUARE", "CHURCH", "CHAPEL",
<big>[[Livonia]]</big>
"CROSS", "BUNKER", "FORTRESS", "FOUNTAIN", "VIEW-TOWER", "LIGHTHOUSE", "QUAY", "FUELSTATION", "HOSPITAL", "FENCE", "WALL", "HIDE", "BUSSTOP",
{{Columns|5|
"ROAD", "FOREST", "TRANSMITTER", "STACK", "RUIN", "TOURISM", "WATERTOWER", "TRACK", "MAIN ROAD", "ROCK", "ROCKS", "POWER LINES", "RAILWAY",
* BUILDING: 1262
"POWERSOLAR", "POWERWAVE", "POWERWIND", "SHIPWRECK", "TRAIL"];
* BUNKER: 40
* BUSH: 473543
* BUSSTOP: 73
* CHAPEL: 8
* CHURCH: 17
* FENCE: 48426
* FOUNTAIN: 36
* FUELSTATION: 7
* HIDE: 474123
* HOUSE: 6762
* MAIN ROAD: 2118
* POWER LINES: 2671
* POWERSOLAR: 2
* POWERWIND: 1
* RAILWAY: 843
* ROAD: 5378
* ROCK: 744
* SHIPWRECK: 4
* STACK: 11
* TRACK: 12834
* TRANSMITTER: 15
* TREE: 1881630
* VIEW-TOWER: 239
* WALL: 4418
* WATERTOWER: 7
}}


private _counts = [];
<big>[[Weferlingen]]</big>
private _countTypes = count _types;
{{Columns|5|
* BUILDING: 5072
* BUSH: 731315
* BUSSTOP: 106
* CHAPEL: 13
* CHURCH: 21
* FENCE: 83908
* FUELSTATION: 9
* HIDE: 231818
* HOUSE: 4562
* MAIN ROAD: 1535
* POWER LINES: 1958
* RAILWAY: 2324
* ROAD: 8740
* STACK: 18
* TRACK: 24372
* TRANSMITTER: 1
* TREE: 829449
* VIEW-TOWER: 34
}}


["R3vo_GetNearestTerrainObjects",""] call BIS_fnc_startLoadingScreen;
<big>[[Weferlingen (Winter)]]</big>
{{Columns|5|
* BUILDING: 5072
* BUSH: 519827
* BUSSTOP: 106
* CHAPEL: 13
* CHURCH: 21
* FENCE: 83908
* FUELSTATION: 9
* HIDE: 229792
* HOUSE: 4562
* MAIN ROAD: 1535
* POWER LINES: 1958
* RAILWAY: 2324
* ROAD: 8740
* STACK: 18
* TRACK: 24372
* TRANSMITTER: 1
* TREE: 829449
* VIEW-TOWER: 34
}}


{
<big>[[Cam Lao Nam]]</big>
private _terrainObjects = nearestTerrainObjects
{{Columns|5|
[
* BUILDING: 390
[worldSize / 2, worldSize / 2],
* BUNKER: 2622
[_x],
* BUSH: 1852844
worldSize,
* CHURCH: 6
false
* FENCE: 12346
];
* FORTRESS: 2
* FOUNTAIN: 3
* FUELSTATION: 32
* HIDE: 309385
* HOUSE: 13319
* LIGHTHOUSE: 3
* MAIN ROAD: 4162
* POWER LINES: 1591
* POWERSOLAR: 5
* POWERWIND: 5
* RAILWAY: 1345
* ROAD: 17621
* ROCK: 60452
* SHIPWRECK: 161
* TOURISM: 18
* TRACK: 6846
* TRAIL: 7726
* TRANSMITTER: 33
* TREE: 1442842
* VIEW-TOWER: 529
* WALL: 19664
* WATERTOWER: 32
}}


if (count _terrainObjects > 0) then
<big>[[Khe Sanh]]</big>
{
{{Columns|5|
_counts pushBack [_x,count _terrainObjects];
* BUILDING: 91
};
* BUNKER: 4861
((_forEachIndex + 1) / _countTypes) call BIS_fnc_progressLoadingScreen;
* BUSH: 1299130
} forEach _types;
* FENCE: 2196
* FOUNTAIN: 2
* FUELSTATION: 3
* HIDE: 228731
* HOUSE: 5754
* POWER LINES: 801
* ROAD: 7755
* ROCK: 33853
* TRACK: 8156
* TRANSMITTER: 3
* TREE: 1145377
* VIEW-TOWER: 227
* WALL: 9078
* WATERTOWER: 13
}}


<big>[[The Bra]]</big>
{{Columns|5|
* BUILDING: 8
* BUNKER: 265
* BUSH: 179428
* FENCE: 251
* HIDE: 56960
* HOUSE: 522
* POWER LINES: 25
* ROAD: 7
* ROCK: 671
* SHIPWRECK: 2
* TRACK: 584
* TRAIL: 2767
* TRANSMITTER: 1
* TREE: 203443
* VIEW-TOWER: 48
* WALL: 2076
}}


"R3vo_GetNearestTerrainObjects" call BIS_fnc_endLoadingScreen;
<big>[[Gabreta]]</big>
{{Columns|5|
* BUILDING: 222
* BUSH: 383449
* BUSSTOP: 18
* CHAPEL: 10
* CHURCH: 11
* CROSS: 17
* FENCE: 25616
* FORTRESS: 149
* FOUNTAIN: 2
* FUELSTATION: 11
* HIDE: 582635
* HOSPITAL: 1
* HOUSE: 6352
* MAIN ROAD: 4427
* POWER LINES: 502
* POWERSOLAR: 2
* RAILWAY: 1923
* ROAD: 8693
* ROCK: 918
* RUIN: 5
* SHIPWRECK: 1
* STACK: 6
* TRACK: 10066
* TRAIL: 1170
* TRANSMITTER: 2
* TREE: 3473175
* VIEW-TOWER: 39
* WALL: 6218
* WATERTOWER: 8
}}
 
<big>[[Sefrou-Ramal]]</big>
{{Columns|5|
* BUILDING: 2
* BUSH: 13669
* FENCE: 5199
* FUELSTATION: 2
* HIDE: 23243
* HOUSE: 1963
* MAIN ROAD: 403
* POWER LINES: 565
* POWERWIND: 19
* RAILWAY: 135
* ROAD: 199
* ROCK: 1183
* TRACK: 3286
* TRANSMITTER: 9
* TREE: 7592
* WALL: 3560
* WATERTOWER: 2
}}
 
<big>[[Spearhead 1944 Normandy]]</big>
{{Columns|5|
* BUILDING: 2918
* BUNKER: 1703
* BUSH: 608441
* CHURCH: 45
* CROSS: 16
* FENCE: 288630
* FORTRESS: 196
* FOUNTAIN: 1286
* HIDE: 330656
* HOUSE: 12837
* MAIN ROAD: 1981
* RAILWAY: 776
* ROAD: 20237
* ROCK: 837
* RUIN: 1
* SMALL TREE: 20
* TRACK: 29761
* TRAIL: 6365
* TREE: 581549
* VIEW-TOWER: 95
* WALL: 60793
* WATERTOWER: 34
}}


private _export = "<big>[[" + getText (configFile >> "CfgWorlds" >> worldName >> "description") + "]]</big>" + endl + '<div style="columns: 5">';
<big>[[Spearhead 1944 Mortain]]</big>
{{Columns|5|
* BUILDING: 759
* BUNKER: 597
* BUSH: 192944
* CHURCH: 7
* CROSS: 3
* FENCE: 66361
* FORTRESS: 35
* FOUNTAIN: 320
* HIDE: 140143
* HOUSE: 3120
* MAIN ROAD: 551
* RAILWAY: 733
* ROAD: 4276
* ROCK: 1896
* SMALL TREE: 19
* TRACK: 11268
* TRAIL: 996
* TREE: 291745
* VIEW-TOWER: 65
* WALL: 13364
* WATERTOWER: 13
}}


{
_export = _export + endl + "* " + (_x # 0) + ": " + (str (_x # 1));
} forEach _counts;


_export = _export + endl + "</div>";


copyToClipboard _export;</syntaxhighlight>
{{Wiki|extractionScript}}
</spoiler>
</spoiler>


|DESCRIPTION=
|s1= [[nearestTerrainObjects]] [position, types, radius, sort, 2Dmode]
____________________________________________________________________________________________


| [[nearestTerrainObjects]] [position, types, radius, sort, 2Dmode] |Syntax=
|p1= position: [[Object]], [[Position#PositionAGL|PositionAGL]] or [[Position#Introduction|Position2D]] - where to find objects, center position


|p1= position: [[Object]], [[PositionAGL]] or [[Position2D]] - where to find objects, center position |PARAMETER1=
|p2= types: [[Array]] - list of case-insensitive types of the objects to search for. {{hl|[]}} to search without filters


|p2= types: [[Array]] - list of types of the objects to search for. <tt>[]</tt> to search without filters |PARAMETER2=
|p3= radius: [[Number]] - range from center position to search for objects


|p3= radius: [[Number]] - range from center position to search for objects |PARAMETER3=
|p4= sort: [[Boolean]] - (Optional, default [[true]]) sort objects by distance to the center or not - setting to [[false]] '''greatly''' improves performance
|p4since= arma3 1.62


|p4= sort: [[Boolean]] - (Optional, default [[true]]) sort objects by distance to the center or not (''Available since Arma 3 v1.61.136035'') |PARAMETER4=
|p5= 2Dmode: [[Boolean]] - (Optional, default [[false]]) the object search and sorting mode: [[true]] - 2D, [[false]] - 3D
|p5since= arma3 1.66


|p5= 2Dmode: [[Boolean]] - (Optional, default [[false]]) the object search and sorting mode: [[true]] - 2D, [[false]] - 3D (''Available since Arma 3 v1.65.138818'') |PARAMETER5=
|r1= [[Array]] - array of terrain objects. Before {{arma3}} v2.00 this command did not return roads of type {{hl|"ROAD", "MAIN ROAD", "TRACK", "TRAIL"}}


| [[Array]] - array of terrain objects |RETURNVALUE=
|x1= <sqf>nearestTerrainObjects [player, ["Tree", "Bush"], 200];</sqf>
____________________________________________________________________________________________
 
|x1= <code>[[nearestTerrainObjects]] [<nowiki/>[[player]], ["Tree", "Bush"], 200];</code> |EXAMPLE1=


|x2= <code>[[nearestTerrainObjects]] [<nowiki/>[[player]], ["House"], 200];</code> |EXAMPLE2=
|x2= <sqf>nearestTerrainObjects [player, ["House"], 200];</sqf>


|x3= <code>[[nearestTerrainObjects]] [<nowiki/>[2716,2949,0], ["Chapel", "Fuelstation"], 100];</code> |EXAMPLE3=
|x3= <sqf>nearestTerrainObjects [[2716, 2949, 0], ["Chapel", "Fuelstation"], 100];</sqf>


|x4= Return every terrain object in 50 metres radius around player sorted, closest first:<code>[[nearestTerrainObjects]] [<nowiki/>[[player]], [], 50];</code> |EXAMPLE4=
|x4= Return every terrain object in 50 metres radius around player sorted, closest first:
<sqf>nearestTerrainObjects [player, [], 50];</sqf>


|x5= Return every terrain object in 50 metres radius around player unsorted:<code>[[nearestTerrainObjects]] [<nowiki/>[[player]], [], 50, [[false]]];</code> |EXAMPLE5=
|x5= Return every terrain object in 50 metres radius around player unsorted:
<sqf>nearestTerrainObjects [player, [], 50, false];</sqf>


|x6= Hide all terrain objects [[nearestTerrainObjects]] could find:
|x6= Hide all terrain objects (run locally for each client):
<code>[[if]] ([[isServer]]) [[then]]
<sqf>
{
private _allTerrainObjects = nearestTerrainObjects
{
[
[[_x]] [[hideObjectGlobal]] [[true]];
[worldSize / 2, worldSize / 2],
}
[],
[[forEach]] [[nearestTerrainObjects]]
worldSize * sqrt 2 / 2,
[
false,
<nowiki>[</nowiki>[[worldSize]] / 2, [[worldSize]] / 2],
true
[],
];
[[worldSize]],
{ _x hideObject true } forEach _allTerrainObjects;
[[false]]
</sqf>
];
};</code> |EXAMPLE6=
____________________________________________________________________________________________


| [[nearestObjects]], [[findNearestEnemy]], [[hideObject]], [[nearestBuilding]], [[nearestObject]], [[nearObjects]], [[nearestLocation]], [[nearEntities]], [[nearTargets]], [[nearSupplies]], [[nearestLocationWithDubbing]], [[nearObjectsReady]], [[nearRoads]] |SEEALSO=
|seealso= [[nearestObjects]] [[findNearestEnemy]] [[hideObject]] [[nearestBuilding]] [[nearestObject]] [[nearObjects]] [[nearestLocation]] [[nearEntities]] [[nearTargets]] [[nearSupplies]] [[nearestLocationWithDubbing]] [[nearObjectsReady]] [[nearRoads]] [[roadsConnectedTo]] [[roadAt]] [[isOnRoad]] [[getRoadInfo]] [[nearestMines]]
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= Killzone_Kid
<!-- Note Section BEGIN -->
|timestamp= 20161031002000
|text= Since {{arma3}} v1.66 the default sorting is done according to 3D distance not [[distance2D]] as before. This is an attempt to correct some very old bug in implementation.
}}


<!-- Note Section END -->
{{Note
</dl>
|user= Demellion
|timestamp= 20161228202100
|text= Be aware that some terrain objects types might be tricky to be found, such as terrain rocks and boulders which are not considered to be "ROCKS" or "ROCK", but "HIDE". Example:
<sqf>nearestTerrainObjects [player, ["HIDE"], 20]; // [939688: bluntstone_01.p3d,939691: garbagebags_f.p3d,939671: wreck_car_f.p3d,939692: junkpile_f.p3d]</sqf>
}}


<h3 style="display:none">Bottom Section</h3>
{{Note
 
|user= Killzone_Kid
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
|timestamp= 20200607141600
[[Category:Command_Group:_Object_Information|{{uc:{{PAGENAME}}}}]]
|text= Large bridges are map type {{hl|"ROAD"}}. Small foot bridges are not roads and not included into road net.
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
}}
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on October 31, 2016 - 00:20 (UTC)</dd>
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dd class="note">
Since Arma 3 v1.65.138818 the default sorting is done according to 3D distance not [[distance2D]] as before. This is an attempt to correct some very old bug in implementation.
</dd>
 
<dd class="notedate">Posted on December 28, 2016 - 20:21 (UTC)</dd>
<dt class="note">[[User:Demellion|Demellion]]</dt>
<dd class="note">
Be aware that some terrain objects types might be tricky to be found, such as terrain rocks and boulders which are not considered to be "ROCKS" or "ROCK", but "HIDE". Example:
<code>nearestTerrainObjects [player, ["HIDE"], 20]; {{cc|[939688: bluntstone_01.p3d,939691: garbagebags_f.p3d,939671: wreck_car_f.p3d,939692: junkpile_f.p3d]}}</code>
</dd>
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on June 7, 2020 - 14:16 (UTC)</dd>
<dt class="note">[[User:killzone_kid|killzone_kid]]</dt>
<dd class="note">
Large bridges are map type <tt>"ROAD"</tt>. Small foot bridges are not roads and not included into road net.
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 08:48, 24 September 2024

Hover & click on the images for description

Description

Description:
Returns a list of nearest terrain objects of the given types to the given position or object, within the specified distance. If more than one object is found they will be ordered according to 3D distance to the object (i.e. the closest one will be first in the array). In contrast to nearestObjects this command returns terrain placed objects like trees, rocks and buildings which don't necessarily need an associated config class.

Possible type names:
  • "BUILDING"
  • "BUNKER"
  • "BUSH"
  • "BUSSTOP"
  • "CHAPEL"
  • "CHURCH"
  • "CROSS"
  • "FENCE"
  • "FOREST BORDER"
  • "FOREST SQUARE"
  • "FOREST TRIANGLE"
  • "FOREST"
  • "FORTRESS"
  • "FOUNTAIN"
  • "FUELSTATION"
  • "HIDE"
  • "HOSPITAL"
  • "HOUSE"
  • "LIGHTHOUSE"
  • "MAIN ROAD"
  • "POWER LINES"
  • "POWERSOLAR"
  • "POWERWAVE"
  • "POWERWIND"
  • "QUAY"
  • "RAILWAY"
  • "ROAD"
  • "ROCK"
  • "ROCKS"
  • "RUIN"
  • "SHIPWRECK"
  • "SMALL TREE"
  • "STACK"
  • "TOURISM"
  • "TRACK"
  • "TRAIL"
  • "TRANSMITTER"
  • "TREE"
  • "VIEW-TOWER"
  • "WALL"
  • "WATERTOWER"
The names are / The filter is based on the named property map - not on the named property class or any config definition!
Types which are missing are not present in the given world. Virtual Reality has no terrain objects. Last updated Arma 3 logo black.png2.12

Stratis

  • BUSH: 47974
  • CHAPEL: 2
  • CROSS: 1
  • FENCE: 1728
  • FUELSTATION: 3
  • HIDE: 70975
  • HOUSE: 684
  • LIGHTHOUSE: 3
  • ROAD: 143
  • ROCK: 820
  • SHIPWRECK: 11
  • TRACK: 2063
  • TRANSMITTER: 11
  • TREE: 40110
  • WALL: 1355
  • WATERTOWER: 1

Altis

  • BUSH: 747193
  • CHAPEL: 165
  • CHURCH: 54
  • CROSS: 48
  • FENCE: 47940
  • FUELSTATION: 32
  • HIDE: 655958
  • HOSPITAL: 1
  • HOUSE: 17472
  • LIGHTHOUSE: 7
  • MAIN ROAD: 2061
  • POWER LINES: 2224
  • POWERSOLAR: 10
  • POWERWAVE: 51
  • POWERWIND: 128
  • ROAD: 4849
  • ROCK: 5483
  • RUIN: 3
  • SHIPWRECK: 43
  • TOURISM: 1
  • TRACK: 26823
  • TRANSMITTER: 23
  • TREE: 263630
  • WALL: 38943
  • WATERTOWER: 10

Malden 2035

  • BUSH: 288461
  • BUSSTOP: 45
  • CHAPEL: 14
  • CHURCH: 14
  • CROSS: 16
  • FENCE: 11189
  • FUELSTATION: 24
  • HIDE: 192553
  • HOUSE: 4062
  • LIGHTHOUSE: 15
  • MAIN ROAD: 1050
  • POWER LINES: 3427
  • POWERSOLAR: 1
  • ROAD: 1442
  • ROCK: 3513
  • SHIPWRECK: 23
  • TRACK: 3489
  • TRANSMITTER: 7
  • TREE: 101960
  • WALL: 14189
  • WATERTOWER: 63

Tanoa

  • BUSH: 754347
  • CHURCH: 21
  • FENCE: 2912
  • FUELSTATION: 85
  • HIDE: 356904
  • HOUSE: 13389
  • MAIN ROAD: 2921
  • POWER LINES: 3985
  • POWERSOLAR: 2
  • POWERWIND: 19
  • RAILWAY: 2138
  • ROAD: 1485
  • ROCK: 8909
  • SHIPWRECK: 58
  • TOURISM: 35
  • TRACK: 9419
  • TRAIL: 6936
  • TRANSMITTER: 16
  • TREE: 506993
  • WALL: 20526
  • WATERTOWER: 73

Livonia

  • BUILDING: 1262
  • BUNKER: 40
  • BUSH: 473543
  • BUSSTOP: 73
  • CHAPEL: 8
  • CHURCH: 17
  • FENCE: 48426
  • FOUNTAIN: 36
  • FUELSTATION: 7
  • HIDE: 474123
  • HOUSE: 6762
  • MAIN ROAD: 2118
  • POWER LINES: 2671
  • POWERSOLAR: 2
  • POWERWIND: 1
  • RAILWAY: 843
  • ROAD: 5378
  • ROCK: 744
  • SHIPWRECK: 4
  • STACK: 11
  • TRACK: 12834
  • TRANSMITTER: 15
  • TREE: 1881630
  • VIEW-TOWER: 239
  • WALL: 4418
  • WATERTOWER: 7

Weferlingen

  • BUILDING: 5072
  • BUSH: 731315
  • BUSSTOP: 106
  • CHAPEL: 13
  • CHURCH: 21
  • FENCE: 83908
  • FUELSTATION: 9
  • HIDE: 231818
  • HOUSE: 4562
  • MAIN ROAD: 1535
  • POWER LINES: 1958
  • RAILWAY: 2324
  • ROAD: 8740
  • STACK: 18
  • TRACK: 24372
  • TRANSMITTER: 1
  • TREE: 829449
  • VIEW-TOWER: 34

Weferlingen (Winter)

  • BUILDING: 5072
  • BUSH: 519827
  • BUSSTOP: 106
  • CHAPEL: 13
  • CHURCH: 21
  • FENCE: 83908
  • FUELSTATION: 9
  • HIDE: 229792
  • HOUSE: 4562
  • MAIN ROAD: 1535
  • POWER LINES: 1958
  • RAILWAY: 2324
  • ROAD: 8740
  • STACK: 18
  • TRACK: 24372
  • TRANSMITTER: 1
  • TREE: 829449
  • VIEW-TOWER: 34

Cam Lao Nam

  • BUILDING: 390
  • BUNKER: 2622
  • BUSH: 1852844
  • CHURCH: 6
  • FENCE: 12346
  • FORTRESS: 2
  • FOUNTAIN: 3
  • FUELSTATION: 32
  • HIDE: 309385
  • HOUSE: 13319
  • LIGHTHOUSE: 3
  • MAIN ROAD: 4162
  • POWER LINES: 1591
  • POWERSOLAR: 5
  • POWERWIND: 5
  • RAILWAY: 1345
  • ROAD: 17621
  • ROCK: 60452
  • SHIPWRECK: 161
  • TOURISM: 18
  • TRACK: 6846
  • TRAIL: 7726
  • TRANSMITTER: 33
  • TREE: 1442842
  • VIEW-TOWER: 529
  • WALL: 19664
  • WATERTOWER: 32

Khe Sanh

  • BUILDING: 91
  • BUNKER: 4861
  • BUSH: 1299130
  • FENCE: 2196
  • FOUNTAIN: 2
  • FUELSTATION: 3
  • HIDE: 228731
  • HOUSE: 5754
  • POWER LINES: 801
  • ROAD: 7755
  • ROCK: 33853
  • TRACK: 8156
  • TRANSMITTER: 3
  • TREE: 1145377
  • VIEW-TOWER: 227
  • WALL: 9078
  • WATERTOWER: 13

The Bra

  • BUILDING: 8
  • BUNKER: 265
  • BUSH: 179428
  • FENCE: 251
  • HIDE: 56960
  • HOUSE: 522
  • POWER LINES: 25
  • ROAD: 7
  • ROCK: 671
  • SHIPWRECK: 2
  • TRACK: 584
  • TRAIL: 2767
  • TRANSMITTER: 1
  • TREE: 203443
  • VIEW-TOWER: 48
  • WALL: 2076

Gabreta

  • BUILDING: 222
  • BUSH: 383449
  • BUSSTOP: 18
  • CHAPEL: 10
  • CHURCH: 11
  • CROSS: 17
  • FENCE: 25616
  • FORTRESS: 149
  • FOUNTAIN: 2
  • FUELSTATION: 11
  • HIDE: 582635
  • HOSPITAL: 1
  • HOUSE: 6352
  • MAIN ROAD: 4427
  • POWER LINES: 502
  • POWERSOLAR: 2
  • RAILWAY: 1923
  • ROAD: 8693
  • ROCK: 918
  • RUIN: 5
  • SHIPWRECK: 1
  • STACK: 6
  • TRACK: 10066
  • TRAIL: 1170
  • TRANSMITTER: 2
  • TREE: 3473175
  • VIEW-TOWER: 39
  • WALL: 6218
  • WATERTOWER: 8

Sefrou-Ramal

  • BUILDING: 2
  • BUSH: 13669
  • FENCE: 5199
  • FUELSTATION: 2
  • HIDE: 23243
  • HOUSE: 1963
  • MAIN ROAD: 403
  • POWER LINES: 565
  • POWERWIND: 19
  • RAILWAY: 135
  • ROAD: 199
  • ROCK: 1183
  • TRACK: 3286
  • TRANSMITTER: 9
  • TREE: 7592
  • WALL: 3560
  • WATERTOWER: 2

Spearhead 1944 Normandy

  • BUILDING: 2918
  • BUNKER: 1703
  • BUSH: 608441
  • CHURCH: 45
  • CROSS: 16
  • FENCE: 288630
  • FORTRESS: 196
  • FOUNTAIN: 1286
  • HIDE: 330656
  • HOUSE: 12837
  • MAIN ROAD: 1981
  • RAILWAY: 776
  • ROAD: 20237
  • ROCK: 837
  • RUIN: 1
  • SMALL TREE: 20
  • TRACK: 29761
  • TRAIL: 6365
  • TREE: 581549
  • VIEW-TOWER: 95
  • WALL: 60793
  • WATERTOWER: 34

Spearhead 1944 Mortain

  • BUILDING: 759
  • BUNKER: 597
  • BUSH: 192944
  • CHURCH: 7
  • CROSS: 3
  • FENCE: 66361
  • FORTRESS: 35
  • FOUNTAIN: 320
  • HIDE: 140143
  • HOUSE: 3120
  • MAIN ROAD: 551
  • RAILWAY: 733
  • ROAD: 4276
  • ROCK: 1896
  • SMALL TREE: 19
  • TRACK: 11268
  • TRAIL: 996
  • TREE: 291745
  • VIEW-TOWER: 65
  • WALL: 13364
  • WATERTOWER: 13


Extraction script can be found on the Biki Export Scripts page.
↑ Back to spoiler's top
Groups:
Object Detection

Syntax

Syntax:
nearestTerrainObjects [position, types, radius, sort, 2Dmode]
Parameters:
position: Object, PositionAGL or Position2D - where to find objects, center position
types: Array - list of case-insensitive types of the objects to search for. [] to search without filters
radius: Number - range from center position to search for objects
since Arma 3 logo black.png1.62
sort: Boolean - (Optional, default true) sort objects by distance to the center or not - setting to false greatly improves performance
since Arma 3 logo black.png1.66
2Dmode: Boolean - (Optional, default false) the object search and sorting mode: true - 2D, false - 3D
Return Value:
Array - array of terrain objects. Before Arma 3 v2.00 this command did not return roads of type "ROAD", "MAIN ROAD", "TRACK", "TRAIL"

Examples

Example 1:
nearestTerrainObjects [player, ["Tree", "Bush"], 200];
Example 2:
nearestTerrainObjects [player, ["House"], 200];
Example 3:
nearestTerrainObjects [[2716, 2949, 0], ["Chapel", "Fuelstation"], 100];
Example 4:
Return every terrain object in 50 metres radius around player sorted, closest first:
nearestTerrainObjects [player, [], 50];
Example 5:
Return every terrain object in 50 metres radius around player unsorted:
nearestTerrainObjects [player, [], 50, false];
Example 6:
Hide all terrain objects (run locally for each client):
private _allTerrainObjects = nearestTerrainObjects [ [worldSize / 2, worldSize / 2], [], worldSize * sqrt 2 / 2, false, true ]; { _x hideObject true } forEach _allTerrainObjects;

Additional Information

See also:
nearestObjects findNearestEnemy hideObject nearestBuilding nearestObject nearObjects nearestLocation nearEntities nearTargets nearSupplies nearestLocationWithDubbing nearObjectsReady nearRoads roadsConnectedTo roadAt isOnRoad getRoadInfo nearestMines

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Killzone_Kid - c
Posted on Oct 31, 2016 - 00:20 (UTC)
Since Arma 3 v1.66 the default sorting is done according to 3D distance not distance2D as before. This is an attempt to correct some very old bug in implementation.
Demellion - c
Posted on Dec 28, 2016 - 20:21 (UTC)
Be aware that some terrain objects types might be tricky to be found, such as terrain rocks and boulders which are not considered to be "ROCKS" or "ROCK", but "HIDE". Example:
nearestTerrainObjects [player, ["HIDE"], 20]; // [939688: bluntstone_01.p3d,939691: garbagebags_f.p3d,939671: wreck_car_f.p3d,939692: junkpile_f.p3d]
Killzone_Kid - c
Posted on Jun 07, 2020 - 14:16 (UTC)
Large bridges are map type "ROAD". Small foot bridges are not roads and not included into road net.