Jump to content
jakkob4682

need help with a couple functions

Recommended Posts

No error in the .rpt but the waypoints aren't working for the infantry group thats spawned.  If I go about it using assignAsCargo and orderGetIn it works fine but then I have an issue with the group not ejecting out of the vehicle.

params ["_center","_radius"];

_LZArea = nearestLocations [_center,["FlatArea"],_radius];
_LZ_Zone = _LZArea select 0;
_LZ_Pos = locationPosition _LZ_Zone;

_LZ_Site = [_LZ_Pos,sideEmpty,(configfile >> "CfgGroups" >> "Empty" >> "Military" >> "HeliportsSmall" >> "SquareLZ")] call BIS_fnc_spawnGroup;


_veh = "CUP_B_CH53E_USMC" createVehicle _LZ_Pos;
createVehicleCrew _veh;



_infGroups = [west,"CUP_B_USMC","Infantry_DES",[2,8]] call f_randomGrp;
_infType = selectRandom _infGroups;

_pos = (getPos _veh) findEmptyPosition [25,50,(typeof _veh)];
_grp = [_pos,west,(configFile>>"CfgGroups">>"WEST">>"CUP_B_USMC">>"Infantry_DES">>_infType)] call BIS_fnc_spawnGroup;

_hWP = (group _veh) addWaypoint [getPos _veh,1,0];
_hWP setWaypointType "LOAD";
_hWp setWaypointStatements ["true",""];

_cargoWP = _grp addWaypoint [getPos _veh,10,0];
_cargoWP setWaypointType "GETIN";
_cargoWP setWaypointStatements ["true",""];

[(group _veh),0] synchronizeWaypoint [[_grp,0]];

[_veh,_grp]

next function

_qrf = [getPos player,3000] call f_spawnHeli;
_veh = _qrf select 0;
_grp = _qrf select 1;


waitUntil{{_x in _veh} count units _grp == count units _grp};
_lz = (getPos player) findEmptyPosition [25,75,(typeOf _veh)];
_pad = "Land_HelipadEmpty_F" createVehicle _lz;

_wp2 = (group _veh) addWaypoint [getPos _pad,25,1];
_wp2 setWaypointType "TR UNLOAD";
_wp2 setWaypointStatements ["true",""];

_wp1 = _grp addWaypoint [getPos _pad,10,1];
_wp1 setWaypointType "GETOUT";
_wp1 setWaypointStatements ["true",""];

[(group _veh),1] synchronizeWaypoint [[_grp,1]];

true

again if I don't use the waypoint system and use assignAsCargo and orderGetIn and then use action "eject" in this function they don't eject

Share this post


Link to post
Share on other sites
1 hour ago, jakkob4682 said:

[(group _veh),0] synchronizeWaypoint [[_grp,0]];

0 ( as in [_grp,0] ) is not a valid index, waypoint 0 of a group is given to any group when it is created and is their starting position. It is not the first waypoint assigned either by script or in editor, these will always be index 1.

Although as you are adding the waypoints via script you can just use the returned waypoint from the addWaypoint commands, rather than guessing an index.

_hWP synchronizeWaypoint [ _cargoWP ];

 

1 hour ago, jakkob4682 said:

[(group _veh),1] synchronizeWaypoint [[_grp,1]];

Same here in the second script, just use the returned waypoints...

_wp2 synchronizeWaypoint [ _wp1 ];

 

 

As for making a group board a vehicle, maybe giving the boarding group a vehicle using addVehicle on the group could help if they are not obeying the Load?

  • Like 2

Share this post


Link to post
Share on other sites
waitUntil{{_x in _veh} count units _grp == count units _grp};
_lz = (getPos player) findEmptyPosition [10,50,(typeOf _veh)];
hint format ["%1",str _lz];
_pad = "Land_HelipadEmpty_F" createVehicle _lz;
_wp = _vGrp addWaypoint [_lz,50,1];
_wp setWaypointType "MOVE";
_wp setWaypointStatements ["true",""];

waitUntil{_veh distance _lz < 200};
{_x action ["eject",_veh]}forEach units _grp;
{unassignVehicle _x}forEach units _grp;
{[_x] orderGetIn false}forEach units _grp;
_veh land "LAND";

this is working now, I abandoned the waypoint system

Share this post


Link to post
Share on other sites
4 hours ago, Larrow said:

As for making a group board a vehicle, maybe giving the boarding group a vehicle using addVehicle on the group could help if they are not obeying the Load?

should I do this in the load waypoint or in a separate line?

Share this post


Link to post
Share on other sites
14 hours ago, jakkob4682 said:

waitUntil{{_x in _veh} count units _grp == count units _grp};
_lz = (getPos player) findEmptyPosition [10,50,(typeOf _veh)];
hint format ["%1",str _lz];
_pad = "Land_HelipadEmpty_F" createVehicle _lz;
_wp = _vGrp addWaypoint [_lz,50,1];
_wp setWaypointType "MOVE";
_wp setWaypointStatements ["true",""];

waitUntil{_veh distance _lz < 200};
{_x action ["eject",_veh]}forEach units _grp;
{unassignVehicle _x}forEach units _grp;
{[_x] orderGetIn false}forEach units _grp;
_veh land "LAND";

this is working now, I abandoned the waypoint system

Hey this is somewhat irrelevant to the question but in the quoted snippet you could possibly combine all forEach into one, looking something like

{
	_x action ["eject",_veh];
	unassignVehicle _x;
	[_x] orderGetIn false
} forEach units _grp;

 

10 hours ago, jakkob4682 said:

should I do this in the load waypoint or in a separate line?

As for this, I believe that Larrow means that you should give a vehicle to the group either when you create the group, or the at the place/time that you want it to board a vehicle. There are some "interesting" points found in the command's BIKI.   Quoting two of them:

  • This is relevant for some waypoints like getIn and guard - potentially more.
  • If used on a vehicle already driven by a member of another group, the driver will continue under his own group's orders, which may not benefit the addVehicle group.

So, this means that you may have to assign the vehicle to the group you want to be transported. Additionally, the second bullet might suggest what is stated in this page, that you have to give the pilot a "Transport Unload" ("TR UNLOAD") and to the transported group a "GET OUT" waypoint and then synchronize them.

 

Finally, it may be good practice to use leaveVehicle after the group has gotten out of the vehicle. Please note the suggestions at the command's (leaveVehicle) BIKI page, stating that it is better to get the group out of the vehicle and unassign the vehicle explicitly (with unassignVehicle).

 

I haven't used any of the commands myself and all I present here is mere suggestions (and hypotheses) based on the BIKI pages, so please treat them with caution and make sure to test before use.

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

×