Home   Help Search Login Register  

Author Topic: randomly positioning units on the map  (Read 758 times)

0 Members and 1 Guest are viewing this topic.

Atelophobia

  • Guest
randomly positioning units on the map
« on: 30 Oct 2002, 00:49:54 »
I've searched the forum unsuccessfully for a simple command that would randomly place a unit in 3 different locations on the map.  I have a hostage rescue mission completed except I don't want to know where the hostage will be each time.  I would like to teleport him, however the random command does not work.

I placed a trigger that would always be activated when the mission starts and on activation I added: rnd = random 2.

I then had three triggers that had condition rnd == 0, 1, or 2 which would then teleport my hostage to one of three areas.

The hostage never moved, and I tested the triggers by setting rnd = 1 or 2 manually, which then teleported the hostage.

Please let me know of an easy way to do this.

Thanks,
-Atelophobia



Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:randomly positioning units on the map
« Reply #1 on: 30 Oct 2002, 02:37:08 »
Welcome to the forums, Atelophobia

You've got the right idea... but the reason your trigger doesn't work is because the random command returns an integer. So when you tell OFP:

rnd = random 2

It gets a number between 0 and 2 (eg. 1.256). Now, your other triggers try to match that number, but since it will be very, very rare to get 1.000 or 2.000, they never go off.

What you need is a conditions looking like this:

rnd < 1
rnd >= 1 and rnd < 2
rnd >= 2

And make your original line:

rnd = random 3

So now your triggers will actually pick a position instead of missing the random number ;)

Atelophobia

  • Guest
Re:randomly positioning units on the map
« Reply #2 on: 30 Oct 2002, 03:10:58 »
Thanks for the help! I didn't even think that it would return a decimal. Now I feel dumb :)

-Atelophobia

Bremmer

  • Guest
Re:randomly positioning units on the map
« Reply #3 on: 30 Oct 2002, 10:34:49 »
A somewhat more straight-forward method is to place some empty markers where you want your unit to appear. Group these with the unit, and make sure that the unit is In Formation (in the special field). Now when the mission starts the unit will have an equal chance of appearing at each of the marker locations, and the location where you actually placed the unit on the map.

Cheers