lawman_actual 24 Posted July 19, 2015 (edited) Afternoon I need to be able to reassign a unit after it's completed it's Waypoint. I have achieved this easily enough for units I know about from the start by writing a unique handle for each one, but I'm not sure how to achieve this for units procedurally generated in-mission. I made a test scenario to try out the concept so you can see what I mean. Here was my first test; testscript.sqf for "_i" from 1 to 3 step 1 do { _newgroup = createGroup west; _unit = _newgroup createUnit ["B_Soldier_GL_F",getMarkerPos "marker2",[],0.5,"CORPORAL"]; _goal = _newgroup addWaypoint [getMarkerPos "marker1", 5]; _goal setWaypointType "MOVE"; _newgroup setCurrentWaypoint _goal; _goal setWaypointStatements ["True","deleteVehicle _unit"]; sleep 10; }; As you can see, as part of a cycle, three units are generated and assigned a waypoint. On reaching that waypoint _unit is deleted. The problem with this was that _unit was constantly being redefined when the next unit was created. The result was that when unit 1 reached it's waypoint, unit 3 was being deleted. So I attempted creating a unique handle for each by concatenating a variable that changed after each pass; numbercounter = 1; for "_i" from 1 to 3 step 1 do { _newgroup = createGroup west; _unit = Format["unit_%1", numbercounter]; _goal = Format["goal_%1", numbercounter]; _unit = _newgroup createUnit ["B_Soldier_GL_F",getMarkerPos "marker2",[],0.5,"CORPORAL"]; _goal = _newgroup addWaypoint [getMarkerPos "marker1", 5]; _goal setWaypointType "MOVE"; _newgroup setCurrentWaypoint _goal; _goal setWaypointStatements ["True","Format['deleteVehicle unit_%1', numbercounter];"]; numbercounter = numbercounter + 1; sleep 2; }; Although this didn't show any errors, it's not deleting any units. In any case, I'm not sure when this script would be concatenating the numbercounter variable. Would it be as the waypoint statement is set (in which case the number would be the correct one) or as the waypoint statement script is called (in which case the number would again refer to the last created unit) Anyhow, this doesn't seem like a great way of doing it as I'm going to end up with bucket-loads of "unit_x" variables. Any other ideas very welcome! Best, Lawman Edited July 19, 2015 by Lawman_Actual Share this post Link to post Share on other sites
Larrow 2822 Posted July 19, 2015 The leader and the units of a group can be referenced in the waypoint statements using this and thisList respectively. So your first example could look like... for "_i" from 1 to 3 step 1 do { _newgroup = createGroup west; _unit = _newgroup createUnit ["B_Soldier_GL_F",getMarkerPos "marker2",[],0.5,"CORPORAL"]; _goal = _newgroup addWaypoint [getMarkerPos "marker1", 5]; _goal setWaypointType "MOVE"; _newgroup setCurrentWaypoint _goal; _goal setWaypointStatements ["True","{ deleteVehicle _x }foreach thislist;"]; sleep 10; }; Share this post Link to post Share on other sites
lawman_actual 24 Posted July 19, 2015 Worked perfectly! Many thanks Larrow Can you explain what thislist does? I didn't find it on the scripting commands BIS page and Google wasn't particularly helpful :D Share this post Link to post Share on other sites
lawman_actual 24 Posted July 19, 2015 Ok, so here's a script I had written previously for specific units that I am trying to convert into a generic script that can be reused indefinitely. How would I achieve this? I want different units doing different things (different objectives assigned to Alpha, Bravo and Charlie, vehicle crew to head to base) Can this be achieved with the thislist thing? w_unload setWaypointStatements ["true", "starthemtt lock false; doGetOut [dag2a1,dag2a2,dag2a3,dag2a4,dag2b1,dag2b2,dag2b3,dag2b4,dag2c1,dag2c2,dag2c3,dag2c4]; dag2a1 leaveVehicle starthemtt13one; dag2a2 leaveVehicle starthemtt13one; dag2a3 leaveVehicle starthemtt13one; dag2a4 leaveVehicle starthemtt13one; dag2b1 leaveVehicle starthemtt13one; dag2b2 leaveVehicle starthemtt13one; dag2b3 leaveVehicle starthemtt13one; dag2b4 leaveVehicle starthemtt13one; dag2c1 leaveVehicle starthemtt13one; dag2c2 leaveVehicle starthemtt13one; dag2c3 leaveVehicle starthemtt13one; dag2c4 leaveVehicle starthemtt13one; obj13pos1 = getMarkerPos newobj; dag2aobj = deploygroup2a addWaypoint [obj13pos1, 1]; dag2aobj setWaypointType 'SAD'; dag2aobj setWaypointCombatMode 'RED'; deploygroup2a setCurrentWaypoint dag2aobj; dag2bobj = deploygroup2b addWaypoint [obj13pos1, 1]; dag2bobj setWaypointType 'SAD'; dag2bobj setWaypointCombatMode 'RED'; deploygroup2b setCurrentWaypoint dag2bobj; dag2cobj = deploygroup2c addWaypoint [obj13pos1, 1]; dag2cobj setWaypointType 'SAD'; dag2cobj setWaypointCombatMode 'RED'; deploygroup2c setCurrentWaypoint dag2cobj; _usrtb13one = getMarkerPos 'usdeploymark'; _hemttrtb13one = hemttcrew13one addWaypoint [_usrtb13one, 1]; _hemttrtb13one setWaypointType 'MOVE'; _hemttrtb13one setWaypointStatements ['true', '{starthemtt13one deleteVehicleCrew _x} forEach crew starthemtt13one; deleteVehicle starthemtt13one;']; Share this post Link to post Share on other sites
Larrow 2822 Posted July 19, 2015 (edited) Can you explain what thislist does?I didn't find it on the scripting commands BIS page and Google wasn't particularly helpful Its not a command it is a special variable only used in waypoint and trigger statements. see Here for Waypoints.Can this be achieved with the thislist thing? Who is that original waypoint given to? I cant quiet make it out from the code given, if its a Unload WP then you would of thought it was one of the groups yet you handle the groups leaving separately within the statement, if its a Transport Unload then im not quite sure why you handle the hemtt within the statement. Can you show me the code for the group/s before this for the whole scenario e.g spawn getin moveto unload etc, the waypoint type given by addWaypoint's. Edited July 19, 2015 by Larrow Share this post Link to post Share on other sites
lawman_actual 24 Posted July 19, 2015 (edited) Apologies. Here is a little more of the script. _register = 12; _alist = usstarts; for "_i" from 1 to 20 step 1 do { _subject = [_alist call BIS_fnc_selectRandom]; _trial = (markerlist find (_subject select 0)); if (((usattacking select _trial) + _register) <= maxatobj) then {numbhandle = _trial; _i = 20;} else {_alist = _alist - _subject;}; }; newobj = markerlist select numbhandle; _current = usattacking select numbhandle; _new = _current + _register; usattacking set [numbhandle, _new]; _obj13pos1 = getMarkerPos newobj; _xpos13one = _obj13pos1 select 0; _ypos13one = _obj13pos1 select 1; _zpos13one = _obj13pos1 select 2; _location13one = [_xpos13one, _ypos13one, _zpos13one]; _distvar13one = [200,400] call BIS_fnc_randomInt; _greenzone13one = [(getMarkerPos newobj), (getMarkerPos "usfob")] call BIS_fnc_dirTo; _dirvar13one = [(_greenzone13one - 50), (_greenzone13one + 50)] call BIS_fnc_randomInt; _spawn13one = _distvar13one + 250; _startspawn13one = [_location13one, _spawn13one, _dirvar13one] call BIS_fnc_relPos; _location13one = [_xpos13one, _ypos13one, 0]; _startdeploy13one = [_location13one, _distvar13one, _dirvar13one] call BIS_fnc_relPos; _ATLZ13one = 0; _modATLZ13one = 1; for "_i" from 1 to 20 step 1 do { _intersectN13one = lineIntersectsWith [[(_startspawn13one select 0), (_startspawn13one select 1) + 2, _modATLZ13one], [(_startspawn13one select 0) + 0.2, (_startspawn13one select 1) + 2.2, _ATLZ13one + 0.25], objNull, objNull, false]; _intersectE13one = lineIntersectsWith [[(_startspawn13one select 0) + 2, (_startspawn13one select 1), _modATLZ13one], [(_startspawn13one select 0) + 2.2, (_startspawn13one select 1) + 0.2, _ATLZ13one + 0.25], objNull, objNull, false]; _intersectS13one = lineIntersectsWith [[(_startspawn13one select 0), (_startspawn13one select 1) - 1, _modATLZ13one], [(_startspawn13one select 0) - 0.2, (_startspawn13one select 1) - 2.2, _ATLZ13one + 0.25], objNull, objNull, false]; _intersectW13one = lineIntersectsWith [[(_startspawn13one select 0) - 2, (_startspawn13one select 1), _modATLZ13one], [(_startspawn13one select 0) - 2.2, (_startspawn13one select 1) - 0.2, _ATLZ13one + 0.25], objNull, objNull, false]; _intersectC13one = lineIntersectsWith [[(_startspawn13one select 0), (_startspawn13one select 1), _modATLZ13one], [(_startspawn13one select 0) + 0.1, (_startspawn13one select 1) + 0.1, _ATLZ13one + 0.25], objNull, objNull, false]; isclear = 0; treecheck = nearestObjects [_startdeploy13one, ["building","wall"], 20]; if (count treecheck >= 1) then {} else {isclear = 1;}; if (count _intersectN13one <= 0 && count _intersectE13one <= 0 && count _intersectS13one <= 0 && count _intersectW13one <= 0 && count _intersectC13one <= 0 && isclear == 1) then {_i = 20} else { _dismodifier = [15,30] call BIS_fnc_randomInt; _dirmodifier = [(_greenzone13one-50), (_greenzone13one+50)] call BIS_fnc_randomInt; _startspawn13one = [_startspawn13one, _dismodifier, _dirmodifier] call BIS_fnc_relPos; }; }; //B_Truck_01_covered_F also possible starthemtt13one = createVehicle ["B_Truck_01_transport_F", _startspawn13one, [], 0, "NONE"]; createVehicleCrew starthemtt13one; hemttcrew13one = group leader starthemtt13one; hemttcrew13one allowFleeing 0; starthemtt13one setDir ([(getPos starthemtt13one), (getMarkerPos newobj)] call BIS_fnc_dirTo); hemttcrew13one setCombatMode "BLUE"; unload13one = hemttcrew13one addWaypoint [_startdeploy13one, 1]; unload13one setWaypointType "MOVE"; hemttcrew13one setCurrentWaypoint unload13one; deploygroup2a = group dag2a1; deploygroup2b = group dag2b1; deploygroup2c = group dag2c1; unload13one setWaypointStatements ["true", "starthemtt13one lock false; doGetOut [dag2a1,dag2a2,dag2a3,dag2a4,dag2b1,dag2b2,dag2b3,dag2b4,dag2c1,dag2c2,dag2c3,dag2c4]; dag2a1 leaveVehicle starthemtt13one; dag2a2 leaveVehicle starthemtt13one; dag2a3 leaveVehicle starthemtt13one; dag2a4 leaveVehicle starthemtt13one; dag2b1 leaveVehicle starthemtt13one; dag2b2 leaveVehicle starthemtt13one; dag2b3 leaveVehicle starthemtt13one; dag2b4 leaveVehicle starthemtt13one; dag2c1 leaveVehicle starthemtt13one; dag2c2 leaveVehicle starthemtt13one; dag2c3 leaveVehicle starthemtt13one; dag2c4 leaveVehicle starthemtt13one; obj13pos1 = getMarkerPos newobj; dag2aobj = deploygroup2a addWaypoint [obj13pos1, 1]; dag2aobj setWaypointType 'SAD'; dag2aobj setWaypointCombatMode 'RED'; deploygroup2a setCurrentWaypoint dag2aobj; dag2bobj = deploygroup2b addWaypoint [obj13pos1, 1]; dag2bobj setWaypointType 'SAD'; dag2bobj setWaypointCombatMode 'RED'; deploygroup2b setCurrentWaypoint dag2bobj; dag2cobj = deploygroup2c addWaypoint [obj13pos1, 1]; dag2cobj setWaypointType 'SAD'; dag2cobj setWaypointCombatMode 'RED'; deploygroup2c setCurrentWaypoint dag2cobj; _usrtb13one = getMarkerPos 'usdeploymark'; _hemttrtb13one = hemttcrew13one addWaypoint [_usrtb13one, 1]; _hemttrtb13one setWaypointType 'MOVE'; _hemttrtb13one setWaypointStatements ['true', '{starthemtt13one deleteVehicleCrew _x} forEach crew starthemtt13one; deleteVehicle starthemtt13one;']; if (group player == group dag2a1 || group player == group dag2b1 || group player == group dag2c1) then { newobj setMarkerAlpha 1; } else {}; "]; //_usrtb13one = getMarkerPos "usdeploymark"; //_hemttrtb13one = hemttcrew13one addWaypoint [_usrtb13one, 1]; //_hemttrtb13one setWaypointType "MOVE"; //_hemttrtb13one setWaypointStatements ["true", "{starthemtt13one deleteVehicleCrew _x} forEach crew starthemtt13one; deleteVehicle starthemtt13one;"]; dag2a1 moveInCargo starthemtt13one; dag2a2 moveInCargo starthemtt13one; dag2a3 moveInCargo starthemtt13one; dag2a4 moveInCargo starthemtt13one; dag2b1 moveInCargo starthemtt13one; dag2b2 moveInCargo starthemtt13one; dag2b3 moveInCargo starthemtt13one; dag2b4 moveInCargo starthemtt13one; dag2c1 moveInCargo starthemtt13one; dag2c2 moveInCargo starthemtt13one; dag2c3 moveInCargo starthemtt13one; dag2c4 moveInCargo starthemtt13one; starthemtt13one lock true; And here is my first attempt at re-writing it in a more generic, repeatable form (haven't managed to test it out yet) if _h_vehicle == 4 then { _register = 12; _alist = usstarts; for "_x" from 1 to 20 step 1 do { _subject = [_alist call BIS_fnc_selectRandom]; _trial = (markerlist find (_subject select 0)); if (((usattacking select _trial) + _register) <= maxatobj) then {numbhandle = _trial; _x = 20;} else {_alist = _alist - _subject;}; }; newobj = markerlist select numbhandle; _current = usattacking select numbhandle; _new = _current + _register; usattacking set [numbhandle, _new]; _objpos = getMarkerPos newobj; _xpos = _objpos select 0; _ypos = _objpos select 1; _zpos = _objpos select 2; _location = [_xpos, _ypos, _zpos]; _distvar = [200,400] call BIS_fnc_randomInt; _greenzone = [(getMarkerPos newobj), (getMarkerPos "usfob")] call BIS_fnc_dirTo; _dirvar = [(_greenzone - 50), (_greenzone + 50)] call BIS_fnc_randomInt; _spawn = _distvar + 250; _startspawn = [_location, _spawn, _dirvar] call BIS_fnc_relPos; _location = [_xpos, _ypos, 0]; _startdeploy = [_location, _distvar, _dirvar] call BIS_fnc_relPos; _ATLZ = 0; _modATLZ = 1; for "_x" from 1 to 30 step 1 do { _intersectN = lineIntersectsWith [[(_startspawn select 0), (_startspawn select 1) + 2, _modATLZ], [(_startspawn select 0) + 0.2, (_startspawn select 1) + 2.2, _ATLZ + 0.25], objNull, objNull, false]; _intersectE = lineIntersectsWith [[(_startspawn select 0) + 2, (_startspawn select 1), _modATLZ], [(_startspawn select 0) + 2.2, (_startspawn select 1) + 0.2, _ATLZ + 0.25], objNull, objNull, false]; _intersectS = lineIntersectsWith [[(_startspawn select 0), (_startspawn select 1) - 1, _modATLZ], [(_startspawn select 0) - 0.2, (_startspawn select 1) - 2.2, _ATLZ + 0.25], objNull, objNull, false]; _intersectW = lineIntersectsWith [[(_startspawn select 0) - 2, (_startspawn select 1), _modATLZ], [(_startspawn select 0) - 2.2, (_startspawn select 1) - 0.2, _ATLZ + 0.25], objNull, objNull, false]; _intersectC = lineIntersectsWith [[(_startspawn select 0), (_startspawn select 1), _modATLZ], [(_startspawn select 0) + 0.1, (_startspawn select 1) + 0.1, _ATLZ + 0.25], objNull, objNull, false]; isclear = 0; treecheck = nearestObjects [_startdeploy, ["building","wall"], 20]; if (count treecheck >= 1) then {} else {isclear = 1;}; if (count _intersectN <= 0 && count _intersectE <= 0 && count _intersectS <= 0 && count _intersectW <= 0 && count _intersectC <= 0 && isclear == 1) then {_i = 30} else { _dismodifier = [15,30] call BIS_fnc_randomInt; _dirmodifier = [(_greenzone-50), (_greenzone+50)] call BIS_fnc_randomInt; _startspawn = [_startspawn, _dismodifier, _dirmodifier] call BIS_fnc_relPos; }; }; //B_Truck_01_covered_F also possible starthemtt = createVehicle ["B_Truck_01_transport_F", _startspawn, [], 0, "NONE"]; createVehicleCrew starthemtt; hemttcrew = group leader starthemtt; hemttcrew allowFleeing 0; starthemtt setDir ([(getPos starthemtt), (getMarkerPos newobj)] call BIS_fnc_dirTo); hemttcrew setCombatMode "BLUE"; w_unload = hemttcrew addWaypoint [_startdeploy, 1]; w_unload setWaypointType "MOVE"; hemttcrew setCurrentWaypoint w_unload; _newgroup = createGroup west; _dag1a1 = _newgroup createUnit ["B_Soldier_GL_F",[135,122,0],[],0.5,"CORPORAL"]; _dag1a1 addEventHandler ["killed", {null = call {_this execVM "respawni.sqf";}}]; _dag1a2 = _newgroup createUnit ["B_soldier_AR_F",getMarkerPos "respawn1",[],0.5,"PRIVATE"]; _dag1a2 addEventHandler ["killed", {null = call {_this execVM "respawni.sqf";}}]; _dag1a3 = _newgroup createUnit ["B_medic_F",getMarkerPos "respawn1",[],0.5,"PRIVATE"]; _dag1a3 addEventHandler ["killed", {null = call {_this execVM "respawni.sqf";}}]; _dag1a4 = _newgroup createUnit ["B_soldier_F",getMarkerPos "respawn1",[],0.5,"PRIVATE"]; _dag1a4 addEventHandler ["killed", {null = call {_this execVM "respawni.sqf";}}]; _dag1b1 = _newgroup createUnit ["B_Soldier_GL_F",[135,122,0],[],0.5,"CORPORAL"]; _dag1b1 addEventHandler ["killed", {null = call {_this execVM "respawni.sqf";}}]; _dag1b2 = _newgroup createUnit ["B_soldier_AR_F",getMarkerPos "respawn1",[],0.5,"PRIVATE"]; _dag1b2 addEventHandler ["killed", {null = call {_this execVM "respawni.sqf";}}]; _dag1b3 = _newgroup createUnit ["B_medic_F",getMarkerPos "respawn1",[],0.5,"PRIVATE"]; _dag1b3 addEventHandler ["killed", {null = call {_this execVM "respawni.sqf";}}]; _dag1b4 = _newgroup createUnit ["B_soldier_F",getMarkerPos "respawn1",[],0.5,"PRIVATE"]; _dag1b4 addEventHandler ["killed", {null = call {_this execVM "respawni.sqf";}}]; _dag1c1 = _newgroup createUnit ["B_Soldier_GL_F",[135,122,0],[],0.5,"CORPORAL"]; _dag1c1 addEventHandler ["killed", {null = call {_this execVM "respawni.sqf";}}]; _dag1c2 = _newgroup createUnit ["B_soldier_AR_F",getMarkerPos "respawn1",[],0.5,"PRIVATE"]; _dag1c2 addEventHandler ["killed", {null = call {_this execVM "respawni.sqf";}}]; _dag1c3 = _newgroup createUnit ["B_medic_F",getMarkerPos "respawn1",[],0.5,"PRIVATE"]; _dag1c3 addEventHandler ["killed", {null = call {_this execVM "respawni.sqf";}}]; _dag1c4 = _newgroup createUnit ["B_soldier_F",getMarkerPos "respawn1",[],0.5,"PRIVATE"]; _dag1c4 addEventHandler ["killed", {null = call {_this execVM "respawni.sqf";}}]; us_tickets = us_tickets - _register; if chosenside == 1 then { potentialunits = potentialunits + [_dag1a1,_dag1a2,_dag1a3,_dag1a4,_dag1b1,_dag1b2,_dag1b3,_dag1b4,_dag1c1,_dag1c2,_dag1c3,_dag1c4]; } else {}; w_unload setWaypointStatements ["true", " _myvehicle = vehicle thislist select 0; _myvehicle lock false; _increw = (crew _myvehicle); _incargo = thislist - _increw; { doGetOut _x} foreach _incargo; {_x leaveVehicle (vehicle _increw)} foreach _incargo; objpos = getMarkerPos newobj; _aunit = _incargo call BIS_fnc_selectRandom; alphagroup = group _aunit; _incargo = _incargo - units alphagroup; _aunit = _incargo call BIS_fnc_selectRandom; bravogroup = group _aunit; _incargo = _incargo - units bravogroup; _aunit = _incargo call BIS_fnc_selectRandom; charliegroup = group _aunit; _incargo = _incargo - units charliegroup; alphaobj = alphagroup addWaypoint [objpos, 25]; alphaobj setWaypointType 'SAD'; alphaobj setWaypointCombatMode 'RED'; alphagroup setCurrentWaypoint alphaobj; bravoobj = bravogroup addWaypoint [objpos, 25]; bravoobj setWaypointType 'SAD'; bravoobj setWaypointCombatMode 'RED'; bravogroup setCurrentWaypoint bravoobj; charlieobj = deploygroup2c addWaypoint [obj13pos1, 1]; charlieobj setWaypointType 'SAD'; charlieobj setWaypointCombatMode 'RED'; charliegroup setCurrentWaypoint charlieobj; _rtbpos = getMarkerPos 'usdeploymark'; _rtb = _increw addWaypoint [_rtb, 50]; _rtb setWaypointType 'MOVE'; _rtb setWaypointStatements ['true', '{_myvehicle deleteVehicleCrew _x} forEach crew _myvehicle; deleteVehicle myvehicle;']; if player in _incargo then {newobj setMarkerAlpha 1;} else {}; "]; dag2a1 moveInCargo starthemtt; dag2a2 moveInCargo starthemtt; dag2a3 moveInCargo starthemtt; dag2a4 moveInCargo starthemtt; dag2b1 moveInCargo starthemtt; dag2b2 moveInCargo starthemtt; dag2b3 moveInCargo starthemtt; dag2b4 moveInCargo starthemtt; dag2c1 moveInCargo starthemtt; dag2c2 moveInCargo starthemtt; dag2c3 moveInCargo starthemtt; dag2c4 moveInCargo starthemtt; starthemtt lock true; if us_tickets < 4 then {_i = 50;} else {}; } else {}; }; ---------- Post added at 15:52 ---------- Previous post was at 15:41 ---------- I should also point out that although the waypoint is called "unload" it is not an unload waypoint ( I seem to remember I tried to use transport unload but I ran into problems and opted to just move and get out) Edited July 19, 2015 by Lawman_Actual Share this post Link to post Share on other sites
Larrow 2822 Posted July 20, 2015 Here something from messing around with your code, I've had to improvise in places and changed a lot of your variable names to save my sanity :) . Shame that testing is such a pita with AI driving, plus the fact the Hemtt cargo positions are still messed up even though it has been reported a number of times, hence the reason ive moved the groups behind the truck and told them to get in, otherwise you always leave someone behind forcing them in with moveInCargo, which is another reason the TR LOAD does not work correctly on its own as its waiting for the soldier left behind to catch up :/ . Overall it should give you an idea on how to use this and thislist in waypoint statements. _register = 12; _alist = usstarts; _numHandle = for "_i" from 1 to 20 do { _subject = _alist call BIS_fnc_selectRandom; _trial = markerlist find _subject; if (((usattacking select _trial) + _register) <= maxatobj) exitWith { _trial }; _alist = _alist - _subject; }; _objectiveMkr = markerlist select _numHandle; usattacking set [_numHandle, ( usattacking select _numHandle ) + _register ]; _objective = getMarkerPos _objectiveMkr; _rndDist = ( random 200 ) + 200; _safeDir = [ _objective, getMarkerPos "usfob"] call BIS_fnc_dirTo; _rndSafeDir = _safeDir + (( random 100 ) - 50 ); _spawnPoint = [_objective, _rndDist + 250, _rndSafeDir] call BIS_fnc_relPos; _objective set [ 2, 0 ]; _deployPoint = [_objective, _rndDist, _rndSafeDir] call BIS_fnc_relPos; _truck = createVehicle ["B_Truck_01_transport_F", [ 0, 0, 2000 ], [], 0, "NONE"]; _truck enableSimulationGlobal false; _numAttempts = 20; _found = while { _numAttempts > 0 } do { _isFlat = _spawnPoint isFlatEmpty [ (sizeOf typeOf _truck ) / 2, 0, 0.25, (sizeOf typeOf _truck) / 2, 0, true, objNull ]; if !( _isFlat isEqualTo [] ) exitWith { true }; _numAttempts = _numAttempts - 1; _spawnPoint = [_spawnPoint, ( random 15 ) + 15, _safeDir + (( random 100 ) - 50 )] call BIS_fnc_relPos; }; if !( _found ) exitWith { [ "Could not find spawn position for Hemtt13one" ] call BIS_fnc_error }; _truck setPosATL _spawnPoint; _truck setDir ( [_spawnPoint, _objective ] call BIS_fnc_dirTo ); _truck enableSimulationGlobal true; createVehicleCrew _truck; _truckGroup = group leader _truck; _truckGroup allowFleeing 0; _truckGroup setCombatMode "BLUE"; _loadWP = _truckGroup addWaypoint [_spawnPoint, 0]; _loadWP setWaypointType "LOAD"; _loadWP setWaypointStatements [ " _units = units dag2a1 + units dag2b1 + units dag2c1; { _x in vehicle this }count _units isEqualTo count _units ", format [ " vehicle this lock true; _groups = []; { if !( group _x in _groups ) then { _group = group _x; _wp = _group addWaypoint [ %1, 10 ]; _wp setWaypointType 'GETOUT'; _wp = _group addWaypoint [ %2, 0 ]; _wp setWaypointType 'SAD'; _wp setWaypointCombatMode 'RED'; _groups pushback _group; }; }foreach assignedCargo vehicle this; ", _deployPoint, _objective ] ]; { { _x setPosATL ( [ _truck, ( random 10 ) + 5, getDirVisual _truck + 180 ] call BIS_fnc_relPos ); _x assignAsCargo _truck; [ _x ] orderGetIn true; }forEach units _x; }forEach [ group dag2a1, group dag2b1, group dag2c1 ]; _deployWP = _truckGroup addWaypoint [_deployPoint, 0]; _deployWP setWaypointType "TR UNLOAD"; _deployWP setWaypointCompletionRadius 5; _deployWP setWaypointStatements ["true", format [ " ( vehicle this ) lock false; { if ( isplayer _x ) then { [ { %1 setMarkerAlphaLocal 1 }, 'BIS_fnc_call', _x, false ] call BIS_fnc_MP; }; _x leaveVehicle vehicle this; }foreach assignedCargo vehicle this; ", str _objectiveMkr ]]; _returnWP = _truckGroup addWaypoint [ getMarkerPos "usdeploymark", 1]; _returnWP setWaypointType 'MOVE'; _returnWP setWaypointStatements ["true", "{deleteVehicle _x} forEach [ vehicle this ] + thislist;" ]; Share this post Link to post Share on other sites