PDA

View Full Version : Creating a waypoint and vehicle during the mission and using "GETOUT" problem



GDICommand
Dec 19 2010, 00:27
So I'm trying to create a flashy ending to my mission, so this isn't entirely necessary, but regardless, for missions that I've done in the past where it was necessary, I ran into this same problem.

So the idea is to create a vehicle at some point after the mission was started. So I create the vehicle, create the crew and put them in the vehicle, then I start adding waypoints to it based on certain markers positions. The vehicle is some sort of troop transport (i.e. hmmwv, aav, 7ton, etc). I set up a waypoint for the transport that is of type "TR UNLOAD", and the waypoint for the passengers are "GETOUT". The problem with this is that the passengers never "reach" the waypoint. If I don't sync the waypoints together, the vehicle goes through the waypoint and onto the next in it's list. If I do sync them together, the transport sits there indefinitely waiting for the passengers to get out. The problem seems to lie with the passengers not knowing that they're at the waypoint.

I seemed to hack my way around this one, but I'm kind of looking for a more effective solution. This is what I have though (note I didn't sync the waypoints):


aav1 = createVehicle ["AAV", getMarkerPos "reinforcementSpawn2", [], 10, "FORM"];
"USMC_Soldier_Crew" createUnit [position player, aavReinforcements, "aavDriver1 = this;", 0.6, "corporal"];
aavDriver1 moveInDriver aav1;
"USMC_Soldier_Crew" createUnit [position player, aavReinforcements,"aavCommander1 = this;", 0.6, "corporal"];
aavCommander1 moveInCommander aav1;
"USMC_Soldier_Crew" createUnit [position player, aavReinforcements,"aavGunner1 = this;", 0.6, "corporal"];
aavGunner1 moveInGunner aav1;
aavReinforcements setFormation "COLUMN";
aavWaypoint1 = aavReinforcements addWaypoint [getMarkerPos "townCenter", 0];
aavWaypoint1 setWaypointSpeed "FULL";
aavWaypoint1 setWaypointType "TR UNLOAD";
aavWaypoint1 setWaypointStatements ["true", "doGetOut units reinforcementSquad1; reinforcementSquad1 setCurrentWaypoint [reinforcementSquad1, 1];{unassignVehicle _x} forEach units reinforcementSquad1;"];
aavWaypoint2 = aavReinforcements addWaypoint [getMarkerPos "waypoint2", 0];

"USMC_Soldier" createUnit [position player, reinforcementSquad1, "squad1_1 = this;", 0.6, "corporal"];
squad1_1 moveInCargo aav1;
"USMC_Soldier" createUnit [position player, reinforcementSquad1, "squad1_2 = this;", 0.6, "corporal"];
squad1_2 moveInCargo aav1;
squad1wp1 = reinforcementSquad1 addWaypoint [getMarkerPos "townCenter", 0];
squad1wp1 setWaypointType "GETOUT";
squad1wp1 setWaypointCompletionRadius 30;
squad1wp1 synchronizeWaypoint [aavWaypoint1];
squad1wp2 = reinforcementSquad1 addWaypoint [getMarkerPos "waypoint2", 10];
//just here so I can view it first hand, wouldn't be there in production code
selectPlayer squad1_2;


So basically the code that's important is:


aavWaypoint1 setWaypointStatements ["true", "doGetOut units
reinforcementSquad1; reinforcementSquad1 setCurrentWaypoint
[reinforcementSquad1, 1];{unassignVehicle _x} forEach units
reinforcementSquad1;"];
the rest of it is just esthetics, just to make it look nice as far as waypoints on the map if you were personally in the squad that you were creating after the mission start, so that way it still shows on the map "Get Out"

I'm looking for a way that I won't have to hack this together next time...anybody know something I don't? I tried searching, but came up with a bunch of stuff that's unrelated.

bhaz
Dec 19 2010, 00:37
The unassignVehicle command should be enough to order them out of the vehicle, once it stops moving. Then you could wait until they're all out, and create the AAV's final waypoint afterwards.


{unassignVehicle _x} forEach units reinforcementSquad1;
waitUntil {{_x in aav1} count units reinforcementSquad1 == 0};
// then create the rest of the AAV waypoints afterwards

Plus, the unassignVehicle command relies on the fact that you've assigned them in the first place, before moving them in. (assignAsCargo)

zigzag
Dec 19 2010, 00:38
In the waypoint were you want the group to get out put.
alpha leaveVehicle (http://community.bistudio.com/wiki/leaveVehicle) heli; { _x action [""eject"", heli] } forEach units group s1;

alpha is the groupname of the soldiers.
heli is the name of the vehicle.
s1 is the name of the soldiers group leader.

GDICommand
Dec 19 2010, 01:08
The unassignVehicle command should be enough to order them out of the vehicle, once it stops moving. Then you could wait until they're all out, and create the AAV's final waypoint afterwards.


{unassignVehicle _x} forEach units reinforcementSquad1;
waitUntil {{_x in aav1} count units reinforcementSquad1 == 0};
// then create the rest of the AAV waypoints afterwards

Plus, the unassignVehicle command relies on the fact that you've assigned them in the first place, before moving them in. (assignAsCargo)

ooo, yea you're right. I just checked the description of the unassignVehicle command and it appears thats all I really needed. I don't like creating waypoints after I do that though, thats even more "hacky" then the way i did it lol. Besides, I already created all the waypoints at the same time, and it works without creating the waypoints after, because the doGetOut command orders the vehicle that the unit is in to stop until all the passengers are out (which I'm assuming the unassignVehicle command does the same, although the description doesn't say, which is why I said doGetOut). The aav actually reaches it's waypoint, but just turns into "wait" until the passengers are out, so as soon as theyre out, it continues anyway.


In the waypoint were you want the group to get out put.
alpha leaveVehicle (http://community.bistudio.com/wiki/leaveVehicle) heli; { _x action [""eject"", heli] } forEach units group s1;

alpha is the groupname of the soldiers.
heli is the name of the vehicle.
s1 is the name of the soldiers group leader.

I can tell you didn't test this, but I'll fill you in why this doesn't work. The actions in the waypoint don't get activated because the group never reaches the waypoint, so you have to do all actions from the transports waypoint

zigzag
Dec 19 2010, 01:14
I have that in a trigger that gets activated when the chopper is on the ground and it works for me.
Should work the same if you put it in the vehicles waypoint.

GDICommand
Dec 19 2010, 01:22
well then you skimmed over my original post. everything works how it should if a vehicle and crew exists (with crew inside of vehicle) at missions start, but if you create the vehicle and crew after the mission is started, then the passengers of the vehicle will never reach the waypoint...so no it doesnt work, because the actions inside of the waypoint only execute after the group reaches the waypoint...if the unit never reaches the waypoint...then no actions...