132 lines
4.3 KiB
Markdown

# LootDistributionGenerator
Generates Distribution .json files which are required by the SPT-AKI/Server to spawn loot.
## Setup
### Creating config file and setting folders
Requires a config.yaml in /config defining dump and target folders as well as a location for 7z.exe
````yaml
---
tools:
7z_exe: 'C:/Program Files/7-Zip/7z.exe'
server:
# SPT-AKI Server location (to store the generated json)
location: 'C:/GAMES/SPT_AKI_Dev/Server/'
# The map names in the loot dump do not directly correspond to the server database structure, this is the mapping
map_directory_mapping_yaml: map_directory_mapping.yaml
archives:
# where we put our sequential dump jsons to be sorted archived, preprocessor will put them into archives
source_folder: 'D:/Games/SPT_Dev/map_dumps/12.12/'
# here we store the archives with used data
target_folder: 'D:/Games/SPT_Dev/map_dumps/12.12_used/'
# archive name for map loot dump data
loot_filename: loot_dumps.7z
# archive name for bot dump data
bot_filename: bot_dumps.7z
# all dump data is appended into an archive in this folder
backup_file: 'D:/Games/SPT_Dev/map_dumps/12.12_unused/complete.7z'
config:
static:
# we have a separate yaml that defined forced static loot per map
forced_yaml: forced_static.yaml
loose:
# known quest items per map for validation
forced_yaml: forced_loose.yaml
````
### Installing Python
1) Install python 3.9 https://www.python.org/downloads/release/python-3910/ to your preferred path
2) Create a virtual environment and requirements in the LootDistributionGenerator's main folder
`````commandline
PS C:\LootDistributionGenerator> C:\pythonpath\python.exe -m venv .\venv
`````
Your dir should now look like
````commandline
📦LootDistributionGenerator
┣ 📂config
┃ ┣ 📜config.yaml
┃ ┣ 📜forced_loose.yaml
┃ ┣ 📜forced_static.yaml
┃ ┗ 📜map_directory_mapping.yaml
┣ 📂src
┃ ┣ 📜loose_loot.py
┃ ┣ 📜static_loot.py
┃ ┗ 📜tarkov_items.py
┣ 📂venv
┃ ┣ 📂Include
┃ ┣ 📂Lib
┃ ┣ 📂Scripts
┃ ┗ 📜pyenv.cfg
┣ 📜01_process_dump_data.py
┗ 📜02_loot_generator_parallel.py
````
Activate the python virtual environment and install the requirements
`````commandline
PS C:\GAMES\SPT_AKI_Dev\LootDistributionGenerator> .\venv\Scripts\activate
(venv) PS C:\GAMES\SPT_AKI_Dev\LootDistributionGenerator> pip install -r .\requirements.txt
`````
Now the program should be ready to use.
## Use
Always activate the virtual environment when you use the tool. Also, make sure the locations in the *config.yaml* are
set correctly for your system.
### Preparing and archiving new dumps
The LootDistribution generator will care for archiving dumps. It creates two 7z archives with the used dumps (currently
loot and bot jsons)
- archives/target_folder/loot_filename
- archives/target_folder/bot_filename
a third archive is created which will contain all the dumps
- archives/backup_file
When you receive new dumps you place them in
- archives/source_folder
and run
````commandline
(venv) PS C:\GAMES\SPT_AKI_Dev\LootDistributionGenerator> python .\01_process_dump_data.py
````
now all the files in *source_folder* will be appended to their corresponding archives.
### Creating the LootDistribution files for the server
When the archives are ready, run
````commandline
(venv) PS C:\GAMES\SPT_AKI_Dev\LootDistributionGenerator> python .\02_loot_generator_parallel.py
````
The program will process the dumps to generate the loot files and stores them directly in the correct place
in your SPT-AKI server development folder specified in *server/location* in the config.yaml
# Todos:
- Check for spawnpoints with location duplicates
- Option 1
- If that happens only group by xyz-coords, without rotation
- spawnpoints with different rotations but same position will be combined
- each item in the distribution will receive a rotation attribute to define how to place it
- Pro/Con: simpler server code, simpler generation code, larger file size
- Option 2
- keep spawnpoints as is (same location but different rotation lead to separate spawnpoints)
- make a "xyz location id" and after drawing, filter out all with same id from pool
- Pro/Con: smaller file size, not sure yet how to create such a location id in the current generation code