BIS fnc inTrigger: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(can detect in markers and locations as well)
m (Text replacement - "(\|[pr][0-9]+ *= *[^- ]*) *- *P([a-gi-z ])" to "$1 - p$2")
 
(48 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{RV|type=function


{{Function|= Comments
|game1= arma2
____________________________________________________________________________________________
|version1= 1.00


| arma2 |= Game name
|game2= arma2oa
|version2= 1.50


|1.00|= Game version
|game3= tkoh
____________________________________________________________________________________________
|version3= 1.00


| Detects whether position is within area (Since Arma 3 v1.57 an engine solution is available [[inArea]]) '''or''' calculates distance to the nearest edge of trigger area by using optional params.|= Description
|game4= arma3
____________________________________________________________________________________________
|version4= 0.50


| [area, position, returnDistance, includeFloorCeiling] call [[BIS_fnc_inTrigger]] |= Syntax
|gr1= Object Manipulation


|p1= area: [[Object]] - trigger, [[String]] - marker, [[Location]] - location or [[Array]] - [[Triggers|Trigger]] or area in format [center, distance] or [center, [a, b, angle, rect]] or [center, [a, b, angle, rect, height]]|=
|descr= Detects whether position is within area '''or''' calculates distance to the nearest edge of trigger area by using optional params.
|p2= position: [[Object]] or [[Array]] - Position to check (e.g. player) or [[Position]] |=
{{Feature|arma3|Since {{arma3}} v1.57 [[inArea]] is available for an area check.}}
|p3= returnDistance (Optional): [[Boolean]] - [[true]] to return distance to nearest edge of trigger area. Default: [[false]] |=
|p4= includeFloorCeiling (Optional): [[Boolean]] - [[true]] to include trigger area floor and ceiling in calculation when calculating distance to nearest edge. Default: [[false]] |=
| [[Boolean]] - [[true]] when position is in area, false if not
<br>
'''or'''
<br>[[Number]] - (when ''returnDistance'' is [[true]]) - distance from closest border: negative distance - from inside, positive distance - from outside |= Return value
____________________________________________________________________________________________


|x1= <code>_trigger = [[createTrigger]] ["EmptyDetector", [[getPosATL]] [[player]]];
|s1= [area, position, returnDistance, includeFloorCeiling] call [[BIS_fnc_inTrigger]]
_trigger [[setTriggerArea]] [10, 10, 0, false];
_inTrigger = [_trigger, [[player]]] call [[BIS_fnc_inTrigger]]; //_inTrigger = true</code> |=
____________________________________________________________________________________________


| [[createTrigger]], [[createMarker]], [[setTriggerArea]], [[setMarkerSize]], [[triggerArea]], [[markerSize]], [[inArea]], [[inAreaArray]] |= See also
|p1= area: [[Object]], [[String]], [[Location]] or [[Array]]
* [[Object]] - trigger
* [[String]] - marker
* [[Location]] - location
* [[Array]] - in format [center, distance] or [center, [a, b, angle, rect]] or [center, [a, b, angle, rect, height]]


}}
|p2= position: [[Object]] or [[Array]] - position to check (e.g. [[player]]) or [[Position]]


<h3 style="display:none">Notes</h3>
|p3= returnDistance: [[Boolean]] - (Optional, default [[false]]) [[true]] to return distance to nearest edge of trigger area
<dl class="command_description">
<!-- Note Section BEGIN -->


<!-- Note Section END -->
|p4= includeFloorCeiling: [[Boolean]] - (Optional, default [[false]]) to include trigger area floor and ceiling in calculation when calculating distance to nearest edge
</dl>


<h3 style="display:none">Bottom Section</h3>
|r1=
[[Category:Function Group: Misc|{{uc:inTrigger}}]]
* [[Boolean]] - [[true]] when position is in area, false if not
[[Category:Functions|{{uc:inTrigger}}]]
* [[Number]] - (when ''returnDistance'' is [[true]]) - distance from closest border: negative distance - from inside, positive distance - from outside
[[Category:{{Name|arma2}}: Functions|{{uc:inTrigger}}]]
[[Category:{{Name|arma2oa}}: Functions|{{uc:inTrigger}}]]
[[Category:{{Name|tkoh}}: Functions|{{uc:inTrigger}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:inTrigger}}]]


<!-- CONTINUE Notes -->
|x1= <sqf>
<dl class="command_description">
private _trigger = createTrigger ["EmptyDetector", getPosATL player];
<dd class="notedate">Posted on May 6, 2015 - 19:34 (UTC)</dd>
_trigger setTriggerArea [10, 10, 0, false];
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
_inTrigger = [_trigger, player] call BIS_fnc_inTrigger; // _inTrigger = true
<dd class="note">
</sqf>
Works with markers too:
<code>inMarker <nowiki>=</nowiki> ["markername", _position] [[call]] [[BIS_fnc_inTrigger]];</code>
</dd>
</dl>
<!-- DISCONTINUE Notes -->


<!-- CONTINUE Notes -->
|seealso= [[createTrigger]] [[createMarker]] [[setTriggerArea]] [[setMarkerSize]] [[triggerArea]] [[markerSize]] [[inArea]] [[inAreaArray]] [[BIS_fnc_getArea]]
<dl class="command_description">
}}
<dd class="notedate">Posted on October 4, 2015 - 11:14 (UTC)</dd>
<dt class="note">[[User:Larrow|Larrow]]</dt>
<dd class="note">
As of ["Arma 3","Arma3",152,132676,"Stable",true] this command is still broken if checking against markers that have axisB larger axisA.
To get around this if needed you can create your marker with the largest radius in axisA and rotate your marker by 90degrees.
</dd>
</dl>
<!-- DISCONTINUE Notes -->
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on October 4, 2015 - 11:22 (UTC)</dd>
<dt class="note">[[User:Larrow|Larrow]]</dt>
<dd class="note">
Also works with [ pos, radius ]
<code>[ [position, radius], player ] call BIS_fnc_inTrigger</code>
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 16:45, 8 November 2023

Hover & click on the images for description

Description

Description:
Detects whether position is within area or calculates distance to the nearest edge of trigger area by using optional params.
Arma 3
Since Arma 3 v1.57 inArea is available for an area check.
Execution:
call
Groups:
Object Manipulation

Syntax

Syntax:
[area, position, returnDistance, includeFloorCeiling] call BIS_fnc_inTrigger
Parameters:
area: Object, String, Location or Array
  • Object - trigger
  • String - marker
  • Location - location
  • Array - in format [center, distance] or [center, [a, b, angle, rect]] or [center, [a, b, angle, rect, height]]
position: Object or Array - position to check (e.g. player) or Position
returnDistance: Boolean - (Optional, default false) true to return distance to nearest edge of trigger area
includeFloorCeiling: Boolean - (Optional, default false) to include trigger area floor and ceiling in calculation when calculating distance to nearest edge
Return Value:
  • Boolean - true when position is in area, false if not
  • Number - (when returnDistance is true) - distance from closest border: negative distance - from inside, positive distance - from outside

Examples

Example 1:
private _trigger = createTrigger ["EmptyDetector", getPosATL player]; _trigger setTriggerArea [10, 10, 0, false]; _inTrigger = [_trigger, player] call BIS_fnc_inTrigger; // _inTrigger = true

Additional Information

See also:
createTrigger createMarker setTriggerArea setMarkerSize triggerArea markerSize inArea inAreaArray BIS_fnc_getArea

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