Jump to content

Recommended Posts

Hello Arma scripting gurus !

 

To give a bit of background, I'd like to make a mission where the waypoints order would be something like :

A1->A2->A3->| if(condition1) ->B1->B2->B3
            | if(condition2) ->C1->C2->C3
            | if(condition3) ->D1->D2->D3

I am aware that I can achieve this if I assign the A waypoints to the group, then on A3 completion check the conditions, then create and assign B,C or D using scripting commands.

However, I am not familiar with this method and I believe it would be inconvenient to give a position array for each waypoint I want to create.

 

Therefore, is there a way to do that "branching waypoints" using the 3D Editor ? Or at least how can I do it by scripting in the most user-friendly way ?

 

Thanks for you help !

Share this post


Link to post
Share on other sites

A quick solution:

 

//init.sqf or wherever you seem fit

//this function grabs markers that fit the criteria, i.e. branch1, branch2 etc
GOM_fnc_grabPositions = {
	params [["_filter",""]];
	if (_filter isEqualTo "") exitWith {systemchat "Wrong filter set!"};

	_wpMarkers = [];

	{

		if (toUpper _x find toUpper _filter >= 0) then {_wpMarkers pushback _x};

	} forEach allMapMarkers;

	_wpMarkers sort true;
	systemchat format ["Selected branches: %1",_wpMarkers];
	_return = _wpMarkers apply {getMarkerPos _x};
	{deletemarker _x} forEach _wpMarkers;
	_return

};

//this function assigns waypoints to the group that are of the input branch
GOM_fnc_branchWP = {
	params ["_group","_branch"];
	_positions = [_branch] call GOM_fnc_grabPositions;
	{
		_wp = _group addWaypoint [_x,0];
		_wp setWaypointType "MOVE";
	} forEach _positions;
};

//now in a trigger or last waypoint before the branching do this
[group test,selectRandom ["branch1","branch2","branch3"]] call GOM_fnc_branchWP;

This will make the group chose a random branch, you can also use any condition you want to pick the appropriate branch.

For branches simply place appropriate named markers as seen in the video (branch1, branch1_1, branch1_2 etc).

By copy-pasting markers the automated naming will take care of the ascending order of marker names.

 

You could easily enhance on this foundation, maybe add waypoint type filter into marker name, so a marker named "branch2_4_SAD" will make the waypoint of type seek and destroy if you add another check to the function etc.

 

 

Demo mission.

 

Cheers

  • Like 4

Share this post


Link to post
Share on other sites

Wonderful !

 

I can hardly thank you enough !

  • Like 1

Share this post


Link to post
Share on other sites

Also, for further reference, an alternative to achieve those "branching waypoints" would be:

  1. Create a group for each branch, for instance by placing a single unit.
  2. Set the probability of presence to 0 for each of those units. (So they don't spawn in the mission)
  3. Assign to each group the waypoints corresponding to the branch they represent. (Doable in the editor, Yay !)
  4. To assign a branch to the player once the conditions are met, use : (units group player) joinSilent GroupBranch1;

The 4th step basically moves all the units of the player's group (including the player) into the empty group to which the branch waypoints are assigned, therefore assigning the player's group those waypoints.

 

  • 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

×