war_planning = {
	SPR_mexican_reform_war_purchase_usa_support = {
		icon = power_struggle
		available = { 
			set_temp_variable = { loan_size_to_check = 200}
			has_less_than_specific_loan_size = yes 
			USA = { set_temp_variable = { loan_size_to_check = 200}
			has_less_than_specific_loan_size = yes }
			custom_trigger_tooltip = {
				tooltip = USA_loan_support_limit_tooltip
				check_variable = { var = USA_debt_repayments_level value = 15 compare = less_than_or_equals }
			}
		}
		custom_cost_trigger = {
			set_temp_variable = { amount_of_money_to_check = 0.5 }
		}
		custom_cost_text = eoanb_money_cost_text
		visible = { USA = { has_country_flag = USA_mexican_reform_war_loans_flag } }
		allowed = { tag = MEX }
		fire_only_once = no
		days_re_enable = 15
		days_remove = 7
		complete_effect = {
			set_temp_variable = { money_to_gain = -0.5 }
			add_money_with_tooltip_effect = yes	
			if = {
				limit = { NOT = { OR = { TAG = D01 TAG = D02 TAG = D03 TAG = D04 } } }
				set_temp_variable = { money_to_gain = -0.3 }
				add_money_with_tooltip_effect = yes	
			}
		}
		remove_effect = {
			add_equipment_to_stockpile = {
				type = infantry_equipment_rifle_1
				amount = 1500
				producer = USA
			}
			add_equipment_to_stockpile = {
				type = uniform_equipment_1
				amount = 1500
				producer = USA
			}
			add_equipment_to_stockpile = {
				type = cavalry_equipment_0
				amount = 500
				producer = USA
			}
			add_war_support = 0.01
		}
		ai_will_do = {
			base = 10
			modifier = {
				factor = 0
				set_temp_variable = { loan_size_to_check = 45 }
				has_less_than_specific_loan_size = no				
			}
		}
	}
}

political_actions = {
	
	MEX_mexican_reform_war_resistance_476 = {
		icon = power_struggle
		available = { 476 = { resistance < 10 } }
		visible = { has_country_flag = MEX_mexican_reform_war_resistance_flag }
		allowed = { tag = MEX }
		fire_only_once = yes
		days_remove = 7
		remove_effect = {
			476 = { 
				hidden_effect = { remove_claim_by = MEC }
				force_disable_resistance = {
					clear = yes
					occupier = MEX
					occupied = MEC
				}
				custom_effect_tooltip = MEX_mexican_reform_war_resistance_removal_tooltip
			}
		}
		ai_will_do = { base = 100 }
	}
	MEX_mexican_reform_war_resistance_475 = {
		icon = power_struggle
		available = { 475 = { resistance < 10 } }
		visible = { has_country_flag = MEX_mexican_reform_war_resistance_flag }
		allowed = { tag = MEX }
		fire_only_once = yes
		days_remove = 7
		remove_effect = {
			475 = { 
				hidden_effect = { remove_claim_by = MEC }
				force_disable_resistance = {
					clear = yes
					occupier = MEX
					occupied = MEC
				}
				custom_effect_tooltip = MEX_mexican_reform_war_resistance_removal_tooltip
			}
		}
		ai_will_do = { base = 100 }
	}
	MEX_mexican_reform_war_resistance_474 = {
		icon = power_struggle
		available = { 474 = { resistance < 10 } }
		visible = { has_country_flag = MEX_mexican_reform_war_resistance_flag }
		allowed = { tag = MEX }
		fire_only_once = yes
		days_remove = 7
		remove_effect = {
			474 = { 
				hidden_effect = { remove_claim_by = MEC }
				force_disable_resistance = {
					clear = yes
					occupier = MEX
					occupied = MEC
				}
				custom_effect_tooltip = MEX_mexican_reform_war_resistance_removal_tooltip
			}
		}
		ai_will_do = { base = 100 }
	}
	MEX_mexican_reform_war_resistance_481 = {
		icon = power_struggle
		available = { 481 = { resistance < 10 } }
		visible = { has_country_flag = MEX_mexican_reform_war_resistance_flag }
		allowed = { tag = MEX }
		fire_only_once = yes
		days_remove = 7
		remove_effect = {
			481 = { 
				hidden_effect = { remove_claim_by = MEC }
				force_disable_resistance = {
					clear = yes
					occupier = MEX
					occupied = MEC
				}
				custom_effect_tooltip = MEX_mexican_reform_war_resistance_removal_tooltip
			}
		}
		ai_will_do = { base = 100 }
	}
	MEX_mexican_reform_war_resistance_482 = {
		icon = power_struggle
		available = { 482 = { resistance < 10 } }
		visible = { has_country_flag = MEX_mexican_reform_war_resistance_flag }
		allowed = { tag = MEX }
		fire_only_once = yes
		days_remove = 7
		remove_effect = {
			482 = { 
				hidden_effect = { remove_claim_by = MEC }
				force_disable_resistance = {
					clear = yes
					occupier = MEX
					occupied = MEC
				}
				custom_effect_tooltip = MEX_mexican_reform_war_resistance_removal_tooltip
			}
		}
		ai_will_do = { base = 100 }
	}
	MEX_mexican_reform_war_resistance_483 = {
		icon = power_struggle
		available = { 483 = { resistance < 10 } }
		visible = { has_country_flag = MEX_mexican_reform_war_resistance_flag }
		allowed = { tag = MEX }
		fire_only_once = yes
		days_remove = 7
		remove_effect = {
			483 = { 
				hidden_effect = { remove_claim_by = MEC }
				force_disable_resistance = {
					clear = yes
					occupier = MEX
					occupied = MEC
				}
				custom_effect_tooltip = MEX_mexican_reform_war_resistance_removal_tooltip
			}
		}
		ai_will_do = { base = 100 }
	}
	MEX_mexican_reform_war_resistance_1125 = {
		icon = power_struggle
		available = { 1125 = { resistance < 10 } }
		visible = { has_country_flag = MEX_mexican_reform_war_resistance_flag }
		allowed = { tag = MEX }
		fire_only_once = yes
		days_remove = 7
		remove_effect = {
			1125 = { 
				hidden_effect = { remove_claim_by = MEC }
				force_disable_resistance = {
					clear = yes
					occupier = MEX
					occupied = MEC
				}
				custom_effect_tooltip = MEX_mexican_reform_war_resistance_removal_tooltip
			}
		}
		ai_will_do = { base = 100 }
	}
	
	

	
	
MEX_decision_claim_mexican_crown = {

	available = {
		original_tag = MEX
		has_government = autocracy
		NOT = { country_exists = MEX }
	}

	visible = {
		original_tag = MEX
		has_government = autocracy
		NOT = { country_exists = MEX }
	}
	allowed = { TAG = MEX }

	fire_only_once = yes

	cost = 15

	complete_effect = {
		custom_effect_tooltip = MEX_decision_claim_mexican_crown_tt
		hidden_effect = {
		every_owned_state = {
			limit = {
			is_core_of = MEX
			}
			MEX = {
			transfer_state = PREV
			}
		}
		MEX = {
			change_tag_from = FROM
		}
		FRA = {
			set_autonomy = {
				target = MEX
				autonomous_state = autonomy_imperial_protectorate
				freedom_level = 0.3
			}
		}
		MEX = {
			set_politics = {
			ruling_party = autocracy
			elections_allowed = no
			}
			create_country_leader = {
			name = "Maximilian-Ferdinand of Austria"
			picture= GFX_Portrait_MXE_Maxililian_Ferdinand
			ideology = despotism
			}
		}
		}
	}

	ai_will_do = {
		base = 1000
	}
}
}

MEX_decision_category_republican_forces = {

	MEX_decision_northern_militias = {
		#allowed = { tag = MEX }
		highlight_states = {
			state = 482
		}
		available = {
			has_full_control_of_state = 482
			OR = { has_war_with = FRA has_war_with = MXE }
			tag = MEX
			surrender_progress > 0.4
		}
		visible = {
			OR = { has_war_with = FRA has_war_with = MXE }
			tag = MEX
		}

		cancel_trigger = {
				NOT = { controls_state = 482 }
		}

		fire_only_once = yes
		days_remove = 5
		cost = 50

		ai_will_do = {
			factor = 3
			modifier = {
				factor = 2.0
				has_full_control_of_state = 482
			}
		}

		complete_effect = {
		add_political_power = 70
			add_war_support = 0.03
			add_stability = -0.03
		}
		remove_effect = {
			hidden_effect = {
				 482 = {
					create_unit = {
						division = "name = \"Plateados\" division_template = \"Plateados\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Plateados\" division_template = \"Plateados\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Rurales\" division_template = \"Rurales\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Rurales\" division_template = \"Rurales\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Rurales\" division_template = \"Rurales\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Republican guerrilla\" division_template = \"Republican guerrilla\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Republican guerrilla\" division_template = \"Republican guerrilla\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Republican guerrilla\" division_template = \"Republican guerrilla\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Republican guerrilla\" division_template = \"Republican guerrilla\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Republican Infantry\" division_template = \"Republican Infantry\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Republican Infantry\" division_template = \"Republican Infantry\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Battalion of Supremos Podores\" division_template = \"Battalion of Supremos Podores\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
				}
			}
		}
	}

	MEX_decision_central_militias = {
		#allowed = { tag = MEX }
		highlight_states = {
			state = 1112
		}
		available = {
			has_full_control_of_state = 1112
			OR = { has_war_with = FRA has_war_with = MXE }
			tag = MEX
			surrender_progress > 0.2
		}
		visible = {
			OR = { has_war_with = FRA has_war_with = MXE }
			tag = MEX
		}

		cancel_trigger = {
				NOT = { controls_state = 1112 }
		}

		fire_only_once = yes
		days_remove = 5
		cost = 50

		ai_will_do = {
			factor = 3
			modifier = {
				factor = 2.0
				has_full_control_of_state = 1112
			}
		}

		complete_effect = {
			add_political_power = 70
			add_war_support = 0.03
			add_stability = -0.03
		}
		remove_effect = {
			hidden_effect = {
				1112 = {
					create_unit = {
						division = "name = \"Plateados\" division_template = \"Plateados\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Rurales\" division_template = \"Rurales\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Rurales\" division_template = \"Rurales\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Republican guerrilla\" division_template = \"Republican guerrilla\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Republican guerrilla\" division_template = \"Republican guerrilla\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Republican Infantry\" division_template = \"Republican Infantry\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Republican Infantry\" division_template = \"Republican Infantry\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
				}
			}
		}
	}

	MEX_decision_southern_militias = {
		#allowed = { tag = MEX }
		highlight_states = {
			state = 476
		}
		available = {
			has_full_control_of_state = 476
			OR = { has_war_with = FRA has_war_with = MXE }
			tag = MEX
			surrender_progress > 0.2
		}
		visible = {
			OR = { has_war_with = FRA has_war_with = MXE }
			tag = MEX
		}

		cancel_trigger = {
				NOT = { controls_state = 476 }
		}

		fire_only_once = yes
		days_remove = 5
		cost = 50

		ai_will_do = {
			factor = 3
			modifier = {
				factor = 2.0
				has_full_control_of_state = 476
			}
		}

		complete_effect = {
		add_political_power = 70
			add_war_support = 0.03
			add_stability = -0.03
		}
		remove_effect = {
			hidden_effect = {
				476 = {
					create_unit = {
						division = "name = \"Plateados\" division_template = \"Plateados\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Rurales\" division_template = \"Rurales\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Rurales\" division_template = \"Rurales\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Republican guerrilla\" division_template = \"Republican guerrilla\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Republican guerrilla\" division_template = \"Republican guerrilla\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Republican Infantry\" division_template = \"Republican Infantry\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"State Militia\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
				}
			}
		}
	}

	MEX_decision_porfirios_legions = {
		#allowed = { tag = MEX }
		highlight_states = {
			state = 480
		}
		available = {
			has_full_control_of_state = 480
			OR = { has_war_with = FRA has_war_with = MXE }
			tag = MEX
		}
		visible = {
			OR = { has_war_with = FRA has_war_with = MXE }
			tag = MEX
		}

		cancel_trigger = {
				NOT = { controls_state = 480 }
		}

		fire_only_once = yes
		days_remove = 5
		cost = 50

		ai_will_do = {
			factor = 3
			modifier = {
				factor = 2.0
				has_full_control_of_state = 480
			}
		}

		complete_effect = {
		add_political_power = 70
			add_war_support = 0.03
			add_stability = -0.03
		}
		remove_effect = {
			hidden_effect = {
				480 = {
					create_unit = {
						division = "name = \"Porfirio's Legion\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Porfirio's Legion\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Porfirio's Legion\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Porfirio's Legion\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Porfirio's Legion\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Porfirio's Legion\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Porfirio's Legion\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Porfirio's Legion\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Porfirio's Legion\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
					create_unit = {
						division = "name = \"Porfirio's Legion\" division_template = \"State Militia\"	start_experience_factor = 0.0"
						owner = MEX
					}
				}
			}
		}
	}

	MEX_decision_american_advisors = {

	icon = generic_construction

		available = {
		tag = MEX
			has_idea = MEX_american_support
			OR = { has_war_with = MXE has_war_with = FRA }
		}

		visible = {
		tag = MEX
		}
		#allowed = { tag = MEX }

		fire_only_once = yes
		is_good = yes

		cost = 100

	complete_effect = {
		set_country_flag = MEX_american_advisors
			custom_effect_tooltip = MEX_vic_usa_advisors_tt
		}

		ai_will_do = {
			base = 1
		}
	}
}

MEX_decision_category_foreign_policy = {
	# Mexican Debt Intervention (End Maxmillian Installation)
	MEX_decision_mexican_intervention = {
		icon = generic_political_discourse

		activation = {
			has_country_flag = MEX_Debt_Intervention_Flag
			OR = {
				has_war_with = ENG
				has_war_with = SPR
				has_war_with = FRA
			}
			all_owned_state = { is_controlled_by = ROOT }
		}

		available = { always = no }

		
		allowed = { 
			OR = {
				tag = MEX
				tag = MEC
				tag = USA
				tag = SPR
				tag = ENG
				tag = FRA
			}
		}

		visible = {
			OR = {
				tag = MEX
				tag = MEC
				tag = USA
				if = {
					limit = {
						OR = {
							ENG = { has_war_with = MEX }
							ENG = { has_war_with = MEC }
						}
					}
					tag = ENG
				}
				if = {
					limit = {
						OR = {
						FRA = { has_war_with = MEX }
						FRA = { has_war_with = MEC }
						}
					}
					tag = FRA
				}
				if = {
					limit = {
						OR = {
						SPR = { has_war_with = MEX }
						SPR = { has_war_with = MEC }
						}
					}
					tag = SPR
				}
			}
		}

		cancel_trigger = {
			if = {
				limit = { country_exists = MEX }
				MEX = { all_owned_state = { is_controlled_by = MEX } }
			}
			else_if = {
				limit = { country_exists = MEC }
				MEX = { all_owned_state = { is_controlled_by = MEC } }
			}
			else = {

			}
		}

		fire_only_once = yes

		ai_will_do = {
			base = 4000
		}
		is_good = yes

		days_mission_timeout = 1200

		timeout_effect = {
			if = {
				limit = {
					OR = {
						tag = MEX
						tag = MEC
					}
				}
				custom_effect_tooltip = MEX_decision_mexican_intervention_1_trigger_tt
				ROOT = {
					if = {
					limit = {
						has_war_with = ENG
						controls_state = 311
					}
					transfer_state = 311
					hidden_effect = {
						add_state_core = 311
						ENG = {
						remove_state_core = 311
						remove_state_claim = 311
						country_event = { id = nap_france.36201 }
						}
					}
					white_peace = ENG
					}
					if = {
					limit = {
						has_war_with = ENG
						NOT = { controls_state = 311 }
					}
					white_peace = ENG
					hidden_effect = {
						ENG = { country_event = { id = nap_france.36201 } }
					}
					}
					if = {
					limit = { has_war_with = SPR }
					white_peace = SPR
					hidden_effect = {
						ENG = { country_event = { id = nap_france.36201 } }
					}
					}
					if = {
					limit = { has_war_with = FRA }
					white_peace = FRA
					hidden_effect = {
						ENG = { country_event = { id = nap_france.36201 } }
					}
					}
				}
				hidden_effect = {
					ROOT = { clr_country_flag = MEX_Debt_Intervention_Flag }
					ENG = { clr_country_flag = ENG_mexican_intervention_flag }
					SPR = { clr_country_flag = SPR_mexican_intervention_flag }
					FRA = { clr_country_flag = FRA_mexican_intervention_flag }
				}
			}
			else_if = {
				custom_effect_tooltip = MEX_decision_mexican_intervention_2_trigger_tt
			}
		}
	}
}