• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

Stridercal

Sergeant
14 Badges
Dec 13, 2018
98
0
  • Pillars of Eternity
  • Stellaris
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Stellaris - Path to Destruction bundle
  • BATTLETECH
  • Stellaris: Synthetic Dawn
  • Stellaris: Apocalypse
  • Shadowrun Returns
  • BATTLETECH: Flashpoint
  • Stellaris: Megacorp
  • Stellaris: Ancient Relics
  • BATTLETECH: Season pass
  • BATTLETECH: Heavy Metal
So i've finished all my new and revised mechs and chassis, with a few items and upgrades to boot. Once packaged into a mod.json, they seem to load correctly.

But i can't seem to figure out how to load contracts, constants, simgameconstants, and a few others.

Basically, i'm trying to hand-place my mechs in certain campaign missions, tweak a few falshpoitns, and make a couple changes to game constants.

Please help?!
 
For the constants, you can create a StreamingAssets folder in your mod folder, then put a data folder in there, and then a constants and simGameConstants in there. In those folders, you can put your updated constants/simgameconstants files. You don't have to do the whole file, and you don't need to add anything to the mod.json file (at least with ModTek). Can just do the parts you change, with some caveats. Stuff at the root level you can just do, but stuff inside arrays (the [] blocks), I believe you have to do the entire array. The ModTek readme and/or the files on the wiki on ModTek's github page lays it all out. And of course, the file name needs to be the same as the file you're want to overwrite bits of.

To illustrate what I mean, this is the start of simGameConstants.json, and let's say this is the bit in which you wanted to make changes:
{
"Player1sMercUnitHeraldryDef" : {
"Description": {
"Id": "heraldrydef_company",
"Name": "Mason's Marauders",
"Details": "This is the heraldry def from SimGameConstants",
"Icon": "",
"Cost": 0,
"Rarity": 1,
"Purchasable": false
},
"displayName": "Mason's Marauders Company Heraldry",
"textureLogoID": "envTxrHrld_set01_01",
"primaryMechColorID": "Blue_05",
"secondaryMechColorID": "Yellow_02",
"tertiaryMechColorID": "Greyscale_05",
"HERALDRY_VERSION": 1
},

If you wanted to change that default "displayName", all you'd need in your simGameConstants.json file is:
{
"displayName": "Haley's Harbingers of Hatred Company Heraldry"
}

And if I recall correctly, if I just wanted to change the "Name" in the Player1sMercUnitHeraldryDef", it'd be like this:
(
"Player1sMercUnitHeraldryDef" : {
"Description": {
"Name": "Mason's Marauders"
}
}
}

But if I wanted to change the range values on an stock Small Laser so that its short range ends at 60m rather than 90m, it'd be this, the entire array, even though I'm only interested in changing the the first two indexes in the array:
{
"RangeSplit" : [
60,
60,
90
]
}

The reason you only want to include as little as possible is that it reduces the risk of conflicting with another mod or a patch. It also makes it easier to see what you've changed.

Note that you can do this for any of the base game json files. Want to change ranges on weapons? You can do that this way. Want to add the Warhammer's capacitors to the Panther? Can be done this way as well, even though the Panther file doesn't even that section by default.

Alternately, and again this works with ModTek, not sure about HBS's system, you can do an advanced jsonmerge. So from one of the mods I'm working on, I have this in my mod.json file:
{ "Path": "vehicleChassis_merged", "Type": "AdvancedJSONMerge" },
And inside my vehicleChassis_merged folder, I have a file that contains this:
{
"TargetIDs": ["vehiclechassisdef_STRIKER"],
"Instructions": [
{
"JSONPath": "$.Locations..InternalStructure",
"Action": "Replace",
"Value": 20
}
]
}
This tells it to find the chassisdef for the Striker, then go inside it to any InternalStructure found within the locations' array's members, and replace the value there (it's 4) with 20. A bug fix for the Striker having incorrect values for its structure. If I wanted to, I could add other target ids and change their structure to 20 as well in the same go. Or I could add another instruction and do something else to the Striker. So here, I don't have to include the entire Locations section, but instead, I rely on the AdvancedJsonMerge's path code to change just what I want. If you do a search for "stefan.goessner jsonpath" that should turn up an article that lays out how the pathing works.

But it can be a bit of work to figure out how the pathing works (and it can be told to only do the instruction if a certain condition is true). And speaking of that "how pathing works" bit, I'm not actually sure how to point it at the info from a constant file. Haven't checked into it at all, as I used the first method for those. I expect it would work for contracts, though, as they have an ID... "ID" : "AmbushConvoy_BackyardBarbecue",

Edit: Also worth noting, that both these methods work only for files found in the streamingAssets/data folder.
 
Last edited:
Nice summary Axterix13. Yes, advanced JSON merging works with contracts.

I would add that changing flashpoints, or anything else from the DLC, is a bit more complicated. Someone with more experience than I may know an easier way, but this is how I got it to work:

You have to use ModTek. It doesn’t work with the builtin modloader at this point. Then, because of the order in which things are loaded, you can’t just edit the file like with other JSONs. You need to load the entire file and then load the edits.

I wanted to add a medium range bracket to all the weapons. Go to the GitHub page with the DLC data (it’s linked in the modding sticky thread) and download the JSONs for all the DLC weapons. Put them in a folder in your mod. Then add a second folder with the advanced JSON merge instructions to change the ranges. Add them both to the manifest section in your mod.json, one as though you’re adding new files and one to do the merge.

I’ve done that successfully with weapons and contracts from the DLC, and it should work just as well with flashpoints.
 
Thanks.

I wanted to add a medium range bracket to all the weapons. Go to the GitHub page with the DLC data (it’s linked in the modding sticky thread) and download the JSONs for all the DLC weapons. Put them in a folder in your mod. Then add a second folder with the advanced JSON merge instructions to change the ranges. Add them both to the manifest section in your mod.json, one as though you’re adding new files and one to do the merge.

I’ve done that successfully with weapons and contracts from the DLC, and it should work just as well with flashpoints.
I was curious about this, if that would work.

You can also just DL the files, put them in the folder in your mod, and change the files directly there. Though obviously, that does mean if a patch changes values in that file, you'll have to merge changes (a program like WinMerge can help with that), rather than just replacing the folder files with the new updated version.
 
I expect just changing the files directly would work. In the case of editing all the weapons though, there are so many that I found it easier to write a python script to create the advanced merge files than to edit them all in place by hand.
 
You have to use ModTek. It doesn’t work with the builtin modloader at this point. Then, because of the order in which things are loaded, you can’t just edit the file like with other JSONs. You need to load the entire file and then load the edits.
Interesting... I hadn't thought of that. I included the whole file, but modified it in place (when changing movedefs).

Another general tip to keep in mind that hasn't been mentioned and might not be obvious... after ModTek has loaded everything into the game, the .modtek directory will include a cached version of all the files you changed. There are log files there as well. When you start getting into the advanced merges it can be very important to verify that the changes were applied the way you expected (and advanced merges are the only way to change part of an array without replacing the whole thing).