#
# The Great War mod.
#
# AI events by maizenkor, altered by P Tan
#
# id 7xxxxx
#
# The dates of the plans must not cross each other to make sure only one plan is selected
# and the correct probabilities are used.
# 

##############################################################################
# GERMANY.
# 700xxx
# Germany has 2 plans:
#   1) Schlieffen plan : West first through Belgium,Luxemburg (historical)
#   2) East first. 
##############################################################################

################################
# Schlieffen Historical Plan.
################################
# Select Schlieffen plan buildup.
event = {
	id = 700000
	random = no
	country = GER
	
	name = "AI_EVENT"
	desc = ""
	style = 0
	
	action_a = { 
		command = { type = ai which = "tgw_ger_1914_schlieffen.ai" } 
                command = { type = sleepevent which = 700020 }
        }
}

################################
# Kaiserschlacht
################################
# Throw everything at France
event = {
	id = 700010
	random = no
	country = GER
	
	trigger = {
	ai = yes
	war = { country = GER country = FRA }
	war = { country = GER country = ENG }	
	
	OR = {
		NOT = { 
		war = { country = GER country = RUS } 
		war = { country = GER country = SOV } 
		}
		}
	}

	name = "AI_EVENT"
	desc = ""
	style = 0
	
	date = { day = 1 month = june year = 1914 }
	offset = 15
	deathdate = { day = 15 month = june year = 1925 }
	
	action_a = { 
		command = { type = ai which = "tgw_ger_kaiserschlacht.ai" } 
        }
}

##############################
# Non-Historical Russia first.
##############################
event = {
	id = 700020
	random = no
	country = GER
	
	trigger = { 
	ai = yes 
	NOT = { 
	war = { country = GER country = BEL } 
	}
	war = { country = GER country = FRA }
	war = { country = GER country = RUS }
        }

	name = "AI_EVENT"
	desc = ""
	style = 0
	
	date = { day = 30 month = july year = 1914 }
	offset = 5
	deathdate = { day = 30 month = june year = 1925 }
	
	action_a = { 
		command = { type = ai which = "tgw_ger_1914_russia.ai" } 
                command = { type = sleepevent which = 700000 }
	}
}

#################################################
# Focus on Russia once trench warfare has set in
#################################################
event = {
	id = 700030
	random = no
	country = GER
	
	trigger = { 
	ai = yes 
	war = { country = GER country = FRA }
	war = { country = GER country = RUS }
	OR = {
	event = 62017
	event = 62022
	event = 62027
	event = 62028
	event = 62029
	}
        }

	name = "AI_EVENT"
	desc = ""
	style = 0
	
	date = { day = 1 month = january year = 1915 }
	offset = 5
	deathdate = { day = 30 month = june year = 1925 }
	
	action_a = { 
		command = { type = ai which = "tgw_ger_1914_russia.ai" } 
		command = { type = trigger which = 600003 }
	}
}

##############################
# Sealion
##############################

event = {
	id = 700040
	random = no
	country = GER
	
	trigger = { 
	ai = yes 
	OR = { # Treaty of Strasbourg must have happened
	event which = 20810 
	event which = 20811 
	}
	OR = {
	OR = {
	event = 48709 # Treaty of Tilsit
	event = 74002 # Soviet German peace
	}
	AND = {
	event = 74003 # No Soviet German peace
	NOT = { exists = SOV }
	}
	}
	NOT = { 
	war = { country = GER country = FRA } 
	war = { country = GER country = RUS }
	}
	war = { country = GER country = ENG }
        }

	name = "AI_EVENT"
	desc = ""
	style = 0
	
	date = { day = 30 month = july year = 1916 }
	offset = 5
	deathdate = { day = 30 month = june year = 1925 }
	
	action_a = { 
		command = { type = ai which = "tgw_ger_sealion.ai" } 
	}
}


######################################################################################################
# AUSTRIA-HUNGARY.
# 710xxx
# Austria-Hungary has 2 opening plans :
# 80% : 1) Plan B: Serbia first (historical).
# 20% : 2) Plan R: Russia first (historically switched when invasion of Serbia didn't work)
#
# If Italy leave the Alliance a plan is triggered to handle that.
#
######################################################################################################

###############
# Plan B.
# Serbia first.
###############
# somewhere between 1 June - 15 June 1914.
event = {
	id = 710000
	random = no
	country = U11
	
	trigger = { 
          ai = yes 
          random = 80  # 80% of chance.
        }

	name = "AI_EVENT"
	desc = ""
	style = 0
	
	date = { day = 1 month = june year = 1914 }
	offset = 15
	deathdate = { day = 15 month = june year = 1914 }
	
	action_a = { 
		command = { type = ai which = "tgw_ah_1914_planB.ai" } 
                # sleep other plans.
                command = { type = sleepevent which = 710010 }
	}
}

###############
# Plan R.
# Russia First.
###############
# somewhere between 15 June - 20 June 1914, if Plan B not choosen.
event = {
	id = 710010
	random = no
	country = U11
	
	trigger = { 
          ai = yes
# if we are here the first plan did not fire so select this one.
        }

	name = "AI_EVENT"
	desc = ""
	style = 0
	
	date = { day = 15 month = june year = 1914 }
	offset = 5
	deathdate = { day = 20 month = june year = 1914 }
	
	action_a = { 
		command = { type = ai which = "tgw_ah_1914_planR.ai" } 
                # sleep other plans.
                command = { type = sleepevent which = 710000 }
	}
}


################################################################# 
# PLAN I
# Italy backstab and leave the Alliance.
# Must not be "sleeped" by other plans, it overrides other plans.
#################################################################
event = {
	id = 710020
	random = no
	country = U11
	
	trigger = { 
          ai = yes
	  NOT = { alliance = { country = U11 country = ITA } }  # Italy leaves our alliance.
        }

	name = "AI_EVENT"
	desc = ""
	style = 0
	
	date = { day = 0 month = january year = 1914 }
	offset = 1
	deathdate = { day = 30 month = december year = 1947 }
	
	action_a = { 
		command = { type = ai which = "tgw_ah_planI.ai" } 
	}
}


##########################################################################################
# FRANCE.
# 720xxx
# France has only 1 plan:
# 1) Plan XVII : invade Germany to get Alsace-Lorraine back (historical).
#
# When Germany invades Belgium -and is successful- the AI reacts by repositioning troops.
##########################################################################################


# React to German invasion of Belgium.
event = {
	id = 720010
	random = no
	country = FRA
	
	trigger = { 
          ai = yes 
	  # Germans have successfully invaded Belgium.
	  # Joffre did nothing until the Germans were camping in Northern France.
	  AND = {
		control = { province = 557 data = GER }  # Arlon.
		control = { province = 552 data = GER }  # Bruxelles.
		control = { province = 548 data = GER }  # Antwerp.		
 	  }
        }

	name = "AI_EVENT"
	desc = ""
	style = 0
	
	date = { day = 0 month = january year = 1914 }
	offset = 1
	deathdate = { day = 30 month = december year = 1947 }
	
	action_a = { 
		command = { type = ai which = "tgw_fra_1914_plan17_belgium.ai" } 
	}
}


#################################################
# RUSSIA.
# 730xxx
# Russia has 2 plans:
# 80% 1) Plan 19/A : invade Germany (historical).
# 20% 2) Plan G    : defend in depth. 
#################################################

#######################
# Plan 19/A Historical.
#######################
# Plan 19/A.
# 80% chance, somewhere between 15 May - 15 June 1914.
event = {
	id = 730000
	random = no
	country = RUS
	
	trigger = { 
          ai = yes 
          random = 80 # 80% of chance to select Plan 19/A.
        }

	name = "AI_EVENT"
	desc = ""
	style = 0
	
	date = { day = 15 month = may year = 1914 }
	offset = 30
	deathdate = { day = 15 month = june year = 1914 }
	
	action_a = { 
		command = { type = ai which = "tgw_rus_1914_plan19A.ai" } 
                # sleep other plans.
                command = { type = sleepevent which = 730010 }
	}
}


########################
# Plan G Non Historical.
########################
# Plan G.
# somewhere between 16 June - 20 June 1914.
event = {
	id = 730010
	random = no
	country = RUS
	
	trigger = { 
          ai = yes 
# if we are here the first plan did not fire so select this one.
        }

	name = "AI_EVENT"
	desc = ""
	style = 0
	
	date = { day = 16 month = june year = 1914 }
	offset = 4
	deathdate = { day = 20 month = june year = 1914 }
	
	action_a = { 
		command = { type = ai which = "tgw_rus_1914_planG.ai" } 
                # sleep other plans.
                command = { type = sleepevent which = 730000 }
	}
}

########################
# USA goes to war
########################
event = {
	id = 740000
	random = no
	country = USA
	
	trigger = { 
        ai = yes 
	atwar = yes
        }

	name = "AI_EVENT"
	desc = ""
	style = 0
	
	date = { day = 1 month = january year = 1914 }
	offset = 1
	deathdate = { day = 1 month = january year = 1947 }
	
	action_a = { 
		command = { type = ai which = "usa_war.ai" } 
               	}
}


##################################
# Romania joins Central Powers
##################################
event = {
	id = 750000
	random = no
	country = ROM
	
	trigger = { 
        ai = yes 
	war = { country = ROM country = RUS }
	OR = {
	alliance = { country = ROM country = U11 }
	alliance = { country = ROM country = GER }
	}
        }

	name = "AI_EVENT"
	desc = ""
	style = 0
	
	date = { day = 1 month = january year = 1914 }
	offset = 1
	deathdate = { day = 1 month = january year = 1947 }
	
	action_a = { 
		command = { type = ai which = "romania_central.ai" } 
               	}
}

################################
# Italy joins Entente
################################
event = {
	id = 760000
	random = no
	country = ITA
	
	trigger = {
	ai = yes
	war = { country = ITA country = U11 }
	OR = {
		alliance = { country = ITA country = FRA }
		alliance = { country = ITA country = ENG }
	}
	}

	name = "AI_EVENT"
	desc = ""
	style = 0
	
	date = { day = 1 month = january year = 1914 }
	offset = 15
	deathdate = { day = 15 month = june year = 1925 }
	
	action_a = { 
		command = { type = ai which = "italy_entente.ai" } 
        }
}