The Minor JSON Questions Thread

Is it possible to make a fruit jelly that can be sealed in a small jar? It’s strange that the only fruit spread available is in a three-liter jar and can only be found, not made.

Seems easy enough but looking at comestibles.json and recipe_food.json in Notepad is overwhelming.

This is what I tried for jelly, jam, and preserves:

[spoiler][tt]{
“type” : “COMESTIBLE”,
“id” : “jelly_fruit”,
“name” : “fruit jelly”,
“weight” : 250,
“color” : “red”,
“spoils_in” : 240,
“container” : “jar_glass”,
“comestible_type” : “FOOD”,
“symbol” : “~”,
“nutrition” : 10,
“description” : “A fruity gel made from reducing fruit juice with sugar and straining to remove particles.”,
“price” : 80,
“material” : “fruit”,
“volume” : 1,
“phase” : “liquid”,
“charges” : 4,
“fun” : 10,
“flags” : [“USE_EAT_VERB”]
}

{
“type” : “COMESTIBLE”,
“id” : “jam_fruit”,
“name” : “fruit jam”,
“weight” : 250,
“color” : “red”,
“spoils_in” : 240,
“container” : “jar_glass”,
“comestible_type” : “FOOD”,
“symbol” : “~”,
“nutrition” : 10,
“description” : “Fresh fruits cooked with sugar to make them last longer.”,
“price” : 80,
“material” : “fruit”,
“volume” : 1,
“phase” : “liquid”,
“charges” : 4,
“fun” : 10,
“flags” : [“USE_EAT_VERB”]
}

{
“type” : “COMESTIBLE”,
“id” : “preserve_fruit”,
“name” : “fruit preserves”,
“weight” : 250,
“color” : “red”,
“spoils_in” : 240,
“container” : “jar_glass”,
“comestible_type” : “FOOD”,
“symbol” : “~”,
“nutrition” : 10,
“description” : “Chunks of fruit suspended in jelly. Delicious on biscuits.”,
“price” : 80,
“material” : “fruit”,
“volume” : 1,
“phase” : “liquid”,
“charges” : 4,
“fun” : 14,
“flags” : [“USE_EAT_VERB”]
}[/tt][/spoiler]

And this is my attempt at a recipe for a jar of fruit jelly:

[tt]{
“type” : “recipe”,
“result”: “fruit jelly”,
“id_suffix” : “jarred”,
“container”: “jar_glass_sealed”,
“category”: “CC_FOOD”,
“subcategory”: “CSC_FOOD_DRINKS”,
“skill_used”: “cooking”,
“skills_required”: [“mechanics”,1],
“difficulty”: 3,
“time”: 30000,
“autolearn”: true,
“batch_time_factors”:[80, 4],
“qualities”:[
{“id”:“COOK”,“level”:3}
], “tools”: [
[
[ “hotplate”, 2 ],
[ “char_smoker”, 2 ],
[ “toolset”, 2 ],
[ “fire”, -1 ]
],
[
[ “vac_sealer”, 10 ],
[ “makeshift_sealer”, 20 ]
]
],
“components”: [
[
[ “jar_glass”, 1 ]
[ “rag”, 1 ]
[ “juice_fruit”, 4 ]],
[
[“apple”, 2],
[“apple_canned”, 2],
[“apple_vac”, 2],
[“apricot”, 2],
[“blackberries”, 4],
[“blueberries”, 4],
[“cherries”, 4],
[“cranberries”, 8],
[“dry_fruit”, 4 ],
[“grapefruit”, 2],
[“grapes”, 8],
[“irradiated_apple”, 2],
[“irradiated_apricot”, 2],
[“irradiated_blackberries”, 4],
[“irradiated_blueberries”, 4],
[“irradiated_cherries”, 4],
[“irradiated_cranberries”, 8],
[“irradiated_grapefruit”, 2],
[“irradiated_grapes”, 8],
[“irradiated_kiwi”, 2],
[“irradiated_lemon”, 2],
[“irradiated_mango”, 2],
[“irradiated_melon”, 4],
[“irradiated_orange”, 2],
[“irradiated_papaya”, 2],
[“irradiated_peach”, 2],
[“irradiated_pear”, 2],
[“irradiated_pineapple”, 2],
[“irradiated_plums”, 2],
[“irradiated_pomegranate”, 2],
[“irradiated_raspberries”, 4],
[“irradiated_rhubarb”, 4],
[“irradiated_strawberries”, 4],
[“irradiated_watermelon”, 2],
[“kiwi”, 2],
[“lemon”, 2],
[“mango”, 2],
[“melon”, 4],
[“orange”, 2],
[“papaya”, 2],
[“peach”, 2],
[“pear”, 2],
[“pineapple”, 2],
[“plums”, 2],
[“pomegranate”, 2],
[“raspberries”, 4],
[“rhubarb”, 4],
[“strawberries”, 4],
[“watermelon”, 2]
],
[
[ “sugar”, 4 ]
],
[
[“water”, 6],
[“water_clean”, 6]
]
]
}[/tt]

Basically what I want to do is a separate entry for jelly (fruit juice and sugar strained through a rag, no fruit bits) preserves (fruit chunks suspended in jelly) and jam (chopped/crushed fruit and sugar) as well as a way to preserve them in jars. Am I on the right track? If this works, I’d like to try adding more recipes for foods without many recipes like hickory nuts.

i think yoy can either look at the sealed/pickles meat recipes or make a seriee of recipes t make jam.

jam should be 100% possible postapoc but im mobile rn

How do i make it so that a profession has an item inside a container on game start? And where is the json for lye powder? I am looking to make a tanner profession for a small mod I am making and want him to have a waterskin or bladder full of lye powder for curing hides

You have to either use or make an item id that has a default container. you can also use the relatively new system of inlaying items into items. examples of ammo/guns/holsters:

    ],
    "entries": [
      { "item": "m1911", "ammo-item": "45_jhp", "charges": 7, "contents-item": "brass_catcher", "container-item": "holster" },
      { "item": "45_jhp", "charges": 7, "container-item": "m1911mag" },
      { "item": "45_jhp", "charges": 16 },
      { "item": "ithaca_doom", "ammo-item": "shot_00", "charges": 12, "container-item":  "megaarmor_torso_1" },
      { "item": "shot_00", "charges": 8 }

]

It should also work with things like batteries or cardboard boxes, but i havent tested it. Look here at my git for the source of my example.

Thanks a million pisskop. Once upon a time i tried making a doom mod for the game, and gave up once i found out what a chore it would be to modify ranged attacks from the few preexisting defaults. I have to say you did a pretty amazing job

I feel like i am going to end up posting here quite a lot as i continue to work on my shit

I am working on a sort of primitive medical system and want to code a draught or potion that has a decent change of activating an antibiotic effect, but also causes pain and disorientation.

Looking at the code for antibiotics they call on a use_action called ANTIBIOTIC. Is it possible to make an item call on multiple use_actions or will i need to make my own use_action that combines the infection fighting property with the other effects i want? Is it possible to make it only call on use_action ANTIBIOTIC 75 percent of the time to simulate its unreliable nature?

Also where is the actual code for these use_action s stored? I found ANTIBIOTIC in item_actions.json but all it has is a name and an ID with no indications of its actual functions

I think the best you can do is guarantee to cure infection by removing the effect itself with another effect and then add in some guaranteed negatives like disorientation or w.e.

Take an example:

{
“type”: “effect_type”,
“id”: “gauze”,
“removes_effects”: [ “bite” ],
“base_mods”: {
“h_mod_min”: [1],
“h_mod_chance”: [200]
}
},

From Here

that will remove the blue bite effect and grant some other bonuses. Make them maluses instead.

Or

{
“type” : “COMESTIBLE”,
“id” : “fertilizer_chelated”,
“copy-from” :“fungicide”,
“sub”: “fertilizer_commercial”,
“name” : “aquarium fertilizer”,
“name_plural” : “aquarium fertilizer”,
“color” : “ltred”,
“nutrition”: 4,
“stim” : -2,
“healthy” : -2,
“fun” : -15,
“charges” : 40,
“stack_size” : 50,
“description” : “Agricultural grade, ionically-treated fertilizer for cleansing minerals from aquariums. Could remove radiation from the body in a pinch.”,
“price” : 1500,
“use_action” : {
“type” : “consume_drug”,
“activation_message” : “You consume a helping of the %s.”,
“effects” : [ { “id” : “chelated_iron”, “duration” : 1200 }, { “id” : “chelated_iron”, “duration” : 800 }, { “id” : “chelated_iron”, “duration” : 600 }, { “id” : “rad_reduce”, “duration” : 1200 }, { “id” : “rad_reduce”, “duration” : 800 }, { “id” : “rad_reduce”, “duration” : 600 } ],
“vitamins”: [
[ “iron”, 36, 48 ]
]
},
“flags”: [ “USE_ON_NPC”, “NPC_SAFE” ]
},

From Here

Where I add multiple effects to an item. This item will reduce the amount of radiation, but then has other effects that make you more likely to vomit.


the issue with adding multiple hardcoded effects is that the game allows the player to choose with one to activate at any given use. if somebody has a solution or a way to make it a split, random chance Id love to hear it.

Alright i figured there may be issues. I am certainly fine with having it be a guaranteed chance of a cure with a stat penalty.

In the gauze example you posted it has the “removes_effects” bit which seems easy enough to port. What exactly does the h_mod_min and h_mod_chance bit do? How would i go about making a similar effect type that removes an effect and also imposes penalties on say strength and dexterity?

EDIT: After looking at the code for stimpacks in that same file i feel i may have figured it out, will attempt and post results

This will explain how the effects system works under the hood

this is amazing, thank you

Last question on this i think, what are the units for “duration”? I want to make the effect last roughly 24 hours but i have no idea what the units are on the number that follows the duration tag

It seems that they are ‘combat turns’.

I.E. each is a point 6 second window.

600 is about an hour, give or take.

One thing I dislike in the code is how vague the units of measurements are, and how they change from context to context.

Okay so, i have coded an effect using your gauze entry as a template, as well as coding a new liquid medicine that calls that effect with use_action. When i try running the game with the mod active i get an error along the lines of “received unrecognised iuse function”, and if i hit space to continue the game crashes rather than simply exiting to main menu.

Code for the item:

{
“id” : “tonic”,
“type” : “COMESTIBLE”,
“comestible_type” : “MED”,
“name” : “health tonic”,
“name_plural” : “health tonic”,
“description” : “A potent and foul smelling concoction of medicinal plants and chemicals. Famed for its fast action and horrific side effects.”,
“weight” : 48,
“volume” : 1,
“price” : 3000,
“charges” : 5,
“symbol” : “~”,
“color” : “green”,
“phase” : “liquid”,
“container” : “bottle_glass”,
“use_action” : “tonicuse”,
“flags” : “NPC_SAFE”
}

Code for the effect

{
“type”: “effect_type”,
“id”: “tonicuse”,
“duration”: [60],
“apply_message”: “You are wracked with pain, weakness and nausea as the medicine takes hold.”,
“remove_message”: “You recover from the effects of the tonic”,
“removes_effects”: [ “infected” ],
“base_mods”: {
“str_mod”: [-4],
“dex_mod”: [-4],
“pain_amount”: [25],
“vomit_chance”: [25],
“vomit_tick”: [10]
}
}

Am i missing a needed flag somewhere or is there another file i need to define to make this work?

I think you need to

add_effect: tonicuse

not use_action: tonic use

you defined an effect not a use_action

"use_action" : {
  "type" : "consume_drug",
  "activation_message" : "You consume a helping of the %s.",
  "effects" : [ { "id" : "chelated_iron", "duration" : 1200 }, { "id" : "chelated_iron", "duration" : 800 }, { "id" : "chelated_iron", "duration" : 600 },              { "id" : "rad_reduce", "duration" : 1200 }, { "id" : "rad_reduce", "duration" : 800 }, { "id" : "rad_reduce", "duration" : 600 } ],

this kind of thing

So i switched the syntax from use_action to add_effect. The game compiles and runs properly and without error but when i debug in my tonic and drink some nothing happens. Should i define a use_action as well using the example below and have tonicuse under “effects” ?

Yes. Its a drug. use the code I have here, delete my effects, and add your own. make sure you specify a duration.

Hahah it worked! Thanks a million!

It’s hard to use a unified system because multiple systems want different granularities.
It would, however, be possible to have some sort of parsing system that would understand “100 moves”, “100 turns”, “100 seconds”, “100 minutes” etc.

Food in cata is EVERYWHERE. You litterally can’t die from starvation even in worst circumstances. I wanna SUFFER from lacking food, but i don’t want to play with 0.1 item spawn rate. So, i wonder, is possible to decrease food spawn without touching other items? Is there’s any way, besides going into every mapgen .json which could contain food and decreasing every chance value?

Readed docs for modding. Hmm. How to force decrease probability of whole food category?