Skip to content

Add custom objects to your server or mission

Arkensor edited this page Jul 18, 2019 · 9 revisions

Step 1

Start the community offline mode using the DayZCommunityOfflineMode.bat file.

Step 2

Go into the freecam mode, this makes it much easier to fly around in the world to place down your objects.
You can go into the freecam mode by pressing INSERT on your keyboard.

Alternatively you can also toggle the free cam from the COM tool bar.
To do this Press Y (Z for QWERTZ-Keyboard users) and click the camera icon (last one in the list).
Now click the bottom right button Toggle camera in the menu that just opened. You can now press ESC to close the menu again.

Step 3

Press Y (Z for QWERTZ-Keyboard users) to bring up the COM tool bar.

Step 4

Open the object spawner (OB) which is called Items and Objects when opened. This is used for spawning in new objects into the world. Now open the object info panel (click the little robot arm icon). This panel is used to display info about select objects and also allows you to manipulate them.

Step 5

Spawn in a building/item using the object spawner. To do this you can for example use one of the filters on the left side of the Items and Objects panel. Click on Buildings and use the search input to filter/find certain class names or scroll through them using the mousewheel. You can see a preview of the object on the right side of the panel. You can also drag around the preview using your mouse.

When you decided which object you want to spawn, click the Cursor button that is located on the bottom left. This will spawn the selected object/item at the position you are currently looking at.

Step 6

While spawning the object at the cursor position already provides some rough placement, you might want to move around the object further or change its orientation. All these manipulations are done using the Object Info panel.

To manipulate an object/item you can click on it with your cursor, or click on the list of already spawned objects on the left of the panel.

When you have selected an object the class name (if available) will be displayed inside the panel together with the values for position and orientation. You can change these values by typing in numbers or by hovering over the numbers, and using the mouse wheel to increase/decrease them.

Step 7

After you placed down all objects you want to add, press SAVE in the Object Info panel. You can do this at any given time to ensure you don't loose your progress.
To export the objects simply press the EXPORT button. Now all placed objects will be exported and the code you need will be copied to your clipboard.

An example export could look like this:

//Spawn helper function
void SpawnObject( string type, vector position, vector orientation )
{
    auto obj = GetGame().CreateObject( type, position );
    obj.SetPosition( position );
    obj.SetOrientation( orientation );
    obj.SetOrientation( obj.GetOrientation() ); //Collision fix
    obj.Update();
    obj.SetAffectPathgraph( true, false );
    if( obj.CanAffectPathgraph() ) GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( GetGame().UpdatePathgraphRegionByObject, 100, false, obj );
}

//Your custom spawned objects
SpawnObject("Land_Construction_Crane", "6149.272949 28.847200 2346.562256", "-57.999992 0.000000 0.000000");
SpawnObject("Land_Construction_House2", "6159.585938 13.708900 2346.833008", "0.000000 0.000000 0.000000");

The SpawnObject helper function is used to spawn the objects. This function only needs to be present ONCE in your mission and can be placed nearly everywhere. However, the easiest way is to just put it at the top of your init.c.

The init.c can be found at the following places:

  • For servers: DayZServer\mpmissions\dayzOffline.chernarusplus\init.c
  • For the official offline mode: Steam\steamapps\common\DayZ\Missions\dayzOffline.ChernarusPlus\init.c
  • For the community offline mode: Steam\steamapps\common\DayZ\Missions\DayZCommunityOfflineMode.ChernarusPlus\init.c

To add the helper function to your init.c you would do something like this:

//Spawn helper function
void SpawnObject( string type, vector position, vector orientation )
{
    auto obj = GetGame().CreateObject( type, position );
    obj.SetPosition( position );
    obj.SetOrientation( orientation );
    obj.SetOrientation( obj.GetOrientation() ); //Collision fix
    obj.Update();
    obj.SetAffectPathgraph( true, false );
    if( obj.CanAffectPathgraph() ) GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( GetGame().UpdatePathgraphRegionByObject, 100, false, obj );
}

void main()
{
...

Now inside the void main() function you put the objects you just exported. So, in the end, it looks something like this:

//Spawn helper function
void SpawnObject( string type, vector position, vector orientation )
{
    auto obj = GetGame().CreateObject( type, position );
    obj.SetPosition( position );
    obj.SetOrientation( orientation );
    obj.SetOrientation( obj.GetOrientation() ); //Collision fix
    obj.Update();
    obj.SetAffectPathgraph( true, false );
    if( obj.CanAffectPathgraph() ) GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( GetGame().UpdatePathgraphRegionByObject, 100, false, obj );
}

void main()
{
//Your custom spawned objects
SpawnObject( "Land_Construction_Crane", "6149.272949 28.847200 2346.562256", "-57.999992 0.000000 0.000000" );
SpawnObject( "Land_Construction_House2", "6159.585938 13.708900 2346.833008", "0.000000 0.000000 0.000000" );
...

After saving the init.c you need to restart your server or game if it was for an offline mission. The objects should now be visible in-game where you previously placed them.

Step 8

Profit.

Note: How to enable loot spawn on your custom placed objects is being described on a different wiki page here: Enable loot for custom placed objects.