OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: NightJay0044 on 08 Sep 2005, 17:24:36

Title: Randomly Teleporting Objects/units?
Post by: NightJay0044 on 08 Sep 2005, 17:24:36
Hi if anyone wishes to answer this question or has a direct link, please provide. OTher if you post please post the necceassary steps of completing the procss. Such as first step to last step.

QUESTION:

!) How do I get a unit/object to teleport anywhere I want to, when the mission starts or if I want to via trigger/waypoint?

2) ALso how do I get an object/unit to teleport to 3 or more different locations when you start the mission to give a difficulty level for players?

Thanks for your time...
Title: Re:Randomly Teleporting Objects/units?
Post by: bedges on 08 Sep 2005, 18:39:30
1. take a look at the setpos command (http://www.ofpec.com/editors/comref.php?letter=S#setPos).

2. either - create 3 markers and group them to the unit you wish to place randomly

or

create three markers, empty markers are best.

copy/paste the following into a script -

Code: [Select]
_r = random 3
_r = _r - (_r mod 1)

?_r == 1 : unit_name setpos getmarkerpos "marker_1"
?_r == 2 : unit_name setpos getmarkerpos "marker_2"
?_r == 3 : unit_name setpos getmarkerpos "marker_3"

exit

save it as 'choose_position.sqs' and run it from the init line of a unit.
Title: Re:Randomly Teleporting Objects/units?
Post by: Blanco on 08 Sep 2005, 18:53:25
You can also do this without any script :
Lets say you need 10 random positions

1- Place your group or unit on the map
2- Place 9 markers (F6) next to them (the current position of your unit /group is the 10th position, so you 'll need 9 markers instead of 10)
3- Group (F2) every marker with that group or unit (when it's a group, you only have to group the marker with the leader)
4- Drag every marker to the place you want them to start.
5- Change all 9 markers to the "empty" type

When you preview the mission the group or unit will randomly start on one of those markerpositions.
Groups will start together btw and it works in MP.
That's all.  :)


Title: Re:Randomly Teleporting Objects/units?
Post by: RujiK on 09 Sep 2005, 03:28:07
Or to make it REALLY random, SO random it will virtually never be in the same place twice!!! You can just put this in the units init field:

Code: [Select]
this setpos [(getpos this select 0)+(random 500)-250,(getpos this select 0)+(random 500)-250,0]
The first time you do this its so random you might even think the game messed up and deleted the object! also if thats TOO random you may want to take the numbers down, like to 100-50 or something.
Title: Re:Randomly Teleporting Objects/units?
Post by: NightJay0044 on 09 Sep 2005, 03:33:36
Thanks a lot guys, I solved my question. I used "blanco" idea. Thanks for your idea to everyone else i didn't mention. You may add this to the FAQ if it's not already there OFPEC.  ;D

 :cheers: