####################################
# Spanish Nationalists AI events 32400 - 32499 by Lothos
####################################
################
# Minister of Security Section 32400 - 32409
#############################################
event = { # José Martínez de Velasco takes power
	id = 32400
	random = no 
	country = SPA
	persistent = yes
	
	trigger = {
		ai = yes
		minister = 10150 # José Martínez de Velasco
		NOT = { InCabinet = 10150 }
		OR = {
			manpower = 200
			NOT = { minister = 10127 } # Pedro Sáinz Rodríguez
		}
	}

	name = "AI_EVENT"
	style = 0	
	
	date = { day = 1 month = january year = 1936 }
	offset = 7
	deathdate = { day = 29 month = december year = 1999 }

	action_a = {
		command = { type = ministerofsecurity which = 10150 }
		command = { type = dissent value = -1 }
	}
}
event = { # Pedro Sáinz Rodríguez takes power
	id = 32401
	random = no 
	country = SPA
	persistent = yes
	
	trigger = {
		ai = yes
		minister = 10127 # Pedro Sáinz Rodríguez
		NOT = { InCabinet = 10127 }
		OR = {
			NOT = { manpower = 200 }
			NOT = { minister = 10150 } # José Martínez de Velasco
		}
	}

	name = "AI_EVENT"
	style = 0	
	
	date = { day = 1 month = january year = 1936 }
	offset = 7
	deathdate = { day = 29 month = december year = 1999 }

	action_a = {
		command = { type = ministerofsecurity which = 10127 }
		command = { type = dissent value = -1 }
	}
}
################
# Chief of Staff Section 32410 - 32419
#############################################
event = { # Luís Orgaz Yoldi takes power
	id = 32410
	random = no 
	country = SPA
	persistent = yes
	
	trigger = {
		ai = yes
		minister = 10017 # Luís Orgaz Yoldi
		NOT = { InCabinet = 10017 }
		atwar = yes
		OR = {
			AND = {
				manpower = 200
			}
			AND = {
				NOT = { manpower = 200 }
				NOT = { minister = 10200 } # Gonzalo Queipo de Llano
			}
		}
	}

	name = "AI_EVENT"
	style = 0	
	
	date = { day = 1 month = january year = 1936 }
	offset = 7
	deathdate = { day = 29 month = december year = 1999 }

	action_a = {
		command = { type = chiefofstaff which = 10017 }
		command = { type = dissent value = -1 }
	}
}
event = { # Gonzalo Queipo de Llano power
	id = 32411
	random = no 
	country = SPA
	persistent = yes
	
	trigger = {
		ai = yes
		minister = 10200 # Gonzalo Queipo de Llano
		NOT = { InCabinet = 10200 }
		OR = {
			atwar = no
			NOT = { manpower = 200 }
		}
	}

	name = "AI_EVENT"
	style = 0	
	
	date = { day = 1 month = january year = 1936 }
	offset = 7
	deathdate = { day = 29 month = december year = 1999 }

	action_a = {
		command = { type = chiefofstaff which = 10200 }
		command = { type = dissent value = -1 }
	}
}
################
# Head of Intelligence Section 32420 - 32429
#############################################
event = { # José Ungría Jiménez takes power
	id = 32420
	random = no 
	country = SPA
	persistent = yes
	
	trigger = {
		ai = yes
		minister = 10162 # José Ungría Jiménez
		NOT = { InCabinet = 10162 }
	}

	name = "AI_EVENT"
	style = 0	
	
	date = { day = 1 month = january year = 1936 }
	offset = 7
	deathdate = { day = 29 month = december year = 1999 }

	action_a = {
		command = { type = ministerofintelligence which = 10162 }
		command = { type = dissent value = -1 }
	}
}
################
# Chief of the Army Section 32430 - 32439
#############################################
event = { # Agustín Aznar Guerner takes power
	id = 32430
	random = no 
	country = SPA
	persistent = yes
	
	trigger = {
		ai = yes
		atwar = no
		minister = 10216 # Agustín Aznar Guerner
		NOT = { InCabinet = 10216 }
	}

	name = "AI_EVENT"
	style = 0	
	
	date = { day = 1 month = january year = 1936 }
	offset = 7
	deathdate = { day = 29 month = december year = 1999 }

	action_a = {
		command = { type = chiefofarmy which = 10216 }
		command = { type = dissent value = -1 }
	}
}
event = { # Francisco Franco Bahamonde takes power
	id = 32431
	random = no 
	country = SPA
	persistent = yes
	
	trigger = {
		ai = yes
		atwar = yes
		minister = 10276 # Francisco Franco Bahamonde Guerner
		NOT = { InCabinet = 10276 }
	}

	name = "AI_EVENT"
	style = 0	
	
	date = { day = 1 month = january year = 1936 }
	offset = 7
	deathdate = { day = 29 month = december year = 1999 }

	action_a = {
		command = { type = chiefofarmy which = 10276 }
		command = { type = dissent value = -1 }
	}
}
################
# Armament Minister Section 32440 - 32449
#############################################
event = { # Juan March Ordinas takes power
	id = 32440
	random = no 
	country = SPA
	persistent = yes
	
	trigger = {
		ai = yes
		minister = 10113 # Juan March Ordinas
		NOT = { InCabinet = 10113 }
	}

	name = "AI_EVENT"
	style = 0	
	
	date = { day = 1 month = january year = 1936 }
	offset = 7
	deathdate = { day = 29 month = december year = 1999 }

	action_a = {
		command = { type = armamentminister which = 10113 }
		command = { type = dissent value = -1 }
	}
}
event = { # Joaquín Bau Nolla takes power
	id = 32441
	random = no 
	country = SPA
	persistent = yes
	
	trigger = {
		ai = yes
		NOT = { minister = 10113 } # Juan March Ordinas
		minister = 10097 # Joaquín Bau Nolla
		NOT = { InCabinet = 10097 }
	}

	name = "AI_EVENT"
	style = 0	
	
	date = { day = 1 month = january year = 1936 }
	offset = 7
	deathdate = { day = 29 month = december year = 1999 }

	action_a = {
		command = { type = armamentminister which = 10097 }
		command = { type = dissent value = -1 }
	}
}





#############################################
# Regular AI Events 32460 - 34199
#############################################
################
# Spanish Civil War AI
#############################################
event = {
	id = 32460
	random = no 
	country = SPA

	trigger = {
		ai = yes
		OR = {
			war = { country = SPR country = SPA }
			event = 3100 # Spanish Civil War
		}
	}

	name = "AI_EVENT"
	style = 0	
	
	date = { day = 1 month = january year = 1936 }
	offset = 1
	deathdate = { day = 29 month = december year = 1938 }

	action_a = {
		command = { type = ai which = "switch/SPR_CivilWar.ai" }
	}
}
################
# End of Spanish Civil War AI
#############################################
event = {
	id = 32461
	random = no 
	country = SPA

	trigger = {
		ai = yes
		event = 32460
		OR = {
			NOT = { exists = SPR }
			NOT = { war = { country = SPR country = SPA } }
		}
	}

	name = "AI_EVENT"
	style = 0	
	
	date = { day = 1 month = january year = 1936 }
	offset = 1
	deathdate = { day = 29 month = december year = 1999 }

	action_a = {
		command = { type = ai which = "switch/SP_EndCivilWar.ai" }
		command = { type = sleepevent which = 32561 }
	}
}

event = { 
	id = 32464
	random = no 
	country = SPA
	persistent = yes

	trigger = {
		ai = yes
		NOT = { local_flag = spa_build_land }
		OR = {
			AND = {
				manpower = 20
				NOT = { army = 5 }
			}
			AND = {
				manpower = 40
				NOT = { army = 10 }
			}
			AND = {
				manpower = 60
				NOT = { army = 15 }
			}
			AND = {
				manpower = 80
				NOT = { army = 20 }
			}
			AND = {
				manpower = 100
				NOT = { army = 25 }
			}
			AND = {
				manpower = 120
				NOT = { army = 30 }
			}
			AND = {
				manpower = 140
				NOT = { army = 35 }
			}
			AND = {
				manpower = 160
				NOT = { army = 40 }
			}
			AND = {
				manpower = 180
				NOT = { army = 45 }
			}
			AND = {
				manpower = 200
				NOT = { army = 50 }
			}
			AND = {
				manpower = 220
				NOT = { army = 55 }
			}
			AND = {
				manpower = 240
				NOT = { army = 60 }
			}
			AND = {
				manpower = 260
				NOT = { army = 65 }
			}
			AND = {
				manpower = 280
				NOT = { army = 70 }
			}
			AND = {
				manpower = 300
				NOT = { army = 75 }
			}
			AND = {
				manpower = 320
				NOT = { army = 80 }
			}
			AND = {
				manpower = 340
				NOT = { army = 85 }
			}
			AND = {
				manpower = 360
				NOT = { army = 90 }
			}
			AND = {
				manpower = 380
				NOT = { army = 95 }
			}
			AND = {
				manpower = 400
				NOT = { army = 100 }
			}
		}
	}

	name = "AI_EVENT"
	style = 0
	
	date = { day = 1 month = january year = 1936 }
	offset = 1
	deathdate = { day = 29 month = december year = 1999 }

	action_a = {
		command = { type = ai which = "switch/spa_build_land.ai" }
		command = { type = local_setflag which = spa_build_land }
		command = { type = local_clrflag which = spa_build_standard }
	}
}

event = { 
	id = 32465
	random = no 
	country = SPA
	persistent = yes

	trigger = {
		ai = yes
		NOT = { local_flag = spa_build_standard }
		OR = {
			AND = {
				army = 5 
				NOT = { manpower = 20 }
			}
			AND = {
				army = 10 
				NOT = { manpower = 40 }
			}
			AND = {
				army = 15 
				NOT = { manpower = 60 }
			}
			AND = {
				army = 20 
				NOT = { manpower = 80 }
			}
			AND = {
				army = 25 
				NOT = { manpower = 100 }
			}
			AND = {
				army = 30 
				NOT = { manpower = 120 }
			}
			AND = {
				army = 35 
				NOT = { manpower = 140 }
			}
			AND = {
				army = 40 
				NOT = { manpower = 160 }
			}
			AND = {
				army = 45 
				NOT = { manpower = 180 }
			}
			AND = {
				army = 50 
				NOT = { manpower = 200 }
			}
			AND = {
				army = 55 
				NOT = { manpower = 220 }
			}
			AND = {
				army = 60 
				NOT = { manpower = 240 }
			}
			AND = {
				army = 65 
				NOT = { manpower = 260 }
			}
			AND = {
				army = 70 
				NOT = { manpower = 280 }
			}
			AND = {
				army = 75 
				NOT = { manpower = 300 }
			}
			AND = {
				army = 80 
				NOT = { manpower = 320 }
			}
			AND = {
				army = 85 
				NOT = { manpower = 340 }
			}
			AND = {
				army = 90 
				NOT = { manpower = 360 }
			}
			AND = {
				army = 95 
				NOT = { manpower = 380 }
			}
			army = 100
		}
	}

	name = "AI_EVENT"
	style = 0
	
	date = { day = 1 month = january year = 1936 }
	offset = 1
	deathdate = { day = 29 month = december year = 1999 }

	action_a = {
		command = { type = ai which = "switch/spa_build_standard.ai" }
		command = { type = local_clrflag which = spa_build_land }
		command = { type = local_setflag which = spa_build_standard }
	}
}

################
# Reinforcements balance events by Pang Bingxun
#############################################

event = { 
	id = 32462
	random = no 
	country = SPA
	persistent = yes

	trigger = {
		ai = yes
		NOT = { local_flag = reinforcement_020 }
		NOT = { manpower = 1 }
	}

	name = "AI_EVENT"
	style = 0
	
	date = { day = 1 month = january year = 1936 }
	offset = 1
	deathdate = { day = 29 month = december year = 1999 }

	action_a = {
		command = { type = ai which = "switch/reinforcement_020.ai" }
		command = { type = local_setflag which = reinforcement_020 }
		command = { type = local_clrflag which = reinforcement_050 }
	}
}

event = { 
	id = 32463
	random = no 
	country = SPA
	persistent = yes

	trigger = {
		ai = yes
		NOT = { local_flag = reinforcement_050 }
		manpower = 3
	}

	name = "AI_EVENT"
	style = 0
	
	date = { day = 1 month = january year = 1936 }
	offset = 1
	deathdate = { day = 29 month = december year = 1999 }

	action_a = {
		command = { type = ai which = "switch/reinforcement_050.ai" }
		command = { type = local_clrflag which = reinforcement_020 }
		command = { type = local_setflag which = reinforcement_050 }
	}
}


################
# switch capital to Madrid when possible
#############################################

event = { 
	id = 32466
	random = no 
	country = SPA
	persistent = yes

	trigger = {
		ai = yes
		NOT = { local_flag = madrid_capital }
		owned = { province = 341 data = SPA } # Madrid
		control = { province = 341 data = SPA } # Madrid
		control = { province = 338 data = SPA } # Salamanca
		control = { province = 339 data = SPA } # Valladoid
		control = { province = 340 data = SPA } # Sigüenca
		control = { province = 342 data = SPA } # Guadalajara
		control = { province = 343 data = SPA } # Badajoz
	}

	name = "AI_EVENT"
	style = 0
	
	date = { day = 1 month = january year = 1936 }
	offset = 1
	deathdate = { day = 29 month = december year = 1999 }

	action_a = {
		command = { type = capital which = 341 } # Madrid
		command = { type = local_setflag which = madrid_capital }
	}
}


