OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Lone~Wolf 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
-
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
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:
(blahblahblah_conditions) OR finishWP
Then, when you need to have the waypoint finished, have a script execute:
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 (http://www.ofpec.com/COMREF/index.php?action=details&id=153&game=OFP) 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
("_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
-
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: