OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: 456820 on 27 Mar 2005, 13:20:38
-
i know how to create ubits and place them on a marker but not near the player i would like it 5 metres back from the player
and also how can you set position a created unit to the nearest house at position 1
-
to make a unit 5 meters behind the player:
w1 = "SoldierWB" createUnit [[getPos player select 0,(getPos player select 1)-5,getPos player select 2],groupAlpha]
or create the unit elsewhere and setPos him with the below:
unit setPos [getPos player select 0,(getPos player select 1)-5,0]
to setpos a unit into a house at a certain position:
you need to create the unit, then setPos him to whatever height the position is at, and then setPos the unit to exactally where you want him.
Not very quick or easy way.....
-
as far as i know, tyger's solution for the first problem will indeed work, but only if the player is facing north. to place something behind the player irrespective of what direction s/he is facing, use some trig - thanks THobson ;)
_dir = getdir player
_x = getpos player select 0
_y = getpos player select 1
object setpos [_x + (-5*sin(_dir)), _y + (-5*cos(_dir))]
off the top of my head, that should work.
-
how would i put that with the create command Bedges
would it be
"SoldierWLAW" createUnit [bravo1]
_dir = getdir player
_x = getpos player select 0
_y = getpos player select 1
object setpos [_x + (-5*sin(_dir)), _y + (-5*cos(_dir))]
or is it some other way
and thanks for the help
-
if you look at the createunit command in the comref, the positional part of it can use the directional elements i showed you...
type createUnit unitInfo
Operand types:
type: String
unitInfo: Array
Description:
Create unit of given type . Format of unitInfo is: [pos (Position),group (Group), init (String), skill (Number), rank (String)]
-
that was a good point bedges, didn't think about that ;)
@456820
You would just create the unit to a random spot away from the mission area and then setPos him using bedges' syntax.
I would suggest something like this:
w1 = "SoldierWB" createUnit [[0,0,1000],groupAlpha]
_dir = getdir player
_x = getpos player select 0
_y = getpos player select 1
w1 setpos [_x + (-5*sin(_dir)), _y + (-5*cos(_dir))]
-
so with multiple units would it be the same but change the w1 to w2 for a new unit
-
if you wanted to name the created units, yes.
but if you simply want loons, you don't really need to name them; all you need to do is assign them to a group, which you need to do anyways as part of the createunit command (i think).
so you could use
_dir = getdir player
_x = getpos player select 0
_y = getpos player select 1
"SoldierWB" createUnit [[_x + (-5*sin(_dir)), _y + (-5*cos(_dir))],groupAlpha]
"SoldierWB" createUnit [[_x + (-5*sin(_dir+20)), _y + (-5*cos(_dir+20))],groupAlpha]
to ensure the loons aren't created on top of each other, you could alter the _dir variable each time as shown above.
-
and one final quick question how do i just place a single unit 10metres above the ground from its position
-
unit_name setpos [getpos unit_name select 0, getpos unit_name select 1, height]
-
Is the coordinate setting of the setpos command not the same as the format used in the mission.sqm ?
I got some coordinates by putting different units on the map, then saving, copying the coordinates out of mission.sqm into a script as the setpos array, but when i execute the script instead of moving to the coordinate i pasted he reports being at the south end of the map. (i am FD45, he reports after the setpos FD99, the coordinates are maybe ten meters from me).
I used GPAs Display Unit Position snippet, and in the hint window there is something about scalar boolean, i can see his leader logo, he is falling from a really high place :tomato:
Could somebody guide me to some tutorial where the difference between these coordinate systems is explained or tell me right away that this :
this setpos[6814.813965,99.821884,6523.692383]
was not one of my really good ideas ?
Thanks, StG
-
I will rephrase my question.
Why is it that
position[]={10821.918945,127.979996,3123.275879};
is used in the mission.sqm while the necessary setpos command to this position looks like this :
this setpos[10821.918945,3123.275879,0]
which means that Y has changed place with Z, and Z has become zero because it has its zero counted from the terrain surface at this position.
What does the game do with the 127.979996 from mission.sqm ?
Is this the real elevation from the absolute zero of the maps Z axis ?
Thanks, StG
-
OFP is crazy and mixed up anyway.
AFAIK the convention used for OFP mostly is [x,z,y]
Where y is the height
The mission.sqm seems to do it differently.
The important thing in most instances is that the first 2 are the east/west, north/south positions and the last is the height.
Unless it is the mission.sqm apparently. ::) ::)
Planck
-
Okay, thanks, planck. So Mission.sqm is a kind of alien. ;)
StG
-
you can add a waypoint over another press Shift Over the Car Again and While Pressing Shift Double Click the Car Again...