#############################################
# CTA: Combat Trait Advancement             #
#                                           #
# Events to complement the integrated New   #
# Duel Engine with combat trait advancement #
# via:                                      #
# - cta.0, on_combat_pulse                  #
# - cta.10, victorious duel engine output   #
#                                           #
# zijistark <azrinon@gmail.com>             #
#############################################

namespace = CombatTraits

# cta.0
# on_combat_pulse on_action event:
#
# Character linearly advances through the 3 experience point (XP)
# tiers required to level-up their combat trait.
#
# Valid for all characters that can take the ambition (could be
# open to more), whether they've enabled the ambition or not. Of
# course, enabling the ambition dramatically increases the odds
# of this event firing.
#
# The associated ambitions are strict about gender: females can
# only take them when conditions are such that they are allowed
# to participate in battle. Neither this on_combat_pulse series
# nor the victorious duel series enforce that directly (in the
# first case because it's implied by the event firing at all and
# in the second because XP advancement is just fine if a female
# somehow gets into a duel when she can't participate in battles,
# as it is for non-rulers and non-marshals as well).

character_event = {
	id = CombatTraits.0

	is_triggered_only = yes
	hide_window = yes

	immediate = {
		# Reminder: event is hidden, only does the bookkeeping, and forwards all visible events from here

		random_player = {
			limit = {
				has_global_flag = debug_cta
				is_local_human_observer = no
			#	is_multiplayer_host_character = yes # Also works in singleplayer
			}

			character_event = { id = CombatTraits.110 }
			character_event = { id = CombatTraits.111 }
		}

		if = {
			limit = { has_character_flag = ctxp1 } # Have 2nd, just earned 3rd experience tier (of 3)

			clr_character_flag = ctxp1

			if = {
				limit = {
					OR = {
						trait = poor_warrior
						trait = trained_warrior
						trait = skilled_warrior
					}
				}

				# Since they aren't starting from the first rung (no combat trait), this is the only/last
				# combat trait advancement they'll get from this system (associated ambitions will also
				# be disabled, of course).

				set_character_flag = cta_done

				# Otherwise, the ctxp[01] flags are all reset just as they were when they started advancing
				# toward poor_warrior, so they will be allowed to continue advancing toward trained_warrior
				# (at a significantly reduced expected frequency of firing this event)
			}

			random_player = {
				limit = {
					has_global_flag = debug_cta
					is_local_human_observer = no
				#	is_multiplayer_host_character = yes # Also works in singleplayer
				}

				character_event = { id = CombatTraits.114 }
			}

			# Notify character of level-up (level-up is an effect of that event, forcing the Ambition Fulfilled popup to only appear afterward, if applicable)
			character_event = { id = CombatTraits.3 }
		}
		else_if = {
			limit = { has_character_flag = ctxp0 } # Have 1st, just earned 2nd experience tier (of 3)

			clr_character_flag = ctxp0
			set_character_flag = ctxp1

			# Notify character of further progress being made
			character_event = { id = CombatTraits.2 }
		}
		else = {
			# Earned 1st experience tier (of 3)
			set_character_flag = ctxp0

			# Notify character of progress being made
			character_event = { id = CombatTraits.1 }
		}
	}
}

# TODO: Each notification should randomly choose between a small prestige bonus, random allied combatant opinion bonuses (at location), etc.
# TODO: Even within the battle series, there should be multiple notification events (randomly chosen) for each XP tier for flavor and to avoid excessive repetition

# First notification of progress being made toward CTA (of 2): battle series
character_event = {
	id = CombatTraits.1
	desc = EVTDESC_CombatTraits_1
	picture = GFX_evt_battle
	border = GFX_event_normal_frame_war

	is_triggered_only = yes
	hide_from = yes

	ai = no

	trigger = {
		NOT = { trait = master_warrior }
	}

	option = {
		name = EVTOPTA_CombatTraits_1

		custom_tooltip = { text = EVTOPTA_CombatTraits_1.CTT }
	}
}

# Second notification of progress being made toward CTA (of 2): battle series
character_event = {
	id = CombatTraits.2
	desc = EVTDESC_CombatTraits_2
	picture = GFX_evt_battle
	border = GFX_event_normal_frame_war

	is_triggered_only = yes
	hide_from = yes

	ai = no

	trigger = {
		NOT = { trait = master_warrior }
	}

	option = {
		name = EVTOPTA_CombatTraits_2

		custom_tooltip = { text = EVTOPTA_CombatTraits_2.CTT }
	}
}

# Successful CTA level-up: battle series
#
# TODO: Add a more significant random bonus (e.g., temporary opinion from numerous
#       friendly soldiers/leaders at the same location and possibly the liege)
# NOTE: Ff the character had a CTA ambition enabled (they probably did if they
#       advanced this far), they'll receive a small, tier-dependent prestige bonus
#       and an Ambition Fulfilled notification moments after accepting this event.
character_event = {
	id = CombatTraits.3
	desc = EVTDESC_CombatTraits_3
	picture = GFX_evt_battle
	border = GFX_event_normal_frame_war

	is_triggered_only = yes
	hide_from = yes

	trigger = {
		NOT = { trait = master_warrior }
	}

	option = {
		name = EVTOPTA_CombatTraits_3

		trigger = {
			NOR = {
				trait = poor_warrior
				trait = trained_warrior
				trait = skilled_warrior
			}
		}

		add_trait = poor_warrior
	}

	option = {
		name = EVTOPTB_CombatTraits_3

		trigger = { trait = poor_warrior }

		remove_trait = poor_warrior
		add_trait = trained_warrior
	}

	option = {
		name = EVTOPTC_CombatTraits_3

		trigger = { trait = trained_warrior }

		remove_trait = trained_warrior
		add_trait = skilled_warrior
	}

	option = {
		name = EVTOPTD_CombatTraits_3

		trigger = { trait = skilled_warrior }

		remove_trait = skilled_warrior
		add_trait = master_warrior
	}
}

# Victorious Duel (opponent slain or spared)
#
# Called for 1) battlefield duels, 2) feast duels, 3) rival duels, 4) regency duels, etc. (check various_duel_events.txt)
# FROM = loser, ROOT = winner.  Ergo, if we want to reference the loser of the duel in a notification event fired from here,
# FROMFROM will be the loser and ROOT=FROM will be the winner. This event is a model of DuelEngine.901 scope-wise, and indeed,
# it was originally called directly from NDE's duel outcomes rather than duel output events. However, I wanted to minimize merge
# conflicts with NDE, so DuelEngine.901 forwards back to the [possibly dead] loser in CombatTraits.11, which immediately bounces
# back to the winner here, in CombatTraits.10, allowing full access to FROMFROM (and FROMFROM's portait) in child events. A little
# silly but not.
#
# Again, this is a hidden-window event which does bookkeeping and only fires visible messaging events when appropriate.
# It could not be (unlike the combat impulse event), but a single victorious duel does not earn an experience tier (only 3
# and always exactly 3 victories would be required if it did).  Instead, each duel win has a random chance of advancing
# the character's experience tier.  The cumulative density function for experience tier advancement needs to be tuned for
# balance.
#
# NOTE: Progress notifications were skipped in this case, as there is enough event-chain clutter for the user to click
#       their way through during/after duels (and they're likely in the middle of a battle, which presents yet more).
#
# TODO: Variation on flavor of level-up notification. we don't effectively use information about the opponent or the location
#       to throw out some interesting edification when we could (or at all-- the event text is generic regarding combat).

character_event = {
	id = CombatTraits.10

	is_triggered_only = yes
	hide_window = yes

	# Essentially same trigger as combat impulse event for uniformity's sake, though the duel engine isn't going to feed us
	# a dead/child/prisoner/incapable/blind winner (hopefully).  HOWEVER, we lift the "ruler or marshal of one" restriction,
	# because duel cases are rare, and the character might as well get a shot at advancing some state toward a CTA in the
	# future or, without the ambition, via duels alone.

	prisoner = no
	only_capable = yes

	trigger = {
		is_adult = yes
		practical_age < 50

		NOR = {
			trait = blinded
			trait = master_warrior
			has_character_flag = cta_done
		}
	}

	immediate = {

		# Flip a coin for whether this duel win counts toward an XP tier or not

		# Currently: 40% chance per win w/o ambition (regardless of tier),
		#            70% per win w/ ambition and skilled_warrior
		#            75% per win w/ ambition and trained_warrior,
		#            85% per win w/ ambition and no combat trait or poor_warrior
		#
		# The probability of k victorious duels being required to advance a combat trait (dueling on its own, without
		# the help of any earned combat pulses) is (k >= 3):
		#
		# (1 - c)^(k - 3) * c^3
		#
		# where c is the chance of a victorious duel resulting in an XP advance (the above-cited percentages)
		#
		# The consequent expectation of duel wins required to advance a level is a bit daunting (especially
		# considering that each is usually kill-or-be-killed), hence the relatively high seeming percentages.
		# of course, XP advancement works in concert with combat pulses, so these probabilities are not the
		# whole story.
		#
		# In the future: since we've taken great care to keep the duel loser, alive or dead, in FROM (ergo FROMFROM
		# of any event we call), it would be much cooler to encapsulate the "coin flip" into another hidden event
		# which uses ai_chance on two options (either set cta_xp or do not) to allow nice, multiplicative modifiers
		# to be applied to the probability of advancement based upon relative skill of winner v. loser, actual duel
		# count won (to improve determinism past a certain number of wins), the type of duel (friendly vs. not), etc.

		# Flag cta_xp is temp. to this event and represents whether ROOT did indeed earn an XP tier this time.

		random_list = {
			40 = { set_character_flag = cta_xp } # 40%

			30 = { # 70%
				if = {
					limit = {
						OR = {
							has_ambition = obj_cta_0
							has_ambition = obj_cta_1
							has_ambition = obj_cta_2
							has_ambition = obj_cta_3
						}
					}
					set_character_flag = cta_xp
				}
			}

			5 = { # 75%
				if = {
					limit = {
						OR = {
							has_ambition = obj_cta_0
							has_ambition = obj_cta_1
							has_ambition = obj_cta_2
						}
					}
					set_character_flag = cta_xp
				}
			}

			10 = { # 85%
				if = {
					limit = {
						OR = {
							has_ambition = obj_cta_0
							has_ambition = obj_cta_1
						}
					}
					set_character_flag = cta_xp
				}
			}

			15 = {
				random_player = {
					limit = {
						has_global_flag = debug_cta
						is_local_human_observer = no
					#	is_multiplayer_host_character = yes # Also works in singleplayer
					}

					character_event = { id = CombatTraits.113 }
				}
			}
		}

		if = {
			limit = { has_character_flag = cta_xp }

			# Cool. Advanced an XP tier.

			random_player = {
				limit = {
					has_global_flag = debug_cta
					is_local_human_observer = no
				#	is_multiplayer_host_character = yes # Also works in singleplayer
				}

				character_event = { id = CombatTraits.112 }
			}

			if = {
				limit = { has_character_flag = ctxp1 } # Earned 3rd experience tier (of 3)

				clr_character_flag = ctxp1

				if = {
					limit = {
						OR = {
							trait = poor_warrior
							trait = trained_warrior
							trait = skilled_warrior
						}
					}

					set_character_flag = cta_done
				}

				random_player = {
					limit = {
						has_global_flag = debug_cta
						is_local_human_observer = no
					#	is_multiplayer_host_character = yes # Also works in singleplayer
					}

					character_event = { id = CombatTraits.114 }
				}

				# Notify character of level-up (actual level-up is an effect of that event)
				character_event = { id = CombatTraits.13 }
			}
			else_if = {
				limit = { has_character_flag = ctxp0 } # Earned 2nd experience tier (of 3)
				clr_character_flag = ctxp0
				set_character_flag = ctxp1
			}
			else = {
				# Earned 1st experience tier (of 3)
				set_character_flag = ctxp0
			}
		}

		clr_character_flag = cta_xp
	}
}


# Silly scope bouncer for CombatTraits.10. initial entry point from DuelEngine.90* (duel_engine_events.txt)
# FROM is winner
# ROOT is loser
character_event = {
	id = CombatTraits.11

	is_triggered_only = yes
	hide_window = yes

	immediate = {
		FROM = { character_event = { id = CombatTraits.10 } }
	}
}


#############
# CombatTraits.12 free
#############

# Duel series: successful CTA level-up
character_event = {
	id = CombatTraits.13
	desc = EVTDESC_CombatTraits_13
	picture = GFX_evt_battle
	border = GFX_event_normal_frame_war

	is_triggered_only = yes
	show_from_from = yes
	hide_from = yes

	trigger = {
		NOT = { trait = master_warrior }
	}

	option = {
		name = EVTOPTA_CombatTraits_13

		trigger = {
			NOR = {
				trait = poor_warrior
				trait = trained_warrior
				trait = skilled_warrior
			}
		}

		add_trait = poor_warrior
	}

	option = {
		name = EVTOPTB_CombatTraits_13

		trigger = { trait = poor_warrior }

		remove_trait = poor_warrior
		add_trait = trained_warrior
	}

	option = {
		name = EVTOPTC_CombatTraits_13

		trigger = { trait = trained_warrior }

		remove_trait = trained_warrior
		add_trait = skilled_warrior
	}

	option = {
		name = EVTOPTD_CombatTraits_13

		trigger = { trait = skilled_warrior }

		remove_trait = skilled_warrior
		add_trait = master_warrior
	}
}

# Debug notification: Combat impulse.
# Variant: Character has selected a CTA ambition.
character_event = {
	id = CombatTraits.110
	desc = EVTDESC_CombatTraits_110
	picture = GFX_evt_battle

	is_triggered_only = yes

	trigger = {
		FROM = {
			OR = {
				has_ambition = obj_cta_0
				has_ambition = obj_cta_1
				has_ambition = obj_cta_2
				has_ambition = obj_cta_3
			}
		}
	}

	option = { name = OK }
}

# Debug notification: Combat impulse.
# Variant: Character has no CTA ambition.
character_event = {
	id = CombatTraits.111
	desc = EVTDESC_CombatTraits_111
	picture = GFX_evt_battle

	is_triggered_only = yes

	trigger = {
		FROM = {
			NOT = {
				has_ambition = obj_cta_0
				has_ambition = obj_cta_1
				has_ambition = obj_cta_2
				has_ambition = obj_cta_3
			}
		}
	}

	option = { name = OK }
}

# Debug notification: Duel victory impulse.
# Variant: Coin-flip advanced XP tier (possibly levelled).
character_event = {
	id = CombatTraits.112
	desc = EVTDESC_CombatTraits_112
	picture = GFX_evt_battle
	border = GFX_event_normal_frame_war

	is_triggered_only = yes

	option = { name = OK }
}

# Debug notification: Duel victory impulse.
# Variant: Coin-flip did not advance XP tier.
character_event = {
	id = CombatTraits.113
	desc = EVTDESC_CombatTraits_113
	picture = GFX_evt_battle
	border = GFX_event_normal_frame_war

	is_triggered_only = yes

	option = { name = OK }
}

# Debug notification: Combat trait level-up.
character_event = {
	id = CombatTraits.114
	desc = EVTDESC_CombatTraits_114
	picture = GFX_evt_battle
	border = GFX_event_normal_frame_war

	is_triggered_only = yes

	trigger = {
		FROM = { NOT = { trait = master_warrior } }
	}

	option = {
		name = EVTOPTA_CombatTraits_114

		trigger = {
			FROM = {
				NOR = {
					trait = poor_warrior
					trait = trained_warrior
					trait = skilled_warrior
				}
			}
		}

		tooltip = {
			FROM = {
				show_scope_change = no
				add_trait = poor_warrior
			}
		}
	}

	option = {
		name = EVTOPTB_CombatTraits_114

		trigger = { FROM = { trait = poor_warrior } }

		tooltip = {
			FROM = {
				show_scope_change = no
				add_trait = trained_warrior
			}
		}
	}

	option = {
		name = EVTOPTC_CombatTraits_114

		trigger = { FROM = { trait = trained_warrior } }

		tooltip = {
			FROM = {
				show_scope_change = no
				add_trait = skilled_warrior
			}
		}
	}

	option = {
		name = EVTOPTD_CombatTraits_114

		trigger = { FROM = { trait = skilled_warrior } }

		tooltip = {
			FROM = {
				show_scope_change = no
				add_trait = master_warrior
			}
		}
	}
}

###################################
#
# Hand out traits. Totally ripped from PB
#
###################################

character_event = {
	id = CombatTraits.600

	is_triggered_only = yes
	hide_window = yes

	immediate = {
		# Give out combat traits
		any_character = {
			limit = {
				# Only assign a combat trait to characters who don't already have one
				has_warrior_trait_trigger = no

				trigger_if = {
					limit = { is_ruler = no }
					has_education_martial_trigger = yes
				}
			}

			if = {
				limit = { trait = misguided_warrior }
				change_variable = { which = local_combat_skill value = 2 }
			}
			if = {
				limit = { trait = tough_soldier }
				change_variable = { which = local_combat_skill value = 4 }
			}
			if = {
				limit = { trait = skilled_tactician }
				change_variable = { which = local_combat_skill value = 6 }
			}
			if = {
				limit = { trait = brilliant_strategist }
				change_variable = { which = local_combat_skill value = 8 }
			}
			if = {
				limit = { trait = diligent }
				change_variable = { which = local_combat_skill value = 1 }
			}
			if = {
				limit = { trait = brave }
				change_variable = { which = local_combat_skill value = 2 }
			}
			if = {
				limit = { trait = quick }
				change_variable = { which = local_combat_skill value = 1 }
			}
			if = {
				limit = { trait = shrewd }
				change_variable = { which = local_combat_skill value = 1 }
			}
			if = {
				limit = { trait = genius }
				change_variable = { which = local_combat_skill value = 2 }
			}
			if = {
				limit = { trait = brawny }
				change_variable = { which = local_combat_skill value = 1 }
			}
			if = {
				limit = { trait = strong }
				change_variable = { which = local_combat_skill value = 2 }
			}
			if = {
				limit = { trait = agile }
				change_variable = { which = local_combat_skill value = 1 }
			}
			if = {
				limit = { trait = weak }
				change_variable = { which = local_combat_skill value = -2 }
			}
			if = {
				limit = { trait = frail }
				change_variable = { which = local_combat_skill value = -1 }
			}
			if = {
				limit = { trait = slow }
				change_variable = { which = local_combat_skill value = -1 }
			}
			if = {
				limit = { trait = dull }
				change_variable = { which = local_combat_skill value = -1 }
			}
			if = {
				limit = { trait = imbecile }
				change_variable = { which = local_combat_skill value = -3 }
			}
			if = {
				limit = { trait = inbred }
				change_variable = { which = local_combat_skill value = -2 }
			}
			if = {
				limit = { trait = clubfooted }
				change_variable = { which = local_combat_skill value = -1 }
			}
			if = {
				limit = { trait = slothful }
				change_variable = { which = local_combat_skill value = -1 }
			}
			if = {
				limit = { trait = craven }
				change_variable = { which = local_combat_skill value = -2 }
			}

			# Hand out trait
			if = {
				limit = { check_variable = { which = local_combat_skill value >= 8 } }
				add_trait = master_warrior
			}
			else_if = {
				limit = { check_variable = { which = local_combat_skill value >= 6 } }
				add_trait = skilled_warrior
			}
			else_if = {
				limit = { check_variable = { which = local_combat_skill value >= 4 } }
				add_trait = trained_warrior
			}
			else_if = {
				limit = { check_variable = { which = local_combat_skill value >= 1 } }
				add_trait = poor_warrior
			}

			# Clear variable for next character
			set_variable = { which = local_combat_skill value = 0 }
		}
	}
}

### Combat Trait Events (CombatTraits.20-22)
### Credits to Galla (Greg) for coming up with 99% of these;

# Learning the sword from your guardian
character_event = {
	id = CombatTraits.20
	desc = EVTDESC_CombatTraits_20
	picture = GFX_evt_child_sword

	is_triggered_only = yes # on_yearly_childhood_pulse, random_events

	prisoner = no
	capable_only = yes

	trigger = {
		educator = {
			OR = {
				trait = misguided_warrior
				trait = tough_soldier
				trait = skilled_tactician
				trait = brilliant_strategist

				trait = poor_warrior
				trait = trained_warrior
				trait = skilled_warrior
				trait = master_warrior

				trait = duelist
				has_job_title = job_marshal
				has_minor_title = title_commander
			}
		}

		NOT = { trait = master_warrior }
	}

	weight_multiplier = {
		factor = 1

		# Advancement slows down based on current level
		mult_modifier = {
			factor = 0.5
			trait = poor_warrior
		}

		mult_modifier = {
			factor = 0.25
			trait = trained_warrior
		}

		mult_modifier = {
			factor = 0.17
			trait = skilled_warrior
		}

		# Advancement slows down if ward has better trait than guardian
		mult_modifier = {
			factor = 0.17

			OR = {
				trigger_if = {
					limit = { trait = poor_warrior }

					educator = {
						NOR = {
							trait = trained_warrior
							trait = skilled_warrior
							trait = master_warrior
						}
					}
				}
				trigger_else_if = {
					limit = { trait = trained_warrior }

					educator = {
						NOR = {
							trait = skilled_warrior
							trait = master_warrior
						}
					}
				}
				trigger_else_if = {
					limit = { trait = skilled_warrior }

					educator = {
						NOT = { trait = master_warrior }
					}
				}

				educator = {
					combat_rating_diff = {
						who = ROOT
						value <= -50
					}
				}
			}
		}

		# Mentor Effects
		mult_modifier = {
			factor = 1.18

			educator = {
				OR = {
					trait = poor_warrior
					trait = trained_warrior
					trait = skilled_warrior
					trait = master_warrior
				}
			}
		}

		mult_modifier = {
			factor = 1.18

			educator = {
				OR = {
					trait = trained_warrior
					trait = skilled_warrior
					trait = master_warrior
				}
			}
		}

		mult_modifier = {
			factor = 1.18

			educator = {
				OR = {
					trait = skilled_warrior
					trait = master_warrior
				}
			}
		}

		mult_modifier = {
			factor = 0.85

			educator = {
				trait = master_warrior
			}
		}

		# Mentor has martial education
		mult_modifier = {
			factor = 1.18

			educator = {
				OR = {
					has_job_title = job_marshal
					trait = misguided_warrior
					trait = tough_soldier
					trait = skilled_tactician
					trait = brilliant_strategist
				}
			}
		}

		mult_modifier = {
			factor = 1.18

			OR = {
				has_focus = focus_ed_martial
				has_focus = focus_ch_struggle
			}
		}

		mult_modifier = {
			factor = 1.18

			educator = {
				OR = {
					trait = tough_soldier
					trait = skilled_tactician
					trait = brilliant_strategist
				}
			}
		}

		mult_modifier = {
			factor = 1.18

			educator = {
				OR = {
					trait = skilled_tactician
					trait = brilliant_strategist
				}
			}
		}

		mult_modifier = {
			factor = 1.18

			educator = {
				trait = brilliant_strategist
			}
		}

		# Mentor is skilled in combat
		modifier = {
			factor = 1.18
			educator = { trait = duelist }
		}

		## Personality Effects
		# Good
		mult_modifier = {
			factor = 1.18

			OR = {
				trait = diligent
				trait = brave
				trait = rowdy
			}
		}

		# Bad
		mult_modifier = {
			factor = 0.74

			OR = {
				trait = slothful
				trait = craven
				trait = timid
			}
		}

		## Intelligence Effects
		# Good
		mult_modifier = {
			factor = 1.18
			trait = genius
		}

		mult_modifier = {
			factor = 1.11

			OR = {
				trait = quick
				trait = shrewd
			}
		}

		# Bad
		mult_modifier = {
			factor = 0.83

			OR = {
				trait = slow
				trait = dull
			}
		}

		mult_modifier = {
			factor = 0.74
			trait = imbecile
		}

		## Physical Effects
		# Good
		mult_modifier = {
			factor = 1.18
			is_strong_trigger = yes
		}

		# Bad
		mult_modifier = {
			factor = 0.74
			is_weak_trigger = yes
		}

		# Sexism
		mult_modifier = {
			factor = 0.71
			is_female = yes
		}
	}

	option = {
		name = EVTOPTA_CombatTraits_20 # Stick 'em with the pointy end!

		hidden_effect = {
			educator = {
				character_event = { id = CombatTraits.21 } # Guardian Notification
			}
		}

		if = {
			limit = { trait = skilled_warrior }
			remove_trait = skilled_warrior
			add_trait = master_warrior
		}
		else_if = {
			limit = { trait = trained_warrior }
			remove_trait = trained_warrior
			add_trait = skilled_warrior
		}
		else_if = {
			limit = { trait = poor_warrior }
			remove_trait = poor_warrior
			add_trait = trained_warrior
		}
		else = {
			add_trait = poor_warrior
		}
	}
}


character_event = { #Guardian Notification for trait incrase
	id = CombatTraits.21
	desc = EVTDESC_CombatTraits_21 # I have increased my ward's fighting skills
	picture = GFX_evt_child_sword

	is_triggered_only = yes

	ai = no

	option = {
		name = OK
	}
}

character_event = { # Trait demotion due to age
	id = CombatTraits.22
	desc = EVTDESC_CombatTraits_22
	picture = GFX_evt_illness

	is_triggered_only = yes # on_yearly_pulse, random_events

	min_age = 45

	trigger = {
		OR = {
			trait = poor_warrior
			trait = trained_warrior
			trait = skilled_warrior
			trait = master_warrior
		}

		immortal = no
		NOT = { has_character_flag = cte_demoted }
	}

	weight_multiplier = {
		factor = 1

		## Personality Effects
		# Good
		mult_modifier = {
			factor = 0.8

			OR = {
				trait = diligent
				trait = brave
				trait = duelist
			}
		}

		# Bad
		mult_modifier = {
			factor = 1.33
			trait = slothful
		}

		## Physical Effects
		# Good
		mult_modifier = {
			factor = 0.67
			is_strong_trigger = yes
		}

		# Bad
		mult_modifier = {
			factor = 5
			is_weak_trigger = yes
		}
	}

	option = {
		name = CURSES

		set_character_flag = cte_demoted

		if = {
			limit = { trait = poor_warrior }
			remove_trait = poor_warrior
		}
		else_if = {
			limit = { trait = trained_warrior }
			remove_trait = trained_warrior
			add_trait = poor_warrior
		}
		else_if = {
			limit = { trait = skilled_warrior }
			remove_trait = skilled_warrior
			add_trait = trained_warrior
		}
		else_if = {
			limit = { trait = master_warrior }
			remove_trait = master_warrior
			add_trait = skilled_warrior
		}
	}
}