Home   Help Search Login Register  

Author Topic: Is there a detect unit command?  (Read 583 times)

0 Members and 2 Guests are viewing this topic.

Cap

  • Guest
Is there a detect unit command?
« 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
« Last Edit: 06 Sep 2005, 19:28:28 by Neilos »

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:Is there a detect unit command?
« Reply #1 on: 06 Sep 2005, 19:42:23 »
i would use a script. this would make use of the nearestobject command, and the side command.

Code: [Select]
#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

Cap

  • Guest
Re:Is there a detect unit command?
« Reply #2 on: 06 Sep 2005, 19:47:48 »
Yeah that would do it, excelent thx.

:D

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:Is there a detect unit command?
« Reply #3 on: 06 Sep 2005, 21:02:28 »
no probs. and if i may be arrogant for a moment, 'arrogance' has two r's. :P
« Last Edit: 06 Sep 2005, 21:03:02 by bedges »