﻿add_namespace = civwar

country_event = {
	id = civwar.110
	is_triggered_only = yes
	hidden = yes

	immediate = {
		EQS = {
			ROOT = { transfer_technology = yes }
		}
	}
}

#New event that will fire if EQS is at war with a non pony country (eg. Changelings) and with a minor civil war faction offering a ceasefire
country_event = {
    id = civwar.100
    hidden = yes

    trigger = {
      tag = EQS
      has_war = yes
      has_completed_focus = All_ponies_front
      OR = {
        has_government = democratic
        has_government = communism
      }
      any_enemy_country = {
        is_pony_race = no
        strength_ratio = { tag = EQS ratio > 0.33 }
      }
      any_enemy_country = {
        NOT = { has_country_flag = refused_eqs_ceasefire }
        NOT = { tag = NLR }
        NOT = { tag = NMS }
        is_eqs_civil_war_tag = yes
        has_defensive_war_with = EQS
      }
    }

    mean_time_to_happen = {
      days = 15
    }

    immediate = {
      random_enemy_country = {
        limit = {
          NOT = { has_country_flag = refused_eqs_ceasefire }
          NOT = { tag = NLR }
          NOT = { tag = NMS }
          is_eqs_civil_war_tag = yes
          has_defensive_war_with = EQS
        }
        save_event_target_as = ceasefire_target
      }
    }

    option = {
      country_event = { id = civwar.101 }
    }
}

country_event = {
    id = civwar.101
    title = civwar.101.t
    desc = civwar.101.d
    picture = GFX_event_technical

    is_triggered_only = yes

    #Sure, ceasefire sounds nice
    option = {
    name = civwar.101.a
      event_target:ceasefire_target = {country_event = { id = civwar.102 days = 2 } }
      ai_chance = {
        factor = 35
      }
    }

    #Try to get them on our side
    option = {
    name = civwar.101.b
      add_political_power = -100
      event_target:ceasefire_target = {country_event = { id = civwar.103 days = 2 } }
      ai_chance = {
        factor = 30
        modifier = {
          factor = 3
          OR = {
            AND = {
              has_government = democratic
              event_target:ceasefire_target = { has_government = democratic }
            }
            AND = {
              has_government = communism
              event_target:ceasefire_target = { has_government = communism }
            }
          }
        }
        modifier = {
          factor = 0.5
          OR = {
            strength_ratio = { tag = event_target:ceasefire_target ratio < 1 }
            event_target:ceasefire_target = { surrender_progress > 0.15 }
          }
        }
      }
    }

    #Nah, let's fuck em up
    option = {
    name = civwar.101.c
      event_target:ceasefire_target = { set_country_flag = refused_eqs_ceasefire }
      ai_chance = {
        factor = 35
        modifier = {
          factor = 2
          OR = {
            event_target:ceasefire_target = { surrender_progress > 0.6 }
          }
        }
        modifier = {
          factor = 0
          OR = {
            strength_ratio = { tag = event_target:ceasefire_target ratio < 0.7 }
            surrender_progress > 0.2
            has_manpower < 50000
          }
        }
      }
    }
}

country_event = {
    id = civwar.102
    title = civwar.102.t
    desc = civwar.102.d
    picture = GFX_event_technical

    is_triggered_only = yes

    #Sure, ceasefire sounds nice
    option = {
      name = civwar.102.a
      set_country_flag = eqs_ceasefire
      white_peace = FROM
      hidden_effect = {
        FROM = {
          every_owned_state = {
            limit = { is_controlled_by = ROOT }
            ROOT = { transfer_state = PREV }
          }
        }
        ROOT = {
          every_owned_state = {
            limit = { is_controlled_by = FROM }
            FROM = { transfer_state = PREV }
          }
        }
      }

      ai_chance = {
        factor = 50
        modifier = {
          factor = 0.5
          strength_ratio = { tag = FROM ratio > 0.7 }
        }
        modifier = {
          factor = 0
          strength_ratio = { tag = FROM ratio > 0.9 }
        }
        modifier = {
          factor = 0.5
          any_enemy_country = {
            NOT = { tag = FROM }
            has_war_with = ROOT
          }
        }
        modifier = {
          factor = 0
          any_enemy_country = {
            NOT = { tag = FROM }
            has_war_with = ROOT
            strength_ratio = { tag = ROOT ratio > 0.8 }
          }
        }
      }
    }

    #Nah, let's fuck em up
    option = {
    name = civwar.102.b
      set_country_flag = refused_eqs_ceasefire
      ai_chance = {
        factor = 35
        modifier = {
          factor = 2
          has_government = fascism
        }
        modifier = {
          factor = 0.5
          strength_ratio = { tag = FROM ratio < 0.6 }
        }
        modifier = {
          factor = 0
          strength_ratio = { tag = FROM ratio < 0.4 }
        }
        modifier = {
          factor = 0
          surrender_progress > 0.4
        }
      }
    }
}

country_event = {
    id = civwar.104
    hidden = yes

    is_triggered_only = yes

    option = {
      event_target:faction_lead = { add_to_faction = ROOT }
    }
}

country_event = {
    id = civwar.105
    title = civwar.105.t
    desc = civwar.105.d
    picture = GFX_event_technical

    trigger = {
      has_country_flag = eqs_ceasefire
      has_war = no
    }

    mean_time_to_happen = {
      days = 30
    }

    immediate = {
      clr_country_flag = eqs_ceasefire
    }

    option = {
      name = civwar.105.a
      declare_war_on = { target = EQS type = annex_everything }
      ai_chance = {
        factor = 50
        modifier = {
          factor = 2
          has_government = fascism
        }
        modifier = {
          factor = 2
          strength_ratio = { tag = EQS ratio > 0.9 }
        }
        modifier = {
          factor = 0.5
          strength_ratio = { tag = EQS ratio < 0.7 }
        }
        modifier = {
          factor = 0
          strength_ratio = { tag = EQS ratio < 0.5 }
        }
      }
    }

    option = {
      name = civwar.105.b
      ai_chance = {
        factor = 50
        modifier = {
          factor = 1.5
          OR = {
            AND = {
              has_government = democratic
              FROM = { has_government = democratic }
            }
            AND = {
              has_government = communism
              FROM = { has_government = communism }
            }
          }
        }
      }
    }
}

country_event = {
    id = civwar.103
    title = civwar.103.t
    desc = civwar.103.d
    picture = GFX_event_technical

    is_triggered_only = yes

    #Yep, let's join
    option = {
      name = civwar.103.a
      white_peace = FROM
      hidden_effect = {
        FROM = {save_event_target_as = faction_lead}
        country_event = { id = civwar.104 days = 7 }
      }
      ai_chance = {
        factor = 50
        modifier = {
          factor = 0.5
          strength_ratio = { tag = FROM ratio > 0.7 }
        }
        modifier = {
          factor = 0
          strength_ratio = { tag = FROM ratio > 0.9 }
        }
        modifier = {
          factor = 2
          OR = {
            AND = {
              has_government = democratic
              FROM = { has_government = democratic }
            }
            AND = {
              has_government = communism
              FROM = { has_government = communism }
            }
          }
        }
        modifier = {
          factor = 2
          any_enemy_country = {
            NOT = { tag = FROM }
            has_war_with = ROOT
          }
        }
        modifier = {
          factor = 2
          any_enemy_country = {
            NOT = { tag = FROM }
            has_war_with = ROOT
            strength_ratio = { tag = ROOT ratio > 0.8 }
          }
        }
      }
    }

    #Sure, ceasefire sounds nice
    option = {
      name = civwar.103.b
      white_peace = FROM
      set_country_flag = eqs_ceasefire
      hidden_effect = {
        FROM = {
          every_owned_state = {
            limit = { is_controlled_by = ROOT }
            ROOT = { transfer_state = PREV }
          }
        }
        ROOT = {
          every_owned_state = {
            limit = { is_controlled_by = FROM }
            FROM = { transfer_state = PREV }
          }
        }
      }
      ai_chance = {
        factor = 50
        modifier = {
          factor = 0.5
          strength_ratio = { tag = FROM ratio > 0.7 }
        }
        modifier = {
          factor = 0
          strength_ratio = { tag = FROM ratio > 0.9 }
        }
        modifier = {
          factor = 0.5
          any_enemy_country = {
            NOT = { tag = FROM }
            has_war_with = ROOT
          }
        }
        modifier = {
          factor = 0
          any_enemy_country = {
            NOT = { tag = FROM }
            has_war_with = ROOT
            strength_ratio = { tag = ROOT ratio > 0.8 }
          }
        }
      }
    }

    #Nah, let's fuck em up
    option = {
      name = civwar.103.c
      set_country_flag = refused_eqs_ceasefire
      ai_chance = {
        factor = 35
        modifier = {
          factor = 2
          has_government = fascism
        }
        modifier = {
          factor = 0.5
          strength_ratio = { tag = FROM ratio < 0.6 }
        }
        modifier = {
          factor = 0
          strength_ratio = { tag = FROM ratio < 0.4 }
        }
        modifier = {
          factor = 0
          surrender_progress > 0.4
        }
      }
    }
}



country_event = {
    id = civwar.2
    title = civwar.2.t
    desc = civwar.2.d
    picture = GFX_event_technical

    fire_only_once = yes

    trigger = {
    tag = SCS
    OR = {
    has_global_flag = equestrian_civil_war
    has_global_flag = equestrian_com_civil_war
        }
    }

    mean_time_to_happen = {
    days = 15
    }

    option = {
    name = civwar.2.a
    hidden_effect = {
        add_manpower = 10000
        load_oob = "SCS_Civil_War"
        }
    }
}
country_event = {
    id = civwar.3
    title = civwar.3.t
    desc = civwar.3.d
    picture = GFX_event_technical

    fire_only_once = yes

    trigger = {
    tag = VAN
    has_global_flag = equestrian_civil_war
    }

    mean_time_to_happen = {
    days = 10
    }

    option = {
    name = civwar.3.a
    hidden_effect = {
        every_state = {
                limit = {
                    is_owned_by = VAN
                }
                add_core_of = VAN
            }
        add_manpower = 5000
        load_oob = "VAN_Civil_War"
        }
    }
}
country_event = {
    id = civwar.4
    title = civwar.4.t
    desc = civwar.4.d
    picture = GFX_event_technical

    fire_only_once = yes

    trigger = {
    tag = CES
    has_global_flag = equestrian_civil_war
    }

    mean_time_to_happen = {
    days = 10
    }

    option = {
    name = civwar.4.a
    hidden_effect = {
        CES = {
			add_state_core = 35
			add_state_core = 81
			add_state_core = 50
			add_state_core = 86
			add_state_core = 15
			add_state_core = 34
			add_state_core = 33
			add_state_core = 26
			add_state_core = 351
            }
      country_event = {id = civwar.110 }
        load_oob = "CES_Civil_War"
		add_manpower = 50000
		declare_war_on = {
            target = NMS type = annex_everything
        }
        declare_war_on = {
            target = JUN type = annex_everything
        }
        EQS = { add_opinion_modifier = { target = CES modifier = besties } }
        NMS = { add_opinion_modifier = { target = CES modifier = enemies } }
        }
    }
}

country_event = {
    id = civwar.5
    title = civwar.5.t
    desc = civwar.5.d
    picture = GFX_event_technical

    fire_only_once = yes

    trigger = {
    tag = NMS
    has_global_flag = equestrian_civil_war
    }

    mean_time_to_happen = {
    days = 10
    }

    option = {
    name = civwar.5.a
    hidden_effect = {
        NMS = {
		    add_state_core = 52
			add_state_core = 25
			add_state_core = 79
			add_state_core = 353
			add_state_core = 36
			add_state_core = 32
			add_state_core = 30
			add_state_core = 17
			add_state_core = 37
			add_state_core = 81
			add_state_core = 35
      country_event = {id = civwar.110 }
            }
        load_oob = "NMS_Civil_War"
        add_manpower = 60000
        declare_war_on = {
            target = JUN type = annex_everything
        }
        declare_war_on = {
            target = CES type = annex_everything
        }
		declare_war_on = {
            target = BAL type = annex_everything
        }
        NLR = { add_opinion_modifier = { target = NMS modifier = besties } }
        CES = { add_opinion_modifier = { target = NMS modifier = enemies } }
        add_ideas = NLR_fight_to_death
        }
    }
}

country_event = {
    id = civwar.6
    title = civwar.6.t
    desc = civwar.6.d
    picture = GFX_event_technical

    fire_only_once = yes

    trigger = {
    tag = JUN
    has_global_flag = equestrian_civil_war
    }

    mean_time_to_happen = {
    days = 10
    }

    option = {
    name = civwar.6.a
    hidden_effect = {
        JUN = {
            add_state_core = 88
			add_state_core = 352
			add_state_core = 16
			add_state_core = 348
			add_state_core = 24
			add_state_core = 350
			add_state_core = 31
            }
        load_oob = "JUN_Civil_War"
		add_manpower = 50000
        declare_war_on = {
            target = NMS type = annex_everything
        }
        declare_war_on = {
            target = CES type = annex_everything
        }
            }
        }
    }
country_event = {
    id = civwar.7
    title = civwar.7.t
    desc = civwar.7.d
    picture = GFX_event_technical

    fire_only_once = yes

    trigger = {
    tag = BAL
    has_global_flag = equestrian_civil_war
    }

    mean_time_to_happen = {
    days = 10
    }

    option = {
    name = civwar.7.a
    hidden_effect = {
        BAL = {
            add_state_core = 90
			add_state_core = 82
			add_state_core = 27
			add_state_core = 28
			add_state_core = 13
            }
        load_oob = "BAL_Civil_War"
		add_manpower = 50000
        declare_war_on = {
            target = NMS type = annex_everything
        }
        STG = { add_opinion_modifier = { target = NMS modifier = besties } }
        NMS = { add_opinion_modifier = { target = NMS modifier = enemies } }
            }
        }
    }

country_event = { # IF EQS WINS
    id = civwar.9
    title = civwar.9.t
    desc = civwar.9.d
    picture = GFX_event_technical

    is_triggered_only = yes

    option = {
    name = civwar.9.a
    ai_chance = { factor = 100 }
    hidden_effect = {
        EQS = { puppet = JUN }
        }
    }
    option = {
    name = civwar.9.a
    hidden_effect = {
        EQS = { country_event = equestria.113 }
        }
    ai_chance = { factor = 0 }
    }
}
country_event = { # IF
    id = civwar.10
    title = civwar.10.t
    desc = civwar.10.d
    picture = GFX_event_technical

    is_triggered_only = yes

    option = {
    name = civwar.10.a
    ai_chance = { factor = 50 }
    hidden_effect = {
        NLR = { puppet = JUN }
        }
    }
    option = {
    name = civwar.10.a
    hidden_effect = {
        NLR = { country_event = lunas.8 }
        }
    ai_chance = { factor = 50 }
    }
}
country_event = { # NLR Support for NMS
    id = civwar.11
    title = civwar.11.t
    desc = civwar.11.d
    picture = GFX_event_technical


    is_triggered_only = yes

    option = {
    name = civwar.11.a
    add_equipment_to_stockpile = { amount = 3500 type = infantry_equipment producer = NLR }
    }
}

country_event = { # BALTIMARE GETS OFFER
    id = civwar.12
    title = civwar.12.t
    desc = civwar.12.d
    picture = GFX_event_technical

    fire_only_once = yes

    is_triggered_only = yes

    option = {
    name = civwar.12.a
    EQS = { country_event = { id = equestria.121 days = 1 }
        }
    ai_chance = { factor = 85 }
    }
    option = {
    name = civwar.12.b
    EQS = { country_event = { id = equestria.122 days = 1 }
        }
    EQS = { puppet = BAL }
    ai_chance = { factor = 15 }
    }
}
country_event = { # VAN BACK TO EQS
    id = civwar.13
    title = civwar.13.t
    desc = civwar.13.d
    picture = GFX_event_technical

    fire_only_once = yes

    is_triggered_only = yes

    option = {
    name = civwar.13.a
    EQS = { country_event = { id = equestria.124 days = 1 } }
    ai_chance = { factor = 100 }
    }
    option = {
    name = civwar.13.b
    EQS = { country_event = { id = equestria.125 days = 1 } }
    ai_chance = { factor = 0 }
    }
}
country_event = { # BALTIMARE GETS OFFER
    id = civwar.14
    title = civwar.14.t
    desc = civwar.14.d
    picture = GFX_event_technical

    trigger = {
        tag = BAL
        has_war_with = EQS
        country_exists = STG
    }
    mean_time_to_happen = { days = 1 }
    fire_only_once = yes
    option = {
    name = civwar.14.a
    STG = { country_event = { id = stalliongrad.10 days = 1 } }
    ai_chance = { factor = 100 }
    }
    option = {
    name = civwar.14.b
    add_political_power = 200
    ai_chance = { factor = 0 }
    }
}
country_event = { # BALTIMARE GETS OFFER
    id = civwar.15
    title = civwar.15.t
    desc = civwar.15.d
    picture = GFX_event_technical

    trigger = {
        tag = BAL
        has_war_with = NLR
        country_exists = STG
    }
    mean_time_to_happen = { days = 1 }
    fire_only_once = yes
    option = {
    name = civwar.15.a
    STG = { country_event = { id = stalliongrad.11 days = 1 } }
    ai_chance = { factor = 100 }
    }
    option = {
    name = civwar.15.b
    add_political_power = 200
    ai_chance = { factor = 0 }
    }
}
country_event = { # SCS GETS OFFER
    id = civwar.16
    title = civwar.16.t
    desc = civwar.16.d
    picture = GFX_event_technical

    is_triggered_only = yes

    option = {
    name = civwar.16.a
    hidden_effect = {
    EQS = { country_event = { id = equestria.122 days = 1 } }
    declare_war_on = { target = EQS type = annex_everything }
    add_political_power = 500
    remove_ideas = eqs_civil_war
    #load_oob = "SCS_Civil_War"
        }
    ai_chance = { factor = 75 }
    }
    option = {
    name = civwar.16.b
    #load_oob = "SCS_Civil_War"
    EQS = { country_event = { id = equestria.123 days = 1 } }
    ai_chance = {
      factor = 25
      modifier = {
        has_country_flag = SCS_braeburn_wins
        factor = 1.25
      }
      modifier = {
        has_country_flag = SCS_beuford_wins
        factor = 0
      }
    }
    }
}
country_event = {
    id = civwar.17
    title = civwar.17.t
    desc = civwar.17.d
    picture = GFX_event_technical

    fire_only_once = yes

    trigger = {
    tag = SCS
    ROC = { exists = yes }
    }

    mean_time_to_happen = {
    days = 15
    }

    option = {
    name = civwar.17.a
    trigger = {
        has_global_flag = equestrian_com_civil_war
    }
    declare_war_on = { target = ROC type = annex_everything }
    declare_war_on = { target = EQS type = annex_everything }
    }
    option = {
    name = civwar.17.b
    trigger = {
        has_global_flag = equestrian_civil_war
    }
    declare_war_on = { target = ROC type = annex_everything }
    }
}
country_event = {
    id = civwar.18
    title = civwar.18.t
    desc = civwar.18.d
    picture = GFX_event_technical

    fire_only_once = yes

    trigger = {
    tag = ROC
    has_government = communism
    EQS = {
        has_government = communism
        has_civil_war = no
    }
    SCS = { exists = no }
    }

    mean_time_to_happen = {
    days = 2
    }
    option = {
    name = civwar.18.a
    ai_chance = { factor = 100 }
    EQS = {
        country_event = { id = eqscom.14 days = 1 }
        }
    }
    option = {
    name = civwar.18.b
    ai_chance = { factor = 0 }
    add_political_power = 500
    }
}
country_event = {
    id = civwar.19
    title = civwar.19.t
    desc = civwar.19.d
    picture = GFX_event_technical

    fire_only_once = yes

    trigger = {
    tag = BAL
    has_government = communism
    has_global_flag = equestrian_com_civil_war
    }

    mean_time_to_happen = {
    days = 2
    }
    option = {
    name = civwar.19.a
    ai_chance = { factor = 100 }
    declare_war_on = { target = D01 type = annex_everything }
    }
}
country_event = {
    id = civwar.20
    title = civwar.20.t
    desc = civwar.20.d
    picture = GFX_event_technical

    fire_only_once = yes

    trigger = {
    tag = ROC
    has_government = communism
    has_global_flag = equestrian_com_civil_war
    }

    mean_time_to_happen = {
    days = 1
    }
    option = {
    name = civwar.20.a
    ai_chance = { factor = 100 }
    add_manpower = 11000
    add_ideas = war_communism
    every_state = {
        limit = {
            is_owned_by = ROC
        }
        add_core_of = ROC
    }
    }
}
country_event = { # FOR CES
    id = civwar.21
    title = civwar.21.t
    desc = civwar.21.d
    picture = GFX_event_technical

    is_triggered_only = yes

    option = { ## agree to be annexed
    name = civwar.21.a
    ai_chance = { base = 50
    modifier = {
        add = 30
        BAL = {
            num_of_factories > 5
            }
        }
    modifier = {
        add = 15
        BAL = {
            num_of_factories > 10
            }
        }
    modifier = {
        add = 15
        BAL = {
            owns_state = 24
            }
        }
    }
    BAL = {
        country_event = { id = baltimare.21 days = 1 }
        }
    }
    option = { ## disagree
    name = civwar.21.b
    ai_chance = { base = 50
    modifier = {
        add = 30
        BAL = {
            num_of_factories < 5
            }
        }
    modifier = {
        add = 15
        NOT = {
        BAL = {
            owns_state = 24
                }
            }
        }
    }
    BAL = {
        country_event = { id = baltimare.19 days = 1 }
        }
    }
}
country_event = { # FOR JUN
    id = civwar.22
    title = civwar.22.t
    desc = civwar.22.d
    picture = GFX_event_technical

    is_triggered_only = yes

    option = { ## agree to be annexed
    name = civwar.22.a
    ai_chance = { base = 50
    modifier = {
        add = 40
        BAL = {
            num_of_factories > 5
            }
        }
    modifier = {
        add = 30
        BAL = {
            num_of_factories > 10
            }
        }
    modifier = {
        add = 15
        BAL = {
            owns_state = 24
            }
        }
    modifier = {
        factor = 100
        BAL = {
            owns_state = 88
            }
        }
    }
    BAL = {
        country_event = { id = baltimare.20 days = 1 }
        }
    }
    option = { ## disagree
    name = civwar.22.b
    ai_chance = { base = 50
    modifier = {
        add = 30
        BAL = {
            num_of_factories < 5
            }
        }
    modifier = {
        add = 15
        NOT = {
        BAL = {
            owns_state = 24
                }
            }
        }
    modifier = {
        factor = 0
        BAL = {
            owns_state = 88
            }
        }
    }
    BAL = {
        country_event = { id = baltimare.18 days = 1 }
        }
    }
}
