Home   Help Search Login Register  

Author Topic: How Many waypoints?  (Read 1140 times)

0 Members and 1 Guest are viewing this topic.

Offline Lone~Wolf

  • Mission Tools & Mods
  • Members
  • *
  • Vladimir Dmitri Mikhail Andreevich Stamenov
How Many waypoints?
« on: 20 May 2010, 18:10:17 »
How would I find out, through a script, how many waypoints a unit has in total?

Alternatively, you could solve my problem by telling me if any command exists to automatically complete the waypoint, regardless of whether it's conditions have been met or if the unit is near.

Thx,
        Lone~Wolf  :D
Snarling creature, lurking in the background, still writing in .sqs

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: How Many waypoints?
« Reply #1 on: 20 May 2010, 18:49:40 »
Quote
How would I find out, through a script, how many waypoints a unit has in total?

With some hacking, probably. I'll look into it. But

Quote
Alternatively, you could solve my problem by telling me if any command exists to automatically complete the waypoint, regardless of whether it's conditions have been met or if the unit is near.

I know of no one command, but you could modify the conditions of the waypoint so that it is now of the form:

Code: [Select]
(blahblahblah_conditions) OR finishWP

Then, when you need to have the waypoint finished, have a script execute:

Code: [Select]
finishWP = true
[groupOne, 1] setWPPos getpos (leader groupOne)

A waypoint is complete when its conditions are met and the unit is nearby, so the above sort of code will complete any waypoint.

Does that work? :)

EDIT:

Indeed, with some hacking it appears to be possible to find out how many waypoints a unit has. Notice that the getWPPos returns [0,0,0] when it is asked to find the position of a non-existent waypoint. So, set up a script or function that will feed numbers to getWPPos, starting with 0 and increasing, and continue to do so until the returned array is [0,0,0]. Use

Code: [Select]
("_x == 0" count getWPPos [groupOne, _loopindex]) == 3

to check when this happens. Subtract one from your loop index, and you have the number of waypoints that your group has. I'm just assuming that no waypoints will be at exactly [0,0,0]. :D
« Last Edit: 21 May 2010, 14:22:24 by RKurtzDmitriyev »
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Offline Lone~Wolf

  • Mission Tools & Mods
  • Members
  • *
  • Vladimir Dmitri Mikhail Andreevich Stamenov
Re: How Many waypoints?
« Reply #2 on: 21 May 2010, 16:42:58 »
Hey,

I found that it's much easier just to look at the number of waypoints onesself and set the necessary parameter in the exec of the script,

e.g. a unit has 6 waypoints, so I type: "[this,6] exec {blahblahblah.sqs}"

etc.

Thanks anyway!  :good:
Snarling creature, lurking in the background, still writing in .sqs