Jump to content
Sign in to follow this  
Spudgunner

Exiting vehicles following its own WP

Recommended Posts

How do you make an AI character exit a vehicle which is following its own WP routine? To board I use GET IN WP and synchronise it with the vehicles WP and that works fine. However, it doesn't seem to work the same way with a synchronised GET OUT WP. Any ideas?

Share this post


Link to post
Share on other sites

lets say i have 3 wp's..

*start

*middle

*end

and i want my Ai to drive from *start to *middle. then go by foot from *middle to *end.

now what you can do is. on the *middle wp.on ACT put this

{unassignVehicle _x} forEach crew vehicle this;crew vehicle this allowGetIn false  

this will make the ai get out and prevent them from allowing to get in again.

Share this post


Link to post
Share on other sites

The trouble is the vehicle's driver is following its own WP routine. While another AI is interacting as a passenger only and not as a driver.

* Passenger waits for vehicle.

* Vehicle drives to passenger location.

* Passenger boards vehicle

* Driver stops at destination

* passenger exits vehicle (this is the problem part)

* Driver continues journey.

Share this post


Link to post
Share on other sites

Destination wp type for driver: transport unload, for passenger: Get out, sync them.

Share this post


Link to post
Share on other sites
Destination wp type for driver: transport unload, for passenger: Get out, sync them.

Close but unfortunately Transport Unload ejects all passengers. I need to keep some passengers in the vehicle.

Share this post


Link to post
Share on other sites

Use nuxil's code, but instead of crew use group.

{unassignVehicle _x} forEach units groupName;units groupName allowGetIn false

Share this post


Link to post
Share on other sites

This will do the same:

groupName leaveVehicle vehicleName

Share this post


Link to post
Share on other sites
Use nuxil's code, but instead of crew use group.

{unassignVehicle _x} forEach units groupName;units groupName allowGetIn false

The trouble is that there are no groups involved. What I'm trying to achieve is like a bus journey. Some civilians will alight at some stops, while others will board.

Share this post


Link to post
Share on other sites

Do you even know who board/leaves where, or is that random as well. If you do, just foreach an array with those units, instead of a group.

{} foreach [civ1,civ5,civ6]

Share this post


Link to post
Share on other sites
This will do the same:

groupName leaveVehicle vehicleName

Should this be applied to the vehicles WP Act script or the passenger's? Also, to make this work, how do you assign a name to a civilian unit and vehicle?

---------- Post added at 11:19 ---------- Previous post was at 11:13 ----------

Do you even know who board/leaves where, or is that random as well. If you do, just foreach an array with those units, instead of a group.

{} foreach [civ1,civ5,civ6]

For now, I know who boards/leaves the vehicle but eventually it might be random. Although I'm not sure how to address the civilian. Is it the character name text (like Svetlana) thats addressed?

---------- Post added at 12:16 ---------- Previous post was at 11:19 ----------

This will do the same:

groupName leaveVehicle vehicleName

I named the civilian "civ1" and the vehicle "bus1", making your code look like this:

civ1 leaveVehicle bus1

This worked when I didn't synchronise the WP's. Although the passenger got out of the vehicle, unfortunately the driver got out too. Although he did resume driving. If there's a way to make sure the driver doesn't leave then the script will work.

Share this post


Link to post
Share on other sites

I did this with a simple dynamic script and some markers. What you need is to add an 2 events to the vehicle, one for "GETIN" and one for "GETOUT". The vehicle will stop at each waypoint until the "GETOUT" event is fired (or the waypoint times out) thus allowing passengers to get off.

Share this post


Link to post
Share on other sites
I did this with a simple dynamic script and some markers. What you need is to add an 2 events to the vehicle, one for "GETIN" and one for "GETOUT". The vehicle will stop at each waypoint until the "GETOUT" event is fired (or the waypoint times out) thus allowing passengers to get off.

Can you elaborate a bit further - I'm still a newbie at scripting :confused:

Share this post


Link to post
Share on other sites

Ok - first, try this.. Create an empty SQF file in your mission folder called logistics.sqf and put the following in it (this is a heavily stripped down version of the code I wrote for battlefield logistics):

_unit = _this select 0;
_pickupPos = _this select 1;
_dropoffPos = _this select 2;
_group = group _unit;

/* Transporter states 
2 = driving to dropoff point
4 = driving to pickup point */

_unit setVariable ["logistic_state", 4, true];    // start with state 4, drive to pickup

_unit addEventHandler ["GETIN", { transporter1 setVariable ["logistic_state", 2, true]; hintsilent "Transport is loading up."; }];
_unit addEventHandler ["GETOUT", { transporter1 setVariable ["logistic_state", 4, true]; hintsilent "Transport is unloading."; }];
_unit addEventHandler ["FUEL", { hintsilent "Transport is unavailable; out of fuel."; }];
_unit addEventHandler ["DAMMAGED", { group transporter1 setCurrentWaypoint [group transporter1, 1]; hintsilent "Transport has been damaged; returning to base."; }];
_unit addEventHandler ["KILLED", { hintsilent "Transport has been destroyed."; }];

_waypoint0 = _group addwaypoint[_pickupPos, 5];
_waypoint0 setwaypointtype "LOAD";
_waypoint0 setwaypointCombatMode "BLUE";
_waypoint0 setwaypointBehaviour "SAFE";
_waypoint0 setwaypointSpeed "Full";
_waypoint0 setwaypointTimeout [0,0,0];
_waypoint0 setwaypointStatements ["transporter1 getVariable ""logistic_state"" == 2;","hintsilent ""Truck moving to dropoff location."";"];

_waypoint1 = _group addwaypoint[_dropoffPos, 25];
_waypoint1 setwaypointtype "TR UNLOAD";
_waypoint1 setwaypointTimeout [5,5,5];
_waypoint1 setwaypointStatements ["transporter1 getVariable ""logistic_state"" == 4;","hintsilent ""Truck moving to pickup location."";"];

_waypoint2 = _group addwaypoint[_pickupPos, 5];
_waypoint2 setwaypointtype "CYCLE";

Create a vehicle with driver in the editor. Don't give it any waypoints. Give it a name of transporter1. In the vehicle's init line, add this:

[this, getmarkerpos "mark_pickup", getmarkerpos "mark_dropoff"] exec "logistics.sqf";

Now create two markers, one will be your destination and one your pickup point. Call them mark_pickup and mark_dropoff respectively.

Basically this script will drive the vehicle to the pickup point, where it will wait until one or more unit(s) gets in. Then it will proceed to the dropoff point, whereby it will eject its passengers.

It generates waypoints at the markers so that it's easier to reuse in missions; all you need to do is perhaps insert more waypoints of type "UNLOAD" or "MOVE" with various timeouts so that it can do multiple stops. Hope this helps!

Share this post


Link to post
Share on other sites

Thanks disobey, that looks like some useful amd smart coding. Will this work for the bus route I'm planning for civilians? I think BI were going to do this since they supplied the game with a bus and bus stops.

Share this post


Link to post
Share on other sites

Well, I think you'll have to create a marker next to each bus stop really.. while it is possible in code to dynamically get an array of all bus stop objects (i think), I'm not sure it would be easy to automaitcally move to them in a particular logical order.

Share this post


Link to post
Share on other sites

thank you for the script disobey.

If I use your script the 'transport1' vehicle drives to the mark_pickup marker and waits for units to move in. When I get in myself it then drops me of at the mark_dropoff marker and returns to the mark_pickup marker, as intended.

But now my question, how do I get a AI group to get in the transport vehicle? So the group actually waits for the vehicle to arrive and then board the vehicle to be dropped off at the other marker. Cause there are no visible waypoints of transporter1 I cant sync/trigger them with each other. Any ideas?

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
Sign in to follow this  

×