﻿#################################################
# EFFECT LIST 									#
#################################################
#
# Inspiration Generation Effects
#	grant_inspiration_to_character_effect 			- Creates a new Inspiration and gives it to the scope character. Type of inspiration is weighted based on character skills and personality.
#	grant_new_inspiration_in_character_realm_effect - Selects a random Pool character from the scope character's realm, then runs the above effect on them. Afterwards, move to visit the scope character's court.
#	grant_new_inspiration_in_region_effect			- Selects a random Royal Court in a given $GEOLOGICAL_REGION$. The Court's owner then has the above effect run on them.
# 	grant_new_inspiration_in_world_effect			- Selects a random geological region in the world. The selected region then has the above effect run on it.
#
# Inspired Character Movement Effects
#   inspired_character_travel_to_court_effect			- Moves $INSPIRED_CHARACTER$ to the court of $NEW_HOST$.
#	inspired_character_seek_out_new_royal_court_effect 	- Forces the scope character to look for a new, different Royal Court to visit as a guest. If one is found, uses the above effect to move there.

#################################################
# Inspiration Generation Effects 				#
#################################################

grant_inspiration_to_character_effect = {
	$CHARACTER$ = { 
		if = { 
			limit = { NOT = { exists = inspiration } }
			# More likely to get an certain Inspiration type if we will produce higher quality Artifacts of that type.
			random_list = {
				10 = {
					compare_modifier = {
						value = weapon_inspiration_average_skill_value
						multiplier = 6
					}
					modifier = { #Some cultures are more likely to pick this vocation than others
						add = 5
						culture = {
							has_cultural_tradition = tradition_metal_craftsmanship
						}
					}
					modifier = {
						has_trait = inspirational_blacksmith
						factor = 10
					}
					create_inspiration = weapon_inspiration
				}
				10 = { # =Slightly increased weight due to a low number of Armorers appearing in the world.
					compare_modifier = {
						value = armor_inspiration_average_skill_value
						multiplier = 7.2 # A character with an average of 20 in relevant skills will receive a +120 bonus
					}
					modifier = { #Some cultures are more likely to pick this vocation than others
						add = 5
						culture = {
							has_cultural_tradition = tradition_frugal_armorsmiths
						}
					}
					modifier = {
						has_trait = inspirational_blacksmith
						factor = 10
					}
					create_inspiration = armor_inspiration
				}
				10 = { #Adventurers will on average produce better quality items, handle with care.
					compare_modifier = {
						value = adventure_inspiration_average_skill_value
						multiplier = 9
					}
					modifier = {
						add = 5
						culture = { #Some cultures are more likely to pick this vocation than others
							OR = {
								has_cultural_parameter = more_likely_to_leave_court #Swords for Hire & Caravaneers
								has_cultural_tradition = tradition_chivalry
							}
						}
					}
					modifier = {
						has_trait = adventurer
						factor = 3
					}
					create_inspiration = adventure_inspiration
				}
				12 = { # Significantly increased weight due to the wide variety of artifact types this inspiration can produce (regalia, crown, trinket).
					compare_modifier = {
						value = smith_inspiration_average_skill_value
						multiplier = 15
					}
					modifier = { #Some cultures are more likely to pick this vocation than others
						add = 10
						culture = {
							OR = {
								has_cultural_tradition = tradition_metal_craftsmanship
								has_cultural_tradition = tradition_ancient_miners
							}
						}
					}
					modifier = {
						has_trait = inspirational_goldsmith
						factor = 10
					}
					create_inspiration = smith_inspiration
				}
				10 = {
					compare_modifier = {
						value = book_inspiration_average_skill_value
						multiplier = 6
					}
					modifier = {
						has_court_position = court_poet_court_position
						add = 15
					}
					modifier = {
						culture = { #Some cultures are more likely to pick this vocation than others
							OR = {
								has_cultural_tradition = tradition_language_scholars
								has_cultural_tradition = tradition_philosopher_culture
								has_cultural_tradition = tradition_legalistic
							}
						}
						add = 5
					}
					modifier = {
						has_trait = inspirational_author
						factor = 10
					}
					create_inspiration = book_inspiration
				}
				11 = { # Increased weight due to a low number of Weavers appearing in the world (probably a lack of high-diplomacy courtiers).
					compare_modifier = {
						value = weaver_inspiration_average_skill_value
						multiplier = 8.4
					}
					modifier = {
						culture = { #Some cultures are more likely to pick this vocation than others
							has_cultural_parameter = improved_weaver_inspiration
						}
						add = 10
					}
					modifier = {
						has_trait = inspirational_weaver
						factor = 10
					}
					create_inspiration = weaver_inspiration
				}
				14 = { # Moderately increased weight due to the variety of artifact types this inspiration can produce (throne, sculpture). 
					compare_modifier = {
						value = artisan_inspiration_average_skill_value
						multiplier = 12
					}
					modifier = {
						has_court_position = court_poet_court_position
						add = 5
					}
					modifier = {
						culture = { #Some cultures are more likely to pick this vocation than others
							has_cultural_parameter = improved_artisan_inspiration
						}
						add = 15
					}
					modifier = {
						has_trait = inspirational_artisan
						factor = 10
					}
					create_inspiration = artisan_inspiration
				}
				1 = {
					modifier = {
						add = 30
						has_trait = lifestyle_mystic
					}
					modifier = { #Alchemy arrived to Europe in the 13th century, but existed basically everywhere else before that
						add = -20
						NOT = { has_trait = inspirational_alchemist }
						culture_has_european_heritage_pillar_trigger = yes
						current_date < 1200.01.01
					}
					compare_modifier = {
						value = learning
						multiplier = 2
					}
					modifier = {
						has_trait = inspirational_alchemist
						factor = 10
					}
					create_inspiration = alchemy_inspiration
				}
				5 = {
					compare_modifier = {
						value = weapon_inspiration_average_skill_value
						multiplier = 6
					}
					modifier = { #Some cultures are more likely to pick this vocation than others
						add = 5
						culture = {
							has_cultural_tradition = tradition_longbow_competitions
						}
					}
					create_inspiration = bow_inspiration
				}
			}
		}
	}
}

grant_stewardship_inspiration_to_character_effect = {
	$CHARACTER$ = { 
		if = { 
			limit = { NOT = { exists = inspiration } }
			# More likely to get an certain Inspiration type if we will produce higher quality Artifacts of that type.
			random_list = {
				12 = { # Significantly increased weight due to the wide variety of artifact types this inspiration can produce (regalia, crown, trinket).
					compare_modifier = {
						value = smith_inspiration_average_skill_value
						multiplier = 15
					}
					modifier = { #Some cultures are more likely to pick this vocation than others
						add = 10
						culture = {
							OR = {
								has_cultural_tradition = tradition_metal_craftsmanship
								has_cultural_tradition = tradition_ancient_miners
							}
						}
					}
					create_inspiration = smith_inspiration
				}
				14 = { # Moderately increased weight due to the variety of artifact types this inspiration can produce (throne, sculpture). 
					compare_modifier = {
						value = artisan_inspiration_average_skill_value
						multiplier = 12
					}
					modifier = {
						has_court_position = court_poet_court_position
						add = 5
					}
					modifier = {
						culture = { #Some cultures are more likely to pick this vocation than others
							has_cultural_parameter = improved_artisan_inspiration
						}
						add = 15
					}
					create_inspiration = artisan_inspiration
				}
			}
		}
	}
}

grant_learning_inspiration_to_character_effect = {
	$CHARACTER$ = { 
		if = { 
			limit = { NOT = { exists = inspiration } }
			# More likely to get an certain Inspiration type if we will produce higher quality Artifacts of that type.
			random_list = {
				10 = {
					compare_modifier = {
						value = book_inspiration_average_skill_value
						multiplier = 6
					}
					modifier = {
						has_court_position = court_poet_court_position
						add = 15
					}
					modifier = {
						culture = { #Some cultures are more likely to pick this vocation than others
							OR = {
								has_cultural_tradition = tradition_language_scholars
								has_cultural_tradition = tradition_philosopher_culture
								has_cultural_tradition = tradition_legalistic
							}
						}
						add = 5
					}
					modifier = {
						factor = 0.5
						liege ?= {
							any_equipped_character_artifact = {
								count >= 2
								artifact_slot_type = book
							}
						}
					}
					create_inspiration = book_inspiration
				}
				10 = { # Increased weight due to a low number of Weavers appearing in the world (probably a lack of high-diplomacy courtiers).
					trigger = {
						diplomacy >= 10
					}
					compare_modifier = {
						value = weaver_inspiration_average_skill_value
						multiplier = 8.4
					}
					modifier = {
						culture = { #Some cultures are more likely to pick this vocation than others
							has_cultural_parameter = improved_weaver_inspiration
						}
						add = 10
					}
					modifier = {
						factor = 0.1
						liege ?= {
							any_equipped_character_artifact = {
								count >= 3
								artifact_slot_type = wall_big
							}
						}
					}
					create_inspiration = weaver_inspiration
				}
				1 = {
					modifier = {
						add = 30
						has_trait = lifestyle_mystic
					}
					compare_modifier = {
						value = learning
						multiplier = 2
					}
					modifier = { #Alchemy arrived to Europe in the 13th century, but existed basically everywhere else before that
						factor = 0.1
						culture_has_european_heritage_pillar_trigger = yes
						current_year < 1300
					}
					create_inspiration = alchemy_inspiration
				}
			}
		}
	}
}

grant_martial_inspiration_to_character_effect = {
	$CHARACTER$ = { 
		if = { 
			limit = { NOT = { exists = inspiration } }
			# More likely to get an certain Inspiration type if we will produce higher quality Artifacts of that type.
			random_list = {
				1 = { #Adventurers will on average produce better quality items, handle with care.
					compare_modifier = {
						value = adventure_inspiration_average_skill_value
						multiplier = 9
					}
					modifier = {
						add = 5
						culture = { #Some cultures are more likely to pick this vocation than others
							OR = {
								has_cultural_parameter = more_likely_to_leave_court #Swords for Hire & Caravaneers
								has_cultural_tradition = tradition_chivalry
							}
						}
					}
					create_inspiration = adventure_inspiration
				}
				10 = {
					compare_modifier = {
						value = weapon_inspiration_average_skill_value
						multiplier = 6
					}
					modifier = { #Some cultures are more likely to pick this vocation than others
						add = 5
						culture = {
							has_cultural_tradition = tradition_metal_craftsmanship
						}
					}
					modifier = {
						factor = 0.1
						liege ?= {
							any_equipped_character_artifact = {
								artifact_slot_type = primary_armament
							}
						}
					}
					create_inspiration = weapon_inspiration
				}
				10 = { # =Slightly increased weight due to a low number of Armorers appearing in the world.
					compare_modifier = {
						value = armor_inspiration_average_skill_value
						multiplier = 7.2 # A character with an average of 20 in relevant skills will receive a +120 bonus
					}
					modifier = { #Some cultures are more likely to pick this vocation than others
						add = 5
						culture = {
							has_cultural_tradition = tradition_frugal_armorsmiths
						}
					}
					modifier = {
						factor = 0.1
						liege ?= {
							any_equipped_character_artifact = {
								artifact_slot_type = armor
							}
						}
					}
					create_inspiration = armor_inspiration
				}
				5 = {
					compare_modifier = {
						value = weapon_inspiration_average_skill_value
						multiplier = 6
					}
					modifier = { #Some cultures are more likely to pick this vocation than others
						add = 5
						culture = {
							has_cultural_tradition = tradition_longbow_competitions
						}
					}
					create_inspiration = bow_inspiration
				}
			}
		}
	}
}

grant_inspiration_to_character_no_court_artifacts_effect = {
	save_scope_as = court_owner
	$CHARACTER$ = { 
		if = { 
			limit = { NOT = { exists = inspiration } }
			# More likely to get an certain Inspiration type if we will produce higher quality Artifacts of that type.
			random_list = {
				10 = {
					compare_modifier = {
						value = weapon_inspiration_average_skill_value
						multiplier = {
							value = 5
							#Lower the military inspirations for Advancement Movement
							if = {
								limit = {		
									scope:court_owner = {
										top_participant_group:dynastic_cycle ?= {
											participant_group_type = advancement_movement
										}
									}
								}
								multiply = 0
							}
						}
					}
					modifier = { #Some cultures are more likely to pick this vocation than others
						add = 5
						culture = {
							has_cultural_tradition = tradition_metal_craftsmanship
						}
					}
					modifier = {
						has_trait = inspirational_blacksmith
						factor = 10
					}
					create_inspiration = weapon_inspiration
				}
				10 = {
					compare_modifier = {
						value = armor_inspiration_average_skill_value
						multiplier = {
							value = 5
							#Lower the military inspirations for Advancement Movement
							if = {
								limit = {		
									scope:court_owner = {
										top_participant_group:dynastic_cycle ?= {
											participant_group_type = advancement_movement
										}
									}
								}
								multiply = 0
							}
						}
					}
					modifier = { #Some cultures are more likely to pick this vocation than others
						add = 5
						culture = {
							has_cultural_tradition = tradition_frugal_armorsmiths
						}
					}
					modifier = {
						has_trait = inspirational_blacksmith
						factor = 10
					}
					create_inspiration = armor_inspiration
				}
				5 = {
					compare_modifier = {
						value = smith_inspiration_average_skill_value
						multiplier = 5
					}
					modifier = { #Some cultures are more likely to pick this vocation than others
						add = 10
						culture = {
							OR = {
								has_cultural_tradition = tradition_metal_craftsmanship
								has_cultural_tradition = tradition_ancient_miners
							}
						}
					}
					modifier = {
						has_trait = inspirational_goldsmith
						factor = 10
					}
					create_inspiration = smith_inspiration
				}
				5 = {
					compare_modifier = {
						value = book_inspiration_average_skill_value
						multiplier = 5
					}
					modifier = {
						has_court_position = court_poet_court_position
						add = 15
					}
					modifier = {
						culture = { #Some cultures are more likely to pick this vocation than others
							OR = {
								has_cultural_tradition = tradition_language_scholars
								has_cultural_tradition = tradition_philosopher_culture
								has_cultural_tradition = tradition_legalistic
							}
						}
						add = 5
					}
					modifier = {
						has_trait = inspirational_author
						factor = 10
					}
					create_inspiration = book_inspiration
				}
				1 = {
					modifier = {
						add = 30
						has_trait = lifestyle_mystic
					}
					modifier = { #Alchemy arrived to Europe in the 13th century, but existed basically everywhere else before that
						add = -20
						NOT = { has_trait = inspirational_alchemist }
						culture_has_european_heritage_pillar_trigger = yes
						current_date < 1200.01.01
					}
					compare_modifier = {
						value = learning
						multiplier = 2
					}
					modifier = {
						has_trait = inspirational_alchemist
						factor = 10
					}
					create_inspiration = alchemy_inspiration
				}
				5 = {
					compare_modifier = {
						value = weapon_inspiration_average_skill_value
						multiplier = {
							value = 6
							#Lower the military inspirations for Advancement Movement
							if = {
								limit = {		
									scope:court_owner = {
										top_participant_group:dynastic_cycle ?= {
											participant_group_type = advancement_movement
										}
									}
								}
								multiply = 0
							}
						}
					}
					modifier = { #Some cultures are more likely to pick this vocation than others
						add = 5
						culture = {
							has_cultural_tradition = tradition_longbow_competitions
						}
					}
					create_inspiration = bow_inspiration
				}
			}
		}
	}
}

grant_new_inspiration_in_character_realm_effect = {
	save_scope_as = royal_court_owner
	every_sub_realm_barony = {
		title_province = {
			every_pool_character = {
				province = this
				limit = {
					ep1_is_valid_character_for_inspiration_trigger = yes
				}
				add_to_list = potential_inspired_people
			}
		}
	}

	random_in_list = {
		list = potential_inspired_people
		weight = {
			base = 1

			modifier = { #Poets are more likely to become inspired
				add = 40
				has_trait = lifestyle_poet
			}

			modifier = { 
				add = 40
				has_inspirational_lifestyle_trait_trigger = yes
			}

			# More learned characters have a greater pool to draw from for their inspirations.
			compare_modifier = {
				value = learning
				multiplier = 5
			}

			# Older characters are more likely to be inspired from their life's experience.
			compare_modifier = {
				value = age
			}

			# We don't want character dropping dead from old age, injuries, or disease right after they begin work on a project!
			compare_modifier = {
				value = health
				multiplier = 20
			}

			# 'Ambitious' characters are more likely to get an inspiration/seek patronage
			ai_value_modifier = {
				ai_greed = 0.25
				ai_boldness = 0.25
				ai_sociability = 0.10
				ai_rationality = 0.10
			}
		}
		save_scope_as = inspired_person
	}

	# If we were unable to find a valid pool character, create one.
	if = {
		limit = {
			NOT = { exists = scope:inspired_person }
		}
		create_character = {
			template = inspired_template
			location = scope:royal_court_owner.capital_province
			faith = scope:royal_court_owner.faith
			culture = scope:royal_court_owner.culture
			gender_female_chance = 50 
			save_scope_as = inspired_person
		}
	}
	# Clear the list in case this effect gets re-used in the same scope.
	every_in_list = {
		list = potential_inspired_people
		remove_from_list = potential_inspired_people
	}

	scope:inspired_person = {
		grant_inspiration_to_character_effect = { CHARACTER = this }
		# Travel to the new host's court.
		inspired_character_travel_to_court_effect = {
			INSPIRED_CHARACTER = scope:inspired_person
			NEW_HOST = scope:royal_court_owner
		}
	}
	
}

#Debug Effects

grant_inspiration_weight_counter_effect = {
	random_list = {
		10 = {
			compare_modifier = {
				value = weapon_inspiration_average_skill_value
				multiplier = 6
			}
			modifier = {
				has_trait = inspirational_blacksmith
				factor = 10
			}
			desc = blacksmith_added
			if = {
				limit = { NOT = { has_variable = blacksmith_inspiration_count } }
				set_variable = {
					name = blacksmith_inspiration_count
					value = 1
				}
			}
			else = {
				change_variable = {
					name = blacksmith_inspiration_count
					add = 1
				}
			}
		}
		10 = { # =Slightly increased weight due to a low number of Armorers appearing in the world.
			compare_modifier = {
				value = armor_inspiration_average_skill_value
				multiplier = 7.2 # A character with an average of 20 in relevant skills will receive a +120 bonus
			}
			modifier = {
				has_trait = inspirational_blacksmith
				factor = 10
			}
			desc = blacksmith_added
			if = {
				limit = { NOT = { has_variable = blacksmith_inspiration_count } }
				set_variable = {
					name = blacksmith_inspiration_count
					value = 1
				}
			}
			else = {
				change_variable = {
					name = blacksmith_inspiration_count
					add = 1
				}
			}
		}
		10 = { #Adventurers will on average produce better quality items, handle with care.
			compare_modifier = {
				value = adventure_inspiration_average_skill_value
				multiplier = 9
			}
			modifier = {
				has_trait = adventurer
				factor = 3
			}
			desc = adventure_added
			if = {
				limit = { NOT = { has_variable = adventure_inspiration_count } }
				set_variable = {
					name = adventure_inspiration_count
					value = 1
				}
			}
			else = {
				change_variable = {
					name = adventure_inspiration_count
					add = 1
				}
			}
		}
		10 = { # Significantly increased weight due to the wide variety of artifact types this inspiration can produce (regalia, crown, trinket).
			compare_modifier = {
				value = smith_inspiration_average_skill_value
				multiplier = 20
			}
			modifier = {
				has_trait = inspirational_goldsmith
				factor = 10
			}
			desc = goldsmith_added
			if = {
				limit = { NOT = { has_variable = goldsmith_inspiration_count } }
				set_variable = {
					name = goldsmith_inspiration_count
					value = 1
				}
			}
			else = {
				change_variable = {
					name = goldsmith_inspiration_count
					add = 1
				}
			}
		}
		10 = {
			compare_modifier = {
				value = book_inspiration_average_skill_value
				multiplier = 6
			}
			modifier = {
				has_court_position = court_poet_court_position
				add = 15
			}
			modifier = {
				has_trait = inspirational_author
				factor = 10
			}
			desc = book_added
			if = {
				limit = { NOT = { has_variable = author_inspiration_count } }
				set_variable = {
					name = author_inspiration_count
					value = 1
				}
			}
			else = {
				change_variable = {
					name = author_inspiration_count
					add = 1
				}
			}
		}
		14 = { # Increased weight due to a low number of Weavers appearing in the world (probably a lack of high-diplomacy courtiers).
			compare_modifier = {
				value = weaver_inspiration_average_skill_value
				multiplier = 8.4
			}
			modifier = {
				has_court_position = court_poet_court_position
				add = 10
			}
			modifier = {
				has_trait = inspirational_weaver
				factor = 10
			}
			desc = weaver_added
			if = {
				limit = { NOT = { has_variable = weaver_inspiration_count } }
				set_variable = {
					name = weaver_inspiration_count
					value = 1
				}
			}
			else = {
				change_variable = {
					name = weaver_inspiration_count
					add = 1
				}
			}
		}
		14 = { # Moderately increased weight due to the variety of artifact types this inspiration can produce (throne, sculpture). 
			compare_modifier = {
				value = artisan_inspiration_average_skill_value
				multiplier = 12
			}
			modifier = {
				has_court_position = court_poet_court_position
				add = 5
			}
			modifier = {
				has_trait = inspirational_artisan
				factor = 10
			}
			desc = artisan_added
			if = {
				limit = { NOT = { has_variable = artisan_inspiration_count } }
				set_variable = {
					name = artisan_inspiration_count
					value = 1
				}
			}
			else = {
				change_variable = {
					name = artisan_inspiration_count
					add = 1
				}
			}
		}
		1 = {
			modifier = {
				add = 30
				has_trait = lifestyle_mystic
			}
			modifier = { #Alchemy arrived to Europe in the 13th century, but existed basically everywhere else before that
				add = -20
				NOT = { has_trait = inspirational_alchemist }
				culture_has_european_heritage_pillar_trigger = yes
				current_date < 1200.01.01
			}
			compare_modifier = {
				value = learning
				multiplier = 2
			}
			modifier = {
				has_trait = inspirational_alchemist
				factor = 10
			}
			desc = alchemy_added
			if = {
				limit = { NOT = { has_variable = alchemist_inspiration_count } }
				set_variable = {
					name = alchemist_inspiration_count
					value = 1
				}
			}
			else = {
				change_variable = {
					name = alchemist_inspiration_count
					add = 1
				}
			}
		}
	}
}