namespace = disbelieve_mandala_ongoing

#########################################
# disbelieve_mandala_ongoing.0001 - Agents spread rumours about target's miracles being tricks
# disbelieve_mandala_ongoing.0010 - Plant a fake relic on your target's court
#########################################

# Agents spread rumours about target's miracles being tricks
disbelieve_mandala_ongoing.0001 = {
	type = character_event
	title = disbelieve_mandala_ongoing.0001.t
	desc = disbelieve_mandala_ongoing.0001.desc
	
	theme = intrigue
	cooldown = { years = 5 }
	
	left_portrait = {
		character = root
		animation = frontend_left_idle
	}
	right_portrait = {
		character = scope:agent
		animation = scheme
		camera = camera_event_right_pointing_right_scheme
	}
	lower_right_portrait = scope:target
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	trigger = {
		is_available_adult = yes
		any_scheme = {
			type = disbelieve_mandala
			any_scheme_agent_character = { is_available_ai_adult = yes }
		}
	}

	immediate = {
		random_scheme = {
			type = disbelieve_mandala
			save_scope_as = my_scheme
			random_scheme_agent_character = {
				limit = { is_available_ai_adult = yes }
				weight = {
					base = 1
					modifier = { add = intrigue }
				}
				save_scope_as = agent
			}
			scheme_target_character = { save_scope_as = target }
		}
	}

	# People believe it
	option = {
		name = disbelieve_mandala_ongoing.0001.a
		scope:agent = {
        	duel = {
				skills = { learning intrigue } 
				value = decent_skill_rating
				25 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 1.5
						min = -49
					}
					desc = disbelieve_mandala_ongoing.0001.a.crit_success
					root = {
						send_interface_toast = {
							title = disbelieve_mandala_ongoing.0001.a.crit_success
							left_icon = scope:agent
							right_icon = scope:target
							add_piety = medium_piety_gain
							scope:my_scheme = {
								add_scheme_modifier = {
									type = scheme_fake_miracles
								}
							}
						}
					}
				}
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					desc = disbelieve_mandala_ongoing.0001.a.success
					root = {
						send_interface_toast = {
							title = disbelieve_mandala_ongoing.0001.a.success
							left_icon = scope:agent
							right_icon = scope:target
							scope:my_scheme = {
								add_scheme_modifier = {
									type = scheme_fake_miracles
								}
							}
						}
					}
				}
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					desc = disbelieve_mandala_ongoing.0001.a.failure
					root = {
						send_interface_toast = {
							title = disbelieve_mandala_ongoing.0001.a.failure
							left_icon = scope:agent
							right_icon = scope:target
							if = {
								limit = {
									scope:my_scheme = {
										NOT = { scheme_breaches >= scheme_breaches_about_to_hit_limit_value }
									}
								}
								custom_tooltip = {
									text = disbelieve_mandala_ongoing.0001.a.failure.breach
									scope:my_scheme = { add_scheme_breach = 1 }
								}
							}
							else = { add_piety = medium_piety_loss }
							play_sound_effect = "event:/DLC/EP3/SFX/Stingers/Scheme_Rework/ep3_mx_sting_schemerework_scheme_suffering_breaches"
						}
					}
				}
			}
        }
		stress_impact = {
			arrogant = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 2
				OR = {
					has_trait = arrogant
					scope:agent.learning >= high_skill_rating
					scope:agent.intrigue >= high_skill_rating
				}
			}
		}
	}

	# Don't take the risk
	option = {
		name = disbelieve_mandala_ongoing.0001.b
		stress_impact = {
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
}

# Plant a fake relic on your target's court
disbelieve_mandala_ongoing.0010 = {
	type = character_event
	title = disbelieve_mandala_ongoing.0010.t
	desc = disbelieve_mandala_ongoing.0010.desc
	
	theme = intrigue
	override_background = { reference = study }
	cooldown = { years = 5 }
	
	left_portrait = {
		character = root
		animation = interested
	}
	right_portrait = {
		character = scope:spymaster
		animation = schadenfreude
	}
	lower_right_portrait = scope:target
	artifact = {
		position = lower_left_portrait
		target = scope:fake_relic
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	trigger = {
		is_available_adult = yes
		exists = cp:councillor_spymaster
	}

	immediate = {
		random_scheme = {
			type = disbelieve_mandala
			save_scope_as = my_scheme
			scheme_target_character = { save_scope_as = target }
		}
		cp:councillor_spymaster = {
			assign_quirk_effect = yes
			save_scope_as = spymaster
			hidden_effect = {
				if = {
					limit = { NEOW_religion_is_broadly_christian_trigger = yes }
					create_artifact_pedestal_reliquary_christian_effect = { OWNER = scope:spymaster }
				}
				else_if = {
					limit = { religion = religion:islam_religion }
					create_artifact_pedestal_reliquary_islam_effect = { OWNER = scope:spymaster }
				}
				else_if = {
					limit = { religion = religion:buddhism_religion }
					create_artifact_pedestal_reliquary_buddhism_effect = { OWNER = scope:spymaster }
				}
				else_if = {
					limit = { religion = religion:judaism_religion }
					create_artifact_pedestal_reliquary_judaism_effect = { OWNER = scope:spymaster }
				}
				else = {
					create_artifact_sculpture_religious_effect = { OWNER = scope:spymaster }
				}
				scope:newly_created_artifact = { save_scope_as = fake_relic }
			}
		}
	}

	# Do it!
	option = {
		name = disbelieve_mandala_ongoing.0010.a
		scope:spymaster = {
        	duel = {
				skills = { diplomacy intrigue } 
				value = decent_skill_rating
				60 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					desc = disbelieve_mandala_ongoing.0010.a.success
					root = {
						send_interface_toast = {
							title = disbelieve_mandala_ongoing.0010.a.success
							left_icon = scope:spymaster
							right_icon = scope:target
							scope:target = { add_piety = medium_piety_loss }
							scope:my_scheme = {
								add_scheme_progress = 60
							}
						}
					}
				}
				40 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					desc = disbelieve_mandala_ongoing.0010.a.failure
					root = {
						send_interface_toast = {
							title = disbelieve_mandala_ongoing.0010.a.failure
							left_icon = scope:spymaster
							right_icon = scope:target
							scope:target = {
								progress_towards_rival_effect = {
									CHARACTER = root
									OPINION = -40
									REASON = rival_planted_fake_artifact
								}
							}
						}
					}
				}
			}
        }
		stress_impact = {
			deceitful = minor_stress_impact_loss
			honest = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 2
				OR = {
					has_trait = deceitful
					scope:agent.diplomacy >= high_skill_rating
					scope:agent.intrigue >= high_skill_rating
				}
			}
			modifier = {
				factor = 0
				has_trait = honest
			}
		}
	}

	# Nah
	option = {
		name = disbelieve_mandala_ongoing.0010.b
		stress_impact = {
			honest = minor_stress_impact_loss
			deceitful = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = deceitful
			}
			modifier = {
				factor = 2
				has_trait = honest
			}
		}
	}
}