﻿namespace = fund_inspiration

# Adventurer fights a bandit
# Adventurer travels through beast-infested terrain

# Adventurer fights a bandit
fund_inspiration.9000 = {
	type = character_event
	title = fund_inspiration.9000.t
	desc = fund_inspiration.9000.desc
	theme = war

	left_portrait = {
		character = scope:adventurer
		animation = worry
	}
	
	right_portrait = {
		character = scope:bandit
		animation = throne_room_one_handed_passive_1 
	}
	
	override_background = {
		reference = wilderness_scope
	}
	
	cooldown = { years = 5 }

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = {
			exists = var:adventure_destination
			exists = var:adventure_type
			NOR = {
				has_character_flag = fund_adventure_inspiration_event_cooldown
			}
			exists = location
			any_pool_character = {
				province = scope:inspiration_owner.location
				is_available_ai_adult = yes
			}
		}
	}

	immediate = {
		scope:inspiration_owner = {
			save_scope_as = adventurer
			location.barony.title_province = { save_scope_as = background_wilderness_scope }
			random_pool_character = {
				province = location.barony.title_province
				limit = {
					is_available_ai_adult = yes
				}
				weight = {
					base = 10
					modifier = {
						can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = THIS }
						add = 100
					}
				}
				save_scope_as = bandit
			}
		}
	}
	option = {
		name = fund_inspiration.9000.a
		
		scope:adventurer = {
			duel = {
				skill = intrigue
				target = scope:bandit
				2 = {
					desc = fund_inspiration.9000.a.critical_success
					compare_modifier = {
						value = scope:duel_value
					}
					root = {
						send_interface_toast = {
							title = fund_inspiration.9000.a.critical_success
							left_icon = scope:adventurer
							scope:inspiration = { change_inspiration_progress = 2 }
							scope:bandit = {
								pay_short_term_gold = {
									target = root
									gold = medium_gold_value
								}
							}
							hidden_effect = { # The adventurer also gains some gold!
								scope:bandit = {
									pay_short_term_gold = {
										target = scope:adventurer
										gold = medium_gold_value
									}
								}
							}
						}
					}
				}
				8 = {
					desc = fund_inspiration.9000.a.success
					compare_modifier = {
						value = scope:duel_value
					}
					root = {
						send_interface_toast = {
							title = fund_inspiration.9000.a.success
							left_icon = scope:adventurer
							scope:inspiration = { change_inspiration_progress = 1 }
						}
					}
				}
				8 = {
					desc = fund_inspiration.9000.a.failure
					compare_modifier = {
						value = scope:duel_value
						multiplier = -1
					}
					root = {
						send_interface_toast = {
							title = fund_inspiration.9000.a.failure
							left_icon = scope:adventurer
							scope:adventurer = {
								increase_wounds_effect = { REASON = fight }
							}
							scope:inspiration = { change_inspiration_progress = -2 }
						}
					}
				}
			}
		}
		
		ai_chance = {
			base = 4
			modifier = {
				add = scope:adventurer.intrigue
			}
			modifier = {
				add = {
					value = scope:bandit.intrigue
					multiply = -1
				}
			}
		}
	}
	option = {
		name = fund_inspiration.9000.b
		
		scope:adventurer = {
			duel = {
				skill = prowess
				target = scope:bandit
				1 = {
					desc = fund_inspiration.9000.b.critical_success
					compare_modifier = {
						value = scope:duel_value
					}
					root = {
						send_interface_toast = {
							title = fund_inspiration.9000.b.critical_success
							left_icon = scope:adventurer
							scope:adventurer = {
								if = {
									limit = {
										NOR = {
											has_trait = compassionate
											ai_compassion >= high_positive_ai_value
										}
									}
									hidden_effect = {
										scope:bandit = {
											death = {
												death_reason = death_duel
												killer = scope:adventurer
											}
										}
									}
									custom_tooltip = fund_inspiration.9000.b.boil_skull
									scope:inspiration_owner = {
										change_artifact_quality_effect = { AMOUNT = 4 }
									}
									root = {
										hidden_effect_new_object = {
											create_artifact_pedestal_human_skull_effect = {
												OWNER = root
												CREATOR = scope:adventurer
												DESKULLED = scope:bandit
											}
											scope:newly_created_artifact = {
												set_artifact_description = artifact_bandit_skull
											}
										}
									}
								}
								else = {
									scope:bandit = {
										death = {
											death_reason = death_duel
											killer = scope:adventurer
										}
										scope:inspiration_owner = {
											change_artifact_quality_effect = { AMOUNT = 4 }
										}
										scope:inspiration = { change_inspiration_progress = 1 }
									}
								}
							}
						}
					}
				}
				11 = {
					desc = fund_inspiration.9000.b.success
					compare_modifier = {
						value = scope:duel_value
					}
					root = {
						send_interface_toast = {
							title = fund_inspiration.9000.b.success
							left_icon = scope:adventurer
							scope:adventurer = {
								scope:bandit = {
									increase_wounds_effect = { REASON = fight }
								}
								scope:inspiration_owner = {
									change_artifact_quality_effect = { AMOUNT = 2 }
								}
							}
						}
					}
				}
				8 = {
					desc = fund_inspiration.9000.b.failure
					compare_modifier = {
						value = scope:duel_value
						multiplier = -1
					}
					root = {
						send_interface_toast = {
							title = fund_inspiration.9000.b.failure
							left_icon = scope:adventurer
							scope:adventurer = {
								increase_wounds_effect = { REASON = fight }
							}
						}
					}
				}
				1 = {
					desc = fund_inspiration.9000.b.critical_failure
					compare_modifier = {
						value = scope:duel_value
						multiplier = -1
					}
					root = {
						send_interface_toast = {
							title = fund_inspiration.9000.b.critical_failure
							left_icon = scope:adventurer
							scope:adventurer = {
								death = {
									death_reason = death_duel
									killer = scope:bandit
								}
							}
						}
					}
				}
			}
		}
		
		ai_chance = {
			base = 4
			modifier = {
				add = scope:adventurer.prowess
			}
			modifier = {
				add = {
					value = scope:bandit.prowess
					multiply = -1
				}
			}
		}
	}
	option = {
		name = fund_inspiration.9000.c
		pay_short_term_gold = {
			target = scope:bandit
			gold = minor_gold_value
		}
		ai_chance = {
			base = 8
			
			modifier = {
				factor = 2
				ai_compassion >= medium_positive_ai_value
			}
			
			modifier = {
				factor = 0.1
				OR = {
					has_trait = stubborn
					has_trait = wrathful
					has_trait = greedy
				}
			}
			
			modifier = {
				factor = 0
				gold < 0
			}
		}
	}
}

# Adventurer travels through beast-infested terrain
fund_inspiration.9100 = {
	type = character_event
	title = fund_inspiration.9100.t
	desc = fund_inspiration.9100.desc
	theme = war

	left_portrait = {
		character = scope:adventurer
		scripted_animation = duel_wield_weapon
	}
	
	override_background = {
		reference = wilderness_scope
	}
	
	cooldown = { years = 5 }

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = {
			exists = var:adventure_destination
			exists = var:adventure_type
			NOR = {
				has_character_flag = fund_adventure_inspiration_event_cooldown
				has_trait = humble
				has_trait = content
			}
			exists = location
		}
	}

	immediate = {
		scope:inspiration_owner = {
			save_scope_as = adventurer
			location.barony.title_province = { save_scope_as = background_wilderness_scope }
			scope:adventurer = {
				select_local_animal_effect = { TYPE = dangerous } # Save scope to limit possible animals: any/big/small/dangerous/harmless/prowling
			}
		}
	}
	option = {
		name = fund_inspiration.9100.a
		
		scope:adventurer = {
			duel = {
				skill = learning
				value = 8
				
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					

					desc = fund_inspiration.9100.a.success
					root = {
						send_interface_toast = {
							title = fund_inspiration.9100.a.success
							left_icon = scope:adventurer
							scope:inspiration = { change_inspiration_progress = 2 }
						}
					}
				}
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}

					desc = fund_inspiration.9100.a.failure
					send_interface_toast = {
						title = fund_inspiration.9100.a.failure
						left_icon = scope:adventurer
						root = {
							scope:adventurer = {
								increase_wounds_effect = { REASON = fight }
							}
						}
					}
				}
			}
		}
		
		ai_chance = {
			base = 4
			modifier = {
				add = scope:adventurer.learning
			}
		}
	}
	option = {
		name = fund_inspiration.9100.b
		
		scope:adventurer = {
			duel = {
				skill = prowess
				value = 8
				
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}

					
					desc = fund_inspiration.9100.b.success
					root = {
						send_interface_toast = {
							title = fund_inspiration.9100.b.success
							left_icon = scope:adventurer
							scope:inspiration_owner = {
								change_artifact_quality_effect = { AMOUNT = 3 }
							}
							scope:inspiration = { change_inspiration_progress = 1 }
						}
					}
				}
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}

					desc = fund_inspiration.9100.b.failure
					root = {
						send_interface_toast = {
							title = fund_inspiration.9100.b.failure
							left_icon = scope:adventurer
							scope:adventurer = {
								increase_wounds_effect = { REASON = fight }
								random = {
									chance = 25
									custom_tooltip = fund_inspiration.9100.b.maimed
									hidden_effect = {
										maimed_in_battle_effect = yes
									}
								}
							}
						}
					}
				}
			}
		}
		
		ai_chance = {
			base = 4
			modifier = {
				add = scope:adventurer.prowess
			}
		}
	}
	option = {
		name = fund_inspiration.9100.c
		
		scope:inspiration = { change_inspiration_progress = -1 }
		
		ai_chance = {
			base = 4
			
			modifier = {
				factor = 2
				ai_compassion >= medium_positive_ai_value
			}
		}
	}
}
