# Modding - Quick questions

#### jursamaj

##### General
Hello and I appreciate The time you invest to provide assistance.

I am a mere tester for converter team that provides a possibility for players to enjoy a mega-campaign experience across multiple Paradox games.

One of the projects the converter team is working on at the moment is converting the Imperator Rome into the CK2. I don't feel alone in feeling a game is missing between the I:R era and the Ck2 to cover the historical events of the period between I:R end game and the CKII starting date, but until that game comes to reality one day we are working on a converter connecting I:R to CkII.

The converter has a starting point of 1066 and 100 AD.

Now the inquiry is where is it possible to modify tech modifiers? Feeling a need here to add a modifier dependent on the in game year so that during the 1340 years to come from the 100 AD starting point, the tech has room to advance. A modifier to make the integral of a 1044 to 1440 total research points gained for a medium region, equal to the integral of the 100 AD to 1440 research points gained in the converted game. The modifier would look like the following functions*:

Y= Research point modifier that will be multiplied to the number of research gained and will be a negative value
X= The current year {x>100)

Formula: Y= ( (Radical (X+100)+(X+100)^1/2) / 4 ) - 10

Or a simple y = 0.00373 * x -5.62
Or just y = - 0.5

Is it possible to add such a modifier to the mod's tech. I would really appreciate if you could help me with your insight.

*The formulas are only for example Just to see if such functions can be supported.
Question for clarification: Is this converter being implemented in one of the games, or implemented as a separate program?

If a separate program, it can support any function you like.
If within one of the games, taking roots is not directly supported, but there are methods to get roots with nothing but simple math and iteration. But this seems the hard way.

But honestly, there's a problem with this method of adjusting research. In addition to the monthly gain of research, there are many events that award research points. To the best of my knowledge, these awards are not adjusted by research modifiers. Thus, getting such events will throw the whole system out of wack. For instance, I already like the scholar lifestyle astronomy events, because they can produce research points. If my monthly research were reduced by 80%, those events are 5 times as good, and I should almost always be an astronomer!

• 1

#### Siawosh

##### Recruit
Question for clarification: Is this converter being implemented in one of the games, or implemented as a separate program?

If a separate program, it can support any function you like.
If within one of the games, taking roots is not directly supported, but there are methods to get roots with nothing but simple math and iteration. But this seems the hard way.

But honestly, there's a problem with this method of adjusting research. In addition to the monthly gain of research, there are many events that award research points. To the best of my knowledge, these awards are not adjusted by research modifiers. Thus, getting such events will throw the whole system out of wack. For instance, I already like the scholar lifestyle astronomy events, because they can produce research points. If my monthly research were reduced by 80%, those events are 5 times as good, and I should almost always be an astronomer!
Thank you for being helpful. I appreciate that.

To clarify: The converter is an application that converts a save game from a game to another. It generates the mod so as it converts a mod for the CKII it is out and no more used during the game. It sort of translates the I:R into a mod that the player can enjoy on CKII. But while generating the CKII it can modify certain files such as regions holdings and to a certain level characters and what they own at the moment according to what is in the I:R mode. I assume This means that It is implemented in the game not as a separate program as it is no more in use once the conversion is done.

Actually I have come to understand that It would not be possible to fully control the tech advancement If the modifiers don't work for events or the events can't be modified. unless the tech is disabled or ideally capped for certain years. Or the events are controlled. Well perfection seems further but advancement can be achieved if the modification to the passive research can be gained. Do you know how I can add a modifier to the research so I test the outcome? I mean is it in one of the text files or it is inside the codes of the game?

#### Rockphed

##### Uncultured Barbarian
SOLVED: See bottom for solution.

So I have made an event that should destroy all of your trade posts and rebuild them as they were even if you have more than your limit. Unfortunately, it seems to have a problem where it steals the tradeposts from other patricians who have run the event. I think it has to do with not clearing a province flag properly, but I am not sure how to fix it if that is the problem. I can't even figure out how to check which province flags a province has in game (scripting I think I understand).

Event:
Code:
``````character_event = {
id = repair_TP.4
is_triggered_only = yes
is_ruler = yes
hide_window = yes

trigger = {
is_patrician = yes
war = no
NOT = {
}
}
}
fail_trigger_effect = {
if = {
limit = {
}
}
delay = 50
character_event = {id = repair_TP.4}
}

}
immediate = {
random_realm_lord = {
limit = {
is_patrician = yes
NOT = { character = ROOT }
}
save_event_target_as = target_usurper
}

province_event = {id = repair_TP.3}
}
any_province = {#recreate and give to another patrician
limit = {
}
province_event = {id = repair_TP.5}
}

}
after = {
event_target:target_usurper = {
limit = {
}
clear_flags_with_prefix = repair_
}
}

}
}``````

All the events involved for the interested:
Code:
``````province_event = {
id = repair_TP.3
is_triggered_only = yes

hide_window = yes
immediate = {

save_event_target_as = target_patrician
wealth = 100
}
if {
set_flag = repair_tr_port_3
}
if = {
set_flag = repair_tr_port_2
}
if = {
set_flag = repair_tr_port_1
}
if {
set_flag = repair_tr_enclave_3
}
if = {
set_flag = repair_tr_enclave_2
}
if = {
set_flag = repair_tr_enclave_1
}
if {
set_flag = repair_tr_garrison_3
}
if = {
set_flag = repair_tr_garrison_2
}
if = {
set_flag = repair_tr_garrison_1
}

if {
}
if = {
}
if = {
}
if {
}
if = {
}
if = {
}
if {
set_flag = repair_mercenary_garrison_3
}
if = {
set_flag = repair_mercenary_garrison_2
}
if = {
set_flag = repair_mercenary_garrison_1
}
if {
}
if = {
}
if = {
}
if {
set_flag = repair_tr_sahara_3
}
if = {
set_flag = repair_tr_sahara_2
}
if = {
set_flag = repair_tr_sahara_1
}
if {
set_flag = repair_tr_gold_mine_3
}
if = {
set_flag = repair_tr_gold_mine_2
}
if = {
set_flag = repair_tr_gold_mine_1
}
if {
set_flag = repair_tr_salt_mine_1
}
if {
set_flag = repair_cloth_production_1
}

wealth = 100
}

}
}

character_event = {
id = repair_TP.4
is_triggered_only = yes
is_ruler = yes
hide_window = yes

trigger = {
is_patrician = yes
war = no
NOT = {
}
}
}
fail_trigger_effect = {
if = {
limit = {
}
}
delay = 50
character_event = {id = repair_TP.4}
}

}
immediate = {
random_realm_lord = {
limit = {
is_patrician = yes
NOT = { character = ROOT }
}
save_event_target_as = target_usurper
}

province_event = {id = repair_TP.3}
}
any_province = {#recreate and give to another patrician
limit = {
}
province_event = {id = repair_TP.5}
}

}
after = {
event_target:target_usurper = {
limit = {
}
clear_flags_with_prefix = repair_
}
}

}
}
province_event = {
id = repair_TP.5
hide_window = yes
is_triggered_only = yes

immediate = {
FROM = {

}
if {
limit = {has_flag = repair_tr_port_3}
building = tr_port_3
}
}
if = {
limit = {has_flag = repair_tr_port_2}
building = tr_port_2
}
}
if = {
limit = {has_flag = repair_tr_port_1}
building = tr_port_1
}
}
if {
limit = {has_flag = repair_tr_enclave_3}
building = tr_enclave_3
}
}
if = {
limit = {has_flag = repair_tr_enclave_2}
building = tr_enclave_2
}
}
if = {
limit = {has_flag = repair_tr_enclave_1}
building = tr_enclave_1
}
}
if {
limit = {has_flag = repair_tr_garrison_3}
building = tr_garrison_3
}
}
if = {
limit = {has_flag = repair_tr_garrison_2}
building = tr_garrison_2
}
}
if = {
limit = {has_flag = repair_tr_garrison_1}
building = tr_garrison_1
}
}
if {
}
}
if = {
}
}
if = {
}
}
if {
}
}
if = {
}
}
if = {
}
}
if {
limit = {has_flag = repair_mercenary_garrison_3}
building = mercenary_garrison_3
}
}
if = {
limit = {has_flag = repair_mercenary_garrison_2}
building = mercenary_garrison_2
}
}
if = {
limit = {has_flag = repair_mercenary_garrison_1}
building = mercenary_garrison_1
}
}
if {
}
}
if = {
}
}
if = {
}
}
if {
limit = {has_flag = repair_tr_sahara_3}
building = tr_sahara_3
}
}
if = {
limit = {has_flag = repair_tr_sahara_2}
building = tr_sahara_2
}
}
if = {
limit = {has_flag = repair_tr_sahara_1}
building = tr_sahara_1
}
}
if {
limit = {has_flag = repair_tr_gold_mine_3}
building = tr_gold_mine_3
}
}
if = {
limit = {has_flag = repair_tr_gold_mine_2}
building = tr_gold_mine_2
}
}
if = {
limit = {has_flag = repair_tr_gold_mine_1}
building = tr_gold_mine_1
}
}
if {
limit = {has_flag = repair_tr_salt_mine_3}
building = tr_salt_mine_3
}
}
if = {
limit = {has_flag = repair_tr_salt_mine_2}
building = tr_salt_mine_2
}
}
if = {
limit = {has_flag = repair_tr_salt_mine_1}
building = tr_salt_mine_1
}
}
if {
limit = {has_flag = repair_tr_cloth_production_3}
building = tr_cloth_production_3
}
}
if = {
limit = {has_flag = repair_tr_cloth_production_2}
building = tr_cloth_production_2
}
}
if = {
limit = {has_flag = repair_tr_cloth_production_1}
building = tr_cloth_production_1
}
}
}
}``````

SOLUTION: When I was transferring the tradeposts to another patrician I was using "random_realm_lord" to select another patrician, but I think that that finds someone below the scope. I changed it to
Code:
``````liege = {
random_realm_lord = {
limit = {
is_patrician = yes
NOT = { character = ROOT }
}
save_event_target_as = target_usurper
}
}``````
and now it works just fine.

Last edited:

#### kiannameiou

##### Sergeant
is there any way to turn off landless nomads? aside from turning off the dlc, because some council mechanics are in it.

kinda anoyed being bugged by those idiots after taking all their land.

#### Rockphed

##### Uncultured Barbarian
I want to fire events when people are no longer involved in wars. I see the 4 ways a war can end and that the attacker is FROM and defender is ROOT. How would I go about scoping to anyone who was called in (or otherwise joined) the war that just ended?

Also, does the "war" condition return true or false if your liege is involved in a war?

#### liyanjifeng

##### Private
How does the game rank the titles belonging to the same tier? For example, an ai character has many count titles, it usually chooses the first one as the primary title.

#### Silversweeeper

##### Ichi no Hito
How does the game rank the titles belonging to the same tier? For example, an ai character has many count titles, it usually chooses the first one as the primary title.

As far as I can remember the AI first goes with culture (e.g. a Swedish character will pick Sweden over Denmark 100 % of the time since Sweden has "culture = swedish", but an English character wouldn't consider either better than the other based on culture), then dignity (number of counties in the de jure plus the scripted dignity rating (used in a few places where it is relevant historically, e.g. Lotharingia > Burgundy), after which I don't know if it has any priorities (I suspect the game as a whole goes off of either the order in which it reads the titles (based on file structures and with dynamic ones presumably being appended at the end in creation order) or alphabetically).

#### liyanjifeng

##### Private
As far as I can remember the AI first goes with culture (e.g. a Swedish character will pick Sweden over Denmark 100 % of the time since Sweden has "culture = swedish", but an English character wouldn't consider either better than the other based on culture), then dignity (number of counties in the de jure plus the scripted dignity rating (used in a few places where it is relevant historically, e.g. Lotharingia > Burgundy), after which I don't know if it has any priorities (I suspect the game as a whole goes off of either the order in which it reads the titles (based on file structures and with dynamic ones presumably being appended at the end in creation order) or alphabetically).
Thank you, silverweeper.

#### kiannameiou

##### Sergeant
it also probly calculates the county holdings development, I gave away a fully developed county castle to a duke and he moved capital there.

#### Silversweeeper

##### Ichi no Hito
it also probly calculates the county holdings development, I gave away a fully developed county castle to a duke and he moved capital there.

Was it the de jure capital of his primary title or the only county in his primary de jure? The AI definitely prefers using the scripted de jure capital if there's not a good reason not to (e.g. holding type mismatch), and I believe it usually prefers being inside the de jure to not being inside the de jure.

#### kiannameiou

##### Sergeant
Was it the de jure capital of his primary title or the only county in his primary de jure? The AI definitely prefers using the scripted de jure capital if there's not a good reason not to (e.g. holding type mismatch), and I believe it usually prefers being inside the de jure to not being inside the de jure.
must be de jure, his liege died, and he had eligible heirs, the other count didnt. and i had one of the de jure county to give. So i gave the duchy and everything under it.

#### jursamaj

##### General
Thank you for being helpful. I appreciate that.

To clarify: The converter is an application that converts a save game from a game to another. It generates the mod so as it converts a mod for the CKII it is out and no more used during the game. It sort of translates the I:R into a mod that the player can enjoy on CKII. But while generating the CKII it can modify certain files such as regions holdings and to a certain level characters and what they own at the moment according to what is in the I:R mode. I assume This means that It is implemented in the game not as a separate program as it is no more in use once the conversion is done.

Actually I have come to understand that It would not be possible to fully control the tech advancement If the modifiers don't work for events or the events can't be modified. unless the tech is disabled or ideally capped for certain years. Or the events are controlled. Well perfection seems further but advancement can be achieved if the modification to the passive research can be gained. Do you know how I can add a modifier to the research so I test the outcome? I mean is it in one of the text files or it is inside the codes of the game?
Well the monthly base rate is set in common/defines.lua under NTechnology: "POINTS_PER_ATTRIBUTE = 0.04". Some buildings, wonders and event modifiers also add .01 to 1.0 each to that total. These all have "<type>_techpoints = X" lines. All of these use values that are multiples of .01, but I imagine they can use more decimal places if needed.

Dozens of events give lump sums of -50 to 400, as do some council jobs. They use the same "<type>_techpoints" language as above.

Battles give military tech points. It's not clear how it's calculated, but that doesn't matter if you just want to reduce it overall. You can modify all battle awards in common/defines.lua under NMilitary: "BATTLE_TECH_MULTIPLIER = 0.5". Cutting that to .25 will give half as much from any given battle, and so on.

So, to effectively adjust the technology rate, you'd need to adjust everywhere that "*_techpoints = X" appears, multiplying X by the fraction you want, plus modify the POINTS_PER_ATTRIBUTE & BATTLE_TECH_MULTIPLIER the same way. The last 2 are easy. The other would be a major undertaking. And if the player adds any mods, that could wreck it all.

#### kiannameiou

##### Sergeant
Is there a way to scope only your own commanders? I'm trying to create a remove all your commanders effect. For some reason, the commanders at game start, who own land cant be assigned to armies.

#### Silversweeeper

##### Ichi no Hito
Is there a way to scope only your own commanders? I'm trying to create a remove all your commanders effect. For some reason, the commanders at game start, who own land cant be assigned to armies.

Code:
``````remove_all_commanders_effect = {
any_courtier_or_vassal = {
limit = {
has_minor_title = title_commander
}
remove_title = title_commander
}
}``````

#### Rockphed

##### Uncultured Barbarian
I am trying to fire an event whenever somebody is no longer involved in a war. I have the event working for the 4 ways wars can end, but people can also be removed from a war during inheritance. Is there a better way to fire my event than using on_death and an event with is_ruler = yes as a pre-trigger that calls my event on their heirs after 1 day? I suppose I need to fire the event for everyone who inherits any titles; is that just "any_demense_title = {current_heir = {character_event = {id = <event id> days = 1}}}"?

Also, am I missing any ways people can stop being involved in wars? Is there a way to leave a crusade after it starts beyond inheriting as someone who either hadn't joined or is the wrong religion?

#### kiannameiou

##### Sergeant
Code:
``````remove_all_commanders_effect = {
any_courtier_or_vassal = {
limit = {
has_minor_title = title_commander
}
remove_title = title_commander
}
}``````
works, thank you.

#### Aerotinge

##### Gouverneur van Torkia
How can I scope to a title that controls religion of a character, in the absence of the religion head?
e.g I want to scope d_iconoclast when being an iconoclast but the "create iconoclast patriarchy" decision is yet taken.
religion_head is a character scope and not working if absence.

#### Silversweeeper

##### Ichi no Hito
How can I scope to a title that controls religion of a character, in the absence of the religion head?
e.g I want to scope d_iconoclast when being an iconoclast but the "create iconoclast patriarchy" decision is yet taken.
religion_head is a character scope and not working if absence.

You can explicitly scope to the title, and since you know which title it's going to be for which religion (and can check if HF-reformed pagans reformed with a rel head or not) you can create a scripted_effect containing if/else_ifs that simplifies the script in any file where you need to do the scoping.

Code:
``````find_rel_head_title_scope_effect = {
if = {
limit = {
religion = catholic
}
k_papal_state = {
}
}
<Etc.>
}``````

#### Aerotinge

##### Gouverneur van Torkia
You can explicitly scope to the title, and since you know which title it's going to be for which religion (and can check if HF-reformed pagans reformed with a rel head or not) you can create a scripted_effect containing if/else_ifs that simplifies the script in any file where you need to do the scoping.

Code:
``````find_rel_head_title_scope_effect = {
if = {
limit = {
religion = catholic
}
k_papal_state = {
}
}
<Etc.>
}``````
Thanks, so I end up have to enumerate these titles first. :/

Update:
Code:
``````any_title = {
limit = {
controls_religion = yes
has_holder = no
# more conditions...
}
}``````
works for me, but it's CPU heavy and bad for trigger block like law and governent.

Last edited: