﻿join_activity_interaction = {
	category = interaction_category_diplomacy
	greeting = positive
	notification_text = join_activity_interaction_flavor
	reply_item_key = join_activity_reply_item_key
	icon = activity_feast
	common_interaction = yes
	desc = join_activity_interaction_desc

	ai_maybe = yes
	can_send_despite_rejection = yes
	
	is_highlighted = {
		always = yes
	}

	is_shown = {
		exists = scope:recipient.involved_activity
		scope:recipient = scope:recipient.involved_activity.activity_host
		scope:recipient.involved_activity = {
		    is_current_phase_active = no
			OR = {
				has_activity_type = activity_tournament
				has_activity_type = activity_wedding
				has_activity_type = activity_feast
				has_activity_type = activity_hunt
				has_activity_type = activity_chariot_race
			}
		}
		scope:actor = { is_ruler = no }
	}
	
	on_accept = {
		scope:recipient = {
			send_interface_message = {
				type = event_activity_good_with_text
				title = join_activity_accepted
				desc = join_activity_accepted_desc
				left_icon = scope:recipient
				right_icon = scope:actor
				scope:actor = {
					add_to_activity = scope:recipient.involved_activity
				}
			}
		}
	}

	on_decline = {
		scope:actor = {
			send_interface_message = {
				type = event_activity_bad_with_text
				title = join_activity_refused
				desc = join_activity_refused_desc
				left_icon = scope:actor
				right_icon = scope:recipient
				scope:recipient = {
					decline_activity_invite = scope:recipient.involved_activity
				}
			}
		}
	}

	ai_accept = {
		base = 20
         
		 opinion_modifier = { # Opinion Factor
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 0.2
			desc = AI_OPINION_REASON
		 }
		 
		# EDUCATION MODIFIERS #

			modifier = {
				scope:actor = { has_trait = education_martial_prowess_1 } 
				add = 2
				desc = ACTIVITY_MARTIAL_PROWESS_REASON
			}
			modifier = {
				scope:actor = { has_trait = education_martial_prowess_2 }
				add = 5
				desc = ACTIVITY_MARTIAL_PROWESS_REASON
			}
			modifier = {
				scope:actor = { has_trait =  education_martial_prowess_3 }
				add = 8
				desc = ACTIVITY_MARTIAL_PROWESS_REASON
			}
			modifier = {
				scope:actor = { has_trait =  education_martial_prowess_4 }
				add = 10
				desc = ACTIVITY_MARTIAL_PROWESS_REASON
			}
			modifier = {
				scope:actor = { has_trait =  education_martial_1 }
				add = 2
				desc = ACTIVITY_MARTIAL_EDUCATION_REASON
			}
			modifier = {
				scope:actor = { has_trait =  education_martial_2 }
				add = 5
				desc = ACTIVITY_MARTIAL_EDUCATION_REASON
			}
			modifier = {
				scope:actor = { has_trait =  education_martial_3 }
				add = 8
				desc = ACTIVITY_MARTIAL_EDUCATION_REASON
			}
			modifier = {
				scope:actor = { has_trait =  education_martial_4 }
				add = 10
				desc = ACTIVITY_MARTIAL_EDUCATION_REASON
			}
			modifier = {
				scope:actor = { has_trait =  education_martial_5 }
				add = 15
				desc = ACTIVITY_MARTIAL_EDUCATION_REASON
			}

			# OTHER MODIFIERS #
			modifier = {
				scope:actor.culture = { has_cultural_parameter = cannot_hunt }
				add = -100
				desc = ACTIVITY_GUEST_CANNOT_HUNT_REASON
			}
			modifier = {
				scope:recipient = { in_activity_type ?= flag:hunt_type_falconry }
				scope:actor.culture = { has_cultural_tradition = tradition_ep2_avid_falconers }
				add = 25
				desc = ACTIVITY_GUEST_FALCONERS_REASON
			}
			modifier = {
				scope:actor = { has_court_position = master_of_hunt_court_position }
				add = 50
				desc = ACTIVITY_GUEST_MASTER_OF_HUNT_REASON
			}
			modifier = {
				scope:actor = { is_knight = yes }
				add = 25
				desc = ACTIVITY_GUEST_KNIGHT_REASON
			}
			modifier = {
				scope:actor = { is_clergy = yes }
				add = -150
				desc = ACTIVITY_GUEST_CLERGY_REASON
			}
			modifier = {
			    scope:actor = {
				is_clergy = no
				NOR = {
					scope:recipient = { in_activity_type ?= flag:hunt_type_falconry }
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = scope:host }
				}}
				add = -150
				desc = ACTIVITY_GUEST_GENDER_REASON
			}
			
			modifier = {
				add = 100
				scope:actor = {
				is_courtier_of = scope:host
				scope:host = {
					is_landless_adventurer = yes
				}}
				desc = ACTIVITY_GUEST_ADVENTURER_REASON
			}
			modifier = {	
				exists = scope:host.var:hunt_murder_accident_attempt
				add = {
					value = 0
					add = scope:host.var:hunt_murder_accident_attempt
					multiply = -10
				}
				desc = ACTIVITY_GUEST_ACCIDENTAL_HUNT_DEATH_REASON
			}
			modifier = {
				scope:actor = { dynasty = { has_dynasty_modifier = lowborn_modifier } }
				add = {
					add = -15
				}
				desc = join_activity_lowborn_reason
			}
		
	}
}
