﻿

on_declared_war = {
	###############################
	##### Attacker music
	###############################
	#AGOT ADDED
	if = {
		limit = {
			exists = scope:war
			OR = {
				scope:attacker = { is_current_dragonrider = yes }
				scope:defender = { is_current_dragonrider = yes }
			}
		}
		scope:attacker = { play_music_cue = mood_dragons_at_war }
	}
	else_if = {
		limit = {
			exists = scope:war # silence error when building description before war exists
			scope:war = { using_holy_war_cb_trigger = yes } # going CB->war->is this war's CB a certain type->yes
		}
		scope:attacker = { play_music_cue = mx_cue_crusade_starts }
	}
	else_if = {
		limit = {
			exists = scope:war
			OR = {
				#AGOT Modified
				# scope:attacker = { fp3_character_any_involvement_persian_struggle_trigger = yes }
				# scope:defender = { fp3_character_any_involvement_persian_struggle_trigger = yes }
				scope:attacker = { fp2_character_any_involvement_btw_struggle_trigger = yes }
				scope:defender = { fp2_character_any_involvement_btw_struggle_trigger = yes }
			}
		}
		scope:attacker = { play_music_cue = strugglewar_cue }
	}
	else_if = {
		limit = {
			exists = scope:war
			#AGOT Edited
			#OR = {
			#	scope:attacker = { fp2_character_any_involvement_iberian_struggle_trigger = yes }
			#	scope:defender = { fp2_character_any_involvement_iberian_struggle_trigger = yes }
			#}
			OR = {
				scope:attacker = { 
					AND = {
						exists = capital_province
						capital_province = { geographical_region = world_westeros_dorne }
					}
				}
				scope:defender = { 
					AND = {
						exists = capital_province
						capital_province = { geographical_region = world_westeros_dorne }
					}
				}
			}
		}
		scope:attacker = { play_music_cue = mx_IberiaWar }
	}
	else_if = {
		limit = {
			exists = scope:war
			#AGOT Modified
			#scope:attacker = { fp1_is_norse_tribal = yes }
			scope:attacker = { culture = { agot_is_wildling_culture = yes } }
		}
		scope:attacker = { play_music_cue = mx_raid }
	}
	else_if = {
		limit = {
			exists = scope:war
			#AGOT Added
			scope:attacker = { has_title = title:k_the_westerlands }
		}
		scope:attacker = { play_music_cue = mood_castamere }
	}
	else = {
		scope:attacker = { play_music_cue = mx_cue_war_declared }
	}
	###############################
	##### Defender music
	###############################
	#AGOT ADDED
	if = {
		limit = {
			exists = scope:war
			OR = {
				scope:attacker = { is_current_dragonrider = yes }
				scope:defender = { is_current_dragonrider = yes }
			}
		}
		scope:defender = { play_music_cue = mood_dragons_at_war }
	}
	else_if = {
		limit = {
			exists = scope:war
			#AGOT Edited
			#OR = {
			#	scope:attacker = { fp2_character_any_involvement_iberian_struggle_trigger = yes }
			#	scope:defender = { fp2_character_any_involvement_iberian_struggle_trigger = yes }
			#}
			OR = {
				scope:attacker = { 
					AND = {
						exists = capital_province
						capital_province = { geographical_region = world_westeros_dorne }
					}
				}
				scope:defender = { 
					AND = {
						exists = capital_province
						capital_province = { geographical_region = world_westeros_dorne }
					}
				}
			}
		}
		scope:defender = { play_music_cue = mx_IberiaWar }
	}
	else_if = {
		limit = {
			exists = scope:war
			OR = {
				#AGOT Modified
				# scope:attacker = { fp3_character_any_involvement_persian_struggle_trigger = yes }
				# scope:defender = { fp3_character_any_involvement_persian_struggle_trigger = yes }
				scope:attacker = { fp2_character_any_involvement_btw_struggle_trigger = yes }
				scope:defender = { fp2_character_any_involvement_btw_struggle_trigger = yes }
			}
		}
		scope:defender = { play_music_cue = strugglewar_cue }
	}
	else_if = {
		limit = {
			exists = scope:war
			#AGOT Modified
			#scope:attacker = { fp1_is_norse_tribal = yes }
			scope:attacker = { culture = { agot_is_wildling_culture = yes } }
		}
		scope:defender = { play_music_cue = mx_raid }
	}

	else = {
		scope:defender = {
			play_music_cue = mx_cue_war_declared
		}
	}

	###############################
	##### Effects
	###############################

	#AGOT ADDED
	if = {
		limit = {
			exists = scope:war
			scope:war = { using_cb = wildling_raid_cb }
		}
		scope:war = {
			set_variable = {
				name = wildling_raid_strength
				value = {
					value = 0
					scope:attacker = {
						every_army = {
							add = army_size
						}
					}
				}
			}
		}
	}

	#There is no fighting in the admin room!
	if = {
		limit = {
			scope:attacker = {
				OR = {
					government_has_flag = government_is_feudal
					government_has_flag = government_is_clan
					government_has_flag = government_is_tribal
				}			
				liege ?= {
					government_has_flag = government_is_administrative
				}
			}
			scope:defender = {
				government_has_flag = government_is_administrative
				liege ?= scope:attacker.liege
			}
		}
		custom_description_no_bullet = {
			text = on_declared_war_in_admin
		}
		scope:attacker.liege = {
			add_opinion = {
				target = scope:attacker
				modifier = declared_war_in_admin
			}
		}
	}

	# Breaking Truce
	if = {
		limit = {
			scope:attacker = {
				has_truce = scope:defender
			}
		}
		scope:attacker = {
			custom_description_no_bullet = {
				text = attack_breaking_truce_text
			}

			# Remove the war target from the bought_truce_list if they're in it
			if = {
				limit = {
					has_purchased_truce_with_char = { TARGET = scope:defender }
				}
				remove_list_variable = {
					name = bought_truce_list
					target = scope:recipient
				}
			}

			if = {
				limit = {
					NOT = { has_perk = flexible_truces_perk }
				}
				add_prestige = break_truce_prestige_loss
				add_prestige_level = break_truce_prestige_level_loss
			}
			add_legitimacy = {
				value = medium_legitimacy_loss
				multiply = primary_title.tier
			}
			add_character_modifier = {
				modifier = broke_truce
				years = 3
			}

			# Struggle Catalysts.
			if = {
				limit = {
					any_character_struggle = {
						involvement = involved
						activate_struggle_catalyst_secondary_character_involvement_involved_trigger = {
							CATALYST = catalyst_broke_truce_against_important_character
							CHAR = scope:defender
						}
					}
				}
				every_character_struggle = {
					involvement = involved
					limit = {
						activate_struggle_catalyst_secondary_character_involvement_involved_trigger = {
							CATALYST = catalyst_broke_truce_against_important_character
							CHAR = scope:defender
						}
					}
					activate_struggle_catalyst = {
						catalyst = catalyst_broke_truce_against_important_character
						character = scope:attacker
					}
				}
			}
		}
	}
	# Breaking Alliance
	if = {
		limit = {
			scope:attacker = {
				is_allied_to = scope:defender
			}
		}
		scope:attacker = {
			break_alliance_due_to_attack_effect = { TARGET = scope:defender }
		}
	}
	# BP2: Attacking Warden
	if = {
		limit = {
			scope:attacker = {
				any_home_court_hostage = { is_hostage_of = scope:defender }
			}
		}
		scope:attacker = {
			add_prestige = break_truce_prestige_loss
			add_prestige_level = break_truce_prestige_level_loss
			add_character_modifier = {
				modifier = attacked_warden
				years = 5
			}
			# Hostages they hold (yours)
			every_home_court_hostage = {
				save_scope_as = hostage
				every_close_family_member = {
					limit = {
						NOT = { this = scope:attacker }
					}
					custom = attacked_warden_tt
					add_opinion = {
						modifier = attacked_warden
						target = scope:attacker
					}
				}
				if = {
					limit = { is_hostage_of = scope:defender }
					custom_description_no_bullet = {
						text = attack_breaking_truce_hostage
						subject = scope:defender
						object = scope:hostage
					}
				}
			}
		}
	}
	# BP2: Attacking Home Court
	if = {
		limit = {
			scope:attacker = {
				any_warden_hostage = { is_hostage_from = scope:defender }
			}
		}
		scope:attacker = {
			# Hostages you hold (theirs)
			every_warden_hostage = {
				save_scope_as = hostage
				if = {
					limit = { is_hostage_from = scope:defender }
					custom_description_no_bullet = {
						text = attack_breaking_truce_hostage
						subject = scope:attacker
						object = scope:hostage
					}
				}
			}
			add_prestige = break_truce_prestige_loss
			add_prestige_level = break_truce_prestige_level_loss
			add_character_modifier = {
				modifier = attacked_home_court
				years = 5
			}
			# Hostages they hold (yours)
			every_home_court_hostage = {
				save_scope_as = hostage
				every_close_family_member = {
					limit = {
						NOT = { this = scope:attacker }
					}
					custom = attacked_warden_tt
					add_opinion = {
						modifier = attacked_home_court
						target = scope:attacker
					}
				}
				if = {
					limit = { is_hostage_of = scope:defender }
					custom_description_no_bullet = {
						text = attack_breaking_truce_hostage
						subject = scope:defender
						object = scope:hostage
					}
				}
			}
		}
	}

	# Opinion
	scope:defender = {
		add_opinion = {
			target = scope:attacker
			modifier = declared_war
		}
	}
	if = {
		limit = {
			NOT = {
				scope:attacker = {
					is_parent_of = scope:defender
				}
			}
		}
		if = {
			limit = {
				scope:defender = {
					has_father = yes
				}
			}
			scope:defender = {
				father = {
					add_opinion = {
						target = scope:attacker
						modifier = declared_war_on_son_daughter
					}
				}
			}
		}
		if = {
			limit = {
				scope:defender = {
					has_mother = yes
				}
			}
			scope:defender = {
				mother = {
					add_opinion = {
						target = scope:attacker
						modifier = declared_war_on_son_daughter
					}
				}
			}
		}
	}
	if = {
		limit = {
			NOT = { scope:attacker.culture = scope:defender.culture }
			scope:attacker = { is_landed = yes }
			scope:defender = { is_landed = yes }
		}
		scope:defender.culture = {
			change_cultural_acceptance = {
				target = scope:attacker.culture
				value = declare_war_culture_acceptance_impact
				desc = cultural_acceptance_loss_declared_war
			}
		}
	}
	
	scope:attacker = {
		if = {
			limit = {
				any_vassal = {
					has_vassal_stance = parochial
				}
				eighty_percent_of_current_military_strength <= scope:defender.current_military_strength
			}
			custom_tooltip = parochial_vassal_disapproves_war
			hidden_effect = {
				every_vassal = {
					limit = {
						has_vassal_stance = parochial
					}
					add_opinion = {
						target = scope:attacker
						modifier = parochial_disapproves_strong_war_enemy_opinion
					}
				}
			}
		}
	}
	
	# If we're a clan this interaction affects unity
	add_clan_unity_interaction_effect = {
		CHARACTER = scope:attacker
		TARGET = scope:defender
		VALUE = massive_unity_loss
		DESC = clan_unity_declared_war.desc
		REVERSE_NON_HOUSE_TARGET = no
	}
	
	intrigue_duel_on_attack_effect = yes

	scope:attacker = {
		stress_impact = {
			ambitious = -20
			greedy = -20
			vengeful = -10
			brave = -20
			wrathful = -10
			arbitrary = -10
			impatient = -10
			zealous = -10
		}
		stress_impact = {
			lazy = 40
			craven = 20
			forgiving = 20
			compassionate = 30
			calm = 15
			just = 10
			patient = 10
			fickle = 10
		}
	}

	scope:defender = {
		stress_impact = {
			lazy = 40
			craven = 30
			forgiving = 10
			compassionate = 20
			calm = 10
			just = 10
			patient = 10
			fickle = 10
		}
	}

	if = {
		limit = {
			has_game_rule = GPT_wareffects_enabled
		}
		scope:attacker = {
			if = {
				limit = {
					any_vassal = {
						count >= 9
						highest_held_title_tier >= 2
					}
					any_vassal = {
						percent >= 0.50
						OR = {
							is_allied_to = scope:attacker
							opinion = {
								target = scope:attacker
								value >= 40
							}
							AND = {
								ai_vengefulness >= 0
								opinion = {
									target = scope:defender
									value <= -40
								}
							}
							AND = {
								ai_vengefulness >= 40
								opinion = {
									target = scope:defender
									value < 0
								}
							}
							AND = {
								ai_boldness >= 40
								opinion = {
									target = scope:attacker
									value >= 0
								}
							}
							AND = {
								ai_greed <= -20
								opinion = {
									target = scope:attacker
									value >= 20
								}
							}
							AND = {
								scope:attacker = {
									is_house_head = yes
								}
								house = scope:attacker.house
							}
						}
					}
				}
				custom_tooltip = gpt_vassal_reinforcements_tip
				spawn_army = {
					name = gpt_reinforcement_troops
					levies = {
						add = {
							value = 10
							add = { value = dread multiply = 4 }
							add = { value = vassal_count multiply = 12 }
							add = { value = sub_realm_size multiply = 3 }
							add = { value = piety_level multiply = 30 }
							add = { value = prestige_level multiply = 45 }
							add = { value = legitimacy_level multiply = 80 }
							add = { value = capital_province.county.development_level multiply = 10 }
							add = { value = capital_province.combined_building_level multiply = 20 }
							divide = highest_held_title_tier
							divide = highest_held_title_tier
							multiply = 20
							if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_0
										has_realm_law = tribal_authority_0
										has_realm_law = imperial_bureaucracy_0
									}
								}
								multiply = 0.5
							}
							if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_1
										has_realm_law = tribal_authority_1
										has_realm_law = imperial_bureaucracy_1
									}
								}
								multiply = 0.75
							}
							if = {
								limit = {
									has_realm_law_flag = max_authority_level
								}
								multiply = 1.25
							}
							if = {
								limit = {
									government_has_flag = government_is_tribal
								}
								multiply = 1.5
							}
						}
					}
					location = scope:attacker.capital_province
					origin = scope:attacker.capital_province
					uses_supply = yes
					war = scope:war
					inheritable = no
				}
			}
			else_if = {
				limit = {
					any_vassal = {
						count >= 7
						highest_held_title_tier >= 2
					}
					any_vassal = {
						percent >= 0.45
						OR = {
							is_allied_to = scope:attacker
							opinion = {
								target = scope:attacker
								value >= 40
							}
							AND = {
								ai_vengefulness >= 0
								opinion = {
									target = scope:defender
									value <= -40
								}
							}
							AND = {
								ai_vengefulness >= 40
								opinion = {
									target = scope:defender
									value < 0
								}
							}
							AND = {
								ai_boldness >= 40
								opinion = {
									target = scope:attacker
									value >= 0
								}
							}
							AND = {
								ai_greed <= -20
								opinion = {
									target = scope:attacker
									value >= 20
								}
							}
							AND = {
								scope:attacker = {
									is_house_head = yes
								}
								house = scope:attacker.house
							}
						}
					}
				}
				custom_tooltip = gpt_vassal_reinforcements_tip
				spawn_army = {
					name = gpt_reinforcement_troops
					levies = {
						add = {
							value = 10
							add = { value = dread multiply = 4 }
							add = { value = vassal_count multiply = 12 }
							add = { value = sub_realm_size multiply = 3 }
							add = { value = piety_level multiply = 30 }
							add = { value = prestige_level multiply = 45 }
							add = { value = legitimacy_level multiply = 80 }
							add = { value = capital_province.county.development_level multiply = 10 }
							add = { value = capital_province.combined_building_level multiply = 20 }
							divide = highest_held_title_tier
							divide = highest_held_title_tier
							multiply = 16
							if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_0
										has_realm_law = tribal_authority_0
										has_realm_law = imperial_bureaucracy_0
									}
								}
								multiply = 0.5
							}
							if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_1
										has_realm_law = tribal_authority_1
										has_realm_law = imperial_bureaucracy_1
									}
								}
								multiply = 0.75
							}
							if = {
								limit = {
									has_realm_law_flag = max_authority_level
								}
								multiply = 1.25
							}
							if = {
								limit = {
									government_has_flag = government_is_tribal
								}
								multiply = 1.5
							}
						}
					}
					location = scope:attacker.capital_province
					origin = scope:attacker.capital_province
					uses_supply = yes
					war = scope:war
					inheritable = no
				}
			}
			else_if = {
				limit = {
					any_vassal = {
						count >= 5
						highest_held_title_tier >= 2
					}
					any_vassal = {
						percent >= 0.40
						OR = {
							is_allied_to = scope:attacker
							opinion = {
								target = scope:attacker
								value >= 40
							}
							AND = {
								ai_vengefulness >= 0
								opinion = {
									target = scope:defender
									value <= -40
								}
							}
							AND = {
								ai_vengefulness >= 40
								opinion = {
									target = scope:defender
									value < 0
								}
							}
							AND = {
								ai_boldness >= 40
								opinion = {
									target = scope:attacker
									value >= 0
								}
							}
							AND = {
								ai_greed <= -20
								opinion = {
									target = scope:attacker
									value >= 20
								}
							}
							AND = {
								scope:attacker = {
									is_house_head = yes
								}
								house = scope:attacker.house
							}
						}
					}
				}
				custom_tooltip = gpt_vassal_reinforcements_tip
				spawn_army = {
					name = gpt_reinforcement_troops
					levies = {
						add = {
							value = 10
							add = { value = dread multiply = 4 }
							add = { value = vassal_count multiply = 12 }
							add = { value = sub_realm_size multiply = 3 }
							add = { value = piety_level multiply = 30 }
							add = { value = prestige_level multiply = 45 }
							add = { value = legitimacy_level multiply = 80 }
							add = { value = capital_province.county.development_level multiply = 10 }
							add = { value = capital_province.combined_building_level multiply = 20 }
							divide = highest_held_title_tier
							divide = highest_held_title_tier
							multiply = 12
							if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_0
										has_realm_law = tribal_authority_0
										has_realm_law = imperial_bureaucracy_0
									}
								}
								multiply = 0.5
							}
							if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_1
										has_realm_law = tribal_authority_1
										has_realm_law = imperial_bureaucracy_1
									}
								}
								multiply = 0.75
							}
							if = {
								limit = {
									has_realm_law_flag = max_authority_level
								}
								multiply = 1.25
							}
							if = {
								limit = {
									government_has_flag = government_is_tribal
								}
								multiply = 1.5
							}
						}
					}
					location = scope:attacker.capital_province
					origin = scope:attacker.capital_province
					uses_supply = yes
					war = scope:war
					inheritable = no
				}
			}
			else_if = {
				limit = {
					any_vassal = {
						count >= 3
						highest_held_title_tier >= 2
					}
					any_vassal = {
						percent >= 0.35
						OR = {
							is_allied_to = scope:attacker
							opinion = {
								target = scope:attacker
								value >= 40
							}
							AND = {
								ai_vengefulness >= 0
								opinion = {
									target = scope:defender
									value <= -40
								}
							}
							AND = {
								ai_vengefulness >= 40
								opinion = {
									target = scope:defender
									value < 0
								}
							}
							AND = {
								ai_boldness >= 40
								opinion = {
									target = scope:attacker
									value >= 0
								}
							}
							AND = {
								ai_greed <= -20
								opinion = {
									target = scope:attacker
									value >= 20
								}
							}
							AND = {
								scope:attacker = {
									is_house_head = yes
								}
								house = scope:attacker.house
							}
						}
					}
				}
				custom_tooltip = gpt_vassal_reinforcements_tip
				spawn_army = {
					name = gpt_reinforcement_troops
					levies = {
						add = {
							value = 10
							add = { value = dread multiply = 4 }
							add = { value = vassal_count multiply = 12 }
							add = { value = sub_realm_size multiply = 3 }
							add = { value = piety_level multiply = 30 }
							add = { value = prestige_level multiply = 40 }
							add = { value = legitimacy_level multiply = 80 }
							add = { value = capital_province.county.development_level multiply = 10 }
							add = { value = capital_province.combined_building_level multiply = 20 }
							divide = highest_held_title_tier
							divide = highest_held_title_tier
							multiply = 8
							if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_0
										has_realm_law = tribal_authority_0
										has_realm_law = imperial_bureaucracy_0
									}
								}
								multiply = 0.5
							}
							if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_1
										has_realm_law = tribal_authority_1
										has_realm_law = imperial_bureaucracy_1
									}
								}
								multiply = 0.75
							}
							if = {
								limit = {
									has_realm_law_flag = max_authority_level
								}
								multiply = 1.25
							}
							if = {
								limit = {
									government_has_flag = government_is_tribal
								}
								multiply = 1.5
							}
						}
					}
					location = scope:attacker.capital_province
					origin = scope:attacker.capital_province
					uses_supply = yes
					war = scope:war
					inheritable = no
				}
			}
			else_if = {
				limit = {
					any_vassal = {
						count >= 1
						highest_held_title_tier >= 2
					}
					any_vassal = {
						percent >= 0.30
						OR = {
							is_allied_to = scope:attacker
							opinion = {
								target = scope:attacker
								value >= 40
							}
							AND = {
								ai_vengefulness >= 0
								opinion = {
									target = scope:defender
									value <= -40
								}
							}
							AND = {
								ai_vengefulness >= 40
								opinion = {
									target = scope:defender
									value < 0
								}
							}
							AND = {
								ai_boldness >= 40
								opinion = {
									target = scope:attacker
									value >= 0
								}
							}
							AND = {
								ai_greed <= -20
								opinion = {
									target = scope:attacker
									value >= 20
								}
							}
							AND = {
								scope:attacker = {
									is_house_head = yes
								}
								house = scope:attacker.house
							}
						}
					}
				}
				custom_tooltip = gpt_vassal_reinforcements_tip
				spawn_army = {
					name = gpt_reinforcement_troops
					levies = {
						add = {
							value = 10
							add = { value = dread multiply = 4 }
							add = { value = vassal_count multiply = 12 }
							add = { value = sub_realm_size multiply = 3 }
							add = { value = piety_level multiply = 30 }
							add = { value = prestige_level multiply = 45 }
							add = { value = legitimacy_level multiply = 80 }
							add = { value = capital_province.county.development_level multiply = 10 }
							add = { value = capital_province.combined_building_level multiply = 20 }
							divide = highest_held_title_tier
							divide = highest_held_title_tier
							multiply = 4
							if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_0
										has_realm_law = tribal_authority_0
										has_realm_law = imperial_bureaucracy_0
									}
								}
								multiply = 0.5
							}
							if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_1
										has_realm_law = tribal_authority_1
										has_realm_law = imperial_bureaucracy_1
									}
								}
								multiply = 0.75
							}
							if = {
								limit = {
									has_realm_law_flag = max_authority_level
								}
								multiply = 1.25
							}
							if = {
								limit = {
									government_has_flag = government_is_tribal
								}
								multiply = 1.5
							}
						}
					}
					location = scope:attacker.capital_province
					origin = scope:attacker.capital_province
					uses_supply = yes
					war = scope:war
					inheritable = no
				}
			}
			else = {
				custom_tooltip = gpt_vassal_reinforcements_tip
				spawn_army = {
					name = gpt_reinforcement_troops
					levies = {
						add = {
							value = 10
							add = { value = dread multiply = 4 }
							add = { value = vassal_count multiply = 12 }
							add = { value = sub_realm_size multiply = 3 }
							add = { value = piety_level multiply = 30 }
							add = { value = prestige_level multiply = 45 }
							add = { value = legitimacy_level multiply = 80 }
							add = { value = capital_province.county.development_level multiply = 10 }
							add = { value = capital_province.combined_building_level multiply = 20 }
							divide = highest_held_title_tier
							divide = highest_held_title_tier
							multiply = 2
							if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_0
										has_realm_law = tribal_authority_0
										has_realm_law = imperial_bureaucracy_0
									}
								}
								multiply = 0.5
							}
							if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_1
										has_realm_law = tribal_authority_1
										has_realm_law = imperial_bureaucracy_1
									}
								}
								multiply = 0.75
							}
							if = {
								limit = {
									has_realm_law_flag = max_authority_level
								}
								multiply = 1.25
							}
							if = {
								limit = {
									government_has_flag = government_is_tribal
								}
								multiply = 1.5
							}
						}
					}
					location = scope:attacker.capital_province
					origin = scope:attacker.capital_province
					uses_supply = yes
					war = scope:war
					inheritable = no
				}
			}
		}

		scope:defender = {
			if = {
				limit = {
					any_vassal = {
						count >= 9
						highest_held_title_tier >= 2
					}
					any_vassal = {
						percent >= 0.50
						OR = {
							ai_honor >= 20
							is_allied_to = scope:defender
							opinion = {
								target = scope:defender
								value >= 0
							}
							opinion = {
								target = scope:defender
								value <= -40
							}
							AND = {
								scope:attacker = {
									is_house_head = yes
								}
								house = scope:attacker.house
							}
						}
					}
				}
				hidden_effect = {
					spawn_army = {
						name = gpt_reinforcement_troops
						levies = {
							add = {
								value = 10
								add = { value = dread multiply = 4 }
								add = { value = vassal_count multiply = 12 }
								add = { value = sub_realm_size multiply = 3 }
								add = { value = piety_level multiply = 30 }
								add = { value = prestige_level multiply = 45 }
								add = { value = legitimacy_level multiply = 80 }
								add = { value = capital_province.county.development_level multiply = 10 }
								add = { value = capital_province.combined_building_level multiply = 20 }
								divide = highest_held_title_tier
								divide = highest_held_title_tier
								multiply = 30
								if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_0
										has_realm_law = tribal_authority_0
										has_realm_law = imperial_bureaucracy_0
									}
								}
								multiply = 0.5
							}
							if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_1
										has_realm_law = tribal_authority_1
										has_realm_law = imperial_bureaucracy_1
									}
								}
								multiply = 0.75
							}
							if = {
								limit = {
									has_realm_law_flag = max_authority_level
								}
								multiply = 1.25
							}
							if = {
								limit = {
									government_has_flag = government_is_tribal
								}
								multiply = 1.5
							}
							}
						}
						location = scope:defender.capital_province
						origin = scope:defender.capital_province
						uses_supply = yes
						war = scope:war
						inheritable = no
					}
				}
			}
			else_if = {
				limit = {
					any_vassal = {
						count >= 7
						highest_held_title_tier >= 2
					}
					any_vassal = {
						percent >= 0.45
						OR = {
							ai_honor >= 20
							is_allied_to = scope:defender
							opinion = {
								target = scope:defender
								value >= 0
							}
							opinion = {
								target = scope:defender
								value <= -40
							}
							AND = {
								scope:attacker = {
									is_house_head = yes
								}
								house = scope:attacker.house
							}
						}
					}
				}
				hidden_effect = {
					spawn_army = {
						name = gpt_reinforcement_troops
						levies = {
								add = {
								value = 10
								add = { value = dread multiply = 4 }
								add = { value = vassal_count multiply = 12 }
								add = { value = sub_realm_size multiply = 3 }
								add = { value = piety_level multiply = 30 }
								add = { value = prestige_level multiply = 45 }
								add = { value = legitimacy_level multiply = 80 }
								add = { value = capital_province.county.development_level multiply = 10 }
								add = { value = capital_province.combined_building_level multiply = 20 }
								divide = highest_held_title_tier
								divide = highest_held_title_tier
								multiply = 24
								if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_0
										has_realm_law = tribal_authority_0
										has_realm_law = imperial_bureaucracy_0
									}
								}
								multiply = 0.5
							}
							if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_1
										has_realm_law = tribal_authority_1
										has_realm_law = imperial_bureaucracy_1
									}
								}
								multiply = 0.75
							}
							if = {
								limit = {
									has_realm_law_flag = max_authority_level
								}
								multiply = 1.25
							}
							if = {
								limit = {
									government_has_flag = government_is_tribal
								}
								multiply = 1.5
							}
							}
						}
						location = scope:defender.capital_province
						origin = scope:defender.capital_province
						uses_supply = yes
						war = scope:war
						inheritable = no
					}
				}
			}
			else_if = {
				limit = {
					any_vassal = {
						count >= 5
						highest_held_title_tier >= 2
					}
					any_vassal = {
						percent >= 0.40
						OR = {
							ai_honor >= 20
							is_allied_to = scope:defender
							opinion = {
								target = scope:defender
								value >= 0
							}
							opinion = {
								target = scope:defender
								value <= -40
							}
							AND = {
								scope:attacker = {
									is_house_head = yes
								}
								house = scope:attacker.house
							}
						}
					}
				}
				hidden_effect = {
					spawn_army = {
						name = gpt_reinforcement_troops
						levies = {
							add = {
								value = 10
								add = { value = dread multiply = 4 }
								add = { value = vassal_count multiply = 12 }
								add = { value = sub_realm_size multiply = 3 }
								add = { value = piety_level multiply = 30 }
								add = { value = prestige_level multiply = 45 }
								add = { value = legitimacy_level multiply = 80 }
								add = { value = capital_province.county.development_level multiply = 10 }
								add = { value = capital_province.combined_building_level multiply = 20 }
								divide = highest_held_title_tier
								divide = highest_held_title_tier
								multiply = 18
								if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_0
										has_realm_law = tribal_authority_0
										has_realm_law = imperial_bureaucracy_0
									}
								}
								multiply = 0.5
							}
							if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_1
										has_realm_law = tribal_authority_1
										has_realm_law = imperial_bureaucracy_1
									}
								}
								multiply = 0.75
							}
							if = {
								limit = {
									has_realm_law_flag = max_authority_level
								}
								multiply = 1.25
							}
							if = {
								limit = {
									government_has_flag = government_is_tribal
								}
								multiply = 1.5
							}
							}
						}
						location = scope:defender.capital_province
						origin = scope:defender.capital_province
						uses_supply = yes
						war = scope:war
						inheritable = no
					}
				}
			}
			else_if = {
				limit = {
					any_vassal = {
						count >= 3
						highest_held_title_tier >= 2
					}
					any_vassal = {
						percent >= 0.35
						OR = {
							ai_honor >= 20
							is_allied_to = scope:defender
							opinion = {
								target = scope:defender
								value >= 0
							}
							opinion = {
								target = scope:defender
								value <= -40
							}
							AND = {
								scope:attacker = {
									is_house_head = yes
								}
								house = scope:attacker.house
							}
						}
					}
				}
				hidden_effect = {
					spawn_army = {
						name = gpt_reinforcement_troops
						levies = {
							add = {
								value = 10
								add = { value = dread multiply = 4 }
								add = { value = vassal_count multiply = 12 }
								add = { value = sub_realm_size multiply = 3 }
								add = { value = piety_level multiply = 30 }
								add = { value = prestige_level multiply = 45 }
								add = { value = legitimacy_level multiply = 80 }
								add = { value = capital_province.county.development_level multiply = 10 }
								add = { value = capital_province.combined_building_level multiply = 20 }
								divide = highest_held_title_tier
								divide = highest_held_title_tier
								multiply = 12
								if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_0
										has_realm_law = tribal_authority_0
										has_realm_law = imperial_bureaucracy_0
									}
								}
								multiply = 0.5
								}
								if = {
									limit = {
										OR = {
											has_realm_law = crown_authority_1
											has_realm_law = tribal_authority_1
											has_realm_law = imperial_bureaucracy_1
										}
									}
									multiply = 0.75
								}
								if = {
									limit = {
										has_realm_law_flag = max_authority_level
									}
									multiply = 1.25
								}
								if = {
									limit = {
										government_has_flag = government_is_tribal
									}
									multiply = 1.5
								}
							}
						}
						location = scope:defender.capital_province
						origin = scope:defender.capital_province
						uses_supply = yes
						war = scope:war
						inheritable = no
					}
				}
			}
			else_if = {
				limit = {
					any_vassal = {
						count >= 1
						highest_held_title_tier >= 2
					}
					any_vassal = {
						percent >= 0.30
						OR = {
							ai_honor >= 20
							is_allied_to = scope:defender
							opinion = {
								target = scope:defender
								value >= 0
							}
							opinion = {
								target = scope:defender
								value <= -40
							}
							AND = {
								scope:attacker = {
									is_house_head = yes
								}
								house = scope:attacker.house
							}
						}
					}
				}
				hidden_effect = {
					spawn_army = {
						name = gpt_reinforcement_troops
						levies = {
							add = {
								value = 10
								add = { value = dread multiply = 4 }
								add = { value = vassal_count multiply = 12 }
								add = { value = sub_realm_size multiply = 3 }
								add = { value = piety_level multiply = 30 }
								add = { value = prestige_level multiply = 45 }
								add = { value = legitimacy_level multiply = 80 }
								add = { value = capital_province.county.development_level multiply = 10 }
								add = { value = capital_province.combined_building_level multiply = 20 }
								divide = highest_held_title_tier
								divide = highest_held_title_tier
								multiply = 6
								if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_0
										has_realm_law = tribal_authority_0
										has_realm_law = imperial_bureaucracy_0
									}
								}
								multiply = 0.5
								}
								if = {
									limit = {
										OR = {
											has_realm_law = crown_authority_1
											has_realm_law = tribal_authority_1
											has_realm_law = imperial_bureaucracy_1
										}
									}
									multiply = 0.75
								}
								if = {
									limit = {
										has_realm_law_flag = max_authority_level
									}
									multiply = 1.25
								}
								if = {
									limit = {
										government_has_flag = government_is_tribal
									}
									multiply = 1.5
								}
							}
						}
						location = scope:defender.capital_province
						origin = scope:defender.capital_province
						uses_supply = yes
						war = scope:war
						inheritable = no
					}
				}
			}
			else = {
				hidden_effect = {
					spawn_army = {
						name = gpt_reinforcement_troops
						levies = {
							add = {
								value = 10
								add = { value = dread multiply = 4 }
								add = { value = vassal_count multiply = 12 }
								add = { value = sub_realm_size multiply = 3 }
								add = { value = piety_level multiply = 30 }
								add = { value = prestige_level multiply = 45 }
								add = { value = legitimacy_level multiply = 80 }
								add = { value = capital_province.county.development_level multiply = 10 }
								add = { value = capital_province.combined_building_level multiply = 20 }
								divide = highest_held_title_tier
								divide = highest_held_title_tier
								multiply = 3
								if = {
								limit = {
									OR = {
										has_realm_law = crown_authority_0
										has_realm_law = tribal_authority_0
										has_realm_law = imperial_bureaucracy_0
									}
								}
								multiply = 0.5
								}
								if = {
									limit = {
										OR = {
											has_realm_law = crown_authority_1
											has_realm_law = tribal_authority_1
											has_realm_law = imperial_bureaucracy_1
										}
									}
									multiply = 0.75
								}
								if = {
									limit = {
										has_realm_law_flag = max_authority_level
									}
									multiply = 1.25
								}
								if = {
									limit = {
										government_has_flag = government_is_tribal
									}
									multiply = 1.5
								}
							}
						}
						location = scope:defender.capital_province
						origin = scope:defender.capital_province
						uses_supply = yes
						war = scope:war
						inheritable = no
					}
				}
			}
		}
	}
}
