Jump to content
celludriel

[Release] Shk_Pos_Functions

Recommended Posts

 

Shk Pos Functions Library

 

Description

The Shk_Pos library has been around for a long time and a lot of us use it.  However it wasn't maintained in a few years either and arma 3 has evolved over those years.  At a certain point I was working on a project and needed something called remote to give me a random position.  However with the way Shk_Pos was written this wasn't as easy as calling remoteExec.  So I dove into the Shk_Pos code and migrated it to a function library.  Recently I asked Shuko if he wanted to include my changes in his source code.  He told me that he hasn't been involved in arma 3 for years and I was free to do what I could with any of his code.  Therefor I added the code to github and I'm releasing Shk_Pos_Functions 1.0.  It is still all of Shuko's work, just in another form.  You do not have to upgrade any of your missions code if you don't want to.  However if you start a new project, you might want to consider using this library instead of the old one.

 

Should I made a mistake in the conversion and left in a bug or an old bug arises that needs fixing, please let me know or checkout the repository making a pull request.  Lets keep this great library updated and maintained together as a community.

 

Information

GitHub Repository: https://github.com/Celludriel/shk_pos_functions

Release zip: https://github.com/Celludriel/shk_pos_functions/archive/1.0.0.zip

 

Documentation

each small utility function the library uses can be called as well , I will document them later on to complete the documentation

 

findPosition

Spoiler

Select a random position based on anchor position, direction and distance.

usage: position = [anchorPosition, distance, direction, water, road, emptyspace] call ShkPos_fnc_findPosition;

params:

  • anchorPosition: Position to start search from
  • distance: How far out to search
  • direction: Direction to search in 0 - 360
  • water: 0 water not allowed, 1 doesn't matter if water or not, 2 only water allowed
  • road: 0 Road positions not taken in account, 1 Road position preferred, 2 only road position accepted
  • emptyspace: Array, Number, Object or Vehicle Type.  Force finding large enough empty position.
    • [300,heli]: Array with distance and vehicle object.
    • 350: Only distance given
    • (typeof heli): Only vehicle type given
    • heli: Only vehicle object given

output:

  • position: Random position returned based on the parameters given

 

findRandomPositionInMarker

Spoiler

Select a random position from an area defined by a marker.

usage: position = [marker, water, blacklist, emptyspace] call ShkPos_fnc_findRandomPositionInMarker;

params:

  • marker: Marker to search a random position in
  • water: 0 water not allowed, 1 doesn't matter if water or not, 2 only water allowed
  • blacklist: Array of markers that are blacklisted to give a position in
  • emptyspace: Array, Number, Object or Vehicle Type.  Force finding large enough empty position.
    • [300,heli]: Array with distance and vehicle object.
    • 350: Only distance given
    • (typeof heli): Only vehicle type given
    • heli: Only vehicle object given

output:

  • position: Random position returned based on the parameters given

 

findClosestPosition

Spoiler

Return the closest position from array to the positionA.

usage: position = [originPosition, [targetPositions]] call ShkPos_fnc_findClosestPosition;

params:

  • originPosition: Position to find closest target position to
  • [targetPositions]: Array containing positions to look through

output:

  • position: closest position to originPosition selected from [targetPositions]

 

getMarkerCorners

Spoiler

Return all the corners of a marker.

usage: [corners] = [marker] call ShkPos_fnc_getMarkerCorners;

params:

  • marker: Marker to get the corners from

output:

  • corners: Array containing all the corners of the marker

 

getMarkerShape

Spoiler

Return the shape of a marker.

usage: shape = [marker] call ShkPos_fnc_getMarkerShape;

params:

  • marker: Marker to get the shape from

output:

  • shape : Shape of the marker (SQUARE, RECTANGLE, CIRCLE, ELLIPSE, ICON) as a string value

 

getPos

Spoiler

Return a position from an anchor over a distance in a given direction.

usage: position = [anchorPosition,distance,direction] call ShkPos_fnc_getPos;

params:

  • anchorPosition: Position to start search from
  • distance: How far out to search
  • direction: Direction to search in 0 - 360

output:

  • position: Resulting position

 

getPosFromCircle

Spoiler

Return a random position in a circle with marker as epicentre.

usage: position = [marker] call ShkPos_fnc_getPosFromCircle;

params:

  • marker: Marker to use as epicentre the size of the marker determines the size of the circle to look in

output:

  • position: Resulting position in circle

 

getPosFromEllipse

Spoiler

Return a random position in an ellipse with marker as epicentre.

usage: position = [marker] call ShkPos_fnc_getPosFromEllipse;

params:

  • marker: Marker to use as epicentre the size of the marker determines the size of the ellipse to look in

output:

  • position: Resulting position in ellipse

 

getPosFromRectangle

Spoiler

Return a random position in a rectangle with marker as epicentre.

usage: position = [marker] call ShkPos_fnc_getPosFromRectangle;

params:

  • marker: Marker to use as epicentre the size of the marker determines the size of the rectangle to look in

output:

  • position: Resulting position in rectangle

 

getPosFromSquare

Spoiler

Return a random position in a square with marker as epicentre.

usage: position = [marker] call ShkPos_fnc_getPosFromSquare;

params:

  • marker: Marker to use as epicentre the size of the marker determines the size of the square to look in

output:

  • position: Resulting position in square

 

isBlacklisted

Spoiler

Check if a position should be blacklisted. (not sure this method is meant to be called outside of the inner methods of shk_pos)

usage: blacklisted = [position, blacklistMarker] call ShkPos_fnc_isBlacklisted;

params:

  • position: Position to check if it is to be blacklisted
  • blacklistMarker: Marker to check the position is in

output:

  • blacklisted: Boolean indicating if the position is in the given marker or not

 

isInCircle

Spoiler

Checks if position is in the marker as a circle

usage: boolean = [position, marker] call ShkPos_fnc_inCircle;

params:

  • position: Position to check if it is in the circle
  • marker: Marker to check the position is in

output:

  • boolean: Indicator if it's in the circle or not

 

isInEllipse

Spoiler

Checks if position is in the marker as an ellipse

usage: boolean = [position, marker] call ShkPos_fnc_inEllipse;

params:

  • position: Position to check if it is in the ellipse
  • marker: Marker to check the position is in

output:

  • boolean: Indicator if it's in the ellipse or not

 

isInRectangle

Spoiler

Checks if position is in the marker as a rectangle

usage: boolean = [position, marker] call ShkPos_fnc_inRectangle;

params:

  • position: Position to check if it is in the rectangle
  • marker: Marker to check the position is in

output:

  • boolean: Indicator if it's in the rectangle or not

 

isSamePosition

Spoiler

Checks if two positions are the same by only comparing X and Y coordinates, ignoring Z.

usage: boolean = [positionA, positionB] call ShkPos_fnc_isSamePosition;

params:

  • positionA: Source position to check
  • positionB: Target position to check

output:

  • boolean: Indicator if two positions are the same

 

rotatePosition

Spoiler

Rotates a position

usage: rotatedPosition = [position, direction] call ShkPos_fnc_rotatePosition;

params:

  • position: Position to rotate
  • direction: Direction to rotate in 0-360

output:

  • rotatedPosition: The rotated position in given direction 

 

  • Like 3

Share this post


Link to post
Share on other sites

Thanks for sharing this. Are you planning to update any other of Shko's scripts (especially AISSP)?

Share this post


Link to post
Share on other sites
1 hour ago, orcinus said:

Thanks for sharing this. Are you planning to update any other of Shko's scripts (especially AISSP)?

 

Unfortunately I'm to busy with my own projects at the moment to do anything like that.  I had to use shkPos in this new form and asked shuko if I was allowed to share it, which he agreed to.

Share this post


Link to post
Share on other sites

thanks for releasing!

 

anyone compared this to bis_fnc_findsafepos yet? if it has same issue with spawning units inside rocks (even with 10m distance to objects)?

Share this post


Link to post
Share on other sites
14 hours ago, orcinus said:

Thanks for sharing this. Are you planning to update any other of Shko's scripts (especially AISSP)?

 

sorry, but AISSP was spunFIN.or LostVar as per link site name....here

  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, Johnny Drama said:

thanks for releasing!

 

anyone compared this to bis_fnc_findsafepos yet? if it has same issue with spawning units inside rocks (even with 10m distance to objects)?

 

I never had such problems with shkpos, but like most tools a lot depends on how you use it.  You could try it out, find a location with a lot of rocks and do a random pos in circle of 10m radius and see what the results are.

Share this post


Link to post
Share on other sites
17 hours ago, KevsNoTrev said:

 

sorry, but AISSP was spunFIN.or LostVar as per link site name....here

Duh! Quite right, must have had a brainfart.

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×