Home   Help Search Login Register  

Author Topic: Random Waypoints  (Read 2081 times)

0 Members and 1 Guest are viewing this topic.

Offline Cold

  • Members
  • *
  • Mission Maker
Random Waypoints
« on: 15 May 2007, 19:46:11 »
In OFP I had a command I could run from a units first waypoint that would make it choose between x number of markers to set a waypoint to at a random number. Essentially I would place a unit, place a "move" waypoint", and then a cycle waypoint somewhere behind the unit (not that it mattered). In the init line of the first waypoint is where I would place the code (I will edit that in later, I'm at work).

Once you preview the mission, the unit would move to one of the designated markers randomly and then on to the next marker and so on and so forth, it was never the same one twice. I copied the same line of code from an OFP mission into Arma and tried to do it the same way, but it doesn't work... I was wondering if it had something to do with the setWPPosision command? Is that command still used in ARMA?


Like I said, I'll get the specifics tonight when I get home, unless you scripting geniuses have other ways of making random waypoints for units... I just liked it because it was simple to use, and very customizable. Thanks guys.
A leader is best when people barely know he exists, when his work is done, his aim fulfilled, they will say: we did it ourselves. <br />Lao Tzu

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Random Waypoints
« Reply #1 on: 15 May 2007, 21:26:09 »
SetWPPos should still behave the same, but SetWPPosition for ArmA sets a waypoint position randomly within a circle that you specify by location and radius. Take a look at the COMREF for details.
urp!

Offline Cold

  • Members
  • *
  • Mission Maker
Re: Random Waypoints
« Reply #2 on: 15 May 2007, 21:43:51 »
I actually have taken a look at that... only my problem is that I don't necessarily need the waypoints just ANYWHERE in a circle... I may have mis-stated this in my first post. I need the waypoints to be set to specific markers only at a random number. say marker names: move_1, move_2, move_3, move_4.... they are all near different towns, so a car will drive to move_1 and once it has arrived it will select say - move_3, then move_2, move_4 and so on... all at random.
A leader is best when people barely know he exists, when his work is done, his aim fulfilled, they will say: we did it ourselves. <br />Lao Tzu

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Random Waypoints
« Reply #3 on: 16 May 2007, 03:33:32 »
Just to clarify, you are using SetWPPos not SetWPPosition. That was what I was getting at. If you want better help you'll have to provide a little more detail and show your code.

Also, do not forget that code strings in ArmA must be inside curly braces(not quotes) and that you must use call compile on them, not just call.
urp!

Offline Cold

  • Members
  • *
  • Mission Maker
Re: Random Waypoints
« Reply #4 on: 16 May 2007, 05:37:57 »
Sorry for the long delay. Here's the code:
[civcar, 1] setWPPos getMarkerPos (["move_1", "move_2", "move_3", "move_4"] Select (random 4));


Here's the situation: I have a civilian car named "civcar". On it's first waypoint I place this in the On Activation field (I have done so in OFP numerous times). The next waypoint is a simple cycle waypoint behind the vehicle. I have 4 markers throughout the area named "move_1, move_2, move_3, and move_4. With this code line, shouldn't the vehicle traverse to the markers at random, or is there an updated command for any of this in arma. Paron my ignorance Mr. Peanut but I'm not familiar with call compile.

« Last Edit: 16 May 2007, 23:18:57 by Cold »
A leader is best when people barely know he exists, when his work is done, his aim fulfilled, they will say: we did it ourselves. <br />Lao Tzu

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Random Waypoints
« Reply #5 on: 16 May 2007, 22:39:00 »
Your code should be in the On Activation field of the waypoint. One other small detail. To get an even chance of all markers use:
[civcar, 1] setWPPos getMarkerPos (["move_1", "move_2", "move_3", "move_4"] Select (floor(random 4)));

Otherwise I do not see any problems....  :dunno:

Edit. Ahhh I see your mistake. When referring to  WPs you must use a group not a unit. So use:
Code: [Select]
[group civcar, 1] setWPPos getMarkerPos (["move_1", "move_2", "move_3", "move_4"] Select (floor(random 4)));
« Last Edit: 16 May 2007, 22:52:16 by Mr.Peanut »
urp!

Offline Cold

  • Members
  • *
  • Mission Maker
Re: Random Waypoints
« Reply #6 on: 17 May 2007, 05:19:38 »
That did the trick! No more circling around or just sitting there. They go at random to each marker! Thanks Mr. Peanut!  :clap:
A leader is best when people barely know he exists, when his work is done, his aim fulfilled, they will say: we did it ourselves. <br />Lao Tzu