Home Editors Depot Missions Depot FAQ COMREF OFPEC Tags Forum
RSS

FAQ: Objects Index


How to place objects

The position of an object on the map is expressed as an array consisting of 3 numbers representing longitude, latitude and height. Thus a position of [0,0,0] would be a point at the extreme bottom left corner of the map, at 0 metres above the ground. The default height is 0 (probably due to gravity) and so a position can also be described with just longitude and latitude - the object will still be on the ground.


To find out the numerical position of an object

_objpos = getpos object_name

To find out the longitude (West/East) position of an object

_objposx = (getpos object_name select 0)

To find out the latitude (North/South) position of an object

_objposy = (getpos object_name select 1)

To instantly move an object to another position

object_name setpos new_position

new_position is the positional array at which you wish an object to appear, however not many mission editors write the positional array as three numbers in brackets i.e. [10,263,0]. A much more useful method is to place an empty marker on the map and use its positional array instead, like this

object_name setpos getmarkerpos "mk_barracks"

To instantly move an object relative to its current position

object_name setpos [(getpos object_name select 0) +10, getpos object_name select 1]

The example above will place the object 10 metres East of its current location.

You can also move an object relative to some other object:

object_name setpos [(getpos sandbags select 0) -1, (getpos sandbags select 1) + 2]

That example will place object_name 1 metre West and 2 metres North of the object sandbags.

You may wish to move an object relative to the direction the object is facing rather than North/South/East/West. This is a little more complex, requiring sin and cos, and the getdir command.

sandbags setpos [(getpos object_name select 0) + (10*sin(getdir object_name)), (getpos object_name select 1) + (10*cos(getdir object_name))]

That will place the object sandbags 10 metres directly in front of the object object_name, regardless of which direction object_name is facing. For a more detailed explanation of how this works, click here.


To instantly place an object higher up (for example on the first floor of a building)

object_name setpos [getpos object_name select 0, getpos object_name select 1, (getpos object_name select 2) + 5]

That will place object_name 5 metres in the air at his current position. When placing objects within buildings, height values need to be experimented with.


How to light a fire

In the init box of the fire's properties dialog, type

this inflame true

How to open/close doors

First of all, the building must have doors capable of opening and shutting, as there are many enterable buildings which have static doors, such as barns, and these cannot be animated. Nogova is the only default island with houses in which doors can be opened and closed. They are open by default, probably because Nogova has a very trusting population.

Take Victor Troska's house in Dolina as an example. The front door can be opened and closed. The command to close the door is

(object 137404) animate ["Dvere1", 1]

(object 137404) is the object ID of Troska's house. The animate command takes two parameters, the name of the animation to activate - in this case "Dvere1" - and the animation phase, or which state the animation is in. For doors there are two states; phase 0 indicates open, phase 1 indicates closed. More complicated animations are possible, with many phases.

See this demomission for examples of how to use this command.

You can also use the animationphase command to check which state the object is in.


How to switch on/off lights

The switchlight command is used to control the status of streetlights. The lightison command can be used to check if the light is on or not.

See this demomission for an example of how to use this command.


How to put a flag on a flagpole

All manner of flags are stored in the surprisingly named Flags.pbo addon. The command to assign a flag to a flagpole is setflagtexture. To put the Stars and Stripes on a flagpole use the following code:

flagpole_name setflagtexture "\flags\usa.jpg"

How to make a flock of seagulls

See this demomission.