namespace = newbrazil

narrative_event = { #Apostolic New Brazilian Empire
	id = newbrazil.1
	title = EVTNAME_newbrazil.1
	desc = EVTDESC_newbrazil.1
	picture = GFX_evt_coronation
	border = GFX_event_narrative_frame_stewardship

	is_triggered_only = yes

	FROM = { show_portrait = THIS }

        option = {
                name = EVTOPT_newbrazil.1
		prestige = 500
		give_nickname = nick_the_great
		add_artifact = crown_new_brazil
		if = {
			limit = {
				is_female = yes
				religion = apostolic
			}
			create_bloodline = {
				type = new_brazil_apostolic_female
			}
		}
		if = {
			limit = {
				is_female = no
				religion  = apostolic
			}
			create_bloodline = {
				type = new_brazil_apostolic_male
			}
		}
	}
}

narrative_event = { #Celeste New Brazilian Empire
	id = newbrazil.2
	title = EVTNAME_newbrazil.1
	desc = EVTDESC_newbrazil.2
	picture = GFX_evt_coronation
	border = GFX_event_narrative_frame_stewardship

	is_triggered_only = yes

	FROM = { show_portrait = THIS }

        option = {
                name = EVTOPT_newbrazil.1
		prestige = 500
		give_nickname = nick_the_great
		add_artifact = crown_new_brazil
		if = {
			limit = {
				is_female = yes
				religion = celeste
			}
			create_bloodline = {
				type = new_brazil_celeste_female
			}
		}
		if = {
			limit = {
				is_female = no
				religion  = celeste
			}
			create_bloodline = {
				type = new_brazil_celeste_male
			}
		}
	}
}

narrative_event = { #New Brazilian Empire for other religions
	id = newbrazil.3
	title = EVTNAME_newbrazil.1
	desc = EVTDESC_newbrazil.3
	picture = GFX_evt_coronation
	border = GFX_event_narrative_frame_stewardship

	is_triggered_only = yes

	FROM = { show_portrait = THIS }

        option = {
                name = EVTOPT_newbrazil.1
		prestige = 500
		give_nickname = nick_the_great
		add_artifact = crown_new_brazil
		if = {
			limit = {
				is_female = yes
			}
			create_bloodline = {
				type = new_brazil_other_female
			}
		}
		if = {
			limit = {
				is_female = no
			}
			create_bloodline = {
				type = new_brazil_other_male
			}
		}
	}
}

character_event = { # Great brazilian warrior character chance
	id = newbrazil.4
	hide_window = yes
	
	only_playable = yes
	only_capable = yes
	prisoner = no
	min_age = 16

	trigger = {
		any_owned_bloodline = {
			has_bloodline_flag = bloodline_brazil_heroes
			bloodline_is_active_for = PREV
			founder = {
				NOT = {
					character = ROOT
				}
				religion = ROOT
			}
		}
		NOT = {
			any_courtier_or_vassal = {
				count = 4
				has_character_flag = bloodline_brazil_hero
			}
		}
	}
	
	immediate = {
		random_list = {
			80 = {
				modifier = {
					factor = 0.75
					NOT = {
						higher_tier_than = COUNT
					}
				}
				modifier = {
					factor = 0.75
					NOT = {
						higher_tier_than = DUKE
					}
				}
				modifier = {
					factor = 0.75
					any_courtier_or_vassal = {
						count = 2
						has_character_flag = bloodline_brazil_hero
					}
				}
				modifier = {
					factor = 0.75
					any_courtier_or_vassal = {
						count = 3
						has_character_flag = bloodline_brazil_hero
					}
				}
				character_event = { id = newbrazil.5 }
			}
			20 = {
				# Nothing
			}
		}
	}
}

character_event = { # Great brazilian warrior character arrives
	id = newbrazil.5
	desc = EVTDESC_newbrazil.5
	picture = GFX_placeholder
	border = GFX_event_normal_frame_war

	is_triggered_only = yes
	
	only_playable = yes
	only_capable = yes
	prisoner = no
	min_age = 16
	
	immediate = {
		create_random_priest = {
			random_traits = yes
			dynasty = random
			female = no
			attributes = {
				diplomacy = 3
				martial = 8
				stewardship = 6
				intrigue = 3
				learning = 3
			}
		}
		new_character = {
			remove_trait = detached_priest
			remove_trait = martial_cleric
			remove_trait = scholarly_theologian
			remove_trait = mastermind_theologian

			remove_trait = slow
			remove_trait = imbecile
			remove_trait = dull
			remove_trait = craven
				
			remove_trait = mystic
			remove_trait = socializer
			remove_trait = gamer
			remove_trait = hedonist
			remove_trait = duelist
			remove_trait = hunter
			remove_trait = strategist
			remove_trait = administrator
			remove_trait = architect
			remove_trait = gardener
			remove_trait = schemer
			remove_trait = impaler
			remove_trait = seducer
			remove_trait = seductress
			remove_trait = theologian
			remove_trait = scholar

			random_list = { # Flavor Randomization
				70 = { add_trait = skilled_tactician }
				30 = { add_trait = brilliant_strategist }
			}
			random_list = { # Flavor Randomization
				35 = {  } # Nothing
				30 = { 
					change_diplomacy = 1
					change_martial = 2
					change_stewardship = 1
				}
				20 = { 
					change_diplomacy = 1
					change_martial = 3
					change_stewardship = 1
					change_intrigue = 1
					change_learning = 1
				}
				15 = {
					change_diplomacy = 2
					change_martial = 4
					change_stewardship = 2
					change_intrigue = 2
					change_learning = 2
				}
			}
			random_list = { # Flavor Randomization
				40 = {  } # Nothing
				10 = { add_trait = duelist }
				10 = { add_trait = hunter }
				40 = { add_trait = strategist }
			}
			random_list = { # Flavor Randomization
				80 = {  } # Nothing
				15 = { add_trait = shrewd }
				10 = { add_trait = quick }
				 5 = { add_trait = genius }
			}
			random_list = { # Flavor Randomization
				25 = { add_trait = master_of_flame }
				25 = { add_trait = logistics_expert }
				25 = { add_trait = levy_coordinator }
				25 = { add_trait = sapper }
			}
			save_event_target_as = invited_character
		}
		event_target:invited_character = {
			set_character_flag = bloodline_brazil_hero
			set_character_flag = hero_knight
		}
	}

	event_target:invited_character = { show_portrait = THIS }
	
	option = {
		name = MNM.70013.o
		
		trigger = {
			any_realm_character = {
				NOT = {
					higher_tier_than = BARON
				}
				liege = { character = ROOT }
				has_minor_title = title_commander
				NOT = {
					martial = 12
				}
			}
			OR = {
				AND = {
					tier = COUNT
					any_realm_character = {
						count = 2
						liege = { character = ROOT }
						has_minor_title = title_commander
					}
				}
				AND = {
					tier = DUKE
					any_realm_character = {
						count = 4
						liege = { character = ROOT }
						has_minor_title = title_commander
					}
				}
				AND = {
					tier = KING
					is_nomadic = no
					any_realm_character = {
						count = 6
						liege = { character = ROOT }
						has_minor_title = title_commander
					}
				}
				AND = {
					tier = EMPEROR
					is_nomadic = no
					any_realm_character = {
						count = 8
						liege = { character = ROOT }
						has_minor_title = title_commander
					}
				}
				AND = {
					tier = KING
					is_nomadic = yes
					any_realm_character = {
						count = 2
						liege = { character = ROOT }
						has_minor_title = title_commander
					}
				}
				AND = {
					tier = EMPEROR
					is_nomadic = yes
					any_realm_character = {
						count = 4
						liege = { character = ROOT }
						has_minor_title = title_commander
					}
				}
			}
		}
		
		random_realm_character = {
			limit = {
				NOT = {
					higher_tier_than = BARON
				}
				liege = { character = ROOT }
				has_minor_title = title_commander
				NOT = {
					martial = 12
				}
			}
			remove_title = title_commander
			opinion = {
				modifier = insulted
				who = ROOT
				years = 2
			}
		}
		
		event_target:invited_character = {
			give_minor_title = title_commander
			opinion = {
				modifier = opinion_loyal_servant
				who = ROOT
				years = 100
			}
		}
	}

	option = {
		name = EVTOPTA_NE_1
		
		trigger = {
			event_target:invited_character = { has_character_flag = invited_soldier }
			OR = {
				AND = {
					tier = COUNT
					NOT = {
						any_realm_character = {
							count = 2
							liege = { character = ROOT }
							has_minor_title = title_commander
						}
					}
				}
				AND = {
					tier = DUKE
					NOT = {
						any_realm_character = {
							count = 4
							liege = { character = ROOT }
							has_minor_title = title_commander
						}
					}
				}
				AND = {
					tier = KING
					is_nomadic = no
					NOT = {
						any_realm_character = {
							count = 6
							liege = { character = ROOT }
							has_minor_title = title_commander
						}
					}
				}
				AND = {
					tier = EMPEROR
					is_nomadic = no
					NOT = {
						any_realm_character = {
							count = 8
							liege = { character = ROOT }
							has_minor_title = title_commander
						}
					}
				}
				AND = {
					tier = KING
					is_nomadic = yes
					NOT = {
						any_realm_character = {
							count = 2
							liege = { character = ROOT }
							has_minor_title = title_commander
						}
					}
				}
				AND = {
					tier = EMPEROR
					is_nomadic = yes
					NOT = {
						any_realm_character = {
							count = 4
							liege = { character = ROOT }
							has_minor_title = title_commander
						}
					}
				}
			}
		}
		
		event_target:invited_character = {
			give_minor_title = title_commander
			opinion = {
				modifier = opinion_loyal_servant
				who = ROOT
				years = 100
			}
		}
	}
	
	option = {
		name = FANTASTIC
		event_target:invited_character = {
			opinion = {
				modifier = opinion_loyal_servant
				who = ROOT
				years = 100
			}
		}
	}
	
	option = {
		name = EVTOPTB_HF_100
		
		hidden_tooltip = {
			event_target:invited_character = { 
				death = {
					death_reason = death_missing
				}
			}
		}
	}
}

character_event = {
	id = newbrazil.6
	desc = EVTDESC_newbrazil.6
	picture = GFX_placeholder
	border = GFX_event_normal_frame_war

	is_triggered_only = yes

	FROM = { show_portrait = THIS }

	option = {
		name = EVTOPTA_newbrazil.6
		add_trait = master_of_flame
	}
	option = {
		name = EVTOPTB_newbrazil.6
		add_trait = logistics_expert
	}
	option = {
		name = EVTOPTC_newbrazil.6
		add_trait = levy_coordinator
	}
	option = {
		name = EVTOPTD_newbrazil.6
		add_trait = sapper
	}
}