Jump to content
avibird 1

What is the best water Patrol script for arma3.

Recommended Posts

Hey looking for script that will make random waypoints for water units only ships  don't need  divers Roman the waters. I use upmons but it sometimes puts waypoints on the land and the ships get all messed up attempting to reach its waypoint. I know EOS has a function but it puts divers into the water I only want ships at this time. Any suggestions would be great. I can always use the old-fashioned way just put that way points myself but I would like something a little more random with its Patrol waypoints.

Share this post


Link to post
Share on other sites

Writing your own would be the best solution as this is really easy. Just make a while {alive _boat} cycle with waitUntil {unitReady _boat} at the end that finds a water position using BIS_fnc_findSafePos and gives the boat a waypoint.

Share this post


Link to post
Share on other sites

Here's a function I use for dog packs to roam.  It was made to move to random pos where position is NOT water.  For you, I changed it to move to RandomPos that IS Water.  Its looking for one 300 - 400 meters away.  Tweak that distance to your liking.  You still need a loop doing what @theend3r suggests (give boat a waypoint or moveTo command).  This function still runs the risk of returning a "bad" water position like in a mangrove channel that AI can't navigate to.  To reduce chance of AI getting stuck in shallow water or being blocked by a wreck or dock, I set the condition for move completion to within 50 meters of calculated moveTo position.  So boat completes move long before reaching new position.

_fnc_getRandomWaterPos = {
    params["_obj"];
    _posFound = false;
    _randomPos = [];
    while {!_posFound} do
    {
        _distance = 300 + random 100;
        _dir = random 360;
        _randomPos = [_obj, _distance, _dir] call BIS_fnc_relPos;
        if (surfaceIsWater _randomPos) then 
        {
            _posFound = true;
        };
    };
    _randomPos 
};

 

  • Like 2

Share this post


Link to post
Share on other sites

@ theend3r  LMAO maybe for you (:  I can only cut and paste a few codes together to editor scripts to make changes the rest is way over my pay grade.

 

I never realized  after all these years using upmons by  Monsada does not work on ships when given random waypoints on the water

however UPS  Urban Patrol Script by Kronzky works well with ships (:

 

 

@ johnnyboy thanks if you could make a simple mission I would love to look at your codelines how it works.

Share this post


Link to post
Share on other sites

after a few hrs testing the UPS script still runs into issues with waypoints to ships. Anyone have a good ship random waypoint script!!!

Share this post


Link to post
Share on other sites

@johnnyboy

 

I put your code into a  shipwaypoint.sqf

I put this in the ship init  nul = execVM "shipwaypoint.sqf"

I can't get it to work.

Share this post


Link to post
Share on other sites

That wasn't intended as a complete solution.  Just pointing the way.  But here you go.  Put this in the init of a boat with an AI driver, and make player a passenger, and enjoy the ride.   I dropped about 30 boats off SW side of Tanoa between big island and smaller islands, and they all cruised around nicely.  Didn't see anyone get stuck.  The speed boat I was in as the observing player went about 30 meters close to shore a few times, but always turned away and never got stuck.

 

If this is for ambient civilian boat traffic this might be all you need.  If its for patrols that need to react to the enemy then you need to end the loop when driver's behaviour switches to COMBAT, so thier combat ai can take over.

dmy=[this] spawn
{
    _boat = _this select 0;
    _driver = driver (vehicle _boat);
    _moveToPos = [];
    _fnc_getRandomPos = {
        params["_obj"];
        _posFound = false;
        _randomPos = [];
        while {!_posFound} do
        {
            _distance = 800 + random 300;
            _dir = random 360;
            _randomPos = [_obj, _distance, _dir] call BIS_fnc_relPos;
            if (surfaceIsWater _randomPos) then 
            {
                _posFound = true;
            };
        };
        _randomPos 
    };
    _moveToPos = [_boat] call _fnc_getRandomPos;
    _boat commandMove _moveToPos;
 
    while {alive _boat and alive _driver} do
    {
        if ((_boat distance _moveToPos) < 50 ) then
        {
            _moveToPos = [_boat] call _fnc_getRandomPos;
            _boat commandMove _moveToPos;
       };
        sleep 2;
    };
};

 

  • Like 2

Share this post


Link to post
Share on other sites

If Anyone can help on this and make a simple example mission that

Would be great.  I don't really understand how to make this work. I can't believe that they are no real boat random waypoint scripts since water combat improved so much since Arma2.

Share this post


Link to post
Share on other sites

You can make your own sample mission. 

  1. Open editor on any map.
  2. Create a boat unit and place it in the water off the coast.
  3. Make AI unit driver
  4. Add Player unit as passenger on boat
  5. Open double click on boat to open up its attributes
  6. Copy and paste the code I posted above into the units INIT box.
  7. Play mission.

You will observe the boat driving from one random position to another.  All in water.

 

Return to editor, and hightlight the boat, and copy and paste it 20 times creating 20 more boats near original boat.  Play mission and see all boats moving to different destinations.

Share this post


Link to post
Share on other sites

@ johnnyboy it does not work al all the boat just sits in the water lol. help I put your code above you posted in the boat init. Help.

Share this post


Link to post
Share on other sites
3 hours ago, Mr. Birdman said:

@ johnnyboy it does not work al all the boat just sits in the water lol. help I put your code above you posted in the boat init. Help.

Which boat and map are you using? When I did some testing of brown water patrols on Doung island (Unsung mod), I found that at times the AI just waits for a few minutes before it starts to the next waypoint. I was mostly interested in rubber boats and they were particularly keen to 'get stuck'. The faster speedboats seemed to do much better. Though whatever I tried, the AI did not navigate the main river on Doung reliably.

 

Share this post


Link to post
Share on other sites

@TeTeT You're right, I was having two problems:

1. Boats occasionally get stuck in the shallows.

2. Boats occasionally stop moving.

 

I think I've solved the shallows problem, and I've improved the stop moving problem (sometimes they stop for a minute before moving again...no idea why).  But now I've introduced a bug I have to fix before posting the improved solution.  Stay tuned.  The screenshot below shows 4 boats I had running the script for about 40 minutes.  I tracked their paths with different colored markers.  One of the boats stopped moving. I liked that they occasionally folowed a coast line, and the red path managed to pass between a small island and a bigger island.

random_Boat_Paths.jpg

 

  • Like 2

Share this post


Link to post
Share on other sites
9 hours ago, TeTeT said:

Which boat and map are you using? When I did some testing of brown water patrols on Doung island (Unsung mod), I found that at times the AI just waits for a few minutes before it starts to the next waypoint. I was mostly interested in rubber boats and they were particularly keen to 'get stuck'. The faster speedboats seemed to do much better. Though whatever I tried, the AI did not navigate the main river on Doung reliably.

 

Regarding your other points...

  • "faster speedboats seemed to do much better".  True.  I don't know why.
  • "AI did not navigate the main river on Doung reliably".  For the river, you might want to record mulitple boat paths using BIS_fnc_UnitCapture.  I recorded about 10 paths through Lake Limni on Altis for my Property of Mabunga mission, and they worked will.  AI will not drive at all there normally (watch the first minute of mission video at that link to see 4 AI boats crusing up the narrow canal).  To achieve some randomness you can randomize which paths AI will play at mission start, and you can also randomize at what time they start on their paths.

Share this post


Link to post
Share on other sites

I use speed boats on the original arma3 islands still can't get your code to work. I put the code above in the boat init box but just sits in the water.

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

×