## normal scopes(including posttitle scopes) ##
# ROOT = receiver
# FROM = giver
# <no scope change> = attacker or receiver
## title scopes ##
# ROOT = receiver
# FROM = giver
# <no scope change> = thirdparty landed title	
#
# the following effects/triggers exists (example execution order: on_success->on_success_title->on_success_posttitle):
# is_valid, is_valid_title, on_add, on_add_title, on_add_posttitle, on_success, on_success_title, on_success_posttitle, on_fail, on_fail_title, on_fail_posttitle, on_reverse_demand, on_reverse_demand_title, on_reverse_demand_posttitle
#
# Added on_attacker_leader_death, on_defender_leader_death and on_thirdparty_death, which all trigger when corresponding character dies
# These three all have war scopes, which currently has the following scope changes: 
# attacker, defender, thirdparty(only valid if thirdparty character is involved), thirdparty_title(only valid if thirdparty title is involved)
#
# ai_will_do: modifies value AI places on the CB compared to other CBs (default: 1)
# can_use_gui: If otherwise valid, the CB is listed in the Diplo View, but you can't declare war unless 'can_use_gui' is also valid (also shows a trigger tooltip.)
#


free_dynasty_members = {
	name = CB_NAME_FREEDYNASTY
	war_name = WAR_NAME_FREEDYNASTY
	sprite = 11
	truce_days = 1825
	is_permanent = yes
	is_holy_war = no

	can_use = {
		ROOT = {
			OR = {
				NOT = { religion_group = FROM }
				is_heresy_of = FROM
				is_parent_religion = FROM
			}
			top_liege = {
				NOT = { religion = FROM }
			}
			any_dynasty_member = {
				AND = { 
					prisoner = true
					imprisoned_days = 365
					same_realm = FROM
				}
				
			}
		}	
	}
	

	is_valid = {
		ROOT = {
			OR = {
				NOT = { religion_group = FROM }
				is_heresy_of = FROM
				is_parent_religion = FROM
			}
			top_liege = {
				NOT = { religion = FROM }
			}
			any_dynasty_member = {
				AND = { 
					prisoner = true
					imprisoned_days = 365
					same_realm = THIS
				}
				
			}
		}
	}
	
	on_success = {
	
		ROOT = { 
			prestige = 150
			any_dynasty_member = {
				move_character = ROOT
			}
		}

		FROM = { 
			prestige = -50 
		}
	}

	on_fail = {
		ROOT = { 
			prestige = -100
		}
	}

	on_reverse_demand = {
		ROOT = {
			transfer_scaled_wealth = {
				to = FROM
				value = 1.0
			}
			prestige = -150
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 100
			
		}
		
	}

	attacker_ai_victory_worth = {
		factor = -1 # always accept
	}
	
	attacker_ai_defeat_worth = {
		factor = 100
	}

	defender_ai_victory_worth = {
		factor = -1 # always accept
	}
	
	defender_ai_defeat_worth = {
		factor = 100
	}
	
	ai_will_do = { 
		factor = 1
	}
}

rival_war = {
	name = CB_NAME_RIVAL
	war_name = WAR_NAME_RIVAL
	sprite = 11
	truce_days = 1825
	is_permanent = yes
	defender_can_call_allies = no
	attacker_can_call_allies = no
	
	can_use = {
		ROOT = independent	
		FROM = independent
	}
	

	is_valid = {
		ROOT = {
			OR = {
				religion_group = FROM 
				is_heresy_of = FROM
				is_parent_religion = FROM
			}
			is_rival = FROM
		}
	}
	
	on_success = {
		any_attacker = {
			limit = { character = ROOT }
			participation_scaled_prestige = 100
			if = {
				limit = {
					religion_group = muslim
				}
				participation_scaled_decadence = -10
			}
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = { 
				participation_scaled_prestige = 100
			}
		}
		
		ROOT = { 
			remove_rival = FROM
			prestige = 100
		}
		
		FROM = { 
			transfer_scaled_wealth = {
				to = ROOT
				value = 1.0
			}
		}
		
		FROM = { 
			prestige = -200 
			remove_rival = ROOT
		}
	}

	on_fail = {
		ROOT = { 
			prestige = -150
		}
	}

	on_reverse_demand = {
		ROOT = {
			transfer_scaled_wealth = {
				to = FROM
				value = 2.0
			}
			prestige = -300
		}
		any_defender = {
			limit = { character = FROM }
			participation_scaled_prestige = 150
			
		}
		
	}

	attacker_ai_victory_worth = {
		factor = -1 # always accept
	}
	
	attacker_ai_defeat_worth = {
		factor = 100
	}

	defender_ai_victory_worth = {
		factor = -1 # always accept
	}
	
	defender_ai_defeat_worth = {
		factor = 100
	}
	
	ai_will_do = { 
		factor = 1
	}
}