findEmptyPosition: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
(Fix description)
 
(59 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma2 |= Game name
|game1= arma2
|version1= 1.00


|1.00|= Game version
|game2= arma2oa
____________________________________________________________________________________________
|version2= 1.50


| Searches for an empty position around specified position. The search starts looking for an empty position at a minimum distance of [minDistance] from the [center] and looks as far away as [maxDistance]. If a [vehicleType] parameter is specified, then the search will look for an empty positions that is big enough to hold that vehicle type. If an empty position isn't found, an empty array is returned.
|game3= tkoh
|version3= 1.00


<br><br>This command ignores moving objects present within search area. |= Description
|game4= arma3
____________________________________________________________________________________________
|version4= 0.50


| center '''findEmptyPosition''' [minDistance, maxDistance, vehicleType] |= Syntax
|gr1= Positions


|p1= center: [[Array]] - Search area center position in format [x,y] or [x,y,z] in which case z is ignored. Accepts [[Position2D]] or [[Position3D]] |= PARAMETER1
|descr= Searches for an empty area around the specified position, starting from the ''center'' looking for an empty ''areaRadius'' and looks as far away as ''areaRadius'' + ''maxDistance''.
|p2= [minDistance, maxDistance, vehicleType]: [[Array]]|=
This command ignores moving objects present within the search area. The search area can be preloaded with [[findEmptyPositionReady]] command.
|p3= minDistance: [[Number]] - Start searching no closer than minDistance from the center |= PARAMETER2
|p4= maxDistance: [[Number]] - Stop searching no further than maxDistance from the center |= PARAMETER3
|p5= vehicleType: (optional): [[String]] - Class name of a vehicle to accommodate |= PARAMETER4


| [[Array]] - A suitable empty position in format [[Position3D]] or [] if not found |= RETURNVALUE
{{Feature|informative|
This command does not work outside of [[worldSize|world dimensions]] and will always return the provided ''center''.
Objects outside the world dimensions will not be considered in the detection either.
}}
 
|s1= center [[findEmptyPosition]] [areaRadius, maxDistance, vehicleType]
 
|p1= center: [[Array]] format [[Position#Introduction|Position2D]] or [[Position#Introduction|Position3D]] - search area center position in format [x,y] or [x,y,z] in which case z is ignored
 
|p2= areaRadius: [[Number]] - wanted area radius
 
|p3= maxDistance: [[Number]] - stop searching no further than {{hl|areaRadius + maxDistance}} from the center
 
|p4= vehicleType: [[String]] - (Optional) classname of a vehicle to accommodate
 
|r1= [[Array]] - a suitable empty position in format [[Position#Introduction|Position3D]] or empty array <sqf inline>[]</sqf> if not found
 
|x1= <sqf>_position = getPosASL player findEmptyPosition [0, 100];</sqf>
 
|x2= <sqf>_position = _center findEmptyPosition [10,100,"UH60M_EP1"];</sqf>


|x1= <code>_position = ([[getPosATL]] [[player]]) [[findEmptyPosition]] [0,100];</code>|= EXAMPLE1
|x2= <code>_position = _center [[findEmptyPosition]] [10,100,"UH60M_EP1"];</code>|= EXAMPLE2
|x3= Check if exact position is empty:
|x3= Check if exact position is empty:
<code>_position = _center [[findEmptyPosition]] [0,0,"B_Boat_Armed_01_minigun_F"];</code>|= EXAMPLE3
<sqf>_position = _center findEmptyPosition [0, 0, "B_Boat_Armed_01_minigun_F"];</sqf>


____________________________________________________________________________________________
|seealso= [[findEmptyPositionReady]] [[selectBestPlaces]] [[isFlatEmpty]] [[BIS_fnc_findSafePos]]
}}


| [[findEmptyPositionReady]], [[selectBestPlaces]], [[isFlatEmpty]] |= SEEALSO
{{Note
 
|user= Killzone_Kid
|  |= MPBEHAVIOUR
|timestamp= 20131106181000
____________________________________________________________________________________________
|text= Keep search radius short and sweet, under 50 metres maybe. Searching big area takes long time and will result in your game stop responding until the search is over. [[isFlatEmpty]] is probably more suitable for a larger area search.
}}
}}


<h3 style='display:none'>Notes</h3>
{{Note
<dl class='command_description'>
|user= old_man_auz
<!-- Note Section BEGIN -->
|timestamp= 20120306005000
<dd class="notedate">Posted on November 6, 2013
|text= I think the '''radius''' parameter should be treated as a 'minimum distance' from the '''centre''' position. I found that the parameter name '''radius''' was not very clear. Also, if '''radius''' is greater than '''max distance''' then the function will always return an empty array.
<dt class="note">'''[[User:Killzone_Kid|Killzone_Kid]]'''
<dd class="note">
Keep search radius short and sweet, under 50 metres maybe. Searching big area takes long time and will result in your game stop responding until the search is over. [[isFlatEmpty]] is probably more suitable for a larger area search.
<dd class="notedate">Posted on March 6, 2012
<dt class="note">'''[[User:old_man_auz|old_man_auz]]'''
<dd class="note">
I think the '''radius''' parameter should be treated as a 'minimum distance' from the '''centre''' position. I found that the parameter name '''radius''' wasn't very clear. Also, if '''radius''' is greater than '''max distance''' then the function will always return an empty array.


Here is an snippet of code I use to find a safe landing zone for an extraction helicopter. It may be useful for someone.
Here is an snippet of code I use to find a safe landing zone for an extraction helicopter. It may be useful for someone.
<code>_centre = [ getMarkerPos "marker" , random 150 , random 360 ] call BIS_fnc_relPos;
<sqf>
_centre = [getMarkerPos "marker", random 150, random 360] call BIS_fnc_relPos;
_extraction_point = [];
_extraction_point = [];
_max_distance = 100;
_max_distance = 100;
while{ count _extraction_point < 1 } do
while { count _extraction_point < 1 } do
{
{
_extraction_point = _centre findEmptyPosition[ 30 , _max_distance , "UH60M_EP1" ];
_extraction_point = _centre findEmptyPosition [30, _max_distance, "UH60M_EP1"];
_max_distance = _max_distance + 50;
_max_distance = _max_distance + 50;
};
};
</code>
</sqf>
In the above example, make sure that "_max_distance" is greater than 30, otherwise the while loop will go forever.
In the above example, make sure that "_max_distance" is greater than 30, otherwise the while loop will go forever.
 
}}
<!-- Note Section END -->
</dl>
 
<h3 style='display:none'>Bottom Section</h3>
[[Category:ArmA 2: New Scripting Commands List|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Latest revision as of 00:21, 21 December 2022

Hover & click on the images for description

Description

Description:
Searches for an empty area around the specified position, starting from the center looking for an empty areaRadius and looks as far away as areaRadius + maxDistance. This command ignores moving objects present within the search area. The search area can be preloaded with findEmptyPositionReady command.
This command does not work outside of world dimensions and will always return the provided center. Objects outside the world dimensions will not be considered in the detection either.
Groups:
Positions

Syntax

Syntax:
center findEmptyPosition [areaRadius, maxDistance, vehicleType]
Parameters:
center: Array format Position2D or Position3D - search area center position in format [x,y] or [x,y,z] in which case z is ignored
areaRadius: Number - wanted area radius
maxDistance: Number - stop searching no further than areaRadius + maxDistance from the center
vehicleType: String - (Optional) classname of a vehicle to accommodate
Return Value:
Array - a suitable empty position in format Position3D or empty array [] if not found

Examples

Example 1:
_position = getPosASL player findEmptyPosition [0, 100];
Example 2:
_position = _center findEmptyPosition [10,100,"UH60M_EP1"];
Example 3:
Check if exact position is empty:
_position = _center findEmptyPosition [0, 0, "B_Boat_Armed_01_minigun_F"];

Additional Information

See also:
findEmptyPositionReady selectBestPlaces isFlatEmpty BIS_fnc_findSafePos

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 Nov 06, 2013 - 18:10 (UTC)
Keep search radius short and sweet, under 50 metres maybe. Searching big area takes long time and will result in your game stop responding until the search is over. isFlatEmpty is probably more suitable for a larger area search.
old_man_auz - c
Posted on Mar 06, 2012 - 00:50 (UTC)
I think the radius parameter should be treated as a 'minimum distance' from the centre position. I found that the parameter name radius was not very clear. Also, if radius is greater than max distance then the function will always return an empty array. Here is an snippet of code I use to find a safe landing zone for an extraction helicopter. It may be useful for someone.
_centre = [getMarkerPos "marker", random 150, random 360] call BIS_fnc_relPos; _extraction_point = []; _max_distance = 100; while { count _extraction_point < 1 } do { _extraction_point = _centre findEmptyPosition [30, _max_distance, "UH60M_EP1"]; _max_distance = _max_distance + 50; };
In the above example, make sure that "_max_distance" is greater than 30, otherwise the while loop will go forever.