Modding Q&A thread

Now that we’re actually pushing interesting things out to data files, I figure we should have a place for people to ask how modding is done (and/or give the devs feedback about format we’re using, and such). May as well start one, then, along with some starting advice. Also, feel free to copy this stuff onto the wiki - that would be a good long-term place for collected knowledge.

Q: Where is the list of items that the game has?
A: For this one, you’ll need to look at the source (items aren’t moved out to data files yet). Open itypedef.cpp, and there’s a bunch of lines like “TOOL(…”, “BOOK(…”, and so on. All of those start with two strings. The first string is the item’s identifier, which is for use in data files, code, etc… The second string is the name that gets presented to the user.

e.g., the identifier for “Guns n Ammo” is “mag_guns”. So, if you wanted to give a custom profession a copy of “Guns n Ammo”, you’d put “mag_guns” in the profession’s item list.

Q: What do you mean by a “string”?
A: In tech-speak, a “string” generally means “bit of text”. e.g., names.

Love this idea, ive always wanted to know how to mod ASCII/Roguelike games. Teach us your ways all mighty forums.

Also, this may not be the place but maybe we could touch on HOW to make a ASCII game, cause even though im noobish, id love to have a go.

I’ve noticed that the RV Kitchen unit item is listed only in &gamepath&/data/raw/recipes.json, so where to find actual parameters for the item? I’m asking 'cause the game spawns the item; for example, it also spawns flashlight(off) which is both in the item list and is also included amongst the “craftables”.

{ "id": "welder", "type": "TOOL", "symbol": ";", "color": "light_red", "name": "welder", "description": "A tool for welding metal pieces together. Useful for construction.", "rarity": 25, "price": 900, "material": "IRON", "weight": 24, "volume": 6, "bashing": 7, "cutting": 0, "to_hit": -1, "max_charges": 500, "initial_charges": 0, "charges_per_use": 50, "turns_per_charge": 0, "ammo": "battery", "revert_to": "null", "use_action": "NONE" },

  • is confusing. How do I handle this unit in crafting? Is welder(1) referring to 50 charges total when creating new crafting recipees? I’m actually avoiding the resulting crashes due to defining stuff that is already compiled (I assume in the .exe routines), so any help would be appreciated.
1.1 Adding an item 1) Edit itype.h. Change the enum item_id and insert a unique identifier for your new item type. Be sure to put it among similar items. 2) Edit itypedef.cpp. Macros are used for all item types, and they are pretty self-explanatory. Be ABSOLUTELY sure that you insert the macro at the same point in the list as you inserted the identifier in item_id! 3) Your item type is now valid, but won't be spawned. If you want it to be spawned among similar items, edit mapitemsdef.cpp. Find the appropriate array(s), and insert the identifier for your item (e.g. itm_aspirin). Make sure it comes in before the NULL at the end of the list. 5) Some items, like tools or food, also take an iuse::function reference. Edit iuse.h and include the function in the class declaration; then edit iuse.cpp and define your function. Functions may be shared among different item types.
This states that the only reference for doing such can be found in itype.h, itypedef.cpp, mapitemsdef.cpp and iuse.h, but the .json files do use the references from those compiled files (they are calling for USE_ and stuff like "rarity", "type" and "flags"?

The kitchen unit (along with all vehicle parts) is kind of weird, it has two definitions, “kitchen_unit” in data/raw/items/melee.json, and vp_kitchen_unit in veh_itype.h. The json file defines it as a seperate item that you can pick up and carry around, the vehicle component definition kicks in when it actually appears in a vehicle.

We’ll be pushing these out to their own json file at some point as well so vehicle components can also be easily modded.

I’m not totally sure what you’re asking about with the welder, so I’ll throw some facts out and hopefully one of them answers your question.
To make a recipe to BUILD a welder, you need to define an entry in recipes.json with a “result”:“welder”, component.
If you build a welder with such a recipe, it will not have any charges as per “initial_charges”:0,
To use a welder as part of a recipe, the recipe needs to have a welder present in either it’s “tools” or “components” fields, the number next to the item in tools is the number of charges using the tool for this recipe expends, if it’s a component the number is the number of items the recipe consumes.

Unfortunately EDITING is wrong about adding new items, need to update it with the new system and indicate that the old way of adding items is deprecated (but still works for the time being, migrating some of the categories of items is… tricky).

On the subject of adding (or messing around with…) items, last night I played around with the code I downloaded from the code link on the main page (which I wrongly assumed was updated in-line with the nightly build). I made my changes, and referenced the itype.h file where weapon flags were contained. Then after discovering it wasn’t the latest, I got that off github. I noticed the weapon flags have been updated (e.g. weapons like the katana have “slice” and “chop” comes up too, as opposed to just “stab” as previously). So I thought, cool, new flags! But they didn’t appear to be contained in itype.h anymore, and I couldn’t find them in any other files. Admittedly I didn’t look through em all, just the ones I thought were “obvious”. Where’d they go??

Good question, in order to move item definitions out to json files, we needed to get rid of the old enums, because there’s no good way to have enum-like things in the json files. So what we have now is strings acting as flags. This has some tradeoffs:

You can just add any arbitrary string as a new flag. (unlimited number of different flags)
There is no limit on the number of flags you can add to an item.

You still need to add code to handle new flags to the code.

The game doesn’t check whether you’ve typoed the string.
There’s no natural place to define all the flags in one place.

Really good news:
We should be able to work around both of the bad aspects by adding a “flag_list” module in the code that just checks that when a flag is used it’s one of the existing ones. This also gives us a natural place to stick a short description of said flag.

RE: attack type flags, this was something I added very recently, I rejiggered the “your weapon gets stuck in the %s, but you pull it out” mechanic a bit to take weapon attack type into account instead of just using some weird heuristics. I established 5 classes of cutting weapons, “Slice”, “Stab”, “Spear”, “Chop”, and “Improvised”* in ascending order of “stuck-ness”. “Slice” (currently only the katana, but it’s not intended to be exclusive) sticks the least, “Stab” and “Spear” (spears, stabby knives and swords) stick 2x more than “Slicing”, “Chop” (axes, broadswords, etc) sticks another 2x more, and “Improvised” (tools like shovels and a few others) sticks 2x more still.

Severity of sticking is adjusted by the ratio of cutting/bashing damage, so if you throw a point of cutting damage in with 20 points of bashing damage, it won’t make it crazy susceptable to sticking.

Sticking is also reduced by higher skill with the appropriate weapon type.

It could probably still use some more tweaking, but I think it’s better than the previous system already.

*There’s no “Improvised” tag, but the category is applied to any weapon that has cutting damage and none of the other flags.

Is there a way to set quantity for recipe output somehow?

Not directly, though it’d be fairly easy to add that option if it’s desireable. If it’s something that normally spawns in a stack, like ammunition, the recipe will make a stack that big.

Is there any way to script in a vehicle to spawn in with a profession? Like a truck driver with a truck, a Ted Bundy with a Volkswagon Beetle, a soldier with a military vehicle, etcetera?

I don’t know of any easy way to do so at the moment, no.

Anyone know whether it’s possible to add in stats, bionics, or traits to professions? I know skills, items and addictions are possible…

I can make Elvis, and Tony Montana, and all the drug addled buffoons of the world, but I cannot make the Terminator as a profession without being able to add bionics or stats to profession

It would be nice to be able to fine-tune this amount, yes. For example, I wanted to add several recipes for nails crafting from metal. To keep the weight of the raw materials, scrap metal should yield 12 nails, chunk of steel - 75, lump of steel - 1000. Instead, it’s 100 nails regardless.
Maybe also support for range of numbers for randomisation? Although it wouldn’t be any good without factoring in skills (to get higher chances for maximum output).
Thank you for the answer.

[quote=“TheGrifter, post:11, topic:821”]Anyone know whether it’s possible to add in stats, bionics, or traits to professions? I know skills, items and addictions are possible…

I can make Elvis, and Tony Montana, and all the drug addled buffoons of the world, but I cannot make the Terminator as a profession without being able to add bionics or stats to profession[/quote]
To my knowledge, you can’t. Of course, I don’t know much about profession making past what you stated.

However, you could always just put the bionics in his inventory for the profession, then save-scum as you install them, right? I mean, it’s not perfect, but I believe that’d be possible.

Quick answer, every time someone has added a feature to the profession code, they also added a profession that uses it, so currently, if none of the professions use it, it’s not possible.

Is it possible to mod Cataclysm in a way so that it uses the font/graphics of Brogue? Is it a simple matter of replacing the font or is there more to it?

(Sorry if this is the wrong thread, please delete if so)

I’m not sure what you’re asking, if brogue uses a font, it’s a somple matter of dropping it in the right directory and adjusting a config file (data/FONTDATA), but if it’s a tileset, no we don’t support that yet.

any chance someone could tell me where to modify the monster speeds and quantities, i personally prefer zombies a little slower and more numerous, not that they’re too hard :stuck_out_tongue: i OHK them on my latest character, was using reflexive bow and metal arrows and OHK Brutes, but tried to melee for a bit and got killed switching to my bow xD.

I got it already yea. I was basically asking if you could use Brogue’s font & lightning('cause imo, it’s way prettier then most ASCII roguelikes).

stone64: The monsters are defined in mtypedef.cpp, still need to push them out to JSON.

Thanks, once they’re JSON-ified survivors beware :slight_smile: