﻿# Called from code after history generation

on_game_start_after_lobby = {
	on_actions = {
		historical_figure_on_game_start_after_lobby
	}
}

historical_figure_on_game_start_after_lobby = {
	effect = {
		historical_figure_initialize_all_effect = yes
	}
}


# Called from code once a year for "playable" (count+) characters

yearly_playable_pulse = {
	on_actions = {
		historical_figure_yearly_playable_pulse
	}
}

historical_figure_yearly_playable_pulse = {
	effect = {
		if = {
			limit = {
				NOT = { exists = global_var:historical_figure_mod_version }
			}
			historical_figure_initialize_all_effect = yes
		}
	}
}


# Called every Jan 1st

yearly_global_pulse = {
	on_actions = {
		historical_figure_yearly_global_pulse
	}
}

historical_figure_yearly_global_pulse = {
	effect = {
		if = {
			limit = {
				NOT = { has_game_rule = historical_figure_birth_disabled }
			}
			random_living_character = {
				historical_figure_birth_check_all_effect = yes
				historical_figure_check_change_first_name_all_effect = yes
			}
		}
	}
}


# Called on 16th birthday

on_16th_birthday = {
	on_actions = {
		historical_figure_on_16th_birthday
	}
}

historical_figure_on_16th_birthday = {
	events = {
		delay = { days = 1 }
		historical_figure_birth.0010
	}
}


# Called on death

on_death = {
	on_actions = {
		historical_figure_on_death
	}
}

historical_figure_on_death = {
	events = {
		historical_figure_birth.0090	# Character just about to die
	}
}
