Cataclysm: Dark Days Ahead - Official Forums

Cataclysm: Dark Days Ahead => The Lab - Contributions and Mods => The Toolbox - Code Help => Topic started by: pisskop on November 03, 2016, 01:29:38 AM

Title: The Minor JSON Questions Thread
Post by: pisskop on November 03, 2016, 01:29:38 AM
Because having a new thread for every small question is unreasonable.

I hope this sticks.




Title: Re: The Minor JSON Questions Thread
Post by: pisskop on November 03, 2016, 01:31:13 AM
(click to show/hide)

^^

I have 2 poison replacements here.  I mean to use this in conjunction with the venom tags in order to make a linger-term poison attack from monsters.

The issue Im having is getting it to affect the PC for more than 1 turn.  It does apply.  It does not stick for longer than 1 turn.


Im hoping somebody will know what I have done wrong here  ...
It should work by all my accounts.
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on November 03, 2016, 06:33:29 AM
The issue Im having is getting it to affect the PC for more than 1 turn.  It does apply.  It does not stick for longer than 1 turn.

Are you setting the duration to something higher than 1 at start?
Setting intensity to 3 but leaving duration default on application will not cause a 3*int_decay_tick duration, just the default duration of 1.
The only case you can skip setting duration is if you set max duration - then it will start at max duration by default.
Title: Re: The Minor JSON Questions Thread
Post by: xironfistx on November 18, 2016, 04:35:17 PM
would it be possible to have a sort of bandoleer for ammo that also have a holster function?
i haven't attempted to do that yet but i am rather interested in that
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on November 18, 2016, 05:07:45 PM
if items have multiple use_actions a menu will promt you as to what action every time you use it
Title: Re: The Minor JSON Questions Thread
Post by: egomassive on November 18, 2016, 08:20:14 PM
I have a question about terrain with vertical and horizontal elements, e.g. t_chainfence_v and t_chainfence_h. Does it matter if I use them both? In ASCII the AUTO_WALL_SYMBOL is used. In tiles they could be treated differently, but usually aren't. I've also noticed there are legacy versions of t_wall with h and v. I get the feeling this is an old format that's been deprecated but not updated.
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on November 18, 2016, 08:34:06 PM
Yup.  You could use all vertical fencing and with auto-connect they would auto-configure themselves.

You could use them, conversely.  But no reason to.
Title: Re: The Minor JSON Questions Thread
Post by: egomassive on November 18, 2016, 09:56:46 PM
@pisskop: Thanks for the quick response. :)
Title: Re: The Minor JSON Questions Thread
Post by: egomassive on November 21, 2016, 01:54:17 AM
Is there a way to have a chance of furniture or items? I have some crate spots designated in my ASCII map. I want to randomly fill those spaces with closed crates, open crates, or smashed crates. Since crates are furniture and splintered wood and nails are items I can't find a way to do it. Alternatively, is there a way to randomly smash the map from json?
Title: Re: The Minor JSON Questions Thread
Post by: acidia on November 21, 2016, 02:03:53 AM
This is the only way I know of in JSON.
Code: [Select]
        "furniture": {
            "X": ["f_crate_c", "f_crate_c", "f_crate_o", "f_floor"],     
        },
        "items": {
             "X": { "item": "trash", "chance": 60 }
        },
 

So 50% for a closed crate, 25% for open, and 25% for floor... but the trash items will spawn even in the crates.

Title: Re: The Minor JSON Questions Thread
Post by: pisskop on November 21, 2016, 08:46:59 PM
"f_null" is what you want.  "f_floor" doesnt exist.  Its terrain, "t_floor", and goes in terrain definitions.

What you do is:

terrain [
"X": "[t_floor", "t_dirt", "t_dirt"]
],
furniture [
"X": [f_null", "f_null", "f_null", "f_chair"]
]


^^  The above, properly coded, would make a terrain of [66% dirt] and [33% floor] and then have a 25% chance of placing a chair on that terrain regardless of what terrain is there.
Title: Re: The Minor JSON Questions Thread
Post by: egomassive on November 22, 2016, 08:28:01 AM
Thanks acidia and pisskop. I didn't know about f_null. With that I can have open, closed, or missing crates; and then spread debris items over an area. That's probably more realistic than neat piles of debris only where the crates were supposed to be.
Title: Re: The Minor JSON Questions Thread
Post by: Greiger on November 23, 2016, 02:04:34 AM
Alrighty just the kind of thread I needed.

So I was working on a mod focusing on small cars.  Microcars and such.  If I understand correctly gas prices were through the roof before the cataclysm, and I figured I'd make some small 1 person clowncars commuter cars to reflect the car industry adapting.

I had them functioning great.  The gas one would get excellent gas milage while still being small enough to push and pull by hand just like real microcars!  I had plans to add a couple more cars, and some lore fliers and such later.

Now I come back, download the newest experimental like usual and it seems there are some massive car overhauls.  Now the microcar goes roughly 10 steps before running out of gas entirely (excellent coasting distance though)  And from what I can gather on the github engines have changed drastically.  The microcar's engine has changed to a 2L gas engine, from an I4 increasing it's speed but a 2L engine on a 10L tank ain't getting far.

So I'll change the engine to another one simple enough, but I can't find any of these new engines. I still only see the old ones.  Am I missing a file somewhere?  Is the overhaul only partially implemented?  Where would I get information on these new engines to use an appropriate one?

Also anything else I'll need to know about the overhaul?

EDIT:  Ok update!  I found the new engines I think.  Kinda confused why there are 2 different engine lists, but I'm sure there's a reason.  There's a lot more info about gear ratios and such so I can only assume these are them.  But when I try to replace the current engine with a v2_combustion the game throws an error saying that engine does not exist.

EDIT2: Think I figured that out.  Also figured out that the fuel problem was due to another mod that I had originally built my own mod to build off of but had since removed the dependencies to.  But my test world still had it loaded so fuel was draining at an insane rate. 

I'd like to be able to build my own engines for the mod.  Sadly I do not know real life mechanics. Can anyone give me an overview of what idle, optimim, redline, and gears are and how to parse the numbers on the new engines?   I assume efficiency has something to do with how well it conserves fuel, and I 'm guessing idle optimum and redline are the power of the engine, but gears is complete Greek to me.
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on November 26, 2016, 07:07:23 AM
I'd like to be able to build my own engines for the mod.  Sadly I do not know real life mechanics. Can anyone give me an overview of what idle, optimim, redline, and gears are and how to parse the numbers on the new engines?   I assume efficiency has something to do with how well it conserves fuel, and I 'm guessing idle optimum and redline are the power of the engine, but gears is complete Greek to me.

Engine operates at some RPM - higher when strained more.
Idle is the minimum RPM - if the engine is active, it won't go below this.
Optimum is the RPM at which the efficiency is the best possible. The further you go from optimum, the worse the efficiency gets.
Redline is the RPM at which damage starts. Anything below it is safe.
Gears can allow different RPM to power ratios, which means more "chances" to get better efficiency and avoid redlining. Higher ratios allow more velocity, lower ones allow small engines to pull bigger vehicles without dying.

Efficiency is the multiplier on fuel energy. Efficiency 1.0 means all fuel energy is used, efficiency 0.1 means 90% of fuel is wasted and only 10% is turned into power. This is before the penalty from sub-optimal RPM.

I may be wrong about some of those.
Title: Re: The Minor JSON Questions Thread
Post by: Greiger on November 26, 2016, 04:18:02 PM
Sweet awesome.  So if I want a custom engine that is high efficiency but low velocity for a very small car. it sounds like I would want an engine with low rpms in and gears with high numbers since it does not have to haul any real weight.

Thank you for the info!
Title: Re: The Minor JSON Questions Thread
Post by: wad67 on November 27, 2016, 02:12:17 PM
I would also be interested in modding engines, now that they have been exported in json.

Primarily steam engines, having difficulties with fuel types though.
I need to flesh out some kind of 'boiler' object, which accepts any type of flammable fuel & water.
I have the object ingame, but I am having a great deal of trouble defining the fuel/ammo type.
This boiler in turn, needs to create steam. Something that might not be able to do with json.

Managed to implement steam fueltype, but it does not behave like steam at all.

I sorta have boilers, that don't work. And I have steam, that does not work either.

Defining the actual steam engines should be relatively simple, even just a clone of a typical gasoline engine with the fueltype set to steam.

The intention of this is to add some simple, low power steam engines that the player may craft, out of various scrap components.
See :
(click to show/hide)
Along with boilers, that the player may craft, and a very low tech, inefficient alternator.

I had planned to add steam engines a long time ago, but I couldn't really wrap my head around the C++ side of things.


This is mainly to do with a total conversion mod I had in mind, but it could have some potential within the basegame.


Title: Re: The Minor JSON Questions Thread
Post by: pisskop on November 27, 2016, 02:23:26 PM
idk if we can specify water as a fuel -yet.
Title: Re: The Minor JSON Questions Thread
Post by: wad67 on November 28, 2016, 05:41:09 AM
Once a general provision for some simple things come into place, I think it would be quite easy to accomplish.
If there was a way to specify a type of part, that has inputs, outputs and some rate of conversion, you could virtually accomplish any type of mechanical system.
A few ideas:

(click to show/hide)
Title: Re: The Minor JSON Questions Thread
Post by: xironfistx on December 01, 2016, 01:50:26 AM
could be something like power armor,but powered by gasoline be a thing?
i dont know how is the jsons of the power armor set up.
it is possible to add stat effects to clothing or armor?
i would love to make a makeshift power armor that burns you at random intervals and does not require you to be naked to use it.
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on December 01, 2016, 08:15:38 AM
You could copy the RM13 combat armor and change it to have gasoline ammo instead of plutonium.
Though it doesn't count as power armor.

All power armor is hardcoded to require being naked.
Title: Re: The Minor JSON Questions Thread
Post by: egomassive on December 01, 2016, 03:36:34 PM
Is there a document somewhere describing the properties of terrains?

In particular I want to know about the line:
"roof": "t_flat_roof",
Seems to me all indoor terrain should have this as well as windows and doors. It's very hit-or-miss, t_floor gets a roof when looking down on it from above but t_carpet_red doesn't. Is this a matter of no one's taken the time to fully implement it, or it a matter of being an experimental feature that may be dropped?

In a related matter, it rains where I've placed t_open_air_rooved! I guessed this piece was for interior spaces, but it's not flagged INDOORS. Have I misunderstood its purpose or is it broken?
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on December 01, 2016, 04:43:24 PM
Roofs aren't fully implemented, but they probably won't be dropped.
Some weird terrains, like carpet, are sometimes badly specified. They should be copies of floor with some extra modifications, but instead are copied manually, meaning that they may have been missed when updating other terrain.

Rain and roofs are currently independent. Roofs creates terrain above current terrain, but rain depends on outdoor/indoor specification, which doesn't depend on terrain above yet.
Some of that is half-implemented because we can't really commit to fully 3D environment until 3D vision is in. Meaning we need to support 2D hacks and maintain compatibility with them.
Title: Re: The Minor JSON Questions Thread
Post by: Dakkan on December 16, 2016, 12:55:56 AM
Had a much longer post typed out but the board timed me out, so just the major questions.

First a little question, where are the json files for rams?

I am trying to make an underground bore attachment.

(click to show/hide)

(Didn't include recipe or item data, just vehicle_part.)

Loads fine, recipe works fine, attaches fine. The issue is that no matter what I do, I need to reach a speed of 96 km/h to destroy a tree with the bore. Tried upping "damage_modifier" like I saw on the reaper or ram, didn't help. Added "damage" and "bashing" from an ammo item hoping it would help, but it did not. The reaper and advanced reaper both have a "bonus" field of 7, so I added that with a large number, but no luck. [JACKHAMMER] was a desperate attempt, I was actually surprised at how accepting the game was of me tossing in random snippets.

I guess I really want to know how collision damage is calculated in relation to some of these values. The goal is to get it to eat through rock at very slow speeds. (I'll raise the mass and energy consumption to incredible levels to balance it out.) Are trees a poor test subject?

Thanks for any help!
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on December 16, 2016, 01:27:17 AM
rams?

Id look at metal and wooden spikes.  and maybe spiked armor plating.


"ramming" has less to do with any one part but how heavy your car is. afaic.  make it armored and do damage.
Title: Re: The Minor JSON Questions Thread
Post by: Dakkan on December 16, 2016, 01:30:25 AM
I meant the actual vehicle part, for instance "steel ram" or "spiked ram" or "superalloy ram" or "superalloy ram?" They have to be installed in a frame-adjacent square on the vehicle?

I will try out messing with the vehicle weight though, thanks.

Edit: "military composite ram" was supposed to be the third one.
Title: Re: The Minor JSON Questions Thread
Post by: Greiger on December 16, 2016, 02:26:00 AM
Oh I think rams are part of the vehicle additions mod.  So I think you'd look in the data>mods>blazemod folder.
Title: Re: The Minor JSON Questions Thread
Post by: Dakkan on December 16, 2016, 03:02:55 AM
Weird, always thought they were part of the core game. Nothing enlightening in the ram files though unfortunately.

I did try increasing the mass of the bore (and vehicle) by 9000 kg; moderate success, was able to "bore" through a tree at only 64 km/h.

I think the recent changes to engine/motor and the planned gears are going to be an issue however, may have to make special rail "tires" and a massive bore engine for now.

Do structures like trees and rock walls have damage or health associated with them? Seems like no. Even with this test, a continual tile-adjacent ramming doesn't seem to destroy a tree.

Any specific info on how "diameter" and "width" affect wheels in game?
Title: Re: The Minor JSON Questions Thread
Post by: Greiger on December 16, 2016, 04:40:17 PM
Most structures like trees and walls just have a chance of being destroyed based on the power of the strike made against them.  A heavier fast vehicle will have a higher chance of breaking something down than a lighter one, because mass and momentum are taken into account.  Some parts also have a multiplier to their damage, like spiked plating, but I don't know if that translates into terrain damage calculations or if it's just monster damage.  When bashing things on foot I understand the 'you don't seem to be damaging the x' message just comes up when you have a 0% chance to break something.

Diameter and width from what I understand affects your offroading capabilities.  Larger wheels are less liable to sink into the ground, giving you better traction offroad, reducing your power loss when driving through grass and dirt.  The size of your wheels is compared to the weight of your vehicle to give you it's offroading capability.  Larger wheels supposedly also reduce your maximum speed slightly, but I've seen little difference with that bit myself.
Title: Re: The Minor JSON Questions Thread
Post by: Dakkan on December 17, 2016, 01:09:32 AM
Thanks for the replies.

I ended up just making an absurdly massive vehicle, engine power, and power stored per battery (the numbers became silly), and still wasn't able to reach a viable speed from rest to push/destroy through a tree obstacle.

The damage modifier definitely does not affect damage against landscape structures, as far as I've seen.

Would be nice to somehow change the "REAPER" flag so that it works against rock walls instead and applied the damage modifier to it or something.
Title: Re: The Minor JSON Questions Thread
Post by: xironfistx on December 17, 2016, 02:49:10 AM
Could be some kind of livestock be juryrigged using jsons?
Like for example you feed it wheat or rice or some grain so it follows you around and then it lays bird eggs or something along those lines.
Or some kind of alien animal that is able to be tamed like a dog and then is like an ant queen and you then butcher the animals.
Is such possible using jsons alone or some of what it would need to work is hardcoded?
Title: Re: The Minor JSON Questions Thread
Post by: Dakkan on December 17, 2016, 05:26:56 PM
I would think so, a quick check into the dog json files shows "placate_triggers": [ "MEAT" ], so you could probably play with that, adding it to other monsters and using different foods.

As for having them lay harvestables like eggs, could be more tricky, don't see anything immediately useful to pillage in the ant queen files other than the flag "QUEEN," which I kinda think is what causes them to lay ant eggs? I see this tag in other monsters that also create offspring, but nothing that specifies what specific item/creature is spawned. Will poke around a bit more. Could possibly try having a silent mutation that causes them to leave a "slime trail" but instead of slime, egg items, at lower frequency.

But if you just want a tameable ant queen-esque monster, that seems totally possible.

Edit: spoke too soon, forgot about how dog food is the tool used to make dogs friendly towards you, may not be as simple as I thought.
Edit: Though spawning a friendly queen ant with the debug menu seems to cause all subsequent eggs and ants to also be friendly to you, which is fun.
Edit: Ah, the wiki was pretty helpful on this. http://www.wiki.cataclysmdda.com/index.php?title=Creature_AI
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on December 17, 2016, 08:05:07 PM
Its all hardcoded.  Make an item that changes the faciton of the target to 'player' in the c++ hardcode and then make an item that uses that action
Title: Re: The Minor JSON Questions Thread
Post by: CK_Kirbi on December 21, 2016, 06:54:10 AM
Alright. Here's one for you that deals with mutations. I am looking to create my own mutation branch with several abilities which are essentially renamed versions of abilities that already exist. My concern is that in changing the mutation ID, I lose the actual mutation power since those are hard coded.

For example.. I wish to take this..

        "type" : "mutation",
        "id" : "WINGS_BIRD",
        "name" : "Bird Wings",
        "points" : 2,
        "visibility" : 4,
        "ugliness" : 2,
        "description" : "You have a pair of large, feathered wings.  Your body is too heavy to be able to fly, but you can use them to slow your descent during a fall, and will not take falling damage under any circumstances.",
        "prereqs" : ["WINGS_STUB"],
        "cancels" : ["WINGS_BAT", "WINGS_INSECT", "WINGS_BUTTERFLY"],
        "category" : ["MUTCAT_BIRD"]

and turn it into this

        "type" : "mutation",
        "id" : "WINGS_DRAGON",
        "name" : "Drakota Wings",
        "points" : 2,
        "visibility" : 4,
        "ugliness" : 2,
        "description" : "You have a pair of large, articulate, demi-chiropteran wings.  Your body is too heavy to be able to fly, but you can use them to slow your descent during a fall, and will not take falling damage under any circumstances.",
        "prereqs" : ["WINGS_STUB"],
        "cancels" : ["WINGS_BAT", "WINGS_INSECT", "WINGS_BUTTERFLY", "WINGS_BIRD"],
        "category" : ["MUTCAT_DRAGON"]

My question is this: How do I make the new wings have the same ability as the bird wings? The JSON... "language"... here clearly doesn't contain the code for the removal of fall damage.
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on December 21, 2016, 09:50:56 AM
You need to locate the places where wing id is referenced and add the new wing. Then recompile the game.
Easiest done by just a brute force search for the wing id in the src directory. For example, `grep "WINGS_BIRD" -r src`.

Can't be done with json alone.
Title: Re: The Minor JSON Questions Thread
Post by: CK_Kirbi on December 21, 2016, 11:05:03 AM
Crap. That's what I was afraid of. The lua/hardcoded stuff are the limit of my personal skill, but I do have a friend who went to college to learn coding and who is helping me with this project, which I hope to expand greatly in scope.

Alright. That will help a great deal at the end of the day. Thanks for the info.
Title: Re: The Minor JSON Questions Thread
Post by: xironfistx on January 11, 2017, 01:51:27 AM
in which item json is that rivtech powered suit?
i cant find it and i want to make some crude powered suits quite similar to the ever charming huge scrap mounts orks wear in 40k
Title: Re: The Minor JSON Questions Thread
Post by: BorkBorkGoesTheCode on January 11, 2017, 03:17:02 AM
tool_armor.json. Some of its features are hardcoded in places.
Title: Re: The Minor JSON Questions Thread
Post by: xironfistx on January 11, 2017, 04:00:39 AM
At this moment im away from my place,but could i simply copy it json,change some stuff for balance and make it powered by gasoline?
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on January 14, 2017, 04:00:03 AM
i think it might have to be powered by a ups or bionic.

im not 100℅ sure though.

you could make a gasoline powered suit of armor, but it wouldnt req a helmet to use.
such a machine would be monstrously heavy and inefficient.
such a machine would have the glaring flaw of having combustible fluids as it external power source

but yes, you dont strictly have to balance for realism or ease of power acquisition, in theory you could make an airtight body glove of armor powered by gasoline kept in hammerspace
Title: Re: The Minor JSON Questions Thread
Post by: Greiger on January 15, 2017, 12:07:51 AM
Not that I don't find the idea immesely amusing but I would never want to wear a gasoline powered suit of armor.

A ) : Is it supposed to be so loud?    And vibrating so much?
B ) : Yea that's normal.  You'll get used to it once the swelling stops your brain from bouncing around in your cranium. The V6's weren't as bad, but the added power from the V12 definitely makes up for some minor brain trauma.
Title: Re: The Minor JSON Questions Thread
Post by: mGibson on January 31, 2017, 04:12:49 AM
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:
(click to show/hide)

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

(click to show/hide)

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.
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on January 31, 2017, 01:27:48 PM
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
Title: Re: The Minor JSON Questions Thread
Post by: Wyzack on February 13, 2017, 03:23:51 AM
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
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on February 13, 2017, 04:13:04 PM
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:

(click to show/hide)

It should also work with things like batteries or cardboard boxes, but i havent tested it.  Look here (https://github.com/pisskop/PKs_Rebalancing/blob/master/pk_professions.json) at my git for the source of my example.
Title: Re: The Minor JSON Questions Thread
Post by: Wyzack on February 13, 2017, 04:43:13 PM
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
Title: Re: The Minor JSON Questions Thread
Post by: Wyzack on February 15, 2017, 03:44:40 PM
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
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on February 15, 2017, 04:04:19 PM
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:

(click to show/hide)

From Here (https://github.com/pisskop/PKs_Rebalancing/blob/master/pk_effects.json)

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


Or

(click to show/hide)

From Here (https://github.com/pisskop/PKs_Rebalancing/blob/master/items/comestible.json)

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.
Title: Re: The Minor JSON Questions Thread
Post by: Wyzack on February 15, 2017, 04:32:21 PM
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
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on February 15, 2017, 04:43:45 PM
https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/EFFECTS_JSON.md

This will explain how the effects system works under the hood
Title: Re: The Minor JSON Questions Thread
Post by: Wyzack on February 15, 2017, 04:47:54 PM
this is amazing, thank you
Title: Re: The Minor JSON Questions Thread
Post by: Wyzack on February 15, 2017, 06:03:21 PM
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
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on February 15, 2017, 06:56:43 PM
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.
Title: Re: The Minor JSON Questions Thread
Post by: Wyzack on February 15, 2017, 07:04:25 PM
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:

(click to show/hide)

Code for the effect

(click to show/hide)

Am i missing a needed flag somewhere or is there another file i need to define to make this work?
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on February 15, 2017, 07:19:07 PM
I think you need to

add_effect: tonicuse


not use_action: tonic use


you defined an effect not a use_action
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on February 15, 2017, 07:20:42 PM

    "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
Title: Re: The Minor JSON Questions Thread
Post by: Wyzack on February 15, 2017, 07:23:02 PM
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" ?
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on February 15, 2017, 07:45:46 PM
Yes.  Its a drug.  use the code I have here, delete my effects, and add your own.  make sure you specify a duration.
Title: Re: The Minor JSON Questions Thread
Post by: Wyzack on February 15, 2017, 08:21:49 PM
Hahah it worked! Thanks a million!
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on February 15, 2017, 09:00:45 PM
One thing I dislike in the code is how vague the units of measurements are, and how they change from context to context.

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.
Title: Re: The Minor JSON Questions Thread
Post by: hatcher on February 19, 2017, 04:27:13 PM
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?
Title: Re: The Minor JSON Questions Thread
Post by: Taberone on February 19, 2017, 07:36:15 PM
Is there a way to stop getting "There are too many overmap specials" when playing with both PK's and Cata++ by editing a file somewhere? I vaugely remember a solution someone offered to "too many overmap specials" that involved that.
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on February 20, 2017, 02:41:42 AM
Is there's any way, besides going into every mapgen .json which could contain food and decreasing every chance value?

I think there is a way to do it with a complex lua script.
You'd have to have it access every item group, find food items, decrease their probabilities and pad the resulting group with "none".
That wouldn't be easy, though.

Is there a way to stop getting "There are too many overmap specials" when playing with both PK's and Cata++ by editing a file somewhere? I vaugely remember a solution someone offered to "too many overmap specials" that involved that.

You need to find the file where specials are declared and decrease the mandatory occurrences. You can brute force text search the mod directories for "occurrences" - the files with strings like
Quote
"occurrences" : [0, 10],
are the relevant ones.
First number is mandatory occurrences - this is the one you want to change. Lowering the second one can help with more varied worlds, but isn't mandatory.
Title: Re: The Minor JSON Questions Thread
Post by: hatcher on February 20, 2017, 12:21:26 PM
I think there is a way to do it with a complex lua script.
You'd have to have it access every item group, find food items, decrease their probabilities and pad the resulting group with "none".
That wouldn't be easy, though.


Welp, im completelly newbie in LUA, i could just stole somewhat code and modify it, but not write it by myself. And also, i don't know, where to find all those beautiful functions.
In the samples there's good, imo, base:

Code: [Select]
local milk = game.get_comestible_type("milk")

milk.volume = milk.volume / 2

I think, if change comestible_type for category_food and somehow decrease probability by modificator that will work. But i've no idea what it should be, coz i don't know these functions, which game is using.
I dunno,
Code: [Select]
game.get_category("food")or
Code: [Select]
game.get_item_category("food")
food.probability = food.probability / 10
?

Don't laugh hard pls, its just a guess by a fool.
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on February 20, 2017, 03:31:57 PM
Welp, im completelly newbie in LUA, i could just stole somewhat code and modify it, but not write it by myself. And also, i don't know, where to find all those beautiful functions.

In the source distribution on git, there are directories with sample lua mods and there is class_definitions.lua which has all the usable functions.

But no, probability is not a field of item because each item can have multiple different probabilities.
That's the whole problem: you have to access the item groups (not sure if it can be done right now, but if someone really cared we could open them up to lua), go through all of the item groups, find item IDs that represent items which are food, decrease probabilities there and then pad the remaining item group properly (padding is not necessary, just makes it work better).
Item groups are nested, but you wouldn't want to recurse, just go through all of them "flat".
Title: Re: The Minor JSON Questions Thread
Post by: hatcher on February 20, 2017, 04:05:06 PM
But no, probability is not a field of item because each item can have multiple different probabilities.
That's the whole problem: you have to access the item groups (not sure if it can be done right now, but if someone really cared we could open them up to lua), go through all of the item groups, find item IDs that represent items which are food, decrease probabilities there and then pad the remaining item group properly (padding is not necessary, just makes it work better).
Item groups are nested, but you wouldn't want to recurse, just go through all of them "flat".

Sounds very complicated for me. Btw, I found this:
Code: [Select]
{ name = "is_food", rval = "bool", args = { } },But if probability can not be decreased while loot spawn for whole item category and your solution is the most simple, then better just go through every mapgen json and decrease probability there, really.
Item groups with food very often contains other stuff which must be not affected. Example under the spoiler.
P.S.
Code: [Select]
"repeat": [ 1, 3 ] – 1, 3 means from 1 to 3 spawn cycles am i right?

(click to show/hide)
Title: Re: The Minor JSON Questions Thread
Post by: Taberone on February 21, 2017, 03:40:54 AM
Is there a way to stop getting "There are too many overmap specials" when playing with both PK's and Cata++ by editing a file somewhere? I vaugely remember a solution someone offered to "too many overmap specials" that involved that.

You need to find the file where specials are declared and decrease the mandatory occurrences. You can brute force text search the mod directories for "occurrences" - the files with strings like
Quote
"occurrences" : [0, 10],
are the relevant ones.
First number is mandatory occurrences - this is the one you want to change. Lowering the second one can help with more varied worlds, but isn't mandatory.

Changing all the mandatory occurrences to 0 for PK and Cata++ worked.
Title: Re: The Minor JSON Questions Thread
Post by: Noctifer on February 21, 2017, 04:15:49 AM
Changing all the mandatory occurrences to 0 for PK and Cata++ worked. Not sure why nobody else is having problems with PK and Cata++ and overmap specials.
People have had issues with it (my self included) but changing all mandatory occurrences to 0 makes it so that some of the buildings that are core to the mods have a chance to not spawn. This is currently irrelevant since even with mandatory on its a gamble if they will be choosen over other mandatory buildings.
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on February 21, 2017, 08:15:17 PM
i try to limit what is and isnt mandatory

coregame thinks anything that has a c++ component is mandatory.
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on February 22, 2017, 04:42:43 AM
coregame thinks anything that has a c++ component is mandatory.

Some of those can be cut down.
If you think there are non-essential spawns that could be dropped out of mandatory, PR it.
Older system rolled values between mandatory and optional to get an actual count. The new one generates things for as long as it can, so setting something as totally non-mandatory will no longer decrease chance to spawn on a world where all mandatory things are generated.
Title: Re: The Minor JSON Questions Thread
Post by: hatcher on February 23, 2017, 01:38:41 PM
I'd create a little mod which overwriting some default mapgen json's, for example grocery0 and grocery1, with decreased chances of food groups spawn and "repeat" on 1. But that stupid fucking spawn system keep filling at least half of the grocery stores with TONS of food on 1.0 item spawn. WTF?!
Title: Re: The Minor JSON Questions Thread
Post by: viggolo on February 27, 2017, 12:42:12 PM
I can't find the part of the code that increases the encumbrance of clothes when sewing/tailoring (fitting) them with kevlar/leather. Any idea where that is?

(recent experimental version)
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on February 27, 2017, 11:48:43 PM
Thats not.  its a fixed percentage based on hardcode.
Title: Re: The Minor JSON Questions Thread
Post by: viggolo on February 28, 2017, 02:17:34 AM
Thanks for the info. That sucks though, guess I'll have to mod separate recipes for clothes that would have fitted bash/cut resistances without the encumbrance penalties one by one
Title: Re: The Minor JSON Questions Thread
Post by: Zhilkin on February 28, 2017, 08:15:48 AM
Thats not.  its a fixed percentage based on hardcode.
https://github.com/CleverRaven/Cataclysm-DDA/blob/e53b1316b3ca31a7c784ac082835062eacf121bf/src/iuse.cpp#L2049 and below

Code: [Select]
    // TODO: The supremely ugly block of code below looks better than 200 line boilerplate
    // that was there before, but it can probably be moved into a helper somehow

    // TODO 2: List how much material we have and how much we need
    item temp_item = modded_copy( mod, "wooled" );
    // Can we perform this addition or removal
    bool enab = can_add_mod( "wooled", "felt_patch" );
    tmenu.addentry( 0, enab, MENU_AUTOASSIGN, _("%s (Warmth: %d->%d, Encumbrance: %d->%d)"),
        mod->item_tags.count("wooled") == 0 ? _("Line it with wool") : _("Destroy wool lining"),
mod->get_warmth(), temp_item.get_warmth(), mod->get_encumber(), temp_item.get_encumber() );
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on March 06, 2017, 04:15:13 PM
i dont quite understand how the definitions for the custom attacks work.

specifically the damage dealt.  let us pretend i wish to create an attack that deals a mons base damage plus 3 additional cutting damage.  how do?

does max damage overwrite possible damage for an attack?  say for a bite that does a max of 100 stab damage.
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on March 06, 2017, 04:16:08 PM
also i want to know partially because i wish to add a new zombie attack into coregame.  since its been testing well in my mod
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on March 06, 2017, 04:39:14 PM
i dont quite understand how the definitions for the custom attacks work.

specifically the damage dealt.  let us pretend i wish to create an attack that deals a mons base damage plus 3 additional cutting damage.  how do?

does max damage overwrite possible damage for an attack?  say for a bite that does a max of 100 stab damage.

Adding damage isn't possible at the moment, you need to specify the exact damage for the whole attack.
Adding damage sounds simple, but the problem is that damage also has penetration, damage multiplier and armor multiplier. This is why the attacks use this multiplier scaling thing instead of being multiplied by a number or rolled.

So if you want to deal base damage + 3 cutting damage, you need to sum of the damage as a set number and set the multiplier so that lowest multiplier * set damage is the lowest damage and highest multiplier * set damage is the highest damage.
If you set damage higher, it will pierce armor better (armor is deducted before multiplier roll), if you control mostly the multiplier it will pierce armor less.
Title: Re: The Minor JSON Questions Thread
Post by: fxckenstein on March 09, 2017, 05:21:12 AM
Is there a way to modify player's hit-point without changing the source? I see the health settings are hard-coded in character.cpp and wonder if it's possible to modify it by writing some lua code or even Json, I'd like to add a new mutation which modify player's hp by 222.22% (200hp at 10 str), it really upset me when a single grenade fragment kills my PC in full survivor gear with full hp. I don't think a higher health would help much with other things though, it's usually the pain or status ailment get you first, more health will only slow down the inevitable.
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on March 09, 2017, 01:51:02 PM
Currently no.
The best you can get right now is giving self mutations that grant HP.
Title: Re: The Minor JSON Questions Thread
Post by: fxckenstein on March 10, 2017, 01:56:31 AM
Currently no.
The best you can get right now is giving self mutations that grant HP.
Well thanks, but I don`t really like to break immersion. guess I`ll hold on until I find a workaround about it, I played too much cdda these days anyway.
Title: Re: The Minor JSON Questions Thread
Post by: Taberone on March 14, 2017, 05:28:36 AM
(1)What affects how long it takes for a gun to aim in the code, and what determines maximum effective range?

(2)How do I make a profession spawn with a fully loaded RM451 Flamethrower?
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on March 14, 2017, 07:06:14 AM
Aim depends on handling stat, current weapon skill of the user, dexterity and perception of the user, hand encumbrance of the user, used sights and volume of the weapon used.
Effective range is just range at which the fully aimed (stability 100%) has a chance of good hit of 50% or more. Anything that affects accuracy affects effective range: perception, arm encumbrance, used sights, skill in used weapon and marksmanship, targeting bionic.
Title: Re: The Minor JSON Questions Thread
Post by: wad67 on March 26, 2017, 04:54:39 PM
Is there a way for an item blacklist to remove items from the basegame?
It seems to disable crafting, and spawns although items still start with various professions are are still visible in the wish menu.

I was talking to some people on discord, and the main option appears to be redefining every base object that I don't want to 'none'.
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on March 26, 2017, 05:12:40 PM
not take them out no.  their ids will always exist.


To 'take them out' youd have to also override the item's unique id and make them into ... well, whatever.  Be it turn them into bees or chunks of meat or single frozen tear drops lamenting their lose.

overwriting their ids will change their displayed name and properties so that while the item's ids exist, its akin to taking the soul and personality out of one person and putting it into another's body.
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on March 26, 2017, 05:22:27 PM
Is there a way for an item blacklist to remove items from the basegame?
It seems to disable crafting, and spawns although items still start with various professions are are still visible in the wish menu.

That sounds like a bug
Title: Re: The Minor JSON Questions Thread
Post by: wad67 on March 26, 2017, 05:59:09 PM
not take them out no.  their ids will always exist.


To 'take them out' youd have to also override the item's unique id and make them into ... well, whatever.  Be it turn them into bees or chunks of meat or single frozen tear drops lamenting their lose.

overwriting their ids will change their displayed name and properties so that while the item's ids exist, its akin to taking the soul and personality out of one person and putting it into another's body.

I'm aware of this method, however it is a bit of a monumental task to replace every article of clothing in the game, putting together the blacklist was time consuming enough.
I have been experimenting with makeshift vehicle parts, so far I have completed a makeshift alternator and I'm considering which other vehicle systems would be feasible to bodge.
(click to show/hide)

Pastebin with the blacklist if anyone would like it: http://pastebin.com/sLvbKTTM

I'm also trying to define a new type of vehicle part, hint: It involves tinder as a fuel type
But that's another headache for another day

Additionally, is there an output log for json errors? Game stopped showing errors during load for some reason.
Seems to be an issue (https://github.com/CleverRaven/Cataclysm-DDA/issues/20678)
Title: Re: The Minor JSON Questions Thread
Post by: Zhilkin on March 29, 2017, 10:20:25 AM
Is there a way for an item blacklist to remove items from the basegame?
It seems to disable crafting, and spawns although items still start with various professions are are still visible in the wish menu.

I was talking to some people on discord, and the main option appears to be redefining every base object that I don't want to 'none'.
I beleive you can just create new core mod and start new game without dda.
Title: Re: The Minor JSON Questions Thread
Post by: wad67 on March 30, 2017, 07:48:19 PM
Is there a way for an item blacklist to remove items from the basegame?
It seems to disable crafting, and spawns although items still start with various professions are are still visible in the wish menu.

I was talking to some people on discord, and the main option appears to be redefining every base object that I don't want to 'none'.
I beleive you can just create new core mod and start new game without dda.

This made my life a couple of thousand times easier, thanks!
Made a new core mod, removed all the clothing. Started a new game, skipped a couple thousand error messages and then lo and behold. No clothing!
Now all I have to do is come up with a set of material & bodypart based generic clothing, then redefine everything that referred to the old clothing list.
(https://image.ibb.co/jC2L5a/progress.png)

I don't really want to have overlapping items, articles of clothing with multi materials might be considered. Might use some functionality similar to the MBR vest.
Title: Re: The Minor JSON Questions Thread
Post by: GrapeSquid on April 01, 2017, 07:47:40 AM
where can i find the code for the kilns and fermentation vats that tells them to store materials in them and then convert it into another item after some time. Also i can't seem to find the recipe for tinder anywhere, not that it matters really I can use other recipes.
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on April 01, 2017, 02:46:28 PM
where can i find the code for the kilns and fermentation vats that tells them to store materials in them and then convert it into another item after some time.

iexamine.cpp

Quote
Also i can't seem to find the recipe for tinder anywhere, not that it matters really I can use other recipes.

Survival tools mod
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on April 13, 2017, 10:06:03 PM
Is it possible to confer a trait upon somebody using effects?

Lets say, for example, I gave human flesh a 1% chance of granting the cannibal mutation.  Yes, no?
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on April 13, 2017, 11:31:49 PM
Currently no
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on April 20, 2017, 09:39:59 PM
How do I add my own builtins?

I tried adding new caves; for instance it was a few minutes of work to make a 'dusk horror' cave.  but the game wont read it or I dont know how to properly add it as a builtin.

The src mentions:
mapgen_functions_big.cpp

but no such file exists?
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on April 21, 2017, 09:35:46 AM
Nowadays it's just mapgen_functions.cpp

To add a builtin, you need to add a function in mapgen_functions.cpp and bind it to a name in init_mapgen_builtin_functions function in the same file.
Then, of course, recompile the game.
Title: Re: The Minor JSON Questions Thread
Post by: MorCel 374 on April 23, 2017, 05:10:32 PM
I'm trying to add some new mutations and thresholds, and got some questions about the json's and cpp's.

What's the matter with mutation_ordering.json? It looks like it's some sort of priority order for thresholds. And where could I get the source for the new experimental? The one on the main site (http://en.cataclysmdda.com/) seems old.
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on April 23, 2017, 06:08:16 PM
1. What's the matter with mutation_ordering.json? It looks like it's some sort of priority order for thresholds.

2. And where could I get the source for the new experimental? The one on the main site (http://en.cataclysmdda.com/) seems old.

1. It's draw order

2. https://github.com/CleverRaven/Cataclysm-DDA
Title: Re: The Minor JSON Questions Thread
Post by: MorCel 374 on April 23, 2017, 06:29:04 PM
Thanks!
Title: Re: The Minor JSON Questions Thread
Post by: Maddremor on May 02, 2017, 07:00:22 PM
How do you replace the terrain tiles that make up bridges? Trying to make bridges generate as a variant of shallow water to allow boats to pass bridges.
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on May 02, 2017, 07:55:01 PM
Gotta change what they are made of.

'Unfortunately, I dont think they are made of anything but pavement.  so changing them would involve altering what pavement is. Bridges are hardcoded, so you cant replace their constituent IDs, only change their properties.
Title: Re: The Minor JSON Questions Thread
Post by: Zhilkin on May 13, 2017, 09:14:44 AM
How do you replace the terrain tiles that make up bridges? Trying to make bridges generate as a variant of shallow water to allow boats to pass bridges.
Changing JSON won't be enough.
Title: Re: The Minor JSON Questions Thread
Post by: Maddremor on May 18, 2017, 11:46:41 AM
Another question: How do you make an item with multiple "use_action" promt the user with a menu to select the action? Currently, I have the following:

Code: [Select]
"use_action": [
      {
        "target": "abm_belt_cloth_shot_unfinished",
        "msg": "You adjust the belt to house shotshells.",
        "menu_text": "Adjust for shotshells",
        "type": "transform"
      },
      {
        "target": "abm_belt_cloth_50_unfinished",
        "msg": "You adjust the belt to house .50 bullets.",
        "menu_text": "Adjust for .50",
        "type": "transform"
      }
    ],

It defaults to the first option when activated. Is it possible to have the user choose?
Title: Re: The Minor JSON Questions Thread
Post by: Zhilkin on May 18, 2017, 06:54:07 PM
Another question: How do you make an item with multiple "use_action" promt the user with a menu to select the action? Currently, I have the following:

Code: [Select]
"use_action": [
      {
        "target": "abm_belt_cloth_shot_unfinished",
        "msg": "You adjust the belt to house shotshells.",
        "menu_text": "Adjust for shotshells",
        "type": "transform"
      },
      {
        "target": "abm_belt_cloth_50_unfinished",
        "msg": "You adjust the belt to house .50 bullets.",
        "menu_text": "Adjust for .50",
        "type": "transform"
      }
    ],

It defaults to the first option when activated. Is it possible to have the user choose?

I believe you need to create several copies of your item with `transform` actions with different `target`, like this:

Code: [Select]
  {
    "id": "candle_smoke",
    "copy-from": "candle",
    "type": "GENERIC",
    "name": "smoking candle",
    "description": "A candle in every respect, but designed to produce a thin stream of smoke.  Often used in ceremonies or to add an air of 'ambient mystery', but could likely be used to reduce scent by windows and doors it is placed next to.",
    "emits": [ "emit_smoke_flare" ],
    "use_action": {
      "target":  "candle_smoke_lit",
      "msg": "You light the smoking candle.",
      "active": true,
      "need_fire": 1,
      "menu_text": "Light",
      "type": "transform"
    }
  },
  {
    "id": "candle_smoke_lit",
    "type": "TOOL",
    "name": "smoking candle (lit)",
    "name_plural": "smoking candles (lit)",
    "copy-from": "candle_lit",
    "description": "This smoking candle is lit, providing both aeromatic smoke and light.",
    "emits": [ "emit_smoke_flare" ],
    "use_action": {
      "target": "candle_smoke",
      "msg": "The candle winks out.",
      "menu_text": "Extinguish",
      "type": "transform"
    },
    "flags": [ "LIGHT_8", "TRADER_AVOID" ]
  }


So it will go like this:

candle_smoke_lit -> candle_smoke -> candle_smoke_lit
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on May 18, 2017, 07:04:23 PM
If Im understanding the question, you want to be able to take an item and make several 'branches' of items from it.  Transform should only honor the last transform option input.

- You can try to create a 6 second recipe that is accessed from the crafting menu.
- You could also make them all rotate.  i.e. ammo_shot_belt goes to ammo_50_belt goes to ammo_unused_belt goes to ammo_shot_belt.  By this method the player only needs to be aware this function exists.
- You could make the player define its ammo as they create the item i.e. they dont craft the generic version.
Title: Re: The Minor JSON Questions Thread
Post by: africalinguist on May 19, 2017, 02:25:06 AM
i am making a mod that adds more energy weapons but when the world loads it says "result: c-23 in recipe c-23 is not valid" or something like that
Title: Re: The Minor JSON Questions Thread
Post by: Alec White on May 19, 2017, 02:28:20 AM
i am making a mod that adds more energy weapons but when the world loads it says "result: c-23 in recipe c-23 is not valid" or something like that

You probably have a recipe that has the wrong item ID as result.
Title: Re: The Minor JSON Questions Thread
Post by: africalinguist on May 19, 2017, 02:59:27 AM
thanks alec white yes you were right. the item id was s-23 not c-23 :P
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on May 25, 2017, 10:56:23 PM
Anyone know why my custom lighter can start overworld fires but wont spark a cigar?



  {
    "id": "ref_lighter_string",
    "type": "TOOL_ARMOR",
    "name": "wearable lighter",
    "copy-from": "lighter",
    "description": "A lighter with a bit of string and taping to allow it to be worn about the neck like a lanyard.  A bit fumbly to get a hold of, but perfectly servicable.",
    "weight": 25,
    "volume": 0,
    "price": 3000,
    "material": "aluminum",
    "symbol": ",",
    "color": "light_gray",
    "coverage": 1,
    "encumbrance": 0,
    "storage": 0,
    "warmth": 0,
    "material_thickness": 1,
    "ammo": "gasoline",
    "max_charges": 50,
    "rand_charges": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 5, 7, 11, 13, 17, 21, 27 ],
    "charges_per_use": 1,
    "use_action": [
      {
        "type": "firestarter",
        "moves": 60,
        "moves_slow": 600
      }
    ]
  },
Title: Re: The Minor JSON Questions Thread
Post by: Zhilkin on May 26, 2017, 03:42:56 PM
Anyone know why my custom lighter can start overworld fires but wont spark a cigar?



  {
    "id": "ref_lighter_string",
    "type": "TOOL_ARMOR",
    "name": "wearable lighter",
    "copy-from": "lighter",
    "description": "A lighter with a bit of string and taping to allow it to be worn about the neck like a lanyard.  A bit fumbly to get a hold of, but perfectly servicable.",
    "weight": 25,
    "volume": 0,
    "price": 3000,
    "material": "aluminum",
    "symbol": ",",
    "color": "light_gray",
    "coverage": 1,
    "encumbrance": 0,
    "storage": 0,
    "warmth": 0,
    "material_thickness": 1,
    "ammo": "gasoline",
    "max_charges": 50,
    "rand_charges": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 5, 7, 11, 13, 17, 21, 27 ],
    "charges_per_use": 1,
    "use_action": [
      {
        "type": "firestarter",
        "moves": 60,
        "moves_slow": 600
      }
    ]
  },

https://github.com/CleverRaven/Cataclysm-DDA/blob/4bcc67a9d0b5dc3d2b8844fb3705e4b524fdcb23/src/iuse.cpp#L397-L409

Code: [Select]
int iuse::smoking(player *p, item *it, bool, const tripoint&)
{
    bool hasFire = (p->has_charges("fire", 1));

    // make sure we're not already smoking something
    if( !check_litcig( *p ) ) {
        return 0;
    }

    if (!hasFire) {
        p->add_msg_if_player(m_info, _("You don't have anything to light it with!"));
        return 0;
}

***

ref_lighter_on = refillable lighter (lit) also does not provide fire for cigarettes.

You can check this in LUA console by this command:

game.add_msg(tostring(player:has_charges("fire",1)))


***

Probably same issue as described in https://github.com/CleverRaven/Cataclysm-DDA/issues/21005
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on May 26, 2017, 05:09:23 PM
oh hey, thanks for the update edit.

I was doing my own doodadaling with the jsons and came to the conclusion that it must be a hardcode somewhere?
Title: Re: The Minor JSON Questions Thread
Post by: Taberone on August 03, 2017, 11:57:02 PM
how do I reduce the number of mandatory overmap specials in More Locations and Z-Level Buildings mod?
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on August 04, 2017, 12:33:40 AM
Inside the overmap special.json file there are tags for [occurances].

You mod those two bracketed numbers.

Numbers range from [-1,-1] to ... ... whatever.

-1 means 'no limit'
0 means 'none'
A number represents its contemporary quantity.

The first number is a minimal amount.  the second a max.


...  and for the record, Id shy away from using -1.  it scares the game.
Title: Re: The Minor JSON Questions Thread
Post by: DeWolf on August 22, 2017, 09:59:26 PM
So is there anything in the Jason's for the latest experimental s that determines how much engine power a combustion engine has or is this something that is hard coded now?
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on September 01, 2017, 06:01:09 PM
Is it possible to get a turret to run off battery charge any longer?
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on September 02, 2017, 08:05:21 AM
So is there anything in the Jason's for the latest experimental s that determines how much engine power a combustion engine has or is this something that is hard coded now?

It needs to be declared in its item definition Json now.

Is it possible to get a turret to run off battery charge any longer?

It should be. If not, it's probably a bug. Provide an example though - I'm not sure what kind of battery powering do you have in mind. Battery as magazine, vehicle battery, battery-using-gun specified to use UPS not working or what?
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on September 02, 2017, 02:29:21 PM
Well, I have a gun that uses battery to fire.  A tesla coil, if you will.

The gun was originally intended to be too unwieldy to use by hand, but could be mounted.  Back when car batteries could be charged via standard batteries it worked fine when mounted, drawing 100 charge per shot, doing minimal damage per shot, but stunning, lighting up, and bouncing off enemies.

The gun, Ive been informed, will still require batteries when mounted, due to the new turret mechanics.


Anywho, the issue may be the ups version of the gun not drawing power at all from ups.
  Which is another issue entirely, but this shockcannon is incompatible with a ups conversion kit.  I got around that by making an actual ups powered version, but it will not draw power from ups, making it an infinite ammo gun.
Title: Re: The Minor JSON Questions Thread
Post by: Coolthulhu on September 03, 2017, 11:20:22 AM
Weapons may have problems consuming electricity directly, if ammo is specified to be battery, as there is no instance of this happening in core game.
If you want to use it that way, report it, but it may later bitrot again for as long as there is no turret in the core that works this way.

The UPS part however is an obvious bug. UPS weapons are supposed to properly draw power from vehicle storage.
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on September 03, 2017, 03:04:30 PM
it actually works now, with some tweaking.  thanks!

  needed some adjusting, but i do think if battery is an ammo than conversation kits should work on any type of item that could accept them
Title: Re: The Minor JSON Questions Thread
Post by: Taberone on September 05, 2017, 02:25:10 AM
How do I add in a custom monster? Not looking to have it naturally spawn yet, just want a custom monster I can spawn through debug menu for now.
Title: Re: The Minor JSON Questions Thread
Post by: Noctifer on September 05, 2017, 03:03:06 AM
Look at monsters.json and copy the entry that most matches your monster in question. Then modify it and slap the file with that bit of code in a mod.
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on September 05, 2017, 03:05:21 AM
easiest way is to copy one from

/data/json/monsters

and give it a new id.  if you felt like it you could give all the monsters exactly identical stats.  except the id.  id has to differ.

try to take a mon that is somrwhat similar to your own idea.

p:. you evil ninja
Title: Re: The Minor JSON Questions Thread
Post by: Taberone on September 05, 2017, 03:41:38 PM
What about default_faction and species? Thinking of adding in a Touhou character as an enemy.

EDIT: Nevermind, I found it. Monster_factions.json and species.json. Going to experiment with those to fit what I have in mind, since it probably won't fit into any existing factions and I'm not sure about setting it to "humans", since the character I was going to add isn't technically human. On a side note, I've noticed that no monster seems to use "human" as the default faction.
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on September 05, 2017, 03:55:18 PM
'human' is meant to be player/npc.  its likely that the 'human' flag and the npcs themselves obsoleted that species.
Title: Re: The Minor JSON Questions Thread
Post by: harison86 on September 16, 2017, 12:38:38 AM
Trying to make a balancing mod, wanted to adjust the stats of various armors but when I looked at the json I realized it didn't work quite like what I anticipated. Is there a way to adjust the bashing and cutting protection stats of armor directly in the json, or do I just have to work with "material_thickness" of the armor and the properties of the materials in the materials json? And how is bashing and cutting protection for armor calculated?
Title: Re: The Minor JSON Questions Thread
Post by: pisskop on September 16, 2017, 01:32:35 AM
- Materials.json contains the 'raw' values for the matierials of the game.  Things like cutting, bashing, acid, and fire protections.
- The material thickness stat takes all the listed values for an armor and averages them and multiplies that number by the whole value of the mat_thick.
-  idk if you can double up on materials, i.e. [iron, iron, steel] without an error.
Title: Re: The Minor JSON Questions Thread
Post by: DeWolf on September 16, 2017, 05:49:14 PM
- Materials.json contains the 'raw' values for the matierials of the game.  Things like cutting, bashing, acid, and fire protections.
- The material thickness stat takes all the listed values for an armor and averages them and multiplies that number by the whole value of the mat_thick.
-  idk if you can double up on materials, i.e. [iron, iron, steel] without an error.
My question would be why would you want to double up on a material if it is average protection based.