others_invasion = {
	name = CB_NAME_OTHERS_INVASION
	war_name = WAR_NAME_OTHERS_INVASION
	sprite = 8
	truce_days = 50
	hostile_against_others = yes
	is_permanent = yes
	press_claim = yes
	can_ask_to_join_war = no
	capturing_attacker_is_complete_victory = no
	capturing_defender_is_complete_victory = no
	check_de_jure_tier = KING # this scans all de jure kingdoms for the counties which are held by or vassals(or below) of selected character. Only valid if is_permanent = yes
	
	infamy_modifier = 0
	
    can_use_title = { 
		ROOT = { culture = white_walker }
		FROM = { 
			NOT = { culture_group = winter_group } 
			NOT = { culture_group = unoccupied_group } 
		}
		OR = {
			higher_tier_than = COUNT
			holder = FROM
		}
		NOT = { controls_religion = yes }
		NOR = {
			has_alternate_start_parameter = { key = special_culture value = mythological } 
			has_alternate_start_parameter = { key = special_culture value = all } 
		}
	}
	
	is_valid_title = {
		FROM = {
			any_realm_province = {
				de_jure_liege_or_above = PREVPREV
			}
		}
	}

    on_add = {
		ROOT = { show_scope_change = no prestige = -500 }
	}	
	
	on_success = {
		ROOT = {
			show_scope_change = no
			prestige = 200
			participation_scaled_prestige = 200
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = { participation_scaled_prestige = 200 }
		}
		FROM = {
			show_scope_change = no
			prestige = -200
		}
		hidden_tooltip = {
			ROOT = {
				occupy_minors_of_occupied_settlements = FROM
				gain_all_occupied_titles = { who = FROM type = invasion }
				
				if = {
					limit = {
						has_nickname = no
					}
					random_list = {
						10 = { give_nickname = nick_the_great }
						10 = { give_nickname = nick_the_victorious }
						10 = { give_nickname = nick_the_conqueror }
						10 = { give_nickname = nick_the_brave }
						10 = { give_nickname = nick_the_dragon }
						10 = { give_nickname = nick_the_terrible }
					}
				}
			}
		}
	}	
	
	on_success_title = {
		ROOT = {
			hidden_tooltip = {
				character_event = { id = cold_winds.710 } #The Wall
				character_event = { id = cold_winds.711 } #Winterfell
				character_event = { id = cold_winds.712 } #The Eyrie
				character_event = { id = cold_winds.713 } #Casterly Rock
				character_event = { id = cold_winds.714 } #Harrenhal
				character_event = { id = cold_winds.715 } #King's Landing
				character_event = { id = cold_winds.716 } #Oldtown
				character_event = { id = cold_winds.717 } #Storm's End
				character_event = { id = cold_winds.718 } #Sunspear
				#Essos
				character_event = { id = cold_winds.719 }
				character_event = { id = cold_winds.720 }
				character_event = { id = cold_winds.721 }
				character_event = { id = cold_winds.722 }
				character_event = { id = cold_winds.723 }
				character_event = { id = cold_winds.724 }
				character_event = { id = cold_winds.725 }
				character_event = { id = cold_winds.726 }
				character_event = { id = cold_winds.727 }
				character_event = { id = cold_winds.728 }
				character_event = { id = cold_winds.729 }
			}
		}	
		custom_tooltip = {
			text = others_invasion_succ_tip
			hidden_tooltip = {
				ROOT = {
					vassalize_or_take_under_title_destroy_duchies = {
						title = PREV
						enemy = FROM
						type = invasion
					}
				}
			}
		}
	}

	on_fail = {
		FROM = {
			show_scope_change = no
			prestige = 100
			
			hidden_tooltip = {
				if = {
					limit = {
						has_nickname = no
					}
					random_list = {
						10 = { give_nickname = nick_the_great }
						10 = { give_nickname = nick_the_hammer }
						10 = { give_nickname = nick_the_avenger }
						10 = { give_nickname = nick_the_lion }
						10 = { give_nickname = nick_the_bold }
					}
				}
			}
			participation_scaled_prestige = 100
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 100 }
		}
		ROOT = {
			show_scope_change = no
			prestige = -200
		}
	}

	on_reverse_demand = {
		ROOT = {
			show_scope_change = no
			prestige = -200
			transfer_scaled_wealth = {
				to = FROM
				value = 4.0
			}
		}
		FROM = {
			show_scope_change = no
			prestige = 200
			hidden_tooltip = {
				if = {
					limit = {
						has_nickname = no
					}
					random_list = {
						10 = { give_nickname = nick_the_great }
						10 = { give_nickname = nick_the_hammer }
						10 = { give_nickname = nick_the_avenger }
						10 = { give_nickname = nick_the_lion }
						10 = { give_nickname = nick_the_bold }
					}
				}
			}
			
			if = {
				limit = { 
					has_dlc = "Legacy of Rome"
					OR = { 
						has_landed_title = e_iron_throne
						has_landed_title = e_new_valyria
						OR = { 
							religion_group = westerosi_religion
							religion = valyrian_rel
							religion = valyrian_rel_reformed
					    } 
					}	
				}
				hidden_tooltip = { character_event = { id = LoR.30 days = 12 } }
			}
			participation_scaled_prestige = 200
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 200 }
		}
	}

	attacker_ai_victory_worth = {
		factor = 200
	}
	
	attacker_ai_defeat_worth = {
		factor = 100
	}

	defender_ai_victory_worth = {
		factor = -1 # always accept
	}
	
	defender_ai_defeat_worth = {
		factor = 100
	}
	
	ai_will_do = { 
		factor = 100
		
		modifier = {
			factor = 0.9 # Prefer using CB's without on_add costs
		}
		# Try to guide the Hordes in the right direction
		modifier = {
			factor = 100
			ROOT = {
				primary_title = { title = e_winter_walker }
			}
			OR = {
				empire = {
					OR = {
						title = e_iron_throne
						title = e_new_valyria
						title = k_north
					}
				}
				FROM = {
					primary_title = { title = e_winter_walker }
					NOT = { year = 8330 }
				}
			}
		}
		modifier = {
			factor = 0
			FROM = {
				is_nomadic = yes
			}
			ROOT = {
				is_nomadic = no
				NOT = {
					is_tribal = yes
				}
			}
			NOT = {
				any_direct_de_jure_vassal_title = {
					any_direct_de_jure_vassal_title = {
						OR = {
							holding_type = castle
							holding_type = city
						}
					}
				}
			}
		}
		modifier = {
			factor = 0
			FROM = {
				is_nomadic = yes
			}
			ROOT = {
				is_tribal = yes
			}
			NOT = {
				any_direct_de_jure_vassal_title = {
					any_direct_de_jure_vassal_title = {
						OR = {
							holding_type = castle
							holding_type = city
							holding_type = tribal
						}
					}
				}
			}
		}
	}
}