• 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.

Crono1124

Recruit
Feb 26, 2020
7
0
Issue resolved by KMiSSioN.

When creating custom ammo tags use:
"ammoCategoryID" NOT "Category"
CAC will handle it anyway allowing both field names to be used, but you are not using CAC so you HAVE to operate new field style
body.


Hello everybody,

I have been searching for a simple way to MOD the base game to include ammo types for weapons I am creating. I know there has been some forms of implementation of this with the addition of LBX ammo types to the game.

Currently I have my weapon JSON, Ammunition_Chem JSON, and ammunitionBox_Chem JSON files completed.

If i add my ammo type to the enumerated AmmoCategory.JSON as follows
{
"ID" : 20,
"Name" : "Chem",
"FriendlyName" : "Chemical Ammo",
"IsBallistic" : true,
"IsMissile" : false,
"IsEnergy" : true,
"IsSupport" : false,
"UsesInternalAmmo" : false,
"UIColorRef" : "Energy",
"FallbackUIColor" : null,
"Icon" : "EnergyHardpointIcon",
"OutOfAmmoAudioVOEvent" : null
},
The game crashes as soon as the Category Name "Chem" to the ammunition_Chem.JSON file. It seems like the act of invoking the new name causes the game to enter an eternal loading state.

If i Delete my input and just use the unused AMS Ammo type everything works fine.

If it helps my MODTEK mod file calls the AmmoCategory.json and manifest as follows:
"DataAddendumEntries":[
{
"name": "BattleTech.AmmoCategoryEnumeration",
"path": "AmmoCategory.json"
}
],

"Manifest": [
{ "Type": "AmmunitionBoxDef", "Path": "ammunitionBox" },
{ "Type": "AmmunitionDef", "Path": "ammunition" },
{ "Type": "WeaponDef", "Path": "weapons" },
{ "Type": "HeatSinkDef", "Path": "heatsinks" },
{ "Type": "ItemCollectionDef", "Path": "itemcollection" }
],
Is there a hard coded limit to the number of ammo types? Is there any way to fix this without using other mods? Opening the MDD with a SQL viewer i noticed that the AmmoCategory in the Database file does not list category names or friendly names. Is this information referenced somewhere else?

Ultimately I am looking to completely rework all of the mechs, and weapons to create an entirely new world. I've enjoyed well over 300 hours of this game and I want to take my knowledge and skill in editing it a bit further.

I know user Kmission has done something like this with Harmony ( I Believe thats what he called the magic) but I am not sure if he did it post or pre enumeration changes
 
Last edited:
"path": "AmmoCategory.json" - That's not a path. That's the file name. Should that maybe point at a folder?

Anyway, I know a few mods, like Hyades Rim, add factions. That's an enum, so have you checked them out to see how they add those?
 
"path": "AmmoCategory.json" - That's not a path. That's the file name. Should that maybe point at a folder?

Anyway, I know a few mods, like Hyades Rim, add factions. That's an enum, so have you checked them out to see how they add those?

Axterix,

When I pulled the information from my files i noticed that as well. So long as the file AmmoCategory.json was not in another folder the path executed successfully for AmmoCategoryEnumeration.

Hyades Rim uses the same DataAddendumEntries call function to execute FactionEnumeration as shown below:

DataAddendumEntries":[
{ "name":"BattleTech.FactionEnumeration", "path":"enums/Faction.json" }
],

This in theory should have been all that is required to modify the enumerated faction.json to successfully implement factions. The same method is what I have been using in my MOD with the exception of AmmoCategory instead. Credit to the author Hobbes on that one because his code was very neat and alphabetized. :)
 
For what its worth here is the log file after the game successfully loads... Unfortunately it still hangs upon entry to mechlab.

Log Data:
Expanding manifest powermod:
AmmunitionBoxDef:ammunitionBox
C:\Program Files (x86)\Steam\steamapps\common\BATTLETECH\Mods\powermod\ammunitionBox\Ammo_AmmunitionBox_Generic_Chem.json
AmmunitionDef:ammunition
C:\Program Files (x86)\Steam\steamapps\common\BATTLETECH\Mods\powermod\ammunition\Ammunition_Chem.json
WeaponDef:weapons
C:\Program Files (x86)\Steam\steamapps\common\BATTLETECH\Mods\powermod\weapons\Weapon_Laser_ChemLaser_0-STOCK.json
HeatSinkDef:heatsinks
C:\Program Files (x86)\Steam\steamapps\common\BATTLETECH\Mods\powermod\heatsinks\Gear_HeatSink_Generic_Prototype.json
ItemCollectionDef:itemcollection
C:\Program Files (x86)\Steam\steamapps\common\BATTLETECH\Mods\powermod\itemcollection\itemCollection_Ammo_all.csv
C:\Program Files (x86)\Steam\steamapps\common\BATTLETECH\Mods\powermod\itemcollection\itemCollection_Components_base.csv
C:\Program Files (x86)\Steam\steamapps\common\BATTLETECH\Mods\powermod\itemcollection\itemCollection_Weapons_base.csv
:StreamingAssets
7 manifest entries

Adding Mod Content...
Loaded type cache.

powermod:
Add/Replace: "powermod\ammunitionBox\Ammo_AmmunitionBox_Generic_Chem.json" (AmmunitionBoxDef)
Add/Replace: "powermod\ammunition\Ammunition_Chem.json" (AmmunitionDef)
Add/Replace: "powermod\weapons\Weapon_Laser_ChemLaser_0-STOCK.json" (WeaponDef)
Add/Replace: "powermod\heatsinks\Gear_HeatSink_Generic_Prototype.json" (HeatSinkDef)
Add/Replace: "powermod\itemcollection\itemCollection_Ammo_all.csv" (ItemCollectionDef)
Add/Replace: "powermod\itemcollection\itemCollection_Components_base.csv" (ItemCollectionDef)
Add/Replace: "powermod\itemcollection\itemCollection_Weapons_base.csv" (ItemCollectionDef)

Doing merges...
Loaded merge cache.

Old Merge Deleted: C:\Program Files (x86)\Steam\steamapps\common\BATTLETECH\Mods\.modtek\Cache\BattleTech_Data\StreamingAssets\data\constants\ApplicationConstants.json
Old Merge folder deleted: C:\Program Files (x86)\Steam\steamapps\common\BATTLETECH\Mods\.modtek\Cache\BattleTech_Data\StreamingAssets\data\constants
Old Merge folder deleted: C:\Program Files (x86)\Steam\steamapps\common\BATTLETECH\Mods\.modtek\Cache\BattleTech_Data\StreamingAssets\data
Old Merge folder deleted: C:\Program Files (x86)\Steam\steamapps\common\BATTLETECH\Mods\.modtek\Cache\BattleTech_Data\StreamingAssets
Old Merge folder deleted: C:\Program Files (x86)\Steam\steamapps\common\BATTLETECH\Mods\.modtek\Cache\BattleTech_Data

Syncing Database...
Copying over DB and building new DB Cache.

Adding dynamic enums:
powermod:
Current values [BattleTech.AmmoCategoryEnumeration]
[NotSet:0]
[AC2:1]
[AC5:2]
[AC10:3]
[AC20:4]
[LRM:5]
[SRM:6]
[MG:7]
[AMS:8]
[GAUSS:9]
[Flamer:10]
[LB2X:11]
[LB5X:12]
[LB10X:13]
[LB20X:14]
[SRMInferno:15]
[Narc:16]
Loading values [BattleTech.AmmoCategoryEnumeration] from enums/AmmoCategory.json
Addind AmmoCategoryValue to db [NotSet:0]
Addind AmmoCategoryValue to db [AC2:1]
Addind AmmoCategoryValue to db [AC5:2]
Addind AmmoCategoryValue to db [AC10:3]
Addind AmmoCategoryValue to db [AC20:4]
Addind AmmoCategoryValue to db [LRM:5]
Addind AmmoCategoryValue to db [SRM:6]
Addind AmmoCategoryValue to db [MG:7]
Addind AmmoCategoryValue to db [AMS:8]
Addind AmmoCategoryValue to db [GAUSS:9]
Addind AmmoCategoryValue to db [Flamer:10]
Addind AmmoCategoryValue to db [LB2X:11]
Addind AmmoCategoryValue to db [LB5X:12]
Addind AmmoCategoryValue to db [LB10X:13]
Addind AmmoCategoryValue to db [LB20X:14]
Addind AmmoCategoryValue to db [SRMInferno:15]
Addind AmmoCategoryValue to db [Narc:16]
Addind AmmoCategoryValue to db [Chem:17]
Log: DataAddendum successfully loaded name[BattleTech.AmmoCategoryEnumeration] path[enums/AmmoCategory.json]
Updated values [BattleTech.AmmoCategoryEnumeration]
[NotSet:0]
[AC2:1]
[AC5:2]
[AC10:3]
[AC20:4]
[LRM:5]
[SRM:6]
[MG:7]
[AMS:8]
[GAUSS:9]
[Flamer:10]
[LB2X:11]
[LB5X:12]
[LB10X:13]
[LB20X:14]
[SRMInferno:15]
[Narc:16]
[Chem:17]
Added/Updated Weapon_Laser_ChemLaser_0-STOCK (WeaponDef)
Writing DB
Processing sound banks (0):


Interestingly enough it shows it is adding the Chem:17 ammo type to the database. I just can't figure out why its crashing the mech lab...
 
Last edited:
Well, I'm out of ideas. It wouldn't surprise me if it was messed up somewhere inside the code, though. I say that because I tried using LB20X ammo type in a triggered effect once... the game didn't like that either, though regular ol' AC20 worked fine.
 
Well, I'm out of ideas. It wouldn't surprise me if it was messed up somewhere inside the code, though. I say that because I tried using LB20X ammo type in a triggered effect once... the game didn't like that either, though regular ol' AC20 worked fine.

That is very sad to hear... Given the fact that it works with existing AMS type vs any custom type I am starting to believe that the ModTek code: BattleTech.AmmoCategoryEnumeration in

"DataAddendumEntries":
[
{"name": "BattleTech.AmmoCategoryEnumeration", "path":"enums/AmmoCategory.json"}
],

Does not function as intended despite making updates to the new database. Hopefully somebody has an alternative method or an idea how to get around this. Sadly I am not smart enough to reverse engineer whatever they did in RougeTech or the CustomAmmoCategories mods. There are so many additional features in those i can't pick out what does what.
 
{
"ID" : 20,
"Name" : "Chem",
"FriendlyName" : "Chemical Ammo",
"IsBallistic" : true,
"IsMissile" : false,
"IsEnergy" : true,
"IsSupport" : false,
}

I have no experience in modding ammo types but I'd check if the MechLab crash isn't being caused by the Chem ammo being assigned both "IsBallistic" and "IsEnergy", since all the vanilla ammo types are only assigned to one category.
 
I have no experience in modding ammo types but I'd check if the MechLab crash isn't being caused by the Chem ammo being assigned both "IsBallistic" and "IsEnergy", since all the vanilla ammo types are only assigned to one category.

Thank you for catching that Hobbes, It must have been left over from when I was changing variables in an attempt to determine what the cause me be. It was corrected during an iteration and is now:

{
"ID" : 17,
"Name" : "TEST",
"FriendlyName" : "TEST",
"IsBallistic" : false,
"IsMissile" : false,
"IsEnergy" : true,
"IsSupport" : false,
"UsesInternalAmmo" : false,
"UIColorRef" : "Energy",
"FallbackUIColor" : null,
"Icon" : "EnergyHardpointIcon",
"OutOfAmmoAudioVOEvent" : null
}
 
Last edited:
if there are no exception in ModTek.log - only main game log can tell what goes wrong

KMission, Thank you for referencing the battletech log file. It is indeed lengthy. Of particular interest I've found:

This item in particular was the last item before the large crash below:

DataLoader [ERROR] LoadResource() - Caught exception while loading Program Files (x86)\Steam\steamapps\common\BATTLETECH\Mods\powermod\ammunition\Ammunition_TEST.json]

and then the doosy was:

DataLoader [ERROR] System.ArgumentException: Requested value 'TEST' was not found.
at System.Enum+EnumResult.SetFailure (System.Enum+ParseFailureKind failure, System.String failureMessageID, System.Object failureMessageFormatArgument) [0x00023] in
and not sure where this comes from:
MechLab [WARNING] GetWeaponPrefabName failed to find a prefab name for unit warhammer and component Weapon_Laser_MediumLaser_0-STOCK, ideal match name was: chrPrfWeap_warhammer_head_laser_eh, falling back to default item

I've never changed the prefabs before for the mechs and this is a clean install....


***FIXED item below***
ModLoader [LOG] Failed to load Newtonsoft.Json.dll at path \My Games\BattleTech\mods\HBS\Newtonsoft.Json.dll, because it doesn't exist at that path.



This should give me a few things to crunch on.
 
Last edited:
*sigh*
"ammoCategoryID" NOT "Category"
CAC will handle it anyway allowing both field names to be used, but you are not using CAC so you HAVE to operate new field style
and for the future - use spoiler tags or attach file, no one wants to read huge amount of text in post body.
 
*sigh*
"ammoCategoryID" NOT "Category"
CAC will handle it anyway allowing both field names to be used, but you are not using CAC so you HAVE to operate new field style
and for the future - use spoiler tags or attach file, no one wants to read huge amount of text in post body.

KMiSSioN,


Thank you for that. I changed the line as you specified in the Ammunition_TEST.json and it worked perfectly.

I have also cleaned up this post to make it easier to read.