Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: BIS_fnc_findSafePos ?

  1. #1
    Gunnery Sergeant ArmAIIholic's Avatar
    Join Date
    Jun 15 2010
    Location
    Belgrade, Serbia
    Posts
    542

    Thumbs up BIS_fnc_findSafePos

    --[SOLVED]--

    Simple and straight question - what does this function do if it doesn't find safePos?

    Here is the copy of the code from BIS fnc help inside the game (click spoiler).

    Bonus questions:
    What is this configFile >> "CfgWorlds" >> worldName >> "Armory" >> "positionStart" ?
    What is that position? (assuming I don't provide some default position?)
    What is the blacklist?

    Thanx in advance.

    Spoiler:


    --EDIT--

    I found something very interesting about BIS location functions. There is also something about findSafePos...
    Trexian:
    Yeah, I've started using that findSafePos function to find spawn locations.

    That config line basically finds the entry "safeAnchorPosition" (pretty obvious). My understanding of that is that it is more or less the center of the map, or maybe the middle of the land mass for the map.

    I think the function just uses that as a starting point if no other point is passed to it.

    I'm trying to sort out the max gradient element, myself. Otherwise, it is a pretty helpful function.
    [...]
    I found this line in the taskpatrol function with the gradient element defined and have been using it with no problems.
    [...]
    Ah right - I remember seeing that, but it didn't click that it was a conversion from 60 degrees to radians: 60 * (pi / 180).
    Last edited by ArmAIIholic; Jul 18 2010 at 07:53.

  2. #2
    It uses the position of the "Armoury". If that isn't here it uses the centerPosition, which os roughly the center of the "island".

    configFile >> "CfgWorlds" >> worldName >> "Armory" >> "positionStart" is probably the position that is defined as the start position if you run the Armoury from inside the game.
    The blacklist seems to be coordinates which form a rectangle that defines an area you do not wish to get a position from.
    Last edited by Muzzleflash; Jul 16 2010 at 17:53.

  3. #3
    Gunnery Sergeant ArmAIIholic's Avatar
    Join Date
    Jun 15 2010
    Location
    Belgrade, Serbia
    Posts
    542
    Author of the Thread
    Ok, thanx man. I though it is something like that. And the Trexian quote indicates that as well.

    I was wondering if it starts from the center of the island does it have "tendency" to search toward position that user originally specified, if you understand what I mean.

    It wouldn't be useful to place unit or waypoint near the center of the island just for a sake of placing it.... I think it would be completely useless.

    However, this is just "philosophically" because I don't know the facts, I am trying to think like a programmer that made it -- why not returning just false value if there is no such point instead of finding point in the middle of nowhere?

    On the other hand, searching the whole island for such point would take huge amount of CPU time... There must be a "purpose", "meaning" etc.

    These are my thoughts...

  4. #4
    Quote Originally Posted by ArmAIIholic View Post
    I was wondering if it starts from the center of the island does it have "tendency" to search toward position that user originally specified, if you understand what I mean.
    It doesn't start searching from the center unless you don't pass it a position to go from. It starts from the point you give it, then it finds a position in a square with the "radius" of the maxDist. If the position is farther away than minDist and some other checks pass (eg. blackbox, water......) it found a position. Actually it appears in can find a position in the corner of that square where the distance is larger than maxdist.

    If it doesn't find a position, it reverts to the default passed positions. If those don't work it checks if the map has a Armory position. If it doesn't then it uses the maps centerPosition.

    Quote Originally Posted by ArmAIIholic View Post
    It wouldn't be useful to place unit or waypoint near the center of the island just for a sake of placing it.... I think it would be completely useless.
    I agree with you; I think

    However, this is just "philosophically" because I don't know the facts, I am trying to think like a programmer that made it -- why not returning just false value if there is no such point instead of finding point in the middle of nowhere?
    I agree; I think it's better to return false or something like that to indicate no desired position was found. Then the calling script can decide what to do.

    Quote Originally Posted by ArmAIIholic View Post
    On the other hand, searching the whole island for such point would take huge amount of CPU time... There must be a "purpose", "meaning" etc.
    I'm not sure where you are going here?

    This script itself is not very cpu-intensive; it makes a maximum of 1000 point checks with a square and some rectangles that blacklist and a few checks.

  5. #5
    Gunnery Sergeant ArmAIIholic's Avatar
    Join Date
    Jun 15 2010
    Location
    Belgrade, Serbia
    Posts
    542
    Author of the Thread
    Thanx it's clear now. I found part where it says how the script picks new point in every attempt. Since there is the finite number of attempts I guess it's not CPU-intensive.
    That's because sampling area depends on max distance.

    And it is very interesting for next dilemma: is it better to set large or small maximum distance - because new point is at (random (_maxDist * 2)). That actually means large sampling zone, but lower "density of samples". The probability for skipping the important point is higher.

    P.S. I want to fully understand the process, before doing something. My brain is always on the run.

  6. #6
    Yes I can see the dilemma too. However, I think that in most cases it will not be a problem and a valid position will be found, assuming you give it some reasonable parameters. The terrain in Arma is quite open; I think the chance of it not finding an important position is very small.

    There's no doubt that if you or I were to make this script it would most likely end up different than this (i'm not saying this is bad).

    One way you could compensate is: say you want to a check roughly for every 20m^2. Then you just make that number of attempts. Eg. for a circle you just calculate the area first. Then you get the number of attempts:
    _attempts = ceil (_area / 20);

    For a 100m radius circle this would be roughly 1500 attempts. You'll still want to make it random since else the spawning would always be the exact same spot. A good idea in this example might actually be, to not use equal distribution since you get more positions in the center.

  7. #7
    hehe

    I found the best way is just to experiment with it in any particular mission, until you get the results you want. There have been times when I've abandoned the findSafePos because it doesn't give me good results. Other times, it does exactly what I want.

    I have also experimented with the config areas for openAreas (can't quite remember exactly). That'll be areas defined in the config as relatively free from obstructions. That can be helpful sometimes. Alot depends on what exactly you are trying to accomplish. Spawning soldiers is easier than spawning tanks.

  8. #8
    Gunnery Sergeant ArmAIIholic's Avatar
    Join Date
    Jun 15 2010
    Location
    Belgrade, Serbia
    Posts
    542
    Author of the Thread
    Quote Originally Posted by TRexian View Post
    Spawning soldiers is easier than spawning tanks.
    That's why I won't search for safe pos for soldiers, but for tanks I will have "backup" pos, something like camp / base. Thanx.

    Muzzleflash thanx for keeping my brain wheels turning

  9. #9
    uhm, guys... isFlatEmpty exists. Use it and don't miss the precizePos parameter. Also selectBestPlaces comes in handy every now and then.

    Sure, there are some minor problems with these commands (such as ponds, which aren't seen as water) but these are really some lovely/expressive commands to retrieve a position that matches your demands.

  10. #10
    Gunnery Sergeant ArmAIIholic's Avatar
    Join Date
    Jun 15 2010
    Location
    Belgrade, Serbia
    Posts
    542
    Author of the Thread
    Thanx ruebe for help. After studying these functions, I've chosen findSafePos for several reasons:

    1) My spawning script already searches for position that is not in water and this way I can double check water and ponds when searching.
    2) I don't have to check the output therefore I can put default spawning location = base, so if there is no safe position vehicles will spawn at the base which will be near the road, so they are ready to travel long distances (if needed of course).

    I got it working, so basically this question (above) / thread is solved.

    Thank you all
    Last edited by ArmAIIholic; Jul 18 2010 at 07:54.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •