﻿namespace = cagm_whaling

# Hidden arrival dispatcher. An existing Master of Whaling leads
# automatically; a vacant office opens the Hunt-style candidate choice first.
cagm_whaling.0002 = {
	type = activity_event
	hidden = yes

	immediate = {
		if = {
			limit = { employs_court_position = cagm_master_whaler_court_position }
			court_position:cagm_master_whaler_court_position = { save_scope_as = crew_guest }
			involved_activity = { set_variable = { name = cagm_whaling_crew_leader value = scope:crew_guest } }
			trigger_event = cagm_whaling.0001
		}
		else = { trigger_event = cagm_whaling.0003 }
	}
}

# A vacant office mirrors Hunt's arrival-time Master-of-the-Hunt recruitment.
# The two best eligible attendees are ranked by this office's aptitude. Local
# Whalers fill empty candidate slots so the player always receives two choices.
cagm_whaling.0003 = {
	type = activity_event
	title = cagm_whaling.0003.t
	desc = cagm_whaling.0003.desc
	theme = hunting
	override_background = { reference = bp3_coast }
	left_portrait = { character = root animation = thinking }
	center_portrait = { character = scope:whaling_master_candidate_1 animation = marshal }
	right_portrait = { character = scope:whaling_master_candidate_2 animation = marshal }

	immediate = {
		if = {
			limit = { can_employ_court_position_type = cagm_master_whaler_court_position }
			involved_activity = {
				ordered_attending_character = {
					limit = {
						this != root
						OR = { is_vassal_of = root is_courtier_of = root }
						root = { can_appoint_char_to_court_position = { CHAR = prev COURT_POS = cagm_master_whaler_court_position } }
					}
					order_by = aptitude:cagm_master_whaler_court_position
					save_scope_as = whaling_master_candidate_1
				}
				ordered_attending_character = {
					limit = {
						this != root
						trigger_if = {
							limit = { exists = scope:whaling_master_candidate_1 }
							this != scope:whaling_master_candidate_1
						}
						OR = { is_vassal_of = root is_courtier_of = root }
						root = { can_appoint_char_to_court_position = { CHAR = prev COURT_POS = cagm_master_whaler_court_position } }
					}
					order_by = aptitude:cagm_master_whaler_court_position
					save_scope_as = whaling_master_candidate_2
				}
			}
		}
		else = {
			involved_activity = {
				ordered_attending_character = {
					limit = { this != root is_adult = yes is_imprisoned = no NOT = { is_incapable = yes } }
					order_by = aptitude:cagm_master_whaler_court_position
					save_scope_as = whaling_master_candidate_1
				}
				ordered_attending_character = {
					limit = {
						this != root
						trigger_if = {
							limit = { exists = scope:whaling_master_candidate_1 }
							this != scope:whaling_master_candidate_1
						}
						is_adult = yes
						is_imprisoned = no
						NOT = { is_incapable = yes }
					}
					order_by = aptitude:cagm_master_whaler_court_position
					save_scope_as = whaling_master_candidate_2
				}
			}
		}
		if = {
			limit = { NOT = { exists = scope:whaling_master_candidate_1 } }
			create_character = {
				template = cagm_local_whaler_character
				culture = root.location.culture
				faith = root.location.faith
				location = root.location
				save_scope_as = whaling_master_candidate_1
			}
			scope:whaling_master_candidate_1 = { set_employer = root }
		}
		if = {
			limit = { NOT = { exists = scope:whaling_master_candidate_2 } }
			create_character = {
				template = cagm_local_whaler_character
				culture = root.location.culture
				faith = root.location.faith
				location = root.location
				save_scope_as = whaling_master_candidate_2
			}
			scope:whaling_master_candidate_2 = { set_employer = root }
		}
	}

	option = {
		name = cagm_whaling.0003.a
		if = {
			limit = {
				can_employ_court_position_type = cagm_master_whaler_court_position
				scope:whaling_master_candidate_1 = { can_be_employed_as = cagm_master_whaler_court_position }
			}
			appoint_court_position = { recipient = scope:whaling_master_candidate_1 court_position = cagm_master_whaler_court_position }
		}
		involved_activity = { set_variable = { name = cagm_whaling_crew_leader value = scope:whaling_master_candidate_1 } }
		custom_tooltip = cagm_whaling_master_selected_tt
		hidden_effect = { trigger_event = cagm_whaling.0001 }
		ai_chance = { base = 80 }
	}
	option = {
		name = cagm_whaling.0003.b
		if = {
			limit = {
				can_employ_court_position_type = cagm_master_whaler_court_position
				scope:whaling_master_candidate_2 = { can_be_employed_as = cagm_master_whaler_court_position }
			}
			appoint_court_position = { recipient = scope:whaling_master_candidate_2 court_position = cagm_master_whaler_court_position }
		}
		involved_activity = { set_variable = { name = cagm_whaling_crew_leader value = scope:whaling_master_candidate_2 } }
		custom_tooltip = cagm_whaling_master_selected_tt
		hidden_effect = { trigger_event = cagm_whaling.0001 }
		ai_chance = { base = 20 }
	}
}

cagm_whaling.0001 = {
	type = activity_event
	title = cagm_whaling.0001.t
	desc = cagm_whaling.0001.desc
	theme = hunting
	override_background = { reference = bp3_coast }
	left_portrait = { character = root animation = personality_bold }

	option = {
		name = cagm_whaling.0001.a
		custom_tooltip = cagm_whaling_command_safe_tt
			hidden_effect = {
			involved_activity = {
				change_variable = { name = cagm_whaling_event_adjustment add = 5 }
				set_variable = { name = cagm_whaling_story_route_command value = yes }
				set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value }
			}
			trigger_event = { id = cagm_whaling.0100 days = 5 }
		}
		ai_chance = { base = 50 modifier = { add = 30 has_trait = craven } }
	}
	option = {
		name = cagm_whaling.0001.b
		add_stress = 5
		custom_tooltip = cagm_whaling_chase_risk_tt
		hidden_effect = {
			involved_activity = {
				change_variable = { name = cagm_whaling_event_adjustment add = 8 }
				set_variable = { name = cagm_whaling_role_chase value = yes }
				set_variable = { name = cagm_whaling_story_route_chase value = yes }
				set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value }
			}
			trigger_event = { id = cagm_whaling.0100 days = 5 }
		}
		ai_chance = { base = 35 modifier = { add = 20 has_trait = brave } }
	}
	option = {
		name = cagm_whaling.0001.c
		add_stress = 10
		custom_tooltip = cagm_whaling_strike_lethal_warning_tt
		hidden_effect = {
			involved_activity = {
				change_variable = { name = cagm_whaling_event_adjustment add = 10 }
				set_variable = { name = cagm_whaling_role_strike value = yes }
				set_variable = { name = cagm_whaling_story_route_strike value = yes }
				set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value }
			}
			trigger_event = { id = cagm_whaling.0100 days = 5 }
		}
		ai_chance = { base = 15 modifier = { add = 30 has_trait = brave } modifier = { factor = 0 has_trait = craven } }
	}
}

cagm_whaling.0010 = {
	type = activity_event
	title = cagm_whaling.0010.t
	desc = cagm_whaling.0010.desc
	theme = stewardship
	override_background = { reference = bp3_coast }
	left_portrait = { character = root animation = thinking }
	right_portrait = { trigger = { exists = scope:crew_guest } character = scope:crew_guest animation = marshal }
	immediate = {
		involved_activity = {
			if = {
				limit = { exists = var:cagm_whaling_crew_leader }
				var:cagm_whaling_crew_leader = { save_scope_as = crew_guest }
			}
		}
		# Compatibility fallback for an activity started by an older build or a
		# direct debug-event call that bypassed the new dispatcher.
		if = {
			limit = { NOT = { exists = scope:crew_guest } }
			involved_activity = {
				random_attending_character = {
					limit = { this != root is_adult = yes is_imprisoned = no NOT = { is_incapable = yes } }
					save_scope_as = crew_guest
				}
			}
		}
		if = {
			limit = { NOT = { exists = scope:crew_guest } }
			create_character = {
				template = cagm_local_whaler_character
				culture = root.location.culture
				faith = root.location.faith
				location = root.location
				save_scope_as = crew_guest
			}
		}
		if = {
			limit = { exists = scope:crew_guest }
			involved_activity = { set_variable = { name = cagm_whaling_crew_leader value = scope:crew_guest } }
		}
	}

	option = {
		name = cagm_whaling.0010.a
		custom_tooltip = cagm_whaling_progress_strong_opinion_tt
		involved_activity = { every_attending_character = { limit = { this != scope:host } add_opinion = { target = root modifier = cagm_whaling_fair_share_opinion years = 4 } } }
		hidden_effect = {
			involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 9 } set_variable = { name = cagm_whaling_story_method_fair value = yes } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } }
			trigger_event = { id = cagm_whaling.0200 days = 5 }
		}
		ai_chance = { base = 45 modifier = { add = 25 has_trait = just } }
	}
	option = {
		name = cagm_whaling.0010.b
		add_prestige = 50
		custom_tooltip = cagm_whaling_progress_great_tt
		hidden_effect = {
			involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 12 } set_variable = { name = cagm_whaling_story_method_ruler value = yes } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } }
			trigger_event = { id = cagm_whaling.0200 days = 5 }
		}
		ai_chance = { base = 25 modifier = { add = 25 has_trait = greedy } }
	}
	option = {
		name = cagm_whaling.0010.c
		custom_tooltip = cagm_whaling_progress_good_tt
		hidden_effect = {
			involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 6 } set_variable = { name = cagm_whaling_story_method_artisans value = yes } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } }
			trigger_event = { id = cagm_whaling.0200 days = 5 }
		}
		ai_chance = { base = 30 modifier = { add = 20 learning >= 12 } }
	}
}

cagm_whaling.0020 = {
	type = activity_event
	title = cagm_whaling.0020.t
	desc = cagm_whaling.0020.desc
	theme = hunting
	override_background = { reference = bp3_coast }
	left_portrait = { character = root animation = worry }

	option = {
		name = cagm_whaling.0020.a
		custom_tooltip = cagm_whaling_progress_strong_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 10 } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } } }
		ai_chance = { base = 45 modifier = { add = 20 has_trait = patient } }
	}
	option = {
		name = cagm_whaling.0020.b
		add_stress = 10
		custom_tooltip = cagm_whaling_progress_great_reckless_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 14 } set_variable = { name = cagm_whaling_reckless_chase value = yes } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } } }
		ai_chance = { base = 20 modifier = { add = 30 has_trait = brave } modifier = { factor = 0 has_trait = craven } }
	}
	option = {
		name = cagm_whaling.0020.c
		add_stress = -5
		custom_tooltip = cagm_whaling_progress_small_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 4 } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } } }
		ai_chance = { base = 35 modifier = { add = 20 has_trait = calm } }
	}
}

cagm_whaling.0030 = {
	type = activity_event
	title = cagm_whaling.0030.t
	desc = cagm_whaling.0030.desc
	theme = hunting
	override_background = { reference = bp3_coast }
	left_portrait = { character = root animation = personality_bold }

	option = {
		name = cagm_whaling.0030.a
		custom_tooltip = cagm_whaling_turn_back_safe_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = -10 } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } } }
		ai_chance = { base = 35 modifier = { add = 35 has_trait = craven } }
	}
	option = {
		name = cagm_whaling.0030.b
		add_stress = 10
		custom_tooltip = cagm_whaling_progress_strong_crew_risk_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 9 } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } } }
		ai_chance = { base = 50 modifier = { add = 20 has_trait = stubborn } }
	}
	option = {
		name = cagm_whaling.0030.c
		trigger = { involved_activity = { OR = { has_variable = cagm_whaling_role_strike has_variable = cagm_whaling_role_chase } } }
		add_stress = 15
		custom_tooltip = cagm_whaling_continue_lethal_warning_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 15 } set_variable = { name = cagm_whaling_lethal_risk value = yes } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } } }
		ai_chance = { base = 15 modifier = { add = 35 has_trait = brave } modifier = { factor = 0 has_trait = craven } }
	}
}

cagm_whaling.0100 = {
	type = activity_event
	title = {
		first_valid = {
			triggered_desc = { trigger = { involved_activity = { has_variable = cagm_whaling_story_route_command } } desc = cagm_whaling.0100.command.t }
			triggered_desc = { trigger = { involved_activity = { has_variable = cagm_whaling_story_route_chase } } desc = cagm_whaling.0100.chase.t }
			desc = cagm_whaling.0100.strike.t
		}
	}
	desc = {
		first_valid = {
			triggered_desc = { trigger = { involved_activity = { has_variable = cagm_whaling_story_route_command } } desc = cagm_whaling.0100.command.desc }
			triggered_desc = { trigger = { involved_activity = { has_variable = cagm_whaling_story_route_chase } } desc = cagm_whaling.0100.chase.desc }
			desc = cagm_whaling.0100.strike.desc
		}
	}
	theme = hunting
	override_background = { reference = bp3_coast }
	trigger = { exists = scope:activity involved_activity.activity_host ?= this }
	left_portrait = { character = root animation = personality_bold }

	option = {
		name = cagm_whaling.0100.a
		trigger = { involved_activity = { has_variable = cagm_whaling_story_route_command } }
		add_stewardship_lifestyle_xp = 20
		custom_tooltip = cagm_branch_steady_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 4 } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } add_activity_log_entry = { key = cagm_whaling_log_route_steady character = root score = 10 show_in_conclusion = no } } }
		ai_chance = { base = 65 modifier = { add = 20 stewardship >= 12 } }
	}
	option = {
		name = cagm_whaling.0100.b
		trigger = { involved_activity = { has_variable = cagm_whaling_story_route_command } }
		add_stress = 5
		custom_tooltip = cagm_branch_ambitious_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 2 } set_variable = { name = cagm_whaling_story_route_ambition value = yes } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } add_activity_log_entry = { key = cagm_whaling_log_route_ambitious character = root score = 10 show_in_conclusion = no } } }
		ai_chance = { base = 35 modifier = { add = 20 has_trait = ambitious } }
	}
	option = {
		name = cagm_whaling.0100.c
		trigger = { involved_activity = { has_variable = cagm_whaling_story_route_chase } }
		add_stress = -5
		custom_tooltip = cagm_branch_steady_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 4 } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } add_activity_log_entry = { key = cagm_whaling_log_route_steady character = root score = 10 show_in_conclusion = no } } }
		ai_chance = { base = 65 modifier = { add = 20 has_trait = calm } }
	}
	option = {
		name = cagm_whaling.0100.d
		trigger = { involved_activity = { has_variable = cagm_whaling_story_route_chase } }
		add_stress = 5
		custom_tooltip = cagm_branch_ambitious_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 2 } set_variable = { name = cagm_whaling_story_route_ambition value = yes } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } add_activity_log_entry = { key = cagm_whaling_log_route_ambitious character = root score = 10 show_in_conclusion = no } } }
		ai_chance = { base = 35 modifier = { add = 25 has_trait = brave } }
	}
	option = {
		name = cagm_whaling.0100.e
		trigger = { involved_activity = { has_variable = cagm_whaling_story_route_strike } }
		custom_tooltip = cagm_branch_steady_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 4 } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } add_activity_log_entry = { key = cagm_whaling_log_route_steady character = root score = 10 show_in_conclusion = no } } }
		ai_chance = { base = 65 modifier = { add = 20 prowess >= 12 } }
	}
	option = {
		name = cagm_whaling.0100.f
		trigger = { involved_activity = { has_variable = cagm_whaling_story_route_strike } }
		add_stress = 5
		custom_tooltip = cagm_branch_ambitious_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 2 } set_variable = { name = cagm_whaling_story_route_ambition value = yes } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } add_activity_log_entry = { key = cagm_whaling_log_route_ambitious character = root score = 10 show_in_conclusion = no } } }
		ai_chance = { base = 35 modifier = { add = 25 has_trait = brave } modifier = { factor = 0 has_trait = craven } }
	}
}

cagm_whaling.0200 = {
	type = activity_event
	title = {
		first_valid = {
			triggered_desc = { trigger = { involved_activity = { has_variable = cagm_whaling_story_method_fair } } desc = cagm_whaling.0200.fair.t }
			triggered_desc = { trigger = { involved_activity = { has_variable = cagm_whaling_story_method_ruler } } desc = cagm_whaling.0200.ruler.t }
			desc = cagm_whaling.0200.artisans.t
		}
	}
	desc = {
		first_valid = {
			triggered_desc = { trigger = { involved_activity = { has_variable = cagm_whaling_story_method_fair } } desc = cagm_whaling.0200.fair.desc }
			triggered_desc = { trigger = { involved_activity = { has_variable = cagm_whaling_story_method_ruler } } desc = cagm_whaling.0200.ruler.desc }
			desc = cagm_whaling.0200.artisans.desc
		}
	}
	theme = stewardship
	override_background = { reference = bp3_coast }
	trigger = { exists = scope:activity involved_activity.activity_host ?= this }
	immediate = { involved_activity.var:cagm_whaling_crew_leader = { save_scope_as = crew_leader } }
	left_portrait = { character = root animation = thinking }
	right_portrait = { trigger = { exists = scope:crew_leader } character = scope:crew_leader animation = marshal }

	option = {
		name = cagm_whaling.0200.a
		trigger = { involved_activity = { has_variable = cagm_whaling_story_method_fair } }
		custom_tooltip = cagm_branch_steady_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 4 } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } add_activity_log_entry = { key = cagm_whaling_log_method_steady character = root score = 10 show_in_conclusion = no } } }
		ai_chance = { base = 65 modifier = { add = 20 has_trait = just } }
	}
	option = {
		name = cagm_whaling.0200.b
		trigger = { involved_activity = { has_variable = cagm_whaling_story_method_fair } }
		add_prestige = 20
		custom_tooltip = cagm_branch_ambitious_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 2 } set_variable = { name = cagm_whaling_story_method_ambition value = yes } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } add_activity_log_entry = { key = cagm_whaling_log_method_ambitious character = root score = 10 show_in_conclusion = no } } }
		ai_chance = { base = 35 modifier = { add = 20 has_trait = generous } }
	}
	option = {
		name = cagm_whaling.0200.c
		trigger = { involved_activity = { has_variable = cagm_whaling_story_method_ruler } }
		custom_tooltip = cagm_branch_steady_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 4 } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } add_activity_log_entry = { key = cagm_whaling_log_method_steady character = root score = 10 show_in_conclusion = no } } }
		ai_chance = { base = 65 modifier = { add = 20 diplomacy >= 12 } }
	}
	option = {
		name = cagm_whaling.0200.d
		trigger = { involved_activity = { has_variable = cagm_whaling_story_method_ruler } }
		add_prestige = 35
		custom_tooltip = cagm_branch_ambitious_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 2 } set_variable = { name = cagm_whaling_story_method_ambition value = yes } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } add_activity_log_entry = { key = cagm_whaling_log_method_ambitious character = root score = 10 show_in_conclusion = no } } }
		ai_chance = { base = 35 modifier = { add = 25 has_trait = greedy } }
	}
	option = {
		name = cagm_whaling.0200.e
		trigger = { involved_activity = { has_variable = cagm_whaling_story_method_artisans } }
		add_learning_lifestyle_xp = 20
		custom_tooltip = cagm_branch_steady_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 4 } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } add_activity_log_entry = { key = cagm_whaling_log_method_steady character = root score = 10 show_in_conclusion = no } } }
		ai_chance = { base = 65 modifier = { add = 20 learning >= 12 } }
	}
	option = {
		name = cagm_whaling.0200.f
		trigger = { involved_activity = { has_variable = cagm_whaling_story_method_artisans } }
		add_prestige = 20
		custom_tooltip = cagm_branch_ambitious_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 2 } set_variable = { name = cagm_whaling_story_method_ambition value = yes } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } add_activity_log_entry = { key = cagm_whaling_log_method_ambitious character = root score = 10 show_in_conclusion = no } } }
		ai_chance = { base = 35 modifier = { add = 20 has_trait = ambitious } }
	}
}

# Hunt-style contextual pulse: one voyage incident is drawn, resolved, and
# then rejoins the fixed chase timeline.
cagm_whaling.0050 = {
	type = activity_event
	hidden = yes
	trigger = { exists = scope:activity involved_activity.activity_host ?= this }
	immediate = {
		random_list = {
			34 = { trigger_event = cagm_whaling.0300 }
			33 = { trigger_event = cagm_whaling.0310 }
			33 = { trigger_event = cagm_whaling.0320 }
		}
	}
}

cagm_whaling.0300 = {
	type = activity_event
	title = cagm_whaling.0300.t
	desc = cagm_whaling.0300.desc
	theme = hunting
	override_background = { reference = bp3_coast }
	trigger = { exists = scope:activity involved_activity.activity_host ?= this }
	left_portrait = { character = root animation = worry }
	option = {
		name = cagm_whaling.0300.a
		add_learning_lifestyle_xp = 15
		custom_tooltip = cagm_whaling_progress_good_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 4 } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } add_activity_log_entry = { key = cagm_whaling_log_fog_signals character = root score = 10 show_in_conclusion = no } } }
		ai_chance = { base = 60 modifier = { add = 20 learning >= 12 } }
	}
	option = {
		name = cagm_whaling.0300.b
		add_stress = 5
		custom_tooltip = cagm_whaling_progress_strong_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 7 } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } add_activity_log_entry = { key = cagm_whaling_log_fog_press character = root score = 10 show_in_conclusion = no } } }
		ai_chance = { base = 40 modifier = { add = 20 has_trait = brave } }
	}
}

cagm_whaling.0310 = {
	type = activity_event
	title = cagm_whaling.0310.t
	desc = cagm_whaling.0310.desc
	theme = hunting
	override_background = { reference = bp3_coast }
	trigger = { exists = scope:activity involved_activity.activity_host ?= this }
	left_portrait = { character = root animation = thinking }
	option = {
		name = cagm_whaling.0310.a
		add_stewardship_lifestyle_xp = 15
		custom_tooltip = cagm_whaling_progress_good_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 4 } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } add_activity_log_entry = { key = cagm_whaling_log_line_splice character = root score = 10 show_in_conclusion = no } } }
		ai_chance = { base = 60 modifier = { add = 20 has_trait = patient } }
	}
	option = {
		name = cagm_whaling.0310.b
		add_stress = 5
		custom_tooltip = cagm_whaling_progress_strong_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 7 } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } add_activity_log_entry = { key = cagm_whaling_log_line_replace character = root score = 10 show_in_conclusion = no } } }
		ai_chance = { base = 40 modifier = { add = 20 has_trait = impatient } }
	}
}

cagm_whaling.0320 = {
	type = activity_event
	title = cagm_whaling.0320.t
	desc = cagm_whaling.0320.desc
	theme = hunting
	override_background = { reference = bp3_coast }
	trigger = { exists = scope:activity involved_activity.activity_host ?= this }
	left_portrait = { character = root animation = personality_rational }
	option = {
		name = cagm_whaling.0320.a
		add_stress = -5
		custom_tooltip = cagm_whaling_progress_good_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 4 } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } add_activity_log_entry = { key = cagm_whaling_log_rowers_rotate character = root score = 10 show_in_conclusion = no } } }
		ai_chance = { base = 60 modifier = { add = 20 has_trait = compassionate } }
	}
	option = {
		name = cagm_whaling.0320.b
		add_prestige = 25
		custom_tooltip = cagm_whaling_progress_strong_tt
		hidden_effect = { involved_activity = { change_variable = { name = cagm_whaling_event_adjustment add = 7 } set_variable = { name = cagm_whaling_success value = cagm_whaling_success_value } add_activity_log_entry = { key = cagm_whaling_log_rowers_rally character = root score = 10 show_in_conclusion = no } } }
		ai_chance = { base = 40 modifier = { add = 20 diplomacy >= 12 } }
	}
}

cagm_whaling.0099 = {
	type = activity_event
	hidden = yes
	immediate = {
		random = {
			chance = { value = involved_activity.var:cagm_whaling_success }
			involved_activity = { set_variable = { name = cagm_whaling_success_roll value = yes } }
		}
		if = {
			limit = { involved_activity = { has_variable = cagm_whaling_success_roll } }
			random_list = {
				75 = { trigger_event = cagm_whaling.1100 }
				25 = {
					modifier = { add = 15 involved_activity = { has_variable = cagm_whaling_role_strike } }
					modifier = { add = 20 involved_activity = { has_activity_option = { category = cagm_whaling_purpose option = cagm_whaling_legendary } } }
					modifier = { add = 10 involved_activity = { has_activity_option = { category = cagm_whaling_crew option = cagm_whaling_crew_renowned } } }
					modifier = { add = 5 involved_activity = { has_variable = cagm_whaling_story_route_ambition } }
					modifier = { add = 5 involved_activity = { has_variable = cagm_whaling_story_method_ambition } }
					trigger_event = cagm_whaling.1200
				}
			}
		}
		else = { trigger_event = cagm_whaling.1000 }
	}
}

cagm_whaling.1000 = {
	type = activity_event
	title = cagm_whaling.1000.t
	desc = {
		first_valid = {
			triggered_desc = { trigger = { involved_activity = { has_variable = cagm_whaling_story_route_command } } desc = cagm_whaling.1000.command.desc }
			triggered_desc = { trigger = { involved_activity = { has_variable = cagm_whaling_story_route_chase } } desc = cagm_whaling.1000.chase.desc }
			triggered_desc = { trigger = { involved_activity = { has_variable = cagm_whaling_story_route_strike } } desc = cagm_whaling.1000.strike.desc }
			desc = cagm_whaling.1000.desc
		}
	}
	theme = hunting
	override_background = { reference = bp3_coast }
	left_portrait = { character = root animation = worry }
	immediate = {
		cagm_award_whaling_crew_xp_effect = { XP = 5 }
		involved_activity = {
			add_activity_log_entry = {
				key = cagm_whaling_log_failure
				character = root
				score = 25
				show_in_conclusion = yes
			}
		}
	}
	option = {
		name = cagm_whaling.1000.a
		add_prestige = -50
		remove_short_term_gold = 25
		cagm_award_tracked_trait_xp_effect = { TRAIT = cagm_whaler XP = 5 }
		if = {
			limit = { involved_activity = { has_variable = cagm_whaling_lethal_risk } }
			random_list = {
				15 = { death = { death_reason = death_drowned } }
				35 = { add_trait = wounded_2 }
				50 = { add_stress = 25 }
			}
		}
		else_if = {
			limit = { involved_activity = { has_variable = cagm_whaling_reckless_chase } }
			random_list = { 20 = { add_trait = wounded_1 } 80 = { add_stress = 15 } }
		}
		involved_activity = {
			set_variable = { name = cagm_whaling_result_failure value = yes }
			activity_location = { county = { add_county_modifier = { modifier = cagm_whaling_recently_hunted years = 3 } } }
		}
	}
}

# Ordinary success ends with a meaningful disposition decision.
cagm_whaling.1100 = {
	type = activity_event
	title = cagm_whaling.1100.t
	desc = {
		first_valid = {
			triggered_desc = { trigger = { involved_activity = { has_variable = cagm_whaling_story_route_command } } desc = cagm_whaling.1100.command.desc }
			triggered_desc = { trigger = { involved_activity = { has_variable = cagm_whaling_story_route_chase } } desc = cagm_whaling.1100.chase.desc }
			triggered_desc = { trigger = { involved_activity = { has_variable = cagm_whaling_story_route_strike } } desc = cagm_whaling.1100.strike.desc }
			desc = cagm_whaling.1100.desc
		}
	}
	theme = stewardship
	override_background = { reference = bp3_coast }
	left_portrait = { character = root animation = war_over_win }
	immediate = {
		cagm_award_whaling_crew_xp_effect = { XP = 20 }
		involved_activity = {
			add_activity_log_entry = {
				key = cagm_whaling_log_success
				character = root
				score = 75
				show_in_conclusion = yes
			}
		}
	}

	option = {
		name = cagm_whaling.1100.a
		add_gold = 150
		add_prestige = 150
		cagm_award_tracked_trait_xp_effect = { TRAIT = cagm_whaler XP = 20 }
		add_character_flag = cagm_whaling_practice
		involved_activity = { set_variable = { name = cagm_whaling_result_success value = yes } activity_location = { county = { add_county_modifier = { modifier = cagm_whaling_recently_hunted years = 5 } add_county_modifier = { modifier = cagm_whaling_coastal_prosperity years = 4 } } } }
		ai_chance = { base = 40 modifier = { add = 25 has_trait = greedy } }
	}
	option = {
		name = cagm_whaling.1100.b
		add_gold = 75
		add_prestige = 200
		cagm_award_tracked_trait_xp_effect = { TRAIT = cagm_whaler XP = 20 }
		add_character_flag = cagm_whaling_practice
		involved_activity = { every_attending_character = { limit = { this != scope:host } add_opinion = { target = root modifier = cagm_whaling_fair_share_opinion years = 5 } } set_variable = { name = cagm_whaling_result_success value = yes } activity_location = { county = { add_county_modifier = { modifier = cagm_whaling_recently_hunted years = 5 } add_county_modifier = { modifier = cagm_whaling_coastal_prosperity years = 6 } } } }
		ai_chance = { base = 40 modifier = { add = 25 has_trait = generous } }
	}
	option = {
		name = cagm_whaling.1100.c
		add_gold = 50
		add_prestige = 200
		cagm_award_tracked_trait_xp_effect = { TRAIT = cagm_whaler XP = 20 }
		add_character_flag = cagm_whaling_practice
		if = {
			limit = { involved_activity = { has_activity_option = { category = cagm_whaling_purpose option = cagm_whaling_legendary } } }
			cagm_create_legendary_whale_trophy_effect = yes
			remove_character_flag = cagm_whaling_legendary_rumor
			remove_character_flag = cagm_whaling_quarry_white_scar
			remove_character_flag = cagm_whaling_quarry_black_crown
			remove_character_flag = cagm_whaling_quarry_broken_spear
		}
		else = { cagm_create_random_whale_relic_effect = yes }
		involved_activity = { set_variable = { name = cagm_whaling_result_success value = yes } activity_location = { county = { add_county_modifier = { modifier = cagm_whaling_recently_hunted years = 5 } add_county_modifier = { modifier = cagm_whaling_coastal_prosperity years = 4 } } } }
		ai_chance = { base = 20 modifier = { add = 25 has_trait = ambitious } }
	}
	option = {
		name = cagm_whaling.1100.d
		trigger = {
			OR = {
				faith = { has_doctrine = doctrine_clerical_function_alms_and_pacification }
				has_trait = zealous
				has_trait = compassionate
			}
		}
		add_gold = 75
		add_prestige = 175
		add_piety = 150
		cagm_award_tracked_trait_xp_effect = { TRAIT = cagm_whaler XP = 20 }
		add_character_flag = cagm_whaling_practice
		involved_activity = { every_attending_character = { limit = { this != scope:host } add_opinion = { target = root modifier = cagm_whaling_fair_share_opinion years = 5 } } set_variable = { name = cagm_whaling_result_success value = yes } activity_location = { county = { add_county_modifier = { modifier = cagm_whaling_recently_hunted years = 5 } add_county_modifier = { modifier = cagm_whaling_coastal_prosperity years = 5 } } } }
		ai_chance = { base = 20 modifier = { add = 30 has_trait = zealous } }
	}
}

cagm_whaling.1200 = {
	type = activity_event
	title = cagm_whaling.1200.t
	desc = {
		first_valid = {
			triggered_desc = { trigger = { involved_activity = { has_variable = cagm_whaling_story_route_command } } desc = cagm_whaling.1200.command.desc }
			triggered_desc = { trigger = { involved_activity = { has_variable = cagm_whaling_story_route_chase } } desc = cagm_whaling.1200.chase.desc }
			triggered_desc = { trigger = { involved_activity = { has_variable = cagm_whaling_story_route_strike } } desc = cagm_whaling.1200.strike.desc }
			desc = cagm_whaling.1200.desc
		}
	}
	theme = stewardship
	override_background = { reference = bp3_coast }
	left_portrait = { character = root animation = war_over_win }
	immediate = {
		cagm_award_whaling_crew_xp_effect = { XP = 35 }
		involved_activity = {
			add_activity_log_entry = {
				key = cagm_whaling_log_exceptional
				character = root
				score = 100
				show_in_conclusion = yes
			}
		}
	}

	option = {
		name = cagm_whaling.1200.a
		trigger = { involved_activity = { NOT = { has_activity_option = { category = cagm_whaling_purpose option = cagm_whaling_legendary } } } }
		add_gold = 300
		add_prestige = 350
		cagm_award_tracked_trait_xp_effect = { TRAIT = cagm_whaler XP = 35 }
		add_character_flag = cagm_whaling_practice
		add_character_modifier = { modifier = cagm_whaling_renowned_catch years = 5 }
		involved_activity = { set_variable = { name = cagm_whaling_result_exceptional value = yes } activity_location = { county = { add_county_modifier = { modifier = cagm_whaling_recently_hunted years = 5 } add_county_modifier = { modifier = cagm_whaling_coastal_prosperity years = 8 } } } }
		ai_chance = { base = 35 modifier = { add = 25 has_trait = greedy } }
	}
	option = {
		name = cagm_whaling.1200.b
		trigger = { involved_activity = { NOT = { has_activity_option = { category = cagm_whaling_purpose option = cagm_whaling_legendary } } } }
		add_gold = 150
		add_prestige = 450
		cagm_award_tracked_trait_xp_effect = { TRAIT = cagm_whaler XP = 35 }
		add_character_flag = cagm_whaling_practice
		add_character_modifier = { modifier = cagm_whaling_renowned_catch years = 5 }
		involved_activity = { every_attending_character = { limit = { this != scope:host } add_opinion = { target = root modifier = cagm_whaling_fair_share_opinion years = 8 } } set_variable = { name = cagm_whaling_result_exceptional value = yes } activity_location = { county = { add_county_modifier = { modifier = cagm_whaling_recently_hunted years = 5 } add_county_modifier = { modifier = cagm_whaling_coastal_prosperity years = 10 } } } }
		ai_chance = { base = 40 modifier = { add = 25 has_trait = generous } }
	}
	option = {
		name = cagm_whaling.1200.c
		add_gold = 100
		add_prestige = 450
		cagm_award_tracked_trait_xp_effect = { TRAIT = cagm_whaler XP = 35 }
		add_character_flag = cagm_whaling_practice
		add_character_modifier = { modifier = cagm_whaling_renowned_catch years = 5 }
		if = {
			limit = { involved_activity = { has_activity_option = { category = cagm_whaling_purpose option = cagm_whaling_legendary } } }
			cagm_create_legendary_whale_trophy_effect = yes
			remove_character_flag = cagm_whaling_legendary_rumor
			remove_character_flag = cagm_whaling_quarry_white_scar
			remove_character_flag = cagm_whaling_quarry_black_crown
			remove_character_flag = cagm_whaling_quarry_broken_spear
		}
		else = { cagm_create_random_whale_relic_effect = yes }
		involved_activity = { set_variable = { name = cagm_whaling_result_exceptional value = yes } activity_location = { county = { add_county_modifier = { modifier = cagm_whaling_recently_hunted years = 5 } add_county_modifier = { modifier = cagm_whaling_coastal_prosperity years = 8 } } } }
		ai_chance = { base = 25 modifier = { add = 30 has_trait = ambitious } }
	}
	option = {
		name = cagm_whaling.1200.d
		trigger = {
			involved_activity = { NOT = { has_activity_option = { category = cagm_whaling_purpose option = cagm_whaling_legendary } } }
			OR = {
				faith = { has_doctrine = doctrine_clerical_function_alms_and_pacification }
				has_trait = zealous
				has_trait = compassionate
			}
		}
		add_gold = 125
		add_prestige = 350
		add_piety = 300
		cagm_award_tracked_trait_xp_effect = { TRAIT = cagm_whaler XP = 35 }
		add_character_flag = cagm_whaling_practice
		add_character_modifier = { modifier = cagm_whaling_renowned_catch years = 5 }
		involved_activity = { every_attending_character = { limit = { this != scope:host } add_opinion = { target = root modifier = cagm_whaling_fair_share_opinion years = 8 } } set_variable = { name = cagm_whaling_result_exceptional value = yes } activity_location = { county = { add_county_modifier = { modifier = cagm_whaling_recently_hunted years = 5 } add_county_modifier = { modifier = cagm_whaling_coastal_prosperity years = 8 } } } }
		ai_chance = { base = 20 modifier = { add = 35 has_trait = zealous } }
	}
}
