﻿on_game_start = {
	on_actions = {
		on_lmf_start
	}
}

# for setting the lmf_is_loaded variable (for other mods)
# and for suppressing compatibility errors
on_lmf_start = {
	effect = {
        set_global_variable = {
			name = lmf_is_loaded
			value = yes
		}
		# error suppression
        if = {
            limit = {
				always = no # means no effects will actually be run
				exists = global_var:lmf_is_loaded
				exists = global_var:travel_the_distance_is_loaded
				exists = global_var:AGOT_is_loaded
				has_character_flag = marry_for_love
				has_variable = story_stray_seed_location
			}
			add_character_flag = tomboy
			# for Travel the Distance compatibility
			set_global_variable = {
				name = travel_the_distance_is_loaded
				value = yes
			}
        	set_global_variable = {
				name = celebrate_crimes_is_loaded
				value = no
			}
		}
	}
}

# adding initial maidens
on_game_start_after_lobby = {
	events = {
		lmf_maiden.1000 #To generate additional starting maidens
		lmf_interaction.1000 #To warn AGOT users
	}
}

# for most systems that check all playable rulers
random_yearly_playable_pulse = {
	on_actions = {
		delay = { days = { 7 14 } }
		on_lmf_pregnancy_check
		delay = { days = { 15 60 } }
		on_lmf_family_dinner_event
		delay = { days = { 30 180 } }
		on_lmf_ai_intro_check
		delay = { days = { 30 180 } }
		on_lmf_yearly_courtier_scheme_check
		delay = { days = { 1 180 } }
		on_lmf_yearly_courtier_marriage_check
		delay = { days = { 1 180 } }
		on_lmf_tutor_check
		delay = { days = { 30 180 } }
		on_lmf_spouse_check
	}
}

three_year_playable_pulse = {
	on_actions = {
		delay = { days = { 15 180 } }
		on_lmf_3yr_courtier_scheme_check
		delay = { days = { 15 180 } }
		on_lmf_3yr_courtier_marriage_check
		delay = { days = { 60 240 } }
		on_lmf_dynasty_control_check
	}
}

five_year_playable_pulse = {
	on_actions = {
		delay = { days = { 15 180 } }
		on_lmf_5yr_courtier_scheme_check
		delay = { days = { 15 180 } }
		on_lmf_5yr_courtier_marriage_check
	}
}

# for checking special traits & invalid lover secrets (vanilla bug) on all characters
random_yearly_everyone_pulse = {
	on_actions = {
		on_lmf_special_trait_check
		on_lmf_bad_secret_lover_check
	}
}

# for inactive infertility traits
on_birth_child = {
	on_actions = {
		on_lmf_birth_infertile
	}
}

# for most LMF childhood events and heir training
on_birthday = {
	on_actions = {
		delay = { days = { 30 60 } }
		on_lmf_childhood_events
		delay = { days = 1 }
		on_lmf_female_fighter_check
		delay = { days = { 61 120 } }
		on_lmf_heir_training
		delay = { days = { 7 14 } }
		on_lmf_guardian_check
		on_lmf_betrothal_lineality_check
	}
}

# for systems that can be affected by becoming a ruler
on_title_gain = {
	on_actions = {
		on_lmf_traveling_heir_title_check
		on_lmf_heir_in_training_check
		on_lmf_will_not_wed_check
		on_lmf_new_ruler_lover_check
		on_lmf_holy_order_trait_check
	}
}

# for wars that can invalidate visits
on_war_started = {
	on_actions = {
		on_lmf_traveling_heir_war_start_check
		on_lmf_traveling_visit_war_start_check
	}
}

# for imprisonments involving visits
on_imprison = {
	on_actions = {
		on_lmf_traveling_heir_imprison_check
	}
}

# for deaths invalidating visits
on_death = {
	on_actions = {
		on_lmf_intro_death_check
		on_lmf_invitation_death_check
		on_lmf_traveling_heir_death_check
		on_lmf_in_law_check
		on_lmf_mourning_period_check
	}
}

# for initial "wedding night" check & in-law relation setup & LMF spouse event kickoff
on_marriage = {
	on_actions = {
		on_lmf_wedding_night
		delay = { days = 1 }
		on_lmf_in_law_setup
		on_lmf_initial_spouse_check
		on_lmf_maiden_check
	}
}

# for in-law relation removal & checking spouse council refusal
on_divorce = {
	on_actions = {
		on_lmf_in_law_remove
		on_lmf_spouse_council_check
	}
}

# checking spouse council refusal & marital bed refusal
on_remove_relation_rival = {
	on_actions = {
		on_lmf_spouse_council_relation_check
		on_lmf_marital_bed_check
	}
}

on_remove_relation_nemesis = {
	on_actions = {
		on_lmf_spouse_council_relation_check
		on_lmf_marital_bed_check
	}
}

# for the LMF army events check
on_army_monthly = {
	on_actions = {
		on_lmf_army_event_check
	}
}

# for checking changes needed by faith change
on_character_faith_change = {
	on_actions = {
		on_lmf_faith_change_bastard_check
		on_lmf_faith_change_oath_check
	}
}

# for double-checking AI lover pairs
on_set_relation_lover = {
	on_actions = {
		on_lmf_lover_aicheck
	}
}

	