Jump to content

Suggestion: Use of unique IDs to reduce cross-mod incompatibility


Alluvian_Est-Endrati

Recommended Posts

Posted

Greetings all.

 

Some of the mod conflicts for CK3 (and for CK2 as well) are caused by incompatible numeric IDs for various entries, such as traits, events, etc. This occurs when two (or more) mod authors use the same numeric IDs within a given category.

 

One potential solution, is to use a unique prefix for each mod author. Here at the Lab, one method to obtain a semi-unique numeric is the ID you are assigned with your account. This number can be viewed when examining a user profile. For example: "www.loverslab.com/profile/12345678-this-is-a-test-user" would provide "12345678".

 

Posted

Is this actually an issue with CK3 specifically?

 

With CK2 it was fairly easy to avoid, like you suggest, by prefixing your stuff with '<modname>_<reference_string>'. It tends to make reading mod-specific code easier too.

 

As an example, for Perverts of Azeroth, I use(d) the prefix 'WPOA_' before everything related to the mod; traits(WPOA_Futa), modifiers(WPOA_Sex_CD), localization(WPOA_Arousal_3), whatever.

Posted
2 hours ago, Darsel said:

Is this actually an issue with CK3 specifically?

 

With CK2 it was fairly easy to avoid, like you suggest, by prefixing your stuff with '<modname>_<reference_string>'. It tends to make reading mod-specific code easier too.

 

As an example, for Perverts of Azeroth, I use(d) the prefix 'WPOA_' before everything related to the mod; traits(WPOA_Futa), modifiers(WPOA_Sex_CD), localization(WPOA_Arousal_3), whatever.

Yeah, I'm not aware of any mods that suffered from that issue here off hand. Most utilized some kind of prefix that was unique to their mod.

Posted

Keep in mind that the maximum trait index is 2147483647 and this leaves you with 100 possible trait indexes. Enough for most mods, but not total conversions or bigger ones.

 

At the end of the day, we're likely left with "mod registries" again, same as in the bad old days of early CK2 modding for events, until Paradox reinvents the wheel again and lets us set namespaces on trait indexes and so on.

Posted
4 hours ago, Darsel said:

Is this actually an issue with CK3 specifically?

 

With CK2 it was fairly easy to avoid, like you suggest, by prefixing your stuff with '<modname>_<reference_string>'. It tends to make reading mod-specific code easier too.

 

As an example, for Perverts of Azeroth, I use(d) the prefix 'WPOA_' before everything related to the mod; traits(WPOA_Futa), modifiers(WPOA_Sex_CD), localization(WPOA_Arousal_3), whatever.

It seems worse with CK3. Along with the name of the trait, there's also an index number for the trait. So in CK2 you put the mod name in front of the trait name. But now you also have a number for the trait which I guess can't be the same as any other trait numbers. I don't really know why they'd just make it worse like that. Is there some benefit I'm not seeing? Like, I do see one very minor benefit. Which is that if you remove any traits during a CK2 save, it would mess a bunch of traits up. Like the game did its own indexing where the base game traits get assigned in order, then mods based on what order they load. Then if you remove a mod, the trait numbers are weird so somebody still has the 240th trait, which used to be giant penis but now it's small tits. That's an actual thing that happened to me once. Anyway, that only happens if you remove traits mid-save. Which is a very rare scenario, whereas mods that both want to add traits and have to use index numbers and might use the same ones seems way more common.

Posted
1 hour ago, whateverdontcare said:

Like, I do see one very minor benefit. Which is that if you remove any traits during a CK2 save, it would mess a bunch of traits up.

Bingo, and I wouldn't call it minor. It was usually the reason why Paradox always kept having to tell its player-base, "Sorry, this update isn't compatible with old saves." Now, when Paradox adds or removes future traits in their inevitable future DLC, maybe it wont break the old saves. Or maybe it still will, lol who knows, it's Paradox.

 

I wish Paradox had did the trait Index back in CKII so I wouldn't have to answer the hundreds of questions I got wondering why my portraits wouldn't work, even though I'd specifically tell players to always start a new game and not add/remove mods that add/remove traits on old save files. Anytime the trait Index changed even just one number, boom, everything screwed up.

Posted
3 hours ago, Khadir said:

Keep in mind that the maximum trait index is 2147483647 and this leaves you with 100 possible trait indexes. Enough for most mods, but not total conversions or bigger ones.

 

At the end of the day, we're likely left with "mod registries" again, same as in the bad old days of early CK2 modding for events, until Paradox reinvents the wheel again and lets us set namespaces on trait indexes and so on.

That's.. good to know; although a lot of Traits can be shifted over to Modifiers if need be. It's a little less clean to run logic for Modifiers(atleast in CK2), but I presume it's still a viable workaround unless those are indexed now as well.

 

As an ingame example, 'Obese' is a Modifier in CK3 now, instead of being a Trait(Fat) like it was in CK2.

 

I confess I'm not really sure what their internal reasoning is for whether something is a trait or modifier. My initial thought was permanence versus malleable, but then you've got Traits like Wounded and Ill. One of my rulers had the Obese Modifier for over 20 years(his death was due to it, infact), while the decision to lose weight was active the entire time. Conversely, his predecessor had the Melancholic Trait for most of his life but managed to lose it a few months right before he died of old age.

Posted
51 minutes ago, Darsel said:

That's.. good to know; although a lot of Traits can be shifted over to Modifiers if need be. It's a little less clean to run logic for Modifiers(atleast in CK2), but I presume it's still a viable workaround unless those are indexed now as well.

There are a few things which only work for traits, and I assume the same for modifiers. Right now, it looks like only traits can be sins or virtues according to religious doctrines, for example.

Posted
12 hours ago, whateverdontcare said:

It seems worse with CK3. Along with the name of the trait, there's also an index number for the trait. So in CK2 you put the mod name in front of the trait name. But now you also have a number for the trait which I guess can't be the same as any other trait numbers. I don't really know why they'd just make it worse like that. Is there some benefit I'm not seeing? Like, I do see one very minor benefit. Which is that if you remove any traits during a CK2 save, it would mess a bunch of traits up. Like the game did its own indexing where the base game traits get assigned in order, then mods based on what order they load. Then if you remove a mod, the trait numbers are weird so somebody still has the 240th trait, which used to be giant penis but now it's small tits. That's an actual thing that happened to me once. Anyway, that only happens if you remove traits mid-save. Which is a very rare scenario, whereas mods that both want to add traits and have to use index numbers and might use the same ones seems way more common.

I read on ck3 forrums that the id number was just left over from a debugging software and not actually used by the game. Haven't tested that yet though.

Posted
12 hours ago, whateverdontcare said:

It seems worse with CK3. Along with the name of the trait, there's also an index number for the trait. So in CK2 you put the mod name in front of the trait name. But now you also have a number for the trait which I guess can't be the same as any other trait numbers. I don't really know why they'd just make it worse like that. Is there some benefit I'm not seeing?

Events are not really a problem since you have namespace. Those are converted from string to an actual number at runtime based on what mods are being loaded. You might run out of numbers with hundreds of large mods, but honestly, the game would probably have so many other issues at that point.

 

Name spaces work because events are not part of a save game, so the actual number is only important while the game runs.

 

 

 

Traits on the other hands are problematic. Either they have sequential number (like in ck2). Which means adding a new trait shifts all other traits (and breaks all save games).

Or you have a static index (like in ck3) and that means you have to choose a number and make sure no one else uses it. This comes down to a "mod base offset registry". However, it becomes interesting when you look at the error log of the game and there is a clear warning that leaving gaps in traits index will cause the game to be slower (probably because the traits are stored in a vector and not a hash map). This means a registry, will lead to trait index fragmentation which will lead to a game slowdown down the road.

 

Honestly, I am not sure why there is not a namespace system for traits where the save game keeps the full "namespace.trait" index instead of simply saving the trait index to the save game. There might be a reason (or they just never bothered with it).

 

 

Posted
15 minutes ago, Untolddead said:

I read on ck3 forrums that the id number was just left over from a debugging software and not actually used by the game. Haven't tested that yet though.

It's easy to see how they're used. Open up a save game (after unpacking) and check the characters' traits.

Posted
35 minutes ago, Khadir said:

It's easy to see how they're used. Open up a save game (after unpacking) and check the characters' traits.

Traits in the save file are stored like this

Quote

traits={61 58 72 13 211}

 

Posted
On 9/7/2020 at 3:12 PM, coleman1 said:

Traits in the save file are stored like this

 

And I can confirm that those are the index numbers.  I created a mod with a trait that had an index of 500 and that's the number that showed up in the save file.

Posted
5 hours ago, joemann said:

if CK3 does not use the namespace for traits, it will just ignore the mod prefix in a trait? So no point in adding them to traits in my mod?

 

 

Not sure what you are referring to. Traits do not have namespace in their syntax. The vanilla trait file does not contain any traits with a dot (.) in them and there is no namespace definition at the top of the file.

 

I have not tried to name a trait with a sot in the name. Maybe the parser will allow it. But honestly, I would avoid it as it seems counter intuitive to their syntax.

 

 

 

One thing does make me curious are the @annotation at the top of the trait file. I'm wondering what they are used for and what we might do with those.

Quote

@po_compat_high = 30

@pos_compat_medium = 15

@pos_compat_low = 5

 

@neg_compat_high = -30

@neg_compat_medium = -15

@neg_compat_low = -5

 

Posted

in CK2 I used to precede the trait name with a prefix to avoid conflict with other mods: example <modprefix><trait_name>

 

on @po_compat  the trait info file mentions the following:

 

compatibility = { # This is not a Opinion modifier, but can be used by 'compatibility_modifier' and 'trait_compatibility' trigger. Compatibility is checked for the Trait holder vs the listed Traits (of another character.)
    gluttonous = 20
    drunkard = @pos_compat_low
}

Posted
On 9/7/2020 at 7:26 AM, Khadir said:

Keep in mind that the maximum trait index is 2147483647 ...

Just curious where you got the limit number from?

I tried date/time as a test (index = 202009081516) and ck3 hasn't complained and showed the correct trait.

Posted
1 hour ago, Sinus said:

Just curious where you got the limit number from?

I tried date/time as a test (index = 202009081516) and ck3 hasn't complained and showed the correct trait.

Because that's 2^31-1. And also I tried two traits, one with 2147483647  and one with 2147483648, and CK3 "rolled back" the latter to 0.

 

Best check what your trait ends up as in the save game.

Posted

Ok, just checked a save and my trait got a totally different number... not 0 but something in the 60k range (?!)... guess there is something to the limit.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...