﻿# On actions for army events, triggered automatically by the game

# called for armies every 30 days; exact date dependent on army ID
# root is the owner of the army
# scope:army is the army

on_army_monthly = {
	on_actions = {
		gpt_mig_on_army_monthly
	 	gpt_mig_on_siege
	 	gpt_mig_on_siege_pos
		gpt_mig_on_defensive_siege
		gpt_mig_on_defensive_siege_pos
	}
}

on_army_enter_province = {
	on_actions = {
	 	gpt_mig_on_army_move
		gpt_mig_on_army_move_pos
		gpt_mig_on_defensive_army_move
		gpt_mig_on_defensive_army_move_pos
	}
}

on_county_occupied = {
	on_actions = {
	 	delay = { days = 1 }
	 	gpt_mig_on_county_occupation
	}
}

on_combat_end_winner = {
	events = {
		gpt_mig_event.0002
	}
}

mig_on_army_monthly = { trigger = { always = no } }

gpt_mig_on_army_monthly = {
	trigger = {
		has_game_rule = GPT_all_war_events
		root = { is_ai = no }
	}
	events = {		
	}
	
	effect = {		
		root = {
			random_knight = {
				limit = { 							
					knight_army = scope:army
					is_landed = yes
					is_lowborn = no
				}
				save_scope_as = discontent_knight
			}
		}
		scope:army ?= {
			if = {
				limit = {
					exists = scope:discontent_knight
					exists = army_commander
					is_army_in_combat = no
					OR = {
						army_commander = { is_lowborn = yes }
						army_commander = { is_landed = no }
					}
					army_commander = { 
						commanding_army.army_owner = liege_or_court_owner
						NOT = {is_close_family_of = liege_or_court_owner }
					}
				}					
				army_commander = {
					random = {
						chance = 4
						trigger_event = gpt_mig_event.1001
					}
				}
			}
			
			if = {
				limit = {
					exists = army_commander
					is_army_in_combat = no
					army_commander = { 
						save_temporary_scope_as = commander
						commanding_army.army_owner = liege_or_court_owner
						is_at_war = no
					}
				}
				if = {
					limit = {
						army_commander = { 
							calc_true_if = {
								amount >= 4
								prestige_level > liege_or_court_owner.prestige_level
								has_claim_on = liege_or_court_owner.primary_title
								is_powerful_vassal = yes
								has_relation_rival = liege_or_court_owner
								has_strong_claim_on = liege_or_court_owner.primary_title
								opinion = { target = liege_or_court_owner value < -40  }	
								opinion = { target = liege_or_court_owner value < -80  }								
								OR = {
									has_trait = deceitful
									has_trait = arbitrary
									has_trait = ambitious
								}
								liege_or_court_owner = {
									trigger_if = {
										is_vassal_of = scope:army.army_commander
										limit = { scope:army.army_commander = { is_landed = yes }}
										NOT = { meets_legitimacy_expectation_of = scope:army.army_commander }
									}
									sum_of_all_skills_value <= sum_of_all_skills_threshold_poor
									is_incapable = yes
									is_adult = no
									has_any_criminal_trait_in_faith_trigger = { FAITH = faith CHARACTER = this}
									debt_level > 1
									OR = {
										government_has_flag = government_is_administrative
										government_has_flag = government_is_nomadic
									}
								}
							}
							
						}
					}
					if = {
						limit = {
							army_owner = { is_ai = no }
						}
						army_commander = {
							random = {
								chance = 25
								trigger_event = gpt_mig_event.1007
							}
						}
					}
					else = {
						army_commander = {
							random = {
								chance = 5
								trigger_event = gpt_mig_event.1007
							}
						}
					}						
				}
				else_if = {
					limit = {
						army_commander = { 
							calc_true_if = {
								amount >= 3
								prestige_level > liege_or_court_owner.prestige_level
								has_claim_on = liege_or_court_owner.primary_title
								is_powerful_vassal = yes
								has_relation_rival = liege_or_court_owner
								has_strong_claim_on = liege_or_court_owner.primary_title
								opinion = { target = liege_or_court_owner value < -40  }	
								opinion = { target = liege_or_court_owner value < -80  }								
								OR = {
									has_trait = deceitful
									has_trait = arbitrary
									has_trait = ambitious
								}
								liege_or_court_owner = {
									trigger_if = {
										is_vassal_of = scope:army.army_commander
										limit = { scope:army.army_commander = { is_landed = yes } }
										NOT = { meets_legitimacy_expectation_of = scope:army.army_commander }
									}
									sum_of_all_skills_value <= sum_of_all_skills_threshold_poor
									is_incapable = yes
									is_adult = no
									has_any_criminal_trait_in_faith_trigger = { FAITH = faith CHARACTER = this}
									debt_level > 1
									OR = {
										government_has_flag = government_is_administrative
										government_has_flag = government_is_nomadic
									}
								}
							}
						}
					}
					if = {
						limit = {
							army_owner = { is_ai = no }
						}
						army_commander = {
							random = {
								chance = 2
								trigger_event = gpt_mig_event.2007
							}
						}
					}
					else = {
						army_commander = {
							random = {
								chance = 1
								trigger_event = gpt_mig_event.2007
							}
						}
					}	
				}
			}
			if = { # no step back
				limit = {
					exists = army_commander
					is_army_in_combat = no
					army_commander = { 
						NOT = { has_character_flag = no_step_back }
						commanding_army.army_owner = liege_or_court_owner		
						opinion = { target = liege_or_court_owner value > 60  }
						OR = {
							has_trait = wrathful
							has_trait = brave
							has_relation_best_friend = liege_or_court_owner
							has_relation_friend = liege_or_court_owner
							ai_honor >= medium_positive_ai_value
						}
					}
				}					
				army_commander = {
					random = {
						chance = 33
						trigger_event = gpt_mig_event.1008
					}
					add_character_flag = { 
						flag = no_step_back
						years = 5 
					}
				}
			}
			
			if = { # betray
				limit = {
					exists = army_commander
					is_army_in_combat = no
					army_commander = { 
						liege_or_court_owner = {
							is_at_war = yes
						}
						NOT = { has_character_flag = betray_warned }
						commanding_army.army_owner = liege_or_court_owner		
						OR = {
							has_relation_rival = court_owner
							opinion = { target = liege_or_court_owner value < -60  }
							liege_or_court_owner = {
								has_imprisonment_reason = scope:army.army_commander
							}
						}
					}
				}					
				army_commander = {
					random = {
						chance = 6
						trigger_event = gpt_mig_event.2006
					}
				}
			}
		}
	}
}







gpt_mig_on_siege = {
	trigger = {
		has_game_rule = GPT_all_war_events
		root = {
			is_ai = no
			is_at_war_as_attacker = yes
			NOT = { has_character_flag = gpt_mig_invading_army_cooldown }
		}
		scope:army ?= {
			exists = army_commander
			is_army_in_siege = yes
			is_army_in_combat = no
			OR = {
				location.county.holder = { is_at_war_with = root }
				location.county.holder = { any_liege_or_above = { is_at_war_with = root } }
			}
		}
	}
	effect = {

		random_list = {
			98 = {}
			2 = {
				scope:army.location ?= { save_scope_as = gpt_mig_invading_army_county }
				scope:army.army_commander ?= { save_scope_as = gpt_mig_invading_army_commander }
				scope:army ?= { save_scope_as = gpt_mig_invading_army }
				root = {
					add_character_flag = { flag = gpt_mig_invading_army_cooldown days = 180 }
					trigger_event = gpt_mig_event_negative.0021
				}
			}
		}
	}
}

gpt_mig_on_army_move = {
	trigger = {
		has_game_rule = GPT_all_war_events
		root = {
			is_ai = no
			is_at_war_as_attacker = yes
			NOT = { has_character_flag = gpt_mig_invading_army_cooldown }
		}
		scope:army ?= {
			exists = army_commander
			is_army_in_combat = no
			OR = {
				AND = {
					exists = location
					exists = location.county
					exists = location.county
					location = { is_occupied = no }
					location.county.holder = { is_at_war_with = root }
				}
				AND = {
					exists = location
					exists = location.county
					exists = location.county.holder
					location = { is_occupied = no }
					location.county.holder = {
						any_liege_or_above = { is_at_war_with = root }
					}
				}
			}
		}
	}
	effect = {

		random_list = {
			96 = {}
			4 = {
				scope:army.location.county ?= { save_scope_as = gpt_mig_invading_army_county }
				scope:army.army_commander ?= { save_scope_as = gpt_mig_invading_army_commander }
				scope:army ?= { save_scope_as = gpt_mig_invading_army }
				root = {
					add_character_flag = { flag = gpt_mig_invading_army_cooldown days = 180 }
					trigger_event = gpt_mig_event_negative.0011
				}
			}
		}
	}
}

gpt_mig_on_siege_pos = {
	trigger = {
		has_game_rule = GPT_all_war_events
		root = {
			is_ai = no
			is_at_war_as_attacker = yes
			NOT = { has_character_flag = gpt_mig_invading_army_cooldown }
		}
		scope:army ?= {
			exists = army_commander
			is_army_in_siege = yes
			is_army_in_combat = no
			OR = {
				location.county.holder = { is_at_war_with = root }
				location.county.holder = { any_liege_or_above = { is_at_war_with = root } }
			}
		}
	}
	effect = {

		random_list = {
			99 = {}
			1 = {
				scope:army.location ?= { save_scope_as = gpt_mig_invading_army_county }
				scope:army.army_commander ?= { save_scope_as = gpt_mig_invading_army_commander }
				scope:army ?= { save_scope_as = gpt_mig_invading_army }
				root = {
					add_character_flag = { flag = gpt_mig_invading_army_cooldown days = 180 }
					trigger_event = gpt_mig_event_positive.0021
				}
			}
		}
	}
}

gpt_mig_on_army_move_pos = {
	trigger = {
		has_game_rule = GPT_all_war_events
		root = {
			is_ai = no
			is_at_war_as_attacker = yes
			NOT = { has_character_flag = gpt_mig_invading_army_cooldown }
		}
		scope:army ?= {
			exists = army_commander
			is_army_in_combat = no
			OR = {
				AND = {
					exists = location
					exists = location.county
					exists = location.county
					location = { is_occupied = no }
					location.county.holder = { is_at_war_with = root }
				}
				AND = {
					exists = location
					exists = location.county
					exists = location.county.holder
					location = { is_occupied = no }
					location.county.holder = {
						any_liege_or_above = { is_at_war_with = root }
					}
				}
			}
		}
	}
	effect = {

		random_list = {
			98 = {}
			2 = {
				scope:army.location.county ?= { save_scope_as = gpt_mig_invading_army_county }
				scope:army.army_commander ?= { save_scope_as = gpt_mig_invading_army_commander }
				scope:army ?= { save_scope_as = gpt_mig_invading_army }
				root = {
					add_character_flag = { flag = gpt_mig_invading_army_cooldown days = 180 }
					trigger_event = gpt_mig_event_positive.0011
				}
			}
		}
	}
}


gpt_mig_on_defensive_siege = {
	trigger = {
		has_game_rule = GPT_all_war_events
		root = {
			is_ai = yes
			is_at_war_as_attacker = yes
			NOT = { has_character_flag = gpt_mig_invading_army_cooldown }
			any_war_enemy = { is_ai = no }
		}
		scope:army ?= {
			exists = army_commander
			is_army_in_siege = yes
			is_army_in_combat = no
			OR = {
				location.county.holder = { is_ai = no is_at_war_with = root }
				location.county.holder = { any_liege_or_above = { is_at_war_with = root is_ai = no } }
			}
		}
	}
	effect = {

		random_list = {
			98 = {}
			2 = {
				root = { save_scope_as = gpt_mig_army_owner }
				scope:army.location ?= { save_scope_as = gpt_mig_invading_army_county }
				scope:army.army_commander ?= { save_scope_as = gpt_mig_invading_army_commander }
				scope:army ?= { save_scope_as = gpt_mig_invading_army }
				if = {
					limit = {
						scope:army ?= { location.county.holder = { is_ai = no is_at_war_with = root } }
					}
					scope:army ?= { location.county.holder = { save_scope_as = gpt_mig_player } }
				}
				if = {
					limit = {
						scope:army ?= { location.county.holder = { any_liege_or_above = { is_ai = no is_at_war_with = root } } }
					}
					scope:army ?= { location.county.holder = { 
						every_liege_or_above = { 
							limit = { is_ai = no is_at_war_with = root }
							save_scope_as = gpt_mig_player
						}
					} }
				}
				root = {
					add_character_flag = { flag = gpt_mig_invading_army_cooldown days = 180 }
				}
				scope:gpt_mig_player = {
					trigger_event = gpt_mig_event_defensive_negative.0021
				}
			}
		}
	}
}

gpt_mig_on_defensive_army_move = {
	trigger = {
		has_game_rule = GPT_all_war_events
		root = {
			is_ai = yes
			is_at_war_as_attacker = yes
			NOT = { has_character_flag = gpt_mig_invading_army_cooldown }
			any_war_enemy = { is_ai = no }
		}
		scope:army ?= {
			exists = army_commander
			is_army_in_combat = no
			OR = {
				AND = {
					exists = location
					exists = location.county
					exists = location.county
					location = { is_occupied = no }
					location.county.holder = { is_ai = no is_at_war_with = root }
				}
				AND = {
					exists = location
					exists = location.county
					exists = location.county.holder
					location = { is_occupied = no }
					location.county.holder = { any_liege_or_above = { is_at_war_with = root } }
				}
			}
		}
	}
	effect = {

		random_list = {
			96 = {}
			4 = {
				root = { save_scope_as = gpt_mig_army_owner }
				scope:army.location ?= { save_scope_as = gpt_mig_invading_army_county }
				scope:army.army_commander ?= { save_scope_as = gpt_mig_invading_army_commander }
				scope:army ?= { save_scope_as = gpt_mig_invading_army }
				if = {
					limit = {
						scope:army ?= { location.county.holder = { is_ai = no is_at_war_with = root } }
					}
					scope:army ?= { location.county.holder = { save_scope_as = gpt_mig_player } }
				}
				if = {
					limit = {
						scope:army ?= { location.county.holder = { any_liege_or_above = { is_ai = no is_at_war_with = root } } }
					}
					scope:army ?= { location.county.holder = { 
						every_liege_or_above = { 
							limit = { is_ai = no is_at_war_with = root }
							save_scope_as = gpt_mig_player
						}
					} }
				}
				root = {
					add_character_flag = { flag = gpt_mig_invading_army_cooldown days = 180 }
				}
				scope:gpt_mig_player = {
					trigger_event = gpt_mig_event_defensive_negative.0011
				}
			}
		}
	}
}

gpt_mig_on_defensive_siege_pos = {
	trigger = {
		has_game_rule = GPT_all_war_events
		root = {
			is_ai = yes
			is_at_war_as_attacker = yes
			NOT = { has_character_flag = gpt_mig_invading_army_cooldown }
			any_war_enemy = { is_ai = no }
		}
		scope:army ?= {
			exists = army_commander
			is_army_in_siege = yes
			is_army_in_combat = no
			OR = {
				location.county.holder = { is_ai = no is_at_war_with = root }
				location.county.holder = { any_liege_or_above = { is_at_war_with = root } }
			}
		}
	}
	effect = {

		random_list = {
			99 = {}
			1 = {
				root = { save_scope_as = gpt_mig_army_owner }
				scope:army.location ?= { save_scope_as = gpt_mig_invading_army_county }
				scope:army.army_commander ?= { save_scope_as = gpt_mig_invading_army_commander }
				scope:army ?= { save_scope_as = gpt_mig_invading_army }
				if = {
					limit = {
						scope:army ?= { location.county.holder = { is_ai = no is_at_war_with = root } }
					}
					scope:army ?= { location.county.holder = { save_scope_as = gpt_mig_player } }
				}
				if = {
					limit = {
						scope:army ?= { location.county.holder = { any_liege_or_above = { is_ai = no is_at_war_with = root } } }
					}
					scope:army ?= { location.county.holder = { 
						every_liege_or_above = { 
							limit = { is_ai = no is_at_war_with = root }
							save_scope_as = gpt_mig_player
						}
					} }
				}
				root = {
					add_character_flag = { flag = gpt_mig_invading_army_cooldown days = 180 }
				}
				scope:gpt_mig_player = {
					trigger_event = gpt_mig_event_defensive_positive.0021
				}
			}
		}
	}
}

gpt_mig_on_defensive_army_move_pos = {
	trigger = {
		has_game_rule = GPT_all_war_events
		root = {
			is_ai = yes
			is_at_war_as_attacker = yes
			NOT = { has_character_flag = gpt_mig_invading_army_cooldown }
			any_war_enemy = { is_ai = no }
		}
		scope:army ?= {
			exists = army_commander
			is_army_in_combat = no
			OR = {
				AND = {
					exists = location
					exists = location.county
					exists = location.county
					location = { is_occupied = no }
					location.county.holder = { is_ai = no is_at_war_with = root }
				}
				AND = {
					exists = location
					exists = location.county
					exists = location.county.holder
					location = { is_occupied = no }
					location.county.holder = { any_liege_or_above = { is_at_war_with = root } }
				}
			}
		}
	}
	effect = {

		random_list = {
			98 = {}
			2 = {
				root = { save_scope_as = gpt_mig_army_owner }
				scope:army.location ?= { save_scope_as = gpt_mig_invading_army_county }
				scope:army.army_commander ?= { save_scope_as = gpt_mig_invading_army_commander }
				scope:army ?= { save_scope_as = gpt_mig_invading_army }
				if = {
					limit = {
						scope:army ?= { location.county.holder = { is_ai = no is_at_war_with = root } }
					}
					scope:army ?= { location.county.holder = { save_scope_as = gpt_mig_player } }
				}
				if = {
					limit = {
						scope:army ?= { location.county.holder = { any_liege_or_above = { is_ai = no is_at_war_with = root } } }
					}
					scope:army ?= { location.county.holder = { 
						every_liege_or_above = { 
							limit = { is_ai = no is_at_war_with = root }
							save_scope_as = gpt_mig_player
						}
					} }
				}
				root = {
					add_character_flag = { flag = gpt_mig_invading_army_cooldown days = 180 }
				}
				scope:gpt_mig_player = {
					trigger_event = gpt_mig_event_defensive_positive.0011
				}
			}
		}
	}
}




# called when a siege completes. Does *not* fire on reoccupation by province order
# root is the occupant
# scope:barony is the barony title that got occupied
# scope:county is the county title for the barony
# scope:previous_controller is the previous controller of the county
# scope:war is the war causing the previous controller and the occupant to be hostile
# occupied_baronies is a list of all baronies that the siege caused the occupier to control (I.E., can include baronies with no fort level)
gpt_mig_on_county_occupation = {
	trigger = {
		has_game_rule = GPT_all_war_events
		root = { is_ai = no age >= 12 }
		scope:previous_controller = {
			NOR = {
				government_has_flag = government_is_nomadic
				government_has_flag = government_is_tribal
			}
		}
		root = {
			is_at_war = yes
			scope:war = {
				OR = {
					AND = {
						is_attacker = root
						attacker_war_score <= 80
					}
					AND = {
						is_defender = root
						defender_war_score <= 80
					}
				}
			}
			NOT = { has_character_flag = gpt_mig_occupation_cooldown }
			any_knight = {
				is_lowborn = no
				is_in_army = yes
			}
		}
	}

	effect = {
		
		random_list = {
			50 = {}
			50 = {
				root = { add_character_flag = { flag = gpt_mig_occupation_cooldown years = 1 } }
				random_list = {
					20 = {
						trigger = {
							root = {
								faith = { has_doctrine_parameter = male_dominated_law }
								any_knight = {
									is_male = yes
									is_in_army = yes
									has_trait = lustful
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_male = yes
									is_in_army = yes
									has_trait = lustful
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0001
						}
					}
					5 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_honor > 0
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_honor > 0
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0002
						}
					}
					5 = {
						trigger = {
							NOT = { scope:county.faith = root.faith }
							root = {
								any_knight = {
									is_in_army = yes
									ai_boldness < 0
									NOR = {
										has_trait = zealous
										has_trait = cynical
									}
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_boldness < 0
									NOR = {
										has_trait = zealous
										has_trait = cynical
									}
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0003
						}
					}
					5 = {
						trigger = {
							NOT = { scope:county.faith = root.faith }
							root = {
								any_knight = {
									is_in_army = yes
									NOR = {
										has_trait = wrathful
										has_trait = stubborn
										has_trait = zealous
									}
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									NOR = {
										has_trait = wrathful
										has_trait = stubborn
										has_trait = zealous
									}
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0004
						}
					}
					20 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
								}
							}
							scope:previous_controller = {
								any_close_or_extended_family_member = {
									NOT = { is_close_family_of = scope:previous_controller }
									is_courtier_of = scope:previous_controller
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = {
								every_close_or_extended_family_member = {
									limit = {
										is_courtier_of = scope:previous_controller
										NOT = { is_close_family_of = scope:previous_controller }
									}
									save_scope_as = gpt_mig_captured_noble
								}
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0005
						}
					}
					5 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_compassion <= -90
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_compassion <= -90
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0006
						}
					}
					5 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_boldness > 0
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_boldness > 0
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0007
						}
					}
					5 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_honor > 0
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_honor > 0
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0008
						}
					}
					5 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_compassion > 0
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_compassion > 0
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0009
						}
					}
					5 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_greed > 0
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_greed > 0
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0010
						}
					}
					5 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_greed > 0
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_greed > 0
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0011
						}
					}
					5 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_compassion < 0
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_compassion < 0
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0012
						}
					}
					5 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_vengefulness > 0
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_vengefulness > 0
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0013
						}
					}
					5 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_vengefulness < 0
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_vengefulness < 0
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0014
						}
					}
					5 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_sociability > 0
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_sociability > 0
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0015
						}
					}
					5 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_vengefulness < 0
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_vengefulness < 0
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0016
						}
					}
					5 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_boldness > 0
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_boldness > 0
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0017
						}
					}
					5 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_energy > 0
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_energy > 0
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0018
						}
					}
					5 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_honor < 0
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_honor < 0
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0019
						}
					}
					5 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_honor < 0
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_honor < 0
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0021
						}
					}
					5 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_compassion < 0
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_compassion < 0
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0022
						}
					}
					5 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_greed > 0
									NOR = {
										has_trait = zealous
									}
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_greed > 0
									NOR = {
										has_trait = zealous
									}
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0023
						}
					}
					8 = {
						trigger = {
							root = {
								any_knight = {
									is_in_army = yes
									ai_compassion > 0
									ai_honor > 0
								}
							}
						}
						root = {
							every_knight = {
								limit = {
									is_in_army = yes
									ai_compassion > 0
									ai_honor > 0
								}
								save_scope_as = gpt_mig_knight_governor
							}
							scope:previous_controller = { save_scope_as = gpt_mig_previous_ruler }
							scope:county = { save_scope_as = gpt_mig_occupied_county }
							trigger_event = gpt_mig_occupation_event.0024
						}
					}
				}
			}
		}
	}
}