on_actions = {
	
	on_startup = {
		effect = {
			if = {
				limit = { has_global_flag = rt56rp_gr_musictriggers_gflag }
				#limit = { NOT = { has_country_flag = triggers_disabled } }
				play_song = BeforeTheStorm
			}
		}
	}
	
	on_monthly = {
		effect = {
			if = {
				limit = { has_global_flag = rt56rp_gr_musictriggers_gflag }

				if = {
					limit = { has_variable = warTime }
					add_to_variable = { var = warTime value = 1 }
				}
			}
		}
	}

	

	on_justifying_wargoal_pulse = {
		effect = {
			if = {
				limit = { has_global_flag = rt56rp_gr_musictriggers_gflag }

				if = {	
					limit = {
						NOT = { has_country_flag = justification }
						NOT = { has_country_flag = triggers_disabled }
					}
					scoped_play_song = Preperations
					set_country_flag = justification
				}
			}
		}
	}
	
	on_war_relation_added = {
		effect = {
			if = {
				limit = { has_global_flag = rt56rp_gr_musictriggers_gflag }

				if = {
					limit = {
						is_ai = no
						FROM = { is_ai = no }
						set_temp_variable = { total_factories = num_of_factories }
						all_of_scopes = {
							array = allies
							add_to_temp_variable = { total_factories = num_of_factories }
						}
						check_variable = { total_factories > 250 }

						set_temp_variable = { total_factories = FROM.num_of_factories }
						all_of_scopes = {
							array = FROM.allies
							add_to_temp_variable = { total_factories = num_of_factories }
						}
						check_variable = { total_factories > 250 }

						NOT = { has_global_flag = JDPlayed }
						NOT = { has_country_flag = triggers_disabled }
					}
					play_song = JudgementDay
					ROOT = { set_country_flag = major_war }
					FROM = { set_country_flag = major_war }
					set_global_flag = JDPlayed
				}
				else_if = {
					limit = { 
						is_ai = no
						FROM = { is_ai = no }
						set_temp_variable = { total_factories = num_of_factories }
						all_of_scopes = {
							array = allies
							add_to_temp_variable = { total_factories = num_of_factories }
						}
						check_variable = { total_factories > 250 }

						set_temp_variable = { total_factories = FROM.num_of_factories }
						all_of_scopes = {
							array = FROM.allies
							add_to_temp_variable = { total_factories = num_of_factories }
						}
						check_variable = { total_factories > 250 }
						
						has_global_flag = JDPlayed
						NOT = { has_country_flag = triggers_disabled }
					}
					scoped_play_song = JudgementDay
					ROOT = { set_country_flag = major_war }
					FROM = { set_country_flag = major_war }
				}
			}
		}
	}

	on_war_relation_added = {
		effect = {
			if = {
				limit = { has_global_flag = rt56rp_gr_musictriggers_gflag }

				if = {
					limit = {
						is_ai = no
						FROM = { is_ai = no }
						set_temp_variable = { total_factories = num_of_factories }
						all_of_scopes = {
							array = allies
							add_to_temp_variable = { total_factories = num_of_factories }
						}
						check_variable = { total_factories > 125 }

						set_temp_variable = { total_factories = FROM.num_of_factories }
						all_of_scopes = {
							array = FROM.allies
							add_to_temp_variable = { total_factories = num_of_factories }
						}
						check_variable = { total_factories > 125 }

						NOT = { has_country_flag = major_war }
						NOT = { has_global_flag = DaybreakPlayed }
						NOT = { has_country_flag = triggers_disabled }
					}
					play_song = Daybreak
					ROOT = { set_country_flag = medium_war }
					FROM = { set_country_flag = medium_war }
					set_global_flag = DaybreakPlayed
				}
				else_if = {
					limit = {
						is_ai = no
						FROM = { is_ai = no }
						set_temp_variable = { total_factories = num_of_factories }
						all_of_scopes = {
							array = allies
							add_to_temp_variable = { total_factories = num_of_factories }
						}
						check_variable = { total_factories > 125 }

						set_temp_variable = { total_factories = FROM.num_of_factories }
						all_of_scopes = {
							array = FROM.allies
							add_to_temp_variable = { total_factories = num_of_factories }
						}
						check_variable = { total_factories > 125 }

						NOT = { has_country_flag = major_war }
						has_global_flag = DaybreakPlayed 
						NOT = { has_country_flag = triggers_disabled }
					}
					scoped_play_song = Daybreak
					ROOT = { set_country_flag = medium_war }
					FROM = { set_country_flag = medium_war }
				}
			}
		}
	}

	on_war = {
		effect = {
			if = {
				limit = { has_global_flag = rt56rp_gr_musictriggers_gflag }

				if = {
					limit = {
						NOT = {
							has_country_flag = major_war
							has_country_flag = medium_war
						}
						NOT = { has_country_flag = triggers_disabled }
					}		
					scoped_play_song = Invasion
				}
				set_variable = {warTime = 0}
				clr_country_flag = justification
				if = { 
					limit = {
						tag = SPR
						NOT = {has_country_flag = SCWFIRE}
					}
				play_song = Proxy
				set_country_flag = SCWFIRE
				}
			}
		}
	}

	on_peace = { 
		effect = {
			if = {
				limit = { has_global_flag = rt56rp_gr_musictriggers_gflag }

				if = {
					limit = { has_country_flag = major_war }
					clr_country_flag = major_war
				}
				if = {
					limit = { has_country_flag = medium_war }
					clr_country_flag = medium_war
				}
				if = {
					limit = {
						check_variable = { warTime > 5 } 
						NOT = { has_country_flag = triggers_disabled }
					}
					scoped_play_song = InOurTime
				}
				clear_variable = warTime
			}
		}
	}
	
	on_join_faction = {
		effect = {
			if = {
				limit = { has_global_flag = rt56rp_gr_musictriggers_gflag }

				if = {
					limit = {
						NOT = {has_country_flag = PlayedAlliances}
						NOT = { has_country_flag = triggers_disabled }
					}
					scoped_play_song = Alliances
					set_country_flag = PlayedAlliances
				}
			}
		}
	}

	on_create_faction = {
		effect = {
			if = {
				limit = { has_global_flag = rt56rp_gr_musictriggers_gflag }

				if = {
					limit = {
						NOT = {has_country_flag = PlayedAlliances}
						NOT = { has_country_flag = triggers_disabled }
					}
					scoped_play_song = Alliances
					set_country_flag = PlayedAlliances
				}
			}
		}
	}
	
	on_offer_join_faction = {
		effect = {
			if = {
				limit = { has_global_flag = rt56rp_gr_musictriggers_gflag }

				if = {
					limit = {
						NOT = {has_country_flag = PlayedAlliances}
						NOT = { has_country_flag = triggers_disabled }
					}
					scoped_play_song = Alliances
					set_country_flag = PlayedAlliances
				}
			}
		}
	}
	
	on_send_volunteers = {
		effect = {
			if = {
				limit = { has_global_flag = rt56rp_gr_musictriggers_gflag }

				if = {
					limit = {
						NOT = {has_country_flag = first_volunteer_sent }
						NOT = { has_country_flag = triggers_disabled }
					}
					scoped_play_song = Intervention
					set_country_flag = first_volunteer_sent
				}
			}
		}
	}
	
	on_capitulation	= {
		effect = {
			if = {
				limit = { has_global_flag = rt56rp_gr_musictriggers_gflag }

				if = {
					limit = {
						NOT = { has_country_flag = triggers_disabled } 
						has_war = yes
					}
					scoped_play_song = NotQuiteYet
				}
			}
		}
	}

	on_uncapitulation = {
		effect = {
			if = {
				limit = { has_global_flag = rt56rp_gr_musictriggers_gflag }

				if = {
					limit = {
						NOT = { has_country_flag = triggers_disabled }
						has_war = yes
						OR = {
							num_of_owned_factories > 50
							is_ai = no
						}
					}
					every_country = {
						limit = {
							is_in_faction_with = ROOT 
							NOT = { has_country_flag = played_turning_point } 
						}
						scoped_play_song = Liberation
						set_country_flag = played_turning_point
					}
				}
				else_if = {
					limit = { 
						NOT = { has_country_flag = triggers_disabled } 
						has_war = yes 
					}
					scoped_play_song = Liberation
				}
			}
		}
	}
}