Jump to content
scottb613

AI Boat Beach Insertion ?

Recommended Posts

Hi Folks,

 

My mission/scripting question for this week - spent a few hours trying to get something that works - not much luck so far... So has anyone managed to get some form of AI Boat Beach Insertion working ??? Ideally - I'd like the boat to come charging up to the beach - until the bow contacts the beach - unload me and my AI Squad - then backup and peel away... LOL - like THAT's ever going to happen... Seems like the boat path finding is very bad - anytime it gets close to shore - it just stops an unrealistic distance away... I've tried just paralleling in at a shallow angle - same difference... I made sure the WP completion radius was very small - no joy... If I drive the boat into the beach myself - then script for AI to take over as driver and  add a waypoint - the AI isn't even capable of backing up to go back to sea... I can script at an intermediate level if needed and would welcome anyone's insights that may have worked something similar...

 

Thanks...

 

Regards,
Scott

Share this post


Link to post
Share on other sites

H

2 hours ago, HazJ said:

Maybe set the boat crew to CARELESS? If that doesn't work, force the boat to move using the setVelocity command. Example already on the Wiki. #2:

https://community.bistudio.com/wiki/setVelocity

 

Hi Haz,

 

I did have CARELESS set...

 

Thanks for the response - haven't messed with setVelocity before - I'll take a gander...

 

Regards,
Scott

Share this post


Link to post
Share on other sites

I dug this out of the Night Showcase mission a long time ago. You'll have to modify it for your purposes, but it should get you started. Basically spins the boat in place to whatever direction you want it to leave to. If you want to see it in action, go play the Night Showcase again and watch the boat after you're dropped on shore.

//The wanted direction
private "_wantedDirection";
_wantedDirection = [_boat, _finalDestination] call BIS_fnc_dirTo;

//Make sure we have the direction is > 0
if (_wantedDirection < 0) then {
	_wantedDirection = _wantedDirection + 360;
};

//Make sure the direction is between 0-360
if (_wantedDirection > 360) then {
	_wantedDirection = _wantedDirection % 360;
};

//Loop that handles boat direction
//While boat is not facing the direction we want it to, we set it's direction manually
//This is a robust work around the problem with the AI being unable to reverse/turn around when near the coast
while { round(getDir _boat) > round(_wantedDirection) || round (getDir _boat) < round(_wantedDirection) } do {
	if (getDir _boat > _wantedDirection) then {
		_boat setDir (getDir _boat - 0.5);
	} else {
		_boat setDir (getDir _boat + 0.5);
	};
	
	sleep 0.025;
};

 

  • Like 3

Share this post


Link to post
Share on other sites

Morn'n Folks,

 

Thanks so much for the great responses and digging out the example - I have a few things to try out now...

:thumb:

 

Regards,

Scott

Share this post


Link to post
Share on other sites

In my mission Leper Island, I wrote the VelocityBoost script below to force AI to beach the boat (and prevent AI from unloading in deep water and swimming in circles).  It does not handle the case of AI turning boat around and leaving.  I placed a trigger near shore for each boat calling this script.  Trigger should be placed at whatever position the AI will still maintain proper direction toward landing spot.  Note that you may want to make _speed and _iterations parameters, rather than hardcoded, in order to get a proper landing for different boats landing at different positions.

 

//////////////////////////////////////////////////////////
// velocityBoost.sqf
// Created by: johnnyboy
//
// Call this from a trigger that activates when boat is close to shore.  The VelocityBoost will push
// boat to shore, so when soldiers eject, they don't get confused walking in circles in the water.
//
// nul = [boatName] execVM "Scripts\velocityBoost.sqf";
//
//////////////////////////////////////////////////////////
if (isServer) then
{
    _vehicle = _this select 0;
    _vehicle allowDamage false;
    _vel = velocity _vehicle;
    _dir = direction _vehicle;
    _speed = 11;
    _iterations = 10;
    
    diag_log format ["speed=%1",_speed];
    if (! (isplayer (driver _vehicle)) ) then
    {
        driver _vehicle enablesimulation false;
        _vehicle setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+ (cos _dir*_speed),(_vel select 2)];
        _continue = true;
        sleep(0.2);
        x = 0;
        while {x < _iterations and (alive _vehicle) and (alive (driver _vehicle)) } do
       {
            x = x + 1;
            _vehicle setVelocity [_speed * sin(_dir), _speed * cos(_dir), (_vel select 2)];  
            Sleep(.2);
        };
        _vehicle allowDamage true;
        sleep 2;
        driver _vehicle enablesimulation true;
        driver _vehicle leaveVehicle _vehicle;
        sleep .5;
        {_x leaveVehicle _vehicle; } forEach crew _vehicle;         
    };
}
;

I've also used UnitCapture/UnitPlay to great effect in my Property of Mabunga mission.   This allowed AI driven boats to "navigate" narrow channels in Lake Limni in Altis, and worked every time (something that is impossible for AI boat path finding).

 

You can solve your problem if you stick with it!  Good luck!

 

BTW, the community needs a working "AI boat drop off, turn around and motor away" script, so if you get one working, please post it. 

  • Like 2

Share this post


Link to post
Share on other sites

Hi Johnny,

Just a coincidence - recently came across the video of your dog and was thoroughly amazed...

Thanks for taking the time an posting this...

Yeah - I wanted to stay away from the "capture" thing - as that's a one time only deal - I'd prefer a more modular script - where - with a few changes - it could used with a variety of boats at any beach...

It seems we may have examples of both functions needed posted here - approach and egress - so maybe I can get something going - I'm just an intermediate level scripter though - LOL - so don't expect elegant... I'll post anything I figure out here... Probably more questions though - before a real answer... I can't test until the weekend...

Regards,
Scott






Sent from my iPad using Tapatalk

  • Like 1

Share this post


Link to post
Share on other sites

Bonjour / Hello,

 

Je répond un peu tard, mais j'ai du travailler sur un script similaire pour mon débarquement. je vous fait joindre ce que j'ai fait qui est fonctionnel pour ma part, mais pas encore testé sur serveur dédié.

 

I answer a little late, but I had to work on a similar script for my disembarkation. I make you join what I did which is functional for my part, but not yet tested on a dedicated server.

 

if (isServer) then {
    private _vehicle = _this select 0;
    private _vel = velocity _vehicle;
    private _dir = direction _vehicle;
    private _speed = 8;
    private _profondeurMax = 7;
	private _group = group (driver _vehicle);
	
	_profondeurNow = ((selectBestPlaces [position _vehicle, 1, "waterDepth", 1, 1]) select 0) select 1;
	
    diag_log format ["speed=%1",_speed];
    if (!(isplayer (driver _vehicle))) then
    {
        driver _vehicle enablesimulation false;
        _vehicle setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+ (cos _dir*_speed),(_vel select 2)];
        _continue = true;
        sleep 0.2;
        while {_profondeurNow > _profondeurMax and (alive _vehicle) and (alive (driver _vehicle)) } do
       {
			_profondeurNow = ((selectBestPlaces [position _vehicle, 1, "waterDepth", 1, 1]) select 0) select 1;
            _vehicle setVelocity [_speed * sin(_dir), _speed * cos(_dir), (_vel select 2)];  
            Sleep 0.5;
        };
		
        sleep 2;
		
		_vehicle setFuel 0;
		{_vehicle animate [_x, 1]} foreach ['shutter_rotate','ramp_rotate'];
        driver _vehicle enablesimulation true;
        driver _vehicle leaveVehicle _vehicle;
        sleep 0.5;  
		if (alive _vehicle) then {
			[_vehicle] spawn {
				_vehicle = _this select 0;
				{
					unassignVehicle _x ;
					_x leaveVehicle _vehicle;
					_x action ["Eject",  _vehicle];
					sleep 0.125;
				} forEach (crew _vehicle);
			}; 
		};
		
		sleep 0.5;
		
		_group move (getMarkerPos "AttaqueMarker"); // Variable "AttaqueMarker" à rajouter sur un marker système.
		_group setCombatMode "BLUE";
		_group setSpeedMode "FULL";
		{_x setUnitPos "UP"; _x disableAi "autoCombat";  _x disableAi "autoTarget"} foreach units _group;
		_group allowfleeing 0;
		_group setBehaviour "AWARE";
    };
};

 

  • Thanks 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

×