Jump to content
Luft08

How to get AI unit to approach a vehicle's driver door?

Recommended Posts

I am writing a scenario where if the players leave their vehicle named hunter_1 unattended I want an AI unit to walk up to the driver door, get in and drive off. The script I wrote seems to only work sometimes. It is hit or miss.

Any suggestions? I was thinking that maybe the waypoint is being blocked by the vehicle so the "setWaypointStatements" never gets executed... Can I set an exact waypoint just outside of the driver door of the vehicle?

 

My code:

In stealHunter.sqf:

if (isServer) then {
	_wp = group autoThief_1 addWaypoint [position hunter_1, 3];
	_wp setWaypointStatements["true", "[] execVM 'getInHunter.sqf';"];
};

Then in getInHunter.sqf:

if (isServer) then {
	autoThief_1 assignasdriver hunter_1;
// I have tried the two lines below
//	[autoThief_1] orderGetIn true;
//	[autoThief_1] allowGetIn true;

// I have also tried the line below
//	autoThief_1 action ["getInDriver", hunter_1];

	sleep 3;
	if (vehicle autoThief_1 != autoThief_1) then {
		_wpPos = getMarkerPos "wp_stealHunter_1";
		_wp = group autoThief_1 addWaypoint [_wpPos, 0];
		_wp setWaypointStatements["true", "[] execVM 'goToChopShop.sqf';"];
		sleep 20;
		_handle = execVM "allowHelp_1.sqf";
	};
	
};

 

Share this post


Link to post
Share on other sites

A quick solution could be to attach an invisible helipad to the vehicle and set the waypoint on it   :thumbsup:

Share this post


Link to post
Share on other sites

Here is a script I wrote for another topic that does this exact thing:

Just adjust the variables and you should be good to go.

Share this post


Link to post
Share on other sites

Thanks 7erra!

I'll need to do further testing but with a little modification your script seems to be working. Of course mine did too until it failed but you have given me hope! 

if(isServer) then {
	_unit = _this select 0;
	_car = _this select 1;

	_unit assignAsDriver _car;
	[_unit] orderGetIn true;
	_inAnim = toLower getText(configfile >> "CfgVehicles" >> typeOf _car >> "getInAction");
	waitUntil {
  		_inAnim in toLower animationState _unit
	};
	_car lockDriver false;
	[_unit] orderGetIn true;
	_unit switchMove "";
};

 

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

×