﻿#Activity Pulse Actions for Pilgrimages
#
#Adult education means guests are always AI and unlanded, some of these are therefore only for the host
#There won't always be an entourage of more than a caravan master
#There will be other students, and teachers. These are identified with flags and are generated/picked out by the activity.
#APAs marked with * involve or can happen to characters other than the host

#Study Hard Intent:
#apa_leveraging_language_skills

#Revelry Intent:
#

#Stress - University life requires work
#apa_procrastination

##Lifestyles, etc
#apa_studying_scripture - Shared/From other File
#apa_visited_markets - Shared/From other File
#apa_foreign_custom - Shared/From other File

##Random Education APAs
#apa_sight_seeing_group - Shared/From other File
#apa_university_discussions - Pick up lifestyle xp from teacher

#Character knows liturgical language of the religion of the university
#We are using the location here - rather than the religion of the teachers - which could differ
apa_leveraging_language_skills = {
	icon = public
	is_valid = {
		is_current_phase_active = yes
		scope:host = {
			location = scope:province
			has_activity_intent = study_hard_intent
			OR = {
				AND = {
					scope:province.faith.religion = religion:islam_religion
					knows_language = language_arabic
				}
				AND = {
					scope:province = {
						OR = {
							faith = faith:catholic
							faith = faith:conversos
							faith = faith:lollard
							faith = faith:insular_celtic
							faith = faith:mozarabic_church
						}
					}
					knows_language = language_latin
				}
				AND = {
					scope:province.faith = faith:cathar
					knows_language = language_occitano_romance
				}
				AND = {
					scope:province.faith = faith:armenian_apostolic
					knows_language = language_armenian
				}
				AND = {
					scope:province.faith = faith:nestorian
					knows_language = language_aramaic
				}
				AND = {
					scope:province.faith = faith:lamaism
					knows_language = language_tibetan
				}
				AND = {
					scope:province.religion = religion:bon_religion
					knows_language = language_tibetan
				}
				AND = {
					scope:province.religion = religion:taoism_religion
					knows_language = language_chinese
				}
				AND = {
					scope:province = {
						OR = {
							religion = religion:eastern_orthodox_religion
							religion = religion:catholic_religion
							religion = religion:protestant_religion
						}
						NOR = { #Non-Greek
							faith = faith:catholic
							faith = faith:conversos
							faith = faith:lollard
							faith = faith:insular_celtic
							faith = faith:mozarabic_church
							faith = faith:armenian_apostolic
							faith = faith:cathar
						}
					}
					knows_language = language_greek #General Christian Fallback
				}
				#For dead languages we check that you belong to the religion and have sufficient learning to be expected to know a liturgical language:
				AND = {
					religion = scope:province.religion
					scope:province = { #these have specific languages to learn
						NOR = {
							OR = {
								religion = religion:eastern_orthodox_religion
								religion = religion:catholic_religion
								religion = religion:protestant_religion
							}
							religion = religion:islam_religion
							religion = religion:taoism_religion
							faith = faith:lamaism
						}
					}
					learning > 15 #Well educated
				}
				AND = { #Dharmic Faiths knows Sanskrit
					scope:province = {
						is_dharmic_faith_trigger = yes
					}
					is_dharmic_faith_trigger = yes
					learning > 15 #Well educated
				}
			}
		}
	}

	weight = { value = 1 }

	effect = {
		scope:host = {
			save_scope_as = first
		}
		scope:province = {
			save_scope_as = second
		}

		add_activity_log_entry = {
			key = apa_leveraging_language_skills
			tags = { pulse_action }
			character = scope:first

			scope:activity = { activity_special_type_progression_tiny = yes }
			
			scope:first = {
				custom_tooltip = adult_education_tt_positive_tiny
				add_prestige = minor_prestige_gain
			}
		}
	}
}

apa_bonded_during_studies = {
	#Can be both Teachers and Students
	#Only does progress since events is the primary way to gain friends and rivals during studies.
	icon = learning
	is_valid = {
		is_current_phase_active = yes
		any_attending_character = {
			this != scope:host
			is_physically_able_ai_adult = yes
			num_of_relation_friend < 2
			location = scope:province
			number_of_traits_in_common = {
				target = scope:host
				value >= 1
			}
			can_set_relation_friend_trigger = { CHARACTER = scope:host }
		}
	}

	weight = {
		value = 1
	}

	effect = {
		scope:host = {
			save_scope_as = first
		}

		random_attending_character = {
			limit = {
				this != scope:host
				is_physically_able_ai_adult = yes
				num_of_relation_friend < 2
				location = scope:province
				number_of_traits_in_common = {
					target = scope:host
					value >= 1
				}
				can_set_relation_friend_trigger = { CHARACTER = scope:host }
			}
			save_scope_as = second
		}

		add_activity_log_entry = {
			key = apa_bonded_during_studies
			tags = { pulse_action }
			character = scope:first
			target = scope:second
			
			scope:second = {
				progress_towards_friend_effect = {
					REASON = friend_bonded_at_university
					CHARACTER = scope:first
					OPINION = default_friend_opinion
				}
			}
		}
	}
}

apa_procrastination = {
	#Either suitable trait or reveller intent
	icon = learning
	is_valid = {
		is_current_phase_active = yes
		any_attending_character = {
			NOR = {
				has_character_flag = teacher_1
				has_character_flag = teacher_2
			}
			OR = {
				has_activity_intent = university_revelry_intent
				has_trait = lazy
				has_trait = arrogant
				has_trait = drunkard
				has_trait = fickle
				has_trait = arbitrary
			}
		}
	}

	weight = {
		value = 1
	}

	effect = {
		random_attending_character = {
			limit = {
				NOR = {
					has_character_flag = teacher_1
					has_character_flag = teacher_2
				}
				OR = {
					has_activity_intent = university_revelry_intent
					has_trait = lazy
					has_trait = arrogant
					has_trait = drunkard
					has_trait = fickle
					has_trait = arbitrary
				}
			}
			save_scope_as = first
		}
		add_activity_log_entry = {
			key = apa_procrastination
			tags = { pulse_action }
			character = scope:first
			
			scope:first = {
				add_stress = minor_stress_gain
			}
		}
	}
}

apa_university_discussions = {
	#No real triggers
	icon = learning
	is_valid = {
		is_current_phase_active = yes
		any_attending_character = {
			this != scope:host
			is_available_healthy_ai_adult = yes
			OR = {
				has_character_flag = teacher_1
				has_character_flag = teacher_2
			}
		}
	}

	weight = {
		value = 1
	}

	effect = {
		scope:host = {
			save_scope_as = first
		}
		random_attending_character = {
			limit = {
				this != scope:host
				is_available_healthy_ai_adult = yes
				OR = {
					has_character_flag = teacher_1
					has_character_flag = teacher_2
				}
			}
			save_scope_as = second
		}
		add_activity_log_entry = {
			key = apa_university_discussions
			tags = { pulse_action }
			character = scope:first
			target = scope:second

			scope:second = {
				if = {
					limit = {
						has_education_martial_trigger = yes
					}
					scope:first = {
						add_martial_lifestyle_xp = medium_lifestyle_xp
					}
				}
				else_if = {
					limit = {
						has_education_diplomacy_trigger = yes
					}
					scope:first = {
						add_diplomacy_lifestyle_xp = medium_lifestyle_xp
					}
				}
				else_if = {
					limit = {
						has_education_learning_trigger = yes
					}
					scope:first = {
						add_learning_lifestyle_xp = medium_lifestyle_xp
					}
				}
				else_if = {
					limit = {
						has_education_stewardship_trigger = yes
					}
					scope:first = {
						add_stewardship_lifestyle_xp = medium_lifestyle_xp
					}
				}
				else_if = {
					limit = {
						has_education_intrigue_trigger = yes
					}
					scope:first = {
						add_intrigue_lifestyle_xp = medium_lifestyle_xp
					}
				}
			}
		}
	}
}

apa_night_on_books = {
	icon = learning
	is_valid = {
		is_current_phase_active = yes
		any_attending_character = {
			NOR = {
				has_character_flag = teacher_1
				has_character_flag = teacher_2
			}
		}
	}

	weight = {
		value = 1
	}

	effect = {
		random_attending_character = {
			limit = {
				NOR = {
					has_character_flag = teacher_1
					has_character_flag = teacher_2
				}
			}
			save_scope_as = first
		}

		add_activity_log_entry = {
			key = apa_night_on_books
			tags = { pulse_action }
			character = scope:first
			
			scope:first = {
				add_stress = minor_stress_gain
				if = {
					limit = {
						this = scope:host
					}
					custom_tooltip = adult_education_tt_positive_tiny
					scope:activity = { activity_special_type_progression_tiny = yes }
				}
			}
		}
	}
}

apa_student_disagreement = {
	icon = social
	is_valid = {
		is_current_phase_active = yes
		any_attending_character = {
			NOR = {
				has_character_flag = teacher_1
				has_character_flag = teacher_2
			}
			count = 2
		}
	}

	weight = {
		value = 1
	}

	effect = {
		random_attending_character = {
			limit = {
				NOR = {
					has_character_flag = teacher_1
					has_character_flag = teacher_2
				}
			}
			save_scope_as = first
		}
		random_attending_character = {
			limit = {
				NOR = {
					has_character_flag = teacher_1
					has_character_flag = teacher_2
					this = scope:first
				}
			}
			save_scope_as = second
		}

		add_activity_log_entry = {
			key = apa_student_disagreement
			tags = { pulse_action }
			character = scope:first
			target = scope:second

			
			scope:first = {
				if = {
					limit = {
						can_set_relation_rival_trigger = { CHARACTER = scope:second }
					}
					progress_towards_rival_effect = {
						REASON = rival_at_university
						CHARACTER = scope:second
						OPINION = default_rival_opinion
					}
				}
				else_if = {
					limit = {
						is_ai = yes
					}
					add_opinion = {
						target = scope:second
						modifier = annoyed_opinion
						opinion = -10
					}
				}
				else = {
					scope:second = {
						add_opinion = {
							target = scope:first
							modifier = annoyed_opinion
							opinion = -10
						}
					}
				}
			}
		}
	}
}

apa_rowdy_student = {
	icon = social
	is_valid = {
		is_current_phase_active = yes
		any_attending_character = {
			NOR = {
				has_character_flag = teacher_1
				has_character_flag = teacher_2
			}
			OR = {
				has_activity_intent = university_revelry_intent
				has_trait = drunkard
				has_trait = hashishiyah
				has_trait = gregarious
				has_trait = arrogant
			}
		}
		any_attending_character = {
			OR = {
				has_character_flag = teacher_1
				has_character_flag = teacher_2
			}
		}
	}

	weight = {
		value = 1
	}

	effect = {
		random_attending_character = {
			limit = {
				NOR = {
					has_character_flag = teacher_1
					has_character_flag = teacher_2
				}
				OR = {
					has_activity_intent = university_revelry_intent
					has_trait = drunkard
					has_trait = hashishiyah
					has_trait = gregarious
					has_trait = arrogant
				}
			}
			save_scope_as = first
		}
		random_attending_character = {
			limit = {
				OR = {
					has_character_flag = teacher_1
					has_character_flag = teacher_2
				}
			}
			save_scope_as = second
		}

		add_activity_log_entry = {
			key = apa_rowdy_student
			tags = { pulse_action }
			character = scope:first
			target = scope:second

			
			scope:second = {
				add_opinion = {
					target = scope:first
					modifier = annoyed_opinion
					opinion = -10
				}
			}
			scope:first = {
				add_stress = minor_stress_loss
			}	
		}
	}
}

apa_impromptu_poetry = {
	icon = social
	is_valid = {
		is_current_phase_active = yes
		any_attending_character = {
			NOR = {
				has_character_flag = teacher_1
				has_character_flag = teacher_2
			}
			OR = {
				has_activity_intent = university_revelry_intent
				has_trait = gregarious
				has_trait = lifestyle_poet
			}
		}
	}

	weight = {
		value = 1
	}

	effect = {
		random_attending_character = {
			limit = {
				NOR = {
					has_character_flag = teacher_1
					has_character_flag = teacher_2
				}
				OR = {
					has_activity_intent = university_revelry_intent
					has_trait = gregarious
					has_trait = lifestyle_poet
				}
			}
			save_scope_as = first
		}

		add_activity_log_entry = {
			key = apa_impromptu_poetry
			tags = { pulse_action }
			character = scope:first
	
			scope:first = {
				bp2_lifestyle_xp_gain_per_type_effect = { VALUE = minor }
			}	
		}
	}
}

apa_impressed_teacher = {
	icon = social
	is_valid = {
		is_current_phase_active = yes
		any_attending_character = {
			NOR = {
				has_character_flag = teacher_1
				has_character_flag = teacher_2
			}
			OR = {
				has_activity_intent = study_hard_intent
				has_trait = diligent
			}
		}
		any_attending_character = {
			OR = {
				has_character_flag = teacher_1
				has_character_flag = teacher_2
			}
		}
	}

	weight = {
		value = 1
	}

	effect = {
		random_attending_character = {
			limit = {
				NOR = {
					has_character_flag = teacher_1
					has_character_flag = teacher_2
				}
				OR = {
					has_activity_intent = study_hard_intent
					has_trait = diligent
				}
			}
			save_scope_as = first
		}
		random_attending_character = {
			limit = {
				OR = {
					has_character_flag = teacher_1
					has_character_flag = teacher_2
				}
			}
			save_scope_as = second
		}

		add_activity_log_entry = {
			key = apa_impressed_teacher
			tags = { pulse_action }
			character = scope:first
			target = scope:second
	
			scope:first = {
				if = {
					limit = {
						this = scope:host
					}
					custom_tooltip = adult_education_tt_positive_tiny
					scope:activity = { activity_special_type_progression_tiny = yes }
				}
				reverse_add_opinion = {
					target = scope:second
					modifier = proud_opinion
					opinion = 10
				}
			}	
		}
	}
}

apa_revelry_hangover = {
	icon = stress
	is_valid = {
		is_current_phase_active = yes
		any_attending_character = {
			NOR = {
				has_character_flag = teacher_1
				has_character_flag = teacher_2
				has_activity_intent = study_hard_intent
				has_trait = diligent
				has_trait = temperate
			}
			drinks_alcohol_trigger = yes
		}
	}

	weight = {
		value = 1
	}

	effect = {
		random_attending_character = {
			limit = {
				NOR = {
					has_character_flag = teacher_1
					has_character_flag = teacher_2
					has_activity_intent = study_hard_intent
					has_trait = diligent
					has_trait = temperate
				}
				drinks_alcohol_trigger = yes
			}
			save_scope_as = first
		}

		add_activity_log_entry = {
			key = apa_revelry_hangover
			tags = { pulse_action }
			character = scope:first
	
			scope:first = {
				add_stress = minor_stress_gain
			}	
		}
	}
}

apa_studied_confucian_classics = {
	icon = learning
	is_valid = {
		is_current_phase_active = yes
		OR = {
			scope:province.faith.religion = religion:confucianism_religion
			scope:province.county.holder.religion = religion:confucianism_religion
		}
		trigger_if = {
			limit = {
				scope:activity = { has_activity_type = activity_adult_education }
			}
			any_attending_character = {
				NOR = {
					has_character_flag = teacher_1
					has_character_flag = teacher_2
				}
			}
		}
	}

	weight = {
		value = 1
	}

	effect = {
		random_attending_character = {
			limit = {
				NOR = {
					has_character_flag = teacher_1
					has_character_flag = teacher_2
				}
			}
			save_scope_as = first
		}

		add_activity_log_entry = {
			key = apa_studied_confucian_classics
			tags = { pulse_action }
			character = scope:first
	
			scope:first = {
				if = {
					limit = { has_trait = confucian_education }
					add_trait_xp = {
						trait = confucian_education
						value = { 1 3 }
					}
				}
				else = {
					add_trait = confucian_education
				}
			}	
		}
	}
}

apa_local_food = {
	icon = social
	is_valid = {
		is_current_phase_active = yes
		any_attending_character = {
			NOR = {
				has_character_flag = teacher_1
				has_character_flag = teacher_2
			}
		}
	}

	weight = {
		value = 1
	}

	effect = {
		random_attending_character = {
			limit = {
				NOR = {
					has_character_flag = teacher_1
					has_character_flag = teacher_2
				}
			}
			save_scope_as = first
		}

		add_activity_log_entry = {
			key = apa_local_food
			tags = { pulse_action }
			character = scope:first
	
			every_attending_character = {
				limit = {
					NOR = {
						this = scope:first
						is_ai = no
					}
				}
				add_opinion = {
					target = scope:first
					modifier = shared_delicacy_opinion
					opinion = 5
				}
			}
		}
	}
}

apa_aced_homework = {
	icon = learning
	is_valid = {
		is_current_phase_active = yes
	}

	weight = {
		value = 1
	}

	effect = {
		scope:host = {
			save_scope_as = first
		}

		add_activity_log_entry = {
			key = apa_aced_homework
			tags = { pulse_action }
			character = scope:first
	
			custom_tooltip = adult_education_tt_positive_tiny
			scope:activity = { activity_special_type_progression_tiny = yes }
		}
	}
}

apa_pangur_ban = {
	icon = learning
	is_valid = {
		is_current_phase_active = yes
		NOT = { scope:host = { has_character_flag = has_written_pangur_ban } }
	}

	weight = {
		value = 1
	}

	effect = {
		scope:host = {
			save_scope_as = first
			add_character_flag = {
				flag = has_written_pangur_ban
				months = 6
			}
		}

		add_activity_log_entry = {
			key = apa_pangur_ban
			tags = { pulse_action }
			character = scope:first
	
			custom_tooltip = adult_education_tt_positive_tiny
			scope:activity = { activity_special_type_progression_tiny = yes }
		}
	}
}
