Central Economy setup for custom terrains – DayZ

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
m (Some wiki formatting)
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Category:DayZ:Editing|Terrain]]
{{TOC|side}}
[[Category:DayZ:Terrain_Editing|Terrain]]
== Overview ==
 
==Overview==
This page describes basic steps to get a custom terrain working within the Central Economy system in DayZ.
This page describes basic steps to get a custom terrain working within the Central Economy system in DayZ.


Line 9: Line 8:
* Have a '''working custom terrain''' (mod) files, '''binarized and packed into pbo'''.
* Have a '''working custom terrain''' (mod) files, '''binarized and packed into pbo'''.


If you want to see an example of a terrain, I highly suggest you to take a look on a terrain sample in [https://data.bistudio.com/download/dayz/dayz_moddingsamples_r1.zip DayZ Samples package] (look out for ''Test_Terrain'') and read more about it on [[DayZ:Terrain sample| terrain sample page]].
If you want to see an example of a terrain, I highly suggest you to take a look on a terrain sample in DayZ Samples GitHub repository {{Link|https://github.com/BohemiaInteractive/DayZ-Samples/tree/master/Test_Terrain|here}} and read more about it on [[DayZ:Terrain sample| terrain sample page]].


==Mission files==
Central Economy setup can handled within the mission folder if user chooses to do so. One other advantage is that Central Economy works in single-player too, which simplifies the whole process and makes it easier to debug using single-player only diagnostics features, that are available in ''DayZDiag_x64.exe'' (more on that at LINK).


But before delving into that, we need to check the basics - mission folder name tells the game which terrain to load. It is essential to follow this naming convention '''mission_name.terrain_name'''. If you do not know the name of your terrain, I suggest you to take a look into a ''config.cpp'' file near your wrp file (name of the class in ''CfgWorlds''). Mission folder can be placed anywhere on your PC (launch parameter or server config can contain a full path).
== Mission files ==


Assuming your terrain is based on ''ChernarusPlus'' terrain assets, you can base your own mission on the mission files that are available in ''DZ\worlds\chernarusplus\ce'' (extracted game data from ''worlds_chernarusplus_ce.pbo''). This folder contains all default Central Economy files for this terrain. Copy all of those files into your newly created mission folder.
Central Economy setup can handled within the mission folder if user chooses to do so.
One other advantage is that Central Economy works in single-player too, which simplifies the whole process and makes it easier to debug using single-player only diagnostics features, that are available in ''DayZDiag_x64.exe'' (more on that at LINK).


In order to run a mission, you need to add a ''init.c'' script, which is responsible for the mission logic itself (creating playable character, initializing Central Economy,..). Content of ''init.c'' should look like following:
But before delving into that, we need to check the basics - mission folder name tells the game which terrain to load.
<syntaxhighlight lang="c++">
 
It is essential to follow this naming convention '''mission_name.terrain_name'''.
 
If you do not know the name of your terrain, I suggest you to take a look into a ''config.cpp'' file near your wrp file (name of the class in ''CfgWorlds'').
 
Mission folder can be placed anywhere on your PC (launch parameter or server config can contain a full path).
 
Assuming your terrain is based on ''ChernarusPlus'' terrain assets, you can base your own mission on the mission files that are available in ''DZ\worlds\chernarusplus\ce'' (extracted game data from ''worlds_chernarusplus_ce.pbo'').
 
This folder contains all default Central Economy files for this terrain.
 
Copy all of those files into your newly created mission folder.
 
In order to run a mission, you need to add a ''init.c'' script, which is responsible for the mission logic itself (creating playable character, initializing Central Economy, ...).
 
Content of ''init.c'' should look like following:
<enforce>
void main()
void main()
{
{
Line 32: Line 46:
GetGame().SelectPlayer(NULL, player);
GetGame().SelectPlayer(NULL, player);
};
};
</syntaxhighlight>
</enforce>
This simple ''init.c'' will attempt to initialize Central Economy and will create a playable character on given coordinates at ''spawnPos'' (you can change this vector to suit a location on your terrain and restart mission).
This simple ''init.c'' will attempt to initialize Central Economy and will create a playable character on given coordinates at ''spawnPos'' (you can change this vector to suit a location on your terrain and restart mission).


Lets take a quick look at the other files inside the mission folder:
Lets take a quick look at the other files inside the mission folder:


{| class="wikitable" style="width:100%;"
{| class="wikitable" style="width:100%"
|-
|-
! File name !! Purpose of the file
! File name !! Purpose of the file
|-
|-
| db\economy.xml || <tt>Main economy configuration file. Allows you to switch on and off init, load from storage, save to storage, respawn for selected groups of entities in CE (dynamic=loot, animals, zombies,..).</tt>
| db\economy.xml || {{hl|c= Main economy configuration file. Allows you to switch on and off init, load from storage, save to storage, respawn for selected groups of entities in CE (dynamic=loot, animals, zombies, ...).}}
|-
| db\events.xml || {{hl|c= Dynamic events configuration file. Used to define events such as helicrashes, cars, but also AI presence.}}
|-
|-
| db\events.xml || <tt>Dynamic events configuration file. Used to define events such as helicrashes, cars, but also AI presence.</tt>
| db\globals.xml || {{hl|c= Global variables configuration file. Used to change several variables affecting spawning mechanism, but also global limit of infected and animals.}}
|-
|-
| db\globals.xml || <tt>Global variables configuration file. Used to change several variables affecting spawning mechanism, but also global limit of infected and animals.</tt>
| db\types.xml || {{hl|c= Spawnable types configuration file. Used to define all available spawnable types and limiters of their presence in the world (min, nominal values, tags, categories, flags, ...).}}
|-
|-
| db\types.xml || <tt>Spawnable types configuration file. Used to define all available spawnable types and limiters of their presence in the world (min, nominal values, tags, categories, flags,..).</tt>
| env\.. || {{hl|c= Place for all animal and infected territory files.}}
|-
|-
| env\.. || <tt>Place for all animal and infected territory files.</tt>
| init.c || {{hl|c= Mission init script file.}}
|-
|-
| init.c || <tt>Mission init script file.</tt>
| cfgeconomycore.xml || {{hl|c= Basic configuration of Central Economy, do not change unless you know what you are doing.}}
|-
|-
| cfgeconomycore.xml || <tt>Basic configuration of Central Economy, do not change unless you know what you are doing.</tt>
| cfgenvironment.xml || {{hl|c= Configuration of animal herd and their territories.}}
|-
|-
| cfgenvironment.xml || <tt>Configuration of animal herd and their territories.</tt>
| cfgareaflags.xml || {{hl|c= Used to define limiter flags (usage and value) and their names used Central Economy Tool.}}
|-
|-
| cfgareaflags.xml || <tt>Used to define limiter flags (usage and value) and their names used Central Economy Tool.</tt>
| cfglimitsdefinition.xml || {{hl|c= Similar to cfgareaflags.xml, but this one in addition also contains definition for tag and category limiters.}}
|-
|-
| cfglimitsdefinition.xml || <tt>Similar to cfgareaflags.xml, but this one in addition also contains definition for tag and category limiters.</tt>
| cfglimitsdefinitionuser.xml || {{hl|c= User definitions for the limiters, defined in cfglimitsdefinition.xml. Usually allows a simpler definitions such as Tier234 and so on (to save space in db\types.xml file).}}
|-
|-
| cfglimitsdefinitionuser.xml || <tt>User definitions for the limiters, defined in cfglimitsdefinition.xml. Usually allows a simpler definitions such as Tier234 and so on (to save space in db\types.xml file).</tt>
| cfgeventspawns.xml || {{hl|c= Used to define positions (and rotation) for certain types of dynamic events (helicrashes, car spawns, ...).}}
|-
|-
| cfgeventspawns.xml || <tt>Used to define positions (and rotation) for certain types of dynamic events (helicrashes, car spawns,..).</tt>
| cfgplayerspawnpoints.xml || {{hl|c= Contains base positions for the player spawn point generation (only for the multiplayer mission). Resulting binary file will be generated into the storage folder during first new-player connection.}}
|-
|-
| cfgplayerspawnpoints.xml || <tt>Contains base positions for the player spawn point generation (only for the multiplayer mission). Resulting binary file will be generated into the storage folder during first new-player connection.</tt>
| cfgspawnabletypes.xml || {{hl|c= Used to define random contents of cargo (inventory) or random attachments for selected spawnable types (defined in db\types.xml).}}
|-
|-
| cfgspawnabletypes.xml || <tt>Used to define random contents of cargo (inventory) or random attachments for selected spawnable types (defined in db\types.xml).</tt>
| cfgrandompresets.xml || {{hl|c= Definitions of presets for random cargo or attachment spawning. Used in cfgspawnabletypes.xml.}}
|-
|-
| cfgrandompresets.xml || <tt>Definitions of presets for random cargo or attachment spawning. Used in cfgspawnabletypes.xml.</tt>
| mapclusterproto.xml || {{hl|c= Prototypes for cluster-type map groups (fruit trees, objects that spawn mushrooms, ...). Each prototype contains containers with spawn-points for loot.}}
|-
|-
| mapclusterproto.xml || <tt>Prototypes for cluster-type map groups (fruit trees, objects that spawn mushrooms,..). Each prototype contains containers with spawn-points for loot.</tt>
| mapgroupcluster.xml || {{hl|c= Exported positions of all cluster-type map groups. There can be more of these files (because of a limit on xml file-size). In that case, additional files end with number.}}
|-
|-
| mapgroupcluster.xml || <tt>Exported positions of all cluster-type map groups. There can be more of these files (because of a limit on xml file-size). In that case, additional files end with number.</tt>
| mapgroupdirt.xml || {{hl|c= Positions of all map groups (buildings), which are not tied to a specific map object.}}
|-
|-
| mapgrouppos.xml || <tt>Prototypes for standard map groups (buildings). Each prototype contains containers with spawn-points for loot.</tt>
| mapgrouppos.xml || {{hl|c= Exported positions of all standard map groups (buildings).}}
|-
|-
| mapgroupproto.xml|| <tt>Exported positions of all standard map groups (buildings).</tt>
| mapgroupproto.xml|| {{hl|c= Prototypes for standard map groups (buildings). Each prototype contains containers with spawn-points for loot.}}
|}
|}


As you can see, lot of important info is stored in the mission folder. '''Before proceeding any further''' I highly suggest to modify ''db\events.xml'' file. This file is really important as pretty much everything is driven by a dynamic event (including the loot that appears in houses). Why modify it now? We are basically using a Central Economy setup from another terrain and trying to fit it on your terrain. The less we have active at this point, the better. How to deactivate events? Open ''db\events.xml'' and search for ''<active>'' element. Set it to zero everywhere except an event called ''Loot''.
As you can see, lot of important info is stored in the mission folder.
 
 
'''Before proceeding any further''' I highly suggest to modify ''db\events.xml'' file.
 
This file is really important as pretty much everything is driven by a dynamic event (including the loot that appears in houses).
 
 
'''Why modify it now?'''
 
We are basically using a Central Economy setup from another terrain and trying to fit it on your terrain.


==Running the game==
The less we have active at this point, the better.
Once the ''init.c'' has been changed and dynamic events were deactivated, you can proceed by trying it in the game. As I have already mentioned, I recommend testing Central Economy in single-player mode. Here is what you should do in order to run it:
 
<syntaxhighlight lang="c++">
 
'''How to deactivate events?'''
 
Open ''db\events.xml'' and search for ''<active>'' element.
 
Set it to zero everywhere except an event called ''Loot''.
 
 
== Running the game ==
 
Once the ''init.c'' has been changed and dynamic events were deactivated, you can proceed by trying it in the game.
 
As I have already mentioned, I recommend testing Central Economy in single-player mode.
 
Here is what you should do in order to run it:
<syntaxhighlight lang="cpp">
DayZDiag_x64.exe -window -nopause -mod=yourmodfolder -mission=path_to_mission_folder
DayZDiag_x64.exe -window -nopause -mod=yourmodfolder -mission=path_to_mission_folder
</syntaxhighlight>
</syntaxhighlight>
You can also use ''DayZ Launcher'' and select mentioned parameters from the user interface, but it will run the standard ''DayZ_x64.exe''. Right now, it does not matter which exe file you choose as additional Central Economy diagnostics were not made public, but once they will, this guide will be updated and you will want to use DayZDiag_x64 over DayZ_x64 as default DayZ exe does not have these diagnostics.
You can also use ''DayZ Launcher'' and select mentioned parameters from the user interface, but it will run the standard ''DayZ_x64.exe''.
 
Right now, it does not matter which exe file you choose as additional Central Economy diagnostics were not made public, but once they will, this guide will be updated and you will want to use DayZDiag_x64 over DayZ_x64 as default DayZ exe does not have these diagnostics.
 


Lets take a look on what you should do each time you change a file in the mission folder (except the ''init.c'').
Lets take a look on what you should do each time you change a file in the mission folder (except the ''init.c'').
Line 95: Line 140:
# Once you are done observing the changes and ready to make additional changes, close the game and remove ''storage_-1''.
# Once you are done observing the changes and ready to make additional changes, close the game and remove ''storage_-1''.


Please note that ''storage_-1'' folder is the actual state of the Central Economy in your mission. This folder contains binary files only and their backups (you cant modify them, only the game does) and changes to the Central Economy mission files in most cases wont be applied '''unless you remove this folder''' and thus forcing the game to create a new one during the mission init. Also note that the storage folder may not always end with ''-1''. In that case, just remove any folder starting with ''storage_''.
Please note that ''storage_-1'' folder is the actual state of the Central Economy in your mission.
 
This folder contains binary files only and their backups (you cant modify them, only the game does) and changes to the Central Economy mission files in most cases wont be applied '''unless you remove this folder''' and thus forcing the game to create a new one during the mission init.
 
Also note that the storage folder may not always end with ''-1''.
 
In that case, just remove any folder starting with ''storage_''.
 
 
== Exporting data from the game ==


Now that you know how to run the game with a proper mission, its time to take a look how to generate key terrain-related data for your mission.


==Exporting data from the game==
Central Economy can initiate export (usually takes few seconds) of positions for:
Now that you know how to run the game with a proper mission, its time to take a look how to generate key terrain-related data for your mission. Central Economy can initiate export (usually takes few seconds) of positions for:
* '''standard map groups''' (buildings) - ''mapgrouppos.xml'', export is limited to a circle with specified center and radius (set it in a way it covers the whole terrain)
* '''standard map groups''' (buildings) - ''mapgrouppos.xml'', export is limited to a circle with specified center and radius (set it in a way it covers the whole terrain)
* '''cluster-type map groups''' (fruit trees etc.) - ''mapgroupscluster xml files'', export is done across the whole terrain
* '''cluster-type map groups''' (fruit trees etc.) - ''mapgroupscluster xml files'', export is done across the whole terrain
These files can be generated by executing a following ''init.c'':
These files can be generated by executing a following ''init.c'':
<syntaxhighlight lang="c++">
<enforce>
void main()
void main()
{
{
Line 110: Line 164:
GetHive().InitOffline();
GetHive().InitOffline();


// comment/remove following 2 lines when not exporting (can cause further issues if you do this each time you start a mission!)
// comment/remove the following 2 lines when not exporting (can cause further issues if you do this each time you start a mission!)
GetCEApi().ExportProxyData("2560 0 2560", 5120); // standard map groups (buildings) export, terrain center and radius needs to be specified
GetCEApi().ExportProxyData("2560 0 2560", 5120); // standard map groups (buildings) export, terrain center and radius needs to be specified
GetCEApi().ExportClusterData(); // cluster-type map groups export (fruit trees etc.)
GetCEApi().ExportClusterData(); // cluster-type map groups export (fruit trees etc.)
 
// player creation
// player creation
vector spawnPos = "3372 0 3090";
vector spawnPos = "3372 0 3090";
Line 120: Line 174:
GetGame().SelectPlayer(NULL, player);
GetGame().SelectPlayer(NULL, player);
};
};
</syntaxhighlight>
</enforce>
It is essential to call these methods after the ''GetHive().InitOffline()'' and not before. The output of these calls are xml files, which will be stored in ''storage_-1\export'' folder. These should be (assuming they look correct) be copied over to the root of the mission and overwrite the previously available (if any). After this is done, you can close the game, remove storage folder and remove export lines (or add ''//'' to comment them).
It is essential to call these methods after the <enforce inline>GetHive().InitOffline()</enforce> and not before.
After you start the game again, you should see loot the correctly placed where it should be. Look out for a building to quickly test it (you can change ''spawnPos'' of the player character).
 
The output of these calls are xml files, which will be stored in ''storage_-1\export'' folder.
 
These should be (assuming they look correct) be copied over to the root of the mission and overwrite the previously available (if any).
 
After this is done, you can close the game, remove storage folder and remove export lines (or add ''//'' to comment them).
 
After you start the game again, you should see loot the correctly placed where it should be.
 
Look out for a building to quickly test it (you can change ''spawnPos'' of the player character).
 
 
== Adjusting parameters ==
 
Exporting data from the game is just a tiny part of the process.


==Adjusting parameters==
Adjusting specific contents of the mission files is where most of the work is.


Exporting data from the game is just a tiny part of the process. Adjusting specific contents of the mission files is where most of the work is. So lets go through several things that you should be keeping an eye on when transforming ''ChernarusPlus'' Central Economy setup to suit your custom terrain.
So lets go through several things that you should be keeping an eye on when transforming ''ChernarusPlus'' Central Economy setup to suit your custom terrain.




'''db\types.xml'''
'''db\types.xml'''


It is very likely that your terrain will either have too little or too much space for loot (number of map groups - buildings will differ from ChernarusPlus) and thus you will need to '''modify min and nominal values for each spawnable type'''. This is important as it is necessary to prevent Central Economy from getting choked up with the spawn requests (to prevent search overtimes). You can also attempt to make less or more space by modifying/adding ''lootmax'' parameter to map groups and their containers in ''mapgroupproto.xml''. But be aware that only one piece of loot can end up on a spawnpoint, so essentially number of spawnpoints within a container equals max loot of that container. Unfortunately, tweaking the values without any feedback from the system is rather challenging, but there will be diagnostics available (as mentioned earlier), which will make this process a bit easier.
It is very likely that your terrain will either have too little or too much space for loot (number of map groups - buildings will differ from ChernarusPlus) and thus you will need to '''modify min and nominal values for each spawnable type'''.
 
This is important as it is necessary to prevent Central Economy from getting choked up with the spawn requests (to prevent search overtimes).
 
You can also attempt to make less or more space by modifying/adding ''lootmax'' parameter to map groups and their containers in ''mapgroupproto.xml''.
 
But be aware that only one piece of loot can end up on a spawnpoint, so essentially number of spawnpoints within a container equals max loot of that container.
 
Unfortunately, tweaking the values without any feedback from the system is rather challenging, but there will be diagnostics available (as mentioned earlier), which will make this process a bit easier.




'''cfgeventspawns.xml'''
'''cfgeventspawns.xml'''


As already mentioned, this file contains positions and rotations for position-based dynamic events (cars, helicrashes and so on). There are several types of these coordinates (depending on the event type) and number of ways you can get to these coordinates, but best is probably to use Terrain Builder to add dummy objects on selected positions and export the selection/layer from TB into txt file - just keep in mind that map frame border should be subtracted so the coordinates match the in-game coordinates. Once you have coordinates ready for a certain event, you can proceed in re-enabling such event in ''db\events.xml'' file.
As already mentioned, this file contains positions and rotations for position-based dynamic events (cars, helicrashes and so on).
 
There are several types of these coordinates (depending on the event type) and number of ways you can get to these coordinates, but best is probably to use Terrain Builder to add dummy objects on selected positions and export the selection/layer from TB into txt file - just keep in mind that map frame border should be subtracted so the coordinates match the in-game coordinates.
 
Once you have coordinates ready for a certain event, you can proceed in re-enabling such event in ''db\events.xml'' file.




'''cfgplayerspawnpoints.xml'''
'''cfgplayerspawnpoints.xml'''


This is tied to a multiplayer (server) mission (you cant really test the player spawnpoints in a singleplayer mode). Nonetheless, you need to prepare a set of spawnspoints first. Can be done the same way as the positions for dynamic events (mentioned above), coordinates are 2D and after you have them, you can put them into ''<generator_posbubbles>'' within the player spawnpoints xml file.
This is tied to a multiplayer (server) mission (you cant really test the player spawnpoints in a singleplayer mode).
 
Nonetheless, you need to prepare a set of spawnspoints first.
 
Can be done the same way as the positions for dynamic events (mentioned above), coordinates are 2D and after you have them, you can put them into ''<generator_posbubbles>'' within the player spawnpoints xml file.




'''areaflags.map'''
'''areaflags.map'''


As already mentioned, this file is optional and it is one of the outputs of Central Economy Tool. It allows you to limit loot to specific places, where individual standard map groups (buildings) will have usage or value flags assigned based on the info stored within this file. You should either not have it at all or have your own version as using one from ''ChernarusPlus'' mission will definitely not make your life easier. If you are interested in creating one, I suggest you take a look into the samples package, into the CETool project for ''ChernarusPlus'' terrain (LINK) to an idea how does it look like.
As already mentioned, this file is optional and it is one of the outputs of Central Economy Tool.


==AI support==
It allows you to limit loot to specific places, where individual standard map groups (buildings) will have usage or value flags assigned based on the info stored within this file.


Adding a support for AI on your terrain is perhaps a bit more challenging as it involves already mentioned Central Economy Tool, but samples can help here again. Take a look at the CETool project for ChernarusPlus (available in the samples package [https://data.bistudio.com/download/dayz/dayz_moddingsamples_r1.zip here]) to get an idea how that looks like. Similar CETool project can be created for your custom terrain too. The tool can export already mentioned ''areaflags.map'', but also territory/zone files for AI.
You should either not have it at all or have your own version as using one from ''ChernarusPlus'' mission will definitely not make your life easier.


AI also needs a link created between the territory/zone files and appropriate dynamic events. This can be done by modifying ''cfgenvironment.xml'' file in your mission. I would recommend to look at default file, used on ChernarusPlus (located at ''DZ\worlds\chernarusplus\ce'' or ''worlds_chernarusplus_ce.pbo'').
If you are interested in creating one, I suggest you take a look into the samples package, into the CETool project for ''ChernarusPlus'' terrain (get it {{Link|https://github.com/BohemiaInteractive/DayZ-Central-Economy/tree/master/CETool/ChernarusPlus|here}}) to an idea how does it look like.
 
 
== AI support ==
 
Adding a support for AI on your terrain is perhaps a bit more challenging as it involves already mentioned Central Economy Tool, but samples can help here again.
 
Take a look at the CETool project for ChernarusPlus (get it {{Link|https://github.com/BohemiaInteractive/DayZ-Central-Economy/tree/master/CETool/ChernarusPlus|here}}) to get an idea how that looks like.
 
Similar CETool project can be created for your custom terrain too.
 
The tool can export already mentioned ''areaflags.map'', but also territory/zone files for AI.
 
AI also needs a link created between the territory/zone files and appropriate dynamic events.
 
This can be done by modifying ''cfgenvironment.xml'' file in your mission.
 
I would recommend to look at default file, used on ChernarusPlus (located at ''DZ\worlds\chernarusplus\ce'' or ''worlds_chernarusplus_ce.pbo'').


As with everything else, AI spawners are also dynamic events so make sure you re-enable them once you feel that you have prepared rest of the things (they start with ''Animal'' or ''Infected'' words).
As with everything else, AI spawners are also dynamic events so make sure you re-enable them once you feel that you have prepared rest of the things (they start with ''Animal'' or ''Infected'' words).


==Default files==


Update 1.04 has brought the ability to define default Central Economy files. Previously, If you wanted to run a mission with Central Economy, all of the files were required in the mission folder itself. This often resulted in un-necessary data duplication. That is why default files were implemented. With 1.04, your completely vanilla ''ChernarusPlus'' mission requires only a ''init.c'' file, rest is taken automatically from a newly added pbo file (for ''ChernarusPlus'' it is ''worlds_chernarusplus_ce.pbo''). Additionally, you can override any file from the default folder by simply putting it into your mission folder on correct place and with correct name.
== Default files ==
 
Update 1.04 has brought the ability to define default Central Economy files.
 
Previously, If you wanted to run a mission with Central Economy, all of the files were required in the mission folder itself. This often resulted in un-necessary data duplication.
 
That is why default files were implemented.
 
With 1.04, your completely vanilla ''ChernarusPlus'' mission requires only a ''init.c'' file, rest is taken automatically from a newly added pbo file (for ''ChernarusPlus'' it is ''worlds_chernarusplus_ce.pbo'').
 
Additionally, you can override any file from the default folder by simply putting it into your mission folder on correct place and with correct name.


This feature can be implemented the same way for your own terrain, just make sure you add following parameter into the config:
This feature can be implemented the same way for your own terrain, just make sure you add following parameter into the config:
<syntaxhighlight lang="c++">
<syntaxhighlight lang="cpp">
ceFiles = "yourprefix\yourterrain\ce";
ceFiles = "yourprefix\yourterrain\ce";
</syntaxhighlight>
</syntaxhighlight>
You can also look at the [[DayZ:Terrain sample| terrain sample]] to get an idea how the implementation of default Central Economy files should look like.
You can also look at the [[DayZ:Terrain sample| terrain sample]] to get an idea how the implementation of default Central Economy files should look like.
{{GameCategory|dayz|Central Economy}}
{{GameCategory|dayz|Terrain Editing}}

Latest revision as of 12:48, 2 November 2023

Overview

This page describes basic steps to get a custom terrain working within the Central Economy system in DayZ.

Requirements:

  • DayZ and DayZ Tools package installed.
  • Have a working custom terrain (mod) files, binarized and packed into pbo.

If you want to see an example of a terrain, I highly suggest you to take a look on a terrain sample in DayZ Samples GitHub repository here and read more about it on terrain sample page.


Mission files

Central Economy setup can handled within the mission folder if user chooses to do so. One other advantage is that Central Economy works in single-player too, which simplifies the whole process and makes it easier to debug using single-player only diagnostics features, that are available in DayZDiag_x64.exe (more on that at LINK).

But before delving into that, we need to check the basics - mission folder name tells the game which terrain to load.

It is essential to follow this naming convention mission_name.terrain_name.

If you do not know the name of your terrain, I suggest you to take a look into a config.cpp file near your wrp file (name of the class in CfgWorlds).

Mission folder can be placed anywhere on your PC (launch parameter or server config can contain a full path).

Assuming your terrain is based on ChernarusPlus terrain assets, you can base your own mission on the mission files that are available in DZ\worlds\chernarusplus\ce (extracted game data from worlds_chernarusplus_ce.pbo).

This folder contains all default Central Economy files for this terrain.

Copy all of those files into your newly created mission folder.

In order to run a mission, you need to add a init.c script, which is responsible for the mission logic itself (creating playable character, initializing Central Economy, ...).

Content of init.c should look like following:

void main() { // economy init CreateHive(); GetHive().InitOffline(); // player creation vector spawnPos = "3372 0 3090"; Entity playerEnt = GetGame().CreatePlayer(NULL, "SurvivorF_Eva", spawnPos, 0, "NONE"); PlayerBase player = (PlayerBase) playerEnt; GetGame().SelectPlayer(NULL, player); };

This simple init.c will attempt to initialize Central Economy and will create a playable character on given coordinates at spawnPos (you can change this vector to suit a location on your terrain and restart mission).


Lets take a quick look at the other files inside the mission folder:

File name Purpose of the file
db\economy.xml Main economy configuration file. Allows you to switch on and off init, load from storage, save to storage, respawn for selected groups of entities in CE (dynamic=loot, animals, zombies, ...).
db\events.xml Dynamic events configuration file. Used to define events such as helicrashes, cars, but also AI presence.
db\globals.xml Global variables configuration file. Used to change several variables affecting spawning mechanism, but also global limit of infected and animals.
db\types.xml Spawnable types configuration file. Used to define all available spawnable types and limiters of their presence in the world (min, nominal values, tags, categories, flags, ...).
env\.. Place for all animal and infected territory files.
init.c Mission init script file.
cfgeconomycore.xml Basic configuration of Central Economy, do not change unless you know what you are doing.
cfgenvironment.xml Configuration of animal herd and their territories.
cfgareaflags.xml Used to define limiter flags (usage and value) and their names used Central Economy Tool.
cfglimitsdefinition.xml Similar to cfgareaflags.xml, but this one in addition also contains definition for tag and category limiters.
cfglimitsdefinitionuser.xml User definitions for the limiters, defined in cfglimitsdefinition.xml. Usually allows a simpler definitions such as Tier234 and so on (to save space in db\types.xml file).
cfgeventspawns.xml Used to define positions (and rotation) for certain types of dynamic events (helicrashes, car spawns, ...).
cfgplayerspawnpoints.xml Contains base positions for the player spawn point generation (only for the multiplayer mission). Resulting binary file will be generated into the storage folder during first new-player connection.
cfgspawnabletypes.xml Used to define random contents of cargo (inventory) or random attachments for selected spawnable types (defined in db\types.xml).
cfgrandompresets.xml Definitions of presets for random cargo or attachment spawning. Used in cfgspawnabletypes.xml.
mapclusterproto.xml Prototypes for cluster-type map groups (fruit trees, objects that spawn mushrooms, ...). Each prototype contains containers with spawn-points for loot.
mapgroupcluster.xml Exported positions of all cluster-type map groups. There can be more of these files (because of a limit on xml file-size). In that case, additional files end with number.
mapgroupdirt.xml Positions of all map groups (buildings), which are not tied to a specific map object.
mapgrouppos.xml Exported positions of all standard map groups (buildings).
mapgroupproto.xml Prototypes for standard map groups (buildings). Each prototype contains containers with spawn-points for loot.

As you can see, lot of important info is stored in the mission folder.


Before proceeding any further I highly suggest to modify db\events.xml file.

This file is really important as pretty much everything is driven by a dynamic event (including the loot that appears in houses).


Why modify it now?

We are basically using a Central Economy setup from another terrain and trying to fit it on your terrain.

The less we have active at this point, the better.


How to deactivate events?

Open db\events.xml and search for <active> element.

Set it to zero everywhere except an event called Loot.


Running the game

Once the init.c has been changed and dynamic events were deactivated, you can proceed by trying it in the game.

As I have already mentioned, I recommend testing Central Economy in single-player mode.

Here is what you should do in order to run it:

DayZDiag_x64.exe -window -nopause -mod=yourmodfolder -mission=path_to_mission_folder

You can also use DayZ Launcher and select mentioned parameters from the user interface, but it will run the standard DayZ_x64.exe.

Right now, it does not matter which exe file you choose as additional Central Economy diagnostics were not made public, but once they will, this guide will be updated and you will want to use DayZDiag_x64 over DayZ_x64 as default DayZ exe does not have these diagnostics.


Lets take a look on what you should do each time you change a file in the mission folder (except the init.c).

  1. Make sure the game is not running.
  2. Do the modifications within the mission files.
  3. Run DayZ using the parameters provided earlier.
  4. Once you are done observing the changes and ready to make additional changes, close the game and remove storage_-1.

Please note that storage_-1 folder is the actual state of the Central Economy in your mission.

This folder contains binary files only and their backups (you cant modify them, only the game does) and changes to the Central Economy mission files in most cases wont be applied unless you remove this folder and thus forcing the game to create a new one during the mission init.

Also note that the storage folder may not always end with -1.

In that case, just remove any folder starting with storage_.


Exporting data from the game

Now that you know how to run the game with a proper mission, its time to take a look how to generate key terrain-related data for your mission.

Central Economy can initiate export (usually takes few seconds) of positions for:

  • standard map groups (buildings) - mapgrouppos.xml, export is limited to a circle with specified center and radius (set it in a way it covers the whole terrain)
  • cluster-type map groups (fruit trees etc.) - mapgroupscluster xml files, export is done across the whole terrain

These files can be generated by executing a following init.c:

void main() { // economy init CreateHive(); GetHive().InitOffline(); // comment/remove the following 2 lines when not exporting (can cause further issues if you do this each time you start a mission!) GetCEApi().ExportProxyData("2560 0 2560", 5120); // standard map groups (buildings) export, terrain center and radius needs to be specified GetCEApi().ExportClusterData(); // cluster-type map groups export (fruit trees etc.) // player creation vector spawnPos = "3372 0 3090"; Entity playerEnt = GetGame().CreatePlayer(NULL, "SurvivorF_Eva", spawnPos, 0, "NONE"); PlayerBase player = (PlayerBase) playerEnt; GetGame().SelectPlayer(NULL, player); };

It is essential to call these methods after the GetHive().InitOffline() and not before.

The output of these calls are xml files, which will be stored in storage_-1\export folder.

These should be (assuming they look correct) be copied over to the root of the mission and overwrite the previously available (if any).

After this is done, you can close the game, remove storage folder and remove export lines (or add // to comment them).

After you start the game again, you should see loot the correctly placed where it should be.

Look out for a building to quickly test it (you can change spawnPos of the player character).


Adjusting parameters

Exporting data from the game is just a tiny part of the process.

Adjusting specific contents of the mission files is where most of the work is.

So lets go through several things that you should be keeping an eye on when transforming ChernarusPlus Central Economy setup to suit your custom terrain.


db\types.xml

It is very likely that your terrain will either have too little or too much space for loot (number of map groups - buildings will differ from ChernarusPlus) and thus you will need to modify min and nominal values for each spawnable type.

This is important as it is necessary to prevent Central Economy from getting choked up with the spawn requests (to prevent search overtimes).

You can also attempt to make less or more space by modifying/adding lootmax parameter to map groups and their containers in mapgroupproto.xml.

But be aware that only one piece of loot can end up on a spawnpoint, so essentially number of spawnpoints within a container equals max loot of that container.

Unfortunately, tweaking the values without any feedback from the system is rather challenging, but there will be diagnostics available (as mentioned earlier), which will make this process a bit easier.


cfgeventspawns.xml

As already mentioned, this file contains positions and rotations for position-based dynamic events (cars, helicrashes and so on).

There are several types of these coordinates (depending on the event type) and number of ways you can get to these coordinates, but best is probably to use Terrain Builder to add dummy objects on selected positions and export the selection/layer from TB into txt file - just keep in mind that map frame border should be subtracted so the coordinates match the in-game coordinates.

Once you have coordinates ready for a certain event, you can proceed in re-enabling such event in db\events.xml file.


cfgplayerspawnpoints.xml

This is tied to a multiplayer (server) mission (you cant really test the player spawnpoints in a singleplayer mode).

Nonetheless, you need to prepare a set of spawnspoints first.

Can be done the same way as the positions for dynamic events (mentioned above), coordinates are 2D and after you have them, you can put them into <generator_posbubbles> within the player spawnpoints xml file.


areaflags.map

As already mentioned, this file is optional and it is one of the outputs of Central Economy Tool.

It allows you to limit loot to specific places, where individual standard map groups (buildings) will have usage or value flags assigned based on the info stored within this file.

You should either not have it at all or have your own version as using one from ChernarusPlus mission will definitely not make your life easier.

If you are interested in creating one, I suggest you take a look into the samples package, into the CETool project for ChernarusPlus terrain (get it here) to an idea how does it look like.


AI support

Adding a support for AI on your terrain is perhaps a bit more challenging as it involves already mentioned Central Economy Tool, but samples can help here again.

Take a look at the CETool project for ChernarusPlus (get it here) to get an idea how that looks like.

Similar CETool project can be created for your custom terrain too.

The tool can export already mentioned areaflags.map, but also territory/zone files for AI.

AI also needs a link created between the territory/zone files and appropriate dynamic events.

This can be done by modifying cfgenvironment.xml file in your mission.

I would recommend to look at default file, used on ChernarusPlus (located at DZ\worlds\chernarusplus\ce or worlds_chernarusplus_ce.pbo).

As with everything else, AI spawners are also dynamic events so make sure you re-enable them once you feel that you have prepared rest of the things (they start with Animal or Infected words).


Default files

Update 1.04 has brought the ability to define default Central Economy files.

Previously, If you wanted to run a mission with Central Economy, all of the files were required in the mission folder itself. This often resulted in un-necessary data duplication.

That is why default files were implemented.

With 1.04, your completely vanilla ChernarusPlus mission requires only a init.c file, rest is taken automatically from a newly added pbo file (for ChernarusPlus it is worlds_chernarusplus_ce.pbo).

Additionally, you can override any file from the default folder by simply putting it into your mission folder on correct place and with correct name.

This feature can be implemented the same way for your own terrain, just make sure you add following parameter into the config:

ceFiles = "yourprefix\yourterrain\ce";

You can also look at the terrain sample to get an idea how the implementation of default Central Economy files should look like.