Jump to content
Sign in to follow this  
Joe98

Random soldier placement: How to attach a waypoint?

Recommended Posts

In the editor I place a soldier on the map.

I place a series of waypoints so he will patrol due north.

The first waypoint is at a crossroads only 20 meters from the soldier.

I select random placement of the soldier in a circle of 1,000 meters.

When the scenario starts, the soldier appears at random within the circle.

However, the first waypoint, at that crossroads, is now 400 meters away!

How do I set it so that, no matter where the soldier begins on the map, he will always patrol due north?

-

Share this post


Link to post
Share on other sites

1. Remove the placement radius for your soldier and place him in a position that produces the desirable relative waypoint results (we'll reinstate the placement radius later).

2. Create a trigger with condition "true" (it will fire just after mission init), and in its activation have it execute the following script passing the name of the unit as the sole argument (e.g., "nul = enemyDude1 execVM 'findWaypointOffsets.sqf'"):

// findWaypointOffsets.sqf
_offsetArray = [];

{
_relPos = _this worldToModel (getWPPos _x);
_offsetArray = _offsetArray + [_relPos];
} forEach waypoints (group _this);

copyToClipboard (str _offsetArray);

3. Now, using the data that was just copied to your clipboard, create a new script:

// setWaypoints.sqf
_offsetArray = []; // replace this empty array with the data you have on your clipboard

{
_pos = _this modelToWorld _x;
(group _this) addWaypoint [_pos,0];
} forEach _offsetArray;

4. Finally, reinstate the desired placement radius for your unit. Remove all of his waypoints, and in his init field put:

nul = this execVM "setWaypoints.sqf"

You can delete the first script and the trigger that called it at this point. We only needed it to get the offset numbers.

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  

×