# Unsanctioned deity: Village worships excessively
unsanctioned_deity = {
	group = admin_governance_group
	icon = "gfx/interface/icons/message_feed/heresy.dds"

	valid_to_create = {
		valid_governor_contract_trigger = yes
	}

	valid_to_keep = {
		task_contract_taker = { valid_governor_contract_trigger = yes }
		valid_governor_contract_basic_trigger = yes
	}

	valid_to_accept = {
		valid_governor_contract_trigger = yes
		custom_tooltip = {
			text = has_active_governance_issue
			num_taken_task_contracts < 1
		}
		is_available = yes
	}

	valid_to_continue = {
		task_contract_taker = {
			valid_governor_contract_trigger = yes
		}
	}

	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		save_scope_as = task_contract
		task_contract_taker ?= {
			trigger_event = governor_contract_events_tova.0050
		}
	}

	on_completed = {
	}

	on_invalidated = {
		if = {
			limit = { governor_contract_invalidated_message_trigger = yes }
			governor_contract_invalidated_message_effect = yes
		}
	}

	task_contract_reward = {
		success = {
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				custom_tooltip = tgp_admin_contract_success_tt_rewards
			}
		}
		success_failure = {
			positive = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				custom_tooltip = tgp_admin_contract_failure_tt
			}
		}
		sanction_deity = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_as = task_contract
				task_contract_taker ?= {
					increase_governance_effect = { VALUE = 10 }
					change_merit = {
						value = minor_merit_gain
						multiply = governance_task_contract_tier_value
					}
				}
				task_contract_location.county = {
					add_county_modifier = {
						modifier = tgp_sanctioned_deity_modifier
						years = 10
					}
				}				
			}
		}
		burn_shrine = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_as = task_contract
				task_contract_taker ?= {
					increase_governance_effect = { VALUE = 6 }
					change_merit = {
						value = miniscule_merit_gain
						multiply = governance_task_contract_tier_value
					}
				}
			}
		}
		claim_offerings = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_as = task_contract
				task_contract_taker ?= {
					add_gold = {
						value = scope:task_contract.task_contract_location.monthly_income
						multiply = 40
					}
					change_merit = {
						value = miniscule_merit_loss
						multiply = governance_task_contract_tier_value
					}
					if = {
						limit = {
							secret_siphoned_treasury_is_valid_trigger = {
								OWNER = scope:task_contract.task_contract_taker
								TARGET = top_liege
							}
						}
						add_secret = {
							type = secret_siphoned_treasury
							target = top_liege
						}
					}
				}
			}
		}
		debunk_deity = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_as = task_contract
				task_contract_taker ?= {
					increase_governance_effect = { VALUE = 4 }
					change_merit = {
						value = miniscule_merit_gain
						multiply = governance_task_contract_tier_value
					}
					add_character_modifier = {
						modifier = tgp_debunked_deity_modifier
						years = 10
					}
				}
			}
		}
		deity_monks = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_as = task_contract
				task_contract_taker ?= {
					change_influence = {
						value = miniscule_influence_gain
						multiply = governance_task_contract_tier_value
					}
					add_piety = {
						value = medium_piety_gain
						multiply = governance_task_contract_tier_value
					}
				}			
			}
		}
		failure_standard = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				task_contract_taker ?= {
					change_influence = minor_influence_loss
					if = {
						limit = {
							has_trait = governor
							has_trait_xp = {
								trait = governor
								value > 0
							}
						}
						add_trait_xp = {
							trait = governor
							value = -5
						}
					}
				}
			}
		}
	}
}

#Escaped Justice
escaped_justice = {
	group = admin_governance_group
	icon = "gfx/interface/icons/message_feed/marshal_job.dds"

	valid_to_create = {
		valid_governor_contract_trigger = yes
	}

	valid_to_keep = {
		task_contract_taker = { valid_governor_contract_trigger = yes }
		valid_governor_contract_basic_trigger = yes
		task_contract_target = {
			is_travelling = no
			is_imprisoned = no
			is_commanding_army = no
		}
	}

	valid_to_accept = {
		valid_governor_contract_trigger = yes

		custom_tooltip = {
			text = has_active_governance_issue
			num_taken_task_contracts < 1
		}
		is_available = yes
	}

	valid_to_continue = {
		task_contract_taker = {
			valid_governor_contract_trigger = yes
		}
	}

	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		save_scope_as = task_contract
		task_contract_taker ?= {
			trigger_event = governor_contract_events_tova.0055
		}
	}

	on_completed = {
	}

	on_invalidated = {
		if = {
			limit = { governor_contract_invalidated_message_trigger = yes }
			governor_contract_invalidated_message_effect = yes
		}
	}

	task_contract_reward = {
		success = {
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				custom_tooltip = tgp_admin_contract_success_tt_rewards
			}
		}
		success_failure = {
			positive = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				custom_tooltip = tgp_admin_contract_failure_tt
			}
		}
		escapee_persuade = { #Diplomacy
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_as = task_contract
				task_contract_taker ?= {
					increase_governance_effect = { VALUE = 6 }
					change_merit = {
						value = minor_merit_gain
						multiply = governance_task_contract_tier_value
					}
				}
			}
		}
		escapee_slain = { #Martial duel
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_as = task_contract
				task_contract_taker ?= {
					add_dread = {
						value = medium_dread_gain
						multiply = governance_task_contract_tier_value
					}
				}
				task_contract_location.county = {
					if = {
						limit = { county_control < 100 }
						change_county_control = 10
					}
				}
			}
		}
		escapee_join_monastery = { #Increase Piety
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_as = task_contract
				task_contract_taker ?= {
					add_piety = {
						value = medium_piety_gain
						multiply = governance_task_contract_tier_value
					}
				}
			}
		}
		escapee_shunned = { #Influence Gain 
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_as = task_contract
				task_contract_taker ?= {
					increase_governance_effect = { VALUE = 4 }
					change_influence = {
						value = minor_influence_gain
						multiply = governance_task_contract_tier_value
					}
				}
			}
		}
		failure_standard = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				task_contract_taker ?= {
					change_influence = minor_influence_loss
				}
				task_contract_location.county = {
					change_county_control = -5
				}
			}
		}
	}
}

#Forced Conscription
forced_conscription = {
	group = admin_governance_group
	icon = "gfx/interface/icons/message_feed/marshal_job.dds"
	travel = no

	valid_to_create = {
		valid_governor_contract_trigger = yes
	}

	valid_to_keep = {
		task_contract_taker = { valid_governor_contract_trigger = yes }
		valid_governor_contract_basic_trigger = yes
	}

	valid_to_accept = {
		valid_governor_contract_trigger = yes

		custom_tooltip = {
			text = has_active_governance_issue
			num_taken_task_contracts < 1
		}
		is_available = yes
	}

	valid_to_continue = {
		task_contract_taker = {
			valid_governor_contract_trigger = yes
		}
		task_contract_employer = {
			is_alive = yes
		}
	}

	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		save_scope_as = task_contract
		task_contract_employer = {
			save_scope_as = recruitment_employer
		}
		task_contract_taker ?= {
			trigger_event = governor_contract_events_tova.0060
		}
	}

	on_completed = {
	}

	on_invalidated = {
		if = {
			limit = { governor_contract_invalidated_message_trigger = yes }
			governor_contract_invalidated_message_effect = yes
		}
	}

	task_contract_reward = {
		success = {
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				custom_tooltip = tgp_admin_contract_success_tt_rewards
			}
		}
		success_failure = {
			positive = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				custom_tooltip = tgp_admin_contract_failure_tt
			}
		}
		conscripts_bribed = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_as = task_contract
				task_contract_location = {
					add_province_modifier = {
						modifier = tgp_fattened_vanguard_modifier
						years = 10
					}
				}
				task_contract_taker ?= {
					remove_short_term_gold = {
						value = minor_gold_value
						multiply = governance_task_contract_tier_value
					}
				}
			}
		}
		conscripts_forced = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_as = task_contract
				task_contract_location = {
					add_province_modifier = {
						modifier = tgp_fattened_vanguard_modifier
						years = 10
					}
				}
				task_contract_location.county = {
					change_county_control = medium_county_control_loss
				}
				task_contract_taker ?= {
					change_influence = {
						value = minor_influence_gain
						multiply = governance_task_contract_tier_value
					}
				}
			}
		}
		conscripts_convinced = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_as = task_contract
				task_contract_location = {
					add_province_modifier = {
						modifier = tgp_fattened_vanguard_modifier
						years = 10
					}
				}				
				task_contract_taker ?= {
					change_merit = {
						value = minor_merit_gain
						multiply = governance_task_contract_tier_value
					}
				}
			}
		}
		conscripts_trade = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_as = task_contract
				task_contract_location.county = {
					add_county_modifier = {
						modifier = tgp_diligent_workers_modifier
						years = 10
					}
				}				
				task_contract_taker ?= {
					change_merit = {
						value = minor_merit_loss
						multiply = governance_task_contract_tier_value
					}
				}
			}
		}
		failure_standard = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				task_contract_taker ?= {
					change_influence = minor_influence_loss
				}
				task_contract_location.county = {
					change_county_control = -5
				}
			}
		}
	}
}

#Teach Monks Martial Arts
combat_train_monks = {
	group = admin_governance_group
	icon = "gfx/interface/icons/message_feed/marshal_job.dds"

	valid_to_create = {
		valid_governor_contract_trigger = yes
	}

	valid_to_keep = {
		task_contract_taker = { valid_governor_contract_trigger = yes }
		valid_governor_contract_basic_trigger = yes
	}

	valid_to_accept = {
		valid_governor_contract_trigger = yes

		custom_tooltip = {
			text = has_active_governance_issue
			num_taken_task_contracts < 1
		}
		is_available = yes
	}

	valid_to_continue = {
		task_contract_taker = {
			valid_governor_contract_trigger = yes
		}
	}

	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		save_scope_as = task_contract
		task_contract_taker ?= {
			trigger_event = governor_contract_events_tova.0065
		}
	}

	on_completed = {
	}

	on_invalidated = {
		if = {
			limit = {governor_contract_invalidated_message_trigger = yes }
			governor_contract_invalidated_message_effect = yes
		}
	}

	task_contract_reward = {
		success = {
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				custom_tooltip = tgp_admin_contract_success_tt_rewards
			}
		}
		success_failure = {
			positive = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				custom_tooltip = tgp_admin_contract_failure_tt
			}
		}
		hire_monks_as_maa = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_as = task_contract
				task_contract_taker ?= {
					increase_governance_effect = { VALUE = 4 }
				}
			}
		}
		hire_monk_as_knight = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_as = task_contract
				task_contract_taker ?= {
					change_influence = minor_influence_loss
				}
			}
		}
		train_monks = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_as = task_contract
				task_contract_taker ?= {
					change_influence = {
						value = miniscule_influence_gain
						multiply = governance_task_contract_tier_value
					}
					increase_governance_effect = { VALUE = 4 }
				}
				scope:task_contract.task_contract_location = {
					add_province_modifier = {
						modifier = tgp_trained_monks_modifier
						years = 10
					}
				}
				scope:task_contract.task_contract_location.county = {
					if = {
						limit = { county_control < 100 }
						change_county_control = 10
					}
				}
			}
		}
		station_troops = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_as = task_contract
				task_contract_taker ?= {
				}
				scope:task_contract.task_contract_location = {
					add_province_modifier = {
						modifier = tgp_stationed_troops_modifier
						years = 10
					}
				}
				scope:task_contract.task_contract_location.county = {
					if = {
						limit = { county_control < 100 }
						change_county_control = 10
					}				
				}
			}
		}
		let_marshal_handle = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_as = task_contract
				scope:task_contract.task_contract_location = {
					add_province_modifier = {
						modifier = tgp_adequately_trained_monks_modifier
						years = 10
					}
				}
				scope:task_contract.task_contract_location.county = {
					if = {
						limit = { county_control < 100 }
						change_county_control = 10
					}
				}
			}
		}
		failure_standard = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				task_contract_taker ?= {
					change_influence = minor_influence_loss
				}
				task_contract_location.county = {
					change_county_control = -5
				}
			}
		}
	}
}
