Create a decision to make puppets on all occupied territories.

  • 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.

z-stp

Recruit
Apr 12, 2024
3
0
Hello! I'm trying to make a decision code.
When the decision is activated, the ROOT country should create puppet states on all occupied territories that are cores of those states.

I've had several attempts to create a working code. Here's what I've got:

Code №1:
Code:
TEST1 = {
    icon = generic_form_nation
    allowed = {
        always = yes
    }
    available = {
        always = yes
    }
    cost = 0
    ai_will_do = {
        factor = 10
    }
    fire_only_once = no
    complete_effect = {
        every_occupied_country = {
            PREV = {
                release_on_controlled = PREV
            }
        }  
    }
}

When this code is activated, it simply returns the occupied territories to the countries that exist and have cores on them. No puppet is created.

Code №2:
Code:
TEST2 = {
    icon = generic_form_nation
    allowed = {
        always = yes
    }
    available = {
        always = yes
        any_state = {
            is_controlled_by = ROOT
        }
    }
    cost = 0
    ai_will_do = {
        factor = 0
    }
    fire_only_once = no
    complete_effect = {
        create_dynamic_country = {
            original_tag = PREV
            save_event_target_as = test11
            every_state = {
                limit = {
                    is_controlled_by = ROOT
                }
                event_target:test11 = {
                    transfer_state = PREV
                }
            }
        }
    }
}

When this is activated, a state with the same name and flag as mine is created on my states. It looks as if I entered "civilwar" in the console, a civil war started, and the rebel state won. The new state has cores on all my territory, but the old state's cores remain.

Code №3:
Code:
TEST3 = {
    icon = generic_form_nation
    allowed = {
        always = yes
    }
    available = {
        always = yes
    }
    cost = 0
    ai_will_do = {
        factor = 0
    }
    fire_only_once = no
    complete_effect = {
        create_dynamic_country = {
            original_tag = PREV
            save_event_target_as = test11
            every_state = {
                limit = {
                    is_controlled_by = ROOT
                    NOT = { is_core_of = ROOT }
                }
                if = {  // If condition is met
                    limit = { NOT = { any_core_country = { is_tag = ROOT } } }
                    event_target:test11 = {
                        transfer_state = PREV
                    }
                }
            }
        }
    }
}
When activated, it creates a country on the occupied territories with my name and flag. Again, it looks like I entered "civilwar" in the console, but the new state appears only on the occupied territories.

Code №4:
Code:
TEST4 = {
    icon = generic_form_nation
    allowed = {
        always = yes
    }
    available = {
        always = yes
    }
    cost = 0
    ai_will_do = {
        factor = 0
    }
    fire_only_once = no
    complete_effect = {
        IF = {
            every_occupied_country = {
                save_event_target_as = my_country
            }
            original_tag = PREV
        }
        every_state = { 
            limit = {
                is_controlled_by = ROOT
                NOT = { is_core_of = ROOT }
                set_temp_variable = { target_country = THIS }
            }
            create_dynamic_country = {
                original_tag = event_target:my_country
                ideology = ROOT
                transfer_state = yes
            }
        }
    }
}

Here cores for a puppet state are created on the occupied territories, but the country itself is not created.
--------------------------

None of the codes provided have allowed me to implement my idea successfully. Either the game does not understand to whom the states should be transferred, or it transfers them back to me.

I would like to achieve the effect like when using the "Occupied territories" tab, where you release states, but to create states immediately on all occupied territories. If a state already exists on the map, then another state is created (as if a peace conference took place, and two states created a puppet out of the same country).

I planned for democratic states controlled by AI to immediately liberate territories after defeating an enemy, if AI annexes enemy territories as a result of the conference.

Please help me make a working decision code.
 
Hello! I'm trying to make a decision code.
When the decision is activated, the ROOT country should create puppet states on all occupied territories that are cores of those states.

I've had several attempts to create a working code. Here's what I've got:

Code №1:
Code:
TEST1 = {
    icon = generic_form_nation
    allowed = {
        always = yes
    }
    available = {
        always = yes
    }
    cost = 0
    ai_will_do = {
        factor = 10
    }
    fire_only_once = no
    complete_effect = {
        every_occupied_country = {
            PREV = {
                release_on_controlled = PREV
            }
        }
    }
}

When this code is activated, it simply returns the occupied territories to the countries that exist and have cores on them. No puppet is created.

Code №2:
Code:
TEST2 = {
    icon = generic_form_nation
    allowed = {
        always = yes
    }
    available = {
        always = yes
        any_state = {
            is_controlled_by = ROOT
        }
    }
    cost = 0
    ai_will_do = {
        factor = 0
    }
    fire_only_once = no
    complete_effect = {
        create_dynamic_country = {
            original_tag = PREV
            save_event_target_as = test11
            every_state = {
                limit = {
                    is_controlled_by = ROOT
                }
                event_target:test11 = {
                    transfer_state = PREV
                }
            }
        }
    }
}

When this is activated, a state with the same name and flag as mine is created on my states. It looks as if I entered "civilwar" in the console, a civil war started, and the rebel state won. The new state has cores on all my territory, but the old state's cores remain.

Code №3:
Code:
TEST3 = {
    icon = generic_form_nation
    allowed = {
        always = yes
    }
    available = {
        always = yes
    }
    cost = 0
    ai_will_do = {
        factor = 0
    }
    fire_only_once = no
    complete_effect = {
        create_dynamic_country = {
            original_tag = PREV
            save_event_target_as = test11
            every_state = {
                limit = {
                    is_controlled_by = ROOT
                    NOT = { is_core_of = ROOT }
                }
                if = {  // If condition is met
                    limit = { NOT = { any_core_country = { is_tag = ROOT } } }
                    event_target:test11 = {
                        transfer_state = PREV
                    }
                }
            }
        }
    }
}
When activated, it creates a country on the occupied territories with my name and flag. Again, it looks like I entered "civilwar" in the console, but the new state appears only on the occupied territories.

Code №4:
Code:
TEST4 = {
    icon = generic_form_nation
    allowed = {
        always = yes
    }
    available = {
        always = yes
    }
    cost = 0
    ai_will_do = {
        factor = 0
    }
    fire_only_once = no
    complete_effect = {
        IF = {
            every_occupied_country = {
                save_event_target_as = my_country
            }
            original_tag = PREV
        }
        every_state = {
            limit = {
                is_controlled_by = ROOT
                NOT = { is_core_of = ROOT }
                set_temp_variable = { target_country = THIS }
            }
            create_dynamic_country = {
                original_tag = event_target:my_country
                ideology = ROOT
                transfer_state = yes
            }
        }
    }
}

Here cores for a puppet state are created on the occupied territories, but the country itself is not created.
--------------------------

None of the codes provided have allowed me to implement my idea successfully. Either the game does not understand to whom the states should be transferred, or it transfers them back to me.

I would like to achieve the effect like when using the "Occupied territories" tab, where you release states, but to create states immediately on all occupied territories. If a state already exists on the map, then another state is created (as if a peace conference took place, and two states created a puppet out of the same country).

I planned for democratic states controlled by AI to immediately liberate territories after defeating an enemy, if AI annexes enemy territories as a result of the conference.

Please help me make a working decision code.


Maybe try copying the code from the 'make collaboration government' decision:

Code:
    instantiate_collaboration = {
        icon = generic_prepare_civil_war

        cost = 0

        available = {
            has_core_occupation_modifier = {
                occupied_country_tag = FROM
                modifier = compliance_80
            }
        }
        visible = {
            has_rule = can_create_collaboration_government
            is_available_to_collaboration_government = yes
            has_core_occupation_modifier = {
                occupied_country_tag = FROM
                modifier = compliance_60
            }
        }

        complete_effect = {
            set_temp_variable = { country_to_initiate = FROM }
            instantiate_collaboration_government = yes
        }

        target_non_existing = yes
        target_array = occupied_countries
   }

Or you are over thinking it and your first one was correct and was just missing 'release_puppet' like

Code:
every_occupied_country = release_puppet_on_controlled = FROM/PREV

I haven't tried that, that's just my guess.
 
Hmm... interesting. I tried various ways to insert your code - when activating the solution, nothing happened.

However, after thinking about your proposed code, I came up with this:



Code:
TEST7 = {
    icon = generic_form_nation
    allowed = {
        always = yes
    }
    available = {
        always = yes
    }
    cost = 0
    ai_will_do = {
        factor = 0
    }
    fire_only_once = no
    complete_effect = {
        IF = {
            every_occupied_country = {
                save_event_target_as = my_country
            }
            original_tag = PREV
        }
        every_state = { 
            limit = {
                is_controlled_by = ROOT 
                NOT = { is_core_of = ROOT }
                set_temp_variable = { target_country = THIS }
            }
            create_dynamic_country = {
                        original_tag = event_target:my_country
                        
                        set_temp_variable = { new_country = this }
                        ROOT = {
                            every_controlled_state = {
                                limit = {
                                    is_core_of = event_target:my_country
                                    NOT = { is_core_of = ROOT }
                                }
                                var:new_country = { transfer_state = PREV }
                            }
                        }
                        
                        ROOT = {
                            puppet = var:new_country
                            set_autonomy = { target = PREV autonomy_state = autonomy_collaboration_government }

                    }

            }
        }
    }
}

This code achieves 50% of what I wanted to accomplish. If you control at least 1 occupied state, you can create a puppet government on its territory - even if a country with that tag already exists.

However, there are 2 problems. Firstly, when creating a puppet on these occupied states, it's as if 2 puppet governments are created: one active and one inactive.

For example, if I activate this code for Italy, one puppet government is created on the occupied islands of Greece, and the second puppet government receives cores on these islands:

1715272411762.png



The second problem is that the solution only works if the country whose territories I occupy exists on the map. For example, countries on Italian territories in Africa are not created because at the time of activating the code, these countries do not exist and do not control any states on the map.

dratheos, can you help me?
 
You are trying to use a single decision to affect multiple different dynamic countries at once. That example code you posted is only going to create one country, eg puppet greece.

You need to be using an array like "array = occupied_countries" and then something like "for_each_scope_loop"

This is the example the wiki gives

Code:
for_each_scope_loop = {
    array = global.majors
    if = {
        limit = {
            NOT = { tag = ROOT }
        }
        random_owned_controlled_state = {
            transfer_state_to = ROOT
        }
    }
}

I think, but don't know for sure, that you can target the decision dynamically by using "target_array = occupied_countries" and "target_non_existing = yes" so like:


Code:
TEST9 = {
    icon = generic_form_nation
    allowed = {
        always = yes
    }
    available = {
        always = yes
    }
    cost = 0
    ai_will_do = {
        factor = 0
    }
    target_array = occupied_countries
    target_non_existing = yes
    fire_only_once = no
    complete_effect = {
        some_stuff = yes
        }
}

That creates one decision for each occupied country, although I don't know how to use it beyond that.
 
Basically, I now have 3 working codes:

In the first code, puppets are created, but only when the country whose states you are occupying exists. If the country does not exist (is completely captured or was not originally on the map), then activating the decision does nothing.

Code:
The_first_one = {
    icon = generic_form_nation
    allowed = {
        always = yes
    }
    available = {
        always = yes
    }
    cost = 0
    ai_will_do = {
        factor = 0
    }
    fire_only_once = no
    complete_effect = {
        IF = {
            every_occupied_country = {
                save_event_target_as = my_country
            }
            original_tag = PREV
        }
        every_state = {  // Loop through all states
            limit = {
                is_controlled_by = ROOT 
                NOT = { is_core_of = ROOT }
                set_temp_variable = { target_country = THIS }
            }
            create_dynamic_country = {
                        original_tag = event_target:my_country
                        
                        set_temp_variable = { new_country = this }
                        ROOT = {
                            every_controlled_state = {
                                limit = {
                                    is_core_of = event_target:my_country
                                    NOT = { is_core_of = ROOT }
                                }
                                var:new_country = { transfer_state = PREV }
                            }
                        }
                        
                        ROOT = {
                            puppet = var:new_country
                            set_autonomy = { target = PREV autonomy_state = autonomy_collaboration_government }
                        }

                    }

            }
        }
    }

In the second code, a country is created even if the occupied country is not on the map. But this government has the flag of my country and is essentially a copy of my state, not a puppet government of that country. Attempting to replace the tag of my country with the dynamic tag of the occupied country was unsuccessful: no matter what I specify: PREV, THIS, or FROM - the game still creates a duplicate of my country when the decision is activated, although it makes this country my puppet.

Code:
The_second_one = {
    allowed = { always = yes }
    cost = 0
    ai_will_do = {
        factor = 0
    }
    complete_effect = {
        create_dynamic_country = {
            original_tag = FROM
            set_variable = { collaboration_formed_by = PREV }
            set_temp_variable = { new_country = this }
            ROOT = {
                every_controlled_state = {
                    limit = {
                        NOT = { is_core_of = ROOT }
                    }
                    var:new_country = { transfer_state = PREV }
                }
            }
            PREV = {
                puppet = PREV
                set_autonomy = { target = PREV autonomy_state = autonomy_collaboration_government }
            }
            every_possible_country = {
                limit = { has_character = POL_boleslaw_piasecki }
                POL_boleslaw_piasecki = {
                    set_nationality = PREV
                }
            }
        }
    }
}

The third code I created from the in-game code 'test_vichy_france,' which is part of the code file 'FRA' (located in the '/common/decisions/' folder). In the standard code, Vichy France was created upon activation.

I edited the code, leaving only what I needed. The problem with this code is that I can't replace 'original_tag = FRA' with a dynamic parameter.

every_occupied_country = {save_event_target_as = my_puppet_country}original_tag = PREV

I.e., I tried to replace the tag of France with 'original_tag = event_target:my_puppet_country' and it didn't work: the game doesn't understand which country's tag needs to be used.

I also tried to replace this with a temporary variable 'original_tag = var:my_country,' using for the temporary variable the value:

set_temp_variable = { my_puppet_country = THIS }

It didn't work either.

Code:
The_third_one = {
    allowed = { always = yes }
    cost = 0
    ai_will_do = {
        factor = 0
    }
    complete_effect = {
        create_dynamic_country = {
            original_tag = FRA
            save_event_target_as = MYnce_vichy
            every_state = {
                limit = {
                    is_controlled_by = ROOT
                    OR = {
                        is_core_of = DJH
                        is_core_of = BNF
                    }
                }
                event_target:MYnce_vichy = { transfer_state = PREV }
            }
            every_state = {
                limit = {
                    is_controlled_by = ROOT
                    NOT = {
                        is_core_of = ROOT
                    }
                }
                add_core_of = PREV
                event_target:MYnce_vichy = { transfer_state = PREV }
            }
            every_state = {
                limit = {
                    is_controlled_by = ROOT
                    is_core_of = ROOT
                    NOT = {
                        is_controlled_by = event_target:MYnce_vichy
                    }
                }
                add_core_of = PREV
            }
        }
    }
}

The main problem is that the game does not understand which country needs to be acted upon. The game understands when you specify the tag of a specific country (GER, FRA, etc.), but gets confused when you try to set dynamic parameters.

Do you have any thoughts on how to fix my codes above?