nearestTerrainObjects: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\| *arma3 * * *\| *([0-2]\.[0-9]{2}) * " to "|game1= arma3 |version1= $1 ")
m (Add Columns template usage)
Line 20: Line 20:
{{Feature|Informative|Types which are missing are not present in the given world. [[Virtual Reality]] has no terrain objects. Last updated {{GVI|arma3|1.99}}}}
{{Feature|Informative|Types which are missing are not present in the given world. [[Virtual Reality]] has no terrain objects. Last updated {{GVI|arma3|1.99}}}}
<big>[[Stratis]]</big>
<big>[[Stratis]]</big>
<div style="columns: 5">
{{Columns|5|
* BUSH: 47974
* BUSH: 47974
* CHAPEL: 2
* CHAPEL: 2
Line 37: Line 37:
* WALL: 1355
* WALL: 1355
* WATERTOWER: 1
* WATERTOWER: 1
</div>
}}


<big>[[Altis]]</big>
<big>[[Altis]]</big>
<div style="columns: 5">
{{Columns|5|
* BUSH: 747193
* BUSH: 747193
* CHAPEL: 165
* CHAPEL: 165
Line 66: Line 66:
* WALL: 38943
* WALL: 38943
* WATERTOWER: 10
* WATERTOWER: 10
</div>
}}


<big>[[Malden 2035]]</big>
<big>[[Malden 2035]]</big>
<div style="columns: 5">
{{Columns|5|
* BUSH: 288461
* BUSH: 288461
* BUSSTOP: 45
* BUSSTOP: 45
Line 91: Line 91:
* WALL: 14189
* WALL: 14189
* WATERTOWER: 63
* WATERTOWER: 63
</div>
}}


<big>[[Tanoa]]</big>
<big>[[Tanoa]]</big>
<div style="columns: 5">
{{Columns|5|
* BUSH: 754347
* BUSH: 754347
* CHURCH: 21
* CHURCH: 21
Line 116: Line 116:
* WALL: 20526
* WALL: 20526
* WATERTOWER: 73
* WATERTOWER: 73
</div>
}}


<big>[[Livonia]]</big>
<big>[[Livonia]]</big>
<div style="columns: 5">
{{Columns|5|
* BUILDING: 1262
* BUILDING: 1262
* BUNKER: 40
* BUNKER: 40
Line 146: Line 146:
* WALL: 4418
* WALL: 4418
* WATERTOWER: 7
* WATERTOWER: 7
</div>
}}


<big>[[Weferlingen]]</big>
<big>[[Weferlingen]]</big>
<div style="columns: 5">
{{Columns|5|
* BUILDING: 5072
* BUILDING: 5072
* BUSH: 731315
* BUSH: 731315
Line 168: Line 168:
* TREE: 829449
* TREE: 829449
* VIEW-TOWER: 34
* VIEW-TOWER: 34
</div>
}}


<big>[[Weferlingen (Winter)]]</big>
<big>[[Weferlingen (Winter)]]</big>
<div style="columns: 5">
{{Columns|5|
* BUILDING: 5072
* BUILDING: 5072
* BUSH: 519827
* BUSH: 519827
Line 190: Line 190:
* TREE: 829449
* TREE: 829449
* VIEW-TOWER: 34
* VIEW-TOWER: 34
</div>
}}


<syntaxhighlight lang="cpp">[] spawn
<syntaxhighlight lang="cpp">[] spawn

Revision as of 18:18, 14 June 2021

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:"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"

Since Arma 3 v1.62 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.
Since Arma 3 v1.66 it is possible to switch search and sorting mode between 2D and 3D.
Since Arma 3 v2.00 this command also returns missing roads: "ROAD", "MAIN ROAD", "TRACK", "TRAIL"

Types which are missing are not present in the given world. Virtual Reality has no terrain objects. Last updated Arma 3 logo black.png1.99

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
[] spawn
{
  private _types = ["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"];

  _types sort true;

  private _counts = [];
  private _countTypes = count _types;

  ["R3vo_GetNearestTerrainObjects",""] call BIS_fnc_startLoadingScreen;

  {
    private _terrainObjects = nearestTerrainObjects
    [
      [worldSize / 2, worldSize / 2],
      [_x],
      worldSize,
      false
    ];

    if (count _terrainObjects > 0) then
    {
      _counts pushBack [_x,count _terrainObjects];
    };
    ((_forEachIndex + 1) / _countTypes) call BIS_fnc_progressLoadingScreen;
  } forEach _types;

  "R3vo_GetNearestTerrainObjects" call BIS_fnc_endLoadingScreen;

  private _export = "<big>[[" + getText (configFile >> "CfgWorlds" >> worldName >> "description") + "]]</big>" + endl + '<div style="columns: 5">';

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

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

  copyToClipboard _export;
};
↑ 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
sort: Boolean - (Optional, default true) sort objects by distance to the center or not Template:Since
2Dmode: Boolean - (Optional, default false) the object search and sorting mode: true - 2D, false - 3D Template:Since
Return Value:
Array - array of terrain objects

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 nearestTerrainObjects could find: if (isServer) then { private _allTerrainObjects = nearestTerrainObjects [ [worldSize / 2, worldSize / 2], [], worldSize * sqrt 2 / 2, false ]; { _x hideObjectGlobal true } forEach _allTerrainObjects; };

Additional Information

See also:
nearestObjectsfindNearestEnemyhideObjectnearestBuildingnearestObjectnearObjectsnearestLocationnearEntitiesnearTargetsnearSuppliesnearestLocationWithDubbingnearObjectsReadynearRoadsroadsConnectedToroadAtisOnRoadgetRoadInfo

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
Posted on October 31, 2016 - 00:20 (UTC)
Killzone Kid
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.
Posted on December 28, 2016 - 20:21 (UTC)
Demellion
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]
Posted on June 7, 2020 - 14:16 (UTC)
killzone_kid
Large bridges are map type "ROAD". Small foot bridges are not roads and not included into road net.