OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Wildebeest on 27 Nov 2004, 12:57:52

Title: Deployment issue
Post by: Wildebeest on 27 Nov 2004, 12:57:52
Here's a tricky question for you. Or maybe not.

I'm making a strategic mission in which you may deploy units on the map before the action. I have a cannon with gunner and commander, but also some guys standing around it, all in the same group. Now, when I move the gun to another position on the map I make the guys "teleport" to the same spot like this:

onMapSingleClick {"_X setpos _pos" foreach Units rGrp1;  rGunGrp3 setpos [(getpos rGrp3_1 select 0),(getpos rGrp3_1 select 1),-0.2]}

The rGunGrp3 is the cannon and rGrp3_1 is just a guy in the group making the cannon get to the spot where he appears. Prolly a better way of solving that, but anyway, here's the problem. The guys who are supposed to be standing spread out around the cannon instead end up inside it, since they were teleported to the exact same spot.

Is there a way of making them appear next to the cannon instead of inside it when they are "teleported"?

Thx guys, yer the best  :)
Title: Re:Deployment issue
Post by: macguba on 27 Nov 2004, 13:40:50
Yes.    The secret is to split the whole thing into two stages.   Stage 1 teleports a central unit, for example the gun, to the position clicked on the map.    Then you have stage 2, which teleports all the other units to a position which is described relative to the central unit.

You can't use a simple forEach command, you have to have seperate command for each unit since each one is going to a different place.

loon1 setPos [(getPos gun1 select 0) + 2, (getPos gun1 select 1) - 3, 0]

That's just a simple version and syntax is not guaranteed.
Title: Re:Deployment issue
Post by: Wildebeest on 27 Nov 2004, 13:59:52
Thank you very much. That solved it.  :)