Jump to content
Sign in to follow this  
infiltrator_2k

Utilising Markers/waypoins As Triggers?

Recommended Posts

I've edited and used this script to spawn the helo and drop off troops, however, for performance reasons when the chopper's dropped off the troops I want him to fly off to marker5 and when reaching the next it I'd like the "deleteVehicle" command to delete it.

I'd rather utilise reaching the marker as a trigger to keep things tidy, but what code do I add to accomplish this? I've had a look around although I can't seem to find anything other than people running commands through actual inserted waypoints and not markers.

_crew1 = [];
_airframe1 = [];
_mygroup = [];

if (isServer) then {

_crew1 = creategroup EAST; 
_airframe1 = [getMarkerPos "marker1", 180, "O_Heli_Light_02_F", _crew1] call BIS_fnc_spawnVehicle;

_wp2 = _crew1 addWaypoint [(getmarkerpos "marker2"), 0];
_wp2 setWaypointType "MOVE";
_wp2 setWaypointSpeed "LIMITED";

_wp3 = _crew1 addWaypoint [(getmarkerpos "marker3"), 0];
_wp3 setWaypointType "MOVE";
_wp3 setWaypointSpeed "LIMITED";

_wp4 = _crew1 addWaypoint [(getmarkerpos "marker4"), 0];
_wp4 setWaypointType "TR UNLOAD";
_wp4 setWaypointSpeed "LIMITED";
_wp4 setwaypointstatements ["this land 'land'"];

_wp5 = _crew1 addWaypoint [(getmarkerpos "marker5"), 0];
_wp5 setWaypointType "MOVE";
_wp5 setWaypointSpeed "LIMITED";




_mygroup = [getmarkerpos "marker1", EAST, ["O_Soldier_F","O_Soldier_F","O_Soldier_F","O_Soldier_F","O_Soldier_F","O_Soldier_F","O_Soldier_F","O_Soldier_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
_wp1a = _mygroup addWaypoint [getmarkerpos "marker3", 0];

sleep .5;
_mygroup = _mygroup;
{ _x assignAsCargo (_airframe1 select 0); _x moveIncargo (_airframe1 select 0);} foreach units _mygroup;
}; 

Share this post


Link to post
Share on other sites

As far as I know the setWaypointStatements command might also help you delete helicopter when it reaches waypoint. Try something like this:

_wp5 setWaypointStatements["true", "{deleteVehicle _x} forEach crew (vehicle this) + [(vehicle this)]; deleteVehicle (vehicle this)"];

Dunno about markers though. I think it's impossible, otherwise markers would simply duplicate triggers functionality.

Edited by Semiconductor

Share this post


Link to post
Share on other sites
As far as I know the setWaypointStatements command might also help you delete helicopter when it reaches waypoint. Try something like this:

_wp5 setWaypointStatements["true", "{deleteVehicle _x} forEach crew (vehicle this) + [(vehicle this)]; deleteVehicle (vehicle this)"];

Dunno about markers though. I think it's impossible, otherwise markers would simply duplicate triggers functionality.

Works a treat thanks. The algorithm looks more complicated to action a simple command than it should be though :/ I mean, the vehicle is mention a whooping 5 times in a single line. I understand the crew must be deleted before the vehicle, but why is it necessary to mention "vehicle this" 3 times? or is it a typo?

Share this post


Link to post
Share on other sites

According to biki, "this" in setWaypointStatements refers to the group leader, not the vehicle, therefore "(vehicle this)" is used to obtain leader's vehicle so it can be deleted with all of its crew (which includes the leader).

But you're right, there is a typo - I accidentally forgot to remove "deleteVehicle (vehicle this)" command which tries to delete helicopter after it was already deleted. Here's a fixed version:

_wp5 setWaypointStatements["true", "{deleteVehicle _x} forEach crew (vehicle this) + [(vehicle this)];"];

There is no need in separate deleteVehicle command for helicopter since "+ [(vehicle this)]" adds it to the array of units that will be deleted in forEach cycle. But you can keep "deleteVehicle (vehicle this)" and remove "+ [(vehicle this)]" if you wish, it shouldn't make any difference. :)

Edited by Semiconductor

Share this post


Link to post
Share on other sites
According to biki, "this" in setWaypointStatements refers to the group leader, not the vehicle, therefore "(vehicle this)" is used to obtain leader's vehicle so it can be deleted with all of its crew (which includes the leader).

But you're right, there is a typo - I accidentally forgot to remove "deleteVehicle (vehicle this)" command which tries to delete helicopter after it was already deleted. Here's a fixed version:

_wp5 setWaypointStatements["true", "{deleteVehicle _x} forEach crew (vehicle this) + [(vehicle this)];"];

There is no need in separate deleteVehicle command for helicopter since "+ [(vehicle this)]" adds it to the array of units that will be deleted in forEach cycle. But you can keep "deleteVehicle (vehicle this)" and remove "+ [(vehicle this)]" if you wish, it shouldn't make any difference. :)

Cheers, that makes sense. I'm glad it was a typo because it threw me and I thought I'm never going to get my head around SQF. There's no doubt about it, learning to script is a steep learning curve. I've just started reading Mr Murray's guide so hopefully I'll be able to learn something from it.

Share this post


Link to post
Share on other sites

for wait until you reach the waypoint you can use this

_wp5 = _crew1 addWaypoint [(getmarkerpos "marker5"), 0];
_wp5 setWaypointType "MOVE";
_wp5 setWaypointSpeed "LIMITED";
waitUntil { (currentWaypoint (_wp5 select 0)) > (_wp5 select 1) };

after that you can delete the heli . Note that is a waituntil command means that all the code bellow will run after that .....

maybe you need to move some code before the waituntil .... _mygroup ,_wp1a .... you know when should be done in your mission.....

Edited by dragonsyr

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  

×