Home   Help Search Login Register  

Author Topic: creating and set position  (Read 1287 times)

0 Members and 1 Guest are viewing this topic.

Offline 456820

  • Contributing Member
  • **
creating and set position
« 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

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Re:creating and set position
« Reply #1 on: 27 Mar 2005, 13:29:11 »
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.....
« Last Edit: 27 Mar 2005, 13:30:26 by Tyger »
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:creating and set position
« Reply #2 on: 27 Mar 2005, 13:42:15 »
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 ;)

Code: [Select]
_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.

Offline 456820

  • Contributing Member
  • **
Re:creating and set position
« Reply #3 on: 27 Mar 2005, 15:10:13 »
how would i put that with the create command Bedges
would it be

Code: [Select]
"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

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:creating and set position
« Reply #4 on: 27 Mar 2005, 18:16:49 »
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)]

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Re:creating and set position
« Reply #5 on: 28 Mar 2005, 00:21:25 »
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:
Code: [Select]
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))]
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Offline 456820

  • Contributing Member
  • **
Re:creating and set position
« Reply #6 on: 28 Mar 2005, 09:15:36 »
so with multiple units would it be the same but change the w1 to w2 for a new unit

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:creating and set position
« Reply #7 on: 28 Mar 2005, 11:36:09 »
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

Code: [Select]
_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.
« Last Edit: 28 Mar 2005, 11:37:05 by bedges »

Offline 456820

  • Contributing Member
  • **
Re:creating and set position
« Reply #8 on: 28 Mar 2005, 17:34:39 »
and one final quick question how do i just place a single unit 10metres above the ground from  its position

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:creating and set position
« Reply #9 on: 28 Mar 2005, 21:41:25 »
unit_name setpos [getpos unit_name select 0, getpos unit_name select 1, height]


Goettschwan

  • Guest
Re:creating and set position
« Reply #10 on: 14 May 2005, 16:51:24 »
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 :
Code: [Select]

this setpos[6814.813965,99.821884,6523.692383]

was not one of my really good ideas ?
Thanks, StG
« Last Edit: 14 May 2005, 16:52:14 by Goettschwan »

Goettschwan

  • Guest
Re:creating and set position
« Reply #11 on: 15 May 2005, 20:31:32 »
I will rephrase my question.
Why is it that
Code: [Select]
position[]={10821.918945,127.979996,3123.275879};
is used in the mission.sqm while the necessary setpos command to this position looks like this :
Code: [Select]
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
« Last Edit: 15 May 2005, 20:32:49 by Goettschwan »

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:creating and set position
« Reply #12 on: 15 May 2005, 20:38:11 »
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
I know a little about a lot, and a lot about a little.

Goettschwan

  • Guest
Re:creating and set position
« Reply #13 on: 16 May 2005, 11:27:56 »
Okay, thanks, planck. So Mission.sqm is a kind of alien.   ;)

StG

Rochelle

  • Guest
Re:creating and set position
« Reply #14 on: 16 May 2005, 21:33:26 »
you can add a waypoint over another press Shift Over the Car Again and While Pressing Shift Double Click the Car Again...