I noticed a big problem with Romania's changing sides code (+solution)

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

Zeprion

Banned
30 Badges
Oct 31, 2016
949
2.110
  • Hearts of Iron IV: Cadet
  • Hearts of Iron IV: No Step Back
  • Hearts of Iron IV: By Blood Alone
  • Battle for Bosporus
  • Crusader Kings III
  • Hearts of Iron IV: La Resistance
  • Prison Architect
  • Hearts of Iron IV: Expansion Pass
  • Crusader Kings II: Holy Fury
  • Hearts of Iron IV: Expansion Pass
  • Crusader Kings II: Jade Dragon
  • Age of Wonders III
  • Hearts of Iron IV: Death or Dishonor
  • Hearts of Iron IV: Together for Victory
  • Hearts of Iron IV: Colonel
  • Crusader Kings II
  • Crusader Kings II: Conclave
  • Crusader Kings II: Horse Lords
  • Crusader Kings II: Way of Life
  • Mount & Blade: With Fire and Sword
  • Victoria 2
  • Europa Universalis IV
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: The Republic
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: The Old Gods
I've seen some posts on the forum with people saying that changing sides with Romania ruined their game, or that you have the decision to change sides when you shouldn't have.

So I looked into the code, that I will post below.

Basically, in order to change sides you have to:
- Not be faction leader.
- Have the leader of the faction that you want to switch sides to (Allies, Comintern, Axis) be at war with you.

For Allies:
- Have either UK, US or a democracy as the leader.
- Romania is non-aligned or democratic.
Takes priority: Allies - Any USA democratic faction - Random democratic faction.

For Comintern:
- Have either USSR or a communist as the leader.
- Romania is non-aligned or communist.
Takes priority: Comintern - Random communist faction.

For Axis:
- Have either Germany, Italy or a fascist as the leader.
- Romania is non-aligned or fascist.
Takes priority: Axis - Any Italy fascist faction - Random fascist faction.

The problem with this code is that it doesn't check whether you are already in the faction you want to switch sides to.
For example, you want to switch sides to the Allies - it doesn't check whether you are already in the Allies or another democratic faction.
You can: Not be the faction leader, have a democratic leader, be in the Allies.
And you are eligible to switch sides to the Allies. But in fact the game will check for the 2nd condition, any USA democratic faction and then for random democratic faction.

All of this should be fixed by the "has_war_with = ROM" part. If Romania is at war with England, then it means Romania is at war with the Allies and it's not possible for Romania to be in the Allies, right? In theory, yes. But in practice, as I said, I've seen some posts on the forums with people claiming that the game lets them change sides to the country they are already part of.
Maybe there are some loopholes, but rather than seek&destory the loopholes, a better solution is to make other restrictions.

Which is why I suggest to:
- Add another restriction - is not in the faction it tries to switch sides to. AND:
Switch sides to the Allies: is not in a democratic faction.
Switch sides to the Axis: is not in a fascist faction.
Switch sides to the Comintern: is not in a communist faction.
(so that you would avoid jumping from the Axis to the Greater East Asian Co-Prosperity Sphere, or from the Little Entente to the Allies, to give 2 examples)

- I would also suggest to remove the "has_government = neutrality" for Romania when it comes to switching sides.
It makes Romania too unpredictible.
Best allow Romania to:
- Switch sides to the Allies only if democratic.
- Switch sides to the Axis only if fascist.
- Switch sides to the Comintern only if communist.

We already have "King Michael's Coup" that makes Romania become Democratic overnight even if it was 100% fascist (historically accurate) so it won't be a problem if you remove the "has_government = neutrality" condition.

If you want to create an alt-history counterpart for "King Michael's Coup", you can make below "Handle the King" on the democratic path, an exclusive "Iron Guard Coup" and "Communist Party Coup" focuses to do the same thing but in reverse, make Romania fascist or communist overnight even if it was 100% democratic.

Historically speaking, King Michael's Coup and Romania changing sides was all of a sudden, even to the Allies. You can imagine the Germans would have taken precautionary actions if they noticed Romania is slowly turning democratic.

If you want to skip all that text, in short, with my suggestions, the conditions would be these:
- Not be faction leader.
- Have the leader of the faction that you want to switch sides to (Allies, Comintern, Axis) be at war with you.

For Allies:
- Have either UK, US or a democracy as the leader.
- Romania is not in the Allies.
- Romania is not in a democratic faction.
- Romania is democratic.
Takes priority: Allies - Any USA democratic faction - Random democratic faction.

For Comintern:
- Have either USSR or a communist as the leader.
- Romania is not in the Comintern
- Romania is not in a communist faction.
- Romania is communist.
Takes priority: Comintern - Random communist faction.

For Axis:
- Have either Germany, Italy or a fascist as the leader.
- Romania is not in the Axis
- Romania is not in a fascist faction.
- Romania is fascist.
Takes priority: Axis - Any Italy fascist faction - Random fascist faction.

This will allow you to change sides only if you are ideology X, but in a faction of ideology Y, that is at war with a faction of ideology X.
In other words, you can only change sides if you are in a faction of a different ideology than yours AND are fighting against your own ideology.

Code:
ROM_change_sides = {
  
    # Allies

    ROM_change_sides_to_allies = {

        icon = decision_generic_nationalism

        allowed = {
            original_tag = ROM
        }

        available = {
            is_faction_leader = no
            has_capitulated = no
            any_country = {
                is_faction_leader = yes
                has_war_with = ROM
                OR = {
                    has_government = democratic
                    original_tag = ENG
                    original_tag = USA
                }
            }
            OR = {
                has_government = neutrality
                has_government = democratic
            }
            hidden_trigger = {
                NOT = { has_country_flag = romania_has_flipped_sides } #Romania shouldn't be able to keep switching sides all the time
            }
        }
      
        visible = {
            is_faction_leader = no # you shouldn't be able to betray your own faction
            original_tag = ROM
            NOT = { has_country_flag = romania_has_flipped_sides }
            hidden_trigger = { has_country_flag = can_change_sides_dem }
        }

        cost = 0
      
        fire_only_once = yes
      
        remove_effect = {
            hidden_effect = { clr_country_flag = can_change_sides_dem }
        }

        complete_effect = {
            #save current faction leader for use in the event
            hidden_effect = {
                random_country = {
                    limit = {
                        is_in_faction_with = ROOT
                        is_faction_leader = yes
                    }
                    save_global_event_target_as = romania_former_ally_target
                }
            }
            #top priority is joining the Allies if they still exist
            if = {
                limit = {
                    any_country = {
                        is_faction_leader = yes
                        has_war_with = ROM
                        has_government = democratic
                        OR = {
                            original_tag = ENG
                            is_in_faction_with = ENG
                        }
                    }
                }
                random_enemy_country = {
                    limit = {
                        is_faction_leader = yes
                        has_war_with = ROM
                        has_government = democratic
                        OR = {
                            original_tag = ENG
                            is_in_faction_with = ENG
                        }
                    }
                    save_event_target_as = romania_new_ally_target
                }
            }
            #then attempts to join the USA's faction
            else_if = {
                limit = {
                    any_country = {
                        is_faction_leader = yes
                        has_war_with = ROM
                        has_government = democratic
                        OR = {
                            original_tag = USA
                            is_in_faction_with = USA
                        }
                    }
                }
                random_enemy_country = {
                    limit = {
                        is_faction_leader = yes
                        has_war_with = ROM
                        has_government = democratic
                        OR = {
                            original_tag = USA
                            is_in_faction_with = USA
                        }
                    }
                    save_event_target_as = romania_new_ally_target
                }
            }
            #then attempts to join any democratic faction
            else = {
                random_enemy_country = {
                    limit = {
                        is_faction_leader = yes
                        has_war_with = ROM
                        has_government = democratic
                    }
                    save_event_target_as = romania_new_ally_target
                }
            }
            event_target:romania_new_ally_target = {
                country_event = { id = DOD_romania.16 }
            }
            hidden_effect = {
                set_country_flag = romania_has_flipped_sides
            }
        }

        ai_will_do = {
            factor = 100
            modifier = {
                is_historical_focus_on = no
                factor = 0
            }
            modifier = {
                is_historical_focus_on = yes
                NOT = { date > 1944.08.08 }
                factor = 0
            }
        }

    }
  
    # Commintern

    ROM_change_sides_to_commintern = {

        icon = decision_generic_nationalism

        allowed = {
            original_tag = ROM
        }

        available = {
            is_faction_leader = no
            has_capitulated = no
            any_country = {
                is_faction_leader = yes
                has_war_with = ROM
                OR = {
                    has_government = communism
                    original_tag = SOV
                }
            }
            OR = {
                has_government = neutrality
                has_government = communism
            }
            hidden_trigger = {
                NOT = { has_country_flag = romania_has_flipped_sides } #Romania shouldn't be able to keep switching sides all the time
            }
        }
      
        visible = {
            is_faction_leader = no # you shouldn't be able to betray your own faction
            original_tag = ROM
            NOT = { has_country_flag = romania_has_flipped_sides }
            hidden_trigger = { has_country_flag = can_change_sides_com }
        }

        cost = 0
      
        fire_only_once = yes
      
        remove_effect = {
            hidden_effect = { clr_country_flag = can_change_sides_com }
        }

        complete_effect = {
            #save current faction leader for use in the event
            hidden_effect = {
                random_country = {
                    limit = {
                        is_in_faction_with = ROOT
                        is_faction_leader = yes
                    }
                    save_global_event_target_as = romania_former_ally_target
                }
            }
            #top priority is joining the Commintern if they still exist
            if = {
                limit = {
                    any_country = {
                        is_faction_leader = yes
                        has_war_with = ROM
                        has_government = communism
                        OR = {
                            original_tag = SOV
                            is_in_faction_with = SOV
                        }
                    }
                }
                random_enemy_country = {
                    limit = {
                        is_faction_leader = yes
                        has_war_with = ROM
                        has_government = communism
                        OR = {
                            original_tag = SOV
                            is_in_faction_with = SOV
                        }
                    }
                    save_event_target_as = romania_new_ally_target
                }
            }
            #then attempts to join any communist faction
            else = {
                random_enemy_country = {
                    limit = {
                        is_faction_leader = yes
                        has_war_with = ROM
                        has_government = communism
                    }
                    save_event_target_as = romania_new_ally_target
                }
            }
            event_target:romania_new_ally_target = {
                country_event = { id = DOD_romania.16 }
            }
            hidden_effect = {
                set_country_flag = romania_has_flipped_sides
            }
        }

        ai_will_do = {
            factor = 0
        }

    }
  
    # Axis

    ROM_change_sides_to_axis = {

        icon = decision_generic_nationalism

        allowed = {
            original_tag = ROM
        }

        available = {
            is_faction_leader = no
            has_capitulated = no
            any_country = {
                is_faction_leader = yes
                has_war_with = ROM
                OR = {
                    has_government = fascism
                    original_tag = GER
                    original_tag = ITA
                }
            }
            OR = {
                has_government = neutrality
                has_government = fascism
            }
            hidden_trigger = {
                NOT = { has_country_flag = romania_has_flipped_sides } #Romania shouldn't be able to keep switching sides all the time
            }
        }
      
        visible = {
            is_faction_leader = no # you shouldn't be able to betray your own faction
            original_tag = ROM
            NOT = { has_country_flag = romania_has_flipped_sides }
            hidden_trigger = { has_country_flag = can_change_sides_fas }
        }

        cost = 0
      
        fire_only_once = yes
      
        remove_effect = {
            hidden_effect = { clr_country_flag = can_change_sides_fas }
        }

        complete_effect = {
            #save current faction leader for use in the event
            hidden_effect = {
                random_country = {
                    limit = {
                        is_in_faction_with = ROOT
                        is_faction_leader = yes
                    }
                    save_global_event_target_as = romania_former_ally_target
                }
            }
            #top priority is joining the Axis if they still exist
            if = {
                limit = {
                    any_country = {
                        is_faction_leader = yes
                        has_war_with = ROM
                        has_government = fascism
                        OR = {
                            original_tag = GER
                            is_in_faction_with = GER
                        }
                    }
                }
                random_enemy_country = {
                    limit = {
                        is_faction_leader = yes
                        has_war_with = ROM
                        has_government = fascism
                        OR = {
                            original_tag = GER
                            is_in_faction_with = GER
                        }
                    }
                    save_event_target_as = romania_new_ally_target
                }
            }
            #then attempts to join Italy's faction
            else_if = {
                limit = {
                    any_country = {
                        is_faction_leader = yes
                        has_war_with = ROM
                        has_government = fascism
                        OR = {
                            original_tag = ITA
                            is_in_faction_with = ITA
                        }
                    }
                }
                random_enemy_country = {
                    limit = {
                        is_faction_leader = yes
                        has_war_with = ROM
                        has_government = fascism
                        OR = {
                            original_tag = ITA
                            is_in_faction_with = ITA
                        }
                    }
                    save_event_target_as = romania_new_ally_target
                }
            }
            #then attempts to join any fascist faction
            else = {
                random_enemy_country = {
                    limit = {
                        is_faction_leader = yes
                        has_war_with = ROM
                        has_government = fascism
                    }
                    save_event_target_as = romania_new_ally_target
                }
            }
            event_target:romania_new_ally_target = {
                country_event = { id = DOD_romania.16 }
            }
            hidden_effect = {
                set_country_flag = romania_has_flipped_sides
            }
        }

        ai_will_do = {
            factor = 0
        }

    }
  
}
 
  • 4Like
  • 3
Reactions: