﻿#######################
# Chichen Itza Events #
#  Scripted by Happy	#
#######################

add_namespace = itz_harvest

country_event = { # Harvest time!
	immediate = { log = "[GetDateText]: [Root.GetName]: event itz_harvest.1" }
	id = itz_harvest.1
	title = itz_harvest.1.t
	desc = itz_harvest.1.d
	#picture =

	is_triggered_only = yes

	immediate = {
		hidden_effect = { # here and not in a scripted effect to make use of event's intrinsic randomness
			set_variable = { itz_harvest_random = random }
			multiply_variable = { itz_harvest_random = 0.3 } # values between 0 and 0.3
			subtract_from_variable = { itz_harvest_random = 0.25 } # values between -0.25 and 0.05
			set_variable = { temp_harvest_transplant = itz_harvest_prediction } # 4 to 0
			divide_variable = { temp_harvest_transplant = 20 } # 0.2 to 0
			subtract_from_variable = { temp_harvest_transplant = 0.1 } # 0.1 to -0.1
			add_to_variable = { itz_harvest_random = temp_harvest_transplant } # values bewteen -0.35 to 0.15
			# adding/subtracting based on agri exemptions level
			if = {
				limit = { has_idea = itz_idea_extensive_agri_expemtions }
				add_to_variable = { itz_harvest_random = 0.15 }
			}
			else_if = {
				limit = { has_idea = itz_idea_moderate_agri_expemtions }
				add_to_variable = { itz_harvest_random = 0.05 }
			}
			else_if = {
				limit = { has_idea = itz_idea_minimal_agri_expemtions }
				add_to_variable = { itz_harvest_random = -0.05 }
			}
			else_if = {
				limit = { has_idea = itz_idea_bare_minimal_agri_expemtions }
				add_to_variable = { itz_harvest_random = -0.15 }
			}
			# now values are between -0.5 and 0.4
			if = {
				limit = {
					check_variable = { itz_harvest_random < -0.4 }
				}
				set_variable = { itz_harvest_random = -0.4 }
			}
			else_if = {
				limit = {
					check_variable = { itz_harvest_random > 0.2 }
				}
				set_variable = { itz_harvest_random = 0.2 }
			}
			# itz_harvest_mp to be between 0.20 and -0.40
			set_variable = { itz_harvest_mp = itz_harvest_random }
			# itz_harvest_ws to be between 0.15 and -0.15
			add_to_variable = { itz_harvest_random = 0.10 } # values between 0.3 and -0.3
			divide_variable = { itz_harvest_random = 2 } # values between 0.15 and -0.15
			set_variable = { itz_harvest_ws = itz_harvest_random }
			clear_variable = itz_harvest_random
			# setting agri predictions for the next year
			set_variable = { itz_harvest_pred_random = random }
			multiply_variable = { itz_harvest_pred_random = 4 }
			round_variable = itz_harvest_pred_random
			if = {
				limit = {
					check_variable = { itz_harvest_random < -0.3 }
				}
				subtract_from_variable = { itz_harvest_pred_random = 1 }
			}
			else_if = {
				limit = {
					check_variable = { itz_harvest_random > 0.1 }
				}
				add_to_variable = { itz_harvest_pred_random = 1 }
			}
			if = {
				limit = {
					check_variable = { itz_harvest_pred_random < 0 }
				}
				set_variable = { itz_harvest_pred_random = 0 }
			}
			else_if = {
				limit = {
					check_variable = { itz_harvest_random > 4 }
				}
				set_variable = { itz_harvest_pred_random = 4 }
			}
			set_variable = { itz_harvest_prediction = itz_harvest_pred_random }
			clr_country_flag = itz_did_sacrifice
		}
	}

	option = {
		name = itz_harvest.1.a
		ai_chance = {
			base = 1
		}
		custom_effect_tooltip = itz_updated_harvest_tt
		hidden_effect = { force_update_dynamic_modifier = yes }
		if = {
			limit = {
				check_variable = { itz_harvest_random < -0.3 }
				OR = {
					has_idea = itz_idea_bare_minimal_agri_expemtions
					has_idea = itz_idea_minimal_agri_expemtions
					has_idea = itz_idea_light_agri_expemtions
				}
			}
			country_event = { id = itz_harvest.2 days = 7 random = 2 }
		}
		custom_effect_tooltip = itz_next_year_harvest_tt
	}
}

country_event = { # Army desertions!
	immediate = { log = "[GetDateText]: [Root.GetName]: event itz_harvest.2" }
	id = itz_harvest.2
	title = itz_harvest.2.t
	desc = itz_harvest.2.d
	#picture =

	is_triggered_only = yes

	option = {
		name = itz_harvest.2.a
		ai_chance = {
			base = 1
		}
		if = {
			limit = { has_idea = itz_idea_bare_minimal_agri_expemtions }
			swap_ideas = {
				remove_idea = itz_idea_bare_minimal_agri_expemtions
				add_idea = itz_idea_moderate_agri_expemtions
			}
		}
		else_if = {
			limit = { has_idea = itz_idea_minimal_agri_expemtions }
			swap_ideas = {
				remove_idea = itz_idea_minimal_agri_expemtions
				add_idea = itz_idea_moderate_agri_expemtions
			}
		}
		else_if = {
			limit = { has_idea = itz_idea_light_agri_expemtions }
			swap_ideas = {
				remove_idea = itz_idea_light_agri_expemtions
				add_idea = itz_idea_moderate_agri_expemtions
			}
		}
	}
}

add_namespace = nf_itz

## Opening Events

country_event = { # Red, White and Blue
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.1" }
	id = nf_itz.1
	title = nf_itz.1.t
	desc = nf_itz.1.d
	#picture =

	is_triggered_only = yes

	option = { # Red was the blood of the martyrs
		name = nf_itz.1.a
		ai_chance = {
			base = 1
		}
		add_ideas = itz_idea_the_red_blood
	}

	option = { # White was flag we flew in desparation
		name = nf_itz.1.b
		ai_chance = {
			base = 1
		}
		add_ideas = itz_idea_the_white_flag
	}

	option = { # Blue was the water we fled into
		name = nf_itz.1.c
		ai_chance = {
			base = 1
		}
		add_ideas = itz_idea_the_blue_water
	}
}

country_event = { # The Ways of Old
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.2" }
	id = nf_itz.2
	title = nf_itz.2.t
	desc = nf_itz.2.d
	#picture =

	is_triggered_only = yes

	option = { # The sanctity of the family
		name = nf_itz.2.a
		ai_chance = {
			base = 2
		}
		random_owned_state = {
			limit = {
				is_valid_state_for_civilian_factory = yes
			}
			add_extra_state_shared_building_slots = 1
			add_building_construction = {
				type = industrial_complex
				level = 1
				instant_build = yes
			}
		}
		add_resource = {
			type = water
			amount = 6
			state = 788
		}
	}

	option = { # The infallibility of the ruler
		name = nf_itz.2.b
		ai_chance = {
			base = 1
		}
		add_political_power = 120
		add_stability = 0.025
	}
}

country_event = { # The Fleet
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.3" }
	id = nf_itz.3
	title = nf_itz.3.t
	desc = nf_itz.3.d
	#picture =

	is_triggered_only = yes

	option = { # Almirante Camila's plan (river fleets)
		name = nf_itz.3.a
		ai_chance = {
			base = 1
		}
		set_technology = { river_fleet_navy_doctrine = 1 }
		add_tech_bonus = {
			bonus = 0.5
			uses = 2
			category = cat_naval_river_fleet_doctrine
		}
	}

	option = { # Almirante Mateo's plan (dispensed fleets)
		name = nf_itz.3.b
		ai_chance = {
			base = 1
		}
		set_technology = { dispersed_formations_navy_doctrine = 1 }
		add_tech_bonus = {
			bonus = 0.5
			uses = 2
			category = cat_naval_dispersed_formation_doctrine
		}
	}

	option = { # Almirante Luis' plan (fleet in being)
		name = nf_itz.3.c
		ai_chance = {
			base = 1
		}
		set_technology = { force_concentration_navy_doctrine = 1 }
		add_tech_bonus = {
			bonus = 0.5
			uses = 2
			category = cat_naval_force_concentration_doctrine
		}
	}
}

country_event = { # A Kalomte Arises
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.4" }
	id = nf_itz.4
	title = nf_itz.4.t
	desc = nf_itz.4.d
	#picture =

	is_triggered_only = yes

	option = { # His tactics and split-second choices
		name = nf_itz.4.a
		ai_chance = {
			base = 1
		}
		add_country_leader_trait = cult_of_personality
	}

	option = { # His charisma - enough to rally the retreating troops
		name = nf_itz.4.b
		ai_chance = {
			base = 1
		}
		add_country_leader_trait = smooth_talking_charmer
	}

	option = { # His keen focus on army supply
		name = nf_itz.4.c
		ai_chance = {
			base = 3
		}
		add_country_leader_trait = war_industrialist
	}
}

country_event = { # The Two Fronts
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.5" }
	id = nf_itz.5
	title = nf_itz.5.t
	desc = nf_itz.5.d
	#picture =

	is_triggered_only = yes

	option = { # Securing the west is critical
		name = nf_itz.5.a
		ai_chance = {
			base = 5
			modifier = {
				factor = 10
				ATE = { NOT = { is_ai = yes } }
			}
		}
		815 = {
			add_building_construction = {
				type = infrastructure
				level = 2
				instant_build = yes
			}
		}
		817 = {
			add_building_construction = {
				type = infrastructure
				level = 2
				instant_build = yes
			}
		}
	}

	option = { # The threats to the north are the most grave
		name = nf_itz.5.b
		ai_chance = {
			base = 5
			modifier = {
				factor = 10
				OR = {
					ARM = { NOT = { is_ai = yes } }
					PET = { NOT = { is_ai = yes } }
				}
			}
		}
		777 = {
			add_building_construction = {
				type = infrastructure
				level = 1
				instant_build = yes
			}
			if = {
				limit = {
					is_valid_state_for_arms_factory = yes
				}
				add_extra_state_shared_building_slots = 1
				add_building_construction = {
					type = arms_factory
					level = 1
					instant_build = yes
				}
			}
		}
	}
}

country_event = { # Northern Reconnaissance Mission
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.6" }
	id = nf_itz.6
	title = nf_itz.6.t
	desc = nf_itz.6.d
	#picture =

	is_triggered_only = yes

	option = { # We wish them well
		name = nf_itz.6.a
		ai_chance = {
			base = 1
		}
		PET = { country_event = { id = nf_itz.7 days = 7 random = 2 } }
	}
}

country_event = { # Visitors from the Itza
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.7" }
	id = nf_itz.7
	title = nf_itz.7.t
	desc = nf_itz.7.d
	#piture =

	is_triggered_only = yes

	option = { # Stay out of sight
		name = nf_itz.7.a
		ai_chance = {
			base = 2
		}
		ITZ = { country_event = { id = nf_itz.8 days = 7 random = 2 } }
	}

	option = { # Confuse them
		name = nf_itz.7.b
		ai_chance = {
			base = 3
		}
		ITZ = { country_event = { id = nf_itz.9 days = 7 random = 2 } }
	}

	option = { # Send them packing back to their settlements
		name = nf_itz.7.c
		ai_chance = {
			base = 1
		}
		add_manpower = -112
		ITZ = { country_event = { id = nf_itz.10 days = 7 random = 2 } }
	}
}

country_event = { # The North is Abandoned
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.8" }
	id = nf_itz.8
	title = nf_itz.8.t
	desc = nf_itz.8.d
	#picture =

	is_triggered_only = yes

	option = { # Interesting
		name = nf_itz.8.a
		ai_chance = {
			base = 1
		}
		add_equipment_to_stockpile = {
			type = melee_equipment_1
			amount = 50
			producer = PET
		}
		add_equipment_to_stockpile = {
			type = infantry_equipment_1
			amount = 50
			producer = PET
		}
	}
}

country_event = { # Chasing Ghosts
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.9" }
	id = nf_itz.9
	title = nf_itz.9.t
	desc = nf_itz.9.d
	#picture =

	is_triggered_only = yes

	option = { # Interesting
		name = nf_itz.8.a
		ai_chance = {
			base = 1
		}
		add_equipment_to_stockpile = {
			type = melee_equipment_1
			amount = 50
			producer = PET
		}
		add_equipment_to_stockpile = {
			type = infantry_equipment_1
			amount = 50
			producer = PET
		}
	}
}

country_event = { # The Last Stand of 5th Company
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.10" }
	id = nf_itz.10
	title = nf_itz.10.t
	desc = nf_itz.10.d
	#picture =

	is_triggered_only = yes

	option = { # Horrific
		name = nf_itz.10.a
		ai_chance = {
			base = 1
		}
		add_manpower = -50
		set_country_flag = itz_pet_massacre
		custom_effect_tooltip = itz_pet_massacre_tt
	}
}

country_event = { # A Test of the Man
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.11" }
	id = nf_itz.11
	title = nf_itz.11.t
	desc = nf_itz.11.d
	#picture =

	is_triggered_only = yes

	option = { # A well-planned thrust from Rey knocked Vela down!
		name = nf_itz.11.a
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				TDT_has_ai_behavior_servant = yes
			}
		}
		complete_national_focus = tdt_the_shrewd_fox
		add_popularity = {
			ideology = elites
			popularity = -0.20
		}
		add_political_power = 100
		ITZ = {
			country_event = { id = nf_itz.111 hours = 8 }
			effect_tooltip = {
				create_wargoal = {
					target = TDT
					type = puppet_wargoal_focus
				}
			}
		}
	}

	option = { # Vela's sheer force was too much for Rey to withstand for long...
		name = nf_itz.11.b
		ai_chance = {
			base = 3
			modifier = {
				factor = 0
				TDT_has_ai_behavior_fox = yes
			}
		}
		complete_national_focus = tdt_the_loyal_servant
		ITZ = {
			country_event = { id = nf_itz.110 hours = 8 }
			effect_tooltip = {
				if = {
					limit = { TDT = { is_puppet = yes } }
					TDT = {
						overlord = {
							create_wargoal = {
								target = TDT
								type = puppet_wargoal_focus
							}
							end_puppet = TDT
						}
					}
					puppet = TDT
				}
				else = {
					puppet = TDT
				}
				TDT = {
					set_politics = {
						ruling_party = elites
					}
					add_popularity = {
						ideology = elites
						popularity = 0.40
					}
				}
			}
		}
	}
}

country_event = { # Vela is victorious
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.110" }
	id = nf_itz.110
	title = nf_itz.110.t
	desc = nf_itz.110.d
	#picture =

	is_triggered_only = yes

	option = { # Good news
		name = nf_itz.110.a
		ai_chance = {
			base = 1
		}
		if = {
			limit = { TDT = { is_puppet = yes } }
			TDT = {
				overlord = {
					create_wargoal = {
						target = TDT
						type = puppet_wargoal_focus
					}
					end_puppet = TDT
				}
			}
		}
		else = {
			ITZ = { TDT = { become_puppet_of_prev = yes } }
		}
		TDT = {
			set_politics = {
				ruling_party = elites
			}
			add_popularity = {
				ideology = elites
				popularity = 0.40
			}
		}
	}
}

country_event = { # Rey survives another day
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.111" }
	id = nf_itz.111
	title = nf_itz.111.t
	desc = nf_itz.111.d
	#picture =

	is_triggered_only = yes

	option = { # If you want something done right, do it yourself!
		name = nf_itz.111.a
		ai_chance = {
			base = 1
		}
		create_wargoal = {
			target = TDT
			type = puppet_wargoal_focus
		}
	}
}

country_event = { # Raiding the Army of Mexico
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.12" }
	id = nf_itz.12
	title = nf_itz.12.t
	desc = nf_itz.12.d
	#picture =

	is_triggered_only = yes

	option = { # Target stealing weapons
		name = nf_itz.12.a
		ai_chance = {
			base = 1
		}
		set_country_flag = itz_arm_weapons
		ARM = { country_event = { id = nf_itz.13 days = 5 random = 1 } }
	}

	option = { # Target stealing military infrastructure
		name = nf_itz.12.b
		ai_chance = {
			base = 1
		}
		set_country_flag = itz_arm_mil_fac
		ARM = { country_event = { id = nf_itz.13 days = 5 random = 1 } }
	}

	option = { # Target stealing schematics
		name = nf_itz.12.c
		ai_chance = {
			base = 1
		}
		set_country_flag = itz_arm_tech
		ARM = { country_event = { id = nf_itz.13 days = 5 random = 1 } }
	}
}

country_event = { # Boats in the Night
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.13" }
	id = nf_itz.13
	title = nf_itz.13.t
	desc = nf_itz.13.d
	#picture =

	is_triggered_only = yes

	option = { # We must rebuild
		name = nf_itz.13.a
		ai_chance = {
			base = 1
		}
		if = {
			limit = { ITZ = { has_country_flag = itz_arm_weapons } }
			ITZ = { country_event = { id = nf_itz.14 days = 3 random = 1 } }
			effect_tooltip = {
				send_equipment = {
					equipment = infantry_equipment
					amount = 300
					target = ITZ
				}
			}
		}
		else_if = {
			limit = { ITZ = { has_country_flag = itz_arm_mil_fac } }
			ITZ = { country_event = { id = nf_itz.14 days = 3 random = 1 } }
			random_owned_state = {
				limit = {
					is_coastal = yes
					arms_factory > 0
				}
				if = {
					limit = { arms_factory > 1 }
					remove_building = {
						type = arms_factory
						level = 2
					}
				}
				else = {
					remove_building = {
						type = arms_factory
						level = 1
					}
				}
			}
		}
		else_if = {
			limit = { ITZ = { has_country_flag = itz_arm_tech } }
			ITZ = { country_event = { id = nf_itz.14 days = 3 random = 1 } }
			add_timed_idea = {
				idea = itz_idea_schematics_stolen_arm
				days = 180
			}
		}
	}
}

country_event = { # Raiders Return from the North
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.14" }
	id = nf_itz.14
	title = nf_itz.14.t
	desc = nf_itz.14.d
	#picture =

	is_triggered_only = yes

	option = { # Neato
		name = nf_itz.14.a
		ai_chance = {
			base = 1
		}
		if = {
			limit = { ITZ = { has_country_flag = itz_arm_weapons } }
			ARM = {
				send_equipment = {
					equipment = infantry_equipment
					amount = 300
					target = ITZ
				}
			}
			clr_country_flag = itz_arm_weapons
		}
		else_if = {
			limit = { ITZ = { has_country_flag = itz_arm_mil_fac } }
			random_owned_state = {
				limit = {
					is_coastal = yes
					is_valid_state_for_2_arms_factories = yes
				}
				add_extra_state_shared_building_slots = 2
				add_building_construction = {
					type = arms_factory
					level = 2
					instant_build = yes
				}
			}
			clr_country_flag = itz_arm_mil_fac
		}
		else_if = {
			limit = { ITZ = { has_country_flag = itz_arm_tech } }
			add_timed_idea = {
				idea = itz_idea_schematics_stolen
				days = 180
			}
			clr_country_flag = itz_arm_tech
		}
	}
}

country_event = { # Critically Injured
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.15" }
	id = nf_itz.15
	title = nf_itz.15.t
	desc = nf_itz.15.d
	#picture =

	trigger = {
		date > 2276.9.1
		OR = {
			has_completed_focus = itz_begin_integration
			has_completed_focus = itz_clashes_with_the_aztecs
			has_completed_focus = itz_and_colonies_there
		}
		OR = {
			AND = {
				has_completed_focus = itz_dockside_trade
				has_completed_focus = itz_integrated_military_economy
			}
			AND = {
				has_completed_focus = itz_promote_admiral_perez
				has_completed_focus = itz_expand_the_merodeadores
			}
			AND = {
				OR = {
					has_completed_focus = itz_dockside_trade
					has_completed_focus = itz_integrated_military_economy
				}
				OR = {
					has_completed_focus = itz_promote_admiral_perez
					has_completed_focus = itz_expand_the_merodeadores
				}
			}
		}
	}
	mean_time_to_happen = { days = 50 }
	fire_only_once = yes

	immediate = {
		hidden_effect = {
			complete_national_focus = itz_one_expedition_too_far
			country_event = { id = nf_itz.16 days = 10 }
		}
	}

	option = { # Sheiße
		name = nf_itz.15.a
		ai_chance = {
			base = 1
		}
		add_ideas = itz_idea_political_instability
		add_country_leader_trait = critically_ill
		custom_effect_tooltip = kalomte_critically_ill_flag_tt
		set_country_flag = kalomte_has_gotten_critically_ill_flag
	}
}

country_event = { # Things Falling Apart
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.16" }
	id = nf_itz.16
	title = nf_itz.16.t
	desc = nf_itz.16.d
	#picutre =

	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			complete_national_focus = itz_rapid_decline_of_society
			country_event = { id = nf_itz.19 days = 60 random = 5 }
		}
	}

	option = { # Can it get any worse?
		name = nf_itz.16.a
		ai_chance = {
			base = 1
		}
		if = {
			limit = {
				OR = {
					AND = {
						TDT = { exists = no }
						TDT = {
							any_owned_state = {
								is_core_of = TDT
								is_owned_and_controlled_by = TDT
							}
						}
					}
					TDT = { is_subject_of = ITZ }
				}
			}
			hidden_effect = { country_event = { id = nf_itz.18 days = 14 random = 2 } }
		}
		add_ideas = itz_idea_society_in_collapse
		add_ideas = itz_idea_broken_imperialism
		if = { # PET have the chance to grab some land
			limit = { PET = { is_neighbor_of = ITZ } }
			PET = { country_event = { id = nf_itz.17 days = 20 random = 2 } }
		}
		custom_effect_tooltip = itz_power_struggle_soon_tt
	}
}

country_event = { # Chaos to the South
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.17" }
	id = nf_itz.17
	title = nf_itz.17.t
	desc = nf_itz.17.d
	#picture =

	is_triggered_only = yes

	option = {
		name = nf_itz.17.a
		ai_chance = {
			base = 1
		}
		unlock_decision_tooltip = itz_pet_border_clash
	}
}

country_event = { # Tzotzil Declares Independence!
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.18" }
	id = nf_itz.18
	title = nf_itz.18.t
	desc = nf_itz.18.d
	#picture =

	is_triggered_only = yes

	option = { # We're powerless to resist
		name = nf_itz.17.a
		ai_chance = {
			base = 1
		}
		if = {
			limit = {
				TDT = {
					exists = no
					any_owned_state = {
						is_core_of = TDT
						is_owned_and_controlled_by = TDT
					}
				}
			}
			TDT = {
				release_from_prev_as_puppet = yes
				country_event = nf_tdt.7
			}
		}
		else_if = {
			limit = {
				TDT = { is_subject_of = ITZ }
			}
			end_puppet = TDT
			TDT = { country_event = nf_tdt.7 }
		}
		hidden_effect = {
			every_state = {
				limit = {
					is_core_of = TDT
					NOT = { is_owned_by = TDT }
				}
				TDT = { transfer_state = PREV }
			}
		}
	}
}

# Border clash events between PET, ATE and ITZ
add_namespace = nf_itz_border

country_event = { # Itza - PC mass on the border
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz_border.7" }
	id = nf_itz_border.7
	title = nf_itz_border.7.t
	desc = nf_itz_border.7.d
	picture = GFX_event_BRK_village_raid

	is_triggered_only = yes

	option = { # Ah shit
		ai_chance = {
			base = 1
		}
		name = nf_itz_border.7.a
	}
}

country_event = { # Itza - Itza wins clash
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz_border.8" }
	id = nf_itz_border.8
	title = nf_itz_border.8.t
	desc = nf_itz_border.8.d
	picture = GFX_event_BRK_village_raid

	is_triggered_only = yes

	option = { # nice
		name = nf_itz_border.8.a
		ai_chance = {
			base = 1
		}
		add_political_power = 50
		army_experience = 10
		add_tech_bonus = {
			bonus = 0.5
			uses = 1
			category = cat_land_doctrine
		}
	}
}

country_event = { # Itza - Itza lose
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz_border.9" }
	id = nf_itz_border.9
	title = nf_itz_border.9.t
	desc = nf_itz_border.9.d
	picture = GFX_event_BRK_village_raid

	is_triggered_only = yes

	option = { # nice
		name = nf_itz_border.9.a
		ai_chance = {
			base = 1
		}
		army_experience = 5
		effect_tooltip = { PET = { transfer_state = 777 } }
	}
}

country_event = { # Itza - clash cancelled
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz_border.10" }
	id = nf_itz_border.10
	title = nf_itz_border.10.t
	desc = nf_itz_border.10.d
	picture = GFX_event_BRK_village_raid

	is_triggered_only = yes

	option = { # nice
		name = nf_itz_border.10.a
		ai_chance = {
			base = 1
		}
		army_experience = 5
		777 = {
			decimate_half_all_industry = yes
		}
	}
}

country_event = { # PC - PC wins clash
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz_border.11" }
	id = nf_itz_border.11
	title = nf_itz_border.11.t
	desc = nf_itz_border.11.d
	picture = GFX_event_BRK_village_raid

	is_triggered_only = yes

	option = { # nice
		name = nf_itz_border.11.a
		ai_chance = {
			base = 1
		}
		army_experience = 10
		transfer_state = 777
	}
}

country_event = { # PC - PC lose clash
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz_border.12" }
	id = nf_itz_border.12
	title = nf_itz_border.12.t
	desc = nf_itz_border.12.d
	picture = GFX_event_BRK_village_raid

	is_triggered_only = yes

	option = { # nice
		name = nf_itz_border.12.a
		ai_chance = {
			base = 1
		}
		army_experience = 5
		add_political_power = -50
		add_stability = -0.10
	}
}

country_event = { # PC - clash cancelled
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz_border.13" }
	id = nf_itz_border.13
	title = nf_itz_border.13.t
	desc = nf_itz_border.13.d
	picture = GFX_event_BRK_village_raid

	is_triggered_only = yes

	option = { # nice
		name = nf_itz_border.13.a
		ai_chance = {
			base = 1
		}
		army_experience = 5
	}
}

## Power Struggle Events

country_event = { # Power is in the Air
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.19" }
	id = nf_itz.19
	title = nf_itz.19.t
	desc = nf_itz.19.d
	#picture =

	is_triggered_only = yes

	immediate = {
		hidden_effect = { complete_national_focus = itz_the_game_is_on }
	}

	option = { # The Gods are with the Ti'huun
		name = nf_itz.19.a
		ai_chance = {
			base = 2
			modifier = {
				factor = 0
				ITZ_has_ai_behavior_carlos = yes
			}
		}
		custom_effect_tooltip = itz_chose_clara_tt
		set_country_flag = itz_chose_clara
		unlock_decision_category_tooltip = itz_power_struggle
		add_popularity = {
			ideology = ruler
			popularity = -0.40
		}

	}

	option = { # The Ejército can get things done
		name = nf_itz.19.b
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				ITZ_has_ai_behavior_clara = yes
				ITZ_has_ai_behavior_kalomte = yes
			}
		}
		custom_effect_tooltip = itz_chose_ejercito_tt
		set_country_flag = itz_chose_ejercito
		unlock_decision_category_tooltip = itz_power_struggle
		add_popularity = {
			ideology = ruler
			popularity = -0.40
		}
	}
}

country_event = { # Clara Solidifies Her Power
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.20" }
	id = nf_itz.20
	title = nf_itz.20.t
	desc = nf_itz.20.d
	#picture =

	is_triggered_only = yes

	option = { # A victory for stability
		name = nf_itz.20.a
		ai_chance = {
			base = 1
		}
		add_ideas = itz_idea_ejercito_unhappy
		complete_national_focus = itz_schemes_and_stability
		set_politics = {
			ruling_party = intellectuals
		}
		clr_country_flag = itz_chose_clara
		clr_country_flag = itz_chose_ejercito
	}
}

country_event = { # The Ejercito Go All In
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.21" }
	id = nf_itz.21
	title = nf_itz.21.t
	desc = nf_itz.21.d
	#picture =

	is_triggered_only = yes

	option = { # A victory for stability
		name = nf_itz.21.a
		ai_chance = {
			base = 1
		}
		add_ideas = itz_idea_merc_unhappy
		complete_national_focus = itz_guns_and_glory
		set_politics = {
			ruling_party = elites
		}
		clr_country_flag = itz_chose_clara
		clr_country_flag = itz_chose_ejercito
	}
}

country_event = { # The Kalomte Recovers
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.22" }
	id = nf_itz.22
	title = nf_itz.22.t
	desc = nf_itz.22.d
	#picture =

	is_triggered_only = yes

	option = { # A victory for stability
		name = nf_itz.22.a
		ai_chance = {
			base = 1
		}
		remove_country_leader_trait = critically_ill
		set_country_flag = ps_complete
		add_ideas = itz_idea_ejercito_unhappy
		add_ideas = itz_idea_merc_unhappy
		complete_national_focus = itz_the_impossible_possible
		set_politics = {
			ruling_party = ruler
		}
	}
}

country_event = { # The Arrest of the Ti'huun
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.23" }
	id = nf_itz.23
	title = nf_itz.23.t
	desc = nf_itz.23.d
	#picture =

	is_triggered_only = yes

	option = { # She came quietly
		name = nf_itz.23.a
		ai_chance = {
			base = 1
		}
	}

	option = { # She fought bravely till overwhelmed
		name = nf_itz.23.b
		ai_chance = {
			base = 4
		}
		add_war_support = 0.05
		add_manpower = -32
	}
}

country_event = { # The Completion of the Grand Palace
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.24" }
	id = nf_itz.24
	title = nf_itz.24.t
	desc = nf_itz.24.d
	#picture =

	is_triggered_only = yes

	option = { # magnificant, if you overlooked the cost
		name = nf_itz.24.a
		ai_chance = {
			base = 10
			modifier = {
				factor = 0
				has_manpower < 1000
			}
		}
		add_manpower = -400
		random_owned_controlled_state = {
			limit = {
				industrial_complex > 0
			}
			remove_building = { type = industrial_complex level = 1 }
		}
		add_political_power = 100
		add_stability = 0.10
		788 = {
			add_building_construction = {
				type = bunker
				level = 4
				instant_build = yes
				province = 9325
			}
		}
	}

	option = { # grand enough for three kings
		name = nf_itz.24.b
		ai_chance = {
			base = 1
		}
		add_political_power = 40
		add_stability = 0.05
		788 = {
			add_building_construction = {
				type = bunker
				level = 3
				instant_build = yes
				province = 9325
			}
		}
	}
}

country_event = { # The Death of Sebastián
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.25" }
	id = nf_itz.25
	title = nf_itz.25.t
	desc = nf_itz.25.d
	#picture =

	trigger = {
		TAG = ITZ
		has_idea = itz_palace_built
	}
	mean_time_to_happen = { days = 110 }
	fire_only_once = yes

	option = { # Goodbye, dear Kalomte
		name = nf_itz.25.a
		ai_chance = {
			base = 1
		}
		add_stability = -0.05
	}
}

country_event = { # The Fate of the Generals
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.26" }
	id = nf_itz.26
	title = nf_itz.26.t
	desc = nf_itz.26.d
	#picture

	is_triggered_only = yes

	option = { # Execute them all
		name = nf_itz.26.a
		ai_chance = {
			base = 3
		}
		add_stability = 0.05
		remove_unit_leader = 12002
		remove_unit_leader = 12003
		remove_unit_leader = 12004
		remove_unit_leader = 12005
		# remove all Ejer generals
	}

	option = { # Execute only Carlos
		name = nf_itz.26.b
		ai_chance = {
			base = 2
		}
		remove_unit_leader = 12002
		hidden_effect = {
			random_list = {
				60 = {
					country_event = { id = nf_itz.27 days = 200 random = 40 }
				}
				40 = { } # no effect
			}
		}
	}

	option = { # Let them remain as generals - under close supervision
		name = nf_itz.26.c
		ai_chance = {
			base = 1
		}
		add_stability = -0.05
		add_war_support = 0.05
		hidden_effect = {
			random_list = {
				80 = {
					country_event = { id = nf_itz.27 days = 200 random = 40 }
				}
				20 = { } # no effect
			}
		}
		# remove noone
	}
}

country_event = { # The General's Coup
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.27" }
	id = nf_itz.27
	title = nf_itz.27.t
	desc = nf_itz.27.d
	#picture =

	is_triggered_only = yes

	option = { # put it down
		name = nf_itz.27.a
		ai_chance = {
			base = 1
		}
		add_stability = -0.10
		add_manpower = -1000
		if = {
			limit = { has_unit_leader = 12002 }
			remove_unit_leader = 12002
		}
		remove_unit_leader = 12003
		remove_unit_leader = 12004
		remove_unit_leader = 12005
	}
}

country_event = { # The Question of Succession
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.28" }
	id = nf_itz.28
	title = nf_itz.28.t
	desc = nf_itz.28.d
	#picture =

	is_triggered_only = yes

	option = { # we should use primogeniture
		name = nf_itz.28.a
		ai_chance = {
			base = 1
		}
		add_stability = 0.05
		add_war_support = 0.05
	}

	option = { # nominate a successor for elective
		name = nf_itz.28.b
		ai_chance = {
			base = 1
		}
		add_stability = 0.10
		add_political_power = 20
	}
}

country_event = {
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.29" }
	id = nf_itz.29
	title = nf_itz.29.t
	desc = nf_itz.29.d
	#picture =

	is_triggered_only = yes

	option = { # purge the bureaucracy
		name = nf_itz.29.a
		ai_chance = {
			base = 3
		}
		add_stability = 0.05
		add_timed_idea = { idea = itz_idea_purged_beuro days = 200 }
		set_global_flag = itz_purged_clara
	}

	option = { # she will have her uses
		name = nf_itz.29.b
		ai_chance = {
			base = 1
		}
		add_stability = -0.1
		add_political_power = 40
	}
}

country_event = { # The Four Year Plan
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.30" }
	id = nf_itz.30
	title = nf_itz.30.t
	desc = nf_itz.30.d
	#picture =

	is_triggered_only = yes

	option = { # Focus on construction
		name = nf_itz.30.a
		ai_chance = {
			base = 1
		}
		set_country_flag = itz_idea_fyp_construction_flg
		add_timed_idea = { idea = itz_idea_fyp_construction days = 1460 }
	}

	option = { # Focus on resource exploitation
		name = nf_itz.30.b
		ai_chance = {
			base = 1
		}
		set_country_flag = itz_idea_fyp_resources_flg
		add_timed_idea = { idea = itz_idea_fyp_resources days = 1460 }
	}

	option = { # Focus on production
		name = nf_itz.30.c
		ai_chance = {
			base = 1
		}
		set_country_flag = itz_idea_fyp_prod_flg
		add_timed_idea = { idea = itz_idea_fyp_prod days = 1460 }
	}

	option = { # Focus on research
		name = nf_itz.30.e
		ai_chance = {
			base = 1
		}
		set_country_flag = itz_idea_fyp_research_flg
		add_timed_idea = { idea = itz_idea_fyp_research days = 1460 }
	}
}

country_event = { # The Second Four Year Plan
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.300" }
	id = nf_itz.300
	title = nf_itz.300.t
	desc = nf_itz.300.d
	#picture =

	is_triggered_only = yes

	option = { # Focus on construction
		name = nf_itz.30.a #purposefully .30 for the next 4
		ai_chance = {
			base = 1
		}
		trigger = {
			NOT = { has_country_flag = itz_idea_fyp_construction_flg }
		}
		add_timed_idea = { idea = itz_idea_fyp_construction days = 1460 }
	}

	option = { # Double down on construction
		name = nf_itz.300.a
		ai_chance = {
			base = 1
		}
		trigger = {
			has_country_flag = itz_idea_fyp_construction_flg
		}
		add_timed_idea = { idea = itz_idea_fyp_construction_dd days = 1460 }
	}

	option = { # Focus on resource exploitation
		name = nf_itz.30.b
		ai_chance = {
			base = 1
		}
		trigger = {
			NOT = { has_country_flag = itz_idea_fyp_resources_flg }
		}
		add_timed_idea = { idea = itz_idea_fyp_resources days = 1460 }
	}

	option = { # Double down on resource exploitation
		name = nf_itz.300.b
		ai_chance = {
			base = 1
		}
		trigger = {
			has_country_flag = itz_idea_fyp_resources_flg
		}
		add_timed_idea = { idea = itz_idea_fyp_resources_dd days = 1460 }
	}

	option = { # Focus on production
		name = nf_itz.30.c
		ai_chance = {
			base = 1
		}
		trigger = {
			NOT = { has_country_flag = itz_idea_fyp_prod_flg }
		}
		add_timed_idea = { idea = itz_idea_fyp_prod days = 1460 }
	}

	option = { # Double down on production
		name = nf_itz.300.c
		ai_chance = {
			base = 1
		}
		trigger = {
			has_country_flag = itz_idea_fyp_prod_flg
		}
		add_timed_idea = { idea = itz_idea_fyp_prod_dd days = 1460 }
	}

	option = { # Focus on research
		name = nf_itz.30.f
		ai_chance = {
			base = 1
		}
		trigger = {
			NOT = { has_country_flag = itz_idea_fyp_research_flg }
		}
		add_timed_idea = { idea = itz_idea_fyp_research days = 1460 }
	}

	option = { # Double down on research
		name = nf_itz.300.f
		ai_chance = {
			base = 1
		}
		trigger = {
			has_country_flag = itz_idea_fyp_research_flg
		}
		add_timed_idea = { idea = itz_idea_fyp_research_dd days = 1460 }
	}
}

country_event = { # The Problem of [TDT.GetName]
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.31" }
	id = nf_itz.31
	title = nf_itz.31.t
	desc = nf_itz.31.d
	#picture =

	is_triggered_only = yes

	option = { # They need to be brough firmly into the fold.
		name = nf_itz.31.a
		ai_chance = {
			base = 2
		}
		set_country_flag = itz_tdt_reintegration
	}

	option = { # Diplomatic webweaving can get us there again.
		name = nf_itz.31.b
		ai_chance = {
			base = 1
			modifier = {
				add = 4
				is_clara_leader = yes
			}
		}
		trigger = {
			OR = {
				is_sebastian_leader = yes
				is_clara_leader = yes
			}
		}
		set_country_flag = itz_tdt_close
	}
}

country_event = { # The Itza Demands Annexation
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.32" }
	id = nf_itz.32
	title = nf_itz.32.t
	desc = nf_itz.32.d
	#picture =

	is_triggered_only = yes

	option = { # We'll be safer under the Itza.
		name = nf_itz.32.a
		ai_chance = {
			base = 4
		}
		ITZ = {
			country_event = nf_itz.33
			effect_tooltip = {
				annex_country = {
					target = TDT
					transfer_troops = no
				}
			}
		}
	}

	option = { # No, not this again!
		name = nf_itz.32.b
		ai_chance = {
			base = 2
			modifier = {
				factor = 0.5
				strength_ratio = {
					tag = ITZ
					ratio < 0.4
				}
			}
			modifier = {
				factor = 0
				strength_ratio = {
					tag = ITZ
					ratio < 0.1
				}
			}
		}
		complete_national_focus = tdt_weathering_the_storm_once_more
		ITZ = {
			country_event = nf_itz.34
			effect_tooltip = {
				create_wargoal = {
					type = annex_everything
					target = TDT
				}
			}
		}
	}
}

country_event = { # Tzotzil Accepts
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.33" }
	id = nf_itz.33
	title = nf_itz.33.t
	desc = nf_itz.33.d
	#picture =

	is_triggered_only = yes

	option = { # Excellent... wait! Where are you going!
		name = nf_itz.33.a
		ai_chance = {
			base = 1
		}
		annex_country = {
			target = TDT
			transfer_troops = no
		}
		ATE = { country_event = { id = nf_itz.35 days = 7 random = 2 } }
	}
}

country_event = { # Tzotzil Defiant
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.34" }
	id = nf_itz.34
	title = nf_itz.34.t
	desc = nf_itz.34.d
	#picture =

	is_triggered_only = yes

	option = { # Their defiance won't last long...
		name = nf_itz.34.a
		ai_chance = {
			base = 1
		}
		create_wargoal = {
			type = annex_everything
			target = TDT
		}
	}
}

country_event = { # Refugees from Tzotzil
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.35" }
	id = nf_itz.35
	title = nf_itz.35.t
	desc = nf_itz.35.d
	#picture =

	is_triggered_only = yes

	option = { # They may be useful later...
		name = nf_itz.35.a
		ai_chance = {
			base = 1
		}
		set_global_flag = ATE_refugees_from_TDT
	}
}

country_event = { # The Itza Demands Subservience
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.36" }
	id = nf_itz.36
	title = nf_itz.36.t
	desc = nf_itz.36.d
	#picture =

	is_triggered_only = yes

	option = { # We'll be safer under the Itza.
		ai_chance = {
			base = 5
		}
		name = nf_itz.36.a
		complete_national_focus = tdt_fold_to_the_storm
		ITZ = {
			country_event = nf_itz.37
			effect_tooltip = {
				puppet = TDT
			}
		}
	}

	option = { # No, not this again!
		name = nf_itz.36.b
		ai_chance = {
			base = 2
			modifier = {
				factor = 0.5
				strength_ratio = {
					tag = ITZ
					ratio < 0.4
				}
			}
			modifier = {
				factor = 0
				strength_ratio = {
					tag = ITZ
					ratio < 0.1
				}
			}
		}
		complete_national_focus = tdt_weathering_the_storm_once_more
		ITZ = {
			country_event = nf_itz.38
			effect_tooltip = {
				create_wargoal = {
					type = puppet_wargoal_focus
					target = TDT
				}
			}
		}
	}
}

country_event = { # Tzotzil Accepts
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.37" }
	id = nf_itz.37
	title = nf_itz.37.t
	desc = nf_itz.37.d
	#picture =

	is_triggered_only = yes

	option = { # Excellent!
		name = nf_itz.37.a
		ai_chance = {
			base = 1
		}
		ITZ = { TDT = { become_puppet_of_prev = yes } }
	}
}

country_event = { # Tzotzil Defiant
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.38" }
	id = nf_itz.38
	title = nf_itz.38.t
	desc = nf_itz.38.d
	#picture =

	is_triggered_only = yes

	option = { # Their defiance won't last long...
		name = nf_itz.38.a
		ai_chance = {
			base = 1
		}
		create_wargoal = {
			type = puppet_wargoal_focus
			target = TDT
		}
	}
}

country_event = { # Guns from the Itza
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.39" }
	id = nf_itz.39
	title = nf_itz.39.t
	desc = nf_itz.39.d
	#picture =

	is_triggered_only = yes

	option = { # We appreciate their gesture!
		name = nf_itz.39.a
		ai_chance = {
			base = 1
		}
		ITZ = {
			send_equipment = { target = PREV equipment = infantry_equipment amount = 500 }
			send_equipment = { target = PREV equipment = support_equipment amount = 200 }
		}
	}
}

country_event = { # The Problem of [GRH.GetName]
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.40" }
	id = nf_itz.40
	title = nf_itz.40.t
	desc = nf_itz.40.d
	#picture =

	is_triggered_only = yes

	option = { # Leaving an independent state on the border of our heartland is too great risk.
		name = nf_itz.40.a
		ai_chance = {
			base = 2
		}
		set_country_flag = itz_grh_subjects
	}

	option = { # Their efforts are admirable. Let's offer an alliance.
		name = nf_itz.40.b
		ai_chance = {
			base = 1
			modifier = {
				add = 4
				is_clara_leader = yes
			}
		}
		trigger = {
			OR = {
				is_sebastian_leader = yes
				is_clara_leader = yes
			}
		}
		set_country_flag = itz_grh_allies
	}
}

country_event = { # Itza offer an alliance
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.41" }
	id = nf_itz.41
	title = nf_itz.41.t
	desc = nf_itz.41.d
	#picture =

	is_triggered_only = yes

	option = { # sure
		name = nf_itz.41.a
		ai_chance = {
			base = 5
		}
		ITZ = {
			country_event = nf_itz.42
			if = {
				limit = { is_in_faction = no }
				create_or_join_jungle_pact = yes
			}
			GRH = { join_prev_faction = yes }
		}
	}

	option = { # nah
		name = nf_itz.41.b
		ai_chance = {
			base = 1
			modifier = {
				factor = 0.5
				strength_ratio = {
					tag = ITZ
					ratio < 0.4
				}
			}
			modifier = {
				factor = 0
				strength_ratio = {
					tag = ITZ
					ratio < 0.1
				}
			}
		}
		ITZ = { country_event = nf_itz.43 }
	}
}

country_event = { # GRH accepts
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.42" }
	id = nf_itz.42
	title = nf_itz.42.t
	desc = nf_itz.42.d
	#picture =

	is_triggered_only = yes

	option = { # sure
		name = nf_itz.42.a
		ai_chance = {
			base = 1
		}
		effect_tooltip = {
			ITZ = {
				if = {
					limit = { is_in_faction = no }
					create_or_join_jungle_pact = yes
				}
				GRH = { join_prev_faction = yes }
			}
		}
	}
}

country_event = { # GRH declines
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.43" }
	id = nf_itz.43
	title = nf_itz.43.t
	desc = nf_itz.43.d
	#picture =

	is_triggered_only = yes

	option = { # sure
		name = nf_itz.43.a
		ai_chance = {
			base = 1
		}
		set_country_flag = itz_grh_rebuff
	}
}

country_event = { # Itza demands subserviance
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.44" }
	id = nf_itz.44
	title = nf_itz.44.t
	desc = nf_itz.44.d
	#picture =

	is_triggered_only = yes

	option = { # sure
		name = nf_itz.44.a
		ai_chance = {
			base = 2
		}
		if = {
			limit = {
				GRH = { is_puppet = yes }
			}
			every_country = {
				limit = { GRH = { is_subject_of = PREV } }
				country_event = nf_itz.47
				effect_tooltip = {
					create_wargoal = {
						target = GRH
						type = puppet_wargoal_focus
					}
				}
				end_puppet = GRH
			}
		}
		ITZ = {
			country_event = nf_itz.45
			ITZ = { GRH = { become_puppet_of_prev = yes } }
			hidden_effect = {
				GRH = {
					set_politics = {
						ruling_party = people
					}
					set_political_party = {
						ideology = people
						popularity = 75
					}
				}
			}
		}
		custom_effect_tooltip = grh_chained_tt
	}

	option = { # nah
		name = nf_itz.44.b
		ai_chance = {
			base = 2
			modifier = {
				factor = 0.5
				strength_ratio = {
					tag = ITZ
					ratio < 0.6
				}
			}
			modifier = {
				factor = 0
				strength_ratio = {
					tag = ITZ
					ratio < 0.1
				}
			}
		}
		ITZ = {
			country_event = nf_itz.46
			effect_tooltip = {
				create_wargoal = {
					target = GRH
					type = puppet_wargoal_focus
				}
			}
		}
		custom_effect_tooltip = grh_prepared_tt
	}
}

country_event = { # TDT accepts
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.45" }
	id = nf_itz.45
	title = nf_itz.45.t
	desc = nf_itz.45.d
	#picture =

	is_triggered_only = yes

	option = { # sure
		name = nf_itz.45.a
		ai_chance = {
			base = 1
		}
		effect_tooltip = {
			puppet = GRH
		}
	}
}

country_event = { # TDT declines
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.46" }
	id = nf_itz.46
	title = nf_itz.46.t
	desc = nf_itz.46.d
	#picture =

	is_triggered_only = yes

	option = { # sure
		name = nf_itz.46.a
		ai_chance = {
			base = 1
		}
		create_wargoal = {
			target = GRH
			type = puppet_wargoal_focus
		}
	}
}

country_event = { # TDT pisses off
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.47" }
	id = nf_itz.47
	title = nf_itz.47.t
	desc = nf_itz.47.d
	#picture =

	is_triggered_only = yes

	option = { # sure
		name = nf_itz.47.a
		ai_chance = {
			base = 1
		}
		create_wargoal = {
			target = GRH
			type = puppet_wargoal_focus
		}
	}
}

country_event = { # The Marriage of the Ti'huun and the Commandante
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.48" }
	id = nf_itz.48
	title = nf_itz.48.t
	desc = nf_itz.48.d
	#picture =

	is_triggered_only = yes

	option = { # A wonderous occasion!
		name = nf_itz.48.a
		ai_chance = {
			base = 1
		}
		add_ideas = itz_grh_bond_of_love_idea
		set_country_flag = itz_clara_married
	}
}

country_event = { # Ti'huun Clara's Strategic Marriage
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.49" }
	id = nf_itz.49
	title = nf_itz.49.t
	desc = nf_itz.49.d
	#picture =

	is_triggered_only = yes

	option = { # Her webweaving has gained Clara yet another throne
		name = nf_itz.49.a
		ai_chance = {
			base = 1
		}
		set_country_flag = itz_clara_married
		if = {
			limit = { original_tag = TDT }
			add_country_leader_role = {
				character = TDT_tihuun_clara_guzman
				promote_character = yes
				country_leader = {
					desc = ITZ_CLARA_GUZMAN_DESC
					ideology = ideocracy
					traits = {
						political_workhorse
						expert_negotiator
					}
					expire = "3000.1.1.1"
					id = -1
				}
			}
			add_ideas = itz_idea_loyal_subject
		}
		else_if = {
			limit = { original_tag = ITZ }
			effect_tooltip = {
				TDT = {
					add_country_leader_role = {
						character = TDT_tihuun_clara_guzman
						promote_character = yes
						country_leader = {
							desc = ITZ_CLARA_GUZMAN_DESC
							ideology = ideocracy
							traits = {
								political_workhorse
								expert_negotiator
							}
							expire = "3000.1.1.1"
							id = -1
						}
					}
					add_ideas = itz_idea_loyal_subject
				}
			}
		}
	}
}

country_event = {
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.50" }
	id = nf_itz.50
	title = nf_itz.50.t
	desc = nf_itz.50.d
	#picture =

	trigger = {
		MOC = { exists = yes }
		tag = ITZ
	}

	fire_only_once = yes

	option = { # The robots strike fear into our soldiers' hearts
		name = nf_itz.50.a
		ai_chance = {
			base = 0
			modifier = {
				add = 10
				all_of_scopes = {
					array = ATE.core_states
					is_owned_by = ITZ
				}
			}
		}
		custom_effect_tooltip = itz_moc_harder_tt
		add_ideas = itz_robot_fear_3
		complete_national_focus = itz_deal_with_the_ai
	}

	option = { # Our priests had visions of this, and so we prepared!
		name = nf_itz.50.b
		ai_chance = {
			base = 1
		}
		custom_effect_tooltip = itz_moc_easier_tt
		add_ideas = itz_robot_fear_2
		complete_national_focus = itz_deal_with_the_ai
	}
}

country_event = { # Putting Out Feelers?
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.51" }
	id = nf_itz.51
	title = nf_itz.51.t
	desc = nf_itz.51.d
	#picture =

	is_triggered_only = yes

	option = { # We can't turn our back on ancient tradition like this!
		name = nf_itz.51.a
		ai_chance = {
			base = 1
		}
		trigger = {
			is_sebastian_leader = yes
			is_halach_leader = yes
		}
		custom_effect_tooltip = itz_destruction_tt
		custom_effect_tooltip = itz_locked_it_fight_tt
		set_global_flag = no_itz_ate_alliance
	}

	option = { # They must fall under Clara's thumb
		name = nf_itz.51.b
		ai_chance = {
			base = 0
		}
		trigger = {
			is_clara_leader = yes
		}
		custom_effect_tooltip = itz_destruction_tt
		set_global_flag = no_itz_ate_alliance
	}

	option = { # There's no harm in it... Right?
		name = nf_itz.51.c
		ai_chance = {
			base = 1
		}
		trigger = {
			is_clara_leader = yes
		}
		custom_effect_tooltip = itz_diplomacy_tt
		ATE = { country_event = { id = nf_itz.52 days = 15 random = 5 } }
	}
}

country_event = {
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.52" }
	id = nf_itz.52
	title = nf_itz.52.t
	desc = nf_itz.52.d
	#picture =

	is_triggered_only = yes

	option = { # They can't be serious?!?
		name = nf_itz.52.a
		ai_chance = {
			base = 2
			modifier = {
				factor = 0
				ITZ = { NOT = { is_ai = yes } }
			}
		}
		set_global_flag = no_itz_ate_alliance
		ITZ = { country_event = { id = nf_itz.53 days = 10 random = 5 } }
	}

	option = { # Well, it doesn't sound like such a terrible idea...
		name = nf_itz.52.b
		ai_chance = {
			base = 3
		}
		trigger = {
			has_government = elites
		}
		set_global_flag = itz_ate_possible_alliance
		ITZ = { country_event = { id = nf_itz.54 days = 10 random = 5 } }
	}
}

country_event = { # The Aztlan Refuse
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.53" }
	id = nf_itz.53
	title = nf_itz.53.t
	desc = nf_itz.53.d
	#picture =

	is_triggered_only = yes

	option = { # There was no harm in trying
		name = nf_itz.53.a
		ai_chance = {
			base = 1
		}
		add_political_power = -20
	}
}

country_event = { # The Aztlan Seem Receptive
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.54" }
	id = nf_itz.54
	title = nf_itz.54.t
	desc = nf_itz.54.d
	#picture =

	is_triggered_only = yes

	option = { # Let's develop this further
		name = nf_itz.54.a
		ai_chance = {
			base = 1
		}
		add_political_power = 10
	}
}

country_event = { # The Itza Demand We Pick Sides
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.55" }
	id = nf_itz.55
	title = nf_itz.55.t
	desc = nf_itz.55.d
	#picture =

	is_triggered_only = yes

	option = { # Fold to the Itza
		name = nf_itz.55.a
		ai_chance = {
			base = 3
		}
		ITZ = {
			CAF = { become_puppet_of_prev = yes }
			country_event = nf_itz.56
		}
	}

	option = { # Refuse their demands
		name = nf_itz.55.b
		ai_chance = {
			base = 4
			modifier = {
				factor = 0.5
				strength_ratio = {
					tag = ITZ
					ratio < 0.4
				}
			}
			modifier = {
				factor = 0
				strength_ratio = {
					tag = ITZ
					ratio < 0.2
				}
			}
		}
		ITZ = {
			country_event = nf_itz.57
			effect_tooltip = {
				create_wargoal = {
					type = puppet_wargoal_focus
					target = CAF
				}
			}
		}
	}
}

country_event = { # CAF Folds
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.56" }
	id = nf_itz.56
	title = nf_itz.56.t
	desc = nf_itz.56.d
	#picture =

	is_triggered_only = yes

	option = { #
		name = nf_itz.56.a
		ai_chance = {
			base = 1
		}
		effect_tooltip = {
			puppet = CAF
		}
	}
}

country_event = { # CAF refuses
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.57" }
	id = nf_itz.57
	title = nf_itz.57.t
	desc = nf_itz.57.d
	#picture =

	is_triggered_only = yes

	option = { #
		name = nf_itz.57.a
		ai_chance = {
			base = 1
		}
		declare_war_on = {
			type = puppet_wargoal_focus
			target = CAF
		}
	}
}

country_event = {
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.58" }
	id = nf_itz.58
	title = nf_itz.58.t
	desc = nf_itz.58.d
	#picture =

	is_triggered_only = yes

	option = { # War it is
		name = nf_itz.58.a
		trigger = {
			NOT = { is_in_faction_with = ATE }
		}
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				has_global_flag = itz_ate_possible_alliance
			}
		}
		set_country_flag = itz_ate_des
	}

	option = { # Peace can be negotiated!
		name = nf_itz.58.b
		ai_chance = {
			base = 1
		}
		trigger = {
			OR = {
				has_global_flag = itz_ate_possible_alliance
				is_in_faction_with = ATE
			}
		}
		set_country_flag = itz_ate_dip
	}
}

country_event = { # The Marriage of Clara and Armando
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.59" }
	id = nf_itz.59
	title = nf_itz.59.t
	desc = nf_itz.59.d
	#picture =

	is_triggered_only = yes

	option = { #
		name = nf_itz.59.a
		ai_chance = {
			base = 1
		}
		effect_tooltip = {
			create_or_join_mesoamerican_alliance = yes
			ATE = { join_mesoamerican_alliance = yes }
		}
		set_country_flag = itz_clara_married
	}
}

news_event = { # The Birth of the Mesoamerican Alliance
	id = nf_itz.60
	title = nf_itz.60.t
	desc = nf_itz.60.d
	#picture =
	major = yes

	is_triggered_only = yes

	option = { #
		name = nf_itz.60.a
		ai_chance = {
			base = 1
		}
	}
}

country_event = { # Aztlan Civil War
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.61" }
	id = nf_itz.61
	title = nf_itz.61.t
	desc = nf_itz.61.d
	picture = GFX_event_mexico_city_ruins

	mean_time_to_happen = { days = 7 }

	trigger = {
		ATE = { has_civil_war = yes }
		original_tag = ITZ
		has_war = no
		OR = {
			NOT = { owns_state = 817 }
			NOT = { owns_state = 815 }
			NOT = { owns_state = 803 }
		}
	}

	option = { # Sounds like ours for the taking
		name = nf_itz.61.a
		ai_chance = {
			base = 1
		}
		transfer_state = 817
		transfer_state = 815
		transfer_state = 803
	}
}

country_event = {
	immediate = { log = "[GetDateText]: [Root.GetName]: event nf_itz.62" }
	id = nf_itz.62
	title = nf_itz.62.t
	desc = nf_itz.62.d
	#picture =

	is_triggered_only = yes

	option = { # Attempt to heal him!
		name = nf_itz.62.a
		ai_chance = {
			base = 2
			modifier = {
				factor = 0
				check_variable = { KalomteHealAttemptes > 1 }
			}
		}
		add_to_variable = { var = KalomteHealAttemptes value = 1 tooltip = KalomteHeal }
	}

	option = {
		name = nf_itz.62.b
		trigger = {
			OR = {
				check_variable = { KalomteHealAttemptes > 1 }
				ITZ_has_ai_behavior_kalomte = yes
			}
			ITZ_has_ai_behavior_carlos = no
			ITZ_has_ai_behavior_clara = no
		}
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				OR = {
					ITZ_has_ai_behavior_carlos = yes
					ITZ_has_ai_behavior_clara = yes
				}
			}
		}
		country_event = { id = nf_itz.22 days = 4 random = 2 }
		set_country_flag = itz_kalomte_recovers
		clr_country_flag = itz_chose_clara
		clr_country_flag = itz_chose_ejercito
	}
}

# Power Struggle Events
add_namespace = itz_ps

country_event = { # Raid on the Ej HQ
	immediate = { log = "[GetDateText]: [Root.GetName]: event itz_ps.1" }
	id = itz_ps.1
	title = itz_ps.1.t
	desc = itz_ps.1.d
	#picture =

	trigger = {
		has_country_flag = itz_chose_ejercito
	}

	mean_time_to_happen = { days = 80 }
	fire_only_once = yes

	option = {
		name = itz_ps.1.a
		ai_chance = {
			base = 1
		}
		add_manpower = -200
		random_owned_state = {
			limit = { arms_factory > 0 }
			remove_building = {
				type = arms_factory
				level = 1
			}
		}
		add_popularity = {
			ideology = elites
			popularity = -0.10
		}
	}
}

country_event = { # Clara Appears with the Kalomte
	immediate = { log = "[GetDateText]: [Root.GetName]: event itz_ps.2" }
	id = itz_ps.2
	title = itz_ps.2.t
	desc = itz_ps.2.d
	#picture =

	trigger = {
		has_country_flag = itz_chose_ejercito
	}

	mean_time_to_happen = { days = 40 }

	option = { #
		name = itz_ps.2.a
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				ITZ_has_ai_behavior_carlos = yes
			}
		}
		add_popularity = {
			ideology = intellectuals
			popularity = 0.05
		}
	}

	option = { # Two can play at that game!
		name = itz_ps.2.b
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				OR = {
					ITZ_has_ai_behavior_clara = yes
					ITZ_has_ai_behavior_kalomte = yes
				}
			}
		}
		trigger = {
			OR = {
				has_political_power > 20
				ITZ_has_ai_behavior_carlos = yes
			}
		}
		if = {
			limit = { has_political_power > 20 }
			add_political_power = -20
		}
	}
}

country_event = { # Clara Tries to Heal the Kalomte
	immediate = { log = "[GetDateText]: [Root.GetName]: event itz_ps.3" }
	id = itz_ps.3
	title = itz_ps.3.t
	desc = itz_ps.3.d
	#picture =

	trigger = {
		has_country_flag = itz_chose_ejercito
	}

	mean_time_to_happen = { days = 60 }

	option = { # Let her try!
		name = itz_ps.3.a
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				ITZ_has_ai_behavior_carlos = yes
			}
		}
		add_popularity = {
			ideology = intellectuals
			popularity = 0.05
		}
		random_list = {
			10 = {
				country_event = { id = nf_itz.22 days = 4 random = 2 }
				set_country_flag = itz_kalomte_recovers
				clr_country_flag = itz_chose_clara
				clr_country_flag = itz_chose_ejercito
			}
			90 = {	}
		}
	}

	option = { # Meddle with the research
		name = itz_ps.3.b
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				OR = {
					ITZ_has_ai_behavior_clara = yes
					ITZ_has_ai_behavior_kalomte = yes
				}
			}
		}
		trigger = {
			OR = {
				has_political_power > 20
				ITZ_has_ai_behavior_carlos = yes
			}
		}
		if = {
			limit = { has_political_power > 20 }
			add_political_power = -20
		}
		random_list = {
			20 = {
				add_popularity = {
					ideology = elites
					popularity = -0.05
				}
			}
		}
	}
}

country_event = { # Clara Expands the Merodeadores
	immediate = { log = "[GetDateText]: [Root.GetName]: event itz_ps.4" }
	id = itz_ps.4
	title = itz_ps.4.t
	desc = itz_ps.4.d
	#picture =

	trigger = {
		has_country_flag = itz_chose_ejercito
	}

	mean_time_to_happen = { days = 50 }

	option = { # Let her try!
		name = itz_ps.4.a
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				ITZ_has_ai_behavior_carlos = yes
			}
		}
		add_popularity = {
			ideology = intellectuals
			popularity = 0.05
		}
		random_owned_state = {
			custom_effect_tooltip = itz_clara_raise_mero
			hidden_effect = {
				create_unit = {
					division = "name = \"Nuevos Merodeadores\" division_template = \"División de Merodeadores\" start_experience_factor = 0.2 start_equipment_factor = 0.8"
					owner = ITZ
				}
			}
		}
	}

	option = { # Sabotage her recruitment
		name = itz_ps.4.b
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				OR = {
					ITZ_has_ai_behavior_clara = yes
					ITZ_has_ai_behavior_kalomte = yes
				}
			}
		}
		trigger = {
			OR = {
				has_political_power > 20
				ITZ_has_ai_behavior_carlos = yes
			}
		}
		if = {
			limit = { has_political_power > 20 }
			add_political_power = -20
		}
		army_experience = -10
	}
}

country_event = { # Raid on the Mero HQ
	immediate = { log = "[GetDateText]: [Root.GetName]: event itz_ps.5" }
	id = itz_ps.5
	title = itz_ps.5.t
	desc = itz_ps.5.d
	#picture =

	trigger = {
		has_country_flag = itz_chose_clara
	}

	mean_time_to_happen = { days = 80 }
	fire_only_once = yes

	option = {
		name = itz_ps.5.a
		ai_chance = {
			base = 1
		}
		add_manpower = -200
		random_owned_state = {
				limit = { dockyard > 0 }
				remove_building = {
					type = dockyard
					level = 1
				}
			}
		add_popularity = {
			ideology = intellectuals
			popularity = -0.10
		}
	}
}

country_event = { # Ej Hold a Parade
	immediate = { log = "[GetDateText]: [Root.GetName]: event itz_ps.6" }
	id = itz_ps.6
	title = itz_ps.6.t
	desc = itz_ps.6.d
	#picture =

	trigger = {
		has_country_flag = itz_chose_ejercito
	}

	mean_time_to_happen = { days = 40 }

	option = { # Let it happen
		name = itz_ps.6.a
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				OR = {
					ITZ_has_ai_behavior_clara = yes
					ITZ_has_ai_behavior_kalomte = yes
				}
			}
		}
		add_popularity = {
			ideology = elites
			popularity = 0.05
		}
	}

	option = { # Organise a counter parade!
		name = itz_ps.6.b
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				ITZ_has_ai_behavior_carlos = yes
			}
		}
		trigger = {
			OR = {
				has_political_power > 20
				OR = {
					ITZ_has_ai_behavior_clara = yes
					ITZ_has_ai_behavior_kalomte = yes
				}
			}
		}
		if = {
			limit = { has_political_power > 20 }
			add_political_power = -20
		}
	}
}

country_event = { # Carlos Encourages Conscription
	immediate = { log = "[GetDateText]: [Root.GetName]: event itz_ps.7" }
	id = itz_ps.7
	title = itz_ps.7.t
	desc = itz_ps.7.d
	#picture =

	trigger = {
		has_country_flag = itz_chose_ejercito
	}

	mean_time_to_happen = { days = 60 }

	option = { # Let her try!
		name = itz_ps.7.a
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				OR = {
					ITZ_has_ai_behavior_clara = yes
					ITZ_has_ai_behavior_kalomte = yes
				}
			}
		}
		add_popularity = {
			ideology = elites
			popularity = 0.05
		}
		add_manpower = 300
	}

	option = { # Sabotage his recruitment
		name = itz_ps.7.b
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				ITZ_has_ai_behavior_carlos = yes
			}
		}
		trigger = {
			OR = {
				has_political_power > 20
				OR = {
					ITZ_has_ai_behavior_clara = yes
					ITZ_has_ai_behavior_kalomte = yes
				}
			}
		}
		if = {
			limit = { has_political_power > 20 }
			add_political_power = -20
		}
		army_experience = -10
	}
}

country_event = { # Ej Produce Consumer Goods
	immediate = { log = "[GetDateText]: [Root.GetName]: event itz_ps.8" }
	id = itz_ps.8
	title = itz_ps.8.t
	desc = itz_ps.8.d
	#picture =

	trigger = {
		has_country_flag = itz_chose_ejercito
	}

	mean_time_to_happen = { days = 50 }

	option = { # Let her try!
		name = itz_ps.4.a
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				ITZ_has_ai_behavior_carlos = yes
			}
		}
		add_popularity = {
			ideology = intellectuals
			popularity = 0.05
		}
		random_owned_state = {
			limit = { arms_factory > 0 }
			remove_building = {
				type = arms_factory
				level = 1
			}
			add_building_construction = {
				type = industrial_complex
				level = 1
				instant_build = yes
			}
		}
	}

	option = { # Two can play at that game!
		name = itz_ps.4.b
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				OR = {
					ITZ_has_ai_behavior_clara = yes
					ITZ_has_ai_behavior_kalomte = yes
				}
			}
		}
		trigger = {
			OR = {
				has_political_power > 20
				ITZ_has_ai_behavior_carlos = yes
			}
		}
		if = {
			limit = { has_political_power > 20 }
			add_political_power = -20
		}
	}
}
# vim: set ft=pdx ts=2 sw=2 tw=79 :
