• 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.
/alternate_start/_documentation.info

Code:
== Culture and religion spread ==
It is possible to randomize cultures and religions.
The basic process is this:

0. All cultures/religions are cleared from the map
1. For every group, a random province is chosen as the seed province (for religions, this is weighted using "religion_group_spawn", which can use the special trigger any_religion_distance to check the distance to groups already spawned. Religion group spawn happens in a random order)
2. Each province that neighbors a group gets its score calculated. Note that this means a province that borders multiple filled out provinces can have multiple entries. Even for the same group
3. A province is picked by random (weighted proportionally by the score) from the score list, and given the culture/religion group
4. Step 2 and 3 are repeated until all provinces have a culture/religion group
5. For each group, the religion/culture is cleared once more. Each culture/religion within that group randomly picks a starting province within the area allocated to the group. Steps 2 through 4 are then run using cultures rather than group

On top of normal adjacencies, the adjacencies from the "adjacencies" section are used. See the "adjacencies" section of this document. These are *required* if your mod has islands, as otherwise they might end up with no culture or religion. Your territory thus has to be fully connected. You can ensure a score of 0 to make sure it only ever spreads via such an adjacency when there are literally no other options though.

Scoring is done by the culture_spread and so on sections. In vanilla you find these in 01_spread.txt. The scopes available are the culture/religion as ROOT, and the province being evaluated as FROM.
For the groups, the provided culture/religion scope is the first entry within the group.

Can someone help me understanding this?
 
/alternate_start/_documentation.info

Code:
== Culture and religion spread ==
It is possible to randomize cultures and religions.
The basic process is this:

0. All cultures/religions are cleared from the map
1. For every group, a random province is chosen as the seed province (for religions, this is weighted using "religion_group_spawn", which can use the special trigger any_religion_distance to check the distance to groups already spawned. Religion group spawn happens in a random order)
2. Each province that neighbors a group gets its score calculated. Note that this means a province that borders multiple filled out provinces can have multiple entries. Even for the same group
3. A province is picked by random (weighted proportionally by the score) from the score list, and given the culture/religion group
4. Step 2 and 3 are repeated until all provinces have a culture/religion group
5. For each group, the religion/culture is cleared once more. Each culture/religion within that group randomly picks a starting province within the area allocated to the group. Steps 2 through 4 are then run using cultures rather than group

On top of normal adjacencies, the adjacencies from the "adjacencies" section are used. See the "adjacencies" section of this document. These are *required* if your mod has islands, as otherwise they might end up with no culture or religion. Your territory thus has to be fully connected. You can ensure a score of 0 to make sure it only ever spreads via such an adjacency when there are literally no other options though.

Scoring is done by the culture_spread and so on sections. In vanilla you find these in 01_spread.txt. The scopes available are the culture/religion as ROOT, and the province being evaluated as FROM.
For the groups, the provided culture/religion scope is the first entry within the group.

Can someone help me understanding this?

The basic idea is the following:
- Clear the map of all religions.
- Randomly (with weights) pick one province for each religion group to spawn in, e.g. Christianity in Venezia and Pagan in Damascus.

While any province lacks a religion group:
- Every province considered adjacent (normal adjacency or specifically for RW) to a province with a religion group gets a score for each group.
- One province not already assigned to any group gets picked (for each group?) and given to that group.
- Repeat.

- All groups are cleared but remembered.
- Randomly (with weights) pick one province within the area assigned to each group for each religion (permitted to spawn), e.g. Catholic in Vienna and Orthodox in Firenze.

While any province does not have a religion:
- Every province (possibly only within the area given to the group?) adjacent to a province assigned to a religion id given a score for each religion (within the group?).
- One province not alrady assigned to any religion gets picked (for each religion?) and given to that religion.
- Repeat.

The above is also run for culture groups and individual cultures in a similar manner.


What you are trying to achieve may or may not be possible; an obvious problem is that the "Fill in adjacent areas" approach would seem incapable of handling the African pagans having no adjacency to the (arguably connected) broad "Scandinavia to Tibet" pagan block, the Miaphysite/Monophysite presence in Abyssinia generally not being connected to the "European" Christian block, and the like. However, unless someone that has tested something similar to what you describe -- and it's possible nobody has, or that those that have aren't active here -- should happen to come along, the best way to determine what is and isn't possible is to try to get something simpler to work, e.g. "Christianity spawns in Britain and only spreads there, and no other religion group spawns or spreads there".
 
  • 2
Reactions:
The basic idea is the following:
- Clear the map of all religions.
- Randomly (with weights) pick one province for each religion group to spawn in, e.g. Christianity in Venezia and Pagan in Damascus.

While any province lacks a religion group:
- Every province considered adjacent (normal adjacency or specifically for RW) to a province with a religion group gets a score for each group.
- One province not already assigned to any group gets picked (for each group?) and given to that group.
- Repeat.

- All groups are cleared but remembered.
- Randomly (with weights) pick one province within the area assigned to each group for each religion (permitted to spawn), e.g. Catholic in Vienna and Orthodox in Firenze.

While any province does not have a religion:
- Every province (possibly only within the area given to the group?) adjacent to a province assigned to a religion id given a score for each religion (within the group?).
- One province not alrady assigned to any religion gets picked (for each religion?) and given to that religion.
- Repeat.

The above is also run for culture groups and individual cultures in a similar manner.


What you are trying to achieve may or may not be possible; an obvious problem is that the "Fill in adjacent areas" approach would seem incapable of handling the African pagans having no adjacency to the (arguably connected) broad "Scandinavia to Tibet" pagan block, the Miaphysite/Monophysite presence in Abyssinia generally not being connected to the "European" Christian block, and the like. However, unless someone that has tested something similar to what you describe -- and it's possible nobody has, or that those that have aren't active here -- should happen to come along, the best way to determine what is and isn't possible is to try to get something simpler to work, e.g. "Christianity spawns in Britain and only spreads there, and no other religion group spawns or spreads there".
Thank you. I possibly made some progress with the AND command and putting factor to 0. I didn't notice east_african cultures spawning in Europe, but so far I haven't tried it enough to say for sure.

Code:
modifier = {
        factor = 0
        culture_group = east_african
        
        AND = {
            region = world_europe 

        
        }
        NOT = {
            has_alternate_start_setting = {
                setting = culture
                option = full_random
            }
        }
    }

Here I did the same for religion, and it spawned only once to Africa. But again, not enough generations to say for sure.

Code:
modifier = {
        factor = 0
        religion_group = christian
        NOT = {
            has_alternate_start_setting = {
                setting = religion
                option = full_random
            }
        }
        AND = {
            region = {
                world_africa
            }
        }
    }

Can I use several "region = XX" entries inside "AND = { XX }", or do I have to make the whole deal for every region? Maybe "regions =" command works too?
 
Thank you. I possibly made some progress with the AND command and putting factor to 0. I didn't notice east_african cultures spawning in Europe, but so far I haven't tried it enough to say for sure.

Code:
modifier = {
        factor = 0
        culture_group = east_african
       
        AND = {
            region = world_europe

       
        }
        NOT = {
            has_alternate_start_setting = {
                setting = culture
                option = full_random
            }
        }
    }

Here I did the same for religion, and it spawned only once to Africa. But again, not enough generations to say for sure.

Code:
modifier = {
        factor = 0
        religion_group = christian
        NOT = {
            has_alternate_start_setting = {
                setting = religion
                option = full_random
            }
        }
        AND = {
            region = {
                world_africa
            }
        }
    }

Can I use several "region = XX" entries inside "AND = { XX }", or do I have to make the whole deal for every region? Maybe "regions =" command works too?

The AND wrapper is useless the way you use it as you already are in an implicit AND wrapper, and "region" cannot be used as a wrapper (and is in no way a command).

You should look into general CK2 syntax for how to use stuff like conditions, commands (not that you'll have any of those...), scopes, and other things, whether on the wiki or in assorted files.
 
The AND wrapper is useless the way you use it as you already are in an implicit AND wrapper, and "region" cannot be used as a wrapper (and is in no way a command).

You should look into general CK2 syntax for how to use stuff like conditions, commands (not that you'll have any of those...), scopes, and other things, whether on the wiki or in assorted files.
Religion_group_spread follows the same format in the same file as the following, and it has "region" as well. The only difference is that the following has NOT and not AND.

Code:
religion_group_spawn = {
    factor = 100
    modifier = {
        factor = 0.001
        any_religion_distance < 200
    }
    modifier = {
        factor = 0.1
        any_religion_distance < 350
    }
    modifier = { # No starting on islands, except the British Isles
        factor = 0
        is_island = yes
        NOT = { region = world_europe_west_brittania }

Here is another example of the file under culture_group_spread:

Code:
modifier = {
        factor = 8
        culture_group = altaic
        NOT = {
            has_alternate_start_setting = {
                setting = culture
                option = full_random
            }
        }
    }

But yeah, I'm definitely not a "modder". I've just made two minor mods for CK2 and EU4. Considering this seemed to work to some extent, I continue experimenting. Thanks for help!
 
If you're going to do a significant amount of modding, it really is worth using The Validator. It will catch many errors and tell you exactly what's wrong. Also, frequently check that your mod is working. Don't work on it for a week before trying it out, as a lot could be broken, or you could simply be on the wrong track of how to do something.
I guess my next question would be is there a guide on how to use Validator?
 
Religion_group_spread follows the same format in the same file as the following, and it has "region" as well.

Code:
region = my_region

and

Code:
region = { my_region }

are not at all the same (and you had both versions in the first post); the former is proper CK2 syntax, the latter is not, and the best-case scenario of using the latter is that it simply doesn't work (if you're unlucky, there are other problems, potentially all the way up to a CTD).

The only difference is that the following has NOT and not AND.

NOT and AND are vastly different in how they work. The former is never implicit, while the latter most of the time is implicit -- the main exceptions being if you are inside an OR, a NOT, a NOR, or a calc_true_if -- and while a redundant and unnecessary AND isn't going to affect general functionality (assuming it's just redundant and unnecessary) it is not something you want.

But yeah, I'm definitely not a "modder". I've just made two minor mods for CK2 and EU4. Considering this seemed to work to some extent, I continue experimenting. Thanks for help!

Experimenting is fine, but throwing things together willy-nilly to see if they work is a very inefficient way to go about learning to code (or write CK2 script), something can work but still be poorly implemented, and bad habits are hard to unlearn.


Code (or script) should ideally live up to the following, starting from the highest priority.

- It should work. If it doesn't, it's useless.

- It should run well. If it's inefficient, it should be improved.

- It should be readable. If it isn't, it'll be a nightmare to troubleshoot or to understand when you look at it at a later time (say because you want to do something similar), and you don't want that (and anyone potentially helping you spot issues also doesn't want to deal with an unreadable mess).

- It should be "easy"/"quick" to write. Depending on what you're trying to achieve, that might have to be tossed out.


All of the modifier blocks below (and an infinite number of other options) are the same condition (assuming no changes to the Celtic culture group from vanilla):

Code:
modifier = {
    factor = 2
    religion = catholic
    culture = irish
    government = feudal_government
}
modifier = {
    factor = 2
    AND = {
        religion = catholic
        culture = irish
        government = feudal_government
    }
}
modifier = {
    factor = 2
    AND = {
        religion = catholic
    }
    culture = irish
    government = feudal_government
}
modifier = {
    factor = 2
    religion = catholic
    AND = {
        culture = irish
        government = feudal_government
    }
}
modifier = {
    factor = 2
    religion = catholic
    culture = irish
    NOT = {
        NOT = {
            government = feudal_government
        }
    }
}
modifier = {
    factor = 2
    religion = catholic
    culture = irish
    OR = {
        government = feudal_government
    }
}
modifier = {
    factor = 2
    religion = catholic
    AND = {
        culture_group = celtic
        NOR = {
            culture = scottish
            culture = pictish
            culture = welsh
            culture = breton
        }
    }
    government = feudal_government
}

Do they work? Assuming you want to add a multiplicative modifier of 2 if -- and only if -- a character is an Irish Catholic with the Feudal government, any of the above would work.

Do they run well? All of these are straightforward, so all of them would run well, but the first is the cheapest to run, and performance losses add up.

Are they readable? Yes, but the first is the easiest to read due to having no superfluous parts.

Did it take me long to write any of them? Not really, but if copy-paste is ignored the first is certainly the fastest.


Everyone starts somewhere, but for you own sake I would advise looking at e.g. how CK2's boolean operators work, because misusing them is a good way to get something that doesn't work at all as desired.
 
  • 1
Reactions:
Everyone starts somewhere, but for you own sake I would advise looking at e.g. how CK2's boolean operators work, because misusing them is a good way to get something that doesn't work at all as desired.

Thanks for the reply, been a learning experience I suppose :D

But yeah, like I said, I have no idea what I'm doing, and can barely even decipher what you're saying. I really don't even know where to start. Reading the CK2 wiki about modding and implementing it into a functional mod is like trying to write a master thesis in foreign language by just reading the dictionary.

Like usually, I find a flaw in the game, or something that I wish worked differently, and try to fix it if it's not implemented by the developers or any modders. Couple of times I've succeeded by making small mods, but everything major goes way beyond my head. I'd much rather find a mod that does the thing already or just pay someone to make it lol.

I already moved into another """"modding"""" (aka. just messing around with the files) project. I'm trying to figure out how I could make an event that would fire at the beginning of a random generated game, converting wrong religions and cultures in wrong regions into a predetermined set of cultures/religions associated with said regions. I probably don't achieve anything with this one either, but at least I don't feel like I'm hitting my head to the wall and actually learn something (which I will forget in a week when my attention goes to something completely different again lol)
 
Code:
region = my_region

and

Code:
region = { my_region }

are not at all the same (and you had both versions in the first post); the former is proper CK2 syntax, the latter is not, and the best-case scenario of using the latter is that it simply doesn't work (if you're unlucky, there are other problems, potentially all the way up to a CTD).



NOT and AND are vastly different in how they work. The former is never implicit, while the latter most of the time is implicit -- the main exceptions being if you are inside an OR, a NOT, a NOR, or a calc_true_if -- and while a redundant and unnecessary AND isn't going to affect general functionality (assuming it's just redundant and unnecessary) it is not something you want.



Experimenting is fine, but throwing things together willy-nilly to see if they work is a very inefficient way to go about learning to code (or write CK2 script), something can work but still be poorly implemented, and bad habits are hard to unlearn.


Code (or script) should ideally live up to the following, starting from the highest priority.

- It should work. If it doesn't, it's useless.

- It should run well. If it's inefficient, it should be improved.

- It should be readable. If it isn't, it'll be a nightmare to troubleshoot or to understand when you look at it at a later time (say because you want to do something similar), and you don't want that (and anyone potentially helping you spot issues also doesn't want to deal with an unreadable mess).

- It should be "easy"/"quick" to write. Depending on what you're trying to achieve, that might have to be tossed out.


All of the modifier blocks below (and an infinite number of other options) are the same condition (assuming no changes to the Celtic culture group from vanilla):

Code:
modifier = {
    factor = 2
    religion = catholic
    culture = irish
    government = feudal_government
}
modifier = {
    factor = 2
    AND = {
        religion = catholic
        culture = irish
        government = feudal_government
    }
}
modifier = {
    factor = 2
    AND = {
        religion = catholic
    }
    culture = irish
    government = feudal_government
}
modifier = {
    factor = 2
    religion = catholic
    AND = {
        culture = irish
        government = feudal_government
    }
}
modifier = {
    factor = 2
    religion = catholic
    culture = irish
    NOT = {
        NOT = {
            government = feudal_government
        }
    }
}
modifier = {
    factor = 2
    religion = catholic
    culture = irish
    OR = {
        government = feudal_government
    }
}
modifier = {
    factor = 2
    religion = catholic
    AND = {
        culture_group = celtic
        NOR = {
            culture = scottish
            culture = pictish
            culture = welsh
            culture = breton
        }
    }
    government = feudal_government
}

Do they work? Assuming you want to add a multiplicative modifier of 2 if -- and only if -- a character is an Irish Catholic with the Feudal government, any of the above would work.

Do they run well? All of these are straightforward, so all of them would run well, but the first is the cheapest to run, and performance losses add up.

Are they readable? Yes, but the first is the easiest to read due to having no superfluous parts.

Did it take me long to write any of them? Not really, but if copy-paste is ignored the first is certainly the fastest.


Everyone starts somewhere, but for you own sake I would advise looking at e.g. how CK2's boolean operators work, because misusing them is a good way to get something that doesn't work at all as desired.

I just wanted to thank you again for pushing me to absorb the wiki. With the help of an already existing mod, I realized I could make a scenario to the alternative start and painstakingly add the following code after every single custom region, along the lines of historical cultures and religions:

Code:
{ region = custom_balkans }     random_list = { 10 = {culture = serbian} 10 = {culture = croatian}     10 = {culture = bosnian} 2 = {culture = dalmatian}    2 = {culture = carantanian}         } }

It's even better when you add
Code:
 random_list = { 10 = {culture = no}
, so when you use the historical culture setup in the alt-start, all the no cultures get filled up with historical cultures. This doesn't seem to work with religions though.

So far, I have made the alt-start setup screen to use sliders, so that every bookmark would have its own slider, with appropriate religions and cultures for the time period. It works well, although it's rather impractical considering there's a separate slider for every single region. But then again, it would be nice to mix them up for new scenarios.

Another problem is obviously the bordergore and cultural and religious enclaves all over the place. I wonder if it's possible to somehow make them cluster more? But other than that, the mod works flawlessly and pretty much exactly how I wanted it to work. It will take ages until it's ready completed though. I'm maybe 65% done.
 
what are the easiest ways to add or remove the entire regions like that?

i would like to add a little bit more of afroca and byzantium
 
Which is easier on performance?

A MTTH event with ai = no and only_playable = yes pre-filters?

Or an identical but triggered-only event that fires on_yearly_pulse with the same pre-filters?

ai = no already implies only_playable = yes, there's no need to have the latter with the former.
Also, MTTH events are unlikely to be better for performance than anything else you can come up with, outside of triggered modifiers.
 
Is there a way to display a character's current wealth in localisation text?

(There's nothing obvious on the wiki; and my guesses of [This.wealth.GetValue] & [This.GetWealth] don't work.)

If you want to reference it in e.g. an event chain, you could export it to a variable and then reference that. However, that'll not work if you e.g. want to reference it in a decision, a CB, or something else that doesn't allow you to first export a variable.
 
ai = no already implies only_playable = yes, there's no need to have the latter with the former.
Also, MTTH events are unlikely to be better for performance than anything else you can come up with, outside of triggered modifiers.
Thanks for the clarification.

I know ai = no makes only_playable = yes redundant, but since the former is a normal pre-trigger and the latter is a filtering pre-trigger, I figure that it improves performance even more, if only marginally.

That is, on the fastest, quickest, easiest level of performance, that of an event's filtering pre-triggers being checked, only_playable = yes eliminates all non-playable characters as "junk" and doesn't waste time even beginning to evaluate them, then it reaches the normal pre-triggers level, where it eliminates all the playable rulers except the player with ai = no.

Am I misunderstanding the difference between normal pre-triggers and filtering pre-triggers here?
 
I'm making an EU4 mod and wanted to add new Nations like "Francia" or "Al Andalus" but i tried creating Country and History files and added the tags in the country tags file and in the localisation files with the adjectives of them. The Problem ist that the Countries dont seem to get their right names, just their tags, for example: Francia is just "FRC" and Al Andalus is just "AND"
Is there any common bug like this and how can I avoid it.

Have a good Day,
Gab.
 
If you want to reference it in e.g. an event chain, you could export it to a variable and then reference that. However, that'll not work if you e.g. want to reference it in a decision, a CB, or something else that doesn't allow you to first export a variable.
Unfortunately, I'm trying to use it in targeted decision text, as an extra piece of info for the player.

(My prisoner-management mod allows immediate auto-ransom of prisoners via targeted decision on their liege. When prisoners are ransoming themselves, I want to display the amount of ransom and the amount of money the prisoner has, so that the player can decide whether they want to do something else. It's annoying to ransom someone for 10 gold when they're holding thousands, which is probably worth a recruit-imprison-banish...)

Is it possible to display a character's wealth via custom localisation, somehow?
 
Unfortunately, I'm trying to use it in targeted decision text, as an extra piece of info for the player.

(My prisoner-management mod allows immediate auto-ransom of prisoners via targeted decision on their liege. When prisoners are ransoming themselves, I want to display the amount of ransom and the amount of money the prisoner has, so that the player can decide whether they want to do something else. It's annoying to ransom someone for 10 gold when they're holding thousands, which is probably worth a recruit-imprison-banish...)

Is it possible to display a character's wealth via custom localisation, somehow?

Custom loc is unlikely to fully work since you can't access the current wealth "variable" and checking the character's exact wealth would require hundreds or thousands of possibilities... but you could perhaps have the custom loc set up with "wealth tiers" and have it show something like "<character> has a personal wealth between <bounds>", since you can check e.g. "wealth >= 400 wealth < 500".
 
  • 1
Reactions:
Custom loc is unlikely to fully work since you can't access the current wealth "variable" and checking the character's exact wealth would require hundreds or thousands of possibilities... but you could perhaps have the custom loc set up with "wealth tiers" and have it show something like "<character> has a personal wealth between <bounds>", since you can check e.g. "wealth >= 400 wealth < 500".
That's not at all elegant, but it really works - thank you!

20240129222636_1.jpg

EDIT: And I added artifact detection too :)

20240129225318_1.jpg
 
Last edited: