{"name":"isFlatEmpty","operator":null,"title":"isFlatEmpty","type":"command","url":"https://community.bistudio.com/wiki/isFlatEmpty","revid":377421,"updated":"2026-01-02T06:45:31Z","groups":["Positions"],"status":"ok","replaced_by":[],"games":[{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma2","name":"Arma 2","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Checks given position against given filter params. Filter includes checks for:\n- If there are any objects closer than given distance from given position (in 2D)\n- If the area around position is flat enough to match given gradient\n- If the given position is over water or land\n- If the given position is over shore line\nThe gradient seems to correlate with general hill steepness: 0.1 (10%) ~6°, 0.5 (50%) ~27°, 1.0 (100%) ~45°, etc.\n\n> [!NOTE]\n> See also BIS_fnc_findSafePos.","syntaxes":[{"syntax":"position isFlatEmpty [minDistance, mode, maxGradient, maxGradientRadius, overLandOrWater, shoreLine, ignoreObject]","since":null,"effect":null,"exec":null,"params":[{"name":"position","type":"PositionAGL","optional":false,"default":null,"description":null,"types":["PositionAGL"],"since":null,"text":"position: PositionAGL"},{"name":"minDistance","type":"Number","optional":true,"default":"-1","description":"minimum (2D) distance from other objects (range 0..50). -1 to ignore proximity check","types":["Number"],"since":null,"text":"minDistance: Number - (Optional, default -1) minimum (2D) distance from other objects (range 0..50). -1 to ignore proximity check"},{"name":"mode","type":"Number","optional":true,"default":"-1","description":"position check mode (**ALWAYS USE DEFAULT VALUE**)","types":["Number"],"since":null,"text":"mode: Number - (Optional, default -1) position check mode (**ALWAYS USE DEFAULT VALUE**)"},{"name":"maxGradient","type":"Number","optional":true,"default":"-1","description":"maximum terrain steepness allowed. -1 to ignore","types":["Number"],"since":null,"text":"maxGradient: Number - (Optional, default -1) maximum terrain steepness allowed. -1 to ignore"},{"name":"maxGradientRadius","type":"Number","optional":true,"default":"1","description":"how far to extend gradient check","types":["Number"],"since":null,"text":"maxGradientRadius: Number - (Optional, default 1) how far to extend gradient check"},{"name":"overLandOrWater","type":"Number","optional":true,"default":"0","description":"0: position cannot be over water\n- 2: position cannot be over land\n- -1 to ignore","types":["Number"],"since":null,"text":"overLandOrWater: Number - (Optional, default 0)\n- 0: position cannot be over water\n- 2: position cannot be over land\n- -1 to ignore"},{"name":"shoreLine","type":"Boolean","optional":true,"default":"false","description":"true: position is over shoreline (< ~25 m from water)\n- false to ignore","types":["Boolean"],"since":null,"text":"shoreLine: Boolean - (Optional, default false)\n- true: position is over shoreline (< ~25 m from water)\n- false to ignore"},{"name":"ignoreObject","type":"Object","optional":true,"default":"objNull","description":"object to ignore in proximity checks. objNull to ignore","types":["Object"],"since":null,"text":"ignoreObject: Object - (Optional, default objNull) object to ignore in proximity checks. objNull to ignore"}],"returns":{"type":"Array","types":["Array"],"description":"empty array [] if check failed or PositionASL if succeded. Resulting position will be original PositionAGL + getTerrainHeightASL","text":"Array - empty array [] if check failed or PositionASL if succeded. Resulting position will be original PositionAGL + getTerrainHeightASL"},"form":"binary","operator":null,"left":{"text":"position","types":["PositionAGL"]},"right":{"text":"[minDistance, mode, maxGradient, maxGradientRadius, overLandOrWater, shoreLine, ignoreObject]","types":["Array"]}}],"examples":[{"text":"Check if player position is over land:\n\n```sqf\n_overLand = !(position player isFlatEmpty [-1, -1, -1, -1, 0, false] isEqualTo []);\n```","code":["_overLand = !(position player isFlatEmpty [-1, -1, -1, -1, 0, false] isEqualTo []);"]},{"text":"Check if player position is over shore line:\n\n```sqf\n_overShore = !(position player isFlatEmpty  [-1, -1, -1, -1, 0, true] isEqualTo []);\n```","code":["_overShore = !(position player isFlatEmpty  [-1, -1, -1, -1, 0, true] isEqualTo []);"]},{"text":"Check if player position is over water:\n\n```sqf\n_overWater = !(position player isFlatEmpty  [-1, -1, -1, -1, 2, false] isEqualTo []);\n```","code":["_overWater = !(position player isFlatEmpty  [-1, -1, -1, -1, 2, false] isEqualTo []);"]},{"text":"Check if no object is closer than 5m to player position:\n\n```sqf\n_isEmpty = !(position player isFlatEmpty  [5, -1, -1, -1, -1, false, player] isEqualTo []);\n```","code":["_isEmpty = !(position player isFlatEmpty  [5, -1, -1, -1, -1, false, player] isEqualTo []);"]},{"text":"Check if area 10m around player position is relatively flat:\n\n```sqf\n_isFlat = !(position player isFlatEmpty  [-1, -1, 0.3, 10, -1] isEqualTo []);\n```","code":["_isFlat = !(position player isFlatEmpty  [-1, -1, 0.3, 10, -1] isEqualTo []);"]},{"text":"Check if area 15m around player position is very flat and empty:\n\n```sqf\n_isFlatEmpty = !(position player isFlatEmpty  [15, -1, 0.1, 15, -1, false, player] isEqualTo []);\n```","code":["_isFlatEmpty = !(position player isFlatEmpty  [15, -1, 0.1, 15, -1, false, player] isEqualTo []);"]}],"multiplayer":null,"problems":"- Objects accounted for proximity check seem to be static objects. Nearby vehicles and units do not seem to affect the output\n- Given position will be magically transferred into given position + getTerrainHeightASL value\n- The second element must be -1 (≤ 0 really) at all times, otherwise command becomes unusable\n- The command might be a bit heavy on computations so avoid frequent and large area checks","aliases":[],"see_also":["BIS_fnc_findSafePos","selectBestPlaces","findEmptyPosition"],"notes":[{"user":"Killzone_Kid","date":"2016-04-24T17:18:00Z","text":"When this command is instructed to check if area at given position is empty it takes into account the radius of the bounding sphere of surrounding objects. Because of this, the high voltage columns such as \"Land_HighVoltageColumnWire_F\" and such objects may appear extremely large to the calculations and the position will be rejected even if visually it doesn't look too bad. To avoid this, use findEmptyPosition command first to find guaranteed empty position, then pass the result to isFlatEmpty making sure you switched off proximity check by setting 1st param to -1. For example:\n\n```sqf\n// Check if given position is flat and empty within 1m radius\n[4274.66,12113,0.00139618] isFlatEmpty [1, -1, 0.1, 1, -1, false, objNull]; // []\n```\n\nThe result suggests it is not flat and empty.\n\n```sqf\n// Check if given position is flat within 1m radius\n[4274.66,12113,0.00139618] isFlatEmpty [-1, -1, 0.1, 1, -1, false, objNull]; // [4274.66,12113,48.3209]\n```\n\nThe result suggests it is.\n\n```sqf\n// Check if given position is empty within 1m radius\n[4274.66,12113,0.00139618] isFlatEmpty [1, -1, -1, -1, -1, false, objNull]; // []\n```\n\nThe result suggests it is not empty. But the position is in the middle of a road and there is nothing within 1m but there is \"Land_HighVoltageColumnWire_F\" not far.\n\n```sqf\n// Check if given position is empty within 1m radius ignoring nearest \"Land_HighVoltageColumnWire_F\"\n[4274.66,12113,0.00139618] isFlatEmpty [1, -1, -1, 1, -1, false, nearestObject [[4274.66,12113,0.00139618], \"Land_HighVoltageColumnWire_F\"]]; // [4274.66,12113,48.3209]\n```\n\nThe result now suggests it is empty. So instead of relying on internal proximity check we can combine both commands:\n\n```sqf\nfnc_isFlatEmpty =\n{\n    params [\"_pos\", \"_params\"];\n    _pos = _pos findEmptyPosition [0, _params select 0];\n    if (_pos isEqualTo []) exitWith {[]};\n    _params = +_params;\n    _params set [0, -1];\n    _pos = _pos isFlatEmpty _params;\n    if (_pos isEqualTo []) exitWith {[]};\n    _pos\n};\n\n// Test\n[[4274.66,12113,0.00139618], [1, -1, 0.1, 1, -1, false, objNull]] call fnc_isFlatEmpty; // [4274.53,12113,48.3175]\n```"}],"categories":["Arma 2: New Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Positions","Introduced with Arma 2 version 1.00","Scripting Commands","Take On Helicopters: Scripting Commands"]}