﻿
PE_default_ongoing_events_days_min = 150
PE_default_ongoing_events_days_max = 350


PE_menagerie_level_high_value = 20
PE_menagerie_level_medium_value = 15
PE_menagerie_level_low_value = 0

PE_menagerie_level_increase_high_value = 3
PE_menagerie_level_increase_medium_value = 2
PE_menagerie_level_increase_low_value = 1

PE_menagerie_has_ok_animal_variety_value = 1
PE_menagerie_has_good_animal_variety_value = 3
PE_menagerie_has_great_animal_variety_value = 5

PE_menagerie_has_status_animals_value = 5
PE_menagerie_has_status_animal_value = 3

PE_menagerie_has_ok_animal_health_value = 0
PE_menagerie_has_great_animal_health_value = 1
PE_menagerie_has_bad_animal_health_value = -1

PE_menagerie_has_good_animal_behavior_value = 1
PE_menagerie_has_bad_animal_behavior_value = -1
PE_menagerie_has_mid_animal_behavior_value = 0

PE_menagerie_level_employs_keeper_value = 5

PE_menagerie_level_animal_variety_value = {
	value = {
		if = {
			limit = {
				menagerie_has_great_animal_variety_trigger = yes
			}
			add = PE_menagerie_has_great_animal_variety_value
		}
		else_if = {
			limit = {
				menagerie_has_good_animal_variety_trigger = yes
			}
			add = PE_menagerie_has_good_animal_variety_value
		}
		else_if = {
			limit = {
				menagerie_has_ok_animal_variety_trigger = yes
			}
			add = PE_menagerie_has_ok_animal_variety_value
		}
	}
}

PE_menagerie_level_number_of_animals_value = {
	value = {
		if = {
			limit = { any_owned_story = { is_pet_story_trigger = yes } }
			every_owned_story = {
				limit = { is_pet_story_trigger = yes }
				add = 0.5
			}
		}
	}
	max = 5
	round = yes
}

PE_menagerie_level_status_animals_value = {
	value = {
		if = {
			limit = {
				menagerie_has_status_animals_trigger = yes
			}
			add = PE_menagerie_has_status_animals_value
		}
		else_if = {
			limit = {
				menagerie_has_status_animal_trigger = yes
			}
			add = PE_menagerie_has_status_animal_value
		}
	}
}

PE_menagerie_level_animal_health_value = {
	value = {
		if = {
			limit = {
				menagerie_has_great_animal_health_trigger = yes
			}
			add = PE_menagerie_has_great_animal_health_value
		}
		else_if = {
			limit = {
				menagerie_has_ok_animal_health_trigger = yes
			}
			add = PE_menagerie_has_ok_animal_health_value
		}
		else_if = {
			limit = {
				menagerie_has_bad_animal_health_trigger = yes
			}
			add = PE_menagerie_has_bad_animal_health_value
		}
	}
}

PE_menagerie_level_animal_behavior_value = {
	value = {
		if = {
			limit = {
				menagerie_has_good_animal_behavior_trigger = yes
			}
			add = PE_menagerie_has_good_animal_behavior_value
		}
		else_if = {
			limit = {
				menagerie_has_bad_animal_behavior_trigger = yes
			}
			add = PE_menagerie_has_bad_animal_behavior_value
		}
		else = {
			add = PE_menagerie_has_mid_animal_behavior_value
		}
	}
}

PE_menagerie_level_until_medium_level_up = {
	value = {
		add = PE_menagerie_level_medium_value
		subtract = var:PE_menagerie_level
	}
}
PE_menagerie_level_until_high_level_up = {
	value = {
		add = PE_menagerie_level_high_value
		subtract = var:PE_menagerie_level
	}
}

#PE_menagerie_level_until_low_level_down = {
#	value = {
#		add = var:PE_menagerie_level
#		subtract = PE_menagerie_level_medium_value
#		subtract = 1
#	}
#}
#PE_menagerie_level_until_medium_level_down = {
#	value = {
#		add = var:PE_menagerie_level
#		subtract = PE_menagerie_level_high_value
#		subtract = 1
#	}
#}



pet_opinion_increase_minor_value = 1
pet_opinion_increase_medium_value = 2
pet_opinion_increase_major_value = 4

pet_gender_female_chance = {
	# this is to account for the conversion of the cat/dog/warhorse story since the gender has already been set there
	if = {
		limit = {
			scope:story_owner.var:pet_gender ?= flag:male
		}
		add =  0
	}
	else_if = {
		limit = {
			scope:story_owner.var:pet_gender ?= flag:female
		}
		add =  100
	}
	else = {
		add = 50
	}
}

pet_pregnant_min_age_value = 2

pet_opinion_decrease_minor_value = {
	value = pet_opinion_increase_minor_value
	multiply = -1
}
pet_opinion_decrease_medium_value = {
	value = pet_opinion_increase_medium_value
	multiply = -1
}
pet_opinion_decrease_major_value = {
	value = pet_opinion_increase_major_value
	multiply = -1
}

very_bad_pet_opinion = -8
bad_pet_opinion = -4
neutral_pet_opinion = 0
good_pet_opinion = 4
very_good_pet_opinion = 8


pet_prowess_story_scope_diff = {
	value = {
		if = {
			limit = {
				pet_prowess_value > scope:story.pet_prowess_value
			}
			add = pet_prowess_value
			subtract = scope:story.pet_prowess_value
		}
		else_if = {
			limit = {
				scope:story.pet_prowess_value > pet_prowess_value
			}
			add = scope:story.pet_prowess_value
			subtract = pet_prowess_value
		}
		else = {
			add = 0
		}
	}
}

pet_prowess_value = {
	value = {
		#Personality
		if = {
			limit = { var:personality ?= flag:aggressive }
			add = 1
		}
		if = {
			limit = {
				OR = {
					var:personality = flag:friendly
					var:personality = flag:lazy
					var:personality = flag:spoiled
				}
			}
			add = -1
		}

		#Pet type
		if = {
			limit = { story_type = PE_story_cycle_cat }
			add = 6
		}
		else_if = {
			limit = { story_type = PE_story_cycle_dog }
			add = 6
		}
		else_if = {
			limit = { story_type = PE_story_cycle_badger }
			add = 7
		}
		else_if = {
			limit = { story_type = PE_story_cycle_bear }
			add = 9
		}
		else_if = {
			limit = { story_type = PE_story_cycle_falcon }
			add = 4
		}
		else_if = {
			limit = { story_type = PE_story_cycle_ferret }
			add = 3
		}
		else_if = {
			limit = { story_type = PE_story_cycle_fox }
			add = 7
		}
		else_if = {
			limit = { story_type = PE_story_cycle_hedgehog }
			add = 2
		}
		else_if = {
			limit = { story_type = PE_story_cycle_lion }
			add = 8
		}
		else_if = {
			limit = { story_type = PE_story_cycle_monkey }
			add = 7
		}
		else_if = {
			limit = { story_type = PE_story_cycle_nightingale }
			add = 1
		}
		else_if = {
			limit = { story_type = PE_story_cycle_parrot }
			add = 2
		}
		else_if = {
			limit = { story_type = PE_story_cycle_rabbit }
			add = 1
		}
		else_if = {
			limit = { story_type = PE_story_cycle_squirrel }
			add = 2
		}
		else_if = {
			limit = { story_type = PE_story_cycle_tiger }
			add = 8
		}
		else_if = {
			limit = { story_type = PE_story_cycle_weasel }
			add = 3
		}
		else_if = {
			limit = { story_type = PE_story_cycle_elephant }
			add = 10
		}
		else_if = {
			limit = { story_type = PE_story_cycle_hawk }
			add = 5
		}
		else_if = {
			limit = { story_type = PE_story_cycle_raven }
			add = 4
		}
		else_if = {
			limit = { story_type = PE_story_cycle_horse }
			add = 8
		}
	}
}

sell_pet_price_value = {
	#value = root.minor_gold_value
	add = {
		add = root.minor_gold_value
		max = 20
	}
	if = {
		limit = {
			root.var:selected_story_scope = { pet_is_fancy_trigger = yes }
		}
		multiply = 1.5
		ceiling = yes
	}
	if = {
		limit = {
			root.var:selected_story_scope = { pet_is_common_trigger = yes }
		}
		multiply = 0.5
		ceiling = yes
	}
}

gift_pet_opinion_value = {
	value = 1
	add = {
		if = {
			limit = {
				root.diplomacy > 0
			}
			add = {
				value = root.diplomacy
				multiply = 1.2
			}
		}
		if = {
			limit = {
				scope:recipient.ai_greed > 0
			}
			add = {
				value = scope:recipient.ai_greed
				multiply = 0.2
			}
		}
		if = {
			limit = {
				scope:recipient.liege = root
			}
			divide = 1.25
		}
		if = {
			limit = {
				scope:recipient = root.faith.religious_head
			}
			divide = 3
		}
		max = 20
	}
	if = {
		limit = {
			root = {
				tier_difference = {
					target = scope:recipient
					value = -1
				}
			}
		}
		multiply = 0.4
	}
	else_if = {
		limit = {
			root = {
				tier_difference = {
					target = scope:recipient
					value = -2
				}
			}
		}
		multiply = 0.3
	}
	if = {
		limit = {
			root = {
				tier_difference = {
					target = scope:recipient
					value = 1
				}
			}
		}
		multiply = 1.1
	}
	else_if = {
		limit = {
			root = {
				tier_difference = {
					target = scope:recipient
					value = 2
				}
			}
		}
		multiply = 1.2
	}
	if = {
		limit = {
			root.var:selected_story_scope = { pet_is_fancy_trigger = yes }
		}
		multiply = 1.1
	}
	if = {
		limit = {
			root.var:selected_story_scope = { pet_is_common_trigger = yes }
		}
		multiply = 0.4
	}
	if = {
		limit = {
			root.culture = { has_cultural_parameter = more_gift_opinion }
		}
		multiply = 1.2
	}
	if = {
		limit = {
			root = { has_perk = thoughtful_perk }
		}
		multiply = 1.5
	}
	if = {
		limit = {
			root.var:selected_story_type = flag:cat
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_cat } }
		}
		multiply = 0.5
	}
	if = {
		limit = {
			root.var:selected_story_type = flag:dog
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_dog } }
		}
		multiply = 0.5
	}
	if = {
		limit = {
			root.var:selected_story_type = flag:badger
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_badger } }
		}
		multiply = 0.5
	}
	if = {
		limit = {
			root.var:selected_story_type = flag:bear
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_bear } }
		}
		multiply = 0.5
	}
	if = {
		limit = {
			root.var:selected_story_type = flag:falcon
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_falcon } }
		}
		multiply = 0.5
	}
	if = {
		limit = {
			root.var:selected_story_type = flag:ferret
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_ferret } }
		}
		multiply = 0.5
	}
	if = {
		limit = {
			root.var:selected_story_type = flag:fox
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_fox } }
		}
		multiply = 0.5
	}
	if = {
		limit = {
			root.var:selected_story_type = flag:hedgehog
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_hedgehog } }
		}
		multiply = 0.5
	}
	if = {
		limit = {
			root.var:selected_story_type = flag:lion
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_lion } }
		}
		multiply = 0.5
	}
	if = {
		limit = {
			root.var:selected_story_type = flag:monkey
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_monkey } }
		}
		multiply = 0.5
	}
	if = {
		limit = {
			root.var:selected_story_type = flag:nightingale
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_nightingale } }
		}
		multiply = 0.5
	}
	if = {
		limit = {
			root.var:selected_story_type = flag:parrot
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_parrot } }
		}
		multiply = 0.5
	}
	if = {
		limit = {
			root.var:selected_story_type = flag:rabbit
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_rabbit } }
		}
		multiply = 0.5
	}
	if = {
		limit = {
			root.var:selected_story_type = flag:squirrel
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_squirrel } }
		}
		multiply = 0.5
	}
	if = {
		limit = {
			root.var:selected_story_type = flag:tiger
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_tiger } }
		}
		multiply = 0.5
	}
	if = {
		limit = {
			root.var:selected_story_type = flag:weasel
			scope:recipient = { any_owned_story = { story_type = PE_story_cycle_weasel } }
		}
		multiply = 0.5
	}
}





###########
# AGE
###########

pet_max_age_value = {
	value = {
		if = {
			limit = { scope:story = { story_type = PE_story_cycle_cat } }
			add = cat_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_dog } }
			add = dog_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_badger } }
			add = badger_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_bear } }
			add = bear_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_falcon } }
			add = falcon_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_ferret } }
			add = ferret_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_fox } }
			add = fox_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_hedgehog } }
			add = hedgehog_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_lion } }
			add = lion_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_monkey } }
			add = monkey_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_nightingale } }
			add = nightingale_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_parrot } }
			add = parrot_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_rabbit } }
			add = rabbit_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_squirrel } }
			add = squirrel_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_tiger } }
			add = tiger_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_weasel } }
			add = weasel_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_elephant } }
			add = elephant_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_hawk } }
			add = hawk_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_raven } }
			add = raven_max_age_value
		}
		else_if = {
			limit = { scope:story = { story_type = PE_story_cycle_horse } }
			add = horse_max_age_value
		}
	}
}

cat_max_age_value = {
	#value = 18
	value = 22
}
dog_max_age_value = {
	#value = 15
	value = 20
}
badger_max_age_value = {
	#value = 15
	value = 20
}
bear_max_age_value = {
	#value = 25
	value = 30
}
falcon_max_age_value = {
	#value = 15
	value = 20
}
ferret_max_age_value = {
	#value = 10
	value = 15
}
fox_max_age_value = {
	#value = 10
	value = 15
}
hedgehog_max_age_value = {
	#value = 10
	value = 15
}
lion_max_age_value = {
	#value = 20
	value = 25
}
monkey_max_age_value = {
	#value = 30
	value = 35
}
nightingale_max_age_value = {
	#value = 10
	value = 15
}
parrot_max_age_value = {
	value = 40
}
rabbit_max_age_value = {
	#value = 12
	value = 17
}
squirrel_max_age_value = {
	#value = 10
	value = 15
}
tiger_max_age_value = {
	#value = 20
	value = 25
}
weasel_max_age_value = {
	#value = 10
	value = 15
}
elephant_max_age_value = {
	value = 60
}
hawk_max_age_value = {
	#value = 20
	value = 25
}
raven_max_age_value = {
	value = 40
}
horse_max_age_value = {
	#value = 30
	value = 35
}


pet_dif_to_max_age_value = {
	value = {
		if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_cat }
				scope:story.cat_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.cat_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_dog }
				scope:story.dog_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.dog_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_badger }
				scope:story.badger_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.badger_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_bear }
				scope:story.bear_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.bear_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_falcon }
				scope:story.falcon_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.falcon_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_ferret }
				scope:story.ferret_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.ferret_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_fox }
				scope:story.fox_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.fox_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_hedgehog }
				scope:story.hedgehog_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.hedgehog_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_lion }
				scope:story.lion_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.lion_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_monkey }
				scope:story.monkey_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.monkey_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_nightingale }
				scope:story.nightingale_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.nightingale_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_parrot }
				scope:story.parrot_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.parrot_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_rabbit }
				scope:story.rabbit_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.rabbit_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_squirrel }
				scope:story.squirrel_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.squirrel_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_tiger }
				scope:story.tiger_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.tiger_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_weasel }
				scope:story.weasel_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.weasel_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_elephant }
				scope:story.elephant_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.elephant_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_hawk }
				scope:story.hawk_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.hawk_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_raven }
				scope:story.raven_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.raven_dif_to_max_age_value }
		}
		else_if = {
			limit = {
				scope:story = { story_type = PE_story_cycle_horse }
				scope:story.horse_dif_to_max_age_value >= 0.3
			}
			add = { value = scope:story.horse_dif_to_max_age_value }
		}
	}
}

cat_dif_to_max_age_value = {
	value = var:age_variable
	divide = cat_max_age_value
}
dog_dif_to_max_age_value = {
	value = var:age_variable
	divide = dog_max_age_value
}
badger_dif_to_max_age_value = {
	value = var:age_variable
	divide = badger_max_age_value
}
bear_dif_to_max_age_value = {
	value = var:age_variable
	divide = bear_max_age_value
}
falcon_dif_to_max_age_value = {
	value = var:age_variable
	divide = falcon_max_age_value
}
ferret_dif_to_max_age_value = {
	value = var:age_variable
	divide = ferret_max_age_value
}
fox_dif_to_max_age_value = {
	value = var:age_variable
	divide = fox_max_age_value
}
hedgehog_dif_to_max_age_value = {
	value = var:age_variable
	divide = hedgehog_max_age_value
}
lion_dif_to_max_age_value = {
	value = var:age_variable
	divide = lion_max_age_value
}
monkey_dif_to_max_age_value = {
	value = var:age_variable
	divide = monkey_max_age_value
}
nightingale_dif_to_max_age_value = {
	value = var:age_variable
	divide = nightingale_max_age_value
}
parrot_dif_to_max_age_value = {
	value = var:age_variable
	divide = parrot_max_age_value
}
rabbit_dif_to_max_age_value = {
	value = var:age_variable
	divide = rabbit_max_age_value
}
squirrel_dif_to_max_age_value = {
	value = var:age_variable
	divide = squirrel_max_age_value
}
tiger_dif_to_max_age_value = {
	value = var:age_variable
	divide = tiger_max_age_value
}
weasel_dif_to_max_age_value = {
	value = var:age_variable
	divide = weasel_max_age_value
}
elephant_dif_to_max_age_value = {
	value = var:age_variable
	divide = elephant_max_age_value
}
hawk_dif_to_max_age_value = {
	value = var:age_variable
	divide = hawk_max_age_value
}
raven_dif_to_max_age_value = {
	value = var:age_variable
	divide = raven_max_age_value
}
horse_dif_to_max_age_value = {
	value = var:age_variable
	divide = horse_max_age_value
}