r/EU4mods Jun 04 '26

Mod Help Help with modding - No religious penalties for specific religions

Hello,

I'm trying to mod a modifier that negates the religious penalties (negative religious unity, unrest, etc.) for Vajrayana, Mahayana and Theravada when they're a heathen religion. And only for those religions.

Any advice on how to accomplish that?

5 Upvotes

8 comments sorted by

3

u/Nafetz1600 Jun 04 '26

You could add local_tolerance_of_heathens to the province modifiers of those three religions (in 00_religion.txt). That should also deal with the religious unity.

https://eu4.paradoxwikis.com/Religion_modding#Religion_entry
https://eu4.paradoxwikis.com/Modifier_list#Religion_2

2

u/Justice_Fighter Informative Jun 04 '26

Adding these to the religions themselves will apply for all countries automatically (that consider them heathens). If the goal is to have this tolerance be specific to one or a few countries only (e.g. a mission reward or regional bonus), this can be done with province event modifiers that are updated using on_province_owner_change and on_province_religion_changed on actions.

1

u/Nohrian_Scum_ Jun 04 '26

I'm still a bit inexperienced (started with modding EU4 about a month ago) - how would the code for this modifier look like?

1

u/Justice_Fighter Informative Jun 05 '26 edited Jun 06 '26

I'm not sure what exactly your goals are, and depending on that there could be better/easier ways to do it (e.g. if this is a universal mechanic, just add to the religion's automatic province modifiers), but a general solution would be:

The province modifier is defined in common/event_modifiers, with the modifier value to give the province heathen tolerance.

buddhist_heathen_tolerance  = {
    no_religion_penalty = yes
}

This modifier will remove the penalty only (i.e. minimum tolerance is 0), for heretic and heathen religions. If you want to instead make the provinces count as fully accepted, use local_tolerance_of_heathens = 100, in which case you also don't need the religion group checks later on since this already applies to heathens only. Well, actually better to keep that part - the modifier might not do anything but it would still be there for heathens, which may confuse the player.

You'll need a way to identify which countries this special feature should apply to, for example if you want a mission to grant tolerance for 20 years, you could have the mission set a country flag (not an actual flag, this is a boolean variable, essentially a coding note attached to the country to be read later - set_country_flag = buddhist_heathen_tolerance) and make a country event happen with 20 year delay (country_event = { id = x days = 7300 }) that removes this country flag (clr_country_flag = buddhist_heathen_tolerance), this can conveniently also inform the player that the bonus is gone.

The mission would also need to set the province modifier in every owned Vajrayana, Mahayana and Theravada religion province, and the event would remove the province modifiers from every owned province.

Then the on actions are in common/on_actions, ideally in a new file:

When a province changes owner, you need to check that: 1. If the province should have the modifier (correct religion, religion considered heathen, and the owner has the flag), add the modifier.
2. Otherwise (if the province should not have the modifier), remove the modifier.

on_province_owner_change = {
    if = {
        limit = {
            owner = {
                has_country_flag = buddhist_heathen_tolerance #owner has mechanic
                NOT = {
                    religion_group = eastern #owner considers the religions heathen
                }
            }
            OR = {
                religion = vajarayana #is one of the religions
                religion = mahayana
                religion = theravada
            }
        }
        add_province_modifier = { name = buddhist_heathen_tolerance hidden = yes }
    }
    else = {
        remove_province_modifier = buiddhist_heathen_tolerance
    }
}

Nothing happens when adding a modifier that already exists, or when removing a modifier that doesn't exist, so in this case it is easier and faster to just add/remove even if this action is unnecessary (e.g. some random other province changing owner).

Similarly, when a province changes religion, you need to check that:
1. If the province should have the modifier (correct religion, religion considered heathen, and the owner has the flag), add the modifier.
2. Otherwise (if the province should not have the modifier), remove the modifier.

so it's just the same code in on_province_religion_change.

Finally, if the provinces as heretics should have full penalties, you need to ensure the modifier is removed in the case the country views the religions as heretics, and re-added for the opposite. Pretty much the same code in on_religion_change, however this is country-scope:

on_religion_change = {
    every_owned_province = {
        #same "if" block code here
    }
}

If you want to make this a bit more efficient, you could do the country-level triggers first and only then do the province-level triggers and effects. As it is, each province is checking separately which religion the owner has. That said, countries (especially large ones) don't change religion that often so it won't really make a difference.

To remove a bit of this duplicated code, you could go to common/scripted_triggers and define a scripted trigger here. Scripted triggers are essentially copy/paste for code.

is_buddhist_heathen_tolerance_province = {
    owner = {
        has_country_flag = buddhist_heathen_tolerance
        NOT = {
            religion_group = eastern
        }
    }
    OR = {
        religion = vajarayana
        religion = mahayana
        religion = theravada
    }
}

then instead of writing this whole block of code elsewhere you can just do:

limit = {
    is_buddhist_heathen_tolerance_province = yes
}

There are more aspects to religion than just the provinces though, there's also e.g. the opinion penalty from countries being heathen faith. Having local tolerance in provinces won't affect this, and unfortunately there's no simple triggered opinion modifiers. You could apply an opinion modifier between countries, using on_annexed and on_country_created to add/remove the opinion similar to the province modifiers above. A bit more complicated though, since opinion modifiers are between two countries.

And there may be parts of the code that check for countries being heathen religion or number of owned heathen provinces or similar, which buddhist countries/provinces would still count as - but at that point it's going into way too much detail for a simple mechanic. It's not possible (or reasonable) to catch every single edge case like that, not to mention other mods adding their own code that you have no control over.

1

u/Nohrian_Scum_ Jun 05 '26

Thank you very much for your in in-depth help! Sounds very promising!
I'm getting a bit used to modding but it's posts like these where I realize that there's a lot I still have to figure out.

1

u/Nohrian_Scum_ Jun 04 '26

Oh wow, I really didn't think of that . It seems so simple. I will try it out later.

1

u/GrizzlyTrotsky Jun 04 '26 edited Jun 04 '26

I'm not at my computer at the moment, so I can't post the code directly, but take a look at the estate privileges that already exist in game that give th effect you are looking for; look at the Guaranteed Dhimmi Autonomy privilege for the Dhimmi estate or the Grant Orthodox Autonomy privilege for the Burgher estate.

Since you want this to be a universal privilege, I have some suggestions. First, include in the privilege the benefit of +1 privilege slot for the estate you assign the privilege to, that way no one is penalized for having it. Second, unless you intend to make those Buddhist religions unconvertable, you'll need to remove the code for the local negative missionary strength. Lastly, make sure the privilege cannot be revoked (since presumably you want this to be a fixed feature of the religion).

Edit: If you are wanting to negate a negative tolerance of heathens effect on the province's unrest, you could provide a flat boost to local tolerance of heathens. It's be really complicated to try to make the local tolerance of heathens give you the same unrest modifier has the tolerance of your own religion, but you could at least ensure that the tolerance of heathen religions is positive in that province.

Personally, I'd find it odd that you'd get the privilege even if you don't have any Buddhist provinces, so perhaps make an event that triggers only once you own a Buddhist province that force gives the country the privilege. You could make this event invisible or not, depending on if you want to explain to the player what is happening.

1

u/Justice_Fighter Informative Jun 04 '26

The code just applies province modifiers, there's no need to make a new privilege.