• 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.
The only thing I can think of is that the event in question, daemstarter.53, is not called from anywhere. That usually leaves the Validator unable to resolve scopes, even though character events always have a character as ROOT.
Well, i've tried this event chain in the game, and it's working just fine.
So thank you again. To be honest, i'm so stupid and did not even notice that the event was not called from anywhere ( option 1 from daemstarter51 was supposed to do this)
When i had fixed this, the entire event chain started to work as expected.
Validator still call this an issue, but if it works, i'm happy.
You are my savior, Whizzer.
 
For what it's worth, 'mult_modifier' was added to the game in the 2016-01-13 update v2.5.0. In the change log for that update, they recommend using it as a synonym for the old 'modifier' keyword. But, unsurprisingly for PDX, in 5.5 years they haven't taken their own advice, as that mention in the change log is the *only* appearance of 'mult_modifier' in the script files.

Development of Validator is largely driven by the Validator throwing spurious errors, and those errors getting fixed. Since PDX aren't using 'mult_modifier', it may never have gotten reported as a false error.
 
For what it's worth, 'mult_modifier' was added to the game in the 2016-01-13 update v2.5.0. In the change log for that update, they recommend using it as a synonym for the old 'modifier' keyword. But, unsurprisingly for PDX, in 5.5 years they haven't taken their own advice, as that mention in the change log is the *only* appearance of 'mult_modifier' in the script files.

Development of Validator is largely driven by the Validator throwing spurious errors, and those errors getting fixed. Since PDX aren't using 'mult_modifier', it may never have gotten reported as a false error.
I don't get those errors on my end and I exclusively use the recommended alias in everything I do, including CleanSlate. The Validator knows about it, I can assure you.
 
Greetings, friends.
Another question from me - how can i make two characters to duel each other using duel engine from holy fury?
I tried to read through code of the duel event, but still did not quite understand it. Any tips?
 
Greetings, friends.
Another question from me - how can i make two characters to duel each other using duel engine from holy fury?
I tried to read through code of the duel event, but still did not quite understand it. Any tips?

The least you'll have to do is save the attacker as combatant_1, the defender as combatant_2, then fire event HFP.10095 for the defender. There's plenty more you can do to customize the duel. For details, see various events files (mostly HF and HFP), and of course the scripted effects for duels.
 
  • 1Like
Reactions:
The least you'll have to do is save the attacker as combatant_1, the defender as combatant_2, then fire event HFP.10095 for the defender. There's plenty more you can do to customize the duel. For details, see various events files (mostly HF and HFP), and of course the scripted effects for duels.
Thank you for quick response, Whizzer!
I read through hfp_duel_event file carefully, but i still don't understand how the math in the event works.
For example, there is a HFP.10102 event ( Double death - Defender). This event is triggered_only, but this id appears only once in the file. As i do not see any other "duel" event on other event files, it's very confusing. :oops: Very unlikely that there is an event that is triggered_only but triggered by nothing.

upd: as i see, all the combat evaluation stored in scripted effects. It explains almost everything i asked here, that is why you pointed out the importance of scripted effects. Thank you very much again Whizzer
 
Last edited:
Thank you for quick response, Whizzer!
I read through hfp_duel_event file carefully, but i still don't understand how the math in the event works.
For example, there is a HFP.10102 event ( Double death - Defender). This event is triggered_only, but this id appears only once in the file. As i do not see any other "duel" event on other event files, it's very confusing. :oops: Very unlikely that there is an event that is triggered_only but triggered by nothing.

upd: as i see, all the combat evaluation stored in scripted effects. It explains almost everything i asked here, that is why you pointed out the importance of scripted effects. Thank you very much again Whizzer
Yep, HFP.10102 is triggered from the send_duel_result_event_effect script in 01_scripted_effects_duels.txt.

One of the best things you can use for this sort of work is a text editor that will search for text in the entire set of CK2 script files. I use TextWrangler/BBEdit 'Multi-file Search…' on Mac, and Notepad++ 'Find in Files…' on Windows. Either can search thru all the files in seconds. Also, both handle 'regular expression' searching, which is an amazing 'wildcard' search ability (and a lot more than that…).
 
  • 1Like
Reactions:
So, a couple questions:

First, is there any way to force the game to recalculate a patrician's trade post limit during an event? I have a building I want to use to temporarily boost a patrician's trade post limit, but when I add it to a patrician's family palace (which in and of itself was a pain) it takes about 1 day for the new trade post limit to take effect. And since I intend to build and destroy it in the same event, waiting two days for this seems annoying.

Second, it seems that "add_to_special_holding" does not add the prerequisite buildings. Is this a bug, or intended behavior?
 
Code:
kuru_ec_upgrade_trade_post = {
        ai = no
        filter = sub_realm_owned
        ai_target_filter = sub_realm_owned

        from_potential = {
            has_character_flag = immortal_check
        }
        potential = {
            #is_capital = yes
            location = {
                has_trade_post = yes
                
            }
        }
        allow = {
            always = yes
        }
        
        effect = {
            
                
                    if = {
                        limit = {
                            trade_post_owner = {
                                is_patrician = yes
                            }
                            port = yes
                        }
                        add_to_extra_holding = { type = trade_post building = tr_port_1 }
                        add_to_extra_holding = { type = trade_post building = tr_port_2 }
                        add_to_extra_holding = { type = trade_post building = tr_port_3 }
                        add_to_extra_holding = { type = trade_post building = tr_enclave_1 }
                        add_to_extra_holding = { type = trade_post building = tr_enclave_2 }
                        add_to_extra_holding = { type = trade_post building = tr_enclave_3 }
                        add_to_extra_holding = { type = trade_post building = tr_garrison_1 }
                        add_to_extra_holding = { type = trade_post building = tr_garrison_2 }
                        add_to_extra_holding = { type = trade_post building = tr_garrison_3 }
                    }

                    if = {
                        limit = {
                            trade_route = silk_road
                        }
                        add_to_extra_holding = { type = trade_post building = tr_silk_road_1 }
                        add_to_extra_holding = { type = trade_post building = tr_silk_road_2 }
                        add_to_extra_holding = { type = trade_post building = tr_silk_road_3 }
                        add_to_extra_holding = { type = trade_post building = trade_offices_1 }
                        add_to_extra_holding = { type = trade_post building = trade_offices_2 }
                        add_to_extra_holding = { type = trade_post building = trade_offices_3 }
                        add_to_extra_holding = { type = trade_post building = mercenary_garrison_1 }
                        add_to_extra_holding = { type = trade_post building = mercenary_garrison_2 }
                        add_to_extra_holding = { type = trade_post building = mercenary_garrison_3 }

                        if = {
                            limit = {
                                trade_post_owner = {
                                    OR = {
                                        culture_group = israelite
                                        religion_group = jewish_group
                                        culture = khazar
                                    }
                                }
                            }
                            add_to_extra_holding = { type = trade_post building = radhanite_quarter_1 }
                            add_to_extra_holding = { type = trade_post building = radhanite_quarter_2 }
                            add_to_extra_holding = { type = trade_post building = radhanite_quarter_3 }
                        }
                    }

                    if = {
                        limit = {
                            trade_route = trans_saharan_trade_route
                            trans_saharan_trade_post_market_trigger = yes
                        }
                        add_to_extra_holding = { type = trade_post_building = tr_sahara_1 }
                        add_to_extra_holding = { type = trade_post_building = tr_sahara_2 }
                        add_to_extra_holding = { type = trade_post_building = tr_sahara_3 }
                    }

                    if = {
                        limit = {
                            trade_route = trans_saharan_trade_route
                            trans_saharan_trade_post_gold_mine_trigger = yes
                        }
                        add_to_extra_holding = { type = trade_post_building = tr_gold_mine_1 }
                        add_to_extra_holding = { type = trade_post_building = tr_gold_mine_2 }
                        add_to_extra_holding = { type = trade_post_building = tr_gold_mine_3 }
                    }

                    if = {
                        limit = {
                            trade_route = trans_saharan_trade_route
                            OR = {
                                province_id = 912
                                province_id = 916
                            }
                        }
                        add_to_extra_holding = { type = trade_post_building = tr_salt_mine_1 }
                    }

                    if = {
                        limit = {
                            trade_route = trans_saharan_trade_route
                            province_id = 911
                        }
                        add_to_extra_holding = { type = trade_post_building = tr_cloth_production_1 }
                    }

                    

                    
                
            
        }
        
        ai_will_do = {
            factor = 0
        }
    }

Can anyone help to see why this block of code is not working? Its adapted from another mod to fill upgrade trade posts. It goes under trade_post_decisions block, or is this wrong too?
 
Code:
kuru_ec_upgrade_trade_post = {
        ai = no
        filter = sub_realm_owned
        ai_target_filter = sub_realm_owned

        from_potential = {
            has_character_flag = immortal_check
        }
        potential = {
            #is_capital = yes
            location = {
                has_trade_post = yes
               
            }
        }
        allow = {
            always = yes
        }
       
        effect = {
           
               
                    if = {
                        limit = {
                            trade_post_owner = {
                                is_patrician = yes
                            }
                            port = yes
                        }
                        add_to_extra_holding = { type = trade_post building = tr_port_1 }
                        add_to_extra_holding = { type = trade_post building = tr_port_2 }
                        add_to_extra_holding = { type = trade_post building = tr_port_3 }
                        add_to_extra_holding = { type = trade_post building = tr_enclave_1 }
                        add_to_extra_holding = { type = trade_post building = tr_enclave_2 }
                        add_to_extra_holding = { type = trade_post building = tr_enclave_3 }
                        add_to_extra_holding = { type = trade_post building = tr_garrison_1 }
                        add_to_extra_holding = { type = trade_post building = tr_garrison_2 }
                        add_to_extra_holding = { type = trade_post building = tr_garrison_3 }
                    }

                    if = {
                        limit = {
                            trade_route = silk_road
                        }
                        add_to_extra_holding = { type = trade_post building = tr_silk_road_1 }
                        add_to_extra_holding = { type = trade_post building = tr_silk_road_2 }
                        add_to_extra_holding = { type = trade_post building = tr_silk_road_3 }
                        add_to_extra_holding = { type = trade_post building = trade_offices_1 }
                        add_to_extra_holding = { type = trade_post building = trade_offices_2 }
                        add_to_extra_holding = { type = trade_post building = trade_offices_3 }
                        add_to_extra_holding = { type = trade_post building = mercenary_garrison_1 }
                        add_to_extra_holding = { type = trade_post building = mercenary_garrison_2 }
                        add_to_extra_holding = { type = trade_post building = mercenary_garrison_3 }

                        if = {
                            limit = {
                                trade_post_owner = {
                                    OR = {
                                        culture_group = israelite
                                        religion_group = jewish_group
                                        culture = khazar
                                    }
                                }
                            }
                            add_to_extra_holding = { type = trade_post building = radhanite_quarter_1 }
                            add_to_extra_holding = { type = trade_post building = radhanite_quarter_2 }
                            add_to_extra_holding = { type = trade_post building = radhanite_quarter_3 }
                        }
                    }

                    if = {
                        limit = {
                            trade_route = trans_saharan_trade_route
                            trans_saharan_trade_post_market_trigger = yes
                        }
                        add_to_extra_holding = { type = trade_post_building = tr_sahara_1 }
                        add_to_extra_holding = { type = trade_post_building = tr_sahara_2 }
                        add_to_extra_holding = { type = trade_post_building = tr_sahara_3 }
                    }

                    if = {
                        limit = {
                            trade_route = trans_saharan_trade_route
                            trans_saharan_trade_post_gold_mine_trigger = yes
                        }
                        add_to_extra_holding = { type = trade_post_building = tr_gold_mine_1 }
                        add_to_extra_holding = { type = trade_post_building = tr_gold_mine_2 }
                        add_to_extra_holding = { type = trade_post_building = tr_gold_mine_3 }
                    }

                    if = {
                        limit = {
                            trade_route = trans_saharan_trade_route
                            OR = {
                                province_id = 912
                                province_id = 916
                            }
                        }
                        add_to_extra_holding = { type = trade_post_building = tr_salt_mine_1 }
                    }

                    if = {
                        limit = {
                            trade_route = trans_saharan_trade_route
                            province_id = 911
                        }
                        add_to_extra_holding = { type = trade_post_building = tr_cloth_production_1 }
                    }

                   

                   
               
           
        }
       
        ai_will_do = {
            factor = 0
        }
    }

Can anyone help to see why this block of code is not working? Its adapted from another mod to fill upgrade trade posts. It goes under trade_post_decisions block, or is this wrong too?
I don't know if this matters, but in some places you have "type = trade_post_building = [building]" instead of "type = trade_post building = [building]". I am also not sure if having it all in one line will actually work (when I use that command I have it over 4 lines, but 2 lines would accomplish the same logical structure).
 
  • 1
Reactions:
.. in some places you have "type = trade_post_building = [building]" instead of "type = trade_post building = [building]"...

Where is the difference that i don't see ?
 
Where is the difference that i don't see ?
There is a '_' between "trade_post" and "building" in the wrong one; in the right one it is a space. I know that it will mess up that effect, but I don't know if it will mess up the whole decision. If it still doesn't work, make sure you are operating in the appropriate province scope.
 
  • 1
Reactions:
There is a '_' between "trade_post" and "building" in the wrong one; in the right one it is a space.
Oh..
Sorry, i wasn't the original poster you were repsonding to, but i was wondering about what i thought someone else
might wonder about as well....., but now i see the difference. Thanks and cheers.
 
type = trade_post_building = tr_gold_mine_1 - wrong syntax

type = trade_post building = tr_gold_mine_1 - correct syntax

I too didnt notice until now, doooh. Thanks.

Now i understand why Kurushimis cheat doesn't work on gold mines and sahara trade posts in Africa.
The other trade posts do work for me with the mod by the way.
Goooood to know.
 
Yep, HFP.10102 is triggered from the send_duel_result_event_effect script in 01_scripted_effects_duels.txt.

One of the best things you can use for this sort of work is a text editor that will search for text in the entire set of CK2 script files. I use TextWrangler/BBEdit 'Multi-file Search…' on Mac, and Notepad++ 'Find in Files…' on Windows. Either can search thru all the files in seconds. Also, both handle 'regular expression' searching, which is an amazing 'wildcard' search ability (and a lot more than that…).
Thank you very much.
I use Notepad++ in my scripting ofc, but i use 10% of its potential at best. And before your message, i used file explorer to find parts of the code :rolleyes:
 
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.
 
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!
 
  • 1Like
Reactions:
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?
 
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 = {
                any_trade_post = {
                    trade_post_is_building = yes
                }
        }
    }
    fail_trigger_effect = {
        if = {
            limit = {
                any_trade_post = {
                    trade_post_is_building = yes
                }
            }
            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
            }
       
        any_trade_post = {#destroy all the trade posts
       
            province_event = {id = repair_TP.3}
        }
        any_province = {#recreate and give to another patrician
            limit = {
                has_flag = repair_trade_post_being_cleaned
            }
            province_event = {id = repair_TP.5}
        }
       
    }
    after = {
        event_target:target_usurper = {
            any_trade_post = {
                limit = {
                    has_flag = repair_trade_post_being_cleaned
                }
                seize_trade_post = ROOT
                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 = {
       
        trade_post_owner = {
            save_event_target_as = target_patrician
            wealth = 100
            #create_tradepost  = ROOT
        }
        if {
            limit = {trade_post_has_building = tr_port_3}
            set_flag = repair_tr_port_3
        }
        if = {
            limit = {trade_post_has_building = tr_port_2}
            set_flag = repair_tr_port_2
        }
        if = {
            limit = {trade_post_has_building = tr_port_1}
            set_flag = repair_tr_port_1
        }
        if {
            limit = {trade_post_has_building = tr_enclave_3}
            set_flag = repair_tr_enclave_3
        }
        if = {
            limit = {trade_post_has_building = tr_enclave_2}
            set_flag = repair_tr_enclave_2
        }
        if = {
            limit = {trade_post_has_building = tr_enclave_1}
            set_flag = repair_tr_enclave_1
        }
        if {
            limit = {trade_post_has_building = tr_garrison_3}
            set_flag = repair_tr_garrison_3
        }
        if = {
            limit = {trade_post_has_building = tr_garrison_2}
            set_flag = repair_tr_garrison_2
        }
        if = {
            limit = {trade_post_has_building = tr_garrison_1}
            set_flag = repair_tr_garrison_1
        }
       
        if {
            limit = {trade_post_has_building = tr_silk_road_3}
            set_flag = repair_tr_silk_road_3
        }
        if = {
            limit = {trade_post_has_building = tr_silk_road_2}
            set_flag = repair_tr_silk_road_2
        }
        if = {
            limit = {trade_post_has_building = tr_silk_road_1}
            set_flag = repair_tr_silk_road_1
        }
        if {
            limit = {trade_post_has_building = trade_offices_3}
            set_flag = repair_trade_offices_3
        }
        if = {
            limit = {trade_post_has_building = trade_offices_2}
            set_flag = repair_trade_offices_2
        }
        if = {
            limit = {trade_post_has_building = trade_offices_1}
            set_flag = repair_trade_offices_1
        }
        if {
            limit = {trade_post_has_building = mercenary_garrison_3}
            set_flag = repair_mercenary_garrison_3
        }
        if = {
            limit = {trade_post_has_building = mercenary_garrison_2}
            set_flag = repair_mercenary_garrison_2
        }
        if = {
            limit = {trade_post_has_building = mercenary_garrison_1}
            set_flag = repair_mercenary_garrison_1
        }
        if {
            limit = {trade_post_has_building = radhanite_quarter_3}
            set_flag = repair_radhanite_quarter_3
        }
        if = {
            limit = {trade_post_has_building = radhanite_quarter_2}
            set_flag = repair_radhanite_quarter_2
        }
        if = {
            limit = {trade_post_has_building = radhanite_quarter_1}
            set_flag = repair_radhanite_quarter_1
        }
        if {
            limit = {trade_post_has_building = tr_sahara_3}
            set_flag = repair_tr_sahara_3
        }
        if = {
            limit = {trade_post_has_building = tr_sahara_2}
            set_flag = repair_tr_sahara_2
        }
        if = {
            limit = {trade_post_has_building = tr_sahara_1}
            set_flag = repair_tr_sahara_1
        }
        if {
            limit = {trade_post_has_building = tr_gold_mine_3}
            set_flag = repair_tr_gold_mine_3
        }
        if = {
            limit = {trade_post_has_building = tr_gold_mine_2}
            set_flag = repair_tr_gold_mine_2
        }
        if = {
            limit = {trade_post_has_building = tr_gold_mine_1}
            set_flag = repair_tr_gold_mine_1
        }
        if {
            limit = {trade_post_has_building = tr_salt_mine_1}
            set_flag = repair_tr_salt_mine_1
        }
        if {
            limit = {trade_post_has_building = tr_cloth_production_1}
            set_flag = repair_cloth_production_1
        }
        trade_post_owner = {
           
            wealth = 100
        }
        destroy_tradepost = THIS
        set_flag = repair_trade_post_being_cleaned
   
   
    }
}   

character_event = {
    id = repair_TP.4
    is_triggered_only = yes
    is_ruler = yes
    hide_window = yes
   
    trigger = {
        is_patrician = yes
        war = no
        NOT = {
                any_trade_post = {
                    trade_post_is_building = yes
                }
        }
    }
    fail_trigger_effect = {
        if = {
            limit = {
                any_trade_post = {
                    trade_post_is_building = yes
                }
            }
            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
            }
       
        any_trade_post = {#destroy all the trade posts
       
            province_event = {id = repair_TP.3}
        }
        any_province = {#recreate and give to another patrician
            limit = {
                has_flag = repair_trade_post_being_cleaned
            }
            province_event = {id = repair_TP.5}
        }
       
    }
    after = {
        event_target:target_usurper = {
            any_trade_post = {
                limit = {
                    has_flag = repair_trade_post_being_cleaned
                }
                seize_trade_post = ROOT
                clear_flags_with_prefix = repair_
            }
        }
       
    }
}
province_event = {
    id = repair_TP.5
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        FROM = {
           
            create_tradepost  = ROOT
        }
        if {
            limit = {has_flag = repair_tr_port_3}
            add_to_extra_holding = {
                type = trade_post
                building = tr_port_3
            }
        }
        if = {
            limit = {has_flag = repair_tr_port_2}
            add_to_extra_holding = {
                type = trade_post
                building = tr_port_2
            }
        }
        if = {
            limit = {has_flag = repair_tr_port_1}
            add_to_extra_holding = {
                type = trade_post
                building = tr_port_1
            }
        }
        if {
            limit = {has_flag = repair_tr_enclave_3}
            add_to_extra_holding = {
                type = trade_post
                building = tr_enclave_3
            }
        }
        if = {
            limit = {has_flag = repair_tr_enclave_2}
            add_to_extra_holding = {
                type = trade_post
                building = tr_enclave_2
            }
        }
        if = {
            limit = {has_flag = repair_tr_enclave_1}
            add_to_extra_holding = {
                type = trade_post
                building = tr_enclave_1
            }
        }
        if {
            limit = {has_flag = repair_tr_garrison_3}
            add_to_extra_holding = {
                type = trade_post
                building = tr_garrison_3
            }
        }
        if = {
            limit = {has_flag = repair_tr_garrison_2}
            add_to_extra_holding = {
                type = trade_post
                building = tr_garrison_2
            }
        }
        if = {
            limit = {has_flag = repair_tr_garrison_1}
            add_to_extra_holding = {
                type = trade_post
                building = tr_garrison_1
            }
        }
        if {
            limit = {has_flag = repair_tr_silk_road_3}
            add_to_extra_holding = {
                type = trade_post
                building = tr_silk_road_3
            }
        }
        if = {
            limit = {has_flag = repair_tr_silk_road_2}
            add_to_extra_holding = {
                type = trade_post
                building = tr_silk_road_2
            }
        }
        if = {
            limit = {has_flag = repair_tr_silk_road_1}
            add_to_extra_holding = {
                type = trade_post
                building = tr_silk_road_1
            }
        }
        if {
            limit = {has_flag = repair_trade_offices_3}
            add_to_extra_holding = {
                type = trade_post
                building = trade_offices_3
            }
        }
        if = {
            limit = {has_flag = repair_trade_offices_2}
            add_to_extra_holding = {
                type = trade_post
                building = trade_offices_2
            }
        }
        if = {
            limit = {has_flag = repair_trade_offices_1}
            add_to_extra_holding = {
                type = trade_post
                building = trade_offices_1
            }
        }
        if {
            limit = {has_flag = repair_mercenary_garrison_3}
            add_to_extra_holding = {
                type = trade_post
                building = mercenary_garrison_3
            }
        }
        if = {
            limit = {has_flag = repair_mercenary_garrison_2}
            add_to_extra_holding = {
                type = trade_post
                building = mercenary_garrison_2
            }
        }
        if = {
            limit = {has_flag = repair_mercenary_garrison_1}
            add_to_extra_holding = {
                type = trade_post
                building = mercenary_garrison_1
            }
        }
        if {
            limit = {has_flag = repair_radhanite_quarter_3}
            add_to_extra_holding = {
                type = trade_post
                building = radhanite_quarter_3
            }
        }
        if = {
            limit = {has_flag = repair_radhanite_quarter_2}
            add_to_extra_holding = {
                type = trade_post
                building = radhanite_quarter_2
            }
        }
        if = {
            limit = {has_flag = repair_radhanite_quarter_1}
            add_to_extra_holding = {
                type = trade_post
                building = radhanite_quarter_1
            }
        }
        if {
            limit = {has_flag = repair_tr_sahara_3}
            add_to_extra_holding = {
                type = trade_post
                building = tr_sahara_3
            }
        }
        if = {
            limit = {has_flag = repair_tr_sahara_2}
            add_to_extra_holding = {
                type = trade_post
                building = tr_sahara_2
            }
        }
        if = {
            limit = {has_flag = repair_tr_sahara_1}
            add_to_extra_holding = {
                type = trade_post
                building = tr_sahara_1
            }
        }
        if {
            limit = {has_flag = repair_tr_gold_mine_3}
            add_to_extra_holding = {
                type = trade_post
                building = tr_gold_mine_3
            }
        }
        if = {
            limit = {has_flag = repair_tr_gold_mine_2}
            add_to_extra_holding = {
                type = trade_post
                building = tr_gold_mine_2
            }
        }
        if = {
            limit = {has_flag = repair_tr_gold_mine_1}
            add_to_extra_holding = {
                type = trade_post
                building = tr_gold_mine_1
            }
        }
        if {
            limit = {has_flag = repair_tr_salt_mine_3}
            add_to_extra_holding = {
                type = trade_post
                building = tr_salt_mine_3
            }
        }
        if = {
            limit = {has_flag = repair_tr_salt_mine_2}
            add_to_extra_holding = {
                type = trade_post
                building = tr_salt_mine_2
            }
        }
        if = {
            limit = {has_flag = repair_tr_salt_mine_1}
            add_to_extra_holding = {
                type = trade_post
                building = tr_salt_mine_1
            }
        }
        if {
            limit = {has_flag = repair_tr_cloth_production_3}
            add_to_extra_holding = {
                type = trade_post
                building = tr_cloth_production_3
            }
        }
        if = {
            limit = {has_flag = repair_tr_cloth_production_2}
            add_to_extra_holding = {
                type = trade_post
                building = tr_cloth_production_2
            }
        }
        if = {
            limit = {has_flag = repair_tr_cloth_production_1}
            add_to_extra_holding = {
                type = trade_post
                building = tr_cloth_production_1
            }
        }
        seize_trade_post = event_target:target_usurper
    }
}

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: