﻿namespace = rf_coalition

##### 1. A coalition forms against you (root = the target) #####
rf_coalition.1 = {
	type = character_event
	title = rf_coalition.1.t
	desc = rf_coalition.1.desc
	theme = diplomacy
	override_background = { reference = council_chamber }
	left_portrait = { character = root animation = anger }
	right_portrait = { character = scope:rf_joiner animation = schadenfreude }

	immediate = {
		save_scope_as = rf_coalition_target
	}

	option = { # Let them come
		name = rf_coalition.1.a
		add_prestige = 50
		add_character_modifier = { modifier = rf_defiant_modifier years = 5 }
		ai_chance = {
			base = 30
			modifier = { add = 30 has_trait = brave }
			modifier = { add = 30 has_trait = arrogant }
		}
	}
	option = { # Reassure the powers
		name = rf_coalition.1.b
		trigger = { gold >= rf_appease_gold_value }
		remove_short_term_gold = rf_appease_gold_value
		primary_title = { rf_change_menace_effect = { AMOUNT = -15 } }
		custom_tooltip = rf_coalition.1.b.tt
		ai_chance = {
			base = 30
			modifier = { add = 30 has_trait = craven }
			modifier = { add = 20 diplomacy >= 14 }
		}
	}
	option = { # Divide and rule
		name = rf_coalition.1.c
		trigger = { intrigue >= 10 }
		custom_tooltip = rf_coalition.1.c.tt
		random = {
			chance = {
				value = 25
				add = { value = intrigue multiply = 2 }
				max = 75
			}
			primary_title = {
				ordered_in_list = {
					variable = rf_coalition
					limit = { exists = holder }
					order_by = { value = 0 subtract = holder.max_military_strength }
					position = 0
					holder = {
						save_scope_as = rf_turncoat
						rf_leave_coalition_effect = yes
					}
				}
			}
			if = {
				limit = { exists = scope:rf_turncoat }
				send_interface_toast = {
					type = event_toast_effect_good
					title = rf_coalition.1.c.success
					left_icon = scope:rf_turncoat
				}
			}
		}
		add_stress = minor_stress_gain
		ai_chance = {
			base = 20
			modifier = { add = 30 has_trait = deceitful }
			modifier = { add = 20 intrigue >= 14 }
		}
	}
}

##### 2. You are invited to join a coalition (root = the player, scope:rf_threat) #####
rf_coalition.2 = {
	type = character_event
	title = rf_coalition.2.t
	desc = rf_coalition.2.desc
	theme = diplomacy
	override_background = { reference = council_chamber }
	left_portrait = { character = root animation = thinking }
	right_portrait = { character = scope:rf_threat animation = personality_bold }

	trigger = {
		exists = scope:rf_threat
		rf_can_join_coalition_against_trigger = { THREAT = scope:rf_threat }
	}

	option = { # Join
		name = rf_coalition.2.a
		custom_tooltip = rf_coalition.2.a.tt
		hidden_effect = { rf_join_coalition_effect = { THREAT = scope:rf_threat } }
	}
	option = { # Refuse
		name = rf_coalition.2.b
		primary_title = { set_variable = { name = rf_coalition_against_refused value = yes years = 5 } }
		custom_tooltip = rf_coalition.2.b.tt
	}
}

##### 3. As coalition leader, you may strike (root = the player leader) #####
rf_coalition.3 = {
	type = character_event
	title = rf_coalition.3.t
	desc = rf_coalition.3.desc
	theme = war
	override_background = { reference = council_chamber }
	left_portrait = { character = root animation = marshal }
	right_portrait = { character = scope:rf_coalition_target animation = anger }

	trigger = {
		exists = scope:rf_coalition_target
		scope:rf_coalition_target = { rf_coalition_war_ready_trigger = yes }
		NOT = { is_at_war_with = scope:rf_coalition_target }
	}

	option = { # Strike now
		name = rf_coalition.3.a
		rf_declare_coalition_war_effect = { TARGET = scope:rf_coalition_target }
	}
	option = { # Not yet
		name = rf_coalition.3.b
	}
}

##### 4. The coalition marches (root = the target) #####
rf_coalition.4 = {
	type = character_event
	title = rf_coalition.4.t
	desc = rf_coalition.4.desc
	theme = war
	override_background = { reference = council_chamber }
	left_portrait = { character = root animation = rage }
	right_portrait = { character = scope:attacker animation = war_over_win }

	option = {
		name = rf_coalition.4.a
	}
}
