LAR Spain
LAR Spain
is_triggered_only = yes
fire_only_once = yes
     trigger = {
           tag = SPR
           has_dlc = "La Resistance"
     }
      immediate = {
            hidden_effect = {
                  set_country_flag = SPR_spanish_elections_flag
                  if = {
                        limit = {
                              focus_progress = {
                                    focus = SPR_the_popular_front
                                    progress > 0
                              }
                              NOT = { has_completed_focus = SPR_the_popular_front }
                        }
                        complete_national_focus = SPR_the_popular_front
                        add_political_power = -35
                  }
                  if = {
                        limit = {
                              focus_progress = {
                                    focus = SPA_a_great_spain
                                    progress > 0
                              }
                              NOT = { has_completed_focus = SPA_a_great_spain }
                        }
                        complete_national_focus = SPA_a_great_spain
                        add_political_power = -35
                  }
                  if = {
                        limit = {
                              has_completed_focus = SPR_the_popular_front
                        }
                        activate_mission =
SPA_hand_over_the_ceda_campaign_chest_mission
                        activate_mission = SPR_military_plot_republicans
                        hidden_effect = {
                              country_event = { id = lar_spain.4 } # Nationalists
working against the government
                              country_event = { id = lar_spain.5 }
                              activate_mission = SPR_military_plot_republicans
                              add_ideas = SPR_government_power_struggle
                        }
                  }
                  if = {
                        limit = {
                              has_completed_focus = SPA_a_great_spain
                        }
                        random_list = {
                              10 = {
                                    activate_mission =
SPR_secure_the_guardia_de_asalto_mission
                              }
                              10 = {
                                    modifier = {
                                          factor = 0
                                          is_historical_focus_on = yes
                                    }
                                    activate_mission =
SPR_secure_the_guardia_civil_mission
                              }
                        }
                        activate_mission = SPA_military_plot_nationalists
                        hidden_effect = {
                              country_event = { id = lar_spain.3 } # Government
working against the nationalists
                              country_event = { id = lar_spain.5 days = 20
random_days = 10 }
                              activate_mission = SPA_military_plot_nationalists
                        }
                  }
                  every_state = {
                        limit = {
                              is_core_of = SPR
                        }
                        add_core_of = SPA
                  }
            }
      }
     # Popular Front
     option = {
           name = lar_spain.1.a
           trigger = {
                 NOT = {
                       has_completed_focus = SPA_a_great_spain
                 }
           }
           add_popularity = {
                 ideology = communism
                 popularity = 0.1
           }
           add_political_power = 5
           if = {
                 limit = {
                       NOT = {
                             has_completed_focus = SPR_the_popular_front
                       }
                 }
                 complete_national_focus = SPR_the_popular_front
                 add_political_power = -35
                 activate_mission = SPR_military_plot_republicans
                 hidden_effect = {
                       country_event = { id = lar_spain.4 days = 4 } #
Nationalists working against the government
                        country_event = { id = lar_spain.5 }
                        activate_mission = SPR_military_plot_republicans
                        if = {
                              limit = {
                                    NOT = { has_active_mission =
SPA_hand_over_the_ceda_campaign_chest_mission }
                              }
                              activate_mission =
SPA_hand_over_the_ceda_campaign_chest_mission
                        }
                  }
            }
            effect_tooltip = { add_ideas = SPR_government_power_struggle }
            custom_effect_tooltip = SPR_republican_garrison_control_decisions_tt
      }
      # Falange
      option = {
            name = lar_spain.1.b
            trigger = {
                  NOT = {
                        has_completed_focus = SPR_the_popular_front
                  }
            }
            add_popularity = {
                  ideology = fascism
                  popularity = 0.1
            }
            if = {
                  limit = {
                        NOT = {
                              has_completed_focus = SPA_a_great_spain
                        }
                  }
                  complete_national_focus = SPA_a_great_spain
                  add_political_power = -35
                  activate_mission = SPA_military_plot_nationalists
                  hidden_effect = {
                        country_event = { id = lar_spain.3 } # Government working
against the nationalists
                        country_event = { id = lar_spain.5 days = 20 random_days =
10 }
                        activate_mission = SPA_military_plot_nationalists
                        if = {
                              limit = {
                                    NOT = {
                                          has_active_mission =
SPR_secure_the_guardia_de_asalto_mission
                                          has_active_mission =
SPR_secure_the_guardia_civil_mission
                                    }
                              }
                              random_list = {
                                    10 = {
                                          activate_mission =
SPR_secure_the_guardia_de_asalto_mission
                                    }
                                    10 = {
                                             modifier = {
                                                   factor = 0
                                                   is_historical_focus_on = yes
                                             }
                                             activate_mission =
SPR_secure_the_guardia_civil_mission
                                    }
                              }
                        }
                  }
            }
            custom_effect_tooltip = SPA_nationalist_garrison_control_decisions_tt
      }
}
is_triggered_only = yes
      immediate = {
            hidden_effect = {
                  every_owned_state = {
                        limit = {
                              is_core_of = ROOT
                        }
                        set_state_flag = SPR_core_of_spain_flag
                  }
                  set_global_flag = { flag = SPR_civil_war_startup value = 1 days =
3 } # Make AI avoid attacking for a few days
            }
            if = {
                  limit = {
                        has_completed_focus = SPA_a_great_spain
                  }
                  hidden_effect = {
                        SPA = { # Switch the tag alias for SPA - it now becomes SPD
- the republicans
                              clr_country_flag = SPR_nationalist_spain_flag
                              drop_cosmetic_tag = yes
                              set_country_flag = SPR_republican_spain_flag
                              if = {
                                    limit = {
                                          has_game_rule = {
                                                rule = spr_fragmentation_status
                                                option = SPR_EU4
                                          }
                                    }
                                   set_cosmetic_tag = SPR_republican_castille
                             }
                             else = {
                                   set_cosmetic_tag = SPR_republican_spain
                             }
                             set_politics = {
                                   ruling_party = democratic
                             }
                             set_popularities = {
                                   democratic = 50
                                   neutrality = 11
                                   communism = 39
                             }
                             retire_ideology_leader = democratic
                             retire_ideology_leader = neutrality
                             retire_ideology_leader = communism
                       }
                       SPD = { # Remove Carlist/Falangist country leaders for new
SPD tag
                             retire_ideology_leader = fascism
                             retire_ideology_leader = neutrality
                             create_country_leader = {
                                   name = "Manuel Azaña"
                                   desc = "POLITICS_MANUEL_AZANA_DESC"
                                   picture = GFX_portrait_Manuel_Azana
                                   expire = "1965.1.1"
                                   ideology = conservatism
                                   traits = {
                                         figurehead_president
                                   }
                             }
                        }
                        # Switch the tag alias for the player's country - the
player goes from SPR to SPA
                        set_country_flag = SPR_nationalist_spain_flag
                        if = {
                              limit = {
                                    has_game_rule = {
                                          rule = spr_fragmentation_status
                                          option = SPR_EU4
                                    }
                              }
                              set_cosmetic_tag = SPR_nationalist_castille
                        }
                        else = {
                              set_cosmetic_tag = SPR_nationalist_spain
                        }
                        set_politics = {
                              ruling_party = neutrality
                        }
                        add_popularity = {
                            ideology = democratic
                            popularity = -0.25
                        }
                        add_popularity = {
                            ideology = communism
                            popularity = -0.1
                        }
                        kill_country_leader = yes
                       create_country_leader = {
                             name = "José Sanjurjo"
                             desc = "POLITICS_JOSE_SANJURJO_DESC"
                             picture = "GFX_portrait_SPA_jose_sanjurjo"
                             expire = "1965.1.1"
                             ideology = despotism
                             traits = {
                                   the_lion_of_the_rif
                             }
                       }
                       # Add Nationalist and Republican Garrison division
templates
                        division_template = {
                              name = "Guarnición Nacionalista"
                              is_locked = yes
                              template_counter = 6
                              division_names_group = SPR_INF_02
                              regiments = {
                                    infantry = { x = 0 y = 0 }
                                    infantry = { x = 0 y = 1 }
                                    infantry = { x = 0 y = 2 }
                              }
                        }
                        SPD = {
                              division_template = {
                                    name = "Guarnición Republicana"
                                    is_locked = yes
                                    template_counter = 6
                                    division_names_group = SPD_INF_01
                                    regiments = {
                                          infantry = { x = 0 y = 0 }
                                          infantry = { x = 0 y = 1 }
                                          infantry = { x = 0 y = 2 }
                                    }
                              }
                        }
                        # Give SPD Madrid if the Nationalists don't have complete
garrison control over it - becomes capital
                        if = {
                              limit = {
                                    41 = {
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = equals }
                                    }
                              }
                              SPD = {
                                    transfer_state = 41
                              }
                              41 = {
                                    set_state_flag =
SPR_sided_with_republicans_flag
                                    create_unit = {
                                          division = "division_template
= \"Guarnición Republicana\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 3
                                    }
                              }
                        }
                        else_if = {
                              limit = {
                                    41 = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = equals }
                                    }
                              }
                              SPD = {
                                    transfer_state = 41
                              }
                              41 = {
                                    set_state_flag =
SPR_sided_with_republicans_flag
                                    create_unit = {
                                          division = "division_template
= \"Guarnición Republicana\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs   = yes
                                          count = 2
                                    }
                                    create_unit = {
                                          division = "division_template
= \"Guarnición Nacionalista\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs   = yes
                                          count = 1
                                    }
                              }
                        }
                        else_if = {
                              limit = {
                                    41 = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = equals }
                                    }
                              }
                              SPD = {
                                    transfer_state = 41
                              }
                              41 = {
                                    set_state_flag =
SPR_sided_with_republicans_flag
                                    create_unit = {
                                          division = "division_template
= \"Guarnición Republicana\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs   = yes
                                          count = 1
                                    }
                                    create_unit = {
                                          division = "division_template
= \"Guarnición Nacionalista\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs   = yes
                                          count = 2
                                    }
                              }
                        }
                        # If Madrid is controlled by Nationalists, but a random
state exists that has total Republican garrison control, give that as capital first
                        if = {
                              limit = {
                                    41 = {
                                          check_variable = { var =
SPA_garrison_control value = 4 compare = equals }
                                    }
                                    any_owned_state = {
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = equals }
                                    }
                              }
                              random_owned_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = equals }
                                    }
                                    SPD = {
                                          transfer_state = PREV
                                    }
                                    set_state_flag =
SPR_sided_with_republicans_flag
                                    create_unit = {
                                          division = "division_template
= \"Guarnición Republicana\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 3
                                    }
                              }
                        }
                        # Give a state that does not have total Nationalist
garrison control to the Republicans as their capital - in decreasing order of
Republican control
                        else_if = {
                              limit = {
                                    41 = {
                                          check_variable = { var =
SPA_garrison_control value = 4 compare = equals }
                                    }
                                    any_owned_state = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = equals }
                                    }
                              }
                              random_owned_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = equals }
                                    }
                                    SPD = {
                                          transfer_state = PREV
                                    }
                                    set_state_flag =
SPR_sided_with_republicans_flag
                                    create_unit = {
                                          division = "division_template
= \"Guarnición Republicana\" start_experience_factor = 0.1"
                                         owner = SPD
                                         allow_spawning_on_enemy_provs = yes
                                         count = 2
                                    }
                                    create_unit = {
                                          division = "division_template
= \"Guarnición Nacionalista\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                        }
                        else_if = {
                              limit = {
                                    41 = {
                                          check_variable = { var =
SPA_garrison_control value = 4 compare = equals }
                                    }
                                    any_owned_state = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = equals }
                                    }
                              }
                              random_owned_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = equals }
                                    }
                                    SPD = {
                                          transfer_state = PREV
                                    }
                                    set_state_flag =
SPR_sided_with_republicans_flag
                                    create_unit = {
                                          division = "division_template
= \"Guarnición Republicana\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                                    create_unit = {
                                          division = "division_template
= \"Guarnición Nacionalista\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs = yes
                                          count = 2
                                    }
                              }
                        }
                        # Split equipment and army/navy depending on which focuses
the Republicans have finished
                        if = {
                              limit = {
                                    NOT = { has_country_flag =
SPR_enlarge_the_weapon_caches_flag }
                              }
                              transfer_units_fraction = {
                                    target = SPD
                                   size = 0.5 # Fallback in case one of the ratios
below are not stipulated
                                   stockpile_ratio = 0.5
                                   army_ratio = 0.5
                                   navy_ratio = 0.5
                                   air_ratio = 0.5
                                   keep_unit_leaders = {
                                   }
                                   keep_unit_leaders_trigger = {
                                         has_trait =
trait_SPA_nationalist_sympathies
                                   }
                             }
                        }
                        if = {
                              limit = {
                                    has_country_flag =
SPR_enlarge_the_weapon_caches_flag
                                    NOT = { has_country_flag =
SPR_disband_the_army_flag }
                              }
                              transfer_units_fraction = {
                                    target = SPD
                                    size = 0.5
                                    stockpile_ratio = 0.8
                                    army_ratio = 0.5
                                    navy_ratio = 0.5
                                    air_ratio = 0.5
                                    keep_unit_leaders = {
                                   }
                                   keep_unit_leaders_trigger = {
                                         has_trait =
trait_SPA_nationalist_sympathies
                                   }
                             }
                       }
                       if = {
                             limit = {
                                   has_country_flag = SPR_disband_the_army_flag
                             }
                             transfer_units_fraction = {
                                   target = SPD
                                   size = 0.5
                                   stockpile_ratio = 0.8
                                   army_ratio = 0.8
                                   navy_ratio = 0.5
                                   air_ratio = 0.5
                                   keep_unit_leaders = {
                                   }
                                   keep_unit_leaders_trigger = {
                                         has_trait =
trait_SPA_nationalist_sympathies
                                   }
                             }
                       }
                       # If player has completed this focus, give North Africa and
spawn units there (this effect is run first so the tag has any territory whatsoever
- it's assumed all players take this focus)
                        if = {
                              limit = {
                                    has_completed_focus = SPA_the_army_of_africa
                              }
                              division_template = {
                                    name = "División del Ejército de África"
                                    template_counter = 4
                                    division_names_group = SPR_INF_06
                                    regiments = {
                                          infantry = { x = 0 y = 0 }
                                          infantry = { x = 0 y = 1 }
                                          infantry = { x = 0 y = 2 }
                                          infantry = { x = 1 y = 0 }
                                          infantry = { x = 1 y = 1 }
                                          infantry = { x = 1 y = 2 }
                                          infantry = { x = 2 y = 0 }
                                          artillery_brigade = { x = 2 y = 1 }
                                          artillery_brigade = { x = 2 y = 2 }
                                    }
                                    support = {
                                          recon = { x = 0 y = 0 }
                                          engineer = { x = 0 y = 1 }
                                    }
                              }
                              290 = {
                                    create_unit = {
                                          division = "division_template
= \"División del Ejército de África\" start_experience_factor = 0.3"
                                          owner = SPA
                                    }
                                    create_unit = {
                                          division = "division_template
= \"División del Ejército de África\" start_experience_factor = 0.3"
                                          owner = SPA
                                    }
                                    create_unit = {
                                          division = "division_template
= \"División del Ejército de África\" start_experience_factor = 0.3"
                                          owner = SPA
                                    }
                                    if = {
                                          limit = {
                                                ROOT = { NOT = { has_country_flag =
SPR_disband_the_army_flag } }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"División del Ejército de África\" start_experience_factor = 0.3"
                                                owner = SPA
                                          }
                                          create_unit = {
                                                division = "division_template
= \"División del Ejército de África\" start_experience_factor = 0.3"
                                                owner = SPA
                                          }
                                    }
                              }
                       }
                       # Republicans remove their army
                       SPD = {
                             delete_units = {
                                 division_template = "División de Infantería"
                                 disband = yes
                             }
                             delete_units = {
                                 division_template = "División de Caballería"
                                 disband = yes
                             }
                             delete_units = {
                                 division_template = "Brigada Montaña"
                                 disband = yes
                             }
                             delete_units = {
                                 division_template = "Brigada de Infantería"
                                 disband = yes
                             }
                       }
                       # Switch leaders who do not have nationalist sympathies to
the Republicans
                        every_unit_leader = {
                              limit = {
                                    NOT = { has_trait =
trait_SPA_nationalist_sympathies }
                              }
                              set_nationality = SPD
                        }
                        # Remove unnecessary traits from Nationalist commanders (no
longer relevant to see for the player, as the SCW has started)
                        every_unit_leader = {
                              limit = {
                                    has_trait = trait_SPA_nationalist_sympathies
                              }
                              remove_unit_leader_trait =
trait_SPA_nationalist_sympathies
                        }
                        # Add various loyalist traits that now become relevant -
indicating loyalties to the different subfactions
                        every_unit_leader = {
                              limit = {
                                    OR = {
                                          has_id = 1108
                                          has_id = 1109
                                          has_id = 1111
                                          has_id = 1112
                                          has_id = 1113
                                    }
                              }
                              add_unit_leader_trait = trait_SPA_falangist_loyalties
                        }
                        every_unit_leader = {
                              limit = {
                                    OR = {
                                          has_id = 1114
                                          has_id = 1115
                                          has_id = 1116
                                    }
                             }
                             add_unit_leader_trait = trait_SPA_carlist_loyalties
                        }
                        SPD = {
                              every_unit_leader = {
                                    limit = {
                                          OR = {
                                                has_id = 1101
                                                has_id = 1102
                                                has_id = 1103
                                          }
                                    }
                                    add_unit_leader_trait =
trait_SPR_republican_loyalties
                              }
                              every_unit_leader = {
                                    limit = {
                                          OR = {
                                                has_id = 1104
                                                has_id = 1105
                                                has_id = 1106
                                          }
                                    }
                                    add_unit_leader_trait =
trait_SPR_stalinist_loyalties
                              }
                              every_unit_leader = {
                                    limit = {
                                          OR = {
                                                has_id = 1107
                                          }
                                    }
                                    add_unit_leader_trait =
trait_SPR_anti_stalinist_loyalties
                              }
                        }
                        # Add 3 Republican garrisons to every state where the
Nationalists have NONE control
                        every_owned_state = {
                              limit = {
                                    check_variable = { var = SPA_garrison_control
value = 1 compare = equals }
                                    NOT = {
                                          state = 290
                                          state = 699
                                          state = 783
                                          state = 297
                                    }
                              }
                              # Transfer states and set flag to prepare for post-
Civil War de-coring
                              SPD = {
                                    transfer_state = PREV
                              }
                              set_state_flag = SPR_sided_with_republicans_flag
                              create_unit = {
                                    division = "division_template = \"Guarnición
Republicana\" start_experience_factor = 0.1"
                                    owner = SPD
                                   allow_spawning_on_enemy_provs = yes
                                   count = 3
                             }
                       }
                       41 = { # Extra 6 divisions to make Madrid harder to capture
(as historically)
                              create_unit = {
                                    division = "division_template = \"Guarnición
Republicana\" start_experience_factor = 0.1"
                                    owner = SPD
                                    allow_spawning_on_enemy_provs = yes
                                    count = 6
                              }
                        }
                        # Add 3 Nationalist garrisons to every state where the
Nationalists have TOTAL control
                        every_owned_state = {
                              limit = {
                                    check_variable = { var = SPA_garrison_control
value = 4 compare = equals }
                              }
                              create_unit = {
                                    division = "division_template = \"Guarnición
Nacionalista\" start_experience_factor = 0.1"
                                    owner = SPA
                                    allow_spawning_on_enemy_provs = yes
                                    count = 3
                              }
                        }
                        # Trigger war between the sides - necessary because the
next effects spawn units on contested provinces and this requires both sides to be
at war
                        SPA = {
                              declare_war_on = {
                                  target = SPD
                                  type = civil_war
                              }
                              add_civil_war_target = SPD
                        }
                        # 2 Republican and 1 Nationalist garrisons spawned on all
states with WEAK Nationalist control (except for Northern Garrison states)
                        every_owned_state = {
                              limit = {
                                    check_variable = { var = SPA_garrison_control
value = 2 compare = equals }
                                    NOT = { has_state_flag =
SPA_northern_garrisons_state_flag }
                              }
                              # Transfer states and set flag to prepare for post-
Civil War de-coring
                              SPD = {
                                    transfer_state = PREV
                              }
                              set_state_flag = SPR_sided_with_republicans_flag
                              create_unit = {
                                    division = "division_template = \"Guarnición
Republicana\" start_experience_factor = 0.1"
                                    owner = SPD
                                    allow_spawning_on_enemy_provs = yes
                                    count = 2
                              }
                              create_unit = {
                                    division = "division_template = \"Guarnición
Nacionalista\" start_experience_factor = 0.1"
                                    owner = SPA
                                    allow_spawning_on_enemy_provs = yes
                                    count = 1
                              }
                        }
                        # 2 Nationalist and 1 Republican garrisons spawned on all
states with STRONG Nationalist control
                        every_owned_state = {
                              limit = {
                                    check_variable = { var = SPA_garrison_control
value = 3 compare = equals }
                                    NOT = { has_state_flag =
SPA_northern_garrisons_state_flag }
                              }
                              # Transfer states and set flag to prepare for post-
Civil War de-coring
                              SPD = {
                                    transfer_state = PREV
                              }
                              set_state_flag = SPR_sided_with_republicans_flag
                              create_unit = {
                                    division = "division_template = \"Guarnición
Republicana\" start_experience_factor = 0.1"
                                    owner = SPD
                                    allow_spawning_on_enemy_provs = yes
                                    count = 1
                              }
                              create_unit = {
                                    division = "division_template = \"Guarnición
Nacionalista\" start_experience_factor = 0.1"
                                    owner = SPA
                                    allow_spawning_on_enemy_provs = yes
                                    count = 2
                              }
                        }
                        # If Negotiate Carlist Support has been taken, add
Nationalist units in Navarra
                        if = {
                              limit = {
                                    has_country_flag =
SPA_negotiate_carlist_support_flag
                                    OR = {
                                          is_ai = no
                                          is_historical_focus_on = no
                                    }
                              }
                              division_template = {
                                    name = "Requeté Carlista"
                                    template_counter = 8
                                    division_names_group = SPR_INF_03
                                    is_locked = yes
                                    regiments = {
                                          infantry = { x = 0 y = 0 }
                                          infantry = { x = 0 y = 1 }
                                         infantry = { x = 0 y = 2 }
                                   }
                              }
                              172 = {
                                    create_unit = {
                                          division = "division_template =   \"Requeté
Carlista\" start_experience_factor = 0.3"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs =   yes
                                          count = 5
                                    }
                              }
                        }
                        # If Negotiate Carlist Support has been taken AND   AI, add
Nationalist units in Navarra AND Western Aragon
                        if = {
                              limit = {
                                    has_country_flag =
SPA_negotiate_carlist_support_flag
                                    is_ai = yes
                                    is_historical_focus_on = yes
                              }
                              division_template = {
                                    name = "Requeté Carlista"
                                    template_counter = 8
                                    division_names_group = SPR_INF_03
                                    is_locked = yes
                                    regiments = {
                                          infantry = { x = 0 y = 0 }
                                          infantry = { x = 0 y = 1 }
                                          infantry = { x = 0 y = 2 }
                                    }
                              }
                              172 = {
                                    create_unit = {
                                          division = "division_template =   \"Requeté
Carlista\" start_experience_factor = 0.3"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs =   yes
                                          count = 2
                                    }
                              }
                              166 = {
                                    create_unit = {
                                          division = "division_template =   \"Requeté
Carlista\" start_experience_factor = 0.3"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs =   yes
                                          count = 2
                                    }
                                    create_unit = {
                                          division = "division_template =   \"Requeté
Carlista\" start_experience_factor = 0.3"
                                          owner = SPA
                                          prioritize_location = 3816
                                          allow_spawning_on_enemy_provs =   yes
                                          count = 1
                                    }
                              }
                        }
                        # If Republicans secured the Guardia Civil, add Civil
divisions to random states for the Republicans, and Asalto divisions to random
states for the Nationalists
                        if = {
                              limit = {
                                    has_country_flag =
SPR_secure_the_guardia_civil_flag
                              }
                              division_template = {
                                    name = "División de la Guardia de Asalto"
                                    template_counter = 5
                                    division_names_group = SPR_INF_05
                                    is_locked = yes
                                    regiments = {
                                          infantry = { x = 0 y = 0 }
                                          infantry = { x = 0 y = 1 }
                                          infantry = { x = 0 y = 2 }
                                          infantry = { x = 1 y = 0 }
                                          infantry = { x = 1 y = 1 }
                                          infantry = { x = 1 y = 2 }
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template
= \"División de la Guardia de Asalto\" start_experience_factor = 0.3"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs = yes
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template
= \"División de la Guardia de Asalto\" start_experience_factor = 0.3"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs = yes
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template
= \"División de la Guardia de Asalto\" start_experience_factor = 0.3"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs = yes
                                    }
                              }
                                if = {
                                      limit = {
                                            difficulty > 1
                                            ROOT = {
                                                  is_ai = no
                                            }
                                      }
                                      random_state = {
                                            limit = {
                                                  check_variable = { var =
SPA_garrison_control value   = 3 compare = greater_than_or_equals }
                                            }
                                            create_unit = {
                                                  division = "division_template
= \"División de la Guardia   de Asalto\" start_experience_factor = 0.3"
                                                  owner = SPA
                                                  allow_spawning_on_enemy_provs = yes
                                            }
                                      }
                                      random_state = {
                                            limit = {
                                                  check_variable = { var =
SPA_garrison_control value   = 3 compare = greater_than_or_equals }
                                            }
                                            create_unit = {
                                                  division = "division_template
= \"División de la Guardia   de Asalto\" start_experience_factor = 0.3"
                                                  owner = SPA
                                                  allow_spawning_on_enemy_provs = yes
                                            }
                                      }
                                }
                                SPD = {
                                      division_template = {
                                            name = "Brigada de la Guardia Civil"
                                            template_counter = 7
                                            division_names_group = SPR_INF_04
                                            is_locked = yes
                                            regiments = {
                                                  infantry = { x = 0 y = 0 }
                                                  infantry = { x = 0 y = 1 }
                                                  infantry = { x = 0 y = 2 }
                                            }
                                      }
                                }
                                random_state = {
                                      limit = {
                                            check_variable = { var =
SPA_garrison_control value   = 2 compare = less_than_or_equals }
                                            if = {
                                                  limit = {
                                                        ROOT = {
                                                              is_ai = yes
                                                              OR = {
                                                                    AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                         }
                                   }
                                   create_unit = {
                                         division = "division_template = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                         owner = SPD
                                         allow_spawning_on_enemy_provs = yes
                                         count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
     is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                       option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              if = {
                                    limit = {
                                          difficulty > 1
                                          ROOT = {
                                                is_ai = no
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                                if = {
                                                      limit = {
                                                            ROOT = {
                                                                  is_ai = yes
                                                                  OR = {
                                                                        AND = {
is_historical_focus_on = yes
has_game_rule = {
rule = SPR_ai_behavior
     option = DEFAULT
                                                                             }
                                                                       }
has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
     has_game_rule = {
                                                                             rule =
SPR_ai_behavior
                                                                             option
= NATIONALIST_HISTORICAL
                                                                       }
                                                                   }
                                                           }
                                                     }
                                                     NOT = {
                                                           state = 790
                                                           state = 792
                                                     }
                                               }
                                         }
                                         create_unit = {
                                               division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                               owner = SPD
                                               allow_spawning_on_enemy_provs = yes
                                               count = 1
                                         }
                                   }
                                   random_state = {
                                         limit = {
                                               check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                               if = {
                                                     limit = {
                                                           ROOT = {
                                                                 is_ai = yes
                                                                 OR = {
                                                                       AND = {
is_historical_focus_on = yes
has_game_rule = {
rule = SPR_ai_behavior
     option = DEFAULT
                                                                             }
                                                                         }
has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
     has_game_rule = {
                                                                             rule =
SPR_ai_behavior
                                                                             option
= NATIONALIST_HISTORICAL
                                                                         }
                                                                }
                                                           }
                                                     }
                                                     NOT = {
                                                           state = 790
                                                           state = 792
                                                     }
                                               }
                                         }
                                         create_unit = {
                                               division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                               owner = SPD
                                               allow_spawning_on_enemy_provs = yes
                                               count = 1
                                         }
                                   }
                                   random_state = {
                                         limit = {
                                               check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                               if = {
                                                     limit = {
                                                           ROOT = {
                                                                 is_ai = yes
                                                                 OR = {
                                                                       AND = {
is_historical_focus_on = yes
has_game_rule = {
rule = SPR_ai_behavior
     option = DEFAULT
                                                                             }
                                                                         }
has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
     has_game_rule = {
                                                                             rule =
SPR_ai_behavior
                                                                             option
= NATIONALIST_HISTORICAL
                                                                         }
                                                                 }
                                                           }
                                                     }
                                                     NOT = {
                                                           state = 790
                                                           state = 792
                                                     }
                                               }
                                         }
                                         create_unit = {
                                               division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                               owner = SPD
                                               allow_spawning_on_enemy_provs = yes
                                               count = 1
                                         }
                                   }
                                   random_state = {
                                         limit = {
                                               check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                               if = {
                                                     limit = {
                                                           ROOT = {
                                                                 is_ai = yes
                                                                 OR = {
                                                                       AND = {
     is_historical_focus_on = yes
     has_game_rule = {
rule = SPR_ai_behavior
     option = DEFAULT
                                                                             }
                                                                         }
has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
     has_game_rule = {
                                                                             rule =
SPR_ai_behavior
                                                                             option
= NATIONALIST_HISTORICAL
                                                                         }
                                                                 }
                                                           }
                                                     }
                                                     NOT = {
                                                           state = 790
                                                           state = 792
                                                     }
                                                }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                                owner = SPD
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                              }
                        }
                        # If Republicans secured the Guardia de Asalto, do the
opposite distribution
                        else_if = {
                              limit = {
                                    has_country_flag =
SPR_secure_the_guardia_de_asalto_flag
                              }
                              division_template = {
                                    name = "Brigada de la Guardia Civil"
                                    template_counter = 7
                                    division_names_group = SPR_INF_04
                                    is_locked = yes
                                    regiments = {
                                          infantry = { x = 0 y = 0 }
                                          infantry = { x = 0 y = 1 }
                                          infantry = { x = 0 y = 2 }
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template   = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs   = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template   = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs   = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template   = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs   = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template   = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs   = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template   = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs   = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              if = {
                                    limit = {
                                          difficulty > 1
                                          ROOT = {
                                                is_ai = no
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                                owner = SPA
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                                owner = SPA
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                                owner = SPA
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                                owner = SPA
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                              }
                              SPD = {
                                    division_template = {
                                          name = "División de la Guardia de Asalto"
                                          template_counter = 5
                                          division_names_group = SPR_INF_05
                                          is_locked = yes
                                          regiments = {
                                                infantry = { x = 0 y = 0 }
                                                infantry = { x = 0 y = 1 }
                                                infantry = { x = 0 y = 2 }
                                                infantry = { x = 1 y = 0 }
                                                infantry = { x = 1 y = 1 }
                                                infantry = { x = 1 y = 2 }
                                          }
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                             rule =
SPR_ai_behavior
                                                                             option
= DEFAULT
                                                                       }
                                                                 }
                                                                 has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                 has_game_rule = {
                                                                       rule =
SPR_ai_behavior
                                                                       option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template
= \"División de la Guardia de Asalto\" start_experience_factor = 0.3"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                                rule =
SPR_ai_behavior
                                                                                option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                          option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template
= \"División de la Guardia de Asalto\" start_experience_factor = 0.3"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                                rule =
SPR_ai_behavior
                                                                                option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template
= \"División de la Guardia de Asalto\" start_experience_factor = 0.3"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                    }
                              }
                              if = {
                                    limit = {
                                          difficulty > 1
                                          ROOT = {
                                                is_ai = no
                                          }
                                    }
                                    random_state = {
                                         limit = {
                                               check_variable =   { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                               check_variable =   { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals   }
                                               if = {
                                                     limit = {
                                                           ROOT   = {
                                                                   is_ai = yes
                                                                   OR = {
                                                                         AND = {
is_historical_focus_on = yes
has_game_rule = {
rule = SPR_ai_behavior
     option = DEFAULT
                                                                              }
                                                                         }
has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= NATIONALIST_HISTORICAL
                                                                         }
                                                                  }
                                                           }
                                                     }
                                                     NOT = {
                                                           state = 790
                                                           state = 792
                                                     }
                                               }
                                         }
                                         create_unit = {
                                               division = "division_template
= \"División de la Guardia de Asalto\" start_experience_factor = 0.3"
                                               owner = SPD
                                               allow_spawning_on_enemy_provs = yes
                                         }
                                   }
                                   random_state = {
                                         limit = {
                                               check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                               check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                               if = {
                                                     limit = {
                                                           ROOT = {
                                                                  is_ai = yes
                                                                  OR = {
                                                                        AND = {
     is_historical_focus_on = yes
has_game_rule = {
rule = SPR_ai_behavior
     option = DEFAULT
                                                                             }
                                                                         }
has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
     has_game_rule = {
                                                                             rule =
SPR_ai_behavior
                                                                             option
= NATIONALIST_HISTORICAL
                                                                         }
                                                                 }
                                                           }
                                                     }
                                                     NOT = {
                                                           state = 790
                                                           state = 792
                                                     }
                                                }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"División de la Guardia de Asalto\" start_experience_factor = 0.3"
                                                owner = SPD
                                                allow_spawning_on_enemy_provs = yes
                                          }
                                    }
                              }
                        }
                        else = { #Extra backup in case player never took any
focuses - SPA gets BOTH types! Suck on it, Reds!
                              division_template = {
                                    name = "División de la Guardia de Asalto"
                                    template_counter = 5
                                    division_names_group = SPR_INF_05
                                    is_locked = yes
                                    regiments = {
                                          infantry = { x = 0 y = 0 }
                                          infantry = { x = 0 y = 1 }
                                          infantry = { x = 0 y = 2 }
                                          infantry = { x = 1 y = 0 }
                                          infantry = { x = 1 y = 1 }
                                          infantry = { x = 1 y = 2 }
                                    }
                              }
                              division_template = {
                                    name = "Brigada de la Guardia Civil"
                                    template_counter = 7
                                    division_names_group = SPR_INF_04
                                    is_locked = yes
                                    regiments = {
                                          infantry = { x = 0 y = 0 }
                                           infantry = { x = 0 y = 1 }
                                           infantry = { x = 0 y = 2 }
                                     }
                               }
                                #Guardia de Asalto
                                random_state = {
                                      limit = {
                                            check_variable = { var =
SPA_garrison_control value   = 3 compare = greater_than_or_equals }
                                      }
                                      create_unit = {
                                            division = "division_template
= \"División de la Guardia   de Asalto\" start_experience_factor = 0.3"
                                            owner = SPA
                                            allow_spawning_on_enemy_provs = yes
                                      }
                                }
                                random_state = {
                                      limit = {
                                            check_variable = { var =
SPA_garrison_control value   = 3 compare = greater_than_or_equals }
                                      }
                                      create_unit = {
                                            division = "division_template
= \"División de la Guardia   de Asalto\" start_experience_factor = 0.3"
                                            owner = SPA
                                            allow_spawning_on_enemy_provs = yes
                                      }
                                }
                                random_state = {
                                      limit = {
                                            check_variable = { var =
SPA_garrison_control value   = 3 compare = greater_than_or_equals }
                                      }
                                      create_unit = {
                                            division = "division_template
= \"División de la Guardia   de Asalto\" start_experience_factor = 0.3"
                                            owner = SPA
                                            allow_spawning_on_enemy_provs = yes
                                      }
                                }
                                if = {
                                      limit = {
                                            difficulty > 1
                                            ROOT = {
                                                  is_ai = no
                                            }
                                      }
                                      random_state = {
                                            limit = {
                                                  check_variable = { var =
SPA_garrison_control value   = 3 compare = greater_than_or_equals }
                                            }
                                            create_unit = {
                                                  division = "division_template
= \"División de la Guardia   de Asalto\" start_experience_factor = 0.3"
                                                  owner = SPA
                                                  allow_spawning_on_enemy_provs = yes
                                         }
                                   }
                                   random_state = {
                                         limit = {
                                               check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                         }
                                         create_unit = {
                                               division = "division_template
= \"División de la Guardia de Asalto\" start_experience_factor = 0.3"
                                               owner = SPA
                                               allow_spawning_on_enemy_provs = yes
                                         }
                                   }
                              }
                              # Guardia Civil
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template   = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs   = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template   = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs   = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template   = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs   = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              if = {
                                    limit = {
                                          difficulty > 1
                                          ROOT = {
                                                is_ai = no
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                                owner = SPA
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                                owner = SPA
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                                owner = SPA
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                                owner = SPA
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                              }
                        }
                        # If Republicans had time to Train the Union Youth, add
these divisions to random states that have at MOST WEAK Nationalist control
                        if = {
                              limit = {
                                    has_country_flag =
SPR_train_the_union_youth_flag
                              }
                              SPD = {
                                    division_template = {
                                          name = "Brigada de Juventudes Sindicales"
                                          template_counter = 0
                                          division_names_group = SPD_INF_02
                                          is_locked = yes
                                          regiments = {
                                                infantry = { x = 0 y = 0 }
                                                infantry = { x = 0 y = 1 }
                                                infantry = { x = 0 y = 2 }
                                          }
                                    }
                              }
                              random_state = {
                                   limit = {
                                         check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                         check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                         if = {
                                               limit = {
                                                     ROOT = {
                                                           is_ai = yes
                                                           OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                         }
                                   }
                                   create_unit = {
                                         division = "division_template = \"Brigada
de Juventudes Sindicales\" start_experience_factor = 0.2"
                                         owner = SPD
                                         allow_spawning_on_enemy_provs = yes
                                         count = 1
                                   }
                                   if = {
                                         limit = {
                                               difficulty > 1
                                               ROOT = {
                                                     is_ai = no
                                               }
                                         }
                                         create_unit = {
                                               division = "division_template
= \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2"
                                               owner = SPD
                                               allow_spawning_on_enemy_provs = yes
                                               count = 1
                                         }
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                         }
                                   }
                                   create_unit = {
                                         division = "division_template = \"Brigada
de Juventudes Sindicales\" start_experience_factor = 0.2"
                                         owner = SPD
                                         allow_spawning_on_enemy_provs = yes
                                         count = 1
                                   }
                                   if = {
                                         limit = {
                                               difficulty > 1
                                               ROOT = {
                                                     is_ai = no
                                               }
                                         }
                                         create_unit = {
                                               division = "division_template
= \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2"
                                               owner = SPD
                                               allow_spawning_on_enemy_provs = yes
                                               count = 1
                                         }
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                         }
                                   }
                                   create_unit = {
                                         division = "division_template = \"Brigada
de Juventudes Sindicales\" start_experience_factor = 0.2"
                                         owner = SPD
                                         allow_spawning_on_enemy_provs = yes
                                         count = 1
                                   }
                                   if = {
                                         limit = {
                                               difficulty > 1
                                               ROOT = {
                                                     is_ai = no
                                               }
                                         }
                                         create_unit = {
                                                division = "division_template
= \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2"
                                                owner = SPD
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                         }
                                   }
                                   create_unit = {
                                         division = "division_template = \"Brigada
de Juventudes Sindicales\" start_experience_factor = 0.2"
                                         owner = SPD
                                         allow_spawning_on_enemy_provs = yes
                                         count = 1
                                   }
                                   if = {
                                         limit = {
                                               difficulty > 1
                                               ROOT = {
                                                     is_ai = no
                                                }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2"
                                                owner = SPD
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                         }
                                   }
                                   create_unit = {
                                         division = "division_template = \"Brigada
de Juventudes Sindicales\" start_experience_factor = 0.2"
                                         owner = SPD
                                         allow_spawning_on_enemy_provs = yes
                                         count = 1
                                   }
                                   if = {
                                         limit = {
                                               difficulty > 1
                                               ROOT = {
                                                     is_ai = no
                                               }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2"
                                                owner = SPD
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                              }
                        }
                        # If Republicans had time to Distribute Arms to the People,
add these divisions to random states that have at MOST WEAK Nationalist control
                        if = {
                              limit = {
                                    has_country_flag =
SPR_distribute_arms_to_the_people_flag
                              }
                              SPD = {
                                    division_template = {
                                          name = "Brigada Popular"
                                          template_counter = 13
                                          division_names_group = SPD_INF_03
                                          is_locked = yes
                                          regiments = {
                                                infantry = { x = 0 y = 0 }
                                                infantry = { x = 0 y = 1 }
                                                infantry = { x = 0 y = 2 }
                                          }
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                             rule =
SPR_ai_behavior
                                                                             option
= DEFAULT
                                                                        }
                                                                  }
                                                                  has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
Popular\" start_experience_factor = 0"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 2
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                         }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
Popular\" start_experience_factor = 0"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 2
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
Popular\" start_experience_factor = 0"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 2
                                    }
                              }
                              random_state = {
                                   limit = {
                                         check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                         check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                         if = {
                                               limit = {
                                                     ROOT = {
                                                           is_ai = yes
                                                           OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
Popular\" start_experience_factor = 0"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 2
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
     is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
Popular\" start_experience_factor = 0"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 2
                                    }
                              }
                        }
                        # Load Spanish FT for Republicans, unlock relevant focuses
                        SPD = {
                              load_focus_tree = {
                                    tree = spanish_focus
                                    keep_completed = no
                              }
                              unlock_national_focus = SPR_the_popular_front
                        }
                        # Randomize which one they get, unless they had time to
pick one
                        random_list = {
                              10 = {
                                    modifier = {
                                          factor = 0
                                          has_country_flag =
SPR_secure_the_guardia_civil_flag
                                    }
                                    SPD = { unlock_national_focus =
SPR_secure_the_guardia_de_asalto }
                              }
                              10 = {
                                    modifier = {
                                          factor = 0
                                          has_country_flag =
SPR_secure_the_guardia_de_asalto_flag
                                    }
                                    SPD = { unlock_national_focus =
SPR_secure_the_guardia_civil }
                              }
                        }
                        SPD = {
                              unlock_national_focus = SPR_train_the_union_youth
                              unlock_national_focus = SPR_enlarge_the_weapon_caches
                              unlock_national_focus =
SPR_distribute_arms_to_the_people
                              unlock_national_focus = SPR_disband_the_army
                              random_list = {
                                    10 = {
                                          modifier = {
                                                factor = 0
                                                is_historical_focus_on = yes
                                          }
                                          modifier = {
                                                factor = 0
                                                has_global_flag =
SOV_covert_support_for_poum_flag #POUM UPRISING (SUPPORTED BY SOVIET RIGHT
OPPOSITION)
                                          }
                                          complete_national_focus =
SPR_regional_defense_council_of_aragon
                                    }
                                    10 = {
                                          modifier = {
                                                factor = 0
                                                has_global_flag =
SOV_covert_support_for_poum_flag #POUM UPRISING (SUPPORTED BY SOVIET RIGHT
OPPOSITION)
                                          }
                                          complete_national_focus =
SPR_maintain_the_second_republic
                                    }
                                    10 = {
                                          modifier = {
                                                factor = 0
                                                is_historical_focus_on = yes
                                          }
                                          modifier = {
                                                add = 10
                                                has_global_flag =
SOV_covert_support_for_poum_flag #POUM UPRISING (SUPPORTED BY SOVIET RIGHT
OPPOSITION)
                                          }
                                          complete_national_focus =
SPR_the_anti_fascist_workers_revolution
                                    }
                              }
                        }
                        # Unlock division templates for Nationalists
                        country_lock_all_division_template = no
                        every_owned_state = {
                              set_state_flag = SPR_sided_with_nationalists_flag
                        }
                        if = {
                             limit = {
                                   176 = { is_owned_by = ROOT }
                             }
                             set_capital = { state = 176 }
                        }
                        else_if = {
                              limit = {
                                    171 = { is_owned_by = ROOT }
                              }
                              set_capital = { state = 171 }
                        }
                        else = {
                              random_owned_state = {
                                    ROOT = { set_capital = { state = PREV } }
                              }
                        }
                        # Unlock division templates for Republicans
                        SPD = {
                              every_state = {
                                    limit = {
                                          has_state_flag = SPR_core_of_spain_flag
                                    }
                                    add_core_of = SPD
                              }
                              inherit_technology = SPA
                              country_lock_all_division_template = no
                        }
                        if = {
                              limit = {
                                    41 = { is_owned_by = SPD }
                              }
                              SPD = { set_capital = { state = 41 } }
                        }
                        else_if = {
                              limit = {
                                    165 = { is_owned_by = SPD }
                              }
                              SPD = { set_capital = { state = 165 } }
                        }
                        else = {
                              random_owned_state = {
                                    SPD = { set_capital = { state = PREV } }
                              }
                        }
                        # We need to teleport the railway guns after capitals have
been set. transfer_units_fraction will
                        # teleport them but to the wrong province.
                        teleport_railway_guns_to_deploy_province = ROOT
                        teleport_railway_guns_to_deploy_province = SPD
                        SPD = {
                              add_timed_idea = { idea = SPR_death_before_surrender
days = 900 }
                              add_ideas = SPR_disbanded_army_1
                              set_party_name = { ideology = neutrality long_name =
SPR_neutrality_anarchism_party_long name = SPR_neutrality_anarchism_party }
                        }
                        set_party_name = { ideology = neutrality long_name =
SPR_neutrality_military_junta_party_long name = SPR_neutrality_military_junta_party
}
                                #every_unit_leader = {
                                #     limit = {
                                #           has_unit_leader_flag = SPR_reassigned_flag
                                #     }
                                #     ROOT = { remove_unit_leader = PREV }
                                #}
                                add_timed_idea = { idea = SPA_death_before_surrender days =
900 }
                                set_global_flag = spanish_civil_war # Start civil war -
used in many triggers
                        country_event = { id = lar_spain.6 days = 7 } # SCW
notification event for the player
                        country_event = { id = lar_spain.78 days = 7 random_days =
7 } # Sanjurjo dies
                  }
            }
###   ###   ###   #   #   ###   #   ### ##    ##    # #    ###   ###   ###   ### ## ###
# #   #     # #   #   #   # #   #    # # #   # #    ## #   #     #     #     #   # # #
###   ##    ###   #   #   ###   #    # #     ####   # ##   ##    ##    ##    ## #    #
# #   #     #     #   #   # #   #    # # #   # #    # #    #     #     #     #   # # #
# #   ###   #      ##     ###   ### ### ##   # #    # #    ###   #     #     ### ##  #
                                     }
                                     keep_unit_leaders_trigger = {
                                           NOT = { has_trait =
trait_SPA_nationalist_sympathies }
                                     }
                             }
                        }
                        if = {
                              limit = {
                                    has_completed_focus =
SPR_enlarge_the_weapon_caches
                                    NOT = { has_completed_focus =
SPR_disband_the_army }
                              }
                              transfer_units_fraction = {
                                    target = SPA
                                    size = 0.5
                                    stockpile_ratio = 0.2
                                    army_ratio = 0.5
                                    navy_ratio = 0.5
                                    air_ratio = 0.5
                                    keep_unit_leaders = {
                                     }
                                     keep_unit_leaders_trigger = {
                                           NOT = { has_trait =
trait_SPA_nationalist_sympathies }
                                     }
                             }
                       }
                       if = {
                             limit = {
                                   has_completed_focus = SPR_disband_the_army
                             }
                             transfer_units_fraction = {
                                   target = SPA
                                   size = 0.5
                                   stockpile_ratio = 0.2
                                   army_ratio = 0.2
                                   navy_ratio = 0.5
                                   air_ratio = 0.5
                                   keep_unit_leaders = {
                                     }
                                     keep_unit_leaders_trigger = {
                                           NOT = { has_trait =
trait_SPA_nationalist_sympathies }
                                     }
                             }
                        }
                        delete_units = {
                            division_template = "División de Infantería"
                            disband = yes
                        }
                        delete_units = {
                            division_template = "División de Caballería"
                            disband = yes
                        }
                        delete_units = {
                            division_template = "Brigada Montaña"
                            disband = yes
                        }
                        delete_units = {
                            division_template = "Brigada de Infantería"
                            disband = yes
                        }
                        every_unit_leader = {
                              limit = {
                                    has_trait = trait_SPA_nationalist_sympathies
                              }
                              remove_unit_leader_trait =
trait_SPA_nationalist_sympathies
                              set_nationality = SPA
                        }
                        SPA = {
                              every_unit_leader = {
                                    limit = {
                                          OR = {
                                                has_id = 1108
                                                has_id = 1109
                                                has_id = 1111
                                                has_id = 1112
                                                has_id = 1113
                                          }
                                    }
                                    remove_unit_leader_trait =
trait_SPA_nationalist_sympathies
                                    add_unit_leader_trait =
trait_SPA_falangist_loyalties
                              }
                              every_unit_leader = {
                                    limit = {
                                          OR = {
                                                has_id = 1114
                                                has_id = 1115
                                                has_id = 1116
                                          }
                                    }
                                    remove_unit_leader_trait =
trait_SPA_nationalist_sympathies
                                    add_unit_leader_trait =
trait_SPA_carlist_loyalties
                              }
                              every_unit_leader = {
                                    limit = {
                                          has_id = 1110
                                    }
                                    remove_unit_leader_trait =
trait_SPA_nationalist_sympathies
                              }
                        }
                        every_unit_leader = {
                              limit = {
                                    OR = {
                                          has_id = 1101
                                          has_id = 1102
                                          has_id = 1103
                                    }
                              }
                              add_unit_leader_trait =
trait_SPR_republican_loyalties
                        }
                        every_unit_leader = {
                              limit = {
                                    OR = {
                                          has_id = 1104
                                          has_id = 1105
                                          has_id = 1106
                                    }
                              }
                              add_unit_leader_trait = trait_SPR_stalinist_loyalties
                        }
                        every_unit_leader = {
                              limit = {
                                    OR = {
                                          has_id = 1107
                                    }
                              }
                              add_unit_leader_trait =
trait_SPR_anti_stalinist_loyalties
                        }
                        every_owned_state = {
                              limit = {
                                    check_variable = { var = SPA_garrison_control
value = 1 compare = equals }
                                    NOT = {
                                          state = 290
                                          state = 699
                                          state = 783
                                          state = 297
                                    }
                              }
                              create_unit = {
                                    division = "division_template = \"Guarnición
Republicana\" start_experience_factor = 0.1"
                                    owner = SPD
                                    allow_spawning_on_enemy_provs = yes
                                    count = 3
                              }
                        }
                       41 = { # Extra 6 divisions to make Madrid harder to capture
(as historically)
                              create_unit = {
                                    division = "division_template = \"Guarnición
Republicana\" start_experience_factor = 0.1"
                                    owner = SPD
                                    allow_spawning_on_enemy_provs = yes
                                    count = 6
                              }
                        }
                        every_owned_state = {
                              limit = {
                                    check_variable = { var = SPA_garrison_control
value = 4 compare = equals }
                              }
                              SPA = {
                                    transfer_state = PREV
                              }
                              set_state_flag = SPR_sided_with_nationalists_flag
                              create_unit = {
                                    division = "division_template = \"Guarnición
Nacionalista\" start_experience_factor = 0.1"
                                    owner = SPA
                                    allow_spawning_on_enemy_provs = yes
                                    count = 3
                              }
                        }
                        SPA = {
                              declare_war_on = {
                                  target = SPD
                                  type = civil_war
                              }
                              add_civil_war_target = SPD
                        }
                        every_owned_state = {
                              limit = {
                                    check_variable = { var = SPA_garrison_control
value = 2 compare = equals }
                              }
                              if = {
                                    limit = {
                                          has_state_flag =
SPA_northern_garrisons_state_flag
                                    }
                                    SPA = {
                                          transfer_state = PREV
                                    }
                                    create_unit = {
                                          division = "division_template
= \"Guarnición Nacionalista\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                                    create_unit = {
                                          division = "division_template
= \"Guarnición Republicana\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                         count = 2
                                   }
                              }
                              else = {
                                    create_unit = {
                                          division = "division_template
= \"Guarnición Republicana\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 2
                                    }
                                    create_unit = {
                                          division = "division_template
= \"Guarnición Nacionalista\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                        }
                        every_owned_state = {
                              limit = {
                                    check_variable = { var = SPA_garrison_control
value = 3 compare = equals }
                              }
                              if = {
                                    limit = {
                                          has_state_flag =
SPA_northern_garrisons_state_flag
                                    }
                                    SPA = {
                                          transfer_state = PREV
                                    }
                                    create_unit = {
                                          division = "division_template
= \"Guarnición Nacionalista\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs = yes
                                          count = 2
                                    }
                                    create_unit = {
                                          division = "division_template
= \"Guarnición Republicana\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              else = {
                                    create_unit = {
                                          division = "division_template
= \"Guarnición Republicana\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                                    create_unit = {
                                          division = "division_template
= \"Guarnición Nacionalista\" start_experience_factor = 0.1"
                                         owner = SPA
                                         allow_spawning_on_enemy_provs = yes
                                         count = 2
                                   }
                             }
                        }
                        if = {
                              limit = {
                                    has_country_flag =
SPA_negotiate_carlist_support_flag
                              }
                              SPA = {
                                    division_template = {
                                          name = "Requeté Carlista"
                                          template_counter = 8
                                          division_names_group = SPR_INF_03
                                          is_locked = yes
                                          regiments = {
                                                infantry = { x = 0 y = 0 }
                                                infantry = { x = 0 y = 1 }
                                                infantry = { x = 0 y = 2 }
                                          }
                                    }
                              }
                              172 = {
                                    create_unit = {
                                          division = "division_template = \"Requeté
Carlista\" start_experience_factor = 0.5"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs = yes
                                          count = 5
                                    }
                                    if = {
                                          limit = {
                                                difficulty > 1
                                                ROOT = {
                                                      is_ai = no
                                                }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Requeté Carlista\" start_experience_factor = 0.5"
                                                owner = SPA
                                                allow_spawning_on_enemy_provs = yes
                                                count = 5
                                          }
                                    }
                              }
                        }
                        if = {
                              limit = {
                                    has_completed_focus =
SPR_secure_the_guardia_civil
                              }
                              SPA = {
                                    division_template = {
                                          name = "División de la Guardia de Asalto"
                                          template_counter = 5
                                          division_names_group = SPR_INF_05
                                           is_locked = yes
                                           regiments = {
                                                 infantry =   {   x   =   0   y   =   0   }
                                                 infantry =   {   x   =   0   y   =   1   }
                                                 infantry =   {   x   =   0   y   =   2   }
                                                 infantry =   {   x   =   1   y   =   0   }
                                                 infantry =   {   x   =   1   y   =   1   }
                                                 infantry =   {   x   =   1   y   =   2   }
                                           }
                                      }
                                }
                                random_state = {
                                      limit = {
                                            check_variable = { var =
SPA_garrison_control value   = 3 compare = greater_than_or_equals }
                                      }
                                      create_unit = {
                                            division = "division_template
= \"División de la Guardia   de Asalto\" start_experience_factor = 0.3"
                                            owner = SPA
                                            allow_spawning_on_enemy_provs = yes
                                      }
                                }
                                random_state = {
                                      limit = {
                                            check_variable = { var =
SPA_garrison_control value   = 3 compare = greater_than_or_equals }
                                      }
                                      create_unit = {
                                            division = "division_template
= \"División de la Guardia   de Asalto\" start_experience_factor = 0.3"
                                            owner = SPA
                                            allow_spawning_on_enemy_provs = yes
                                      }
                                }
                                random_state = {
                                      limit = {
                                            check_variable = { var =
SPA_garrison_control value   = 3 compare = greater_than_or_equals }
                                      }
                                      create_unit = {
                                            division = "division_template
= \"División de la Guardia   de Asalto\" start_experience_factor = 0.3"
                                            owner = SPA
                                            allow_spawning_on_enemy_provs = yes
                                      }
                                }
                                if = {
                                      limit = {
                                            difficulty > 1
                                            ROOT = {
                                                  is_ai = no
                                            }
                                      }
                                      random_state = {
                                            limit = {
                                                  check_variable = { var =
SPA_garrison_control value   = 3 compare = greater_than_or_equals }
                                            }
                                            create_unit = {
                                                  division = "division_template
= \"División de la Guardia   de Asalto\" start_experience_factor = 0.3"
                                                  owner = SPA
                                                  allow_spawning_on_enemy_provs = yes
                                            }
                                      }
                                      random_state = {
                                            limit = {
                                                  check_variable = { var =
SPA_garrison_control value   = 3 compare = greater_than_or_equals }
                                            }
                                            create_unit = {
                                                  division = "division_template
= \"División de la Guardia   de Asalto\" start_experience_factor = 0.3"
                                                  owner = SPA
                                                  allow_spawning_on_enemy_provs = yes
                                            }
                                      }
                                }
                                SPD = {
                                      division_template = {
                                            name = "Brigada de la Guardia Civil"
                                            template_counter = 7
                                            division_names_group = SPR_INF_04
                                            is_locked = yes
                                            regiments = {
                                                  infantry = { x = 0 y = 0 }
                                                  infantry = { x = 0 y = 1 }
                                                  infantry = { x = 0 y = 2 }
                                            }
                                      }
                                }
                                random_state = {
                                      limit = {
                                            check_variable = { var =
SPA_garrison_control value   = 2 compare = less_than_or_equals }
                                            check_variable = { var =
SPA_garrison_control value   = 1 compare = greater_than_or_equals }
                                            if = {
                                                  limit = {
                                                        ROOT = {
                                                              is_ai = yes
                                                              OR = {
                                                                    AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                               rule =
SPR_ai_behavior
                                                                               option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                         }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                         check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                         if = {
                                               limit = {
                                                     ROOT = {
                                                           is_ai = yes
                                                           OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
     is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                       option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              if = {
                                    limit = {
                                          difficulty > 1
                                          ROOT = {
                                                is_ai = no
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                                check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                                if = {
                                                      limit = {
                                                            ROOT = {
                                                                  is_ai = yes
                                                                  OR = {
                                                                        AND = {
is_historical_focus_on = yes
has_game_rule = {
rule = SPR_ai_behavior
     option = DEFAULT
                                                                             }
                                                                       }
has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
     has_game_rule = {
                                                                             rule =
SPR_ai_behavior
                                                                             option
= NATIONALIST_HISTORICAL
                                                                       }
                                                                   }
                                                           }
                                                     }
                                                     NOT = {
                                                           state = 790
                                                           state = 792
                                                     }
                                               }
                                         }
                                         create_unit = {
                                               division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                               owner = SPD
                                               allow_spawning_on_enemy_provs = yes
                                               count = 1
                                         }
                                   }
                                   random_state = {
                                         limit = {
                                               check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                               check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                               if = {
                                                     limit = {
                                                           ROOT = {
                                                                  is_ai = yes
                                                                  OR = {
                                                                        AND = {
is_historical_focus_on = yes
has_game_rule = {
rule = SPR_ai_behavior
     option = DEFAULT
                                                                               }
                                                                         }
has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
     has_game_rule = {
                                                                               rule =
SPR_ai_behavior
                                                                               option
= NATIONALIST_HISTORICAL
                                                                         }
                                                                }
                                                           }
                                                     }
                                                     NOT = {
                                                           state = 790
                                                           state = 792
                                                     }
                                               }
                                         }
                                         create_unit = {
                                               division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                               owner = SPD
                                               allow_spawning_on_enemy_provs = yes
                                               count = 1
                                         }
                                   }
                                   random_state = {
                                         limit = {
                                               check_variable =   { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                               check_variable =   { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals   }
                                               if = {
                                                     limit = {
                                                           ROOT   = {
                                                                   is_ai = yes
                                                                   OR = {
                                                                         AND = {
is_historical_focus_on = yes
has_game_rule = {
rule = SPR_ai_behavior
     option = DEFAULT
                                                                              }
                                                                         }
has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= NATIONALIST_HISTORICAL
                                                                         }
                                                                  }
                                                           }
                                                     }
                                                     NOT = {
                                                           state = 790
                                                           state = 792
                                                     }
                                               }
                                         }
                                         create_unit = {
                                               division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                               owner = SPD
                                               allow_spawning_on_enemy_provs = yes
                                               count = 1
                                         }
                                   }
                                   random_state = {
                                         limit = {
                                               check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                               check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                               if = {
                                                     limit = {
                                                           ROOT = {
                                                                 is_ai = yes
                                                                 OR = {
                                                                       AND = {
is_historical_focus_on = yes
has_game_rule = {
rule = SPR_ai_behavior
     option = DEFAULT
                                                                             }
                                                                         }
has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
     has_game_rule = {
                                                                             rule =
SPR_ai_behavior
                                                                             option
= NATIONALIST_HISTORICAL
                                                                         }
                                                                 }
                                                           }
                                                     }
                                                     NOT = {
                                                           state = 790
                                                           state = 792
                                                     }
                                                }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                                owner = SPD
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                              }
                        }
                        else_if = {
                              limit = {
                                    has_completed_focus =
SPR_secure_the_guardia_de_asalto
                              }
                              SPA = {
                                    division_template = {
                                          name = "Brigada de la Guardia Civil"
                                          template_counter = 7
                                          division_names_group = SPR_INF_04
                                          is_locked = yes
                                          regiments = {
                                                infantry = { x = 0 y = 0 }
                                                infantry = { x = 0 y = 1 }
                                                infantry = { x = 0 y = 2 }
                                         }
                                   }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template   = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs   = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template   = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs   = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template   = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs   = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template   = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs   = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              if = {
                                    limit = {
                                          difficulty > 1
                                          ROOT = {
                                                is_ai = no
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                                owner = SPA
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                                owner = SPA
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                                owner = SPA
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                                owner = SPA
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                              }
                              SPD = {
                                    division_template = {
                                          name = "División de la Guardia de Asalto"
                                          template_counter = 5
                                          division_names_group = SPR_INF_05
                                          is_locked = yes
                                          regiments = {
                                                infantry = { x = 0 y = 0 }
                                                infantry = { x = 0 y = 1 }
                                                infantry = { x = 0 y = 2 }
                                                infantry = { x = 1 y = 0 }
                                                infantry = { x = 1 y = 1 }
                                                infantry = { x = 1 y = 2 }
                                          }
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                             rule =
SPR_ai_behavior
                                                                             option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template
= \"División de la Guardia de Asalto\" start_experience_factor = 0.3"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                                rule =
SPR_ai_behavior
                                                                                option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template
= \"División de la Guardia de Asalto\" start_experience_factor = 0.3"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                                rule =
SPR_ai_behavior
                                                                                option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                         }
                                   }
                                   create_unit = {
                                         division = "division_template
= \"División de la Guardia de Asalto\" start_experience_factor = 0.3"
                                         owner = SPD
                                         allow_spawning_on_enemy_provs = yes
                                   }
                              }
                              if = {
                                    limit = {
                                          difficulty > 1
                                          ROOT = {
                                                is_ai = no
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable =   { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                                check_variable =   { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals    }
                                                if = {
                                                      limit = {
                                                            ROOT   = {
                                                                    is_ai = yes
                                                                    OR = {
                                                                          AND = {
is_historical_focus_on = yes
has_game_rule = {
rule = SPR_ai_behavior
     option = DEFAULT
                                                                               }
                                                                         }
has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
     has_game_rule = {
                                                                               rule =
SPR_ai_behavior
                                                                               option
= NATIONALIST_HISTORICAL
                                                                         }
                                                                   }
                                                           }
                                                     }
                                                     NOT = {
                                                           state = 790
                                                           state = 792
                                                     }
                                               }
                                         }
                                         create_unit = {
                                               division = "division_template
= \"División de la Guardia de Asalto\" start_experience_factor = 0.3"
                                               owner = SPD
                                               allow_spawning_on_enemy_provs = yes
                                         }
                                   }
                                   random_state = {
                                         limit = {
                                               check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                               check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                               if = {
                                                     limit = {
                                                           ROOT = {
                                                                  is_ai = yes
                                                                  OR = {
                                                                        AND = {
is_historical_focus_on = yes
has_game_rule = {
rule = SPR_ai_behavior
      option = DEFAULT
                                                                             }
                                                                         }
has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
      has_game_rule = {
                                                                             rule =
SPR_ai_behavior
                                                                             option
= NATIONALIST_HISTORICAL
                                                                         }
                                                                 }
                                                           }
                                                     }
                                                     NOT = {
                                                           state = 790
                                                           state = 792
                                                     }
                                                }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"División de la Guardia de Asalto\" start_experience_factor = 0.3"
                                                owner = SPD
                                                allow_spawning_on_enemy_provs = yes
                                          }
                                    }
                              }
                        }
                        else = { #Extra backup in case player never took any
focuses - SPA gets BOTH types!
                              SPA = {
                                    division_template = {
                                          name = "División de la Guardia de Asalto"
                                          template_counter = 5
                                          division_names_group = SPR_INF_05
                                          is_locked = yes
                                          regiments = {
                                                infantry = { x = 0 y = 0 }
                                                infantry = { x = 0 y = 1 }
                                                infantry = { x = 0 y = 2 }
                                                infantry = { x = 1 y = 0 }
                                                infantry = { x = 1 y = 1 }
                                                infantry = { x = 1 y = 2 }
                                           }
                                     }
                                     division_template = {
                                           name = "Brigada de la Guardia Civil"
                                           template_counter = 7
                                           division_names_group = SPR_INF_04
                                           is_locked = yes
                                           regiments = {
                                                 infantry = { x = 0 y = 0 }
                                                 infantry = { x = 0 y = 1 }
                                                 infantry = { x = 0 y = 2 }
                                           }
                                     }
                               }
                                #Guardia de Asalto
                                random_state = {
                                      limit = {
                                            check_variable = { var =
SPA_garrison_control value   = 3 compare = greater_than_or_equals }
                                      }
                                      create_unit = {
                                            division = "division_template
= \"División de la Guardia   de Asalto\" start_experience_factor = 0.3"
                                            owner = SPA
                                            allow_spawning_on_enemy_provs = yes
                                      }
                                }
                                random_state = {
                                      limit = {
                                            check_variable = { var =
SPA_garrison_control value   = 3 compare = greater_than_or_equals }
                                      }
                                      create_unit = {
                                            division = "division_template
= \"División de la Guardia   de Asalto\" start_experience_factor = 0.3"
                                            owner = SPA
                                            allow_spawning_on_enemy_provs = yes
                                      }
                                }
                                random_state = {
                                      limit = {
                                            check_variable = { var =
SPA_garrison_control value   = 3 compare = greater_than_or_equals }
                                      }
                                      create_unit = {
                                            division = "division_template
= \"División de la Guardia   de Asalto\" start_experience_factor = 0.3"
                                            owner = SPA
                                            allow_spawning_on_enemy_provs = yes
                                      }
                                }
                                if = {
                                      limit = {
                                            difficulty > 1
                                            ROOT = {
                                                  is_ai = no
                                            }
                                      }
                                     random_state = {
                                           limit = {
                                                 check_variable = { var =
SPA_garrison_control value   = 3 compare = greater_than_or_equals }
                                           }
                                           create_unit = {
                                                 division = "division_template
= \"División de la Guardia   de Asalto\" start_experience_factor = 0.3"
                                                 owner = SPA
                                                 allow_spawning_on_enemy_provs = yes
                                           }
                                     }
                                     random_state = {
                                           limit = {
                                                 check_variable = { var =
SPA_garrison_control value   = 3 compare = greater_than_or_equals }
                                           }
                                           create_unit = {
                                                 division = "division_template
= \"División de la Guardia   de Asalto\" start_experience_factor = 0.3"
                                                 owner = SPA
                                                 allow_spawning_on_enemy_provs = yes
                                           }
                                     }
                                }
                              # Guardia Civil
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template   = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs   = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template   = \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs   = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template =   \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs =   yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template =   \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs =   yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template =   \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs =   yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                                    create_unit = {
                                          division = "division_template =   \"Brigada
de la Guardia Civil\" start_experience_factor = 0.1"
                                          owner = SPA
                                          allow_spawning_on_enemy_provs =   yes
                                          count = 1
                                    }
                              }
                              if = {
                                    limit = {
                                          difficulty > 1
                                          ROOT = {
                                                is_ai = no
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                                owner = SPA
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                                owner = SPA
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                                owner = SPA
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                                    random_state = {
                                          limit = {
                                                check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                          }
                                          create_unit = {
                                                division = "division_template
= \"Brigada de la Guardia Civil\" start_experience_factor = 0.1"
                                                owner = SPA
                                                allow_spawning_on_enemy_provs = yes
                                                count = 1
                                          }
                                    }
                              }
                        }
                        if = {
                              limit = {
                                    has_completed_focus = SPR_train_the_union_youth
                              }
                              SPD = {
                                    division_template = {
                                          name = "Brigada de Juventudes Sindicales"
                                          template_counter = 0
                                          division_names_group = SPD_INF_02
                                          is_locked = yes
                                          regiments = {
                                               infantry = { x = 0 y = 0 }
                                               infantry = { x = 0 y = 1 }
                                               infantry = { x = 0 y = 2 }
                                         }
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de Juventudes Sindicales\" start_experience_factor = 0.2"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                         if = {
                                               limit = {
                                                     ROOT = {
                                                           is_ai = yes
                                                           OR = {
                                                                 AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de Juventudes Sindicales\" start_experience_factor = 0.2"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de Juventudes Sindicales\" start_experience_factor = 0.2"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
de Juventudes Sindicales\" start_experience_factor = 0.2"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 1
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                         }
                                   }
                                   create_unit = {
                                         division = "division_template = \"Brigada
de Juventudes Sindicales\" start_experience_factor = 0.2"
                                         owner = SPD
                                         allow_spawning_on_enemy_provs = yes
                                         count = 1
                                    }
                             }
                        }
                        if = {
                              limit = {
                                    has_completed_focus =
SPR_distribute_arms_to_the_people
                              }
                              SPD = {
                                    division_template = {
                                          name = "Brigada Popular"
                                          template_counter = 13
                                          division_names_group = SPD_INF_03
                                          is_locked = yes
                                          regiments = {
                                                infantry = { x = 0 y = 0 }
                                                infantry = { x = 0 y = 1 }
                                                infantry = { x = 0 y = 2 }
                                          }
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                               rule =
SPR_ai_behavior
                                                                               option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
Popular\" start_experience_factor = 0"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 2
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                         }
                                   }
                                   create_unit = {
                                         division = "division_template = \"Brigada
Popular\" start_experience_factor = 0"
                                         owner = SPD
                                         allow_spawning_on_enemy_provs = yes
                                         count = 2
                                   }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
Popular\" start_experience_factor = 0"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 2
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
     is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
Popular\" start_experience_factor = 0"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 2
                                    }
                              }
                              random_state = {
                                    limit = {
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = less_than_or_equals }
                                          check_variable = { var =
SPA_garrison_control value = 1 compare = greater_than_or_equals }
                                          if = {
                                                limit = {
                                                      ROOT = {
                                                            is_ai = yes
                                                            OR = {
                                                                  AND = {
is_historical_focus_on = yes
     has_game_rule = {
                                                                              rule =
SPR_ai_behavior
                                                                              option
= DEFAULT
                                                                         }
                                                                   }
                                                                   has_country_flag =
SPR_AI_RANDOM_NATIONALIST_HISTORICAL
                                                                   has_game_rule = {
                                                                         rule =
SPR_ai_behavior
                                                                        option =
NATIONALIST_HISTORICAL
                                                                   }
                                                           }
                                                     }
                                               }
                                               NOT = {
                                                     state = 790
                                                     state = 792
                                               }
                                          }
                                    }
                                    create_unit = {
                                          division = "division_template = \"Brigada
Popular\" start_experience_factor = 0"
                                          owner = SPD
                                          allow_spawning_on_enemy_provs = yes
                                          count = 2
                                    }
                              }
                        }
                        SPA = {
                              load_focus_tree = {
                                    tree = spanish_focus
                                    keep_completed = no
                              }
                              unlock_national_focus = SPA_a_great_spain
                              unlock_national_focus =
SPA_hand_over_the_ceda_campaign_chest
                              unlock_national_focus = SPA_negotiate_carlist_support
                              unlock_national_focus = SPA_the_army_of_africa
                              unlock_national_focus =
SPA_secure_the_northern_garrisons
                              random_list = {
                                    10 = {
                                          modifier = {
                                                factor = 0
                                                ROOT = { has_country_flag =
SPA_con_paquito_flag }
                                          }
                                          unlock_national_focus = SPA_sin_paquito
                                    }
                                    10 = {
                                          modifier = {
                                                factor = 0
                                                ROOT = { has_country_flag =
SPA_sin_paquito_flag }
                                          }
                                          unlock_national_focus = SPA_con_paquito
                                    }
                              }
                              random_list = {
                                    10 = {
                                          modifier = {
                                                factor = 0
                                                is_historical_focus_on = yes
                                          }
                                          modifier = {
                                                factor = 0
                                                ROOT = { has_country_flag =
SPA_con_paquito_flag }
                                          }
                                          complete_national_focus =
SPA_the_phalanx_ascendant
                                    }
                                    10 = {
                                          modifier = {
                                                factor = 0
                                                ROOT = { has_country_flag =
SPA_sin_paquito_flag }
                                          }
                                          complete_national_focus =
SPA_unify_the_nationalist_front
                                    }
                                    10 = {
                                          modifier = {
                                                factor = 0
                                                is_historical_focus_on = yes
                                          }
                                          complete_national_focus =
SPA_supremacy_of_the_communion
                                    }
                              }
                              add_ideas = SPA_carlism_1
                         }
                         country_lock_all_division_template = no
                         every_owned_state = {
                               set_state_flag = SPR_sided_with_republicans_flag
                         }
                         if = {
                               limit = {
                                     41 = { is_owned_by = ROOT }
                               }
                               set_capital = { state = 41 }
                         }
                         else_if = {
                               limit = {
                                     165 = { is_owned_by = ROOT }
                               }
                               set_capital = { state = 165 }
                         }
                         else = {
                               random_owned_state = {
                                     ROOT = { set_capital = { state = PREV } }
                               }
                         }
                         SPA = {
                               every_state = {
                                     limit = {
                                           has_state_flag = SPR_core_of_spain_flag
                                     }
                                     add_core_of = SPA
                               }
                               inherit_technology = SPD
                               country_lock_all_division_template = no
                              if = {
                                    limit = {
                                          176 = { is_owned_by = SPA }
                                    }
                                    SPA = { set_capital = { state = 176 } }
                              }
                              else_if = {
                                    limit = {
                                          171 = { is_owned_by = SPA }
                                    }
                                    SPA = { set_capital = { state = 171 } }
                              }
                              else = {
                                    random_owned_state = {
                                          SPA = { set_capital = { state = PREV } }
                                    }
                              }
                              set_party_name = { ideology = neutrality long_name =
SPR_neutrality_military_junta_party_long name = SPR_neutrality_military_junta_party
}
                        }
                        # We need to teleport the railway guns after capitals have
been set. transfer_units_fraction will
                        # teleport them but to the wrong province.
                        teleport_railway_guns_to_deploy_province = ROOT
                        teleport_railway_guns_to_deploy_province = SPA
                        set_party_name = { ideology = neutrality long_name =
SPR_neutrality_anarchism_party_long name = SPR_neutrality_anarchism_party }
                        SPA = { add_timed_idea = { idea =
SPA_death_before_surrender days = 900 } }
                        add_timed_idea = { idea = SPR_death_before_surrender days =
900 }
                        add_ideas = SPR_disbanded_army_1
                        set_global_flag = spanish_civil_war
                        country_event = { id = lar_spain.6 days = 7 }
                        SPA = { country_event = { id = lar_spain.78 days = 7
random_days = 7 } } # Sanjurjo dies
                  }
            }
            hidden_effect = {
                  # Marks gui as "dirty" so the code updates the layout to properly
hide the unused branches
                  mark_focus_tree_layout_dirty = yes
            }
      }
     trigger = {
           NOT = { has_global_flag = spanish_civil_war }
     }
is_triggered_only = yes
hidden = yes
      immediate = {
            random_list = {
                  30 = { # Government imprisons Primo de Rivera
                        modifier = {
                              factor = 0
                              OR = {
                                    NOT = { has_country_flag =
SPR_primo_de_rivera_first_speech }
                                    has_country_flag =
SPA_primo_de_rivera_imprisoned
                              }
                        }
                        activate_mission = SPA_imprison_primo_de_rivera_mission
                  }
                  30 = { # Government makes political arrest
                        modifier = {
                              factor = 0
                              NOT = { has_country_flag =
SPA_political_assassination_flag }
                        }
                        activate_mission = SPA_political_arrest_mission
                  }
                  10 = { # Government reassigns disloyal general
                        modifier = {
                              factor = 0
                              NOT = {
                                    any_army_leader = {
                                          has_trait =
trait_SPA_nationalist_sympathies
                                          NOT = { has_unit_leader_flag =
SPR_reassigned_flag }
                                    }
                              }
                        }
                        activate_mission = SPA_reassign_disloyal_leader_mission
                  }
                  30 = { # Government makes concessions to the far left
                        activate_mission = SPA_concessions_to_the_left_mission
                  }
            }
      }
}
# Mission Generator simulating Nationalists working against the Republican
Government
country_event = {
      id = lar_spain.4
     trigger = {
           NOT = { has_global_flag = spanish_civil_war }
     }
is_triggered_only = yes
hidden = yes
      immediate = {
            random_list = {
                  35 = { # Primo de Rivera makes inflammatory speech
                        activate_mission = SPR_primo_de_rivera_speech_mission
                        modifier = {
                              factor = 0
                              has_country_flag = SPA_primo_de_rivera_imprisoned
                        }
                        modifier = {
                              factor = 0
                              has_decision = SPR_imprison_primo_de_rivera
                        }
                  }
                  15 = { # Nationalists conduct political assassination
                        activate_mission = SPR_political_assassination_mission
                  }
                  20 = { # Nationalists obtain general's loyalty
                        activate_mission = SPR_sway_leader_loyalty_mission
                        modifier = {
                              factor = 0
                              any_unit_leader = {
                                    has_unit_leader_flag =
SPA_swayed_leader_loyalty_flag
                              }
                        }
                  }
                  30 = { # Nationalists suppress the leftist strikes
                        activate_mission = SPR_suppress_the_strikes_mission
                  }
            }
      }
}
     trigger = {
           NOT = { has_global_flag = spanish_civil_war }
     }
is_triggered_only = yes
     hidden = yes
      immediate = {
            random_list = {
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              OR = {
                                    171 = { check_variable = { var =
SPA_garrison_control value = 2 compare = less_than } }
                                    is_historical_focus_on = yes
                              }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              171 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              NOT = { has_country_flag =
SPA_secure_the_northern_garrisons_flag }
                        }
                        modifier = {
                              factor = 10
                              171 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 20
                              has_completed_focus = SPR_the_popular_front
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_galicia_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              790 = { check_variable = { var = SPA_garrison_control
value = 2 compare = less_than } }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              790 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 10
                              790 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 10
                              has_completed_focus = SPA_a_great_spain
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_asturias_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              OR = {
                                    174 = { check_variable = { var =
SPA_garrison_control value = 2 compare = less_than } }
                                    is_historical_focus_on = yes
                              }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              174 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              NOT = { has_country_flag =
SPA_secure_the_northern_garrisons_flag }
                        }
                        modifier = {
                              factor = 10
                              174 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 20
                              has_completed_focus = SPR_the_popular_front
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_leon_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              OR = {
                                    791 = { check_variable = { var =
SPA_garrison_control value = 2 compare = less_than } }
                                    is_historical_focus_on = yes
                              }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              791 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              NOT = { has_country_flag =
SPA_secure_the_northern_garrisons_flag }
                        }
                        modifier = {
                              factor = 10
                              791 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 20
                              has_completed_focus = SPR_the_popular_front
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_valladolid_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              OR = {
                                    176 = { check_variable = { var =
SPA_garrison_control value = 2 compare = less_than } }
                                    is_historical_focus_on = yes
                              }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              176 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              NOT = { has_country_flag =
SPA_secure_the_northern_garrisons_flag }
                        }
                        modifier = {
                              factor = 10
                              176 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 20
                              has_completed_focus = SPR_the_popular_front
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_burgos_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              792 = { check_variable = { var = SPA_garrison_control
value = 2 compare = less_than } }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              792 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 10
                              792 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 10
                              has_completed_focus = SPA_a_great_spain
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_pais_vasco_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              OR = {
                                    172 = { check_variable = { var =
SPA_garrison_control value = 2 compare = less_than } }
                                    is_historical_focus_on = yes
                              }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              172 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              NOT = { has_country_flag =
SPA_secure_the_northern_garrisons_flag }
                        }
                        modifier = {
                              factor = 10
                              172 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 20
                              has_completed_focus = SPR_the_popular_front
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_navarra_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              OR = {
                                    166 = { check_variable = { var =
SPA_garrison_control value = 2 compare = less_than } }
                                   is_historical_focus_on = yes
                             }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              166 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              NOT = { has_country_flag =
SPA_secure_the_northern_garrisons_flag }
                        }
                        modifier = {
                              factor = 10
                              166 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 20
                              has_completed_focus = SPR_the_popular_front
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_western_aragon_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              794 = { check_variable = { var = SPA_garrison_control
value = 2 compare = less_than } }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              794 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 10
                              794 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 10
                              has_completed_focus = SPA_a_great_spain
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_eastern_aragon_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              165 = { check_variable = { var = SPA_garrison_control
value = 2 compare = less_than } }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              165 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 10
                              165 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 10
                              has_completed_focus = SPA_a_great_spain
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_catalunya_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              OR = {
                                    788 = { check_variable = { var =
SPA_garrison_control value = 2 compare = less_than } }
                                    is_historical_focus_on = yes
                              }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              788 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              NOT = { has_country_flag =
SPA_secure_the_northern_garrisons_flag }
                        }
                        modifier = {
                              factor = 10
                              788 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 20
                              has_completed_focus = SPR_the_popular_front
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_salamanca_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              41 = { check_variable = { var = SPA_garrison_control
value = 2 compare = less_than } }
                        }
                        modifier = {
                              factor = 10
                              has_completed_focus = SPA_a_great_spain
                              41 = { check_variable = { var = SPA_garrison_control
value = 2 compare = greater_than } }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              41 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 10
                              41 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        activate_mission =
SPA_expand_influence_in_the_madrid_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              793 = { check_variable = { var = SPA_garrison_control
value = 2 compare = less_than } }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              793 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 10
                              793 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 10
                              has_completed_focus = SPA_a_great_spain
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_guadalajara_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              167 = { check_variable = { var = SPA_garrison_control
value = 2 compare = less_than } }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              167 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 10
                              167 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 10
                              has_completed_focus = SPA_a_great_spain
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_valencia_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              OR = {
                                    170 = { check_variable = { var =
SPA_garrison_control value = 2 compare = less_than } }
                                    AND = {
                                          is_historical_focus_on = yes
                                          170 = { check_variable = { var =
SPA_garrison_control value = 4 compare = less_than } }
                                    }
                              }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              is_historical_focus_on = yes
                              is_ai = yes
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              170 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 10
                              170 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 20
                              has_completed_focus = SPR_the_popular_front
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_extremadura_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              175 = { check_variable = { var = SPA_garrison_control
value = 2 compare = less_than } }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              175 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 10
                              175 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 10
                              has_completed_focus = SPA_a_great_spain
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_ciudad_real_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              168 = { check_variable = { var = SPA_garrison_control
value = 2 compare = less_than } }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              168 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 10
                              168 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 10
                              has_completed_focus = SPA_a_great_spain
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_murcia_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              OR = {
                                    169 = { check_variable = { var =
SPA_garrison_control value = 2 compare = less_than } }
                                    AND = {
                                          is_historical_focus_on = yes
                                          169 = { check_variable = { var =
SPA_garrison_control value = 4 compare = less_than } }
                                    }
                              }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              is_historical_focus_on = yes
                              is_ai = yes
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              169 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 10
                              169 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 20
                              has_completed_focus = SPR_the_popular_front
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_sevilla_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              OR = {
                                    789 = { check_variable = { var =
SPA_garrison_control value = 2 compare = less_than } }
                                    AND = {
                                          is_historical_focus_on = yes
                                          789 = { check_variable = { var =
SPA_garrison_control value = 3 compare = less_than } }
                                    }
                              }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              is_historical_focus_on = yes
                              is_ai = yes
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              789 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 10
                              789 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 20
                              has_completed_focus = SPR_the_popular_front
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_cordoba_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              173 = { check_variable = { var = SPA_garrison_control
value = 2 compare = less_than } }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              173 = { check_variable = { var = SPA_garrison_control
value = 4 compare = equals } }
                        }
                        modifier = {
                              factor = 10
                              173 = { has_state_flag =
SPR_ai_recently_expanded_influence_flag }
                        }
                        modifier = {
                              factor = 10
                              has_completed_focus = SPA_a_great_spain
                              is_historical_focus_on = yes
                        }
                        activate_mission =
SPA_expand_influence_in_the_granada_garrison_mission
                  }
                  20 = {
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              is_historical_focus_on = no
                              any_owned_state = {
                                    check_variable = { var = SPA_garrison_control
value = 2 compare = greater_than_or_equals }
                              }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPA_a_great_spain
                              is_historical_focus_on = yes
                              OR = {
                                    any_owned_state = {
                                          NOT = { state = 166 }
                                          NOT = { state = 169 }
                                          NOT = { state = 170 }
                                          NOT = { state = 171 }
                                          NOT = { state = 172 }
                                          NOT = { state = 174 }
                                          NOT = { state = 176 }
                                          NOT = { state = 788 }
                                          NOT = { state = 789 }
                                          NOT = { state = 791 }
                                          check_variable = { var =
SPA_garrison_control value = 2 compare = greater_than_or_equals }
                                    }
                                    any_owned_state = {
                                          OR = {
                                                state = 169
                                                state = 170
                                          }
                                          check_variable = { var =
SPA_garrison_control value = 4 compare = equals }
                                    }
                                    789 = {
                                          check_variable = { var =
SPA_garrison_control value = 3 compare = greater_than_or_equals }
                                    }
                              }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              is_historical_focus_on = no
                              any_owned_state = {
                                    check_variable = { var = SPA_garrison_control
value = 4 compare = less_than }
                              }
                        }
                        modifier = {
                              factor = 0
                              has_completed_focus = SPR_the_popular_front
                              is_historical_focus_on = yes
                              any_owned_state = {
                                    OR = {
                                          state = 166
                                          state = 169
                                          state = 170
                                          state = 171
                                          state = 172
                                          state = 174
                                          state = 176
                                          state = 788
                                          state = 789
                                          state = 791
                                    }
                                    check_variable = { var = SPA_garrison_control
value = 4 compare = less_than }
                              }
                        }
                        country_event = { id = lar_spain.5 days = 1 random_days = 9
}
                  }
            }
      }
}
is_triggered_only = yes
immediate = {
      hidden_effect = {
            set_global_flag = scw_frontlines_solidify
            remove_ideas = SPA_planned_uprising
            every_state = {
                  limit = {
                        OR = {
                              state = 41
                              state = 165
                              state = 166
                              state = 167
                              state = 168
                              state = 169
                              state = 170
                              state = 171
                              state = 172
                              state = 173
                              state = 174
                              state = 175
                              state = 176
                              state = 788
                              state = 789
                              state = 790
                              state = 791
                              state = 792
                              state = 793
                              state = 794
                        }
                  }
                  set_state_flag = SPR_unplanned_offensive_flag
                  add_dynamic_modifier = {
                        modifier = unplanned_offensive
                  }
            }
      }
}
option = {
      name = lar_spain.6.a
      if = {
            limit = {
                  tag = SPA
            }
            effect_tooltip = { remove_ideas = SPA_planned_uprising }
      }
      effect_tooltip = {
            every_state = {
                  limit = {
                        OR = {
                              state = 41
                              state = 165
                              state = 166
                              state = 167
                                   state   =   168
                                   state   =   169
                                   state   =   170
                                   state   =   171
                                   state   =   172
                                   state   =   173
                                   state   =   174
                                   state   =   175
                                   state   =   176
                                   state   =   788
                                   state   =   789
                                   state   =   790
                                   state   =   791
                                   state   =   792
                                   state   =   793
                                   state   =   794
                             }
                       }
                       add_dynamic_modifier = {
                             modifier = unplanned_offensive
                       }
                 }
           }
           custom_effect_tooltip = lar_spain.6_tt
     }
}
fire_only_once = yes
is_triggered_only = yes
     immediate = {
           hidden_effect = {
                 SPB = {
                       set_politics = {
                             ruling_party      = neutrality
                       }
                       set_popularities =      {
                             democratic =      13
                             neutrality =      82
                             fascism = 5
                        }
                        set_party_name = { ideology = neutrality long_name =
SPR_neutrality_party_long name = SPR_neutrality_party }
                  }
                  if = { # If SPA owns both of the historical Carlist states
                        limit = {
                              controls_state = 172
                              controls_state = 176
                        }
                        every_state = {
                              limit = {
                                    OR = {
                                          state = 172
                                          state = 176
                                    }
                                    is_controlled_by = ROOT
                              }
                              SPB = {
                                    transfer_state = PREV
                              }
                        }
                        if = {
                              limit = {
                                    num_of_controlled_states > 10
                                    controls_state = 791
                              }
                              SPB = {
                                    transfer_state = 791
                              }
                        }
                        if = {
                              limit = {
                                    num_of_controlled_states > 11
                                    controls_state = 174
                              }
                              SPB = {
                                    transfer_state = 174
                              }
                        }
                        if = {
                              limit = {
                                    num_of_controlled_states > 13
                                    controls_state = 171
                              }
                              SPB = {
                                    transfer_state = 171
                              }
                        }
                        if = {
                              limit = {
                                    num_of_controlled_states > 14
                                    has_global_flag = scw_early_end
                              }
                              random_owned_state = {
                                    limit = {
                                          any_neighbor_state = {
                                                OR = {
                                                      state = 171
                                                      state = 172
                                                    state = 174
                                                    state = 176
                                                    state = 791
                                              }
                                        }
                                        has_state_flag = SPR_core_of_spain_flag
                                        is_controlled_by = ROOT
                                        is_capital = no
                                  }
                                  SPB = {
                                        transfer_state = PREV
                                  }
                            }
                            random_owned_state = {
                                  limit = {
                                        any_neighbor_state = {
                                              OR = {
                                                    state = 171
                                                    state = 172
                                                    state = 174
                                                    state = 176
                                                    state = 791
                                              }
                                        }
                                        has_state_flag = SPR_core_of_spain_flag
                                        is_controlled_by = ROOT
                                        is_capital = no
                                  }
                                  SPB = {
                                        transfer_state = PREV
                                  }
                            }
                       }
                 }
                 else_if = { # Fallback if not owning one of the historically
Carlist states
                      limit = {
                            OR = {
                                  AND = {
                                        controls_state = 172
                                        NOT = { controls_state = 176 }
                                  }
                                  AND = {
                                        controls_state = 176
                                        NOT = { controls_state = 172 }
                                  }
                            }
                      }
                      every_state = {
                            limit = {
                                  OR = {
                                        state = 172
                                        state = 176
                                  }
                                  is_controlled_by = ROOT
                            }
                            SPB = {
                                  transfer_state = PREV
                            }
                       }
                 }
                 else_if = { # Fallback if not owning one of the historically
Carlist states
                      limit = {
                            OR = {
                                  AND = {
                                        controls_state = 172
                                        NOT = { controls_state = 176 }
                                  }
                                  AND = {
                                        controls_state = 176
                                        NOT = { controls_state = 172 }
                                  }
                            }
                      }
                      every_state = {
                            limit = {
                                  OR = {
                                        state = 172
                                        state = 176
                                  }
                                  is_controlled_by = ROOT
                            }
                            SPB = {
                                  transfer_state = PREV
                            }
                      }
                      if = {
                            limit = {
                                  num_of_controlled_states > 5
                                  OR = {
                                        controls_state = 171
                                        controls_state = 174
                                        controls_state = 791
                                  }
                            }
                            random_state = {
                                  limit = {
                                        OR = {
                                              state = 171
                                              state = 174
                                              state = 791
                                        }
                                        has_state_flag = SPR_core_of_spain_flag
                                        is_controlled_by = ROOT
                                        is_capital = no
                                  }
                                  SPB = {
                                        transfer_state = PREV
                                  }
                            }
                      }
                      else = {
                            random_state = {
                                  limit = {
                                        NOT = { state = 178 }
                                        NOT = { state = 177 }
                                        has_state_flag = SPR_core_of_spain_flag
                                         is_controlled_by = ROOT
                                         is_capital = no
                                   }
                                   SPB = {
                                         transfer_state = PREV
                                   }
                             }
                       }
                  }
                  else_if = { # You're not getting out of a civil war by
voluntarily giving up the targetable locations, pal!
                        limit = {
                              NOT = {
                                    controls_state = 172
                                    controls_state = 176
                              }
                              OR = {
                                    controls_state = 171
                                    controls_state = 174
                                    controls_state = 791
                              }
                        }
                        random_state = {
                              limit = {
                                    OR = {
                                          state = 171
                                          state = 174
                                          state = 791
                                    }
                                    has_state_flag = SPR_core_of_spain_flag
                                    is_controlled_by = ROOT
                                    is_capital = no
                              }
                              SPB = {
                                    transfer_state = PREV
                              }
                        }
                        if = {
                              limit = {
                                    num_of_controlled_states > 5
                                    OR = {
                                          controls_state = 171
                                          controls_state = 174
                                          controls_state = 791
                                    }
                              }
                              random_state = {
                                    limit = {
                                          OR = {
                                                state = 171
                                                state = 174
                                                state = 791
                                          }
                                          has_state_flag = SPR_core_of_spain_flag
                                          is_controlled_by = ROOT
                                          is_capital = no
                                    }
                                    SPB = {
                                          transfer_state = PREV
                                   }
                             }
                       }
                       else = {
                             random_state = {
                                   limit = {
                                         NOT = { state = 178 }
                                         NOT = { state = 177 }
                                         has_state_flag = SPR_core_of_spain_flag
                                         is_controlled_by = ROOT
                                         is_capital = no
                                   }
                                   SPB = {
                                         transfer_state = PREV
                                   }
                             }
                       }
                  }
                  else_if = { # You're not getting out of a civil war by
voluntarily giving up the targetable locations, pal!
                        limit = {
                              NOT = {
                                    controls_state = 172
                                    controls_state = 176
                                    controls_state = 171
                                    controls_state = 174
                                    controls_state = 791
                              }
                        }
                        random_state = {
                              limit = {
                                    NOT = { state = 178 }
                                    NOT = { state = 177 }
                                    has_state_flag = SPR_core_of_spain_flag
                                    is_controlled_by = ROOT
                                    is_capital = no
                              }
                              SPB = {
                                    transfer_state = PREV
                              }
                        }
                        if = {
                              limit = {
                                    num_of_controlled_states > 5
                              }
                              random_state = {
                                    limit = {
                                          NOT = { state = 178 }
                                          NOT = { state = 177 }
                                          has_state_flag = SPR_core_of_spain_flag
                                          is_controlled_by = ROOT
                                          is_capital = no
                                    }
                                    SPB = {
                                          transfer_state = PREV
                                    }
                              }
                        }
                  }
                  else = {
                        random_state = {
                              limit = {
                                    has_state_flag = SPR_core_of_spain_flag
                                    is_controlled_by = ROOT
                                    is_capital = no
                              }
                              SPB = {
                                    transfer_state = PREV
                              }
                        }
                  }
                  SPB = {
                        random_owned_state = {
                              limit = {
                                    is_controlled_by = SPB
                                    is_core_of = SPB
                                    NOT = {
                                          state = 177
                                          state = 178
                                    }
                              }
                              SPB = { set_capital = { state = PREV } }
                        }
                        inherit_technology = SPA
                        set_stability = 0.6
                        set_war_support = 0.5
                        division_template = {
                              name = "Requeté Carlista"
                              template_counter = 8
                              priority = 1
                              division_names_group = SPR_INF_03
                              is_locked = yes
                              regiments = {
                                    infantry = { x = 0 y = 0 }
                                    infantry = { x = 0 y = 1 }
                                    infantry = { x = 0 y = 2 }
                              }
                        }
                        set_division_template_lock = {
                            division_template = "Requeté Carlista"
                            is_locked = no
                        }
                        every_owned_state = {
                              create_unit = {
                                    division = "division_template = \"Requeté
Carlista\" start_experience_factor = 0.3"
                                    owner = SPB
                              }
                              create_unit = {
                                    division = "division_template = \"Requeté
Carlista\" start_experience_factor = 0.3"
                                    owner = SPB
                              }
                              create_unit = {
                                    division = "division_template = \"Requeté
Carlista\" start_experience_factor = 0.3"
                                    owner = SPB
                              }
                              create_unit = {
                                    division = "division_template = \"Requeté
Carlista\" start_experience_factor = 0.3"
                                    owner = SPB
                              }
                        }
                        if = {
                              limit = {
                                    NOT = {
                                          owns_state = 791
                                          owns_state = 174
                                          owns_state = 171
                                    }
                              }
                              every_owned_state = {
                                    create_unit = {
                                          division = "division_template = \"Requeté
Carlista\" start_experience_factor = 0.3"
                                          owner = SPB
                                    }
                                    create_unit = {
                                          division = "division_template = \"Requeté
Carlista\" start_experience_factor = 0.3"
                                          owner = SPB
                                    }
                              }
                        }
                        if = {
                              limit = {
                                    owns_state = 172
                              }
                              set_capital = { state = 172 }
                        }
                        else = {
                              random_owned_state = {
                                    SPB = {
                                          set_capital = { state = PREV }
                                    }
                              }
                        }
                  }
                  add_popularity = {
                      ideology = neutrality
                      popularity = -0.15
                  }
                  add_stability = -0.1
                  delete_unit_template_and_units = {
                        division_template = "Requeté Carlista"
                  }
                  transfer_units_fraction = {
                        target = SPB
                        stockpile_ratio = 0.2
                        army_ratio = 0.1
                        navy_ratio = 0.1
                        air_ratio = 0.1
                        keep_unit_leaders = {
                       }
                       keep_unit_leaders_trigger = {
                             has_trait = trait_SPA_falangist_loyalties
                       }
                  }
                  every_unit_leader = {
                        limit = {
                              has_trait = trait_SPA_carlist_loyalties
                        }
                        remove_unit_leader_trait = trait_SPA_carlist_loyalties
                        set_nationality = {
                              character = THIS
                              target_country = SPB
                        }
                  }
                  every_unit_leader = {
                        limit = {
                              has_trait = trait_SPA_falangist_loyalties
                        }
                        remove_unit_leader_trait = trait_SPA_falangist_loyalties
                  }
                  set_global_flag = SPR_carlist_uprising_flag
                  set_global_flag = { flag = SPR_civil_war_startup value = 1 days =
3 } # Make AI avoid attacking for a few days
                  SPB = {
                        every_unit_leader = {
                              limit = {
                                    has_trait = trait_SPA_nationalist_sympathies
                              }
                              remove_unit_leader_trait =
trait_SPA_nationalist_sympathies
                        }
                        declare_war_on = {
                            target = ROOT
                            type = civil_war
                        }
                        add_civil_war_target = ROOT
                        add_ai_strategy = {
                              type = antagonize
                              id = SPA
                              value = 200
                        }
                        declare_war_on = {
                            target = SPD
                            type = civil_war
                        }
                        add_civil_war_target = SPD
                       add_ai_strategy = {
                             type = antagonize
                             id = SPD
                             value = 200
                       }
                       if = {
                             limit = {
                                   country_exists = SPC
                             }
                             declare_war_on = {
                                 target = SPC
                                 type = civil_war
                             }
                             add_civil_war_target = SPC
                             add_ai_strategy = {
                                   type = antagonize
                                   id = SPC
                                   value = 200
                             }
                        }
                  }
                  every_other_country = {
                        add_ai_strategy = {
                              type = support
                              id = SPB
                              value = -200
                        }
                        add_ai_strategy = {
                              type = protect
                              id = SPB
                              value = -200
                        }
                        add_ai_strategy = {
                              type = befriend
                              id = SPB
                              value = -200
                        }
                        add_ai_strategy = {
                              type = alliance
                              id = SPB
                              value = -200
                        }
                  }
                  SPB = {
                        load_focus_tree = {
                              tree = spanish_focus
                              keep_completed = no
                        }
                        unlock_national_focus = SPA_a_great_spain
                        unlock_national_focus =
SPA_hand_over_the_ceda_campaign_chest
                        unlock_national_focus = SPA_negotiate_carlist_support
                        unlock_national_focus = SPA_the_army_of_africa
                        unlock_national_focus = SPA_secure_the_northern_garrisons
                        if = {
                              limit = {
                                    SPA = { has_completed_focus = SPA_sin_paquito }
                              }
                              unlock_national_focus = SPA_sin_paquito
                        }
                        if = {
                              limit = {
                                    SPA = { has_completed_focus = SPA_con_paquito }
                              }
                              unlock_national_focus = SPA_con_paquito
                        }
                        complete_national_focus = SPA_supremacy_of_the_communion
                        complete_national_focus =
SPA_prepare_the_carlist_insurrection
                        complete_national_focus =
SPA_contact_the_union_militar_espanola
                       complete_national_focus   = SPA_head_the_junta_nacional
                       complete_national_focus   = SPA_unite_the_requetes
                       unlock_national_focus =   SPA_no_compromise_on_carlist_ideals
                       add_timed_idea = { idea   = SPA_death_before_surrender days =
900 }
                        every_unit_leader = {
                              limit = {
                                    has_trait = trait_SPA_carlist_loyalties
                              }
                              remove_unit_leader_trait =
trait_SPA_carlist_loyalties
                        }
                  }
                  if = {
                        limit = {
                              has_idea = SPA_carlism_1
                        }
                        remove_ideas = SPA_carlism_1
                  }
                  if = {
                        limit = {
                              has_idea = SPA_carlism_2
                        }
                        remove_ideas = SPA_carlism_2
                  }
                  if = {
                        limit = {
                              has_idea = SPA_carlism_3
                        }
                        remove_ideas = SPA_carlism_3
                  }
                  if = {
                        limit = {
                              has_idea = SPA_carlism_4
                        }
                        remove_ideas = SPA_carlism_4
                  }
                  if = {
                        limit = {
                              has_idea = SPA_carlism_5
                        }
                        remove_ideas = SPA_carlism_5
                  }
     option = {
           name = lar_spain.7.a
           effect_tooltip = {
                 add_popularity = {
                     ideology = neutrality
                     popularity = -0.15
                 }
                 add_stability = -0.1
                 delete_unit_template_and_units = {
                       division_template = "Requeté Carlista"
                 }
                 transfer_units_fraction = {
                       target = SPB
                       stockpile_ratio = 0.2
                       army_ratio = 0.1
                       navy_ratio = 0.1
                       air_ratio = 0.1
                       keep_unit_leaders = {
                       }
                       keep_unit_leaders_trigger = {
                             has_trait = trait_SPA_falangist_loyalties
                       }
                 }
                 every_unit_leader = {
                       limit = {
                             has_trait = trait_SPA_carlist_loyalties
                       }
                       remove_unit_leader_trait = trait_SPA_carlist_loyalties
                       set_nationality = {
                             character = THIS
                             target_country = SPB
                       }
                 }
                 every_unit_leader = {
                       limit = {
                             has_trait = trait_SPA_falangist_loyalties
                       }
                       remove_unit_leader_trait = trait_SPA_falangist_loyalties
                 }
                 SPB = {
                       declare_war_on = {
                           target = ROOT
                           type = civil_war
                       }
                       add_civil_war_target = ROOT
                       declare_war_on = {
                           target = SPD
                           type = civil_war
                       }
                       add_civil_war_target = SPD
                       if = {
                             limit = {
                                   country_exists = SPC
                             }
                             declare_war_on = {
                                 target = SPC
                                 type = civil_war
                             }
                             add_civil_war_target = SPC
                       }
                 }
           }
     }
}
is_triggered_only = yes
      immediate = {
            hidden_effect = {
                  every_other_country = {
                        limit = {
                              ROOT = {
                                    has_volunteers_amount_from = {
                                        tag = PREV
                                        count > 0
                                    }
                              }
                        }
                        recall_volunteers_from = ROOT
                  }
                  set_global_flag = SPR_carlist_uprising_flag
                  set_global_flag = { flag = SPR_civil_war_startup value = 1 days =
3 } # Make AI avoid attacking for a few days
                  if = {
                        limit = {
                              NOT = { has_government = neutrality }
                        }
                        set_politics = {
                              ruling_party = neutrality
                        }
                  }
                  SPB = {
                        clr_country_flag = SPR_carlist_spain_flag
                        drop_cosmetic_tag = yes
                        set_country_flag = SPR_nationalist_spain_flag
                        if = {
                              limit = {
                                    has_game_rule = {
                                          rule = spr_fragmentation_status
                                          option = SPR_EU4
                                    }
                              }
                              set_cosmetic_tag = SPR_nationalist_castille
                        }
                        else = {
                              set_cosmetic_tag = SPR_nationalist_spain
                        }
                  }
                  clr_country_flag = SPR_nationalist_spain_flag
                  drop_cosmetic_tag = yes
                  set_country_flag = SPR_carlist_spain_flag
                  if = {
                        limit = {
                              has_game_rule = {
                                    rule = spr_fragmentation_status
                                    option = SPR_EU4
                              }
                        }
                        set_cosmetic_tag = SPR_carlist_castille
                  }
                  else = {
                        set_cosmetic_tag = SPR_carlist_spain
                  }
                  if = {
                        limit = {
                              any_state = {
                                    is_controlled_by = ROOT
                                    has_state_flag = SPA_carlist_cell_flag
                              }
                        }
                        every_state = {
                              limit = {
                                    NOT = { has_state_flag =
SPA_carlist_cell_flag }
                                    is_controlled_by = ROOT
                              }
                              SPA = {
                                    transfer_state = PREV
                              }
                        }
                  }
                  else_if = {
                        limit = {
                              OR = {
                                    controls_state = 172
                                    controls_state = 176
                              }
                        }
                        every_state = {
                              limit = {
                                    NOT = { state = 172 }
                                    NOT = { state = 176 }
                                    NOT = { has_state_flag =
SPA_carlist_cell_flag }
                                    is_controlled_by = ROOT
                              }
                              SPA = {
                                    transfer_state = PREV
                              }
                        }
                  }
                  else = {
                        random_owned_state = {
                              limit = {
                                    is_controlled_by = ROOT
                              }
                              set_state_flag = SPA_carlist_cell_flag
                        }
                        random_owned_state = {
                              limit = {
                                    is_controlled_by = ROOT
                                    NOT = { has_state_flag =
SPA_carlist_cell_flag }
                              }
                              set_state_flag = SPA_carlist_cell_flag
                        }
                        every_state = {
                              limit = {
                                    NOT = { has_state_flag =
SPA_carlist_cell_flag }
                                   is_controlled_by = ROOT
                             }
                             SPA = {
                                   transfer_state = PREV
                             }
                        }
                  }
                  SPA = {
                        inherit_technology = SPB
                        set_politics = {
                              ruling_party = fascism
                              last_election = "1933.4.26"
                              election_frequency = 48
                              elections_allowed = no
                        }
                        set_popularities = {
                              fascism = 80
                              democratic = 15
                              neutrality = 5
                        }
                        set_stability = 0.6
                        set_war_support = 0.5
                        if = {
                              limit = {
                                    owns_state = 172
                              }
                              set_capital = { state = 172 }
                        }
                        else = {
                              random_owned_state = {
                                    limit = {
                                          is_controlled_by = SPA
                                          is_core_of = SPA
                                          NOT = {
                                                state = 177
                                                state = 178
                                          }
                                    }
                                    SPA = {
                                          set_capital = { state = PREV }
                                    }
                              }
                        }
                        delete_unit_template_and_units = {
                              division_template = "Requeté Carlista"
                        }
                        set_party_name = { ideology = neutrality long_name =
SPR_neutrality_military_junta_party_long name = SPR_neutrality_military_junta_party
}
                  }
                  set_party_name = { ideology = neutrality long_name =
SPR_neutrality_party_long name = SPR_neutrality_party }
                  add_popularity = {
                      ideology = fascism
                      popularity = -0.35
                  }
                  add_stability = -0.1
                  transfer_units_fraction = {
                        target = SPA
                       stockpile_ratio = 0.4
                       army_ratio = 0.3
                       navy_ratio = 0.3
                       air_ratio = 0.3
                       keep_unit_leaders = {
                       }
                       keep_unit_leaders_trigger = {
                             has_trait = trait_SPA_carlist_loyalties
                       }
                  }
                  set_division_template_lock = {
                      division_template = "Requeté Carlista"
                      is_locked = no
                  }
                  every_unit_leader = {
                        limit = {
                              has_trait = trait_SPA_falangist_loyalties
                        }
                        remove_unit_leader_trait = trait_SPA_falangist_loyalties
                        set_nationality = {
                              character = THIS
                              target_country = SPA
                        }
                  }
                  every_unit_leader = {
                        limit = {
                              has_trait = trait_SPA_carlist_loyalties
                        }
                        remove_unit_leader_trait = trait_SPA_carlist_loyalties
                  }
                  SPA = {
                        every_unit_leader = {
                              limit = {
                                    has_trait = trait_SPA_falangist_loyalties
                              }
                              remove_unit_leader_trait =
trait_SPA_falangist_loyalties
                        }
                        every_unit_leader = {
                              limit = {
                                    has_trait = trait_SPA_nationalist_sympathies
                              }
                              remove_unit_leader_trait =
trait_SPA_nationalist_sympathies
                        }
                        declare_war_on = {
                            target = ROOT
                            type = civil_war
                        }
                        add_civil_war_target = ROOT
                        add_ai_strategy = {
                              type = antagonize
                              id = SPB
                              value = 200
                        }
                        declare_war_on = {
                            target = SPD
                            type = civil_war
                       }
                       add_civil_war_target = SPD
                       add_ai_strategy = {
                             type = antagonize
                             id = SPD
                             value = 200
                       }
                       if = {
                             limit = {
                                   country_exists = SPC
                             }
                             declare_war_on = {
                                 target = SPC
                                 type = civil_war
                             }
                             add_civil_war_target = SPC
                             add_ai_strategy = {
                                   type = antagonize
                                   id = SPC
                                   value = 200
                             }
                        }
                  }
                  every_other_country = {
                        add_ai_strategy = {
                              type = support
                              id = SPB
                              value = -200
                        }
                        add_ai_strategy = {
                              type = protect
                              id = SPB
                              value = -200
                        }
                        add_ai_strategy = {
                              type = befriend
                              id = SPB
                              value = -200
                        }
                        add_ai_strategy = {
                              type = alliance
                              id = SPB
                              value = -200
                        }
                  }
                  SPA = {
                        load_focus_tree = {
                              tree = spanish_focus
                              keep_completed = no
                        }
                        unlock_national_focus = SPA_a_great_spain
                        unlock_national_focus =
SPA_hand_over_the_ceda_campaign_chest
                        unlock_national_focus = SPA_negotiate_carlist_support
                        unlock_national_focus = SPA_the_army_of_africa
                        unlock_national_focus = SPA_secure_the_northern_garrisons
                        unlock_national_focus = SPA_sin_paquito
                        complete_national_focus   = SPA_the_phalanx_ascendant
                        complete_national_focus   =
SPA_secure_the_national_defense_council
                        complete_national_focus   = SPA_suspend_the_constitution
                        unlock_national_focus =   SPA_eliminate_the_carlists
                        complete_national_focus   =
SPA_primo_de_rivera_prisoner_exchange
                        complete_national_focus   = SPA_establish_the_directory
                        add_timed_idea = { idea   = SPA_death_before_surrender days =
900 }
                  }
option = {
      name = lar_spain.8.a
      effect_tooltip = {
            if = {
                  limit = {
                        NOT = { has_government = neutrality }
                  }
                  set_politics = {
                        ruling_party = neutrality
                  }
            }
            add_popularity = {
                ideology = fascism
                popularity = -0.35
            }
            add_stability = -0.1
            transfer_units_fraction = {
                  target = SPA
                  stockpile_ratio = 0.4
                  army_ratio = 0.3
                  navy_ratio = 0.3
                  air_ratio = 0.3
                  keep_unit_leaders = {
                 }
                 keep_unit_leaders_trigger = {
                       has_trait = trait_SPA_carlist_loyalties
                 }
           }
           every_unit_leader = {
                 limit = {
                       has_trait = trait_SPA_falangist_loyalties
                 }
                 remove_unit_leader_trait = trait_SPA_falangist_loyalties
                 set_nationality = {
                       character = THIS
                       target_country = SPA
                 }
           }
           every_unit_leader = {
                 limit = {
                       has_trait = trait_SPA_carlist_loyalties
                 }
                 remove_unit_leader_trait = trait_SPA_carlist_loyalties
           }
           set_division_template_lock = {
               division_template = "Requeté Carlista"
               is_locked = no
           }
           SPA = {
                 declare_war_on = {
                     target = ROOT
                     type = civil_war
                 }
                 add_civil_war_target = ROOT
                 declare_war_on = {
                            target = SPD
                            type = civil_war
                       }
                       add_civil_war_target = SPD
                       if = {
                             limit = {
                                   country_exists = SPC
                             }
                             declare_war_on = {
                                 target = SPC
                                 type = civil_war
                             }
                             add_civil_war_target = SPC
                       }
                  }
            }
            random_state = {
                  limit = {
                        has_state_flag = SPA_union_militar_flag
                  }
                  create_unit = {
                        division = "division_template = \"Requeté Carlista\"
start_experience_factor = 0.3"
                        owner = SPB
                        allow_spawning_on_enemy_provs = yes
                        count = 5
                  }
            }
      }
}
fire_only_once = yes
is_triggered_only = yes
      immediate = {
            hidden_effect = {
                  set_global_flag = SPR_anarchist_uprising_flag
                  set_global_flag = { flag = SPR_civil_war_startup value = 1 days =
3 } # Make AI avoid attacking for a few days
                  if = { #POUM UPRISING (SUPPORTED BY SOVIET RIGHT OPPOSITION)
                        limit = {
                              has_global_flag = SOV_covert_support_for_poum_flag
                        }
                        if = {
                              limit = {
                                    communism > 0.03
                              }
                              set_political_party = {
                                  ideology = communism
                                  popularity = 3
                              }
                        }
                        add_popularity = {
                            ideology = neutrality
                            popularity = -0.05
                        }
                        SPC = {
                              set_rule = {
                                    can_generate_female_aces = yes
                              }
                              set_politics = {
                                    ruling_party = communism
                              }
                              set_popularities = {
                                    communism = 58
                                    democratic = 2
                                    neutrality = 40
                              }
                              create_country_leader = {
                                    name = "Julián Gorkin"
                                    desc = "POLITICS_JULIAN_GORKIN_DESC"
                                    picture = "GFX_portrait_SPR_julian_gorkin"
                                    expire = "1965.1.1"
                                    ideology = anarchist_communism
                                    traits = {
                                          militant_socialist
                                    }
                              }
                              #Check for covert depots from Soviets
                              if = {
                                    limit = {
                                          has_global_flag =
SOV_poum_has_covert_depots_from_soviets_flag
                                    }
                                    add_equipment_to_stockpile = {
                                          type = infantry_equipment
                                          amount = 6000
                                          producer = SOV
                                    }
                                    add_equipment_to_stockpile = {
                                          type = support_equipment
                                          amount = 600
                                          producer = SOV
                                    }
                                    add_equipment_to_stockpile = {
                                          type = artillery_equipment
                                          amount = 120
                                          producer = SOV
                                    }
                                   add_equipment_to_stockpile = {
                                         type = motorized_equipment
                                         amount = 60
                                         producer = SOV
                                   }
                                   add_equipment_to_stockpile = {
                                         type = train_equipment
                                         amount = 6
                                         producer = SOV
                                   }
                                   add_opinion_modifier = {
                                         target = SOV
                                         modifier = SOV_sent_us_weapons
                                   }
                             }
                       }
                       if = { #If Right Opposition is still under Stalin's rule,
volunteers come back
                              limit = {
                                    SOV = { has_completed_focus =
SOV_covert_support_for_spanish_poum }
                                    SPD = {
                                          has_volunteers_amount_from = {
                                                tag = SOV
                                                count > 0
                                          }
                                    }
                              }
                              SOV = {     recall_volunteers_from = SPD }
                        }
                  }
                  else = { #REGULAR ANARCHIST UPRISING
                        if = {
                              limit = {
                                    neutrality > 0.03
                              }
                              set_political_party = {
                                  ideology = neutrality
                                  popularity = 3
                              }
                        }
                        add_popularity = {
                            ideology = communism
                            popularity = -0.05
                        }
                        SPC = {
                              set_rule = {
                                  can_puppet = no
                                  can_create_factions = no
                                  can_join_factions = no
                                  can_boost_own_ideology = no
                                    can_generate_female_aces = yes
                                    can_create_collaboration_government = no
                              }
                              set_politics = {
                                    ruling_party = neutrality
                              }
                              set_popularities = {
                                    communism = 40
                 democratic = 2
                 neutrality = 58
           }
           create_country_leader = {
                 name = "Anarchist Commune"
                 desc = "POLITICS_ANARCHIST_COMMUNE_DESC"
                 picture = "GFX_portrait_SPR_anarchist_commune"
                 expire = "1965.1.1"
                 ideology = anarchism
                 traits = {
                       our_right_to_survive
                 }
           }
      }
}
if = {
      limit = {
            165 = {
                  is_capital = yes
            }
      }
      random_owned_controlled_state = {
            limit = {
                  NOT = {
                        state = 165
                  }
            }
            ROOT = {
                  set_capital = {
                        state = PREV
                  }
            }
      }
if = {
      limit = {
            OR = {
                  controls_state = 165
                  controls_state = 794
                  controls_state = 166
            }
      }
      every_state = {
            limit = {
                  OR = {
                        state = 165
                        state = 794
                        state = 166
                  }
                  is_capital = no
                  is_controlled_by = ROOT
            }
            SPC = {
                  transfer_state = PREV
            }
      }
      if = {
     limit = {
           SPC = {
                 NOT = {
                       AND = {
                             controls_state = 165
                             controls_state = 794
                             controls_state = 166
                       }
                 }
           }
           num_of_controlled_states > 8
     }
     random_state = {
           limit = {
                 NOT = { state = 178 }
                 NOT = { state = 177 }
                 any_neighbor_state = {
                       OR = {
                             state = 165
                             state = 794
                             state = 166
                       }
                       is_owned_by = SPC
                 }
                 has_state_flag = SPR_core_of_spain_flag
                 is_controlled_by = ROOT
                 is_capital = no
           }
           SPC = {
                 transfer_state = PREV
           }
     }
}
if = {
      limit = {
            num_of_controlled_states > 15
            has_global_flag = scw_early_end
      }
      SPC = {
            transfer_state = 167
      }
      random_owned_state = {
            limit = {
                  any_neighbor_state = {
                        OR = {
                              state = 165
                              state = 794
                              state = 166
                              state = 167
                        }
                  }
                  has_state_flag = SPR_core_of_spain_flag
                  is_controlled_by = ROOT
                  is_capital = no
            }
            SPC = {
                  transfer_state = PREV
            }
      }
                             random_owned_state = {
                                   limit = {
                                         any_neighbor_state = {
                                               OR = {
                                                     state = 165
                                                     state = 794
                                                     state = 166
                                                     state = 167
                                               }
                                         }
                                         has_state_flag = SPR_core_of_spain_flag
                                         is_controlled_by = ROOT
                                         is_capital = no
                                   }
                                   SPC = {
                                         transfer_state = PREV
                                   }
                             }
                        }
                  }
                  else = { # You're not getting out of a civil war by voluntarily
giving up the targetable locations, pal!
                        random_state = {
                              limit = {
                                    NOT = { state = 178 }
                                    NOT = { state = 177 }
                                    has_state_flag = SPR_core_of_spain_flag
                                    is_controlled_by = ROOT
                                    is_capital = no
                              }
                              SPC = {
                                    transfer_state = PREV
                              }
                        }
                        if = {
                              limit = {
                                    num_of_controlled_states > 3
                              }
                              random_state = {
                                    limit = {
                                          NOT = { state = 178 }
                                          NOT = { state = 177 }
                                          has_state_flag = SPR_core_of_spain_flag
                                          is_controlled_by = ROOT
                                          is_capital = no
                                    }
                                    SPC = {
                                          transfer_state = PREV
                                    }
                              }
                        }
                  }
                  if = {
                        limit = {
                              SPC = {
                                    owns_state = 165
                              }
                        }
                        SPC = { set_capital = { state = 165 } }
                 }
                 else = {
                       SPC = {
                             random_owned_state = {
                                   limit = {
                                         is_controlled_by = SPC
                                         is_core_of = SPC
                                         NOT = {
                                               state = 177
                                               state = 178
                                         }
                                   }
                                   SPC = { set_capital = { state = PREV } }
                             }
                       }
                 }
                 SPC = {
                       inherit_technology = SPD
                       }
                       else = { #REGULAR ANARCHIST UPRISING
                             set_politics = {
                                   ruling_party = neutrality
                                   last_election = "1933.4.26"
                                   election_frequency = 48
                                   elections_allowed = no
                             }
                             set_popularities = {
                                   neutrality = 80
                                   communism = 15
                                   democratic = 5
                             }
                       }
                        remove_ideas = SPR_the_maximum_concession
                        add_ideas = closed_economy
                        set_stability = 0.6
                        set_war_support = 0.5
                        division_template = { #No matter if POUM or Anarchist
split, what really matters is the triumph of the revolution during the SCW
                              name = "Brigada Anarquista"
                               template_counter = 0
                               priority = 1
                               division_names_group   = SPD_INF_04
                               is_locked = yes
                               regiments = {
                                     infantry = { x   = 0 y = 0 }
                                     infantry = { x   = 0 y = 1 }
                                     infantry = { x   = 0 y = 2 }
                               }
                          }
                          every_owned_state = {
                                create_unit = {
                                      division = "division_template = \"Brigada
Anarquista\"   start_experience_factor = 0 start_equipment_factor = 0.25"
                                      owner = SPC
                                }
                                create_unit = {
                                      division = "division_template = \"Brigada
Anarquista\"   start_experience_factor = 0 start_equipment_factor = 0.25"
                                      owner = SPC
                                }
                                create_unit = {
                                      division = "division_template = \"Brigada
Anarquista\"   start_experience_factor = 0 start_equipment_factor = 0.25"
                                      owner = SPC
                                }
                          }
                          if = {
                                limit = {
                                      num_of_controlled_states < 3
                                }
                                every_owned_state = {
                                      create_unit = {
                                            division = "division_template = \"Brigada
Anarquista\"   start_experience_factor = 0 start_equipment_factor = 0.25"
                                            owner = SPC
                                      }
                                      create_unit = {
                                            division = "division_template = \"Brigada
Anarquista\"   start_experience_factor = 0 start_equipment_factor = 0.25"
                                            owner = SPC
                                      }
                                }
                          }
                          if = {
                                limit = {
                                      OR = {
                                            AND = {
                                                  num_of_controlled_states > 2
                                                  num_of_controlled_states < 4
                                            }
                                            has_global_flag = scw_early_end
                                      }
                                }
                                every_owned_state = {
                                      create_unit = {
                                            division = "division_template = \"Brigada
Anarquista\"   start_experience_factor = 0 start_equipment_factor = 0.25"
                                            owner = SPC
                                   }
                             }
                       }
                 }
                 add_popularity = {
                     ideology = neutrality
                     popularity = -0.25
                 }
                 add_stability = -0.1
                 transfer_units_fraction = {
                       target = SPC
                       stockpile_ratio = 0.2
                       army_ratio = 0.1
                       navy_ratio = 0.1
                       air_ratio = 0.1
                       keep_unit_leaders = {
                       }
                       keep_unit_leaders_trigger = {
                             OR = {
                                   has_trait = trait_SPR_republican_loyalties
                                   has_trait = trait_SPR_stalinist_loyalties
                             }
                       }
                  }
                  every_unit_leader = {
                        limit = {
                              has_trait = trait_SPR_republican_loyalties
                        }
                        remove_unit_leader_trait = trait_SPR_republican_loyalties
                  }
                  every_unit_leader = {
                        limit = {
                              has_trait = trait_SPR_stalinist_loyalties
                        }
                        remove_unit_leader_trait = trait_SPR_stalinist_loyalties
                  }
                  every_unit_leader = {
                        limit = {
                              has_trait = trait_SPR_anti_stalinist_loyalties
                        }
                        remove_unit_leader_trait =
trait_SPR_anti_stalinist_loyalties
                        set_nationality = {
                              character = THIS
                              target_country = SPC
                        }
                  }
                  SPC = {
                        every_unit_leader = {
                              limit = {
                                    has_trait = trait_SPR_anti_stalinist_loyalties
                              }
                              remove_unit_leader_trait =
trait_SPR_anti_stalinist_loyalties
                        }
                        declare_war_on = {
                            target = SPA
                            type = civil_war
                       }
                       add_civil_war_target = SPA
                       add_ai_strategy = {
                             type = antagonize
                             id = SPA
                             value = 200
                       }
                       declare_war_on = {
                           target = SPD
                           type = civil_war
                       }
                       add_civil_war_target = SPD
                       add_ai_strategy = {
                             type = antagonize
                             id = SPD
                             value = 200
                       }
                       if = {
                             limit = {
                                   country_exists = SPB
                             }
                             declare_war_on = {
                                 target = SPB
                                 type = civil_war
                             }
                             add_civil_war_target = SPB
                             add_ai_strategy = {
                                   type = antagonize
                                   id = SPB
                                   value = 200
                             }
                        }
                  }
                  if = {
                        limit = {
                              has_completed_focus =
SPR_the_anti_fascist_workers_revolution
                              NOT = {
                                    has_completed_focus =
SPR_the_stalinist_doctrine
                              }
                        }
                        complete_national_focus = SPR_the_stalinist_doctrine
                  }
                  SPC = {
                        load_focus_tree = {
                              tree = spanish_focus
                              keep_completed = no
                        }
                        set_party_name = { ideology = neutrality long_name =
SPR_neutrality_anarchism_party_long name = SPR_neutrality_anarchism_party }
                        set_party_name = { ideology = communism long_name =
SPR_communism_independent_party_long name = SPR_communism_independent_party }
                        create_country_leader = {
                              name = "Anarchist Commune"
                              desc = "POLITICS_ANARCHIST_COMMUNE_DESC"
                             picture = "GFX_portrait_SPR_anarchist_commune"
                             expire = "1965.1.1"
                             ideology = anarchism
                             traits = {
                                   our_right_to_survive
                             }
                        }
                        unlock_national_focus = SPR_the_popular_front
                        if = {
                              limit = {
                                    SPD = { has_completed_focus =
SPR_secure_the_guardia_civil }
                              }
                              unlock_national_focus = SPR_secure_the_guardia_civil
                        }
                        if = {
                              limit = {
                                    SPD = { has_completed_focus =
SPR_secure_the_guardia_de_asalto }
                              }
                              unlock_national_focus =
SPR_secure_the_guardia_de_asalto
                        }
                        unlock_national_focus = SPR_train_the_union_youth
                        unlock_national_focus = SPR_enlarge_the_weapon_caches
                        unlock_national_focus = SPR_distribute_arms_to_the_people
                        unlock_national_focus = SPR_disband_the_army
                        if = { #POUM UPRISING (SUPPORTED BY SOVIET RIGHT
OPPOSITION)
                              limit = {
                                    has_global_flag =
SOV_covert_support_for_poum_flag
                              }
                              complete_national_focus =
SPR_the_anti_fascist_workers_revolution
                              complete_national_focus =
SPR_arm_the_workers_militias
                              complete_national_focus =
SPR_demand_ministerial_positions
                              unlock_national_focus = SPR_hinder_nkvd_interference
                        }
                        else = { #REGULAR ANARCHIST UPRISING
                              complete_national_focus =
SPR_regional_defense_council_of_aragon
                              complete_national_focus = SPR_arm_the_people
                              complete_national_focus =
SPR_appropriate_the_means_of_production
                              unlock_national_focus = SPR_the_maximum_concession
                        }
                        unlock_national_focus = SPR_seize_the_gold_reserves
                        unlock_national_focus = SPR_masters_of_our_own_fate
                        add_timed_idea = { idea = SPR_death_before_surrender days =
900 }
                  }
     option = {
           name = lar_spain.9.a
effect_tooltip = {
      if = { #POUM UPRISING (SUPPORTED BY SOVIET RIGHT OPPOSITION)
            limit = {
                  has_global_flag = SOV_covert_support_for_poum_flag
            }
            if = {
                  limit = {
                        communism > 0.03
                  }
                  set_political_party = {
                      ideology = communism
                      popularity = 3
                  }
            }
            add_popularity = {
                ideology = neutrality
                popularity = -0.05
            }
      }
      else = { #REGULAR ANARCHIST UPRISING
            if = {
                  limit = {
                        neutrality > 0.03
                  }
                  set_political_party = {
                      ideology = neutrality
                      popularity = 3
                  }
            }
            add_popularity = {
                ideology = communism
                popularity = -0.05
            }
      }
      add_stability = -0.1
      transfer_units_fraction = {
            target = SPC
            stockpile_ratio = 0.2
            army_ratio = 0.1
            navy_ratio = 0.1
            air_ratio = 0.1
            keep_unit_leaders = {
           }
           keep_unit_leaders_trigger = {
                 OR = {
                       has_trait = trait_SPR_republican_loyalties
                       has_trait = trait_SPR_stalinist_loyalties
                 }
           }
     }
     every_unit_leader = {
           limit = {
                 has_trait = trait_SPR_republican_loyalties
           }
           remove_unit_leader_trait = trait_SPR_republican_loyalties
     }
     every_unit_leader = {
           limit = {
                             has_trait = trait_SPR_stalinist_loyalties
                       }
                       remove_unit_leader_trait = trait_SPR_stalinist_loyalties
                  }
                  every_unit_leader = {
                        limit = {
                              has_trait = trait_SPR_anti_stalinist_loyalties
                        }
                        remove_unit_leader_trait =
trait_SPR_anti_stalinist_loyalties
                        set_nationality = {
                              character = THIS
                              target_country = SPC
                        }
                  }
                  SPC = {
                        declare_war_on = {
                            target = SPA
                            type = civil_war
                        }
                        add_civil_war_target = SPA
                        declare_war_on = {
                            target = SPD
                            type = civil_war
                        }
                        add_civil_war_target = SPD
                        if = {
                              limit = {
                                    country_exists = SPB
                              }
                              declare_war_on = {
                                  target = SPB
                                  type = civil_war
                              }
                              add_civil_war_target = SPB
                        }
                  }
            }
      }
}
is_triggered_only = yes
      immediate = {
            hidden_effect = {
                  if = { #If POUM split + Right Oppo is in charge + tehy are
supporting the POUM -> Then their volunteers stay in SPC
                        limit = {
                              has_completed_focus =
SPR_the_anti_fascist_workers_revolution
                              SOV = {
                                    has_completed_focus =
SOV_covert_support_for_spanish_poum
                                    has_completed_focus = SOV_coup_detat
                              }
                        }
                        every_other_country = { #Exclude SOV
                              limit = {
                                    NOT = { tag = SOV }
                                    ROOT = {
                                          has_volunteers_amount_from = {
                                              tag = PREV
                                              count > 0
                                          }
                                    }
                              }
                              recall_volunteers_from = ROOT
                        }
                  }
                  else = {
                        every_other_country = { #Default
                              limit = {
                                    ROOT = {
                                          has_volunteers_amount_from = {
                                              tag = PREV
                                              count > 0
                                          }
                                    }
                              }
                              recall_volunteers_from = ROOT
                        }
                  }
                  set_global_flag = SPR_anarchist_uprising_flag
                  set_global_flag = { flag = SPR_civil_war_startup value = 1 days =
3 } # Make AI avoid attacking for a few days
                  if = {
                        limit = {
                              has_completed_focus =
SPR_regional_defense_council_of_aragon
                        }
                        set_politics = {
                              ruling_party = neutrality
                        }
                        set_party_name = { ideology = communism long_name =
SPR_communism_independent_party_long name = SPR_communism_independent_party }
                        create_country_leader = {
                              name = "Julián Gorkin"
                             desc = "POLITICS_JULIAN_GORKIN_DESC"
                             picture = "GFX_portrait_SPR_julian_gorkin"
                             expire = "1965.1.1"
                             ideology = anarchist_communism
                             traits = {
                                   militant_socialist
                             }
                       }
                       create_country_leader = {
                             name = "Anarchist Commune"
                             desc = "POLITICS_ANARCHIST_COMMUNE_DESC"
                             picture = "GFX_portrait_SPR_anarchist_commune"
                             expire = "1965.1.1"
                             ideology = anarchism
                             traits = {
                                   our_right_to_survive
                             }
                       }
                       add_popularity = {
                           ideology = fascism
                           popularity = -1
                       }
                       add_popularity = {
                           ideology = communism
                           popularity = -0.25
                       }
                       if = {
                             limit = {
                                   democratic > 0.01
                             }
                             set_political_party = {
                                 ideology = democratic
                                 popularity = 1
                             }
                       }
                       set_rule = {
                           can_puppet = no
                           can_create_factions = no
                           can_join_factions = no
                           can_boost_own_ideology = no
                             can_generate_female_aces = yes
                             can_create_collaboration_government = no
                       }
                  }
                  if = {
                        limit = {
                              has_completed_focus =
SPR_the_anti_fascist_workers_revolution
                        }
                        set_politics = {
                              ruling_party = communism
                        }
                        set_party_name = { ideology = communism long_name =
SPR_communism_independent_party_long name = SPR_communism_independent_party }
                        create_country_leader = {
                              name = "Julián Gorkin"
                              desc = "POLITICS_JULIAN_GORKIN_DESC"
                              picture = "GFX_portrait_SPR_julian_gorkin"
                              expire = "1965.1.1"
                             ideology = anarchist_communism
                             traits = {
                                   militant_socialist
                             }
                        }
                        add_popularity = {
                            ideology = fascism
                            popularity = -1
                        }
                        add_popularity = {
                            ideology = communism
                            popularity = -0.05
                        }
                        if = {
                              limit = {
                                    democratic > 0.01
                              }
                              set_political_party = {
                                  ideology = democratic
                                  popularity = 1
                              }
                        }
                        #create_field_marshal = {
                        #     name = "José Rovira"
                        #     portrait_path =
"gfx/leaders/Europe/Portrait_Europe_Generic_land_5.dds"
                        #     traits = { infantry_officer politically_connected }
                        #     skill = 3
                        #    attack_skill = 2
                        #    defense_skill = 2
                        #    planning_skill = 2
                        #    logistics_skill = 3
                        #}
                        add_field_marshal_role = { #TODO_Manu: All these guys
should be handled with the new char system
                              character = SPR_jose_rovira
                              traits = { infantry_officer politically_connected }
                              skill = 3
                            attack_skill = 2
                            defense_skill = 2
                            planning_skill = 2
                            logistics_skill = 3
                        }
                        create_corps_commander = {
                              name = "Carmel Rosa Baserba"
                              portrait_path = GFX_portrait_Carmel_Rosa_Baserba
                              traits = { trait_cautious infantry_officer }
                              skill = 3
                            attack_skill = 2
                            defense_skill = 2
                            planning_skill = 2
                            logistics_skill = 2
                        }
                        create_corps_commander = {
                              name = "Luis Rastrollo"
                              portrait_path = GFX_portrait_Luis_Rastrollo
                              traits = { politically_connected }
                              skill = 1
                            attack_skill = 1
                           defense_skill = 2
                           planning_skill = 1
                           logistics_skill = 1
                       }
                       set_rule = { can_generate_female_aces = yes     }
     }
     keep_unit_leaders_trigger = {
           has_trait = trait_SPR_anti_stalinist_loyalties
     }
}
every_unit_leader = {
      limit = {
            has_trait = trait_SPR_republican_loyalties
      }
      remove_unit_leader_trait = trait_SPR_republican_loyalties
      set_nationality = {
            character = THIS
            target_country = SPD
      }
}
every_unit_leader = {
      limit = {
            has_trait = trait_SPR_stalinist_loyalties
      }
      remove_unit_leader_trait = trait_SPR_stalinist_loyalties
      set_nationality = {
            character = THIS
            target_country = SPD
      }
}
every_unit_leader = {
      limit = {
            has_id = 1108
      }
      set_nationality = {
            character = THIS
            target_country = SPD
      }
}
                  every_unit_leader = {
                        limit = {
                              has_trait = trait_SPR_anti_stalinist_loyalties
                        }
                        remove_unit_leader_trait =
trait_SPR_anti_stalinist_loyalties
                  }
                  SPD = {
                        every_unit_leader = {
                              limit = {
                                    has_trait = trait_SPR_republican_loyalties
                              }
                              remove_unit_leader_trait =
trait_SPR_republican_loyalties
                        }
                        every_unit_leader = {
                              limit = {
                                    has_trait = trait_SPR_stalinist_loyalties
                              }
                              remove_unit_leader_trait =
trait_SPR_stalinist_loyalties
                        }
                        declare_war_on = {
                            target = SPA
                            type = civil_war
                        }
                        add_civil_war_target = SPA
                       add_ai_strategy = {
                             type = antagonize
                             id = SPA
                             value = 200
                       }
                       declare_war_on = {
                           target = SPC
                           type = civil_war
                       }
                       add_civil_war_target = SPC
                       add_ai_strategy = {
                             type = antagonize
                             id = SPC
                             value = 200
                       }
                       if = {
                             limit = {
                                   country_exists = SPB
                             }
                             declare_war_on = {
                                 target = SPB
                                 type = civil_war
                             }
                             add_civil_war_target = SPB
                             add_ai_strategy = {
                                   type = antagonize
                                   id = SPB
                                   value = 200
                             }
                        }
                  }
                  SPD = {
                        create_country_leader = {
                              name = "Manuel Azaña"
                              desc = "POLITICS_MANUEL_AZANA_DESC"
                              picture = GFX_portrait_Manuel_Azana
                              expire = "1965.1.1"
                              ideology = conservatism
                              traits = {
                                    figurehead_president
                              }
                        }
                        load_focus_tree = {
                              tree = spanish_focus
                              keep_completed = no
                        }
                        unlock_national_focus = SPR_the_popular_front
                        if = {
                              limit = {
                                    SPC = { has_completed_focus =
SPR_secure_the_guardia_civil }
                              }
                              unlock_national_focus = SPR_secure_the_guardia_civil
                        }
                        if = {
                              limit = {
                                    SPC = { has_completed_focus =
SPR_secure_the_guardia_de_asalto }
                              }
                              unlock_national_focus =
SPR_secure_the_guardia_de_asalto
                        }
                        unlock_national_focus = SPR_train_the_union_youth
                        unlock_national_focus = SPR_enlarge_the_weapon_caches
                        unlock_national_focus = SPR_distribute_arms_to_the_people
                        unlock_national_focus = SPR_disband_the_army
                        complete_national_focus = SPR_maintain_the_second_republic
                        complete_national_focus = SPR_new_leadership
                        complete_national_focus = SPR_the_future_of_the_republic
                        complete_national_focus =
SPR_reaffirm_the_popular_front_strategy
                        unlock_national_focus = SPR_crush_the_revolution
                        add_timed_idea = { idea = SPR_death_before_surrender days =
900 }
                  }
        option = {
              name = lar_spain.10.a
              effect_tooltip = {
                    if = {
                        limit = {
                              has_completed_focus =
SPR_regional_defense_council_of_aragon
                              NOT = { has_government = neutrality }
                        }
                        set_politics = {
                              ruling_party = neutrality
                        }
                        create_country_leader = {
                              name = "Anarchist Commune"
                              desc = "POLITICS_ANARCHIST_COMMUNE_DESC"
                              picture = "GFX_portrait_SPR_anarchist_commune"
                              expire = "1965.1.1"
                              ideology = anarchism
                              traits = {
                                    our_right_to_survive
                              }
                        }
                        add_popularity = {
                            ideology = fascism
                            popularity = -1
                        }
                        add_popularity = {
                            ideology = communism
                            popularity = -0.15
                        }
                        if = {
                              limit = {
                                    democratic > 0.01
                              }
                              set_political_party = {
                                  ideology = democratic
                                  popularity = 1
                              }
                        }
                  }
                  if = {
                        limit = {
                              has_completed_focus =
SPR_the_anti_fascist_workers_revolution
                              NOT = { has_government = communism }
                        }
                        set_politics = {
                              ruling_party = communism
                        }
                        create_country_leader = {
                              name = "Julián Gorkin"
                              desc = "POLITICS_JULIAN_GORKIN_DESC"
                              picture = "GFX_portrait_SPR_julian_gorkin"
                              expire = "1965.1.1"
                              ideology = anarchist_communism
                              traits = {
                                    militant_socialist
                              }
                        }
                        add_popularity = {
                            ideology = fascism
                            popularity = -1
                        }
                       add_popularity = {
                           ideology = communism
                           popularity = -0.05
                       }
                       if = {
                             limit = {
                                   democratic > 0.01
                             }
                             set_political_party = {
                                 ideology = democratic
                                 popularity = 1
                             }
                       }
                 }
                 remove_ideas = SPR_the_maximum_concession
                 add_ideas = closed_economy
                 add_stability = -0.1
                 transfer_units_fraction = {
                       target = SPD
                       stockpile_ratio = 0.4
                       army_ratio = 0.3
                       navy_ratio = 0.3
                       air_ratio = 0.3
                       keep_unit_leaders = {
                       }
                       keep_unit_leaders_trigger = {
                             has_trait = trait_SPR_anti_stalinist_loyalties
                       }
                  }
                  every_unit_leader = {
                        limit = {
                              has_trait = trait_SPR_republican_loyalties
                        }
                        remove_unit_leader_trait = trait_SPR_republican_loyalties
                        set_nationality = {
                              character = THIS
                              target_country = SPD
                        }
                  }
                  every_unit_leader = {
                        limit = {
                              has_trait = trait_SPR_stalinist_loyalties
                        }
                        remove_unit_leader_trait = trait_SPR_stalinist_loyalties
                        set_nationality = {
                              character = THIS
                              target_country = SPD
                        }
                  }
                  every_unit_leader = {
                        limit = {
                              has_trait = trait_SPR_anti_stalinist_loyalties
                        }
                        remove_unit_leader_trait =
trait_SPR_anti_stalinist_loyalties
                  }
                  SPD = {
                        declare_war_on = {
                           target = SPA
                           type = civil_war
                       }
                       add_civil_war_target = SPA
                       declare_war_on = {
                           target = SPC
                           type = civil_war
                       }
                       add_civil_war_target = SPC
                       if = {
                             limit = {
                                   country_exists = SPB
                             }
                             declare_war_on = {
                                 target = SPB
                                 type = civil_war
                             }
                             add_civil_war_target = SPB
                       }
                 }
           }
     }
}
is_triggered_only = yes
     option = {
           name = lar_spain.11.a
     }
}
is_triggered_only = yes
     option = {
           name = lar_spain.11.a
     }
}
     option = {
           name = lar_spain.11.a
     }
}
is_triggered_only = yes
     option = {
           name = lar_spain.11.a
     }
}
is_triggered_only = yes
     option = {
           name = lar_spain.11.a
     }
}
is_triggered_only = yes
     option = {
           name = lar_spain.11.a
     }
}
is_triggered_only = yes
     option = {
             name = lar_spain.11.a
        }
}
# Spain - Nationalists out of focuses to take, have to 'lay low' for a while
country_event = {
      id = lar_spain.18
      title = lar_spain.18.t
      desc = lar_spain.18.desc
      picture = GFX_report_event_spr_nationalist_soldiers
        trigger = {
              tag = SPR
              has_completed_focus = SPA_a_great_spain
              NOT = { has_global_flag = spanish_civil_war }
              NOT = { has_global_flag = scw_over }
              date > 1936.8.10
        }
        mean_time_to_happen = {
              days = 2
        }
fire_only_once = yes
        option = {
              name = lar_spain.18.a
              add_ideas = SPA_awaiting_the_rebellion
              custom_effect_tooltip = lar_spain.18.a_tt
        }
}
is_triggered_only = yes
        option = { # Accept
              name = lar_spain.19.a
              ai_chance = {
                    base = 50
                    modifier = {
                          factor = 0
                          strength_ratio = { tag = FROM ratio > 1 }
                    }
              }
              effect_tooltip = {
                    FROM = { puppet = ROOT }
              }
              hidden_effect = {
                    FROM = {
                          country_event = { id = lar_spain.20 hours = 18 random_hours
= 6 }
                   }
             }
        }
        option = { # Decline
              name = lar_spain.19.b
              ai_chance = {
                    base = 50
                    modifier = {
                          factor = 0.8
                          strength_ratio = { tag = FROM ratio   < 0.5 }
                    }
                    modifier = {
                          factor = 0.8
                          has_opinion = { target = FROM value   > 99 }
                    }
                    modifier = {
                          factor = 0.8
                          strength_ratio = { tag = FROM ratio   < 0.3 }
                    }
                    modifier = {
                          factor = 0.8
                          strength_ratio = { tag = FROM ratio   < 0.2 }
                    }
                    modifier = {
                          factor = 0.5
                          strength_ratio = { tag = FROM ratio   < 0.1 }
                    }
              }
              effect_tooltip = {
                    FROM = {
                          create_wargoal = {
                              type = puppet_wargoal_focus
                              target = ROOT
                          }
                    }
              }
              hidden_effect = {
                    FROM = {
                          country_event = { id = lar_spain.21   hours = 18 random_hours
= 6 }
                   }
             }
        }
}
is_triggered_only = yes
        option = { # Ok
              name = lar_spain.20.a
              puppet = FROM
        }
}
# Reassert American Dominance - Notification event for Spain - Target Declined
country_event = {
      id = lar_spain.21
      title = lar_spain.21.t
      desc = lar_spain.21.desc
      picture = GFX_report_event_generic_parliament
is_triggered_only = yes
     option = { # Damn
           name = lar_spain.21.a
           create_wargoal = {
               type = puppet_wargoal_focus
               target = FROM
           }
     }
}
is_triggered_only = yes
      option = { # Accept
            name = lar_spain.22.a
            ai_chance = {
                  base = 50
                  modifier = {
                        factor = 0
                        has_completed_focus = POR_popular_front
                  }
                  modifier = {
                        factor = 0
                        has_completed_focus =
POR_strict_neutrality_in_the_spanish_civil_war
                  }
            }
            add_manpower = -20000
            effect_tooltip = {
                  FROM = { add_manpower = 20000 }
            }
            add_timed_idea = { idea = SPA_spanish_civil_war_commitments days =
730 }
            add_opinion_modifier = { target = ROOT modifier =
SPA_spanish_civil_war_commitments }
            add_ai_strategy = {
                  type = send_volunteers_desire
                  id = SPA
                  value = 200
            }
            hidden_effect = {
                  FROM = {
                        country_event = { id = lar_spain.23 hours = 18 random_hours
= 6 }
                  }
             }
        }
        option = { # Decline
              name = lar_spain.22.b
              ai_chance = {
                    base = 50
                    modifier = {
                          factor = 0.5
                          has_opinion = { target = FROM value > 99 }
                    }
                    modifier = {
                          factor = 0.5
                          has_completed_focus = POR_support_the_spanish_nationalists
                    }
                    modifier = {
                          factor = 0
                          has_completed_focus = POR_send_assistance
                    }
                    modifier = {
                          factor = 0
                          is_historical_focus_on = yes
                    }
              }
              hidden_effect = {
                    FROM = {
                          country_event = { id = lar_spain.24 hours = 18 random_hours
= 6 }
                   }
             }
        }
}
is_triggered_only = yes
      option = { # OK
            name = lar_spain.23.a
            effect_tooltip = {
                  POR = {
                        add_timed_idea = { idea = SPA_spanish_civil_war_commitments
days = 730 }
                        add_opinion_modifier = { target = ROOT modifier =
SPA_spanish_civil_war_commitments }
                  }
            }
            add_manpower = 20000
      }
}
is_triggered_only = yes
        option = { # OK
              name = lar_spain.24.a
        }
}
is_triggered_only = yes
        option = { # Accept
              name = lar_spain.25.a
              ai_chance = {
                    base = 50
                    modifier = {
                          factor = 0
                          has_completed_focus = POR_popular_front
                    }
              }
              custom_effect_tooltip = SPA_the_iberian_pact_tt
              hidden_effect = {
                    FROM = {
                          country_event = { id = lar_spain.26 hours = 18 random_hours
= 6 }
                   }
             }
             if= { #If Portugal is in faction, Spain will join
                   limit = {
                         is_in_faction = yes
                         FROM = { is_in_faction = no }
                   }
                   effect_tooltip = {
                         random_other_country = {
                               limit = {
                                     is_in_faction_with = ROOT
                                     is_faction_leader = yes
                               }
                               add_to_faction = FROM
                         }
                   }
             }
             else_if = { #If Spain is in faction, Portugal will join
                   limit = {
                         is_in_faction = no
                         FROM = { is_in_faction = yes }
                   }
                   random_other_country = {
                         limit = {
                               is_in_faction_with = FROM
                               is_faction_leader = yes
                         }
                         add_to_faction = ROOT
                  }
            }
            else_if = { #If Spain and Portugal are in different factions, both will
leave their faction
                  limit = {
                        is_in_faction = yes
                        FROM = { is_in_faction = yes }
                        NOT = { is_in_faction_with = FROM }
                  }
                  effect_tooltip = {
                        leave_faction = yes
                        FROM = { leave_faction = yes }
                  }
            }
      }
        option = { # Decline
              name = lar_spain.25.b
              ai_chance = {
                    base = 50
                    modifier = {
                          factor = 0.5
                          has_opinion = { target = FROM value > 99 }
                    }
                    modifier = {
                          factor = 0.5
                          has_completed_focus = POR_support_the_spanish_nationalists
                    }
                    modifier = {
                          factor = 0
                          focus_progress = {
                              focus = POR_iberian_summit
                              progress > 0
                          }
                    }
                    modifier = {
                          factor = 0
                          has_completed_focus = POR_support_the_spanish_nationalists
                          is_historical_focus_on = yes
                    }
              }
              hidden_effect = {
                    FROM = {
                          country_event = { id = lar_spain.27 hours = 18 random_hours
= 6 }
                   }
             }
        }
}
      option = { # OK
            name = lar_spain.26.a
            custom_effect_tooltip = SPA_the_iberian_pact_tt
            if= { #If Spain is in faction, Portugal will join
                  limit = {
                        is_in_faction = yes
                        FROM = { is_in_faction = no }
                  }
                  effect_tooltip = {
                        random_other_country = {
                              limit = {
                                    is_in_faction_with = ROOT
                                    is_faction_leader = yes
                              }
                              add_to_faction = FROM
                        }
                  }
            }
            else_if = { #If Portugal is in faction, Spain will join
                  limit = {
                        is_in_faction = no
                        FROM = { is_in_faction = yes }
                  }
                  random_other_country = {
                        limit = {
                              is_in_faction_with = FROM
                              is_faction_leader = yes
                        }
                        add_to_faction = ROOT
                  }
            }
            else_if = { #If Spain and Portugal are in different factions, both will
leave their faction
                  limit = {
                        is_in_faction = yes
                        FROM = { is_in_faction = yes }
                        NOT = { is_in_faction_with = FROM }
                  }
                  leave_faction = yes
                  FROM = { leave_faction = yes }
            }
            hidden_effect = {
                  FROM = { set_country_flag = SPA_iberian_pact }
                  set_country_flag = SPA_iberian_pact
            }
      }
}
     is_triggered_only = yes
     option = { # OK
           name = lar_spain.27.a
     }
}
# Iberian Pact - Other party has joined a faction, we must uphold our end of the
bargain!
country_event = {
      id = lar_spain.28
      title = lar_spain.28.t
      desc = lar_spain.28.desc
      picture = GFX_report_event_generic_parliament
is_triggered_only = yes
     immediate = {
           hidden_effect = {
                 random_other_country = {
                       limit = {
                             has_country_flag = SPA_iberian_pact_invitee
                       }
                       save_event_target_as = iberian_pact_invitee
                 }
                 random_other_country = {
                       limit = {
                             has_country_flag = SPA_iberian_pact_faction_leader
                       }
                       add_to_faction = ROOT
                 }
           }
     }
      option = { # OK
            name = lar_spain.28.a
            effect_tooltip = {
                  random_other_country = {
                        limit = {
                              is_in_faction_with =
event_target:iberian_pact_invitee
                              is_faction_leader = yes
                        }
                        add_to_faction = ROOT
                  }
            }
      }
}
# Iberian Pact - Other party has joined the war, we must uphold our end of the
bargain!
country_event = {
      id = lar_spain.29
      title = lar_spain.28.t
      desc = lar_spain.29.desc
      picture = GFX_report_event_generic_parliament
is_triggered_only = yes
     option = { # OK
            name = lar_spain.28.a
            random_other_country = {
                  limit = {
                        has_war_with = event_target:iberian_pact_war_target
                        if = {
                              limit = {
                                    any_country = {
                                          has_country_flag =
SPA_iberian_pact_enemy_flag
                                    }
                              }
                              has_country_flag = SPA_iberian_pact_enemy_flag
                        }
                  }
                  random_other_country = {
                        limit = {
                              has_country_flag = SPA_iberian_pact
                              has_war_with = PREV
                        }
                        ROOT = {
                              add_to_war = {
                                  targeted_alliance = PREV
                                  enemy = PREV.PREV
                                  hostility_reason = asked_to_join
                              }
                        }
                  }
            }
      }
}
is_triggered_only = yes
     option = { # Accept
           name = lar_spain.30.a
           ai_chance = {
                 base = 50
                 modifier = {
                       factor = 0
                       has_government = democratic
                       FROM = { has_government = fascism }
                 }
                 modifier = {
                       factor = 0
                       has_government = communism
                 }
           }
           effect_tooltip = {
                 FROM = {
                       add_to_faction = ROOT
                 }
           }
             hidden_effect = {
                   FROM = {
                         country_event = { id = lar_spain.31 hours = 18 random_hours
= 6 }
                   }
                   add_ai_strategy = {
                         type = alliance
                         id = FROM
                         value = 200
                   }
             }
        }
        option = { # Decline
              name = lar_spain.30.b
              ai_chance = {
                    base = 50
                    modifier = {
                          factor = 0.5
                          has_opinion = { target = FROM value > 99 }
                    }
                    modifier = {
                          factor = 0
                          has_government = FROM
                    }
              }
              hidden_effect = {
                    FROM = {
                          country_event = { id = lar_spain.32 hours = 18 random_hours
= 6 }
                   }
             }
        }
}
is_triggered_only = yes
        option = { # OK
              name = lar_spain.31.a
              add_to_faction = FROM
        }
}
        is_triggered_only = yes
     option = { # OK
           name = lar_spain.32.a
     }
}
is_triggered_only = yes
     immediate = {
           hidden_effect = {
                 random_owned_state = {
                       limit = {
                             is_core_of = ROOT
                             is_controlled_by = ROOT
                             NOT = {
                                   state = 177
                                   state = 178
                             }
                             NOT = { has_state_flag = SPA_carlist_cell_flag }
                       }
                       set_state_flag = union_militar_temp_flag_1
                       save_event_target_as = union_militar_target_state_1
                 }
                 random_owned_state = {
                       limit = {
                             is_core_of = ROOT
                             is_controlled_by = ROOT
                             NOT = {
                                   state = 177
                                   state = 178
                             }
                             NOT = { has_state_flag = SPA_carlist_cell_flag }
                             NOT = { has_state_flag = union_militar_temp_flag_1 }
                       }
                       set_state_flag = union_militar_temp_flag_2
                       save_event_target_as = union_militar_target_state_2
                 }
                 random_owned_state = {
                       limit = {
                             is_core_of = ROOT
                             is_controlled_by = ROOT
                             NOT = {
                                   state = 177
                                   state = 178
                             }
                             NOT = { has_state_flag = SPA_carlist_cell_flag }
                             NOT = { has_state_flag = union_militar_temp_flag_1 }
                             NOT = { has_state_flag = union_militar_temp_flag_2 }
                       }
                       set_state_flag = union_militar_temp_flag_3
                       save_event_target_as = union_militar_target_state_3
                 }
           }
     }
is_triggered_only = yes
# Spain - Restore the Monarchy - ### DEPRECATED, replaced by News Event ###
country_event = {
      id = lar_spain.35
      title = lar_spain.35.t
      desc = lar_spain.35.desc
      picture = GFX_report_event_royal_parade
is_triggered_only = yes
is_triggered_only = yes
     option = { # Protest
           name = lar_spain.36.a
           ai_chance = {
                 base = 34
                 modifier = {
                       factor = 3
                       has_war = no
                 }
                 modifier = {
                       factor = 2
                       has_government = democratic
                 }
                 modifier = {
                       factor = 5
                       strength_ratio = {
                           tag = FROM
                           ratio > 5
                       }
                 }
                 modifier = {
                       factor = 2
                         strength_ratio = {
                             tag = FROM
                             ratio > 3
                         }
                   }
                   modifier = {
                         factor = 0.5
                         strength_ratio = {
                             tag = FROM
                             ratio < 2
                         }
                   }
                   modifier = {
                         factor = 0.5
                         NOT = { has_political_power > 100 }
                   }
                   modifier = {
                         factor = 0
                         strength_ratio = {
                             tag = FROM
                             ratio < 1
                         }
                   }
                   modifier = {
                         factor = 0
                         is_in_faction_with = FROM
                   }
             }
             add_political_power = -200
             custom_effect_tooltip = lar_spain.36_tt
             effect_tooltip = {
                   create_wargoal = {
                       type = topple_government
                       target = FROM
                   }
             }
             hidden_effect = {
                   FROM = {
                         country_event = { id = lar_spain.37 hours = 18 random_hours
= 6 }
                   }
             }
        }
is_triggered_only = yes
        option = { # OK
              name = lar_spain.37.a
              ai_chance = {
                    base = 50
                    modifier = {
                          factor = 0
                          is_historical_focus_on = yes
                    }
              }
              FROM = {
                    create_wargoal = {
                        type = topple_government
                        target = ROOT
                    }
              }
              290 = {
                    add_extra_state_shared_building_slots = 3
                    add_building_construction = {
                          type = industrial_complex
                          level = 2
                          instant_build = yes
                    }
              }
        }
is_triggered_only = yes
     option = { # OK
           name = lar_spain.38.a
           290 = {
                 add_extra_state_shared_building_slots = 3
                 add_building_construction = {
                       type = industrial_complex
                       level = 2
                       instant_build = yes
                 }
           }
     }
}
is_triggered_only = yes
     option = { # Accept
           name = lar_spain.39.a
           ai_chance = {
                 base = 50
                 modifier = {
                       factor = 0
                       strength_ratio = { tag = FROM ratio > 1 }
                 }
                 modifier = {
                       factor = 5
                       NOT = { has_war_with = FROM }
                       has_war = yes
                 }
           }
           effect_tooltip = {
                 FROM = {
                       transfer_state = 461
                       transfer_state = 462
                       transfer_state = 459
                       transfer_state = 460
                       transfer_state = 513
                       transfer_state = 514
                       transfer_state = 458
                       transfer_state = 665
                 }
           }
           hidden_effect = {
                   set_country_flag = surrendered_french_north_africa
                   FROM = {
                         country_event = { id = lar_spain.40 hours = 18 random_hours
= 6 }
                   }
                   news_event = { id = lar_news.14 days = 2 }
             }
        }
        option = { # Decline
              name = lar_spain.39.b
              ai_chance = {
                    base = 50
                    modifier = {
                          factor = 0.8
                          strength_ratio = { tag = FROM ratio   < 0.5 }
                    }
                    modifier = {
                          factor = 0.8
                          has_opinion = { target = FROM value   > 99 }
                    }
                    modifier = {
                          factor = 0.8
                          strength_ratio = { tag = FROM ratio   < 0.3 }
                    }
                    modifier = {
                          factor = 0.8
                          strength_ratio = { tag = FROM ratio   < 0.2 }
                    }
                    modifier = {
                          factor = 0
                          strength_ratio = { tag = FROM ratio   < 0.1 }
                    }
                    modifier = {
                          factor = 0
                          has_focus_tree = vichy_french_focus
                          NOT = { has_war_with = GER }
                          FROM = { is_in_faction_with = GER }
                    }
              }
              effect_tooltip = {
                    FROM = {
                          add_state_claim = 461
                          add_state_claim = 462
                          add_state_claim = 459
                          add_state_claim = 460
                          add_state_claim = 513
                          add_state_claim = 514
                          add_state_claim = 458
                          add_state_claim = 665
                          create_wargoal = {
                                type = take_state_focus
                                target = ROOT
                                generator = { 461 462 459 460   513 514 458 665 }
                                expire = 0
                          }
                    }
              }
              hidden_effect = {
                   FROM = {
                         country_event = { id = lar_spain.41 hours = 18 random_hours
= 6 }
                   }
             }
        }
}
is_triggered_only = yes
        option = { # Ok
              name = lar_spain.40.a
              transfer_state = 461
              transfer_state = 462
              transfer_state = 459
              transfer_state = 460
              transfer_state = 513
              transfer_state = 514
              transfer_state = 458
              transfer_state = 665
        }
}
is_triggered_only = yes
        option = { # Damn
              name = lar_spain.41.a
              add_state_claim = 461
              add_state_claim = 462
              add_state_claim = 459
              add_state_claim = 460
              add_state_claim = 513
              add_state_claim = 514
              add_state_claim = 458
              add_state_claim = 665
              create_wargoal = {
                    type = take_state_focus
                    target = FROM
                    generator = { 461 462 459 460 513 514 458 665 }
                    expire = 0
              }
        }
}
is_triggered_only = yes
        option = { # Accept
              name = lar_spain.42.a
              ai_chance = {
                    base = 5
                    modifier = {
                          factor = 0
                          has_war = no
                          strength_ratio = { tag = FROM ratio > 0.5 }
                    }
              }
              effect_tooltip = {
                    FROM = {
                          annex_country = { target = ROOT transfer_troops = yes }
                    }
              }
              hidden_effect = {
                    FROM = {
                          country_event = { id = lar_spain.43 hours = 18 random_hours
= 6 }
                   }
                   news_event = { id = lar_news.15 days = 2 }
             }
             custom_effect_tooltip = GAME_OVER_TT
        }
        option = { # Decline
              name = lar_spain.42.b
              ai_chance = {
                    base = 95
                    modifier = {
                          factor = 0
                          focus_progress = {
                                focus = FRA_the_legitimate_heir
                                progress > 0
                          }
                    }
                    modifier = {
                          factor = 0.8
                          NOT = { has_war_with = FROM }
                          has_war = yes
                          surrender_progress > 0.1
                    }
                    modifier = {
                          factor = 0.5
                          NOT = { has_war_with = FROM }
                          has_war = yes
                          surrender_progress > 0.3
                    }
                    modifier = {
                          factor = 0.5
                          strength_ratio = { tag = FROM ratio < 0.2 }
                   }
                   modifier = {
                         factor = 0.2
                         NOT = { has_war_with = FROM }
                         has_war = yes
                         surrender_progress > 0.5
                   }
             }
             effect_tooltip = {
                   FROM = {
                         create_wargoal = {
                               type = annex_everything
                               target = ROOT
                         }
                   }
             }
             hidden_effect = {
                   FROM = {
                         country_event = { id = lar_spain.44 hours = 18 random_hours
= 6 }
                   }
             }
        }
}
is_triggered_only = yes
      option = { # Ok
            name = lar_spain.43.a
            puppet = FROM
            custom_effect_tooltip = lar_spain.43_tt
            hidden_effect = { country_event = { id = lar_spain.79 days = 7
random_days = 7 } }
      }
}
is_triggered_only = yes
        option = { # Damn
              name = lar_spain.44.a
              create_wargoal = {
                    type = annex_everything
                    target = FROM
              }
        }
}
is_triggered_only = yes
        option = { # Accept
              name = lar_spain.45.a
              ai_chance = {
                    base = 5
                    modifier = {
                          factor = 0
                          has_war = no
                          strength_ratio = { tag = FROM ratio > 0.5 }
                          NOT = { is_puppet_of = FROM }
                    }
                    modifier = {
                          factor = 5
                          has_opinion = { target = FROM value > 99 }
                    }
              }
              effect_tooltip = {
                    FROM = {
                          annex_country = { target = ROOT transfer_troops = yes }
                    }
              }
              hidden_effect = {
                    FROM = {
                          country_event = { id = lar_spain.46 hours = 18 random_hours
= 6 }
                   }
                   news_event = { id = lar_news.16 days = 2 }
             }
             custom_effect_tooltip = GAME_OVER_TT
        }
        option = { # Decline
              name = lar_spain.45.b
              ai_chance = {
                    base = 95
                    modifier = {
                          factor = 0.1
                          has_completed_focus = POR_the_royal_iberian_alliance
                    }
                    modifier = {
                          factor = 0.8
                          NOT = { has_war_with = FROM }
                          has_war = yes
                          surrender_progress > 0.1
                    }
                    modifier = {
                          factor = 0.5
                          NOT = { has_war_with = FROM }
                          has_war = yes
                         surrender_progress > 0.3
                   }
                   modifier = {
                         factor = 0.5
                         strength_ratio = { tag = FROM ratio < 0.2 }
                   }
                   modifier = {
                         factor = 0
                         OR = {
                               AND = {
                                     NOT = { has_war_with = FROM }
                                     has_war = yes
                                     surrender_progress > 0.5
                               }
                               is_puppet_of = FROM
                         }
                   }
             }
             effect_tooltip = {
                   FROM = {
                         create_wargoal = {
                               type = annex_everything
                               target = ROOT
                         }
                   }
             }
             hidden_effect = {
                   FROM = {
                         country_event = { id = lar_spain.47 hours = 18 random_hours
= 6 }
                   }
             }
        }
}
is_triggered_only = yes
        option = { # Ok
              name = lar_spain.46.a
              set_cosmetic_tag = ESU_POR_unified
              every_state = {
                    limit = {
                          is_core_of = POR
                    }
                    add_core_of = ROOT
              }
              annex_country = { target = FROM transfer_troops = yes }
        }
}
is_triggered_only = yes
     option = { # Damn
           name = lar_spain.47.a
           create_wargoal = {
                 type = annex_everything
                 target = FROM
           }
     }
}
is_triggered_only = yes
     immediate = {
           hidden_effect = {
                 random_owned_state = {
                       limit = {
                             any_neighbor_state = {
                                   is_fully_controlled_by = SPC
                             }
                       }
                       set_state_flag = SPC_portuguese_anarchism_state
                 }
                 set_global_flag = SPR_portuguese_anarchism_flag
           }
     }
     option = { # Ok :'(
           name = lar_spain.48.a
           hidden_effect = {
                 start_civil_war = {
                     ideology = communism
                     size = 0.1
                     states_filter = {
                         has_state_flag = SPC_portuguese_anarchism_state
                     }
                     keep_unit_leaders_trigger = {
                       always = yes
                     }
                 }
                 random_country = {
                       limit = {
                             original_tag = POR
                             has_government = communism
                             NOT = { tag = ROOT }
                       }
                       set_politics = {
                              ruling_party = neutrality
                        }
                        set_political_party = {
                            ideology = neutrality
                            popularity = 100
                        }
                        set_party_name = { ideology = neutrality long_name =
SPR_neutrality_anarchism_party_long name = SPR_neutrality_anarchism_party }
                        set_cosmetic_tag = SPR_POR_anarchism
                        set_country_flag = SPR_portuguese_anarchism_flag
                        retire_country_leader = yes
                        create_country_leader = {
                              name = "Anarchist Commune"
                              desc = "POLITICS_ANARCHIST_COMMUNE_DESC"
                              picture = "GFX_portrait_SPR_anarchist_commune"
                              expire = "1965.1.1"
                              ideology = anarchism
                              traits = {
                              }
                        }
                  }
                  FROM = {
                        country_event = { id = lar_spain.49 }
                  }
            }
      }
}
is_triggered_only = yes
     option = { # Ok
           name = lar_spain.49.a
           random_country = {
                 limit = {
                       original_tag = POR
                       has_government = neutrality
                       NOT = { tag = FROM }
                 }
                 SPC = {
                       add_to_war = {
                           targeted_alliance = PREV
                           enemy = POR
                           hostility_reason = asked_to_join
                       }
                       puppet = PREV
                 }
                 set_political_party = {
                     ideology = neutrality
                     popularity = 100
                 }
           }
           POR ={
                 set_rule = { can_join_factions = no }
           }
     }
}
is_triggered_only = yes
     option = { # Ok
           name = lar_spain.50.a
           random_country = {
                 limit = {
                       original_tag = POR
                       has_government = neutrality
                       is_subject_of = ROOT
                 }
                 SPC = {
                       annex_country = {
                           target = PREV
                           transfer_troops = yes
                       }
                 }
           }
           clr_global_flag = SPR_portuguese_anarchism_flag
     }
}
is_triggered_only = yes
      immediate = {
            hidden_effect = {
                  random_other_country = {
                        limit = {
                              ROOT = {
                                    has_volunteers_amount_from = {
                                        tag = PREV
                                        count > 0
                                    }
                              }
                              NOT = { tag = SOV }
                        }
                        set_country_flag =
SPR_relocated_gold_reserves_selection_flag1
                        save_event_target_as =
SPR_relocated_gold_reserves_selection_1
                  }
                  random_other_country = {
                        limit = {
                              ROOT = {
                                    has_volunteers_amount_from = {
                                        tag = PREV
                                        count > 0
                                    }
                              }
                              NOT = { tag = SOV }
                              NOT = { has_country_flag =
SPR_relocated_gold_reserves_selection_flag1 }
                        }
                        set_country_flag =
SPR_relocated_gold_reserves_selection_flag2
                        save_event_target_as =
SPR_relocated_gold_reserves_selection_2
                  }
                  random_other_country = {
                        limit = {
                              ROOT = {
                                    has_volunteers_amount_from = {
                                        tag = PREV
                                        count > 0
                                    }
                              }
                              NOT = { tag = SOV }
                              NOT = { has_country_flag =
SPR_relocated_gold_reserves_selection_flag1 }
                              NOT = { has_country_flag =
SPR_relocated_gold_reserves_selection_flag2 }
                        }
                        set_country_flag =
SPR_relocated_gold_reserves_selection_flag3
                        save_event_target_as =
SPR_relocated_gold_reserves_selection_3
                  }
            }
      }
is_triggered_only = yes
      option = { # Ok
            name = lar_spain.52.a
            set_country_flag = { flag = SPR_relocate_the_gold_reserves_timer_flag
value = 1 days = 60 }
      }
}
# Relocate the Gold Reserves - Event for Target - Seize the Gold
country_event = {
      id = lar_spain.53
      title = lar_spain.53.t
      desc = lar_spain.53.desc
      picture = GFX_report_event_generic_read_write
fire_only_once = yes
     trigger = {
           any_country = {
                 original_tag = SPR
                 OR = {
                       has_government = democratic
                       has_government = communism
                 }
                 has_volunteers_amount_from = {
                     tag = ROOT
                     count > 0
                 }
                 has_completed_focus = SPR_relocate_the_gold_reserves
           }
           OR = {
                 has_country_flag = SPR_relocated_gold_reserves_selection_flag_sov
                 has_country_flag = SPR_relocated_gold_reserves_selection_flag1
                 has_country_flag = SPR_relocated_gold_reserves_selection_flag2
                 has_country_flag = SPR_relocated_gold_reserves_selection_flag3
           }
           NOT = { has_country_flag = SPR_relocate_the_gold_reserves_timer_flag }
     }
     mean_time_to_happen = {
           days = 30
     }
is_triggered_only = yes
     immediate = {
           hidden_effect = {
                 remove_ideas = SPR_relocate_the_gold_reserves
                 set_country_flag = SPR_seized_gold_reserves_flag
           }
     }
     option = { # Ok
           name = lar_spain.54.a
           effect_tooltip = { remove_ideas = SPR_relocate_the_gold_reserves }
           custom_effect_tooltip = lar_spain.54.a_tt
     }
}
fire_only_once = yes
     trigger = {
           original_tag = SPR
           has_country_flag = SPR_seized_gold_reserves_flag
           has_global_flag = scw_over
     }
        mean_time_to_happen = {
              days = 2
        }
        option = { # Dangit
              name = lar_spain.55.a
              add_timed_idea = { idea = SPR_seized_spanish_gold_reserves_spain days =
365 }
        }
}
is_triggered_only = yes
        option = { # Accept
              name = lar_spain.56.a
              end_puppet = FROM
              hidden_effect = {
                    FROM = {
                          country_event = { id = lar_spain.57 }
                    }
              }
        }
        option = { # Decline
              name = lar_spain.56.b
              ai_chance = {
                    base = 0
              }
              hidden_effect = {
                    FROM = {
                          country_event = { id = lar_spain.58 }
                    }
              }
        }
}
is_triggered_only = yes
        option = { # Ok
              name = lar_spain.57.a
              effect_tooltip = {
                    FROM = { end_puppet = ROOT }
              }
        }
}
# Appeal for Increased Autonomy - Event for Spain - SOV declined
country_event = {
      id = lar_spain.58
      title = lar_spain.58.t
      desc = lar_spain.58.desc
      picture = GFX_report_event_generic_sign_treaty2
is_triggered_only = yes
     option = { # Damn
           name = lar_spain.58.a
     }
}
is_triggered_only = yes
     option = { # Accept
           name = lar_spain.59.a
           ai_chance = {
                 base = 50
           }
           effect_tooltip = {
                 FROM = {
                       annex_country = { target = ROOT transfer_troops = yes }
                 }
           }
           hidden_effect = {
                 FROM = {
                       country_event = { id = lar_spain.60 }
                 }
           }
           custom_effect_tooltip = GAME_OVER_TT
     }
     option = { # Decline
           name = lar_spain.59.b
           ai_chance = {
                 base = 50
                 modifier = {
                       factor = 0
                       focus_progress = {
                           focus = POR_the_iberian_socialist_union
                           progress > 0
                       }
                 }
                 modifier = {
                       factor = 0.8
                       strength_ratio = { tag = FROM ratio < 0.5 }
                 }
                 modifier = {
                       factor = 0.8
                       has_opinion = { target = FROM    value > 99 }
                 }
                 modifier = {
                       factor = 0.8
                       strength_ratio = { tag = FROM    ratio < 0.3 }
                 }
                 modifier = {
                       factor = 0.8
                       strength_ratio = { tag = FROM    ratio < 0.2 }
                 }
                 modifier = {
                       factor = 0
                       strength_ratio = { tag = FROM    ratio < 0.1 }
                 }
                 modifier = {
                       factor = 0.8
                       NOT = { has_war_with = FROM }
                       has_war = yes
                       surrender_progress > 0
                 }
                 modifier = {
                       factor = 0.5
                       NOT = { has_war_with = FROM }
                       has_war = yes
                       surrender_progress > 0.3
                 }
                 modifier = {
                       factor = 0.5
                       strength_ratio = { tag = FROM    ratio < 0.2 }
                 }
                 modifier = {
                       factor = 0
                       NOT = { has_war_with = FROM }
                       has_war = yes
                       surrender_progress > 0.5
                 }
           }
           effect_tooltip = {
                 FROM = {
                       create_wargoal = {
                             type = annex_everything
                             target = ROOT
                       }
                 }
           }
           hidden_effect = {
                 FROM = {
                       country_event = { id = lar_spain.61 }
                 }
           }
     }
}
     option = { # Ok
           name = lar_spain.60.a
           set_cosmetic_tag = ESU_POR_unified
           every_state = {
                 limit = {
                       is_core_of = POR
                 }
                 add_core_of = ROOT
           }
           annex_country = { target = FROM transfer_troops = yes }
     }
}
is_triggered_only = yes
     option = { # Damn
           name = lar_spain.61.a
           create_wargoal = {
                 type = annex_everything
                 target = FROM
           }
     }
}
is_triggered_only = yes
     option = { # Ok :'(
           name = lar_spain.62.a
           hidden_effect = {
                 if = {
                       limit = {
                             communism > 0.4
                       }
                       start_civil_war = {
                           ideology = communism
                           size = 0.3
                           keep_unit_leaders_trigger = {
                             always = yes
                           }
                       }
                 }
                 else_if = {
                       limit = {
                             communism > 0.3
                       }
                       start_civil_war = {
                           ideology = communism
                           size = 0.2
                           keep_unit_leaders_trigger = {
                             always = yes
                           }
                       }
                 }
                 else = {
                       start_civil_war = {
                           ideology = communism
                           size = 0.1
                           keep_unit_leaders_trigger = {
                             always = yes
                           }
                       }
                 }
                 FROM = {
                       country_event = { id = lar_spain.63 }
                 }
           }
     }
}
is_triggered_only = yes
     option = { # Ok
           name = lar_spain.63.a
           random_country = {
                 limit = {
                       original_tag = FRA
                       has_government = communism
                       NOT = { tag = FROM }
                 }
                 SPR = {
                       puppet = PREV
                       add_to_war = {
                           targeted_alliance = PREV
                           enemy = FRA
                           hostility_reason = asked_to_join
                       }
                 }
           }
     }
}
is_triggered_only = yes
      option = { # Accept
            name = lar_spain.64.a
            ai_chance = {
                  base = 50
                  modifier = {
                        factor = 0.5
                        is_historical_focus_on = yes
                  }
                  modifier = {
                        factor = 0.2
                        has_country_flag = FRA_non_intervention
                  }
            }
            add_political_power = -50
            add_popularity = {
                  ideology = communism
                  popularity = 0.1
            }
            add_timed_idea = { idea = SPR_equipment_shipments days = 730 }
            add_opinion_modifier = { target = FROM modifier =
SPA_spanish_civil_war_commitments }
            FROM = {
                  add_war_support = 0.15
            }
            add_ai_strategy = { type = send_lend_lease_desire id = SPR value =
100 }
            hidden_effect = {
                  FROM = {
                        country_event = { id = lar_spain.65 }
                  }
            }
      }
     option = { # Decline
           name = lar_spain.64.b
           ai_chance = {
                 base = 50
                 modifier = {
                       factor = 0
                       OR = {
                             has_country_flag   = FRA_arms_purchases_allowed
                             has_country_flag   = FRA_sending_weapons_allowed
                             has_country_flag   = FRA_volunteer_work_allowed
                       }
                 }
           }
           hidden_effect = {
                 FROM = {
                       country_event = { id =   lar_spain.66 }
                 }
           }
     }
}
# Petition for French Aid - Event for Spain - France Accepted
country_event = {
      id = lar_spain.65
      title = lar_spain.65.t
      desc = lar_spain.65.desc
      picture = GFX_report_event_spr_no_pasaran
      is_triggered_only = yes
      option = { # Ok
            name = lar_spain.65.a
            effect_tooltip = { FROM = { add_opinion_modifier = { target = ROOT
modifier = SPA_spanish_civil_war_commitments } } }
            add_war_support = 0.15
      }
}
is_triggered_only = yes
     option = { # Damn
           name = lar_spain.66.a
     }
}
is_triggered_only = yes
     immediate = {
           hidden_effect = {
                 end_puppet = FROM
                 remove_from_faction = FROM
           }
     }
     option = { # Ok
           name = lar_spain.67.a
           ai_chance = {
                 base = 100
                 modifier = {
                       factor = 0.33
                       any_country = {
                             is_major = yes
                             has_war_with = ROOT
                       }
                 }
                 modifier = {
                       factor = 0
                       surrender_progress > 0.1
                 }
           }
           effect_tooltip = {
                 end_puppet = FROM
                 remove_from_faction = FROM
           }
           FROM = {
                 declare_war_on = {
                     target = ROOT
                     type = topple_government
                 }
           }
           hidden_effect = { FROM = { news_event = { id = lar_news.20 hours =
6 } } }
      }
is_triggered_only = yes
        option = { # Accept
              name = lar_spain.68.a
              ai_chance = {
                    base = 75
              }
              add_timed_idea = { idea = SPR_equipment_shipments days = 730 }
              add_ai_strategy = { type = send_lend_lease_desire id = SPR value =
100 }
             hidden_effect = {
                   FROM = {
                         country_event = { id = lar_spain.69 }
                   }
             }
        }
        option = { # Decline
              name = lar_spain.68.b
              ai_chance = {
                    base = 25
                    modifier = {
                          factor = 0.5
                          has_opinion = { target = FROM value > 99 }
                    }
                    modifier = {
                          factor = 0
                          has_war_with = SOV
                    }
              }
              hidden_effect = {
                    FROM = {
                          country_event = { id = lar_spain.70 }
                    }
              }
        }
}
# Those Who Would Not Help Us - Event for Spain - FROM Accepted
country_event = {
      id = lar_spain.69
      title = lar_spain.69.t
      desc = lar_spain.69.desc
      picture = GFX_report_event_generic_sign_treaty1
is_triggered_only = yes
      option = { # Ok
            name = lar_spain.69.a
            effect_tooltip = {
                  FROM = { add_timed_idea = { idea = SPR_equipment_shipments days =
730 } }
            }
      }
}
# Those Who Would Not Help Us - Event for Spain - FROM Declined
country_event = {
      id = lar_spain.70
      title = lar_spain.70.t
      desc = lar_spain.70.desc
      picture = GFX_report_event_generic_read_write
is_triggered_only = yes
     option = { # Damn
           name = lar_spain.70.a
     }
}
is_triggered_only = yes
     option = { # Accept
           name = lar_spain.71.a
           ai_chance = {
                 base = 75
           }
           diplomatic_relation = {
               country = FROM
               relation = non_aggression_pact
               active = yes
           }
           hidden_effect = {
                 FROM = {
                       country_event = { id = lar_spain.72 }
                 }
           }
     }
     option = { # Decline
           name = lar_spain.71.b
           ai_chance = {
                 base = 25
                 modifier = {
                       factor = 0.5
                       has_opinion = { target = FROM value > 99 }
                 }
                 modifier = {
                       factor = 0
                       has_war_with = SOV
                 }
           }
           hidden_effect = {
                 FROM = {
                       country_event = { id = lar_spain.73 }
                 }
           }
     }
}
is_triggered_only = yes
        option = { # Ok
              name = lar_spain.72.a
              effect_tooltip = {
                    FROM = {
                          diplomatic_relation = {
                              country = ROOT
                              relation = non_aggression_pact
                              active = yes
                          }
                    }
              }
        }
}
is_triggered_only = yes
        option = { # Damn
              name = lar_spain.73.a
        }
}
is_triggered_only = yes
        option = { # Accept
              name = lar_spain.74.a
              ai_chance = {
                    base = 75
              }
              army_experience = -25
              effect_tooltip = {
                    FROM = {
                          add_timed_idea = { idea = SPR_deal_with_the_devil days =
730 }
                   }
           }
           hidden_effect = {
                 FROM = {
                       country_event = { id = lar_spain.75 }
                 }
           }
     }
     option = { # Decline
           name = lar_spain.74.b
           ai_chance = {
                 base = 25
                 modifier = {
                       factor = 0.5
                       has_opinion = { target = FROM value > 99 }
                 }
                 modifier = {
                       factor = 0
                       has_war_with = SOV
                 }
           }
           hidden_effect = {
                 FROM = {
                       country_event = { id = lar_spain.76 }
                 }
           }
     }
}
is_triggered_only = yes
     option = { # Ok
           name = lar_spain.75.a
           add_timed_idea = { idea = SPR_deal_with_the_devil days = 730 }
     }
}
is_triggered_only = yes
     option = { # Damn
           name = lar_spain.76.a
     }
}
      trigger = {
            original_tag = SPR
            if = {
                  limit = {
                        any_country = {
                              OR = {
                                    AND = {
                                          tag = SPA
                                          has_completed_focus =
SPA_unify_the_nationalist_front
                                    }
                                    tag = SPB
                              }
                              is_ai = no
                        }
                  }
                  is_ai = no
            }
            has_completed_focus = SPA_a_great_spain
            NOT = { has_completed_focus = SPA_the_phalanx_ascendant }
            NOT = { has_global_flag = SPB_alfonso_xiii_dead }
            date > 1940.2.28
      }
     mean_time_to_happen = {
           days = 365
     }
fire_only_once = yes
     immediate = {
           hidden_effect = {
                 set_global_flag = SPB_alfonso_xiii_dead
                 if = {
                       limit = {
                             has_country_leader = {
                                   name = "Alfonso XIII"
                                   ruling_only = yes
                             }
                       }
                       kill_country_leader = yes
                       create_country_leader = {
                             name = "Jaime IV"
                             desc = "POLITICS_JAIME_IV_DESC"
                             picture = "GFX_portrait_fra_infante_jaime"
                             expire = "1965.1.1"
                             ideology = despotism
                             traits = {
                               }
                       }
                 }
           }
     }
     option = { # RIP
           name = lar_spain.77.a
           if = {
                 limit = {
                       has_country_leader = {
                           name = "Alfonso XIII"
                           ruling_only = yes
                       }
                 }
                 effect_tooltip = {
                       kill_country_leader = yes
                       create_country_leader = {
                             name = "Jaime IV"
                             desc = "POLITICS_JAIME_IV_DESC"
                             picture = "GFX_portrait_fra_infante_jaime"
                             expire = "1965.1.1"
                             ideology = despotism
                             traits = {
                               }
                       }
                 }
           }
     }
}
is_triggered_only = yes
     immediate = {
           hidden_effect = {
                 kill_country_leader = yes
                 create_country_leader = {
                       name = "Military Junta"
                       desc = "POLITICS_MILITARY_JUNTA_DESC"
                       picture = "GFX_portrait_SPA_military_junta"
                       expire = "1965.1.1"
                       ideology = despotism
                       traits = {
                             divided_interests
                       }
                 }
           }
     }
     option = { # RIP
           name = lar_spain.78.a
           effect_tooltip = {
                 custom_effect_tooltip = lar_spain.78_tt
                 hidden_effect = {
                       kill_country_leader = yes
                 }
                 create_country_leader = {
                       name = "Military Junta"
                       desc = "POLITICS_MILITARY_JUNTA_DESC"
                       picture = "GFX_portrait_SPA_military_junta"
                       expire = "1965.1.1"
                       ideology = despotism
                       traits = {
                             divided_interests
                       }
                 }
           }
     }
}
is_triggered_only = yes
     option = { # Ok
           name = lar_spain.79.a
           FRA = {
                 every_unit_leader = {
                       set_nationality = ROOT
                 }
           }
           every_state = {
                 limit = {
                       is_core_of = FRA
                 }
                 add_core_of = ROOT
           }
           annex_country = { target = FRA transfer_troops = yes }
     }
}
     trigger = {
           tag = SPA
           has_completed_focus = SPA_caudillo_of_spain
           NOT = { has_completed_focus = SPA_restore_the_monarchy }
           date > 1950.1.1
     }
     mean_time_to_happen = {
           days = 2
     }
fire_only_once = yes
hidden = yes
      immediate = {
            hidden_effect = {
                  SPA_francisco_franco = {
                        set_portraits = {
                              civilian = { large =
GFX_portrait_spain_francisco_franco_old }
                        }
                  }
            }
      }
}
is_triggered_only = yes
     option = { # Ok
           name = lar_spain.81.a
           effect_tooltip = {
                 puppet = SPD
           }
     }
}
is_triggered_only = yes
     immediate = {
           hidden_effect = {
                 if = {
                       limit = {
                             has_government = democratic
                       }
                       set_country_flag = SPR_democratic_government_flag
                 }
                 set_temp_variable = {
                       var = soviet_puppet_democratic_var
                       value = party_popularity@democratic
                 }
                 SOV = { puppet = SPD }
                 if = {
                       limit = {
                             has_country_flag = SPR_democratic_government_flag
                       }
                       set_politics = {
                             ruling_party = democratic
                       }
                       clr_country_flag = SPR_democratic_government_flag
                 }
                 set_political_party = {
                     ideology = communism
                     popularity = 100
                 }
                 add_popularity = {
                     ideology = democratic
                     popularity = soviet_puppet_democratic_var
                 }
           }
     }
     option = { # Ok
           name = lar_spain.82.a
           effect_tooltip = {
                 SOV = { puppet = SPD }
           }
     }
}
     trigger = {
           tag = SOV
           any_country = {
                 original_tag = SPR
                 focus_progress = {
                     focus = SPR_subvert_soviet_control
                     progress > 0.1
                 }
           }
     }
     mean_time_to_happen = {
           days = 2
     }
     fire_only_once = yes
is_triggered_only = yes
     option = { # Bastards!
           name = lar_spain.84.a
           set_country_flag = SOV_took_spanish_states
           effect_tooltip = {
                 SOV = {
                       transfer_state = 165
                       transfer_state = 167
                       transfer_state = 794
                 }
           }
     }
}
     trigger = {
           tag = SPD
           has_completed_focus = SPR_war_of_independence
           has_country_flag = SOV_took_spanish_states
           has_war_with = SOV
           SOV = { owns_state = 165 }
           has_full_control_of_state = 165
     }
     mean_time_to_happen = {
           days = 2
     }
fire_only_once = yes
     immediate = {
           hidden_effect = {
                 165 = { save_event_target_as = SPR_stolen_state_name }
           }
     }
     option = { # Excellent!
           name = lar_spain.85.a
           transfer_state = 165
           hidden_effect = { SOV = { country_event = { id = lar_spain.88 } } }
     }
}
     trigger = {
           tag = SPD
           has_completed_focus = SPR_war_of_independence
           has_country_flag = SOV_took_spanish_states
           has_war_with = SOV
           SOV = { owns_state = 167 }
           has_full_control_of_state = 167
     }
     mean_time_to_happen = {
           days = 2
     }
fire_only_once = yes
     immediate = {
           hidden_effect = {
                 167 = { save_event_target_as = SPR_stolen_state_name }
           }
     }
     option = { # Excellent!
           name = lar_spain.85.a
           transfer_state = 167
           hidden_effect = { SOV = { country_event = { id = lar_spain.88 } } }
     }
}
     trigger = {
           tag = SPD
           has_completed_focus = SPR_war_of_independence
           has_country_flag = SOV_took_spanish_states
           has_war_with = SOV
           SOV = { owns_state = 794 }
           has_full_control_of_state = 794
     }
     mean_time_to_happen = {
           days = 2
     }
fire_only_once = yes
     immediate = {
           hidden_effect = {
                 794 = { save_event_target_as = SPR_stolen_state_name }
           }
     }
     option = { # Excellent!
           name = lar_spain.85.a
           transfer_state = 794
           hidden_effect = { SOV = { country_event = { id = lar_spain.88 } } }
     }
}
is_triggered_only = yes
      option = { # Excellent!
            name = lar_spain.88.a
            effect_tooltip = { FROM = { transfer_state =
event_target:SPR_stolen_state_name } }
      }
}
     option = { # Ok
           name = lar_spain.89.a
           if = {
                 limit = {
                       SOV = { has_country_flag = SOV_annexed_spanish_land }
                 }
                 SOV = { clr_country_flag = SOV_annexed_spanish_land }
                 effect_tooltip = {
                       FROM = {
                             transfer_state = 165
                             transfer_state = 167
                             transfer_state = 794
                       }
                 }
           }
     }
}
     trigger = {
           tag = SPR
           date > 1936.4.20
           NOT = { has_global_flag = spanish_civil_war }
     }
     mean_time_to_happen = {
           days = 2
     }
fire_only_once = yes
     option = { # Ok
           name = lar_spain.90.a
           if = {
                 limit = {
                       has_dlc = "La Resistance"
                 }
                 if = {
                       limit = {
                             has_completed_focus = SPR_the_popular_front
                       }
                       remove_ideas = SPR_government_power_struggle
                       add_political_power = 10
                 }
                 retire_country_leader = yes
                 create_country_leader = {
                       name = "Manuel Azaña"
                       desc = "POLITICS_MANUEL_AZANA_DESC"
                       picture = GFX_portrait_Manuel_Azana
                       expire = "1965.1.1"
                   ideology = conservatism
                   traits = {
                         figurehead_president
                   }
              }
        }
        else = {
              retire_country_leader = yes
              create_country_leader = {
                    name = "Manuel Azaña"
                    desc = "POLITICS_MANUEL_AZANA_DESC"
                    picture = GFX_portrait_Manuel_Azana
                    expire = "1965.1.1"
                    ideology = conservatism
                    traits = {
                   }
             }
        }
    }
}