Announcement

Collapse

New Releases Available

Please refer to our website or newsletter for updates on new releases.
See more
See less

Scripting repeating waypoint cycle

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Scripting repeating waypoint cycle

    Hi,
    we're trying to use the scripting engine to create and assign waypoints to a unit that should follow these waypoints in a patrolling like manner, i.e. the unit should follow these waypoints in a cyclic order and repeat it infinitely (or till the fuel of the vehicle gets empty). However, we do not know how to do this. There is the addWaypoint command to add waypoints to a specific group, but as soon as the waypoint is reached, it is removed from the map. We even tried to add the first waypoint position at the end to create some kind of cycle but it had no effect. Is there a way to assign waypoints that a unit follows repetitively?

  • #2
    //Make an array of all the waypoints, i.e 10 waypoints example _wparray = [ [1234, 2345, 0], [1236, 2366,0], ...]; remember array start at 0

    //get the group;
    _grp = group player;


    //create the loop
    while ( alive player ) do {
    //this will create the first waypoint which is _wparray [0]
    _grp setcurrentwaypoint [ _wparray[0], 1]; // set current start waypoint with index 1
    //this will create a route to follow and will go from 1 to 9 in the array, the waypoint index will from 2 to 10
    for "_x" from 1 to 9 do { _grp addwaypoint [_wparray[_x],0, _x + 1] };
    //if player is dead or when reaching the last created waypoint,
    //it will then return a non-existing current waypoint, in this case (11) and we start again
    waituntil { !( alive player ) or ( waypointCurrent _grp = 11 ) }; };
    //this should be close enough to work, tune it as req'd
    Last edited by denisboucher; 05-30-2019, 04:25 PM.

    Comment

    Working...
    X