Zen's Treasure Mod - ZenarchistCode/ZenModPack GitHub Wiki

download

What Is This?

My treasure photo mod is inspired by Hunterz' Treasure mod, but his mod lacked features I needed, so I made my own version of that same idea.

All of my code is original though so if you read this Hunterz, thanks for the amazing idea and inspiration but don't worry - I did not steal any of your code.

The main difference with my mod is that it's much easier to add new photos (using hidden selection textures and keeping all the position config directly inside the *.cpp file) and when a player reads the photo, it does not immediately spawn the stash.

Instead of spawning the stash immediately, the player is added to a Trigger stored in JSON format. Every time the server restarts, a trigger for each stash location is spawned, and when a player enters the area of the stash and they are on the 'treasure hunter' list (ie. they have read the photo associated with that location), the buried stash is then spawned.

This prevents the problem of players learning the stash locations and farming them regardless of whether they were the ones who found the photo or not.

In other words: only people who have found and read the photo's treasure message can actually spawn the stash when they go to dig it up. by default their position on the 'treasure hunter' list lasts 2 weeks before they can no longer activate the treasure stash spawn, but you can change that in the %profiles/Zenarchist/ZenTreasure.json config (more info below under the ZenTreasure.json heading).

How To Add New Photos

All photos MUST be contained within ZenTreasure.pbo

You will need to modify my ZenTreasure.pbo file and re-pack it to add new photos. This is because the TreasurePhoto item uses a script to set its textures automatically based on the photo number. The file path looks like this: SetObjectTexture(0, "ZenTreasure/data/photos/photo" + photoNumber + ".paa");

So for example, the photo texture for ZenTreasure_Photo01 would be placed in ZenTreasure/data/photos/photo01.paa and the mod will automatically assign that texture to the photo item without needing to mess with hidden selection textures etc anywhere else, it's all automatic.

I designed this mod so that it would be super, super fast to add new photos - just set a stash position, write a short text description, set a preset loot config type, and take a screenshot in-game and convert the image to photo##.paa or photo##_winter.paa for the actual photo texture. It only takes a couple minutes to add a new treasure photo.

On my server I swap between summer and winter each month, so I included 2 different versions of the same photo for each season in my mod config.

If you only use one season, then you can just set the photo##.paa texture up and ignore the _winter.paa version.

My server uses a custom #ifdef WINTER to tell if it's winter or summer so that I can just add/remove the winter define PBO whenever I swap between snow and 'vanilla'/summer, and this define triggers winter-specific code to be enabled/disabled based on the season.

This means that if you don't use the "#ifdef WINTER" on your own server and you aren't fussed about swapping seasons or having the photo change between a winter and summer version, then the mod will always use the default photo01.paa, photo02.paa etc texture for each photo.

Basically, when I swap between summer and winter, all photo textures will swap to the corresponding season without needing to spawn new photo items in or have a winter version of each item - but most of you won't need to worry about that unless you want to mimic my server's seasonal style.

I've included a Git repository for an example treasure config - click here to see it.

That means you can define new photos very quickly - here are some config examples (make sure to read the next section to learn how to set up loot config):

    //! LIVONIA PHOTO CONFIG:
    class ZenTreasure_Photo01 : ZenTreasure_PhotoBase
    {
        scope = 2;
        descriptionShort = "description #1";
        treasure_stash_x = 11579; // Karlin power plant
        treasure_stash_z = 6940;
	mapName = "enoch";
    }
    class ZenTreasure_Photo02 : ZenTreasure_PhotoBase
    {
        scope = 2;
        descriptionShort = "description #2";
        treasure_stash_x = 10935; // Sitnik train cross intersection
        treasure_stash_z = 9490;
	mapName = "enoch";
    }
    class ZenTreasure_Photo03 : ZenTreasure_PhotoBase
    {
        scope = 2;
        descriptionShort = "description #3";
        treasure_stash_x = 8891; // Wrzcczczc
        treasure_stash_z = 4464;
	mapName = "enoch";
    }

Just make sure your photo number is unique and the mod will take care of the rest.

"mapName" is optional, and really only necessary if you're running a map hive mod like Daemonforge's MapLink mod where players can move between maps. Leave this mapName parameter out of the config entirely when adding new photos if you aren't using the hive mod, and then the mod will treat all photos as valid and ignore the map name altogether.

You can use the keyword TREASURETYPE to specify what type of stash it is, based on the ZenTreasureConfig.json's Description for the TreasureTypes.

Here's an example:

descriptionShort = "If you're reading this, then I'm dead. I buried some TREASURETYPE supplies under a pile of tires near the power plant east of Karlin. There's an old caravan right next to the pile of tires. Take care survivor. I hope you have better luck than I did.";

In that example, the keyword TREASURETYPE would be replaced with valuable (aka generic), hunting, basebuilding, military etc depending on which stash 'type' was chosen.

These entries MUST be placed inside ZenTreasure.pbo's config.cpp file in order to be handled appropriately by the scripting side of this mod, so some knowledge and experience of how to repack mods will be required to add new photos. If you're not experienced, find someone to help you in the DayZ Modder's discord.

ZenTreasureConfig.json

Inside your %server_profile/Zenarchist folder will be a config file called ZenTreasure.json. This is where you set up your loot config.

Here's a description of each setting:

DebugZenMapCompatibility: If enabled, then the map markers will show up in-game on the vanilla map. This will show markers for ALL spawn points of all treasure photos added to your modpack, so don't leave this enabled on your live server - this is just for debugging and seeing where all your photo spawn points are. Requires my ZenMap mod to work: https://steamcommunity.com/sharedfiles/filedetails/?id=3483440991

DebugTeleportToPhoto: If enabled, when you read a photo it will automatically teleport you to the stash location (used for setting up new photos - don't leave this enabled on your live server!!)

DebugAlwaysSpawnStashID: Again for debug/making new stashes. This will force the stash type to be the specified index from TreasureTypes array list further down the file. For example, setting it to zero will force any photo you read to spawn the first loot config type in the list, 1 will be the second config, and so on.

TreasurePersistenceSecs: This sets how long the buried stash lasts once spawned. Remember, stashes are only spawned when a player enters the trigger near the spawn location. So by default this is set to 3600 secs (1 hour) - if the player leaves and doesn't dig up the stash then it will be cleaned up by the loot economy within an hour.

IsWinterMap: This is an alternative to my #ifdef WINTER system. If you don't want to use that system, but you want to swap between summer/winter, just remember to set this to 1 to force the mod to load the photo##_winter.paa version of your treasure photos.

SpawnPhotosOnZombiesChance: This is a % chance for a random photo to spawn on zombies as loot. It's a value between 0 and 1. So for example, 0.01 would mean a 1% chance of a random photo spawning on ANY zombie in-game. Just a convenient way to spawn all photo types on zombies without screwing with cfgspawnabletypes.xml, if you don't want to use this feature just set this value to 0.

PhotoSpawnStartNumber: Starting photo number to spawn on this server. Leave as 0 to pick from all possible photos in the config.

PhotoSpawnStopNumber: Ending photo number to spawn on this server. (Mod picks a random number between these two and spawns ZenTreasure_Photo#). Leave as 0 to pick from all possible photos in the config.

PredefinedTypes: This is a list of predefined loot types - for example, gun configs that include attachments etc. The ConfigName is what you put into your loot config to include this predefined loot type. Here's a detailed explanation:

    "PredefinedTypes": [
        {
            "ConfigName": "Predef_SVD", // Config name for placing this into loot types later
            "Item": {
                "ClassName": "SVD", // Item classname
                "MinQuantity": 1, // Minimum quantity
                "MaxQuantity": 1, // Max quantity
                "MinHealth": 10, // Minimum health (max hp is 100%)
                "SpawnChance": 1.0, // Chance to spawn if this is selected
                "Attachments": [
                    "Mag_SVD_10Rnd", // Magazine attachment
                    "PSO11Optic|h=0.01|c=0.5", // Optic attachment, h=0.01 is minimum health, c=0.5 is chance 50%
                    "Battery9V",
                    "AmmoBox_762x54Tracer_20Rnd|c=0.9", // c=0.9 = 90% chance to spawn this attachment
                    "AmmoBox_762x54Tracer_20Rnd|c=0.9"
                ]
            }
        },

TreasureTypes: This is the actual list of treasure types/categories that will be spawned, containing all the different loot. For example you might want a basebuilding stash, a military stash, an ammo stash etc - this is where you set that up. Stashes are randomly selected with no weighting so keep them fairly generic.

The first two stash types Generic_Small and Generic_Large will spawn their loot completely random based on the loot included in ALL stashes. So it's just a random mashup of all possible loot types.

            "ConfigName": "HuntingLoot_Small", // Config name for your reference
            "Description": "hunting", // Description (is included in photo text)
            "ContainerType": "ZenTreasure_WoodenCrate", // Container type (can be anything)
            "Loot": [
                {
                    "ClassName": "Predef_SVD", // A predefined loot type from PredefinedTypes
                    "MinQuantity": 1, // Minimum quantity
                    "MaxQuantity": 1, // Maximum quantity
                    "MinHealth": 10, // Minimum health %
                    "SpawnChance": 0.8999999761581421, // Chance to spawn
                    "Attachments": []
                },
                {
                    "ClassName": "Ammo_762x54", // Classname of item
                    "MinQuantity": 10, // Minimum quantity
                    "MaxQuantity": 20, // Maximum quantity
                    "MinHealth": 10, // Minimum health %
                    "SpawnChance": 0.8999999761581421, // Chance to spawn
                    "Attachments": [] // List of potential attachments
                }

Master Config

To disable this mod set "ZenTreasure": 0 in %server_profile/Zenarchist/ZenModPackConfig.json

Types.xml

ZenTreasure_DebugShovel: don't add this to your server types, but if you need to test your treasure photos you can spawn this tool in with admin tools and it will dig stashes up instantly.

Make sure to add each new photo you add to your types.xml - there is a default types config below to get you started.

If you have a lot of photos, I recommend not spawning all of them but instead have a few ZenTreasure_RandomPhoto items as SurvivorMissions or airdrop rewards/zombie loot etc. The ZenTreasure_RandomPhoto type will automatically turn into a different photo.

Do not add the ZenTreasure_RandomPhoto item as a spawn into the types.xml however, because it will continuously respawn since the item ZenTreasure_RandomPhoto actually deletes itself the moment it appears and converts into a different photo item, so the game will constantly respawn it if it's included in types.xml.

 <type name="ZenTreasure_Photo01">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo02">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo03">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo04">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
<type name="ZenTreasure_Photo05">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo06">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo07">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo08">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo09">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo10">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo11">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo12">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo13">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo14">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo15">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo16">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo17">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo18">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo19">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo20">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo21">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo22">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo23">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo24">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
    <type name="ZenTreasure_Photo25">
        <nominal>1</nominal>
        <lifetime>7200</lifetime>
        <restock>0</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="1" crafted="0" deloot="0"/>
        <category name="food"/>
        <tag name="shelves"/>
        <usage name="Coast"/>
        <usage name="Village"/>
        <usage name="Town"/>
    </type>
⚠️ **GitHub.com Fallback** ⚠️