Enable loot for custom placed objects - Arkensor/DayZCommunityOfflineMode GitHub Wiki
To enable loot spawn on your custom placed objects you will need to add just one extra line into your init.c
file mentioned in the wiki page Add custom objects to your server or mission, then perform a couple of other simple actions.
GetCEApi().ExportProxyData( "7500 0 7500", 10000 ); //Center of map, radius of how far to go out and find buildings.
The GetCEApi();
function is used to activate the Central Economy Testing subset of features. From here, you are able to call the ExportProxtData()
function, which takes 2 parameters. The first is the vector position of the center of the testing zone. The second is the radius around the center point to test for all buildings present on the map and potential loot locations.
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
Step 1
Inside the void main()
function you put this new line under the last custom placed object from your exported objects.
Important note: Make sure that the line containing GetCEApi().ExportProxyData(...)
is placed after the "CreateHive" function / INIT ECONOMY
//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()
{
...
//INIT ECONOMY --------------------------------------
Hive myHive = CreateHive();
...
//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" );
GetCEApi().ExportProxyData( "7500 0 7500", 10000 ); //Center of map, radius of how far to go out and find buildings.
...
Step 2
You will need to save your init.c file and start your server as you normally would. You are not done yet, there are more steps to go. We have now told the server to generate a new mapgrouppos.xml
file, but it does not put it right into the correct place to be used immediately. This process takes about 1-2 minutes, depending on the server hardware.
Step 3
You will need to now navigate to your storage_1
folder inside your mission (the number may vary depending on your host and configuration). Inside this folder you should find a folder named export
. Inside the export
folder, you will find a file named mapgrouppos.xml
The mapgrouppos.xml
can be found at the following places:
- For servers:
DayZServer\mpmissions\dayzOffline.chernarusplus\storage_1\export\mapgrouppos.xml
- For the official offline mode:
Steam\steamapps\common\DayZ\Missions\dayzOffline.ChernarusPlus\storage_1\export\mapgrouppos.xml
- For the community offline mode:
Steam\steamapps\common\DayZ\Missions\DayZCommunityOfflineMode.ChernarusPlus\storage_1\export\mapgrouppos.xml
Step 4
You will need to cut or copy this file and head back to the mission
folder.
The mission
folder can be found at the following places:
- For servers:
DayZServer\mpmissions\dayzOffline.chernarusplus
- For the official offline mode:
Steam\steamapps\common\DayZ\Missions\dayzOffline.ChernarusPlus
- For the community offline mode:
Steam\steamapps\common\DayZ\Missions\DayZCommunityOfflineMode.ChernarusPlus
Once inside the mission
folder, you will need to paste the mapgrouppos.xml
file and overwrite the existing file.
You're still not done yet.
Step 5
Shutdown your server via #shutdown command in rcon or by logging into the server as admin in-game (press t to type #login yourpassword
- changing yourpassword
for your admin password from your config) and then send the #shutdown
command via in-game chat. Wait patiently as this can take a couple of minutes to finish saving your persistence.
Step 6
Open your init.c
file again and comment out the new line we added
//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");
//GetCEApi().ExportProxyData( "7500 0 7500", 10000 ); //Centre of map, radius of how far to go out and find buildings.
...
This will prevent the XML file being generated on every server restart but can be uncommented when you add more custom placed objects, just make sure that if you keep this line AFTER
any new custom placed objects, otherwise they will not be present for the check. Save the init.c
file and close it.
Step 7
Final step! All you have to do now is turn your server on and head to your custom placed objects and check for loot!