OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Cap on 06 Sep 2005, 19:24:43
-
ok i want to make a mission where there are tons of flags and i was wondering if there was a way to detect if an east or west player was within a certain distance from any of the flags.
I know how to accomplish this with lots of triggers (ie. 2 for each flag one detecting east the other west), but wouldnt it be better to do this from a script? i was just wondering, otherwise i will use the trigger method.
btw i have 35 flags so that means 70 triggers just for the flags, is that not to many?
also i dont think that using unit names will do the job either cos if i have 10 units on each side that will take 20 lines of script for each flag min. Except if i create an array of the units on each side and write something like WestArray distance flag1 < 5, but it would have to be if 1 unit of the array is within the distance rather than ALL! lol.
Thx
-
i would use a script. this would make use of the nearestobject (http://www.ofpec.com/editors/comref.php?letter=N#nearestObject) command, and the side (http://www.ofpec.com/editors/comref.php?letter=S#side) command.
#loop
_unit = nearestobject [getpos flag_number]
?side _unit == west : west side is here - consequences
?side _unit == east : east side is here - consequences
_unit = nearestobject [getpos next_flag_number]
?side _unit == west : west side is here - consequences
?side _unit == east : east side is here - consequences
etc...
~1
goto "loop"
something along the lines of that
-
Yeah that would do it, excelent thx.
:D
-
no probs. and if i may be arrogant for a moment, 'arrogance' has two r's. :P