
PRU_pastaza_conflict = {


	# Declare War on Ecuador
	PRU_start_military_conflict_with_ecuador  = {

		priority = 100

		icon = GFX_decision_generic_operation

		ai_will_do = {
			base = 250
			modifier = {
				factor = 0
				is_historical_focus_on = yes
				date < 1941.1.1
			}
			modifier = {
				add = 500
				is_historical_focus_on = yes
				date > 1941.6.1
			}
		}

		allowed = {
			original_tag = PRU
		}

		available = {
		
			any_state = {
				OR = {
					state = 490
					state = 1182
					state = 1188
					state = 1395
					state = 1396
					state = 1397
					state = 1398
				}
				OWNER = {
					NOT = {
						tag = ROOT
						is_ally_with = ROOT
						is_subject_of = ROOT
					}
				}
			}
			
			OR = {
				USA = {
					has_war = yes
				}
				threat > 0.35
			}
			command_power > 39

			has_war_support > 0.49

			is_in_faction = no
		}

		highlight_states = {
			highlight_states_trigger = {
				OR = {
					state = 490
					state = 1182
					state = 1188
					state = 1395
					state = 1396
					state = 1397
					state = 1398
				}
				OWNER = {
					NOT = {
						tag = ROOT
						is_ally_with = ROOT
						is_subject_of = ROOT
					}
				}
			}
		}

		visible = {
			OR = {
				NOT = { owns_state = 490 }
				NOT = { owns_state = 1182 }
				NOT = { owns_state = 1188 }
				NOT = { owns_state = 1395 }
				NOT = { owns_state = 1396 }
				NOT = { owns_state = 1397 }
				NOT = { owns_state = 1398 }
			}
		}

		cost = 100
 
		#days_remove = 14 

		fire_only_once = yes

		complete_effect = {

			add_command_power = -40

			every_country = {
				limit = {
					NOT = {
						tag = ROOT
						is_ally_with = ROOT
						is_subject_of = ROOT
					}
					OR = {
						owns_state = 490
						owns_state = 1182
						owns_state = 1188
						owns_state = 1395
						owns_state = 1396
						owns_state = 1397
						owns_state = 1398
					}
				}
				PRU = {
		            declare_war_on = {
		                target = PREV
		                type = annex_everything
		            }
		        }
			}

			ROOT = {
				add_ideas = PRU_amazonian_war
			}

			every_country = {
				limit = {
					NOT = {
						tag = ROOT
						is_ally_with = ROOT
						is_subject_of = ROOT
					}
					OR = {
						owns_state = 490
						owns_state = 1182
						owns_state = 1188
						owns_state = 1395
						owns_state = 1396
						owns_state = 1397
						owns_state = 1398
					}
				}
				add_ideas = PRU_amazonian_war
			} 

			hidden_effect = {

				set_country_flag = PRU_has_invaded_ecuador

				IF = {
					limit = {
						ECU = {
							OR = {
								owns_state = 490
								owns_state = 1182
								owns_state = 1188
								owns_state = 1395
								owns_state = 1396
								owns_state = 1397
								owns_state = 1398
							}
						}
					}
					ECU = {
						division_template = {
						    name = "Milicia Ecuatoriana"
						    is_locked = no
						    division_names_group = SPAN_INF_01
						    priority = 1
						    regiments = {
						        infantry = { x = 0 y = 0 } 
						        infantry = { x = 0 y = 1 }
						        infantry = { x = 1 y = 0 } 
						        infantry = { x = 1 y = 1 } 
						    }
						} 

						305 = {
							create_unit = {
							    division = "name = \"Milicia Quito\" division_template = \"Milicia Ecuatoriana\" start_experience_factor = 0.1 start_equipment_factor = 0.7"
							    owner = ECU 
							}
							create_unit = {
							    division = "name = \"Milicia Guayaquil\" division_template = \"Milicia Ecuatoriana\" start_experience_factor = 0.1 start_equipment_factor = 0.7"
							    owner = ECU 
							}
							create_unit = {
							    division = "name = \"Milicia Machala\" division_template = \"Milicia Ecuatoriana\" start_experience_factor = 0.1 start_equipment_factor = 0.7"
							    owner = ECU 
							}
						}
						649 = {
							create_unit = {
							    division = "name = \"Milicia Galapagos\" division_template = \"Milicia Ecuatoriana\" start_experience_factor = 0.1 start_equipment_factor = 0.2"
							    owner = ECU 
							}
						}

						add_war_support = 0.05
					}
				}
				
				IF = {
					limit = {
						ECU = {
							owns_state = 1395
						}
					}
					1395 = {
						create_unit = {
							division = "name = \"Milicia Iquitos\" division_template = \"Milicia Ecuatoriana\" start_experience_factor = 0.1 start_equipment_factor = 0.4"
							owner = ECU 
						}
					}
				}
				
				IF = {
					limit = {
						ECU = {
							owns_state = 1398
						}
					}
					1398 = {
						create_unit = {
							division = "name = \"Milicia Iquitos\" division_template = \"Milicia Ecuatoriana\" start_experience_factor = 0.1 start_equipment_factor = 0.6"
							owner = ECU 
						}
					}
				}

				news_event = {
					id = south_american_news.1 
					days = 3
					random_days = 4
				}

				IF = {
					limit = {
						has_dlc = "Trial of Allegiance"
						CHL = {
							exists = yes
							NOT = {
								OR = {
									has_war_with = ROOT
									has_subject = ROOT
									is_subject_of = ROOT
									is_in_faction_with = ROOT
								}
							}
						}
						947 = {
							is_owned_and_controlled_by = ROOT
						}
						OR = {
							951 = {
								is_owned_and_controlled_by = CHL
							}
							302 = {
								is_owned_and_controlled_by = CHL
							}
						}
					}
					CHL = {
						country_event = {
							id = CHL_political_events.21
							days = 1
						}	
					}
				}

			}
		}

		remove_effect = {

		}

	}

	# Enforce Our Claims to Pastaza
	PRU_force_peace_ecuador_good  = {

		priority = 90

		icon = GFX_decision_generic_nationalism

		ai_will_do = {
			base = 1000
		}

		allowed = {  
			original_tag = PRU
		}

		available = {
			NOT = {
				OR = {
					has_country_flag = PRU_has_ended_their_invasion_won
					has_country_flag = PRU_has_ended_their_invasion_lost		
				}
			}
			OR = {
				1188 = {
					NOT = { is_owned_by = ROOT }
					is_controlled_by = ROOT
				}
				1189 = {
					NOT = { is_owned_by = ROOT }
					is_controlled_by = ROOT
				}
				1395 = {
					NOT = { is_owned_by = ROOT }
					is_controlled_by = ROOT
				}
				1396 = {
					NOT = { is_owned_by = ROOT }
					is_controlled_by = ROOT
				}
				1398 = {
					NOT = { is_owned_by = ROOT }
					is_controlled_by = ROOT
				}
			}
			has_war = yes
		}

		visible = {
			NOT = {
				OR = {
					owns_state = 1188
					owns_state = 1189
					owns_state = 1395
					owns_state = 1396
					owns_state = 1398
				}
				OR = {
					has_country_flag = PRU_has_ended_their_invasion_won
					has_country_flag = PRU_has_ended_their_invasion_lost		
				}
			}
		}

		cost = 25
 
		#days_remove = 14  

		fire_only_once = yes

		complete_effect = {

			add_war_support = 0.1
			add_stability = 0.05
			add_political_power = 50

			hidden_effect = {
				set_country_flag = PRU_has_ended_their_invasion_won
			}	
			
			every_country = {
				limit = {
					OR = {
						owns_state = 490
						owns_state = 1182
						owns_state = 1188
						owns_state = 1395
						owns_state = 1396
						owns_state = 1397
						owns_state = 1398
					}
					has_war_with = PRU
				}
				country_event = {
					id = south_american_events.17
					hours = 3
				}
			}
		}

		remove_effect = {

		}

	}


	# Withdraw from the Amazon
	PRU_force_peace_ecuador_bad  = {

		priority = 80

		icon = GFX_decision_eng_trade_unions_support

		ai_will_do = {
			base = 500
		}

		allowed = {  
			original_tag = PRU
		}

		available = {
		
			NOT = {
				controls_state = 490
				controls_state = 1182
				controls_state = 1397
				
				OR = {
					has_country_flag = PRU_has_ended_their_invasion_won
					has_country_flag = PRU_has_ended_their_invasion_lost		
				}
			}
			has_war = yes
		}

		visible = {
			NOT = {
				OR = {
					has_country_flag = PRU_has_ended_their_invasion_won
					has_country_flag = PRU_has_ended_their_invasion_lost		
				}
			}
		}

		cost = 10
 
		#days_remove = 14  

		fire_only_once = yes

		complete_effect = {	

			every_country = {
				limit = {
					AND = {
						OR = {
							owns_state = 1182
							owns_state = 1188
							owns_state = 1395
							owns_state = 1396
							owns_state = 1397
							owns_state = 1398
						}
						has_war_with = PRU
					}
				}
				country_event = {
					id = south_american_events.20
					hours = 3
				}
			}

			add_war_support = -0.1

			add_stability = -0.05

			hidden_effect = {
				set_country_flag = PRU_has_ended_their_invasion_lost
			}
		}

		remove_effect = {

		}
	}


}

