﻿# More Personality Depth — Character-window view-hook
#
# Executed from gui/window_character.gui: an invisible widget bound to
# IsShown becomes visible when the displayed character has an un-rolled
# personality trait, and its _show transition calls Execute. This closes
# the XP=0 gap for traits added by sources we cannot hook (AGOT events,
# vanilla decisions, console, other mods) the moment the character is
# actually looked at. Same auto-execute pattern AGOT uses in
# interaction_declare_war.gui (rv_save_defender).
#
# is_valid re-checks the trigger at execute time: if another client already
# rolled this character (multiplayer double-open), the call is a no-op.
# The roller itself is idempotent on top of that.

mpd_gui_roll_xp = {
	scope = character

	is_shown = {
		exists = this
		mpd_has_unrolled_personality_trait_trigger = yes
	}

	is_valid = {
		mpd_has_unrolled_personality_trait_trigger = yes
	}

	effect = {
		# Convert stray designer level-markers first (console-added included),
		# then roll any remaining un-rolled personality traits.
		mpd_convert_rd_marker_traits = yes
		mpd_roll_all_personality_xp = yes
	}
}
