﻿namespace = pod_factions

# Hunter Faction Demand

pod_factions.1101 = {
	type = letter_event
	sender = scope:hunter_leader
	opening = "FACTION_DEMAND_HUNTER"
	desc = FACTION_DEMAND_HUNTER_DESC

	trigger = {
		exists = scope:faction
		exists = scope:hunter_leader
		scope:hunter_leader.joined_faction = scope:faction
	}

	on_trigger_fail = {
		debug_log = "Hunter Faction tried to press claim (probably) without existing hunter_leader"
		debug_log_scopes = yes
		debug_log = "Hunter Faction error reporting complete"
	}

	option = {
		 name = "FACTION_DEMAND_HUNTER_ACCEPT"
		# hunter_faction_demands_enforced = {
		# FACTION = scope:faction
		# FACTION_LEADER = scope:hunter_leader
		# TARGET_TITLE = scope:target_title		
		# }
		
			add_prestige_level = -1
			POD_depose_effect = yes
			
			if = {
				limit = { has_realm_law = crown_authority_1 }
				add_realm_law = crown_authority_0
			}
			if = {
				limit = { has_realm_law = crown_authority_2 }
				add_realm_law = crown_authority_1
			}
			if = {
				limit = { has_realm_law = crown_authority_3 }
				add_realm_law = crown_authority_2
			}	

		scope:hunter_leader = {
			trigger_event = pod_factions.1102
			}

		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_boldness = -4
			}
			modifier = {
				add = 50
				scope:faction = { faction_power >= 100 }
			}
			modifier = {
				add = 50
				scope:faction = { faction_power >= 110 }
			}
			modifier = {
				add = 50
				scope:faction = { faction_power >= 120 }
			}
			modifier = {
				add = 50
				scope:faction = { faction_power >= 130 }
			}
			modifier = {
				add = 50
				scope:faction = { faction_power >= 140 }
			}
			modifier = {
				add = 50
				scope:faction = { faction_power >= 150 }
			}
			modifier = {
				add = -300
				has_character_modifier = masquerade0_modifier
			}
		}
	}

	option = {
		name = "FACTION_DEMAND_HUNTER_REFUSE"

		scope:faction = {
			faction_start_war = {
			}
			every_faction_county_member = {
				custom = hunter_faction_every_county
				change_county_control = peasant_war_starts_county_control_loss
			}
		}
		

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 4
			}
			modifier = {
				add = 50
				scope:faction = { faction_power < 90 }
			}
			modifier = {
				add = 50
				scope:faction = { faction_power < 80 }
			}
		}
	}
}

pod_factions.1102 = {
	hidden = yes

	trigger = {
		is_imprisoned = no
	}

	immediate = {
		death = {
			death_reason = death_vanished
		}
	}
}


pod_factions.1103 = {
	type = character_event
	content_source = dlc_POD
	title = pod_factions.1103.t
	desc = pod_factions.1103.desc
	theme = murder_scheme

	left_portrait = { 	
			character = root
			animation = shame
		}	

	trigger = {
	}

	immediate = {
	}

	option = {
		name = pod_factions.1103.a
		
		POD_depose_effect = yes
	}
	
	option = {
		name = pod_factions.1103.b
		
		add_character_modifier = {
			modifier = broken_authority_modifier
			years = 50
		}	
	}	
}

# faction_demand.1110 = {
	# hidden = yes

	# trigger = {
		# has_variable = rebel_leader_peasants
		# joined_faction = var:rebel_leader_peasants
		# exists = scope:war
		# scope:war = {
			# primary_defender = scope:previous_controller
		# }
	# }

	# immediate = {
		# # Determine how many rebel reinforcements we need to spawn, based on the total number of provinces captured.
		# set_variable = {
			# name = number_rebel_reinforcements
			# value = {		
				# add = {
					# every_in_list = {
						# list = occupied_baronies
						# add = building_levies
					# }
				# }
				# multiply = { # Spawns between 50% and 100% of the total county's levies
					# add = 0.5
					# add = {
						# scope:county = {
							# add = development_level
							# multiply = 0.005
						# }
					# }	
				# }
			# }
		# }

		# # Spawn the army on the captured province.
		# spawn_army = {
			# name = event_troop_default_name
			# levies = var:number_rebel_reinforcements
			# location = scope:barony.title_province
			# war = scope:war
		# }

		# # Additional loss of county control, can be up to -70 for large counties.
		# every_in_list = {
			# list = occupied_baronies
			# scope:county = {
				# change_county_control = -10
			# }
		# }
		# # Lose an extra -10 county control.
		# scope:county = {
			# change_county_control = -10
		# }
	# }

	# after = {
		# remove_variable = number_rebel_reinforcements
	# }
# }