namespace = godduel
########################
# God Duel
########################
character_event = {
	id = godduel.001
	desc = EVTDESC_WOL_11000
	picture = GFX_evt_god_01
	border = GFX_event_normal_frame_war
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				OR = {
					NOT = { has_character_modifier = declined_prestige_duel_timer }
					NOT = { 
						AND = {
							is_female = no
							event_target:challenger = { is_female = yes }
						}
					}
				}
			}
			add_character_modifier = {
				modifier = declined_prestige_duel_timer
				duration = 1095
				hidden = yes
			}
			set_character_flag = punish_declining
		}
		if = {
			limit = { NOT = { has_character_modifier = recent_duel_timer } }
			add_character_modifier = {
				modifier = recent_duel_timer
				hidden = yes
				duration = 365
			}
		}
		FROMFROM = {
			if = {
				limit = { NOT = { has_character_modifier = recent_duel_timer } }
				add_character_modifier = {
					modifier = recent_duel_timer
					hidden = yes
					duration = 365
				}
			}
		}
	}
	
	option = {
		name = EVTOPTA_WOL_11000
		ai_chance = {
			factor = 20
			modifier = {
				factor = 0.8
				NOT = {combat_rating = 5}
			}
			modifier = {
				factor = 0.5
				NOT = {combat_rating = 3}
			}
			modifier = {
				factor = 0
				NOT = {combat_rating = 1}
			}
			modifier = {
				factor = 2
				trait = proud
			}
			modifier = {
				factor = 0.05
				trait = craven
			}
			modifier = {
				factor = 0.5
				religion = jain
			}
			modifier = {
				religion_group = christian
				is_priest = yes
				factor = 0
			}
			modifier = {
				is_female = no
				FROM = { is_female = yes }
				factor = 0.025
			}
		}
		if = {
			limit = { trait = craven }
			random = {
				chance = 20
				remove_trait = craven
			}
		}
		if = {
			limit = { religion = jain }
			piety = -20
			custom_tooltip = { text = jain_ahimsa_tooltip }
		}
		if = {
			limit = { 
				FROMFROM = { 
					has_opinion_modifier = { who = ROOT modifier = grievously_offended }
				}
			}
			FROMFROM = {
				remove_opinion = { who = ROOT modifier = grievously_offended }
			}
		}
		save_event_target_as = opponent
		FROMFROM = {
			save_event_target_as = challenger
			hidden_tooltip = {
				character_event = { id = godduel.002 days = 3 }
			}
		}
		clr_character_flag = punish_declining
	}
	option = {
		name = EVTOPTB_WOL_11000
		ai_chance = {
			factor = 1
		}
		if = {
			limit = { has_character_flag = punish_declining }
			if = {
				limit = { 
					NOT = { trait = craven }
					NOT = { trait = brave }
				}
				random = {
					chance = 30
					add_trait = craven
				}
			}
			if = {
				limit = {
					trait = brave
				}
				remove_trait = brave
			}
			prestige = -50
			add_character_modifier = {
				modifier = declined_prestige_duel_timer
				hidden = yes
				duration = 1095
			}
		}
		hidden_tooltip = {
			remove_character_modifier = recent_duel_timer
		}
		FROMFROM = {
			hidden_tooltip = {
				remove_character_modifier = recent_duel_timer
				opinion = {
					modifier = opinion_fled_duel
					who = ROOT
					years = 100
				}
				character_event = { id = godduel.002 days = 3 }
			}
		}
		clr_character_flag = punish_declining
	}
}

# Start the duel
character_event = {
	id = godduel.002
	is_triggered_only = yes
	desc = EVTDESC_WOL_11001
	picture = GFX_evt_god_01
	border = GFX_event_normal_frame_war
	
	option = {
		name = EVTOPTA_WOL_11001
		hidden_tooltip = {
			character_event = { id = godduel.004 }
		}
	}
}

# Duel rejected
character_event = {
	id = godduel.003
	is_triggered_only = yes
	desc = EVTDESC_WOL_11002
	picture = GFX_evt_god_01
	border = GFX_event_normal_frame_war
	
	option = {
		name = EVTOPTA_WOL_11002
	}
}

# Pop-in without dialogue to accept (event_target:opponent and event_target:challenger must be set)
character_event = {
	id = godduel.004
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		if = {
			limit = { NOT = { has_character_modifier = recent_duel_timer } }
			add_character_modifier = {
				modifier = recent_duel_timer
				hidden = yes
				duration = 365
			}
		}
		event_target:opponent = {
			if = {
				limit = { NOT = { has_character_modifier = recent_duel_timer } }
				add_character_modifier = {
					modifier = recent_duel_timer
					hidden = yes
					duration = 365
				}
			}
		}
		opinion = {
			modifier = opinion_fought_duel
			who = event_target:opponent
			years = 150
		}
		if = {
			limit = {
				has_character_modifier = recent_duel_victory
			}
			remove_character_modifier = recent_duel_victory
		}
		event_target:opponent = {			
			opinion = {
				modifier = opinion_fought_duel
				who = ROOT
				years = 150
			}
			hidden_tooltip = {
				add_character_modifier = {
					name = fdcd
					duration = 45
					hidden = yes
				}
				character_event = { id = DEU.100 }
			}
		}
	}
}
